@vibe/core 3.16.0-alpha-02eba.0 → 3.16.0
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/components/Menu/MenuItem/MenuItem.d.ts +0 -8
- package/dist/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.d.ts +1 -1
- package/dist/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.types.d.ts +1 -2
- package/dist/hooks/usePopover.d.ts +1 -2
- package/dist/mocked_classnames/components/Menu/MenuItem/MenuItem.d.ts +0 -8
- package/dist/mocked_classnames/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.d.ts +1 -1
- package/dist/mocked_classnames/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.types.d.ts +1 -2
- package/dist/mocked_classnames/hooks/usePopover.d.ts +1 -2
- package/dist/mocked_classnames/src/components/Dialog/Dialog.js +1 -1
- package/dist/mocked_classnames/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/mocked_classnames/src/components/Menu/MenuItem/MenuItem.js.map +1 -1
- package/dist/mocked_classnames/src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.js +1 -1
- package/dist/mocked_classnames/src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.js.map +1 -1
- package/dist/mocked_classnames/src/hooks/usePopover.js +1 -1
- package/dist/mocked_classnames/src/hooks/usePopover.js.map +1 -1
- package/dist/src/components/Dialog/Dialog.js +1 -1
- package/dist/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/src/components/Menu/MenuItem/MenuItem.js.map +1 -1
- package/dist/src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.js +1 -1
- package/dist/src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.js.map +1 -1
- package/dist/src/hooks/usePopover.js +1 -1
- package/dist/src/hooks/usePopover.js.map +1 -1
- package/package.json +3 -3
- package/dist/components/Dialog/modifiers/observeContentResizeModifier.d.ts +0 -2
- package/dist/mocked_classnames/components/Dialog/modifiers/observeContentResizeModifier.d.ts +0 -2
- package/dist/mocked_classnames/src/components/Dialog/modifiers/observeContentResizeModifier.js +0 -2
- package/dist/mocked_classnames/src/components/Dialog/modifiers/observeContentResizeModifier.js.map +0 -1
- package/dist/src/components/Dialog/modifiers/observeContentResizeModifier.js +0 -2
- package/dist/src/components/Dialog/modifiers/observeContentResizeModifier.js.map +0 -1
|
@@ -49,14 +49,6 @@ export interface MenuItemProps extends VibeComponentProps {
|
|
|
49
49
|
splitMenuItem?: boolean;
|
|
50
50
|
"aria-label"?: AriaAttributes["aria-label"];
|
|
51
51
|
submenuPosition?: SubmenuPosition;
|
|
52
|
-
/**
|
|
53
|
-
* Enables the observation of content resize for the menu item's submenu.
|
|
54
|
-
* When set to `true`, a ResizeObserver is attached to the popper content,
|
|
55
|
-
* automatically triggering repositioning when the size of the submenu's content changes.
|
|
56
|
-
*
|
|
57
|
-
* This is useful for when submenu's content may grow or shrink without a re-render being triggered.
|
|
58
|
-
*/
|
|
59
|
-
observeSubMenuContentResize?: boolean;
|
|
60
52
|
}
|
|
61
53
|
export interface MenuItemTitleComponentProps extends Omit<MenuItemProps, "title"> {
|
|
62
54
|
title: ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MenuItemSubMenuProps } from "./MenuItemSubMenu.types";
|
|
3
|
-
declare const MenuItemSubMenu: ({ anchorRef, open, autoFocusOnMount, onClose, children, submenuPosition
|
|
3
|
+
declare const MenuItemSubMenu: ({ anchorRef, open, autoFocusOnMount, onClose, children, submenuPosition }: MenuItemSubMenuProps) => React.JSX.Element;
|
|
4
4
|
export default MenuItemSubMenu;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { CloseMenuOption, MenuChild } from "../../../Menu/MenuConstants";
|
|
3
3
|
import { SubmenuPosition } from "../../MenuItem.types";
|
|
4
|
-
|
|
5
|
-
export interface MenuItemSubMenuProps extends Pick<MenuItemProps, "observeSubMenuContentResize"> {
|
|
4
|
+
export interface MenuItemSubMenuProps {
|
|
6
5
|
/**
|
|
7
6
|
* Reference to the anchor element that the submenu is related to. This is used to position the submenu correctly relative to the parent menu item.
|
|
8
7
|
*/
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Placement } from "./popoverConstants";
|
|
3
|
-
export default function usePopover(referenceElement: HTMLElement, popperElement: HTMLElement, { isOpen, placement
|
|
3
|
+
export default function usePopover(referenceElement: HTMLElement, popperElement: HTMLElement, { isOpen, placement }: {
|
|
4
4
|
isOpen?: boolean;
|
|
5
5
|
placement?: Placement;
|
|
6
|
-
observeContentResize?: boolean;
|
|
7
6
|
}): {
|
|
8
7
|
styles: {
|
|
9
8
|
[key: string]: import("react").CSSProperties;
|
|
@@ -49,14 +49,6 @@ export interface MenuItemProps extends VibeComponentProps {
|
|
|
49
49
|
splitMenuItem?: boolean;
|
|
50
50
|
"aria-label"?: AriaAttributes["aria-label"];
|
|
51
51
|
submenuPosition?: SubmenuPosition;
|
|
52
|
-
/**
|
|
53
|
-
* Enables the observation of content resize for the menu item's submenu.
|
|
54
|
-
* When set to `true`, a ResizeObserver is attached to the popper content,
|
|
55
|
-
* automatically triggering repositioning when the size of the submenu's content changes.
|
|
56
|
-
*
|
|
57
|
-
* This is useful for when submenu's content may grow or shrink without a re-render being triggered.
|
|
58
|
-
*/
|
|
59
|
-
observeSubMenuContentResize?: boolean;
|
|
60
52
|
}
|
|
61
53
|
export interface MenuItemTitleComponentProps extends Omit<MenuItemProps, "title"> {
|
|
62
54
|
title: ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MenuItemSubMenuProps } from "./MenuItemSubMenu.types";
|
|
3
|
-
declare const MenuItemSubMenu: ({ anchorRef, open, autoFocusOnMount, onClose, children, submenuPosition
|
|
3
|
+
declare const MenuItemSubMenu: ({ anchorRef, open, autoFocusOnMount, onClose, children, submenuPosition }: MenuItemSubMenuProps) => React.JSX.Element;
|
|
4
4
|
export default MenuItemSubMenu;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { CloseMenuOption, MenuChild } from "../../../Menu/MenuConstants";
|
|
3
3
|
import { SubmenuPosition } from "../../MenuItem.types";
|
|
4
|
-
|
|
5
|
-
export interface MenuItemSubMenuProps extends Pick<MenuItemProps, "observeSubMenuContentResize"> {
|
|
4
|
+
export interface MenuItemSubMenuProps {
|
|
6
5
|
/**
|
|
7
6
|
* Reference to the anchor element that the submenu is related to. This is used to position the submenu correctly relative to the parent menu item.
|
|
8
7
|
*/
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Placement } from "./popoverConstants";
|
|
3
|
-
export default function usePopover(referenceElement: HTMLElement, popperElement: HTMLElement, { isOpen, placement
|
|
3
|
+
export default function usePopover(referenceElement: HTMLElement, popperElement: HTMLElement, { isOpen, placement }: {
|
|
4
4
|
isOpen?: boolean;
|
|
5
5
|
placement?: Placement;
|
|
6
|
-
observeContentResize?: boolean;
|
|
7
6
|
}): {
|
|
8
7
|
styles: {
|
|
9
8
|
[key: string]: import("react").CSSProperties;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{inherits as e,createClass as n,toConsumableArray as o,classCallCheck as t,callSuper as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import s from"classnames";import r,{PureComponent as a}from"react";import{createPortal as l}from"react-dom";import{Manager as u,Reference as d,Popper as h}from"react-popper";import{isFunction as c}from"lodash-es";import{NOOP as p,convertToArray as m,chainFunctions as
|
|
1
|
+
import{inherits as e,createClass as n,toConsumableArray as o,classCallCheck as t,callSuper as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import s from"classnames";import r,{PureComponent as a}from"react";import{createPortal as l}from"react-dom";import{Manager as u,Reference as d,Popper as h}from"react-popper";import{isFunction as c}from"lodash-es";import{NOOP as p,convertToArray as m,chainFunctions as f}from"../../utils/function-utils.js";import{DialogContent as v}from"./DialogContent/DialogContent.js";import{isInsideClass as g}from"../../utils/dom-utils.js";import{Refable as D}from"../Refable/Refable.js";import{HideShowEvent as y,DialogPosition as w,AnimationType as E}from"./DialogConstants.js";import k from"./Dialog.module.scss.js";import{getTestId as C,ComponentDefaultTestId as T}from"../../tests/testIds.js";import b from"../LayerProvider/LayerContext.js";import{isClient as S}from"../../utils/ssr-utils.js";var O=function(p){function f(e){var n;return t(this,f),(n=i(this,f,[e])).state={shouldUseDerivedStateFromProps:e.useDerivedStateFromProps,isOpen:e.shouldShowOnMount},n.onMouseEnter=n.onMouseEnter.bind(n),n.onMouseLeave=n.onMouseLeave.bind(n),n.onMouseDown=n.onMouseDown.bind(n),n.onClick=n.onClick.bind(n),n.onFocus=n.onFocus.bind(n),n.onBlur=n.onBlur.bind(n),n.isShown=n.isShown.bind(n),n.onEsc=n.onEsc.bind(n),n.onClickOutside=n.onClickOutside.bind(n),n.onDialogEnter=n.onDialogEnter.bind(n),n.onDialogLeave=n.onDialogLeave.bind(n),n.getContainer=n.getContainer.bind(n),n.onContentClick=n.onContentClick.bind(n),n.onKeyDown=n.onKeyDown.bind(n),n.closeDialogOnEscape=n.closeDialogOnEscape.bind(n),n.onContextMenu=n.onContextMenu.bind(n),n.hideTimeout=null,n.showTimeout=null,n}return e(f,a),n(f,[{key:"closeDialogOnEscape",value:function(e){if(this.state.isOpen)switch(e.key){case"Escape":this.hideDialogIfNeeded(e,y.ESCAPE_KEY);break;case"Tab":this.handleEvent(y.TAB_KEY,e.target,e);break;case"Enter":this.handleEvent(y.ENTER,e.target,e)}}},{key:"componentDidMount",value:function(){var e=this.props,n=e.shouldCallbackOnMount,o=e.onDialogDidShow,t=this.state.isOpen;S()&&document.addEventListener("keyup",this.closeDialogOnEscape),n&&t&&o&&o()}},{key:"componentWillUnmount",value:function(){S()&&document.removeEventListener("keyup",this.closeDialogOnEscape)}},{key:"getContainer",value:function(){var e=document.querySelector(this.props.containerSelector);if(!(e&&e instanceof Element)){var n=this.context.layerRef;return(null==n?void 0:n.current)?n.current:document.body}return e}},{key:"showDialog",value:function(e,n){var o=this,t=this.props,i=t.instantShowAndHide,s=t.getDynamicShowDelay,r=t.showDelay,a=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).preventAnimation;if(s){var l=s();r=l.showDelay||0,a=a||l.preventAnimation}i?(this.onShowDialog(e,n),this.setState({isOpen:!0,preventAnimation:a}),this.showTimeout=null):this.showTimeout=setTimeout((function(){o.onShowDialog(e,n),o.showTimeout=null,o.setState({isOpen:!0,preventAnimation:a})}),r)}},{key:"onShowDialog",value:function(e,n){this.isShown()||(0,this.props.onDialogDidShow)(e,n)}},{key:"showDialogIfNeeded",value:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.props.disable||(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),this.showTimeout||this.showDialog(e,n,o))}},{key:"hideDialog",value:function(e,n){var o=this,t=this.props,i=t.hideDelay;t.instantShowAndHide?(this.onHideDialog(e,n),this.setState({isOpen:!1}),this.hideTimeout=null):this.hideTimeout=setTimeout((function(){o.onHideDialog(e,n),o.setState({isOpen:!1}),o.hideTimeout=null}),i)}},{key:"onHideDialog",value:function(e,n){var o=this.props.onDialogDidHide;o&&o(e,n)}},{key:"hideDialogIfNeeded",value:function(e,n){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),this.hideTimeout||this.hideDialog(e,n)}},{key:"handleEvent",value:function(e,n,o){var t=this.props,i=t.showTriggerIgnoreClass,s=t.hideTriggerIgnoreClass;return!this.isShowTrigger(e)||this.isShown()||g(n,i)?this.isHideTrigger(e)&&!g(n,s)?this.hideDialogIfNeeded(o,e):void 0:this.showDialogIfNeeded(o,e)}},{key:"isShown",value:function(){return this.state.isOpen||this.props.open}},{key:"isShowTrigger",value:function(e){var n=this.props,o=n.addKeyboardHideShowTriggersByDefault,t=m(n.showTrigger);return!(!o||"focus"!==e||-1>=t.indexOf("mouseenter"))||t.indexOf(e)>-1}},{key:"isHideTrigger",value:function(e){var n=this.props,o=n.addKeyboardHideShowTriggersByDefault,t=m(n.hideTrigger);return!(!o||"blur"!==e||-1>=t.indexOf("mouseleave"))||t.indexOf(e)>-1}},{key:"onMouseEnter",value:function(e){this.handleEvent("mouseenter",e.target,e)}},{key:"onMouseLeave",value:function(e){this.handleEvent("mouseleave",e.target,e)}},{key:"onClick",value:function(e){e.button||this.handleEvent("click",e.target,e)}},{key:"onKeyDown",value:function(e){"Enter"===e.key&&this.handleEvent("enter",e.target,e),"Tab"===e.key&&this.handleEvent("tab",e.target,e)}},{key:"onMouseDown",value:function(e){e.button||this.handleEvent("mousedown",e.target,e)}},{key:"onFocus",value:function(e){this.handleEvent("focus",e.target,e)}},{key:"onBlur",value:function(e){this.handleEvent("blur",e.relatedTarget,e)}},{key:"onEsc",value:function(e){this.handleEvent("esckey",e.target,e)}},{key:"onContextMenu",value:function(e){var n=this.isShown();(this.isShowTrigger("contextmenu")&&!n||this.isHideTrigger("contextmenu")&&n)&&e.preventDefault(),this.handleEvent("contextmenu",e.target,e)}},{key:"onClickOutside",value:function(e){var n=this.props.onClickOutside;this.handleEvent("clickoutside",e.target,e),n(e)}},{key:"onDialogEnter",value:function(e){this.props.showOnDialogEnter&&this.showDialogIfNeeded(e,"DialogEnter")}},{key:"onDialogLeave",value:function(e){this.props.showOnDialogEnter&&this.hideDialogIfNeeded(e,"DialogLeave")}},{key:"onContentClick",value:function(e){var n=this.props.onContentClick;this.handleEvent("onContentClick",e.target,e),n(e)}},{key:"render",value:function(){var e=this,n=this.props,t=n.wrapperClassName,i=n.content,a=n.startingEdge,p=n.children,m=n.preventAnimationOnMount,f=n.animationType,g=n.position,y=n.showDelay,w=n.moveBy,E=n.modifiers,b=n.tooltip,O=n.tooltipClassName,x=n.referenceWrapperClassName,H=n.zIndex,L=n.hideWhenReferenceHidden,A=n.disableContainerScroll,N=n.containerSelector,R=n.observeContentResize,I=this.state.preventAnimation,B=n["data-testid"]||C(T.DIALOG,n.id),j=m||I?void 0:f,P=c(i)?i():i;return P?r.createElement(u,null,r.createElement(d,null,(function(n){var o=n.ref;return r.createElement(D,{className:s(x),ref:o,onBlur:M("onBlur",e,e.props),onKeyDown:M("onKeyDown",e,e.props),onClick:M("onClick",e,e.props),onFocus:M("onFocus",e,e.props),onMouseDown:M("onMouseDown",e,e.props),onMouseEnter:M("onMouseEnter",e,e.props),onMouseLeave:M("onMouseLeave",e,e.props),onContextMenu:M("onContextMenu",e,e.props)},p)})),S()&&l(r.createElement(h,{placement:g,modifiers:[{name:"offset",options:{offset:[w.secondary,w.main]}},{name:"zIndex",enabled:!0,phase:"write",fn:function(e){var n=e.state;return H&&(n.styles.popper.zIndex=H+""),n}},{name:"rotator",enabled:!0,phase:"write",fn:function(e){var n=e.state;return n.styles.arrow?(n.styles.arrow.transform="".concat(n.styles.arrow.transform," rotate(45deg)"),n):n}},{name:"observeContentResize",enabled:R,phase:"beforeWrite",fn:function(){},effect:function(e){var n=e.state,o=e.instance,t=new ResizeObserver((function(){o.update()}));return t.observe(n.elements.popper),function(){t.disconnect()}}}].concat(o(E))},(function(n){var o=n.placement,i=n.style,l=n.ref,u=n.arrowProps,d=n.isReferenceHidden;if(!e.isShown()&&o)return null;if(L&&d){var h=new CustomEvent("onReferenceHidden");e.hideDialog(h,"onReferenceHidden")}return r.createElement(v,{"data-testid":B,isReferenceHidden:L&&d,onMouseEnter:e.onDialogEnter,onMouseLeave:e.onDialogLeave,onClickOutside:e.onClickOutside,onContextMenu:e.onContextMenu,onEsc:e.onEsc,animationType:j,position:o,wrapperClassName:t,startingEdge:a,isOpen:e.isShown(),showDelay:y,styleObject:i,ref:l,onClick:e.onContentClick,hasTooltip:!!b,containerSelector:N,disableContainerScroll:A},P,b&&r.createElement("div",{style:u.style,ref:u.ref,className:s(k.arrow,O),"data-placement":o}))})),this.getContainer())):p}}],[{key:"getDerivedStateFromProps",value:function(e,n){return n.shouldUseDerivedStateFromProps?{isOpen:e.isOpen}:null}}])}();function M(e,n,o){return f([o[e],n[e]],!0)}O.hideShowTriggers=y,O.positions=w,O.animationTypes=E,O.defaultProps={position:"top",modifiers:[],moveBy:{main:0,secondary:0},showDelay:100,hideDelay:100,showTrigger:O.hideShowTriggers.MOUSE_ENTER,hideTrigger:O.hideShowTriggers.MOUSE_LEAVE,showOnDialogEnter:!1,shouldShowOnMount:!1,disable:!1,open:!1,animationType:O.animationTypes.EXPAND,preventAnimationOnMount:!1,tooltip:!1,onDialogDidShow:p,onDialogDidHide:p,onClickOutside:p,onContentClick:p,useDerivedStateFromProps:!1,hideWhenReferenceHidden:!1,shouldCallbackOnMount:!1,instantShowAndHide:!1,addKeyboardHideShowTriggersByDefault:!1,observeContentResize:!1},O.contextType=b;export{O as default};
|
|
2
2
|
//# sourceMappingURL=Dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { PureComponent, ReactElement } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Manager, Modifier, Popper, Reference } from \"react-popper\";\nimport { isFunction } from \"lodash-es\";\nimport { chainFunctions, convertToArray, NOOP } from \"../../utils/function-utils\";\nimport { DialogContent } from \"./DialogContent/DialogContent\";\nimport { isInsideClass } from \"../../utils/dom-utils\";\nimport { Refable } from \"../Refable/Refable\";\nimport {\n AnimationType as AnimationTypeEnum,\n HideShowEvent as DialogTriggerEventEnum,\n DialogPosition as DialogPositionEnum\n} from \"./DialogConstants\";\nimport { VibeComponentProps } from \"../../types\";\nimport * as PopperJS from \"@popperjs/core\";\nimport styles from \"./Dialog.module.scss\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport { DialogAnimationType, DialogPosition, DialogTriggerEvent } from \"./Dialog.types\";\nimport LayerContext from \"../LayerProvider/LayerContext\";\nimport { isClient } from \"../../utils/ssr-utils\";\nimport { createObserveContentResizeModifier } from \"./modifiers/observeContentResizeModifier\";\n\nexport interface DialogProps extends VibeComponentProps {\n /**\n * A Classname to be added to <span> element which wraps the children\n */\n referenceWrapperClassName?: string;\n /**\n * Where the dialog should be in reference to the children,\n * Top, Left, Right, Bottom ...\n */\n position?: DialogPosition;\n /**\n * PopperJS Modifiers type\n * https://popper.js.org/docs/v2/modifiers/\n */\n modifiers?: Modifier<any>[];\n startingEdge?: string;\n /**\n * How much to move the dialog in relative to children\n * main is the axis in which the position is aligned to\n * secondary is the vertical axes to the position\n */\n moveBy?: { main?: number; secondary?: number };\n /**\n * how much delay should the Dialog wait until it should trigger the show in MS\n */\n showDelay?: number;\n /**\n * how much delay should the Dialog wait until it should trigger the hide in MS\n */\n hideDelay?: number;\n /**\n * an array of hide/show trigger -\n */\n showTrigger?: DialogTriggerEvent | DialogTriggerEvent[];\n /**\n * an array of hide/show trigger -\n */\n hideTrigger?: DialogTriggerEvent | DialogTriggerEvent[];\n /**\n * If true, prevents opened Dialog from closing on mouseEnter, and closes Dialog when mouse leaves it\n */\n showOnDialogEnter?: boolean;\n /**\n * Show the Dialog when the children are mounting\n */\n shouldShowOnMount?: boolean;\n /**\n * disable the opening of the dialog\n */\n disable?: boolean;\n /**\n * open is a controlled prop to open the dialog\n */\n open?: boolean;\n /**\n * used when state is derived from props\n */\n isOpen?: boolean;\n /**\n * if this class exists on the children the show trigger will be ignored\n */\n showTriggerIgnoreClass?: string | Array<string>;\n /**\n * if this class exists on the children the hide trigger will be ignored\n */\n hideTriggerIgnoreClass?: string | Array<string>;\n /**\n * Dialog animation type\n */\n animationType?: DialogAnimationType;\n /**\n * Classname to be added to the content container\n */\n wrapperClassName?: string;\n /**\n * Prevent Animation\n */\n preventAnimationOnMount?: boolean;\n /**\n * the container selector in which to append the dialog\n * for examples: \"body\" , \".my-class\", \"#my-id\"\n */\n containerSelector?: string;\n /**\n * should position the tooltip element\n * https://popper.js.org/docs/v2/modifiers/arrow/\n */\n tooltip?: boolean;\n /**\n * class name to add to the tooltip element\n */\n tooltipClassName?: string;\n /**\n * callback to be called when the dialog is shown\n */\n onDialogDidShow?: (event?: DialogEvent, eventName?: DialogTriggerEvent | string) => void;\n /**\n * callback to be called when the dialog is hidden\n */\n onDialogDidHide?: (event: DialogEvent, eventName: DialogTriggerEvent | string) => void;\n /**\n * callback to be called when click outside is being triggered\n */\n onClickOutside?: (event: React.MouseEvent) => void;\n /**\n * callback to be called when click on the content is being triggered\n */\n onContentClick?: (event: React.MouseEvent) => void;\n /**\n * z-index to add to the dialog\n */\n zIndex?: number;\n useDerivedStateFromProps?: boolean;\n /**\n * Make the dialog disappear when the element it is attached to becomes hidden\n */\n hideWhenReferenceHidden?: boolean;\n shouldCallbackOnMount?: boolean;\n instantShowAndHide?: boolean;\n getDynamicShowDelay?: () => { showDelay: number; preventAnimation: boolean };\n content?: (() => JSX.Element) | JSX.Element;\n /**\n * The element where we will position the dialog beside.\n */\n children?: ReactElement | ReactElement[] | string;\n /**\n * Treats keyboard focus/blur events as mouse-enter/mouse-leave events\n */\n addKeyboardHideShowTriggersByDefault?: boolean;\n /**\n * If true disable the scroll for the containerSelector element.\n * If string use it as selector to prevent scroll.\n */\n disableContainerScroll?: boolean | string;\n /**\n * Enables the observation of content resize for the popper element.\n * When set to `true`, a ResizeObserver is attached to the popper content,\n * automatically triggering repositioning when the size of the content changes.\n *\n * This is useful for dialogs, tooltips, or popovers with dynamic content\n * that may grow or shrink without a re-render being triggered.\n */\n observeContentResize?: boolean;\n}\n\nexport interface DialogState {\n isOpen?: boolean;\n shouldUseDerivedStateFromProps?: boolean;\n preventAnimation?: boolean;\n}\n\nexport type DialogEvent = React.MouseEvent | React.KeyboardEvent | KeyboardEvent | React.FocusEvent | CustomEvent;\n\nexport default class Dialog extends PureComponent<DialogProps, DialogState> {\n static hideShowTriggers = DialogTriggerEventEnum;\n static positions = DialogPositionEnum;\n static animationTypes = AnimationTypeEnum;\n static defaultProps = {\n position: \"top\",\n modifiers: [] as Modifier<any>[],\n moveBy: { main: 0, secondary: 0 },\n showDelay: 100,\n hideDelay: 100,\n showTrigger: Dialog.hideShowTriggers.MOUSE_ENTER,\n hideTrigger: Dialog.hideShowTriggers.MOUSE_LEAVE,\n showOnDialogEnter: false,\n shouldShowOnMount: false,\n disable: false,\n open: false,\n animationType: Dialog.animationTypes.EXPAND,\n preventAnimationOnMount: false,\n tooltip: false,\n onDialogDidShow: NOOP,\n onDialogDidHide: NOOP,\n onClickOutside: NOOP,\n onContentClick: NOOP,\n useDerivedStateFromProps: false,\n hideWhenReferenceHidden: false,\n shouldCallbackOnMount: false,\n instantShowAndHide: false,\n addKeyboardHideShowTriggersByDefault: false,\n observeContentResize: false\n };\n private showTimeout: NodeJS.Timeout;\n private hideTimeout: NodeJS.Timeout;\n context!: React.ContextType<typeof LayerContext>;\n\n constructor(props: DialogProps) {\n super(props);\n this.state = {\n shouldUseDerivedStateFromProps: props.useDerivedStateFromProps,\n isOpen: props.shouldShowOnMount\n };\n\n // Binding section.\n this.onMouseEnter = this.onMouseEnter.bind(this);\n this.onMouseLeave = this.onMouseLeave.bind(this);\n this.onMouseDown = this.onMouseDown.bind(this);\n this.onClick = this.onClick.bind(this);\n this.onFocus = this.onFocus.bind(this);\n this.onBlur = this.onBlur.bind(this);\n this.isShown = this.isShown.bind(this);\n this.onEsc = this.onEsc.bind(this);\n this.onClickOutside = this.onClickOutside.bind(this);\n this.onDialogEnter = this.onDialogEnter.bind(this);\n this.onDialogLeave = this.onDialogLeave.bind(this);\n this.getContainer = this.getContainer.bind(this);\n this.onContentClick = this.onContentClick.bind(this);\n this.onKeyDown = this.onKeyDown.bind(this);\n this.closeDialogOnEscape = this.closeDialogOnEscape.bind(this);\n this.onContextMenu = this.onContextMenu.bind(this);\n\n // Timeouts\n this.hideTimeout = null;\n this.showTimeout = null;\n }\n\n closeDialogOnEscape(event: KeyboardEvent) {\n const { isOpen } = this.state;\n if (!isOpen) {\n return;\n }\n switch (event.key) {\n case \"Escape\":\n this.hideDialogIfNeeded(event, DialogTriggerEventEnum.ESCAPE_KEY);\n break;\n case \"Tab\":\n this.handleEvent(DialogTriggerEventEnum.TAB_KEY, event.target, event);\n break;\n case \"Enter\":\n this.handleEvent(DialogTriggerEventEnum.ENTER, event.target, event);\n break;\n default:\n break;\n }\n }\n\n componentDidMount() {\n const { shouldCallbackOnMount, onDialogDidShow } = this.props;\n const { isOpen } = this.state;\n if (isClient()) {\n document.addEventListener(\"keyup\", this.closeDialogOnEscape);\n }\n if (shouldCallbackOnMount && isOpen) {\n onDialogDidShow && onDialogDidShow();\n }\n }\n\n componentWillUnmount() {\n if (isClient()) {\n document.removeEventListener(\"keyup\", this.closeDialogOnEscape);\n }\n }\n\n static getDerivedStateFromProps(nextProps: DialogProps, state: DialogState): DialogState {\n if (state.shouldUseDerivedStateFromProps) {\n return { isOpen: nextProps.isOpen };\n }\n return null;\n }\n\n getContainer() {\n const { containerSelector } = this.props;\n const containerElement = document.querySelector(containerSelector);\n if (!containerElement || !(containerElement instanceof Element)) {\n const { layerRef } = this.context;\n if (layerRef?.current) {\n return layerRef.current;\n }\n return document.body;\n }\n return containerElement;\n }\n\n showDialog(event: DialogEvent, eventName: DialogTriggerEvent | string, options: { preventAnimation?: boolean } = {}) {\n const { showDelay, instantShowAndHide, getDynamicShowDelay } = this.props;\n let finalShowDelay = showDelay;\n let preventAnimation = options.preventAnimation;\n if (getDynamicShowDelay) {\n const dynamicDelayObj = getDynamicShowDelay();\n finalShowDelay = dynamicDelayObj.showDelay || 0;\n preventAnimation = preventAnimation || dynamicDelayObj.preventAnimation;\n }\n\n if (instantShowAndHide) {\n this.onShowDialog(event, eventName);\n this.setState({ isOpen: true, preventAnimation });\n this.showTimeout = null;\n } else {\n this.showTimeout = setTimeout(() => {\n this.onShowDialog(event, eventName);\n this.showTimeout = null;\n this.setState({ isOpen: true, preventAnimation });\n }, finalShowDelay);\n }\n }\n\n onShowDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n if (this.isShown()) return;\n const { onDialogDidShow } = this.props;\n onDialogDidShow(event, eventName);\n }\n\n showDialogIfNeeded(event: DialogEvent, eventName: DialogTriggerEvent | string, options = {}) {\n const { disable } = this.props;\n if (disable) {\n return;\n }\n\n if (this.hideTimeout) {\n clearTimeout(this.hideTimeout);\n this.hideTimeout = null;\n }\n\n if (!this.showTimeout) {\n this.showDialog(event, eventName, options);\n }\n }\n\n hideDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n const { hideDelay, instantShowAndHide } = this.props;\n if (instantShowAndHide) {\n this.onHideDialog(event, eventName);\n this.setState({ isOpen: false });\n this.hideTimeout = null;\n } else {\n this.hideTimeout = setTimeout(() => {\n this.onHideDialog(event, eventName);\n this.setState({ isOpen: false });\n this.hideTimeout = null;\n }, hideDelay);\n }\n }\n\n onHideDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n const { onDialogDidHide } = this.props;\n if (onDialogDidHide) onDialogDidHide(event, eventName);\n }\n\n hideDialogIfNeeded(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n if (this.showTimeout) {\n clearTimeout(this.showTimeout);\n this.showTimeout = null;\n }\n\n if (this.hideTimeout) {\n return;\n }\n this.hideDialog(event, eventName);\n }\n\n handleEvent(eventName: DialogTriggerEvent, target: EventTarget, event: DialogEvent) {\n const { showTriggerIgnoreClass, hideTriggerIgnoreClass } = this.props;\n if (\n this.isShowTrigger(eventName) &&\n !this.isShown() &&\n !isInsideClass(target as HTMLElement, showTriggerIgnoreClass)\n ) {\n return this.showDialogIfNeeded(event, eventName);\n }\n\n if (this.isHideTrigger(eventName) && !isInsideClass(target as HTMLElement, hideTriggerIgnoreClass)) {\n return this.hideDialogIfNeeded(event, eventName);\n }\n }\n\n isShown() {\n const { isOpen } = this.state;\n const { open } = this.props;\n\n return isOpen || open;\n }\n\n isShowTrigger(eventName: DialogTriggerEvent) {\n const { showTrigger, addKeyboardHideShowTriggersByDefault } = this.props;\n const showTriggersArray = convertToArray(showTrigger);\n\n if (addKeyboardHideShowTriggersByDefault) {\n if (eventName === \"focus\" && showTriggersArray.indexOf(\"mouseenter\") > -1) {\n return true;\n }\n }\n\n return showTriggersArray.indexOf(eventName) > -1;\n }\n\n isHideTrigger(eventName: DialogTriggerEvent) {\n const { hideTrigger, addKeyboardHideShowTriggersByDefault } = this.props;\n const hideTriggersArray = convertToArray(hideTrigger);\n\n if (addKeyboardHideShowTriggersByDefault) {\n if (eventName === \"blur\" && hideTriggersArray.indexOf(\"mouseleave\") > -1) {\n return true;\n }\n }\n\n return hideTriggersArray.indexOf(eventName) > -1;\n }\n\n onMouseEnter(e: React.MouseEvent) {\n this.handleEvent(\"mouseenter\", e.target, e);\n }\n\n onMouseLeave(e: React.MouseEvent) {\n this.handleEvent(\"mouseleave\", e.target, e);\n }\n\n onClick(e: React.MouseEvent) {\n if (e.button) return;\n this.handleEvent(\"click\", e.target, e);\n }\n\n onKeyDown(event: React.KeyboardEvent) {\n if (event.key === \"Enter\") {\n this.handleEvent(\"enter\", event.target, event);\n }\n\n if (event.key === \"Tab\") {\n this.handleEvent(\"tab\", event.target, event);\n }\n }\n\n onMouseDown(e: React.MouseEvent) {\n if (e.button) return;\n this.handleEvent(\"mousedown\", e.target, e);\n }\n\n onFocus(e: React.FocusEvent) {\n this.handleEvent(\"focus\", e.target, e);\n }\n\n onBlur(e: React.FocusEvent) {\n this.handleEvent(\"blur\", e.relatedTarget, e);\n }\n\n onEsc(e: React.KeyboardEvent) {\n this.handleEvent(\"esckey\", e.target, e);\n }\n\n onContextMenu(e: React.MouseEvent) {\n const isShown = this.isShown();\n if ((this.isShowTrigger(\"contextmenu\") && !isShown) || (this.isHideTrigger(\"contextmenu\") && isShown)) {\n e.preventDefault();\n }\n this.handleEvent(\"contextmenu\", e.target, e);\n }\n\n onClickOutside(event: React.MouseEvent) {\n const { onClickOutside } = this.props;\n this.handleEvent(\"clickoutside\", event.target, event);\n onClickOutside(event);\n }\n\n onDialogEnter(event: React.MouseEvent) {\n const { showOnDialogEnter } = this.props;\n if (showOnDialogEnter) this.showDialogIfNeeded(event, \"DialogEnter\");\n }\n\n onDialogLeave(event: React.MouseEvent) {\n const { showOnDialogEnter } = this.props;\n if (showOnDialogEnter) this.hideDialogIfNeeded(event, \"DialogLeave\");\n }\n\n onContentClick(e: React.MouseEvent) {\n const { onContentClick } = this.props;\n this.handleEvent(\"onContentClick\", e.target, e);\n onContentClick(e);\n }\n\n render() {\n const {\n wrapperClassName,\n content,\n startingEdge,\n children,\n preventAnimationOnMount,\n animationType,\n position,\n showDelay,\n moveBy,\n modifiers,\n tooltip,\n tooltipClassName,\n referenceWrapperClassName,\n zIndex,\n hideWhenReferenceHidden,\n disableContainerScroll,\n containerSelector,\n observeContentResize,\n id,\n \"data-testid\": dataTestId\n } = this.props;\n const { preventAnimation } = this.state;\n const overrideDataTestId = dataTestId || getTestId(ComponentDefaultTestId.DIALOG, id);\n\n const animationTypeCalculated = preventAnimationOnMount || preventAnimation ? undefined : animationType;\n const contentRendered = isFunction(content) ? content() : content;\n\n if (!contentRendered) {\n return children;\n }\n return (\n <Manager>\n <Reference>\n {({ ref }) => {\n return (\n <Refable\n className={cx(referenceWrapperClassName)}\n ref={ref}\n onBlur={chainOnPropsAndInstance(\"onBlur\", this, this.props)}\n onKeyDown={chainOnPropsAndInstance(\"onKeyDown\", this, this.props)}\n onClick={chainOnPropsAndInstance(\"onClick\", this, this.props)}\n onFocus={chainOnPropsAndInstance(\"onFocus\", this, this.props)}\n onMouseDown={chainOnPropsAndInstance(\"onMouseDown\", this, this.props)}\n onMouseEnter={chainOnPropsAndInstance(\"onMouseEnter\", this, this.props)}\n onMouseLeave={chainOnPropsAndInstance(\"onMouseLeave\", this, this.props)}\n onContextMenu={chainOnPropsAndInstance(\"onContextMenu\", this, this.props)}\n >\n {children}\n </Refable>\n );\n }}\n </Reference>\n {isClient() &&\n createPortal(\n <Popper\n placement={position as unknown as PopperJS.Placement}\n modifiers={[\n {\n name: \"offset\",\n options: {\n offset: [moveBy.secondary, moveBy.main]\n }\n },\n {\n name: \"zIndex\",\n enabled: true,\n phase: \"write\",\n fn({ state }) {\n if (zIndex) {\n state.styles.popper.zIndex = String(zIndex);\n }\n return state;\n }\n },\n {\n name: \"rotator\",\n enabled: true,\n phase: \"write\",\n fn({ state }) {\n if (!state.styles.arrow) {\n return state;\n }\n // const reg = new RegExp(\n // /translate\\(([0-9].*)px, ([0-9].*)px\\)/\n // );\n // const transform = state.styles.arrow.transform;\n // const res = reg.exec(transform);\n // state.styles.popper.transformOrigin = `${100 -\n // res[1]}% ${100 - res[2]}%`;\n state.styles.arrow.transform = `${state.styles.arrow.transform} rotate(45deg)`;\n return state;\n }\n },\n createObserveContentResizeModifier(observeContentResize),\n ...modifiers\n ]}\n >\n {({ placement, style, ref, arrowProps, isReferenceHidden }) => {\n if (!this.isShown() && placement) {\n return null;\n }\n\n if (hideWhenReferenceHidden && isReferenceHidden) {\n const event = new CustomEvent(\"onReferenceHidden\");\n this.hideDialog(event, \"onReferenceHidden\");\n }\n\n return (\n <DialogContent\n data-testid={overrideDataTestId}\n isReferenceHidden={hideWhenReferenceHidden && isReferenceHidden}\n onMouseEnter={this.onDialogEnter}\n onMouseLeave={this.onDialogLeave}\n onClickOutside={this.onClickOutside}\n onContextMenu={this.onContextMenu}\n onEsc={this.onEsc}\n animationType={animationTypeCalculated}\n position={placement}\n wrapperClassName={wrapperClassName}\n startingEdge={startingEdge}\n isOpen={this.isShown()}\n showDelay={showDelay}\n styleObject={style}\n ref={ref}\n onClick={this.onContentClick}\n hasTooltip={!!tooltip}\n containerSelector={containerSelector}\n disableContainerScroll={disableContainerScroll}\n >\n {contentRendered}\n {tooltip && (\n <div\n style={arrowProps.style}\n ref={arrowProps.ref}\n className={cx(styles.arrow, tooltipClassName)}\n data-placement={placement}\n />\n )}\n </DialogContent>\n );\n }}\n </Popper>,\n this.getContainer()\n )}\n </Manager>\n );\n }\n}\n\nfunction chainOnPropsAndInstance(name: string, instance: Dialog, props: DialogProps) {\n // @ts-ignore\n return chainFunctions([props[name], instance[name]], true);\n}\n\nDialog.contextType = LayerContext;\n"],"names":["Dialog","_PureComponent","props","_this","_classCallCheck","_callSuper","state","shouldUseDerivedStateFromProps","useDerivedStateFromProps","isOpen","shouldShowOnMount","onMouseEnter","bind","onMouseLeave","onMouseDown","onClick","onFocus","onBlur","isShown","onEsc","onClickOutside","onDialogEnter","onDialogLeave","getContainer","onContentClick","onKeyDown","closeDialogOnEscape","onContextMenu","hideTimeout","showTimeout","_inherits","PureComponent","_createClass","key","value","event","this","hideDialogIfNeeded","DialogTriggerEventEnum","ESCAPE_KEY","handleEvent","TAB_KEY","target","ENTER","_this$props","shouldCallbackOnMount","onDialogDidShow","isClient","document","addEventListener","removeEventListener","containerElement","querySelector","containerSelector","Element","layerRef","context","current","body","eventName","_this2","_this$props2","instantShowAndHide","getDynamicShowDelay","finalShowDelay","showDelay","preventAnimation","dynamicDelayObj","onShowDialog","setState","setTimeout","options","arguments","length","undefined","disable","clearTimeout","showDialog","_this3","_this$props3","hideDelay","onHideDialog","onDialogDidHide","hideDialog","_this$props4","showTriggerIgnoreClass","hideTriggerIgnoreClass","isShowTrigger","isInsideClass","isHideTrigger","showDialogIfNeeded","open","_this$props5","addKeyboardHideShowTriggersByDefault","showTriggersArray","convertToArray","showTrigger","indexOf","_this$props6","hideTriggersArray","hideTrigger","e","button","relatedTarget","preventDefault","showOnDialogEnter","_this4","_this$props7","wrapperClassName","content","startingEdge","children","preventAnimationOnMount","animationType","position","moveBy","modifiers","tooltip","tooltipClassName","referenceWrapperClassName","zIndex","hideWhenReferenceHidden","disableContainerScroll","observeContentResize","overrideDataTestId","getTestId","ComponentDefaultTestId","DIALOG","id","animationTypeCalculated","contentRendered","isFunction","React","Manager","createElement","Reference","_ref","ref","Refable","className","cx","chainOnPropsAndInstance","createPortal","Popper","placement","name","offset","secondary","main","enabled","phase","fn","_ref2","styles","popper","String","_ref3","arrow","transform","concat","createObserveContentResizeModifier","_toConsumableArray","_ref4","style","arrowProps","isReferenceHidden","CustomEvent","DialogContent","styleObject","hasTooltip","nextProps","instance","chainFunctions","hideShowTriggers","positions","DialogPositionEnum","animationTypes","AnimationTypeEnum","defaultProps","MOUSE_ENTER","MOUSE_LEAVE","EXPAND","NOOP","contextType","LayerContext"],"mappings":"wgCAgLqBA,IAAAA,WAAOC,GAkC1B,SAAAD,EAAYE,GAAkB,IAAAC,EA2BJ,OA3BIC,OAAAJ,IAC5BG,EAAAE,EAAAL,KAAAA,GAAME,KACDI,MAAQ,CACXC,+BAAgCL,EAAMM,yBACtCC,OAAQP,EAAMQ,mBAIhBP,EAAKQ,aAAeR,EAAKQ,aAAaC,KAAIT,GAC1CA,EAAKU,aAAeV,EAAKU,aAAaD,KAAIT,GAC1CA,EAAKW,YAAcX,EAAKW,YAAYF,KAAIT,GACxCA,EAAKY,QAAUZ,EAAKY,QAAQH,KAAIT,GAChCA,EAAKa,QAAUb,EAAKa,QAAQJ,KAAIT,GAChCA,EAAKc,OAASd,EAAKc,OAAOL,KAAIT,GAC9BA,EAAKe,QAAUf,EAAKe,QAAQN,KAAIT,GAChCA,EAAKgB,MAAQhB,EAAKgB,MAAMP,KAAIT,GAC5BA,EAAKiB,eAAiBjB,EAAKiB,eAAeR,KAAIT,GAC9CA,EAAKkB,cAAgBlB,EAAKkB,cAAcT,KAAIT,GAC5CA,EAAKmB,cAAgBnB,EAAKmB,cAAcV,KAAIT,GAC5CA,EAAKoB,aAAepB,EAAKoB,aAAaX,KAAIT,GAC1CA,EAAKqB,eAAiBrB,EAAKqB,eAAeZ,KAAIT,GAC9CA,EAAKsB,UAAYtB,EAAKsB,UAAUb,KAAIT,GACpCA,EAAKuB,oBAAsBvB,EAAKuB,oBAAoBd,KAAIT,GACxDA,EAAKwB,cAAgBxB,EAAKwB,cAAcf,KAAIT,GAG5CA,EAAKyB,YAAc,KACn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","sources":["../../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { PureComponent, ReactElement } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Manager, Modifier, Popper, Reference } from \"react-popper\";\nimport { isFunction } from \"lodash-es\";\nimport { chainFunctions, convertToArray, NOOP } from \"../../utils/function-utils\";\nimport { DialogContent } from \"./DialogContent/DialogContent\";\nimport { isInsideClass } from \"../../utils/dom-utils\";\nimport { Refable } from \"../Refable/Refable\";\nimport {\n AnimationType as AnimationTypeEnum,\n HideShowEvent as DialogTriggerEventEnum,\n DialogPosition as DialogPositionEnum\n} from \"./DialogConstants\";\nimport { VibeComponentProps } from \"../../types\";\nimport * as PopperJS from \"@popperjs/core\";\nimport styles from \"./Dialog.module.scss\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport { DialogAnimationType, DialogPosition, DialogTriggerEvent } from \"./Dialog.types\";\nimport LayerContext from \"../LayerProvider/LayerContext\";\nimport { isClient } from \"../../utils/ssr-utils\";\n\nexport interface DialogProps extends VibeComponentProps {\n /**\n * A Classname to be added to <span> element which wraps the children\n */\n referenceWrapperClassName?: string;\n /**\n * Where the dialog should be in reference to the children,\n * Top, Left, Right, Bottom ...\n */\n position?: DialogPosition;\n /**\n * PopperJS Modifiers type\n * https://popper.js.org/docs/v2/modifiers/\n */\n modifiers?: Modifier<any>[];\n startingEdge?: string;\n /**\n * How much to move the dialog in relative to children\n * main is the axis in which the position is aligned to\n * secondary is the vertical axes to the position\n */\n moveBy?: { main?: number; secondary?: number };\n /**\n * how much delay should the Dialog wait until it should trigger the show in MS\n */\n showDelay?: number;\n /**\n * how much delay should the Dialog wait until it should trigger the hide in MS\n */\n hideDelay?: number;\n /**\n * an array of hide/show trigger -\n */\n showTrigger?: DialogTriggerEvent | DialogTriggerEvent[];\n /**\n * an array of hide/show trigger -\n */\n hideTrigger?: DialogTriggerEvent | DialogTriggerEvent[];\n /**\n * If true, prevents opened Dialog from closing on mouseEnter, and closes Dialog when mouse leaves it\n */\n showOnDialogEnter?: boolean;\n /**\n * Show the Dialog when the children are mounting\n */\n shouldShowOnMount?: boolean;\n /**\n * disable the opening of the dialog\n */\n disable?: boolean;\n /**\n * open is a controlled prop to open the dialog\n */\n open?: boolean;\n /**\n * used when state is derived from props\n */\n isOpen?: boolean;\n /**\n * if this class exists on the children the show trigger will be ignored\n */\n showTriggerIgnoreClass?: string | Array<string>;\n /**\n * if this class exists on the children the hide trigger will be ignored\n */\n hideTriggerIgnoreClass?: string | Array<string>;\n /**\n * Dialog animation type\n */\n animationType?: DialogAnimationType;\n /**\n * Classname to be added to the content container\n */\n wrapperClassName?: string;\n /**\n * Prevent Animation\n */\n preventAnimationOnMount?: boolean;\n /**\n * the container selector in which to append the dialog\n * for examples: \"body\" , \".my-class\", \"#my-id\"\n */\n containerSelector?: string;\n /**\n * should position the tooltip element\n * https://popper.js.org/docs/v2/modifiers/arrow/\n */\n tooltip?: boolean;\n /**\n * class name to add to the tooltip element\n */\n tooltipClassName?: string;\n /**\n * callback to be called when the dialog is shown\n */\n onDialogDidShow?: (event?: DialogEvent, eventName?: DialogTriggerEvent | string) => void;\n /**\n * callback to be called when the dialog is hidden\n */\n onDialogDidHide?: (event: DialogEvent, eventName: DialogTriggerEvent | string) => void;\n /**\n * callback to be called when click outside is being triggered\n */\n onClickOutside?: (event: React.MouseEvent) => void;\n /**\n * callback to be called when click on the content is being triggered\n */\n onContentClick?: (event: React.MouseEvent) => void;\n /**\n * z-index to add to the dialog\n */\n zIndex?: number;\n useDerivedStateFromProps?: boolean;\n /**\n * Make the dialog disappear when the element it is attached to becomes hidden\n */\n hideWhenReferenceHidden?: boolean;\n shouldCallbackOnMount?: boolean;\n instantShowAndHide?: boolean;\n getDynamicShowDelay?: () => { showDelay: number; preventAnimation: boolean };\n content?: (() => JSX.Element) | JSX.Element;\n /**\n * The element where we will position the dialog beside.\n */\n children?: ReactElement | ReactElement[] | string;\n /**\n * Treats keyboard focus/blur events as mouse-enter/mouse-leave events\n */\n addKeyboardHideShowTriggersByDefault?: boolean;\n /**\n * If true disable the scroll for the containerSelector element.\n * If string use it as selector to prevent scroll.\n */\n disableContainerScroll?: boolean | string;\n /**\n * Enables the observation of content resize for the popper element.\n * When set to `true`, a ResizeObserver is attached to the popper content,\n * automatically triggering repositioning when the size of the content changes.\n *\n * This is useful for dialogs, tooltips, or popovers with dynamic content\n * that may grow or shrink without a re-render being triggered.\n */\n observeContentResize?: boolean;\n}\n\nexport interface DialogState {\n isOpen?: boolean;\n shouldUseDerivedStateFromProps?: boolean;\n preventAnimation?: boolean;\n}\n\nexport type DialogEvent = React.MouseEvent | React.KeyboardEvent | KeyboardEvent | React.FocusEvent | CustomEvent;\n\nexport default class Dialog extends PureComponent<DialogProps, DialogState> {\n static hideShowTriggers = DialogTriggerEventEnum;\n static positions = DialogPositionEnum;\n static animationTypes = AnimationTypeEnum;\n static defaultProps = {\n position: \"top\",\n modifiers: [] as Modifier<any>[],\n moveBy: { main: 0, secondary: 0 },\n showDelay: 100,\n hideDelay: 100,\n showTrigger: Dialog.hideShowTriggers.MOUSE_ENTER,\n hideTrigger: Dialog.hideShowTriggers.MOUSE_LEAVE,\n showOnDialogEnter: false,\n shouldShowOnMount: false,\n disable: false,\n open: false,\n animationType: Dialog.animationTypes.EXPAND,\n preventAnimationOnMount: false,\n tooltip: false,\n onDialogDidShow: NOOP,\n onDialogDidHide: NOOP,\n onClickOutside: NOOP,\n onContentClick: NOOP,\n useDerivedStateFromProps: false,\n hideWhenReferenceHidden: false,\n shouldCallbackOnMount: false,\n instantShowAndHide: false,\n addKeyboardHideShowTriggersByDefault: false,\n observeContentResize: false\n };\n private showTimeout: NodeJS.Timeout;\n private hideTimeout: NodeJS.Timeout;\n context!: React.ContextType<typeof LayerContext>;\n\n constructor(props: DialogProps) {\n super(props);\n this.state = {\n shouldUseDerivedStateFromProps: props.useDerivedStateFromProps,\n isOpen: props.shouldShowOnMount\n };\n\n // Binding section.\n this.onMouseEnter = this.onMouseEnter.bind(this);\n this.onMouseLeave = this.onMouseLeave.bind(this);\n this.onMouseDown = this.onMouseDown.bind(this);\n this.onClick = this.onClick.bind(this);\n this.onFocus = this.onFocus.bind(this);\n this.onBlur = this.onBlur.bind(this);\n this.isShown = this.isShown.bind(this);\n this.onEsc = this.onEsc.bind(this);\n this.onClickOutside = this.onClickOutside.bind(this);\n this.onDialogEnter = this.onDialogEnter.bind(this);\n this.onDialogLeave = this.onDialogLeave.bind(this);\n this.getContainer = this.getContainer.bind(this);\n this.onContentClick = this.onContentClick.bind(this);\n this.onKeyDown = this.onKeyDown.bind(this);\n this.closeDialogOnEscape = this.closeDialogOnEscape.bind(this);\n this.onContextMenu = this.onContextMenu.bind(this);\n\n // Timeouts\n this.hideTimeout = null;\n this.showTimeout = null;\n }\n\n closeDialogOnEscape(event: KeyboardEvent) {\n const { isOpen } = this.state;\n if (!isOpen) {\n return;\n }\n switch (event.key) {\n case \"Escape\":\n this.hideDialogIfNeeded(event, DialogTriggerEventEnum.ESCAPE_KEY);\n break;\n case \"Tab\":\n this.handleEvent(DialogTriggerEventEnum.TAB_KEY, event.target, event);\n break;\n case \"Enter\":\n this.handleEvent(DialogTriggerEventEnum.ENTER, event.target, event);\n break;\n default:\n break;\n }\n }\n\n componentDidMount() {\n const { shouldCallbackOnMount, onDialogDidShow } = this.props;\n const { isOpen } = this.state;\n if (isClient()) {\n document.addEventListener(\"keyup\", this.closeDialogOnEscape);\n }\n if (shouldCallbackOnMount && isOpen) {\n onDialogDidShow && onDialogDidShow();\n }\n }\n\n componentWillUnmount() {\n if (isClient()) {\n document.removeEventListener(\"keyup\", this.closeDialogOnEscape);\n }\n }\n\n static getDerivedStateFromProps(nextProps: DialogProps, state: DialogState): DialogState {\n if (state.shouldUseDerivedStateFromProps) {\n return { isOpen: nextProps.isOpen };\n }\n return null;\n }\n\n getContainer() {\n const { containerSelector } = this.props;\n const containerElement = document.querySelector(containerSelector);\n if (!containerElement || !(containerElement instanceof Element)) {\n const { layerRef } = this.context;\n if (layerRef?.current) {\n return layerRef.current;\n }\n return document.body;\n }\n return containerElement;\n }\n\n showDialog(event: DialogEvent, eventName: DialogTriggerEvent | string, options: { preventAnimation?: boolean } = {}) {\n const { showDelay, instantShowAndHide, getDynamicShowDelay } = this.props;\n let finalShowDelay = showDelay;\n let preventAnimation = options.preventAnimation;\n if (getDynamicShowDelay) {\n const dynamicDelayObj = getDynamicShowDelay();\n finalShowDelay = dynamicDelayObj.showDelay || 0;\n preventAnimation = preventAnimation || dynamicDelayObj.preventAnimation;\n }\n\n if (instantShowAndHide) {\n this.onShowDialog(event, eventName);\n this.setState({ isOpen: true, preventAnimation });\n this.showTimeout = null;\n } else {\n this.showTimeout = setTimeout(() => {\n this.onShowDialog(event, eventName);\n this.showTimeout = null;\n this.setState({ isOpen: true, preventAnimation });\n }, finalShowDelay);\n }\n }\n\n onShowDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n if (this.isShown()) return;\n const { onDialogDidShow } = this.props;\n onDialogDidShow(event, eventName);\n }\n\n showDialogIfNeeded(event: DialogEvent, eventName: DialogTriggerEvent | string, options = {}) {\n const { disable } = this.props;\n if (disable) {\n return;\n }\n\n if (this.hideTimeout) {\n clearTimeout(this.hideTimeout);\n this.hideTimeout = null;\n }\n\n if (!this.showTimeout) {\n this.showDialog(event, eventName, options);\n }\n }\n\n hideDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n const { hideDelay, instantShowAndHide } = this.props;\n if (instantShowAndHide) {\n this.onHideDialog(event, eventName);\n this.setState({ isOpen: false });\n this.hideTimeout = null;\n } else {\n this.hideTimeout = setTimeout(() => {\n this.onHideDialog(event, eventName);\n this.setState({ isOpen: false });\n this.hideTimeout = null;\n }, hideDelay);\n }\n }\n\n onHideDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n const { onDialogDidHide } = this.props;\n if (onDialogDidHide) onDialogDidHide(event, eventName);\n }\n\n hideDialogIfNeeded(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n if (this.showTimeout) {\n clearTimeout(this.showTimeout);\n this.showTimeout = null;\n }\n\n if (this.hideTimeout) {\n return;\n }\n this.hideDialog(event, eventName);\n }\n\n handleEvent(eventName: DialogTriggerEvent, target: EventTarget, event: DialogEvent) {\n const { showTriggerIgnoreClass, hideTriggerIgnoreClass } = this.props;\n if (\n this.isShowTrigger(eventName) &&\n !this.isShown() &&\n !isInsideClass(target as HTMLElement, showTriggerIgnoreClass)\n ) {\n return this.showDialogIfNeeded(event, eventName);\n }\n\n if (this.isHideTrigger(eventName) && !isInsideClass(target as HTMLElement, hideTriggerIgnoreClass)) {\n return this.hideDialogIfNeeded(event, eventName);\n }\n }\n\n isShown() {\n const { isOpen } = this.state;\n const { open } = this.props;\n\n return isOpen || open;\n }\n\n isShowTrigger(eventName: DialogTriggerEvent) {\n const { showTrigger, addKeyboardHideShowTriggersByDefault } = this.props;\n const showTriggersArray = convertToArray(showTrigger);\n\n if (addKeyboardHideShowTriggersByDefault) {\n if (eventName === \"focus\" && showTriggersArray.indexOf(\"mouseenter\") > -1) {\n return true;\n }\n }\n\n return showTriggersArray.indexOf(eventName) > -1;\n }\n\n isHideTrigger(eventName: DialogTriggerEvent) {\n const { hideTrigger, addKeyboardHideShowTriggersByDefault } = this.props;\n const hideTriggersArray = convertToArray(hideTrigger);\n\n if (addKeyboardHideShowTriggersByDefault) {\n if (eventName === \"blur\" && hideTriggersArray.indexOf(\"mouseleave\") > -1) {\n return true;\n }\n }\n\n return hideTriggersArray.indexOf(eventName) > -1;\n }\n\n onMouseEnter(e: React.MouseEvent) {\n this.handleEvent(\"mouseenter\", e.target, e);\n }\n\n onMouseLeave(e: React.MouseEvent) {\n this.handleEvent(\"mouseleave\", e.target, e);\n }\n\n onClick(e: React.MouseEvent) {\n if (e.button) return;\n this.handleEvent(\"click\", e.target, e);\n }\n\n onKeyDown(event: React.KeyboardEvent) {\n if (event.key === \"Enter\") {\n this.handleEvent(\"enter\", event.target, event);\n }\n\n if (event.key === \"Tab\") {\n this.handleEvent(\"tab\", event.target, event);\n }\n }\n\n onMouseDown(e: React.MouseEvent) {\n if (e.button) return;\n this.handleEvent(\"mousedown\", e.target, e);\n }\n\n onFocus(e: React.FocusEvent) {\n this.handleEvent(\"focus\", e.target, e);\n }\n\n onBlur(e: React.FocusEvent) {\n this.handleEvent(\"blur\", e.relatedTarget, e);\n }\n\n onEsc(e: React.KeyboardEvent) {\n this.handleEvent(\"esckey\", e.target, e);\n }\n\n onContextMenu(e: React.MouseEvent) {\n const isShown = this.isShown();\n if ((this.isShowTrigger(\"contextmenu\") && !isShown) || (this.isHideTrigger(\"contextmenu\") && isShown)) {\n e.preventDefault();\n }\n this.handleEvent(\"contextmenu\", e.target, e);\n }\n\n onClickOutside(event: React.MouseEvent) {\n const { onClickOutside } = this.props;\n this.handleEvent(\"clickoutside\", event.target, event);\n onClickOutside(event);\n }\n\n onDialogEnter(event: React.MouseEvent) {\n const { showOnDialogEnter } = this.props;\n if (showOnDialogEnter) this.showDialogIfNeeded(event, \"DialogEnter\");\n }\n\n onDialogLeave(event: React.MouseEvent) {\n const { showOnDialogEnter } = this.props;\n if (showOnDialogEnter) this.hideDialogIfNeeded(event, \"DialogLeave\");\n }\n\n onContentClick(e: React.MouseEvent) {\n const { onContentClick } = this.props;\n this.handleEvent(\"onContentClick\", e.target, e);\n onContentClick(e);\n }\n\n render() {\n const {\n wrapperClassName,\n content,\n startingEdge,\n children,\n preventAnimationOnMount,\n animationType,\n position,\n showDelay,\n moveBy,\n modifiers,\n tooltip,\n tooltipClassName,\n referenceWrapperClassName,\n zIndex,\n hideWhenReferenceHidden,\n disableContainerScroll,\n containerSelector,\n observeContentResize,\n id,\n \"data-testid\": dataTestId\n } = this.props;\n const { preventAnimation } = this.state;\n const overrideDataTestId = dataTestId || getTestId(ComponentDefaultTestId.DIALOG, id);\n\n const animationTypeCalculated = preventAnimationOnMount || preventAnimation ? undefined : animationType;\n const contentRendered = isFunction(content) ? content() : content;\n\n if (!contentRendered) {\n return children;\n }\n return (\n <Manager>\n <Reference>\n {({ ref }) => {\n return (\n <Refable\n className={cx(referenceWrapperClassName)}\n ref={ref}\n onBlur={chainOnPropsAndInstance(\"onBlur\", this, this.props)}\n onKeyDown={chainOnPropsAndInstance(\"onKeyDown\", this, this.props)}\n onClick={chainOnPropsAndInstance(\"onClick\", this, this.props)}\n onFocus={chainOnPropsAndInstance(\"onFocus\", this, this.props)}\n onMouseDown={chainOnPropsAndInstance(\"onMouseDown\", this, this.props)}\n onMouseEnter={chainOnPropsAndInstance(\"onMouseEnter\", this, this.props)}\n onMouseLeave={chainOnPropsAndInstance(\"onMouseLeave\", this, this.props)}\n onContextMenu={chainOnPropsAndInstance(\"onContextMenu\", this, this.props)}\n >\n {children}\n </Refable>\n );\n }}\n </Reference>\n {isClient() &&\n createPortal(\n <Popper\n placement={position as unknown as PopperJS.Placement}\n modifiers={[\n {\n name: \"offset\",\n options: {\n offset: [moveBy.secondary, moveBy.main]\n }\n },\n {\n name: \"zIndex\",\n enabled: true,\n phase: \"write\",\n fn({ state }) {\n if (zIndex) {\n state.styles.popper.zIndex = String(zIndex);\n }\n return state;\n }\n },\n {\n name: \"rotator\",\n enabled: true,\n phase: \"write\",\n fn({ state }) {\n if (!state.styles.arrow) {\n return state;\n }\n // const reg = new RegExp(\n // /translate\\(([0-9].*)px, ([0-9].*)px\\)/\n // );\n // const transform = state.styles.arrow.transform;\n // const res = reg.exec(transform);\n // state.styles.popper.transformOrigin = `${100 -\n // res[1]}% ${100 - res[2]}%`;\n state.styles.arrow.transform = `${state.styles.arrow.transform} rotate(45deg)`;\n return state;\n }\n },\n {\n name: \"observeContentResize\",\n enabled: observeContentResize,\n phase: \"beforeWrite\",\n fn() {},\n effect({ state, instance }) {\n const observer = new ResizeObserver(() => {\n instance.update();\n });\n observer.observe(state.elements.popper);\n\n return () => {\n observer.disconnect();\n };\n }\n },\n ...modifiers\n ]}\n >\n {({ placement, style, ref, arrowProps, isReferenceHidden }) => {\n if (!this.isShown() && placement) {\n return null;\n }\n\n if (hideWhenReferenceHidden && isReferenceHidden) {\n const event = new CustomEvent(\"onReferenceHidden\");\n this.hideDialog(event, \"onReferenceHidden\");\n }\n\n return (\n <DialogContent\n data-testid={overrideDataTestId}\n isReferenceHidden={hideWhenReferenceHidden && isReferenceHidden}\n onMouseEnter={this.onDialogEnter}\n onMouseLeave={this.onDialogLeave}\n onClickOutside={this.onClickOutside}\n onContextMenu={this.onContextMenu}\n onEsc={this.onEsc}\n animationType={animationTypeCalculated}\n position={placement}\n wrapperClassName={wrapperClassName}\n startingEdge={startingEdge}\n isOpen={this.isShown()}\n showDelay={showDelay}\n styleObject={style}\n ref={ref}\n onClick={this.onContentClick}\n hasTooltip={!!tooltip}\n containerSelector={containerSelector}\n disableContainerScroll={disableContainerScroll}\n >\n {contentRendered}\n {tooltip && (\n <div\n style={arrowProps.style}\n ref={arrowProps.ref}\n className={cx(styles.arrow, tooltipClassName)}\n data-placement={placement}\n />\n )}\n </DialogContent>\n );\n }}\n </Popper>,\n this.getContainer()\n )}\n </Manager>\n );\n }\n}\n\nfunction chainOnPropsAndInstance(name: string, instance: Dialog, props: DialogProps) {\n // @ts-ignore\n return chainFunctions([props[name], instance[name]], true);\n}\n\nDialog.contextType = LayerContext;\n"],"names":["Dialog","_PureComponent","props","_this","_classCallCheck","_callSuper","state","shouldUseDerivedStateFromProps","useDerivedStateFromProps","isOpen","shouldShowOnMount","onMouseEnter","bind","onMouseLeave","onMouseDown","onClick","onFocus","onBlur","isShown","onEsc","onClickOutside","onDialogEnter","onDialogLeave","getContainer","onContentClick","onKeyDown","closeDialogOnEscape","onContextMenu","hideTimeout","showTimeout","_inherits","PureComponent","_createClass","key","value","event","this","hideDialogIfNeeded","DialogTriggerEventEnum","ESCAPE_KEY","handleEvent","TAB_KEY","target","ENTER","_this$props","shouldCallbackOnMount","onDialogDidShow","isClient","document","addEventListener","removeEventListener","containerElement","querySelector","containerSelector","Element","layerRef","context","current","body","eventName","_this2","_this$props2","instantShowAndHide","getDynamicShowDelay","finalShowDelay","showDelay","preventAnimation","dynamicDelayObj","onShowDialog","setState","setTimeout","options","arguments","length","undefined","disable","clearTimeout","showDialog","_this3","_this$props3","hideDelay","onHideDialog","onDialogDidHide","hideDialog","_this$props4","showTriggerIgnoreClass","hideTriggerIgnoreClass","isShowTrigger","isInsideClass","isHideTrigger","showDialogIfNeeded","open","_this$props5","addKeyboardHideShowTriggersByDefault","showTriggersArray","convertToArray","showTrigger","indexOf","_this$props6","hideTriggersArray","hideTrigger","e","button","relatedTarget","preventDefault","showOnDialogEnter","_this4","_this$props7","wrapperClassName","content","startingEdge","children","preventAnimationOnMount","animationType","position","moveBy","modifiers","tooltip","tooltipClassName","referenceWrapperClassName","zIndex","hideWhenReferenceHidden","disableContainerScroll","observeContentResize","overrideDataTestId","getTestId","ComponentDefaultTestId","DIALOG","id","animationTypeCalculated","contentRendered","isFunction","React","Manager","createElement","Reference","_ref","ref","Refable","className","cx","chainOnPropsAndInstance","createPortal","Popper","placement","name","offset","secondary","main","enabled","phase","fn","_ref2","styles","popper","String","_ref3","arrow","transform","concat","effect","_ref4","instance","observer","ResizeObserver","update","observe","elements","disconnect","_toConsumableArray","_ref5","style","arrowProps","isReferenceHidden","CustomEvent","DialogContent","styleObject","hasTooltip","nextProps","chainFunctions","hideShowTriggers","positions","DialogPositionEnum","animationTypes","AnimationTypeEnum","defaultProps","MOUSE_ENTER","MOUSE_LEAVE","EXPAND","NOOP","contextType","LayerContext"],"mappings":"u6BA+KqBA,IAAAA,WAAOC,GAkC1B,SAAAD,EAAYE,GAAkB,IAAAC,EA2BJ,OA3BIC,OAAAJ,IAC5BG,EAAAE,EAAAL,KAAAA,GAAME,KACDI,MAAQ,CACXC,+BAAgCL,EAAMM,yBACtCC,OAAQP,EAAMQ,mBAIhBP,EAAKQ,aAAeR,EAAKQ,aAAaC,KAAIT,GAC1CA,EAAKU,aAAeV,EAAKU,aAAaD,KAAIT,GAC1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AAiB,iBAC7B0B,IAKzB,IAEH5G,KAAKb,iBAjIJwF,CAqIX,IAAC,CAAA,CAAA9E,IAAA,2BAAAC,MA1XD,SAAgCgJ,EAAwB5K,GACtD,OAAIA,EAAMC,+BACD,CAAEE,OAAQyK,EAAUzK,QAEtB,IACT,IAAC,IAwXH,SAASoI,EAAwBI,EAAciB,EAAkBhK,GAE/D,OAAOiL,EAAe,CAACjL,EAAM+I,GAAOiB,EAASjB,KAAQ,EACvD,CApeSjJ,EAAgBoL,iBAAG9I,EACnBtC,EAASqL,UAAGC,EACZtL,EAAcuL,eAAGC,EACjBxL,EAAAyL,aAAe,CACpBvE,SAAU,MACVE,UAAW,GACXD,OAAQ,CAAEiC,KAAM,EAAGD,UAAW,GAC9BlF,UAAW,IACXe,UAAW,IACXgB,YAAahG,EAAOoL,iBAAiBM,YACrCtF,YAAapG,EAAOoL,iBAAiBO,YACrClF,mBAAmB,EACnB/F,mBAAmB,EACnBiE,SAAS,EACTgB,MAAM,EACNsB,cAAejH,EAAOuL,eAAeK,OACrC5E,yBAAyB,EACzBK,SAAS,EACTvE,gBAAiB+I,EACjB3G,gBAAiB2G,EACjBzK,eAAgByK,EAChBrK,eAAgBqK,EAChBrL,0BAA0B,EAC1BiH,yBAAyB,EACzB5E,uBAAuB,EACvBiB,oBAAoB,EACpB+B,sCAAsC,EACtC8B,sBAAsB,GA2c1B3H,EAAO8L,YAAcC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.js","sources":["../../../../../../src/components/Menu/MenuItem/MenuItem.tsx"],"sourcesContent":["import React, { AriaAttributes, ForwardedRef, ReactElement, forwardRef, useMemo, useRef } from \"react\";\nimport Tooltip, { TooltipProps } from \"../../../components/Tooltip/Tooltip\";\nimport Icon from \"../../../components/Icon/Icon\";\nimport useIsOverflowing from \"../../../hooks/useIsOverflowing/useIsOverflowing\";\nimport { SubIcon, VibeComponent, VibeComponentProps, withStaticProps } from \"../../../types\";\nimport { IconType } from \"../../Icon\";\nimport { CloseMenuOption, MenuChild } from \"../Menu/MenuConstants\";\nimport Label from \"../../Label/Label\";\nimport styles from \"./MenuItem.module.scss\";\nimport BaseMenuItem from \"./components/BaseMenuItem/BaseMenuItem\";\nimport MenuItemIcon from \"./components/MenuItemIcon/MenuItemIcon\";\nimport { TooltipPositions } from \"../../Tooltip/Tooltip.types\";\nimport { TooltipPositions as TooltipPositionsEnum } from \"../../Tooltip/TooltipConstants\";\nimport { SubmenuPosition } from \"./MenuItem.types\";\n\nexport interface MenuItemProps extends VibeComponentProps {\n title?: string;\n label?: string | React.ReactElement<typeof Label>;\n icon?: SubIcon;\n iconType?: IconType;\n iconBackgroundColor?: string;\n disabled?: boolean;\n disableReason?: string;\n selected?: boolean;\n onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;\n activeItemIndex?: number;\n setActiveItemIndex?: (index: number) => void;\n index?: number;\n key?: string;\n isParentMenuVisible?: boolean;\n resetOpenSubMenuIndex?: () => void;\n hasOpenSubMenu?: boolean;\n setSubMenuIsOpenByIndex?: (index: number, isOpen: boolean) => void;\n useDocumentEventListeners?: boolean;\n tooltipContent?: string;\n tooltipPosition?: TooltipPositions;\n tooltipShowDelay?: number;\n tooltipProps?: Partial<TooltipProps>;\n onMouseLeave?: (event: React.MouseEvent) => void;\n onMouseEnter?: (event: React.MouseEvent) => void;\n /**\n * Class name which is added to div which wraps an Icon\n */\n iconWrapperClassName?: string;\n isInitialSelectedState?: boolean;\n shouldScrollMenu?: boolean;\n closeMenu?: (option: CloseMenuOption) => void;\n menuRef?: React.RefObject<HTMLElement>;\n //// TODO: [breaking] MenuItem can accept only Menu element as first level child, it accepts MenuChild[] as children even though it is not valid\n children?: MenuChild | MenuChild[];\n /**\n * Type of menu item with sub menu, which has two click/hover options-\n * 1. click on the main menu item will trigger onClick\n * 2. click/hover on icon button will open the sub menu\n */\n splitMenuItem?: boolean;\n \"aria-label\"?: AriaAttributes[\"aria-label\"];\n submenuPosition?: SubmenuPosition;\n
|
|
1
|
+
{"version":3,"file":"MenuItem.js","sources":["../../../../../../src/components/Menu/MenuItem/MenuItem.tsx"],"sourcesContent":["import React, { AriaAttributes, ForwardedRef, ReactElement, forwardRef, useMemo, useRef } from \"react\";\nimport Tooltip, { TooltipProps } from \"../../../components/Tooltip/Tooltip\";\nimport Icon from \"../../../components/Icon/Icon\";\nimport useIsOverflowing from \"../../../hooks/useIsOverflowing/useIsOverflowing\";\nimport { SubIcon, VibeComponent, VibeComponentProps, withStaticProps } from \"../../../types\";\nimport { IconType } from \"../../Icon\";\nimport { CloseMenuOption, MenuChild } from \"../Menu/MenuConstants\";\nimport Label from \"../../Label/Label\";\nimport styles from \"./MenuItem.module.scss\";\nimport BaseMenuItem from \"./components/BaseMenuItem/BaseMenuItem\";\nimport MenuItemIcon from \"./components/MenuItemIcon/MenuItemIcon\";\nimport { TooltipPositions } from \"../../Tooltip/Tooltip.types\";\nimport { TooltipPositions as TooltipPositionsEnum } from \"../../Tooltip/TooltipConstants\";\nimport { SubmenuPosition } from \"./MenuItem.types\";\n\nexport interface MenuItemProps extends VibeComponentProps {\n title?: string;\n label?: string | React.ReactElement<typeof Label>;\n icon?: SubIcon;\n iconType?: IconType;\n iconBackgroundColor?: string;\n disabled?: boolean;\n disableReason?: string;\n selected?: boolean;\n onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;\n activeItemIndex?: number;\n setActiveItemIndex?: (index: number) => void;\n index?: number;\n key?: string;\n isParentMenuVisible?: boolean;\n resetOpenSubMenuIndex?: () => void;\n hasOpenSubMenu?: boolean;\n setSubMenuIsOpenByIndex?: (index: number, isOpen: boolean) => void;\n useDocumentEventListeners?: boolean;\n tooltipContent?: string;\n tooltipPosition?: TooltipPositions;\n tooltipShowDelay?: number;\n tooltipProps?: Partial<TooltipProps>;\n onMouseLeave?: (event: React.MouseEvent) => void;\n onMouseEnter?: (event: React.MouseEvent) => void;\n /**\n * Class name which is added to div which wraps an Icon\n */\n iconWrapperClassName?: string;\n isInitialSelectedState?: boolean;\n shouldScrollMenu?: boolean;\n closeMenu?: (option: CloseMenuOption) => void;\n menuRef?: React.RefObject<HTMLElement>;\n //// TODO: [breaking] MenuItem can accept only Menu element as first level child, it accepts MenuChild[] as children even though it is not valid\n children?: MenuChild | MenuChild[];\n /**\n * Type of menu item with sub menu, which has two click/hover options-\n * 1. click on the main menu item will trigger onClick\n * 2. click/hover on icon button will open the sub menu\n */\n splitMenuItem?: boolean;\n \"aria-label\"?: AriaAttributes[\"aria-label\"];\n submenuPosition?: SubmenuPosition;\n}\n\nexport interface MenuItemTitleComponentProps extends Omit<MenuItemProps, \"title\"> {\n title: ReactElement;\n \"aria-label\": NonNullable<AriaAttributes[\"aria-label\"]>;\n}\n\nconst MenuItem: VibeComponent<MenuItemProps | MenuItemTitleComponentProps> & {\n iconType?: typeof Icon.type;\n isSelectable?: boolean;\n isMenuChild?: boolean;\n tooltipPositions?: typeof TooltipPositionsEnum;\n} = forwardRef(\n (\n {\n className,\n iconWrapperClassName,\n title = \"\",\n label = \"\",\n icon = \"\",\n iconType,\n iconBackgroundColor,\n disabled = false,\n disableReason,\n selected = false,\n key,\n children,\n tooltipContent,\n tooltipPosition = \"right\",\n tooltipShowDelay = 300,\n tooltipProps,\n \"aria-label\": ariaLabel,\n ...baseMenuProps\n }: MenuItemProps | MenuItemTitleComponentProps,\n ref: ForwardedRef<HTMLElement>\n ) => {\n const titleRef = useRef();\n\n // if \"title\" is a component ariaLabel is mandatory\n const iconLabel = ariaLabel ?? (title as string);\n\n const isTitleHoveredAndOverflowing = useIsOverflowing({ ref: titleRef });\n const shouldShowTooltip = isTitleHoveredAndOverflowing || disabled || tooltipContent;\n\n const finalTooltipContent = useMemo(() => {\n if (disabled) return disableReason;\n if (tooltipContent) return tooltipContent;\n return title;\n }, [disableReason, disabled, title, tooltipContent]);\n\n const renderLabel = useMemo(() => {\n if (!label) return;\n if (typeof label === \"string\") {\n return <Label kind=\"line\" text={label} />;\n }\n if (React.isValidElement(label) && label.type === Label) {\n return label;\n }\n }, [label]);\n\n return (\n <Tooltip\n content={shouldShowTooltip ? finalTooltipContent : null}\n position={tooltipPosition}\n showDelay={tooltipShowDelay}\n {...tooltipProps}\n >\n <BaseMenuItem\n key={key}\n ref={ref}\n subMenu={children}\n className={className}\n disabled={disabled}\n selected={selected}\n {...baseMenuProps}\n >\n {Boolean(icon) && (\n <MenuItemIcon\n icon={icon}\n type={iconType}\n label={iconLabel}\n disabled={disabled}\n selected={selected}\n backgroundColor={iconBackgroundColor}\n wrapperClassName={iconWrapperClassName}\n />\n )}\n <div ref={titleRef} className={styles.title}>\n {title}\n </div>\n {renderLabel}\n </BaseMenuItem>\n </Tooltip>\n );\n }\n);\n\nObject.assign(MenuItem, {\n isSelectable: true,\n isMenuChild: true\n});\n\nexport default withStaticProps(MenuItem, {\n iconType: Icon.type,\n tooltipPositions: TooltipPositionsEnum\n});\n"],"names":["MenuItem","forwardRef","_a","ref","className","iconWrapperClassName","_a$title","title","_a$label","label","_a$icon","icon","iconType","iconBackgroundColor","_a$disabled","disabled","disableReason","_a$selected","selected","key","children","tooltipContent","_a$tooltipPosition","tooltipPosition","_a$tooltipShowDelay","tooltipShowDelay","tooltipProps","ariaLabel","baseMenuProps","__rest","titleRef","useRef","iconLabel","shouldShowTooltip","useIsOverflowing","finalTooltipContent","useMemo","renderLabel","React","createElement","Label","kind","text","isValidElement","type","Tooltip","Object","assign","content","position","showDelay","BaseMenuItem","subMenu","MenuItemIcon","backgroundColor","wrapperClassName","styles","isSelectable","isMenuChild","withStaticProps","Icon","tooltipPositions","TooltipPositionsEnum"],"mappings":"snBAiEA,IAAMA,EAKFC,GACF,SACEC,EAoBAC,OAnBEC,EAgBuBF,EAhBvBE,UACAC,EAeuBH,EAfvBG,qBAAoBC,EAeGJ,EAdvBK,MAAAA,OAAQ,IAAHD,EAAG,GAAEA,EAAAE,EAcaN,EAbvBO,MAAAA,OAAQ,IAAHD,EAAG,GAAEA,EAAAE,EAaaR,EAZvBS,KAA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2B,gBAACe,EAAY,CACX1C,KAAMA,EACNiC,KAAMhC,EACNH,MAAOuB,EACPjB,SAAUA,EACVG,SAAUA,EACVoC,gBAAiBzC,EACjB0C,iBAAkBlD,IAGtBiC,EAAKC,cAAA,MAAA,CAAApC,IAAK2B,EAAU1B,UAAWoD,EAAOjD,OACnCA,GAEF8B,GAIT,IAGFS,OAAOC,OAAO/C,EAAU,CACtByD,cAAc,EACdC,aAAa,IAGf,IAAeC,EAAAA,EAAgB3D,EAAU,CACvCY,SAAUgD,EAAKhB,KACfiB,iBAAkBC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{useRef as n,useMemo as o}from"react";import t from"../../../../DialogContentContainer/DialogContentContainer.js";import i from"../../../../../hooks/usePopover.js";import{Placement as s}from"../../../../../hooks/popoverConstants.js";import r from"../../../../../hooks/ssr/useIsomorphicLayoutEffect.js";var l=function(l){var u,c=l.anchorRef,a=l.open,p=l.autoFocusOnMount,m=l.onClose,v=l.children,f=l.submenuPosition,d=
|
|
1
|
+
import e,{useRef as n,useMemo as o}from"react";import t from"../../../../DialogContentContainer/DialogContentContainer.js";import i from"../../../../../hooks/usePopover.js";import{Placement as s}from"../../../../../hooks/popoverConstants.js";import r from"../../../../../hooks/ssr/useIsomorphicLayoutEffect.js";var l=function(l){var u,c=l.anchorRef,a=l.open,p=l.autoFocusOnMount,m=l.onClose,v=l.children,f=l.submenuPosition,d=n(null),b=n(null);r((function(){p&&a&&(null==d?void 0:d.current)&&requestAnimationFrame((function(){d.current.focus()}))}),[p,a]);var h=o((function(){return"left"===f?s.LEFT_START:void 0}),[f]),j=i(null==c?void 0:c.current,null==b?void 0:b.current,{isOpen:a,placement:h}),C=j.styles,g=j.attributes,y=v&&e.Children.only(v);return(null===(u=null==y?void 0:y.type)||void 0===u?void 0:u.isMenu)?e.createElement("div",Object.assign({style:Object.assign(Object.assign({},C.popper),{visibility:a?"visible":"hidden"})},g.popper,{ref:b}),y&&a&&e.createElement(t,null,e.cloneElement(y,Object.assign(Object.assign({},null==y?void 0:y.props),{isVisible:a,isSubMenu:!0,onClose:m,ref:d,useDocumentEventListeners:!p})))):(console.error("MenuItem can accept only Menu element as first level child, this element is not valid: ",y),null)};export{l as default};
|
|
2
2
|
//# sourceMappingURL=MenuItemSubMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItemSubMenu.js","sources":["../../../../../../../../src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.tsx"],"sourcesContent":["import React, { useMemo, useRef } from \"react\";\nimport DialogContentContainer from \"../../../../DialogContentContainer/DialogContentContainer\";\nimport usePopover from \"../../../../../hooks/usePopover\";\nimport { MenuChild } from \"../../../Menu/MenuConstants\";\nimport { MenuItemSubMenuProps } from \"./MenuItemSubMenu.types\";\nimport { Placement } from \"../../../../../hooks/popoverConstants\";\nimport useIsomorphicLayoutEffect from \"../../../../../hooks/ssr/useIsomorphicLayoutEffect\";\n\nconst MenuItemSubMenu = ({\n anchorRef,\n open,\n autoFocusOnMount,\n onClose,\n children,\n submenuPosition
|
|
1
|
+
{"version":3,"file":"MenuItemSubMenu.js","sources":["../../../../../../../../src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.tsx"],"sourcesContent":["import React, { useMemo, useRef } from \"react\";\nimport DialogContentContainer from \"../../../../DialogContentContainer/DialogContentContainer\";\nimport usePopover from \"../../../../../hooks/usePopover\";\nimport { MenuChild } from \"../../../Menu/MenuConstants\";\nimport { MenuItemSubMenuProps } from \"./MenuItemSubMenu.types\";\nimport { Placement } from \"../../../../../hooks/popoverConstants\";\nimport useIsomorphicLayoutEffect from \"../../../../../hooks/ssr/useIsomorphicLayoutEffect\";\n\nconst MenuItemSubMenu = ({\n anchorRef,\n open,\n autoFocusOnMount,\n onClose,\n children,\n submenuPosition\n}: MenuItemSubMenuProps) => {\n const childRef = useRef<HTMLDivElement>(null);\n const popperElementRef = useRef<HTMLDivElement>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (!autoFocusOnMount || !open || !childRef?.current) {\n return;\n }\n requestAnimationFrame(() => {\n childRef.current.focus();\n });\n }, [autoFocusOnMount, open]);\n\n const submenuPlacement = useMemo(\n () => (submenuPosition === \"left\" ? Placement.LEFT_START : undefined),\n [submenuPosition]\n );\n\n const { styles: popoverStyles, attributes: popoverAttributes } = usePopover(\n anchorRef?.current,\n popperElementRef?.current,\n {\n isOpen: open,\n placement: submenuPlacement\n }\n );\n\n const subMenu: MenuChild = children && React.Children.only(children);\n if (!subMenu?.type?.isMenu) {\n console.error(\"MenuItem can accept only Menu element as first level child, this element is not valid: \", subMenu);\n return null;\n }\n\n return (\n <div\n style={{ ...popoverStyles.popper, visibility: open ? \"visible\" : \"hidden\" }}\n {...popoverAttributes.popper}\n ref={popperElementRef}\n >\n {subMenu && open && (\n <DialogContentContainer>\n {React.cloneElement(subMenu, {\n ...subMenu?.props,\n isVisible: open,\n isSubMenu: true,\n onClose,\n ref: childRef,\n useDocumentEventListeners: !autoFocusOnMount\n })}\n </DialogContentContainer>\n )}\n </div>\n );\n};\n\nexport default MenuItemSubMenu;\n"],"names":["MenuItemSubMenu","_ref","anchorRef","open","autoFocusOnMount","onClose","children","submenuPosition","childRef","useRef","popperElementRef","useIsomorphicLayoutEffect","current","requestAnimationFrame","focus","submenuPlacement","useMemo","Placement","LEFT_START","undefined","_usePopover","usePopover","isOpen","placement","popoverStyles","styles","popoverAttributes","attributes","subMenu","React","Children","only","_a","type","isMenu","createElement","Object","assign","style","popper","visibility","ref","DialogContentContainer","cloneElement","props","isVisible","isSubMenu","useDocumentEventListeners","console","error"],"mappings":"uTAQA,IAAMA,EAAkB,SAAHC,GAOM,MANzBC,EAASD,EAATC,UACAC,EAAIF,EAAJE,KACAC,EAAgBH,EAAhBG,iBACAC,EAAOJ,EAAPI,QACAC,EAAQL,EAARK,SACAC,EAAeN,EAAfM,gBAEMC,EAAWC,EAAuB,MAClCC,EAAmBD,EAAuB,MAEhDE,GAA0B,WACnBP,GAAqBD,IAASK,aAAA,EAAAA,EAAUI,UAG7CC,uBAAsB,WACpBL,EAASI,QAAQE,OACnB,GACF,GAAG,CAACV,EAAkBD,IAEtB,IAAMY,EAAmBC,GACvB,WAAA,MAA2B,SAApBT,EAA6BU,EAAUC,gBAAaC,CAAS,GACpE,CAACZ,IAGHa,EAAiEC,EAC/DnB,aAAA,EAAAA,EAAWU,QACXF,aAAA,EAAAA,EAAkBE,QAClB,CACEU,OAAQnB,EACRoB,UAAWR,IALCS,EAAaJ,EAArBK,OAAmCC,EAAiBN,EAA7BO,WASzBC,EAAqBtB,GAAYuB,EAAMC,SAASC,KAAKzB,GAC3D,OAAoB,QAAf0B,EAAAJ,aAAA,EAAAA,EAASK,YAAM,IAAAD,OAAA,EAAAA,EAAAE,QAMlBL,EAAAM,cAAA,MAAAC,OAAAC,OAAA,CACEC,MAAKF,OAAAC,OAAAD,OAAAC,OAAA,GAAOb,EAAce,QAAQ,CAAAC,WAAYrC,EAAO,UAAY,YAC7DuB,EAAkBa,QACtBE,IAAK/B,IAEJkB,GAAWzB,GACV0B,gBAACa,EAAsB,KACpBb,EAAMc,aAAaf,EAAOQ,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EACtBT,aAAA,EAAAA,EAASgB,OAAK,CACjBC,UAAW1C,EACX2C,WAAW,EACXzC,QAAAA,EACAoC,IAAKjC,EACLuC,2BAA4B3C,QAlBpC4C,QAAQC,MAAM,0FAA2FrB,GAClG,KAuBX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useMemo as e}from"react";import{usePopper as t}from"react-popper";import{Placement as
|
|
1
|
+
import{useMemo as e}from"react";import{usePopper as t}from"react-popper";import{Placement as r}from"./popoverConstants.js";import o from"./ssr/useIsomorphicLayoutEffect.js";import s from"./useForceUpdate.js";var i=r.RIGHT_START,a={name:"flip",options:{fallbackPlacements:[r.RIGHT_END,r.LEFT_START,r.LEFT_END]}};function n(r,n,p){var m=p.isOpen,f=p.placement,l=void 0===f?i:f,c=s();o((function(){c()}),[r,n,c]);var u=e((function(){return{placement:l,modifiers:[a,{name:"displayNone",enabled:!0,phase:"write",fn:function(e){var t=e.state;return t.styles.popper.visibility=m?"visible":"hidden",t}}]}}),[m,l]),d=t(r,n,u);return{styles:d.styles,attributes:d.attributes}}export{n as default};
|
|
2
2
|
//# sourceMappingURL=usePopover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePopover.js","sources":["../../../../src/hooks/usePopover.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { usePopper } from \"react-popper\";\nimport { Placement } from \"./popoverConstants\";\nimport useIsomorphicLayoutEffect from \"./ssr/useIsomorphicLayoutEffect\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport type { Options, State } from \"@popperjs/core\";\
|
|
1
|
+
{"version":3,"file":"usePopover.js","sources":["../../../../src/hooks/usePopover.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { usePopper } from \"react-popper\";\nimport { Placement } from \"./popoverConstants\";\nimport useIsomorphicLayoutEffect from \"./ssr/useIsomorphicLayoutEffect\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport type { Options, State } from \"@popperjs/core\";\n\nconst { RIGHT_START, RIGHT_END, LEFT_START, LEFT_END } = Placement;\n\nconst FLIP_MODIFIER = {\n name: \"flip\",\n options: {\n fallbackPlacements: [RIGHT_END, LEFT_START, LEFT_END]\n }\n};\n\nexport default function usePopover(\n referenceElement: HTMLElement,\n popperElement: HTMLElement,\n {\n isOpen,\n placement = RIGHT_START\n }: {\n isOpen?: boolean;\n placement?: Placement;\n }\n) {\n const forceUpdate = useForceUpdate();\n\n // we have to use forceUpdate because\n // usePopper need to run again after any refs changes, even after the first render.\n useIsomorphicLayoutEffect(() => {\n forceUpdate();\n }, [referenceElement, popperElement, forceUpdate]);\n\n const popperOptions: Pick<Options, \"placement\" | \"modifiers\"> = useMemo(() => {\n return {\n placement,\n modifiers: [\n FLIP_MODIFIER,\n {\n name: \"displayNone\",\n enabled: true,\n phase: \"write\",\n fn: ({ state }: { state: State }) => {\n state.styles.popper.visibility = isOpen ? \"visible\" : \"hidden\";\n return state;\n }\n }\n ]\n };\n }, [isOpen, placement]);\n\n const { styles, attributes } = usePopper(referenceElement, popperElement, popperOptions);\n\n return { styles, attributes };\n}\n"],"names":["RIGHT_START","Placement","FLIP_MODIFIER","name","options","fallbackPlacements","RIGHT_END","LEFT_START","LEFT_END","usePopover","referenceElement","popperElement","_ref","isOpen","_ref$placement","placement","forceUpdate","useForceUpdate","useIsomorphicLayoutEffect","popperOptions","useMemo","modifiers","enabled","phase","fn","_ref2","state","styles","popper","visibility","_usePopper","usePopper","attributes"],"mappings":"gNAOA,IAAQA,EAAiDC,EAAjDD,YAEFE,EAAgB,CACpBC,KAAM,OACNC,QAAS,CACPC,mBAAoB,CALiCJ,EAApCK,UAAoCL,EAAzBM,WAAyBN,EAAbO,YASpB,SAAAC,EACtBC,EACAC,EAA0BC,GAOzB,IALCC,EAAMD,EAANC,OAAMC,EAAAF,EACNG,UAAAA,OAAYf,IAAHc,EAAGd,EAAWc,EAMnBE,EAAcC,IAIpBC,GAA0B,WACxBF,GACD,GAAE,CAACN,EAAkBC,EAAeK,IAErC,IAAMG,EAA0DC,GAAQ,WACtE,MAAO,CACLL,UAAAA,EACAM,UAAW,CACTnB,EACA,CACEC,KAAM,cACNmB,SAAS,EACTC,MAAO,QACPC,GAAI,SAAAC,GAAgC,IAA7BC,EAAKD,EAALC,MAEL,OADAA,EAAMC,OAAOC,OAAOC,WAAahB,EAAS,UAAY,SAC/Ca,CACT,IAIR,GAAG,CAACb,EAAQE,IAEZe,EAA+BC,EAAUrB,EAAkBC,EAAeQ,GAE1E,MAAO,CAAEQ,OAFKG,EAANH,OAESK,WAFSF,EAAVE,WAGlB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{inherits as e,createClass as n,toConsumableArray as o,classCallCheck as t,callSuper as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import s from"classnames";import r,{PureComponent as a}from"react";import{createPortal as l}from"react-dom";import{Manager as u,Reference as d,Popper as h}from"react-popper";import{isFunction as c}from"lodash-es";import{NOOP as p,convertToArray as m,chainFunctions as
|
|
1
|
+
import{inherits as e,createClass as n,toConsumableArray as o,classCallCheck as t,callSuper as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import s from"classnames";import r,{PureComponent as a}from"react";import{createPortal as l}from"react-dom";import{Manager as u,Reference as d,Popper as h}from"react-popper";import{isFunction as c}from"lodash-es";import{NOOP as p,convertToArray as m,chainFunctions as f}from"../../utils/function-utils.js";import{DialogContent as v}from"./DialogContent/DialogContent.js";import{isInsideClass as g}from"../../utils/dom-utils.js";import{Refable as D}from"../Refable/Refable.js";import{HideShowEvent as y,DialogPosition as w,AnimationType as E}from"./DialogConstants.js";import k from"./Dialog.module.scss.js";import{getTestId as C,ComponentDefaultTestId as T}from"../../tests/testIds.js";import b from"../LayerProvider/LayerContext.js";import{isClient as S}from"../../utils/ssr-utils.js";var O=function(p){function f(e){var n;return t(this,f),(n=i(this,f,[e])).state={shouldUseDerivedStateFromProps:e.useDerivedStateFromProps,isOpen:e.shouldShowOnMount},n.onMouseEnter=n.onMouseEnter.bind(n),n.onMouseLeave=n.onMouseLeave.bind(n),n.onMouseDown=n.onMouseDown.bind(n),n.onClick=n.onClick.bind(n),n.onFocus=n.onFocus.bind(n),n.onBlur=n.onBlur.bind(n),n.isShown=n.isShown.bind(n),n.onEsc=n.onEsc.bind(n),n.onClickOutside=n.onClickOutside.bind(n),n.onDialogEnter=n.onDialogEnter.bind(n),n.onDialogLeave=n.onDialogLeave.bind(n),n.getContainer=n.getContainer.bind(n),n.onContentClick=n.onContentClick.bind(n),n.onKeyDown=n.onKeyDown.bind(n),n.closeDialogOnEscape=n.closeDialogOnEscape.bind(n),n.onContextMenu=n.onContextMenu.bind(n),n.hideTimeout=null,n.showTimeout=null,n}return e(f,a),n(f,[{key:"closeDialogOnEscape",value:function(e){if(this.state.isOpen)switch(e.key){case"Escape":this.hideDialogIfNeeded(e,y.ESCAPE_KEY);break;case"Tab":this.handleEvent(y.TAB_KEY,e.target,e);break;case"Enter":this.handleEvent(y.ENTER,e.target,e)}}},{key:"componentDidMount",value:function(){var e=this.props,n=e.shouldCallbackOnMount,o=e.onDialogDidShow,t=this.state.isOpen;S()&&document.addEventListener("keyup",this.closeDialogOnEscape),n&&t&&o&&o()}},{key:"componentWillUnmount",value:function(){S()&&document.removeEventListener("keyup",this.closeDialogOnEscape)}},{key:"getContainer",value:function(){var e=document.querySelector(this.props.containerSelector);if(!(e&&e instanceof Element)){var n=this.context.layerRef;return(null==n?void 0:n.current)?n.current:document.body}return e}},{key:"showDialog",value:function(e,n){var o=this,t=this.props,i=t.instantShowAndHide,s=t.getDynamicShowDelay,r=t.showDelay,a=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).preventAnimation;if(s){var l=s();r=l.showDelay||0,a=a||l.preventAnimation}i?(this.onShowDialog(e,n),this.setState({isOpen:!0,preventAnimation:a}),this.showTimeout=null):this.showTimeout=setTimeout((function(){o.onShowDialog(e,n),o.showTimeout=null,o.setState({isOpen:!0,preventAnimation:a})}),r)}},{key:"onShowDialog",value:function(e,n){this.isShown()||(0,this.props.onDialogDidShow)(e,n)}},{key:"showDialogIfNeeded",value:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.props.disable||(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),this.showTimeout||this.showDialog(e,n,o))}},{key:"hideDialog",value:function(e,n){var o=this,t=this.props,i=t.hideDelay;t.instantShowAndHide?(this.onHideDialog(e,n),this.setState({isOpen:!1}),this.hideTimeout=null):this.hideTimeout=setTimeout((function(){o.onHideDialog(e,n),o.setState({isOpen:!1}),o.hideTimeout=null}),i)}},{key:"onHideDialog",value:function(e,n){var o=this.props.onDialogDidHide;o&&o(e,n)}},{key:"hideDialogIfNeeded",value:function(e,n){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),this.hideTimeout||this.hideDialog(e,n)}},{key:"handleEvent",value:function(e,n,o){var t=this.props,i=t.showTriggerIgnoreClass,s=t.hideTriggerIgnoreClass;return!this.isShowTrigger(e)||this.isShown()||g(n,i)?this.isHideTrigger(e)&&!g(n,s)?this.hideDialogIfNeeded(o,e):void 0:this.showDialogIfNeeded(o,e)}},{key:"isShown",value:function(){return this.state.isOpen||this.props.open}},{key:"isShowTrigger",value:function(e){var n=this.props,o=n.addKeyboardHideShowTriggersByDefault,t=m(n.showTrigger);return!(!o||"focus"!==e||-1>=t.indexOf("mouseenter"))||t.indexOf(e)>-1}},{key:"isHideTrigger",value:function(e){var n=this.props,o=n.addKeyboardHideShowTriggersByDefault,t=m(n.hideTrigger);return!(!o||"blur"!==e||-1>=t.indexOf("mouseleave"))||t.indexOf(e)>-1}},{key:"onMouseEnter",value:function(e){this.handleEvent("mouseenter",e.target,e)}},{key:"onMouseLeave",value:function(e){this.handleEvent("mouseleave",e.target,e)}},{key:"onClick",value:function(e){e.button||this.handleEvent("click",e.target,e)}},{key:"onKeyDown",value:function(e){"Enter"===e.key&&this.handleEvent("enter",e.target,e),"Tab"===e.key&&this.handleEvent("tab",e.target,e)}},{key:"onMouseDown",value:function(e){e.button||this.handleEvent("mousedown",e.target,e)}},{key:"onFocus",value:function(e){this.handleEvent("focus",e.target,e)}},{key:"onBlur",value:function(e){this.handleEvent("blur",e.relatedTarget,e)}},{key:"onEsc",value:function(e){this.handleEvent("esckey",e.target,e)}},{key:"onContextMenu",value:function(e){var n=this.isShown();(this.isShowTrigger("contextmenu")&&!n||this.isHideTrigger("contextmenu")&&n)&&e.preventDefault(),this.handleEvent("contextmenu",e.target,e)}},{key:"onClickOutside",value:function(e){var n=this.props.onClickOutside;this.handleEvent("clickoutside",e.target,e),n(e)}},{key:"onDialogEnter",value:function(e){this.props.showOnDialogEnter&&this.showDialogIfNeeded(e,"DialogEnter")}},{key:"onDialogLeave",value:function(e){this.props.showOnDialogEnter&&this.hideDialogIfNeeded(e,"DialogLeave")}},{key:"onContentClick",value:function(e){var n=this.props.onContentClick;this.handleEvent("onContentClick",e.target,e),n(e)}},{key:"render",value:function(){var e=this,n=this.props,t=n.wrapperClassName,i=n.content,a=n.startingEdge,p=n.children,m=n.preventAnimationOnMount,f=n.animationType,g=n.position,y=n.showDelay,w=n.moveBy,E=n.modifiers,b=n.tooltip,O=n.tooltipClassName,x=n.referenceWrapperClassName,H=n.zIndex,L=n.hideWhenReferenceHidden,A=n.disableContainerScroll,N=n.containerSelector,R=n.observeContentResize,I=this.state.preventAnimation,B=n["data-testid"]||C(T.DIALOG,n.id),j=m||I?void 0:f,P=c(i)?i():i;return P?r.createElement(u,null,r.createElement(d,null,(function(n){var o=n.ref;return r.createElement(D,{className:s(x),ref:o,onBlur:M("onBlur",e,e.props),onKeyDown:M("onKeyDown",e,e.props),onClick:M("onClick",e,e.props),onFocus:M("onFocus",e,e.props),onMouseDown:M("onMouseDown",e,e.props),onMouseEnter:M("onMouseEnter",e,e.props),onMouseLeave:M("onMouseLeave",e,e.props),onContextMenu:M("onContextMenu",e,e.props)},p)})),S()&&l(r.createElement(h,{placement:g,modifiers:[{name:"offset",options:{offset:[w.secondary,w.main]}},{name:"zIndex",enabled:!0,phase:"write",fn:function(e){var n=e.state;return H&&(n.styles.popper.zIndex=H+""),n}},{name:"rotator",enabled:!0,phase:"write",fn:function(e){var n=e.state;return n.styles.arrow?(n.styles.arrow.transform="".concat(n.styles.arrow.transform," rotate(45deg)"),n):n}},{name:"observeContentResize",enabled:R,phase:"beforeWrite",fn:function(){},effect:function(e){var n=e.state,o=e.instance,t=new ResizeObserver((function(){o.update()}));return t.observe(n.elements.popper),function(){t.disconnect()}}}].concat(o(E))},(function(n){var o=n.placement,i=n.style,l=n.ref,u=n.arrowProps,d=n.isReferenceHidden;if(!e.isShown()&&o)return null;if(L&&d){var h=new CustomEvent("onReferenceHidden");e.hideDialog(h,"onReferenceHidden")}return r.createElement(v,{"data-testid":B,isReferenceHidden:L&&d,onMouseEnter:e.onDialogEnter,onMouseLeave:e.onDialogLeave,onClickOutside:e.onClickOutside,onContextMenu:e.onContextMenu,onEsc:e.onEsc,animationType:j,position:o,wrapperClassName:t,startingEdge:a,isOpen:e.isShown(),showDelay:y,styleObject:i,ref:l,onClick:e.onContentClick,hasTooltip:!!b,containerSelector:N,disableContainerScroll:A},P,b&&r.createElement("div",{style:u.style,ref:u.ref,className:s(k.arrow,O),"data-placement":o}))})),this.getContainer())):p}}],[{key:"getDerivedStateFromProps",value:function(e,n){return n.shouldUseDerivedStateFromProps?{isOpen:e.isOpen}:null}}])}();function M(e,n,o){return f([o[e],n[e]],!0)}O.hideShowTriggers=y,O.positions=w,O.animationTypes=E,O.defaultProps={position:"top",modifiers:[],moveBy:{main:0,secondary:0},showDelay:100,hideDelay:100,showTrigger:O.hideShowTriggers.MOUSE_ENTER,hideTrigger:O.hideShowTriggers.MOUSE_LEAVE,showOnDialogEnter:!1,shouldShowOnMount:!1,disable:!1,open:!1,animationType:O.animationTypes.EXPAND,preventAnimationOnMount:!1,tooltip:!1,onDialogDidShow:p,onDialogDidHide:p,onClickOutside:p,onContentClick:p,useDerivedStateFromProps:!1,hideWhenReferenceHidden:!1,shouldCallbackOnMount:!1,instantShowAndHide:!1,addKeyboardHideShowTriggersByDefault:!1,observeContentResize:!1},O.contextType=b;export{O as default};
|
|
2
2
|
//# sourceMappingURL=Dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { PureComponent, ReactElement } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Manager, Modifier, Popper, Reference } from \"react-popper\";\nimport { isFunction } from \"lodash-es\";\nimport { chainFunctions, convertToArray, NOOP } from \"../../utils/function-utils\";\nimport { DialogContent } from \"./DialogContent/DialogContent\";\nimport { isInsideClass } from \"../../utils/dom-utils\";\nimport { Refable } from \"../Refable/Refable\";\nimport {\n AnimationType as AnimationTypeEnum,\n HideShowEvent as DialogTriggerEventEnum,\n DialogPosition as DialogPositionEnum\n} from \"./DialogConstants\";\nimport { VibeComponentProps } from \"../../types\";\nimport * as PopperJS from \"@popperjs/core\";\nimport styles from \"./Dialog.module.scss\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport { DialogAnimationType, DialogPosition, DialogTriggerEvent } from \"./Dialog.types\";\nimport LayerContext from \"../LayerProvider/LayerContext\";\nimport { isClient } from \"../../utils/ssr-utils\";\nimport { createObserveContentResizeModifier } from \"./modifiers/observeContentResizeModifier\";\n\nexport interface DialogProps extends VibeComponentProps {\n /**\n * A Classname to be added to <span> element which wraps the children\n */\n referenceWrapperClassName?: string;\n /**\n * Where the dialog should be in reference to the children,\n * Top, Left, Right, Bottom ...\n */\n position?: DialogPosition;\n /**\n * PopperJS Modifiers type\n * https://popper.js.org/docs/v2/modifiers/\n */\n modifiers?: Modifier<any>[];\n startingEdge?: string;\n /**\n * How much to move the dialog in relative to children\n * main is the axis in which the position is aligned to\n * secondary is the vertical axes to the position\n */\n moveBy?: { main?: number; secondary?: number };\n /**\n * how much delay should the Dialog wait until it should trigger the show in MS\n */\n showDelay?: number;\n /**\n * how much delay should the Dialog wait until it should trigger the hide in MS\n */\n hideDelay?: number;\n /**\n * an array of hide/show trigger -\n */\n showTrigger?: DialogTriggerEvent | DialogTriggerEvent[];\n /**\n * an array of hide/show trigger -\n */\n hideTrigger?: DialogTriggerEvent | DialogTriggerEvent[];\n /**\n * If true, prevents opened Dialog from closing on mouseEnter, and closes Dialog when mouse leaves it\n */\n showOnDialogEnter?: boolean;\n /**\n * Show the Dialog when the children are mounting\n */\n shouldShowOnMount?: boolean;\n /**\n * disable the opening of the dialog\n */\n disable?: boolean;\n /**\n * open is a controlled prop to open the dialog\n */\n open?: boolean;\n /**\n * used when state is derived from props\n */\n isOpen?: boolean;\n /**\n * if this class exists on the children the show trigger will be ignored\n */\n showTriggerIgnoreClass?: string | Array<string>;\n /**\n * if this class exists on the children the hide trigger will be ignored\n */\n hideTriggerIgnoreClass?: string | Array<string>;\n /**\n * Dialog animation type\n */\n animationType?: DialogAnimationType;\n /**\n * Classname to be added to the content container\n */\n wrapperClassName?: string;\n /**\n * Prevent Animation\n */\n preventAnimationOnMount?: boolean;\n /**\n * the container selector in which to append the dialog\n * for examples: \"body\" , \".my-class\", \"#my-id\"\n */\n containerSelector?: string;\n /**\n * should position the tooltip element\n * https://popper.js.org/docs/v2/modifiers/arrow/\n */\n tooltip?: boolean;\n /**\n * class name to add to the tooltip element\n */\n tooltipClassName?: string;\n /**\n * callback to be called when the dialog is shown\n */\n onDialogDidShow?: (event?: DialogEvent, eventName?: DialogTriggerEvent | string) => void;\n /**\n * callback to be called when the dialog is hidden\n */\n onDialogDidHide?: (event: DialogEvent, eventName: DialogTriggerEvent | string) => void;\n /**\n * callback to be called when click outside is being triggered\n */\n onClickOutside?: (event: React.MouseEvent) => void;\n /**\n * callback to be called when click on the content is being triggered\n */\n onContentClick?: (event: React.MouseEvent) => void;\n /**\n * z-index to add to the dialog\n */\n zIndex?: number;\n useDerivedStateFromProps?: boolean;\n /**\n * Make the dialog disappear when the element it is attached to becomes hidden\n */\n hideWhenReferenceHidden?: boolean;\n shouldCallbackOnMount?: boolean;\n instantShowAndHide?: boolean;\n getDynamicShowDelay?: () => { showDelay: number; preventAnimation: boolean };\n content?: (() => JSX.Element) | JSX.Element;\n /**\n * The element where we will position the dialog beside.\n */\n children?: ReactElement | ReactElement[] | string;\n /**\n * Treats keyboard focus/blur events as mouse-enter/mouse-leave events\n */\n addKeyboardHideShowTriggersByDefault?: boolean;\n /**\n * If true disable the scroll for the containerSelector element.\n * If string use it as selector to prevent scroll.\n */\n disableContainerScroll?: boolean | string;\n /**\n * Enables the observation of content resize for the popper element.\n * When set to `true`, a ResizeObserver is attached to the popper content,\n * automatically triggering repositioning when the size of the content changes.\n *\n * This is useful for dialogs, tooltips, or popovers with dynamic content\n * that may grow or shrink without a re-render being triggered.\n */\n observeContentResize?: boolean;\n}\n\nexport interface DialogState {\n isOpen?: boolean;\n shouldUseDerivedStateFromProps?: boolean;\n preventAnimation?: boolean;\n}\n\nexport type DialogEvent = React.MouseEvent | React.KeyboardEvent | KeyboardEvent | React.FocusEvent | CustomEvent;\n\nexport default class Dialog extends PureComponent<DialogProps, DialogState> {\n static hideShowTriggers = DialogTriggerEventEnum;\n static positions = DialogPositionEnum;\n static animationTypes = AnimationTypeEnum;\n static defaultProps = {\n position: \"top\",\n modifiers: [] as Modifier<any>[],\n moveBy: { main: 0, secondary: 0 },\n showDelay: 100,\n hideDelay: 100,\n showTrigger: Dialog.hideShowTriggers.MOUSE_ENTER,\n hideTrigger: Dialog.hideShowTriggers.MOUSE_LEAVE,\n showOnDialogEnter: false,\n shouldShowOnMount: false,\n disable: false,\n open: false,\n animationType: Dialog.animationTypes.EXPAND,\n preventAnimationOnMount: false,\n tooltip: false,\n onDialogDidShow: NOOP,\n onDialogDidHide: NOOP,\n onClickOutside: NOOP,\n onContentClick: NOOP,\n useDerivedStateFromProps: false,\n hideWhenReferenceHidden: false,\n shouldCallbackOnMount: false,\n instantShowAndHide: false,\n addKeyboardHideShowTriggersByDefault: false,\n observeContentResize: false\n };\n private showTimeout: NodeJS.Timeout;\n private hideTimeout: NodeJS.Timeout;\n context!: React.ContextType<typeof LayerContext>;\n\n constructor(props: DialogProps) {\n super(props);\n this.state = {\n shouldUseDerivedStateFromProps: props.useDerivedStateFromProps,\n isOpen: props.shouldShowOnMount\n };\n\n // Binding section.\n this.onMouseEnter = this.onMouseEnter.bind(this);\n this.onMouseLeave = this.onMouseLeave.bind(this);\n this.onMouseDown = this.onMouseDown.bind(this);\n this.onClick = this.onClick.bind(this);\n this.onFocus = this.onFocus.bind(this);\n this.onBlur = this.onBlur.bind(this);\n this.isShown = this.isShown.bind(this);\n this.onEsc = this.onEsc.bind(this);\n this.onClickOutside = this.onClickOutside.bind(this);\n this.onDialogEnter = this.onDialogEnter.bind(this);\n this.onDialogLeave = this.onDialogLeave.bind(this);\n this.getContainer = this.getContainer.bind(this);\n this.onContentClick = this.onContentClick.bind(this);\n this.onKeyDown = this.onKeyDown.bind(this);\n this.closeDialogOnEscape = this.closeDialogOnEscape.bind(this);\n this.onContextMenu = this.onContextMenu.bind(this);\n\n // Timeouts\n this.hideTimeout = null;\n this.showTimeout = null;\n }\n\n closeDialogOnEscape(event: KeyboardEvent) {\n const { isOpen } = this.state;\n if (!isOpen) {\n return;\n }\n switch (event.key) {\n case \"Escape\":\n this.hideDialogIfNeeded(event, DialogTriggerEventEnum.ESCAPE_KEY);\n break;\n case \"Tab\":\n this.handleEvent(DialogTriggerEventEnum.TAB_KEY, event.target, event);\n break;\n case \"Enter\":\n this.handleEvent(DialogTriggerEventEnum.ENTER, event.target, event);\n break;\n default:\n break;\n }\n }\n\n componentDidMount() {\n const { shouldCallbackOnMount, onDialogDidShow } = this.props;\n const { isOpen } = this.state;\n if (isClient()) {\n document.addEventListener(\"keyup\", this.closeDialogOnEscape);\n }\n if (shouldCallbackOnMount && isOpen) {\n onDialogDidShow && onDialogDidShow();\n }\n }\n\n componentWillUnmount() {\n if (isClient()) {\n document.removeEventListener(\"keyup\", this.closeDialogOnEscape);\n }\n }\n\n static getDerivedStateFromProps(nextProps: DialogProps, state: DialogState): DialogState {\n if (state.shouldUseDerivedStateFromProps) {\n return { isOpen: nextProps.isOpen };\n }\n return null;\n }\n\n getContainer() {\n const { containerSelector } = this.props;\n const containerElement = document.querySelector(containerSelector);\n if (!containerElement || !(containerElement instanceof Element)) {\n const { layerRef } = this.context;\n if (layerRef?.current) {\n return layerRef.current;\n }\n return document.body;\n }\n return containerElement;\n }\n\n showDialog(event: DialogEvent, eventName: DialogTriggerEvent | string, options: { preventAnimation?: boolean } = {}) {\n const { showDelay, instantShowAndHide, getDynamicShowDelay } = this.props;\n let finalShowDelay = showDelay;\n let preventAnimation = options.preventAnimation;\n if (getDynamicShowDelay) {\n const dynamicDelayObj = getDynamicShowDelay();\n finalShowDelay = dynamicDelayObj.showDelay || 0;\n preventAnimation = preventAnimation || dynamicDelayObj.preventAnimation;\n }\n\n if (instantShowAndHide) {\n this.onShowDialog(event, eventName);\n this.setState({ isOpen: true, preventAnimation });\n this.showTimeout = null;\n } else {\n this.showTimeout = setTimeout(() => {\n this.onShowDialog(event, eventName);\n this.showTimeout = null;\n this.setState({ isOpen: true, preventAnimation });\n }, finalShowDelay);\n }\n }\n\n onShowDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n if (this.isShown()) return;\n const { onDialogDidShow } = this.props;\n onDialogDidShow(event, eventName);\n }\n\n showDialogIfNeeded(event: DialogEvent, eventName: DialogTriggerEvent | string, options = {}) {\n const { disable } = this.props;\n if (disable) {\n return;\n }\n\n if (this.hideTimeout) {\n clearTimeout(this.hideTimeout);\n this.hideTimeout = null;\n }\n\n if (!this.showTimeout) {\n this.showDialog(event, eventName, options);\n }\n }\n\n hideDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n const { hideDelay, instantShowAndHide } = this.props;\n if (instantShowAndHide) {\n this.onHideDialog(event, eventName);\n this.setState({ isOpen: false });\n this.hideTimeout = null;\n } else {\n this.hideTimeout = setTimeout(() => {\n this.onHideDialog(event, eventName);\n this.setState({ isOpen: false });\n this.hideTimeout = null;\n }, hideDelay);\n }\n }\n\n onHideDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n const { onDialogDidHide } = this.props;\n if (onDialogDidHide) onDialogDidHide(event, eventName);\n }\n\n hideDialogIfNeeded(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n if (this.showTimeout) {\n clearTimeout(this.showTimeout);\n this.showTimeout = null;\n }\n\n if (this.hideTimeout) {\n return;\n }\n this.hideDialog(event, eventName);\n }\n\n handleEvent(eventName: DialogTriggerEvent, target: EventTarget, event: DialogEvent) {\n const { showTriggerIgnoreClass, hideTriggerIgnoreClass } = this.props;\n if (\n this.isShowTrigger(eventName) &&\n !this.isShown() &&\n !isInsideClass(target as HTMLElement, showTriggerIgnoreClass)\n ) {\n return this.showDialogIfNeeded(event, eventName);\n }\n\n if (this.isHideTrigger(eventName) && !isInsideClass(target as HTMLElement, hideTriggerIgnoreClass)) {\n return this.hideDialogIfNeeded(event, eventName);\n }\n }\n\n isShown() {\n const { isOpen } = this.state;\n const { open } = this.props;\n\n return isOpen || open;\n }\n\n isShowTrigger(eventName: DialogTriggerEvent) {\n const { showTrigger, addKeyboardHideShowTriggersByDefault } = this.props;\n const showTriggersArray = convertToArray(showTrigger);\n\n if (addKeyboardHideShowTriggersByDefault) {\n if (eventName === \"focus\" && showTriggersArray.indexOf(\"mouseenter\") > -1) {\n return true;\n }\n }\n\n return showTriggersArray.indexOf(eventName) > -1;\n }\n\n isHideTrigger(eventName: DialogTriggerEvent) {\n const { hideTrigger, addKeyboardHideShowTriggersByDefault } = this.props;\n const hideTriggersArray = convertToArray(hideTrigger);\n\n if (addKeyboardHideShowTriggersByDefault) {\n if (eventName === \"blur\" && hideTriggersArray.indexOf(\"mouseleave\") > -1) {\n return true;\n }\n }\n\n return hideTriggersArray.indexOf(eventName) > -1;\n }\n\n onMouseEnter(e: React.MouseEvent) {\n this.handleEvent(\"mouseenter\", e.target, e);\n }\n\n onMouseLeave(e: React.MouseEvent) {\n this.handleEvent(\"mouseleave\", e.target, e);\n }\n\n onClick(e: React.MouseEvent) {\n if (e.button) return;\n this.handleEvent(\"click\", e.target, e);\n }\n\n onKeyDown(event: React.KeyboardEvent) {\n if (event.key === \"Enter\") {\n this.handleEvent(\"enter\", event.target, event);\n }\n\n if (event.key === \"Tab\") {\n this.handleEvent(\"tab\", event.target, event);\n }\n }\n\n onMouseDown(e: React.MouseEvent) {\n if (e.button) return;\n this.handleEvent(\"mousedown\", e.target, e);\n }\n\n onFocus(e: React.FocusEvent) {\n this.handleEvent(\"focus\", e.target, e);\n }\n\n onBlur(e: React.FocusEvent) {\n this.handleEvent(\"blur\", e.relatedTarget, e);\n }\n\n onEsc(e: React.KeyboardEvent) {\n this.handleEvent(\"esckey\", e.target, e);\n }\n\n onContextMenu(e: React.MouseEvent) {\n const isShown = this.isShown();\n if ((this.isShowTrigger(\"contextmenu\") && !isShown) || (this.isHideTrigger(\"contextmenu\") && isShown)) {\n e.preventDefault();\n }\n this.handleEvent(\"contextmenu\", e.target, e);\n }\n\n onClickOutside(event: React.MouseEvent) {\n const { onClickOutside } = this.props;\n this.handleEvent(\"clickoutside\", event.target, event);\n onClickOutside(event);\n }\n\n onDialogEnter(event: React.MouseEvent) {\n const { showOnDialogEnter } = this.props;\n if (showOnDialogEnter) this.showDialogIfNeeded(event, \"DialogEnter\");\n }\n\n onDialogLeave(event: React.MouseEvent) {\n const { showOnDialogEnter } = this.props;\n if (showOnDialogEnter) this.hideDialogIfNeeded(event, \"DialogLeave\");\n }\n\n onContentClick(e: React.MouseEvent) {\n const { onContentClick } = this.props;\n this.handleEvent(\"onContentClick\", e.target, e);\n onContentClick(e);\n }\n\n render() {\n const {\n wrapperClassName,\n content,\n startingEdge,\n children,\n preventAnimationOnMount,\n animationType,\n position,\n showDelay,\n moveBy,\n modifiers,\n tooltip,\n tooltipClassName,\n referenceWrapperClassName,\n zIndex,\n hideWhenReferenceHidden,\n disableContainerScroll,\n containerSelector,\n observeContentResize,\n id,\n \"data-testid\": dataTestId\n } = this.props;\n const { preventAnimation } = this.state;\n const overrideDataTestId = dataTestId || getTestId(ComponentDefaultTestId.DIALOG, id);\n\n const animationTypeCalculated = preventAnimationOnMount || preventAnimation ? undefined : animationType;\n const contentRendered = isFunction(content) ? content() : content;\n\n if (!contentRendered) {\n return children;\n }\n return (\n <Manager>\n <Reference>\n {({ ref }) => {\n return (\n <Refable\n className={cx(referenceWrapperClassName)}\n ref={ref}\n onBlur={chainOnPropsAndInstance(\"onBlur\", this, this.props)}\n onKeyDown={chainOnPropsAndInstance(\"onKeyDown\", this, this.props)}\n onClick={chainOnPropsAndInstance(\"onClick\", this, this.props)}\n onFocus={chainOnPropsAndInstance(\"onFocus\", this, this.props)}\n onMouseDown={chainOnPropsAndInstance(\"onMouseDown\", this, this.props)}\n onMouseEnter={chainOnPropsAndInstance(\"onMouseEnter\", this, this.props)}\n onMouseLeave={chainOnPropsAndInstance(\"onMouseLeave\", this, this.props)}\n onContextMenu={chainOnPropsAndInstance(\"onContextMenu\", this, this.props)}\n >\n {children}\n </Refable>\n );\n }}\n </Reference>\n {isClient() &&\n createPortal(\n <Popper\n placement={position as unknown as PopperJS.Placement}\n modifiers={[\n {\n name: \"offset\",\n options: {\n offset: [moveBy.secondary, moveBy.main]\n }\n },\n {\n name: \"zIndex\",\n enabled: true,\n phase: \"write\",\n fn({ state }) {\n if (zIndex) {\n state.styles.popper.zIndex = String(zIndex);\n }\n return state;\n }\n },\n {\n name: \"rotator\",\n enabled: true,\n phase: \"write\",\n fn({ state }) {\n if (!state.styles.arrow) {\n return state;\n }\n // const reg = new RegExp(\n // /translate\\(([0-9].*)px, ([0-9].*)px\\)/\n // );\n // const transform = state.styles.arrow.transform;\n // const res = reg.exec(transform);\n // state.styles.popper.transformOrigin = `${100 -\n // res[1]}% ${100 - res[2]}%`;\n state.styles.arrow.transform = `${state.styles.arrow.transform} rotate(45deg)`;\n return state;\n }\n },\n createObserveContentResizeModifier(observeContentResize),\n ...modifiers\n ]}\n >\n {({ placement, style, ref, arrowProps, isReferenceHidden }) => {\n if (!this.isShown() && placement) {\n return null;\n }\n\n if (hideWhenReferenceHidden && isReferenceHidden) {\n const event = new CustomEvent(\"onReferenceHidden\");\n this.hideDialog(event, \"onReferenceHidden\");\n }\n\n return (\n <DialogContent\n data-testid={overrideDataTestId}\n isReferenceHidden={hideWhenReferenceHidden && isReferenceHidden}\n onMouseEnter={this.onDialogEnter}\n onMouseLeave={this.onDialogLeave}\n onClickOutside={this.onClickOutside}\n onContextMenu={this.onContextMenu}\n onEsc={this.onEsc}\n animationType={animationTypeCalculated}\n position={placement}\n wrapperClassName={wrapperClassName}\n startingEdge={startingEdge}\n isOpen={this.isShown()}\n showDelay={showDelay}\n styleObject={style}\n ref={ref}\n onClick={this.onContentClick}\n hasTooltip={!!tooltip}\n containerSelector={containerSelector}\n disableContainerScroll={disableContainerScroll}\n >\n {contentRendered}\n {tooltip && (\n <div\n style={arrowProps.style}\n ref={arrowProps.ref}\n className={cx(styles.arrow, tooltipClassName)}\n data-placement={placement}\n />\n )}\n </DialogContent>\n );\n }}\n </Popper>,\n this.getContainer()\n )}\n </Manager>\n );\n }\n}\n\nfunction chainOnPropsAndInstance(name: string, instance: Dialog, props: DialogProps) {\n // @ts-ignore\n return chainFunctions([props[name], instance[name]], true);\n}\n\nDialog.contextType = LayerContext;\n"],"names":["Dialog","_PureComponent","props","_this","_classCallCheck","_callSuper","state","shouldUseDerivedStateFromProps","useDerivedStateFromProps","isOpen","shouldShowOnMount","onMouseEnter","bind","onMouseLeave","onMouseDown","onClick","onFocus","onBlur","isShown","onEsc","onClickOutside","onDialogEnter","onDialogLeave","getContainer","onContentClick","onKeyDown","closeDialogOnEscape","onContextMenu","hideTimeout","showTimeout","_inherits","PureComponent","_createClass","key","value","event","this","hideDialogIfNeeded","DialogTriggerEventEnum","ESCAPE_KEY","handleEvent","TAB_KEY","target","ENTER","_this$props","shouldCallbackOnMount","onDialogDidShow","isClient","document","addEventListener","removeEventListener","containerElement","querySelector","containerSelector","Element","layerRef","context","current","body","eventName","_this2","_this$props2","instantShowAndHide","getDynamicShowDelay","finalShowDelay","showDelay","preventAnimation","dynamicDelayObj","onShowDialog","setState","setTimeout","options","arguments","length","undefined","disable","clearTimeout","showDialog","_this3","_this$props3","hideDelay","onHideDialog","onDialogDidHide","hideDialog","_this$props4","showTriggerIgnoreClass","hideTriggerIgnoreClass","isShowTrigger","isInsideClass","isHideTrigger","showDialogIfNeeded","open","_this$props5","addKeyboardHideShowTriggersByDefault","showTriggersArray","convertToArray","showTrigger","indexOf","_this$props6","hideTriggersArray","hideTrigger","e","button","relatedTarget","preventDefault","showOnDialogEnter","_this4","_this$props7","wrapperClassName","content","startingEdge","children","preventAnimationOnMount","animationType","position","moveBy","modifiers","tooltip","tooltipClassName","referenceWrapperClassName","zIndex","hideWhenReferenceHidden","disableContainerScroll","observeContentResize","overrideDataTestId","getTestId","ComponentDefaultTestId","DIALOG","id","animationTypeCalculated","contentRendered","isFunction","React","Manager","createElement","Reference","_ref","ref","Refable","className","cx","chainOnPropsAndInstance","createPortal","Popper","placement","name","offset","secondary","main","enabled","phase","fn","_ref2","styles","popper","String","_ref3","arrow","transform","concat","createObserveContentResizeModifier","_toConsumableArray","_ref4","style","arrowProps","isReferenceHidden","CustomEvent","DialogContent","styleObject","hasTooltip","nextProps","instance","chainFunctions","hideShowTriggers","positions","DialogPositionEnum","animationTypes","AnimationTypeEnum","defaultProps","MOUSE_ENTER","MOUSE_LEAVE","EXPAND","NOOP","contextType","LayerContext"],"mappings":"wgCAgLqBA,IAAAA,WAAOC,GAkC1B,SAAAD,EAAYE,GAAkB,IAAAC,EA2BJ,OA3BIC,OAAAJ,IAC5BG,EAAAE,EAAAL,KAAAA,GAAME,KACDI,MAAQ,CACXC,+BAAgCL,EAAMM,yBACtCC,OAAQP,EAAMQ,mBAIhBP,EAAKQ,aAAeR,EAAKQ,aAAaC,KAAIT,GAC1CA,EAAKU,aAAeV,EAAKU,aAAaD,KAAIT,GAC1CA,EAAKW,YAAcX,EAAKW,YAAYF,KAAIT,GACxCA,EAAKY,QAAUZ,EAAKY,QAAQH,KAAIT,GAChCA,EAAKa,QAAUb,EAAKa,QAAQJ,KAAIT,GAChCA,EAAKc,OAASd,EAAKc,OAAOL,KAAIT,GAC9BA,EAAKe,QAAUf,EAAKe,QAAQN,KAAIT,GAChCA,EAAKgB,MAAQhB,EAAKgB,MAAMP,KAAIT,GAC5BA,EAAKiB,eAAiBjB,EAAKiB,eAAeR,KAAIT,GAC9CA,EAAKkB,cAAgBlB,EAAKkB,cAAcT,KAAIT,GAC5CA,EAAKmB,cAAgBnB,EAAKmB,cAAcV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AAOgL,eAAeK,OACrCrE,yBAAyB,EACzBK,SAAS,EACTvE,gBAAiBwI,EACjBpG,gBAAiBoG,EACjBlK,eAAgBkK,EAChB9J,eAAgB8J,EAChB9K,0BAA0B,EAC1BiH,yBAAyB,EACzB5E,uBAAuB,EACvBiB,oBAAoB,EACpB+B,sCAAsC,EACtC8B,sBAAsB,GA4b1B3H,EAAOuL,YAAcC"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { PureComponent, ReactElement } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Manager, Modifier, Popper, Reference } from \"react-popper\";\nimport { isFunction } from \"lodash-es\";\nimport { chainFunctions, convertToArray, NOOP } from \"../../utils/function-utils\";\nimport { DialogContent } from \"./DialogContent/DialogContent\";\nimport { isInsideClass } from \"../../utils/dom-utils\";\nimport { Refable } from \"../Refable/Refable\";\nimport {\n AnimationType as AnimationTypeEnum,\n HideShowEvent as DialogTriggerEventEnum,\n DialogPosition as DialogPositionEnum\n} from \"./DialogConstants\";\nimport { VibeComponentProps } from \"../../types\";\nimport * as PopperJS from \"@popperjs/core\";\nimport styles from \"./Dialog.module.scss\";\nimport { ComponentDefaultTestId, getTestId } from \"../../tests/test-ids-utils\";\nimport { DialogAnimationType, DialogPosition, DialogTriggerEvent } from \"./Dialog.types\";\nimport LayerContext from \"../LayerProvider/LayerContext\";\nimport { isClient } from \"../../utils/ssr-utils\";\n\nexport interface DialogProps extends VibeComponentProps {\n /**\n * A Classname to be added to <span> element which wraps the children\n */\n referenceWrapperClassName?: string;\n /**\n * Where the dialog should be in reference to the children,\n * Top, Left, Right, Bottom ...\n */\n position?: DialogPosition;\n /**\n * PopperJS Modifiers type\n * https://popper.js.org/docs/v2/modifiers/\n */\n modifiers?: Modifier<any>[];\n startingEdge?: string;\n /**\n * How much to move the dialog in relative to children\n * main is the axis in which the position is aligned to\n * secondary is the vertical axes to the position\n */\n moveBy?: { main?: number; secondary?: number };\n /**\n * how much delay should the Dialog wait until it should trigger the show in MS\n */\n showDelay?: number;\n /**\n * how much delay should the Dialog wait until it should trigger the hide in MS\n */\n hideDelay?: number;\n /**\n * an array of hide/show trigger -\n */\n showTrigger?: DialogTriggerEvent | DialogTriggerEvent[];\n /**\n * an array of hide/show trigger -\n */\n hideTrigger?: DialogTriggerEvent | DialogTriggerEvent[];\n /**\n * If true, prevents opened Dialog from closing on mouseEnter, and closes Dialog when mouse leaves it\n */\n showOnDialogEnter?: boolean;\n /**\n * Show the Dialog when the children are mounting\n */\n shouldShowOnMount?: boolean;\n /**\n * disable the opening of the dialog\n */\n disable?: boolean;\n /**\n * open is a controlled prop to open the dialog\n */\n open?: boolean;\n /**\n * used when state is derived from props\n */\n isOpen?: boolean;\n /**\n * if this class exists on the children the show trigger will be ignored\n */\n showTriggerIgnoreClass?: string | Array<string>;\n /**\n * if this class exists on the children the hide trigger will be ignored\n */\n hideTriggerIgnoreClass?: string | Array<string>;\n /**\n * Dialog animation type\n */\n animationType?: DialogAnimationType;\n /**\n * Classname to be added to the content container\n */\n wrapperClassName?: string;\n /**\n * Prevent Animation\n */\n preventAnimationOnMount?: boolean;\n /**\n * the container selector in which to append the dialog\n * for examples: \"body\" , \".my-class\", \"#my-id\"\n */\n containerSelector?: string;\n /**\n * should position the tooltip element\n * https://popper.js.org/docs/v2/modifiers/arrow/\n */\n tooltip?: boolean;\n /**\n * class name to add to the tooltip element\n */\n tooltipClassName?: string;\n /**\n * callback to be called when the dialog is shown\n */\n onDialogDidShow?: (event?: DialogEvent, eventName?: DialogTriggerEvent | string) => void;\n /**\n * callback to be called when the dialog is hidden\n */\n onDialogDidHide?: (event: DialogEvent, eventName: DialogTriggerEvent | string) => void;\n /**\n * callback to be called when click outside is being triggered\n */\n onClickOutside?: (event: React.MouseEvent) => void;\n /**\n * callback to be called when click on the content is being triggered\n */\n onContentClick?: (event: React.MouseEvent) => void;\n /**\n * z-index to add to the dialog\n */\n zIndex?: number;\n useDerivedStateFromProps?: boolean;\n /**\n * Make the dialog disappear when the element it is attached to becomes hidden\n */\n hideWhenReferenceHidden?: boolean;\n shouldCallbackOnMount?: boolean;\n instantShowAndHide?: boolean;\n getDynamicShowDelay?: () => { showDelay: number; preventAnimation: boolean };\n content?: (() => JSX.Element) | JSX.Element;\n /**\n * The element where we will position the dialog beside.\n */\n children?: ReactElement | ReactElement[] | string;\n /**\n * Treats keyboard focus/blur events as mouse-enter/mouse-leave events\n */\n addKeyboardHideShowTriggersByDefault?: boolean;\n /**\n * If true disable the scroll for the containerSelector element.\n * If string use it as selector to prevent scroll.\n */\n disableContainerScroll?: boolean | string;\n /**\n * Enables the observation of content resize for the popper element.\n * When set to `true`, a ResizeObserver is attached to the popper content,\n * automatically triggering repositioning when the size of the content changes.\n *\n * This is useful for dialogs, tooltips, or popovers with dynamic content\n * that may grow or shrink without a re-render being triggered.\n */\n observeContentResize?: boolean;\n}\n\nexport interface DialogState {\n isOpen?: boolean;\n shouldUseDerivedStateFromProps?: boolean;\n preventAnimation?: boolean;\n}\n\nexport type DialogEvent = React.MouseEvent | React.KeyboardEvent | KeyboardEvent | React.FocusEvent | CustomEvent;\n\nexport default class Dialog extends PureComponent<DialogProps, DialogState> {\n static hideShowTriggers = DialogTriggerEventEnum;\n static positions = DialogPositionEnum;\n static animationTypes = AnimationTypeEnum;\n static defaultProps = {\n position: \"top\",\n modifiers: [] as Modifier<any>[],\n moveBy: { main: 0, secondary: 0 },\n showDelay: 100,\n hideDelay: 100,\n showTrigger: Dialog.hideShowTriggers.MOUSE_ENTER,\n hideTrigger: Dialog.hideShowTriggers.MOUSE_LEAVE,\n showOnDialogEnter: false,\n shouldShowOnMount: false,\n disable: false,\n open: false,\n animationType: Dialog.animationTypes.EXPAND,\n preventAnimationOnMount: false,\n tooltip: false,\n onDialogDidShow: NOOP,\n onDialogDidHide: NOOP,\n onClickOutside: NOOP,\n onContentClick: NOOP,\n useDerivedStateFromProps: false,\n hideWhenReferenceHidden: false,\n shouldCallbackOnMount: false,\n instantShowAndHide: false,\n addKeyboardHideShowTriggersByDefault: false,\n observeContentResize: false\n };\n private showTimeout: NodeJS.Timeout;\n private hideTimeout: NodeJS.Timeout;\n context!: React.ContextType<typeof LayerContext>;\n\n constructor(props: DialogProps) {\n super(props);\n this.state = {\n shouldUseDerivedStateFromProps: props.useDerivedStateFromProps,\n isOpen: props.shouldShowOnMount\n };\n\n // Binding section.\n this.onMouseEnter = this.onMouseEnter.bind(this);\n this.onMouseLeave = this.onMouseLeave.bind(this);\n this.onMouseDown = this.onMouseDown.bind(this);\n this.onClick = this.onClick.bind(this);\n this.onFocus = this.onFocus.bind(this);\n this.onBlur = this.onBlur.bind(this);\n this.isShown = this.isShown.bind(this);\n this.onEsc = this.onEsc.bind(this);\n this.onClickOutside = this.onClickOutside.bind(this);\n this.onDialogEnter = this.onDialogEnter.bind(this);\n this.onDialogLeave = this.onDialogLeave.bind(this);\n this.getContainer = this.getContainer.bind(this);\n this.onContentClick = this.onContentClick.bind(this);\n this.onKeyDown = this.onKeyDown.bind(this);\n this.closeDialogOnEscape = this.closeDialogOnEscape.bind(this);\n this.onContextMenu = this.onContextMenu.bind(this);\n\n // Timeouts\n this.hideTimeout = null;\n this.showTimeout = null;\n }\n\n closeDialogOnEscape(event: KeyboardEvent) {\n const { isOpen } = this.state;\n if (!isOpen) {\n return;\n }\n switch (event.key) {\n case \"Escape\":\n this.hideDialogIfNeeded(event, DialogTriggerEventEnum.ESCAPE_KEY);\n break;\n case \"Tab\":\n this.handleEvent(DialogTriggerEventEnum.TAB_KEY, event.target, event);\n break;\n case \"Enter\":\n this.handleEvent(DialogTriggerEventEnum.ENTER, event.target, event);\n break;\n default:\n break;\n }\n }\n\n componentDidMount() {\n const { shouldCallbackOnMount, onDialogDidShow } = this.props;\n const { isOpen } = this.state;\n if (isClient()) {\n document.addEventListener(\"keyup\", this.closeDialogOnEscape);\n }\n if (shouldCallbackOnMount && isOpen) {\n onDialogDidShow && onDialogDidShow();\n }\n }\n\n componentWillUnmount() {\n if (isClient()) {\n document.removeEventListener(\"keyup\", this.closeDialogOnEscape);\n }\n }\n\n static getDerivedStateFromProps(nextProps: DialogProps, state: DialogState): DialogState {\n if (state.shouldUseDerivedStateFromProps) {\n return { isOpen: nextProps.isOpen };\n }\n return null;\n }\n\n getContainer() {\n const { containerSelector } = this.props;\n const containerElement = document.querySelector(containerSelector);\n if (!containerElement || !(containerElement instanceof Element)) {\n const { layerRef } = this.context;\n if (layerRef?.current) {\n return layerRef.current;\n }\n return document.body;\n }\n return containerElement;\n }\n\n showDialog(event: DialogEvent, eventName: DialogTriggerEvent | string, options: { preventAnimation?: boolean } = {}) {\n const { showDelay, instantShowAndHide, getDynamicShowDelay } = this.props;\n let finalShowDelay = showDelay;\n let preventAnimation = options.preventAnimation;\n if (getDynamicShowDelay) {\n const dynamicDelayObj = getDynamicShowDelay();\n finalShowDelay = dynamicDelayObj.showDelay || 0;\n preventAnimation = preventAnimation || dynamicDelayObj.preventAnimation;\n }\n\n if (instantShowAndHide) {\n this.onShowDialog(event, eventName);\n this.setState({ isOpen: true, preventAnimation });\n this.showTimeout = null;\n } else {\n this.showTimeout = setTimeout(() => {\n this.onShowDialog(event, eventName);\n this.showTimeout = null;\n this.setState({ isOpen: true, preventAnimation });\n }, finalShowDelay);\n }\n }\n\n onShowDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n if (this.isShown()) return;\n const { onDialogDidShow } = this.props;\n onDialogDidShow(event, eventName);\n }\n\n showDialogIfNeeded(event: DialogEvent, eventName: DialogTriggerEvent | string, options = {}) {\n const { disable } = this.props;\n if (disable) {\n return;\n }\n\n if (this.hideTimeout) {\n clearTimeout(this.hideTimeout);\n this.hideTimeout = null;\n }\n\n if (!this.showTimeout) {\n this.showDialog(event, eventName, options);\n }\n }\n\n hideDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n const { hideDelay, instantShowAndHide } = this.props;\n if (instantShowAndHide) {\n this.onHideDialog(event, eventName);\n this.setState({ isOpen: false });\n this.hideTimeout = null;\n } else {\n this.hideTimeout = setTimeout(() => {\n this.onHideDialog(event, eventName);\n this.setState({ isOpen: false });\n this.hideTimeout = null;\n }, hideDelay);\n }\n }\n\n onHideDialog(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n const { onDialogDidHide } = this.props;\n if (onDialogDidHide) onDialogDidHide(event, eventName);\n }\n\n hideDialogIfNeeded(event: DialogEvent, eventName: DialogTriggerEvent | string) {\n if (this.showTimeout) {\n clearTimeout(this.showTimeout);\n this.showTimeout = null;\n }\n\n if (this.hideTimeout) {\n return;\n }\n this.hideDialog(event, eventName);\n }\n\n handleEvent(eventName: DialogTriggerEvent, target: EventTarget, event: DialogEvent) {\n const { showTriggerIgnoreClass, hideTriggerIgnoreClass } = this.props;\n if (\n this.isShowTrigger(eventName) &&\n !this.isShown() &&\n !isInsideClass(target as HTMLElement, showTriggerIgnoreClass)\n ) {\n return this.showDialogIfNeeded(event, eventName);\n }\n\n if (this.isHideTrigger(eventName) && !isInsideClass(target as HTMLElement, hideTriggerIgnoreClass)) {\n return this.hideDialogIfNeeded(event, eventName);\n }\n }\n\n isShown() {\n const { isOpen } = this.state;\n const { open } = this.props;\n\n return isOpen || open;\n }\n\n isShowTrigger(eventName: DialogTriggerEvent) {\n const { showTrigger, addKeyboardHideShowTriggersByDefault } = this.props;\n const showTriggersArray = convertToArray(showTrigger);\n\n if (addKeyboardHideShowTriggersByDefault) {\n if (eventName === \"focus\" && showTriggersArray.indexOf(\"mouseenter\") > -1) {\n return true;\n }\n }\n\n return showTriggersArray.indexOf(eventName) > -1;\n }\n\n isHideTrigger(eventName: DialogTriggerEvent) {\n const { hideTrigger, addKeyboardHideShowTriggersByDefault } = this.props;\n const hideTriggersArray = convertToArray(hideTrigger);\n\n if (addKeyboardHideShowTriggersByDefault) {\n if (eventName === \"blur\" && hideTriggersArray.indexOf(\"mouseleave\") > -1) {\n return true;\n }\n }\n\n return hideTriggersArray.indexOf(eventName) > -1;\n }\n\n onMouseEnter(e: React.MouseEvent) {\n this.handleEvent(\"mouseenter\", e.target, e);\n }\n\n onMouseLeave(e: React.MouseEvent) {\n this.handleEvent(\"mouseleave\", e.target, e);\n }\n\n onClick(e: React.MouseEvent) {\n if (e.button) return;\n this.handleEvent(\"click\", e.target, e);\n }\n\n onKeyDown(event: React.KeyboardEvent) {\n if (event.key === \"Enter\") {\n this.handleEvent(\"enter\", event.target, event);\n }\n\n if (event.key === \"Tab\") {\n this.handleEvent(\"tab\", event.target, event);\n }\n }\n\n onMouseDown(e: React.MouseEvent) {\n if (e.button) return;\n this.handleEvent(\"mousedown\", e.target, e);\n }\n\n onFocus(e: React.FocusEvent) {\n this.handleEvent(\"focus\", e.target, e);\n }\n\n onBlur(e: React.FocusEvent) {\n this.handleEvent(\"blur\", e.relatedTarget, e);\n }\n\n onEsc(e: React.KeyboardEvent) {\n this.handleEvent(\"esckey\", e.target, e);\n }\n\n onContextMenu(e: React.MouseEvent) {\n const isShown = this.isShown();\n if ((this.isShowTrigger(\"contextmenu\") && !isShown) || (this.isHideTrigger(\"contextmenu\") && isShown)) {\n e.preventDefault();\n }\n this.handleEvent(\"contextmenu\", e.target, e);\n }\n\n onClickOutside(event: React.MouseEvent) {\n const { onClickOutside } = this.props;\n this.handleEvent(\"clickoutside\", event.target, event);\n onClickOutside(event);\n }\n\n onDialogEnter(event: React.MouseEvent) {\n const { showOnDialogEnter } = this.props;\n if (showOnDialogEnter) this.showDialogIfNeeded(event, \"DialogEnter\");\n }\n\n onDialogLeave(event: React.MouseEvent) {\n const { showOnDialogEnter } = this.props;\n if (showOnDialogEnter) this.hideDialogIfNeeded(event, \"DialogLeave\");\n }\n\n onContentClick(e: React.MouseEvent) {\n const { onContentClick } = this.props;\n this.handleEvent(\"onContentClick\", e.target, e);\n onContentClick(e);\n }\n\n render() {\n const {\n wrapperClassName,\n content,\n startingEdge,\n children,\n preventAnimationOnMount,\n animationType,\n position,\n showDelay,\n moveBy,\n modifiers,\n tooltip,\n tooltipClassName,\n referenceWrapperClassName,\n zIndex,\n hideWhenReferenceHidden,\n disableContainerScroll,\n containerSelector,\n observeContentResize,\n id,\n \"data-testid\": dataTestId\n } = this.props;\n const { preventAnimation } = this.state;\n const overrideDataTestId = dataTestId || getTestId(ComponentDefaultTestId.DIALOG, id);\n\n const animationTypeCalculated = preventAnimationOnMount || preventAnimation ? undefined : animationType;\n const contentRendered = isFunction(content) ? content() : content;\n\n if (!contentRendered) {\n return children;\n }\n return (\n <Manager>\n <Reference>\n {({ ref }) => {\n return (\n <Refable\n className={cx(referenceWrapperClassName)}\n ref={ref}\n onBlur={chainOnPropsAndInstance(\"onBlur\", this, this.props)}\n onKeyDown={chainOnPropsAndInstance(\"onKeyDown\", this, this.props)}\n onClick={chainOnPropsAndInstance(\"onClick\", this, this.props)}\n onFocus={chainOnPropsAndInstance(\"onFocus\", this, this.props)}\n onMouseDown={chainOnPropsAndInstance(\"onMouseDown\", this, this.props)}\n onMouseEnter={chainOnPropsAndInstance(\"onMouseEnter\", this, this.props)}\n onMouseLeave={chainOnPropsAndInstance(\"onMouseLeave\", this, this.props)}\n onContextMenu={chainOnPropsAndInstance(\"onContextMenu\", this, this.props)}\n >\n {children}\n </Refable>\n );\n }}\n </Reference>\n {isClient() &&\n createPortal(\n <Popper\n placement={position as unknown as PopperJS.Placement}\n modifiers={[\n {\n name: \"offset\",\n options: {\n offset: [moveBy.secondary, moveBy.main]\n }\n },\n {\n name: \"zIndex\",\n enabled: true,\n phase: \"write\",\n fn({ state }) {\n if (zIndex) {\n state.styles.popper.zIndex = String(zIndex);\n }\n return state;\n }\n },\n {\n name: \"rotator\",\n enabled: true,\n phase: \"write\",\n fn({ state }) {\n if (!state.styles.arrow) {\n return state;\n }\n // const reg = new RegExp(\n // /translate\\(([0-9].*)px, ([0-9].*)px\\)/\n // );\n // const transform = state.styles.arrow.transform;\n // const res = reg.exec(transform);\n // state.styles.popper.transformOrigin = `${100 -\n // res[1]}% ${100 - res[2]}%`;\n state.styles.arrow.transform = `${state.styles.arrow.transform} rotate(45deg)`;\n return state;\n }\n },\n {\n name: \"observeContentResize\",\n enabled: observeContentResize,\n phase: \"beforeWrite\",\n fn() {},\n effect({ state, instance }) {\n const observer = new ResizeObserver(() => {\n instance.update();\n });\n observer.observe(state.elements.popper);\n\n return () => {\n observer.disconnect();\n };\n }\n },\n ...modifiers\n ]}\n >\n {({ placement, style, ref, arrowProps, isReferenceHidden }) => {\n if (!this.isShown() && placement) {\n return null;\n }\n\n if (hideWhenReferenceHidden && isReferenceHidden) {\n const event = new CustomEvent(\"onReferenceHidden\");\n this.hideDialog(event, \"onReferenceHidden\");\n }\n\n return (\n <DialogContent\n data-testid={overrideDataTestId}\n isReferenceHidden={hideWhenReferenceHidden && isReferenceHidden}\n onMouseEnter={this.onDialogEnter}\n onMouseLeave={this.onDialogLeave}\n onClickOutside={this.onClickOutside}\n onContextMenu={this.onContextMenu}\n onEsc={this.onEsc}\n animationType={animationTypeCalculated}\n position={placement}\n wrapperClassName={wrapperClassName}\n startingEdge={startingEdge}\n isOpen={this.isShown()}\n showDelay={showDelay}\n styleObject={style}\n ref={ref}\n onClick={this.onContentClick}\n hasTooltip={!!tooltip}\n containerSelector={containerSelector}\n disableContainerScroll={disableContainerScroll}\n >\n {contentRendered}\n {tooltip && (\n <div\n style={arrowProps.style}\n ref={arrowProps.ref}\n className={cx(styles.arrow, tooltipClassName)}\n data-placement={placement}\n />\n )}\n </DialogContent>\n );\n }}\n </Popper>,\n this.getContainer()\n )}\n </Manager>\n );\n }\n}\n\nfunction chainOnPropsAndInstance(name: string, instance: Dialog, props: DialogProps) {\n // @ts-ignore\n return chainFunctions([props[name], instance[name]], true);\n}\n\nDialog.contextType = LayerContext;\n"],"names":["Dialog","_PureComponent","props","_this","_classCallCheck","_callSuper","state","shouldUseDerivedStateFromProps","useDerivedStateFromProps","isOpen","shouldShowOnMount","onMouseEnter","bind","onMouseLeave","onMouseDown","onClick","onFocus","onBlur","isShown","onEsc","onClickOutside","onDialogEnter","onDialogLeave","getContainer","onContentClick","onKeyDown","closeDialogOnEscape","onContextMenu","hideTimeout","showTimeout","_inherits","PureComponent","_createClass","key","value","event","this","hideDialogIfNeeded","DialogTriggerEventEnum","ESCAPE_KEY","handleEvent","TAB_KEY","target","ENTER","_this$props","shouldCallbackOnMount","onDialogDidShow","isClient","document","addEventListener","removeEventListener","containerElement","querySelector","containerSelector","Element","layerRef","context","current","body","eventName","_this2","_this$props2","instantShowAndHide","getDynamicShowDelay","finalShowDelay","showDelay","preventAnimation","dynamicDelayObj","onShowDialog","setState","setTimeout","options","arguments","length","undefined","disable","clearTimeout","showDialog","_this3","_this$props3","hideDelay","onHideDialog","onDialogDidHide","hideDialog","_this$props4","showTriggerIgnoreClass","hideTriggerIgnoreClass","isShowTrigger","isInsideClass","isHideTrigger","showDialogIfNeeded","open","_this$props5","addKeyboardHideShowTriggersByDefault","showTriggersArray","convertToArray","showTrigger","indexOf","_this$props6","hideTriggersArray","hideTrigger","e","button","relatedTarget","preventDefault","showOnDialogEnter","_this4","_this$props7","wrapperClassName","content","startingEdge","children","preventAnimationOnMount","animationType","position","moveBy","modifiers","tooltip","tooltipClassName","referenceWrapperClassName","zIndex","hideWhenReferenceHidden","disableContainerScroll","observeContentResize","overrideDataTestId","getTestId","ComponentDefaultTestId","DIALOG","id","animationTypeCalculated","contentRendered","isFunction","React","Manager","createElement","Reference","_ref","ref","Refable","className","cx","chainOnPropsAndInstance","createPortal","Popper","placement","name","offset","secondary","main","enabled","phase","fn","_ref2","styles","popper","String","_ref3","arrow","transform","concat","effect","_ref4","instance","observer","ResizeObserver","update","observe","elements","disconnect","_toConsumableArray","_ref5","style","arrowProps","isReferenceHidden","CustomEvent","DialogContent","styleObject","hasTooltip","nextProps","chainFunctions","hideShowTriggers","positions","DialogPositionEnum","animationTypes","AnimationTypeEnum","defaultProps","MOUSE_ENTER","MOUSE_LEAVE","EXPAND","NOOP","contextType","LayerContext"],"mappings":"u6B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MenuItem/MenuItem.tsx"],"sourcesContent":["import React, { AriaAttributes, ForwardedRef, ReactElement, forwardRef, useMemo, useRef } from \"react\";\nimport Tooltip, { TooltipProps } from \"../../../components/Tooltip/Tooltip\";\nimport Icon from \"../../../components/Icon/Icon\";\nimport useIsOverflowing from \"../../../hooks/useIsOverflowing/useIsOverflowing\";\nimport { SubIcon, VibeComponent, VibeComponentProps, withStaticProps } from \"../../../types\";\nimport { IconType } from \"../../Icon\";\nimport { CloseMenuOption, MenuChild } from \"../Menu/MenuConstants\";\nimport Label from \"../../Label/Label\";\nimport styles from \"./MenuItem.module.scss\";\nimport BaseMenuItem from \"./components/BaseMenuItem/BaseMenuItem\";\nimport MenuItemIcon from \"./components/MenuItemIcon/MenuItemIcon\";\nimport { TooltipPositions } from \"../../Tooltip/Tooltip.types\";\nimport { TooltipPositions as TooltipPositionsEnum } from \"../../Tooltip/TooltipConstants\";\nimport { SubmenuPosition } from \"./MenuItem.types\";\n\nexport interface MenuItemProps extends VibeComponentProps {\n title?: string;\n label?: string | React.ReactElement<typeof Label>;\n icon?: SubIcon;\n iconType?: IconType;\n iconBackgroundColor?: string;\n disabled?: boolean;\n disableReason?: string;\n selected?: boolean;\n onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;\n activeItemIndex?: number;\n setActiveItemIndex?: (index: number) => void;\n index?: number;\n key?: string;\n isParentMenuVisible?: boolean;\n resetOpenSubMenuIndex?: () => void;\n hasOpenSubMenu?: boolean;\n setSubMenuIsOpenByIndex?: (index: number, isOpen: boolean) => void;\n useDocumentEventListeners?: boolean;\n tooltipContent?: string;\n tooltipPosition?: TooltipPositions;\n tooltipShowDelay?: number;\n tooltipProps?: Partial<TooltipProps>;\n onMouseLeave?: (event: React.MouseEvent) => void;\n onMouseEnter?: (event: React.MouseEvent) => void;\n /**\n * Class name which is added to div which wraps an Icon\n */\n iconWrapperClassName?: string;\n isInitialSelectedState?: boolean;\n shouldScrollMenu?: boolean;\n closeMenu?: (option: CloseMenuOption) => void;\n menuRef?: React.RefObject<HTMLElement>;\n //// TODO: [breaking] MenuItem can accept only Menu element as first level child, it accepts MenuChild[] as children even though it is not valid\n children?: MenuChild | MenuChild[];\n /**\n * Type of menu item with sub menu, which has two click/hover options-\n * 1. click on the main menu item will trigger onClick\n * 2. click/hover on icon button will open the sub menu\n */\n splitMenuItem?: boolean;\n \"aria-label\"?: AriaAttributes[\"aria-label\"];\n submenuPosition?: SubmenuPosition;\n
|
|
1
|
+
{"version":3,"file":"MenuItem.js","sources":["../../../../../src/components/Menu/MenuItem/MenuItem.tsx"],"sourcesContent":["import React, { AriaAttributes, ForwardedRef, ReactElement, forwardRef, useMemo, useRef } from \"react\";\nimport Tooltip, { TooltipProps } from \"../../../components/Tooltip/Tooltip\";\nimport Icon from \"../../../components/Icon/Icon\";\nimport useIsOverflowing from \"../../../hooks/useIsOverflowing/useIsOverflowing\";\nimport { SubIcon, VibeComponent, VibeComponentProps, withStaticProps } from \"../../../types\";\nimport { IconType } from \"../../Icon\";\nimport { CloseMenuOption, MenuChild } from \"../Menu/MenuConstants\";\nimport Label from \"../../Label/Label\";\nimport styles from \"./MenuItem.module.scss\";\nimport BaseMenuItem from \"./components/BaseMenuItem/BaseMenuItem\";\nimport MenuItemIcon from \"./components/MenuItemIcon/MenuItemIcon\";\nimport { TooltipPositions } from \"../../Tooltip/Tooltip.types\";\nimport { TooltipPositions as TooltipPositionsEnum } from \"../../Tooltip/TooltipConstants\";\nimport { SubmenuPosition } from \"./MenuItem.types\";\n\nexport interface MenuItemProps extends VibeComponentProps {\n title?: string;\n label?: string | React.ReactElement<typeof Label>;\n icon?: SubIcon;\n iconType?: IconType;\n iconBackgroundColor?: string;\n disabled?: boolean;\n disableReason?: string;\n selected?: boolean;\n onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;\n activeItemIndex?: number;\n setActiveItemIndex?: (index: number) => void;\n index?: number;\n key?: string;\n isParentMenuVisible?: boolean;\n resetOpenSubMenuIndex?: () => void;\n hasOpenSubMenu?: boolean;\n setSubMenuIsOpenByIndex?: (index: number, isOpen: boolean) => void;\n useDocumentEventListeners?: boolean;\n tooltipContent?: string;\n tooltipPosition?: TooltipPositions;\n tooltipShowDelay?: number;\n tooltipProps?: Partial<TooltipProps>;\n onMouseLeave?: (event: React.MouseEvent) => void;\n onMouseEnter?: (event: React.MouseEvent) => void;\n /**\n * Class name which is added to div which wraps an Icon\n */\n iconWrapperClassName?: string;\n isInitialSelectedState?: boolean;\n shouldScrollMenu?: boolean;\n closeMenu?: (option: CloseMenuOption) => void;\n menuRef?: React.RefObject<HTMLElement>;\n //// TODO: [breaking] MenuItem can accept only Menu element as first level child, it accepts MenuChild[] as children even though it is not valid\n children?: MenuChild | MenuChild[];\n /**\n * Type of menu item with sub menu, which has two click/hover options-\n * 1. click on the main menu item will trigger onClick\n * 2. click/hover on icon button will open the sub menu\n */\n splitMenuItem?: boolean;\n \"aria-label\"?: AriaAttributes[\"aria-label\"];\n submenuPosition?: SubmenuPosition;\n}\n\nexport interface MenuItemTitleComponentProps extends Omit<MenuItemProps, \"title\"> {\n title: ReactElement;\n \"aria-label\": NonNullable<AriaAttributes[\"aria-label\"]>;\n}\n\nconst MenuItem: VibeComponent<MenuItemProps | MenuItemTitleComponentProps> & {\n iconType?: typeof Icon.type;\n isSelectable?: boolean;\n isMenuChild?: boolean;\n tooltipPositions?: typeof TooltipPositionsEnum;\n} = forwardRef(\n (\n {\n className,\n iconWrapperClassName,\n title = \"\",\n label = \"\",\n icon = \"\",\n iconType,\n iconBackgroundColor,\n disabled = false,\n disableReason,\n selected = false,\n key,\n children,\n tooltipContent,\n tooltipPosition = \"right\",\n tooltipShowDelay = 300,\n tooltipProps,\n \"aria-label\": ariaLabel,\n ...baseMenuProps\n }: MenuItemProps | MenuItemTitleComponentProps,\n ref: ForwardedRef<HTMLElement>\n ) => {\n const titleRef = useRef();\n\n // if \"title\" is a component ariaLabel is mandatory\n const iconLabel = ariaLabel ?? (title as string);\n\n const isTitleHoveredAndOverflowing = useIsOverflowing({ ref: titleRef });\n const shouldShowTooltip = isTitleHoveredAndOverflowing || disabled || tooltipContent;\n\n const finalTooltipContent = useMemo(() => {\n if (disabled) return disableReason;\n if (tooltipContent) return tooltipContent;\n return title;\n }, [disableReason, disabled, title, tooltipContent]);\n\n const renderLabel = useMemo(() => {\n if (!label) return;\n if (typeof label === \"string\") {\n return <Label kind=\"line\" text={label} />;\n }\n if (React.isValidElement(label) && label.type === Label) {\n return label;\n }\n }, [label]);\n\n return (\n <Tooltip\n content={shouldShowTooltip ? finalTooltipContent : null}\n position={tooltipPosition}\n showDelay={tooltipShowDelay}\n {...tooltipProps}\n >\n <BaseMenuItem\n key={key}\n ref={ref}\n subMenu={children}\n className={className}\n disabled={disabled}\n selected={selected}\n {...baseMenuProps}\n >\n {Boolean(icon) && (\n <MenuItemIcon\n icon={icon}\n type={iconType}\n label={iconLabel}\n disabled={disabled}\n selected={selected}\n backgroundColor={iconBackgroundColor}\n wrapperClassName={iconWrapperClassName}\n />\n )}\n <div ref={titleRef} className={styles.title}>\n {title}\n </div>\n {renderLabel}\n </BaseMenuItem>\n </Tooltip>\n );\n }\n);\n\nObject.assign(MenuItem, {\n isSelectable: true,\n isMenuChild: true\n});\n\nexport default withStaticProps(MenuItem, {\n iconType: Icon.type,\n tooltipPositions: TooltipPositionsEnum\n});\n"],"names":["MenuItem","forwardRef","_a","ref","className","iconWrapperClassName","_a$title","title","_a$label","label","_a$icon","icon","iconType","iconBackgroundColor","_a$disabled","disabled","disableReason","_a$selected","selected","key","children","tooltipContent","_a$tooltipPosition","tooltipPosition","_a$tooltipShowDelay","tooltipShowDelay","tooltipProps","ariaLabel","baseMenuProps","__rest","titleRef","useRef","iconLabel","shouldShowTooltip","useIsOverflowing","finalTooltipContent","useMemo","renderLabel","React","createElement","Label","kind","text","isValidElement","type","Tooltip","Object","assign","content","position","showDelay","BaseMenuItem","subMenu","MenuItemIcon","backgroundColor","wrapperClassName","styles","isSelectable","isMenuChild","withStaticProps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ADT,CAGF,GAAG,CAACA,IAEJ,OACE6B,EAACC,cAAAM,EACCC,OAAAC,OAAA,CAAAC,QAASf,EAAoBE,EAAsB,KACnDc,SAAU1B,EACV2B,UAAWzB,GACPC,GAEJY,EAACC,cAAAY,EACCL,OAAAC,OAAA,CAAA5B,IAAKA,EACLhB,IAAKA,EACLiD,QAAShC,EACThB,UAAWA,EACXW,SAAUA,EACVG,SAAUA,GACNU,KAEKjB,GACP2B,gBAACe,EAAY,CACX1C,KAAMA,EACNiC,KAAMhC,EACNH,MAAOuB,EACPjB,SAAUA,EACVG,SAAUA,EACVoC,gBAAiBzC,EACjB0C,iBAAkBlD,IAGtBiC,EAAKC,cAAA,MAAA,CAAApC,IAAK2B,EAAU1B,UAAWoD,EAAOjD,OACnCA,GAEF8B,GAIT,IAGFS,OAAOC,OAAO/C,EAAU,CACtByD,cAAc,EACdC,aAAa,IAGf,IAAeC,EAAAA,EAAgB3D,EAAU,CACvCY,SAAUgD,EAAKhB,KACfiB,iBAAkBC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{useRef as n,useMemo as o}from"react";import t from"../../../../DialogContentContainer/DialogContentContainer.js";import i from"../../../../../hooks/usePopover.js";import{Placement as s}from"../../../../../hooks/popoverConstants.js";import r from"../../../../../hooks/ssr/useIsomorphicLayoutEffect.js";var l=function(l){var u,c=l.anchorRef,a=l.open,p=l.autoFocusOnMount,m=l.onClose,v=l.children,f=l.submenuPosition,d=
|
|
1
|
+
import e,{useRef as n,useMemo as o}from"react";import t from"../../../../DialogContentContainer/DialogContentContainer.js";import i from"../../../../../hooks/usePopover.js";import{Placement as s}from"../../../../../hooks/popoverConstants.js";import r from"../../../../../hooks/ssr/useIsomorphicLayoutEffect.js";var l=function(l){var u,c=l.anchorRef,a=l.open,p=l.autoFocusOnMount,m=l.onClose,v=l.children,f=l.submenuPosition,d=n(null),b=n(null);r((function(){p&&a&&(null==d?void 0:d.current)&&requestAnimationFrame((function(){d.current.focus()}))}),[p,a]);var h=o((function(){return"left"===f?s.LEFT_START:void 0}),[f]),j=i(null==c?void 0:c.current,null==b?void 0:b.current,{isOpen:a,placement:h}),C=j.styles,g=j.attributes,y=v&&e.Children.only(v);return(null===(u=null==y?void 0:y.type)||void 0===u?void 0:u.isMenu)?e.createElement("div",Object.assign({style:Object.assign(Object.assign({},C.popper),{visibility:a?"visible":"hidden"})},g.popper,{ref:b}),y&&a&&e.createElement(t,null,e.cloneElement(y,Object.assign(Object.assign({},null==y?void 0:y.props),{isVisible:a,isSubMenu:!0,onClose:m,ref:d,useDocumentEventListeners:!p})))):(console.error("MenuItem can accept only Menu element as first level child, this element is not valid: ",y),null)};export{l as default};
|
|
2
2
|
//# sourceMappingURL=MenuItemSubMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItemSubMenu.js","sources":["../../../../../../../src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.tsx"],"sourcesContent":["import React, { useMemo, useRef } from \"react\";\nimport DialogContentContainer from \"../../../../DialogContentContainer/DialogContentContainer\";\nimport usePopover from \"../../../../../hooks/usePopover\";\nimport { MenuChild } from \"../../../Menu/MenuConstants\";\nimport { MenuItemSubMenuProps } from \"./MenuItemSubMenu.types\";\nimport { Placement } from \"../../../../../hooks/popoverConstants\";\nimport useIsomorphicLayoutEffect from \"../../../../../hooks/ssr/useIsomorphicLayoutEffect\";\n\nconst MenuItemSubMenu = ({\n anchorRef,\n open,\n autoFocusOnMount,\n onClose,\n children,\n submenuPosition
|
|
1
|
+
{"version":3,"file":"MenuItemSubMenu.js","sources":["../../../../../../../src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.tsx"],"sourcesContent":["import React, { useMemo, useRef } from \"react\";\nimport DialogContentContainer from \"../../../../DialogContentContainer/DialogContentContainer\";\nimport usePopover from \"../../../../../hooks/usePopover\";\nimport { MenuChild } from \"../../../Menu/MenuConstants\";\nimport { MenuItemSubMenuProps } from \"./MenuItemSubMenu.types\";\nimport { Placement } from \"../../../../../hooks/popoverConstants\";\nimport useIsomorphicLayoutEffect from \"../../../../../hooks/ssr/useIsomorphicLayoutEffect\";\n\nconst MenuItemSubMenu = ({\n anchorRef,\n open,\n autoFocusOnMount,\n onClose,\n children,\n submenuPosition\n}: MenuItemSubMenuProps) => {\n const childRef = useRef<HTMLDivElement>(null);\n const popperElementRef = useRef<HTMLDivElement>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (!autoFocusOnMount || !open || !childRef?.current) {\n return;\n }\n requestAnimationFrame(() => {\n childRef.current.focus();\n });\n }, [autoFocusOnMount, open]);\n\n const submenuPlacement = useMemo(\n () => (submenuPosition === \"left\" ? Placement.LEFT_START : undefined),\n [submenuPosition]\n );\n\n const { styles: popoverStyles, attributes: popoverAttributes } = usePopover(\n anchorRef?.current,\n popperElementRef?.current,\n {\n isOpen: open,\n placement: submenuPlacement\n }\n );\n\n const subMenu: MenuChild = children && React.Children.only(children);\n if (!subMenu?.type?.isMenu) {\n console.error(\"MenuItem can accept only Menu element as first level child, this element is not valid: \", subMenu);\n return null;\n }\n\n return (\n <div\n style={{ ...popoverStyles.popper, visibility: open ? \"visible\" : \"hidden\" }}\n {...popoverAttributes.popper}\n ref={popperElementRef}\n >\n {subMenu && open && (\n <DialogContentContainer>\n {React.cloneElement(subMenu, {\n ...subMenu?.props,\n isVisible: open,\n isSubMenu: true,\n onClose,\n ref: childRef,\n useDocumentEventListeners: !autoFocusOnMount\n })}\n </DialogContentContainer>\n )}\n </div>\n );\n};\n\nexport default MenuItemSubMenu;\n"],"names":["MenuItemSubMenu","_ref","anchorRef","open","autoFocusOnMount","onClose","children","submenuPosition","childRef","useRef","popperElementRef","useIsomorphicLayoutEffect","current","requestAnimationFrame","focus","submenuPlacement","useMemo","Placement","LEFT_START","undefined","_usePopover","usePopover","isOpen","placement","popoverStyles","styles","popoverAttributes","attributes","subMenu","React","Children","only","_a","type","isMenu","createElement","Object","assign","style","popper","visibility","ref","DialogContentContainer","cloneElement","props","isVisible","isSubMenu","useDocumentEventListeners","console","error"],"mappings":"uTAQA,IAAMA,EAAkB,SAAHC,GAOM,MANzBC,EAASD,EAATC,UACAC,EAAIF,EAAJE,KACAC,EAAgBH,EAAhBG,iBACAC,EAAOJ,EAAPI,QACAC,EAAQL,EAARK,SACAC,EAAeN,EAAfM,gBAEMC,EAAWC,EAAuB,MAClCC,EAAmBD,EAAuB,MAEhDE,GAA0B,WACnBP,GAAqBD,IAASK,aAAA,EAAAA,EAAUI,UAG7CC,uBAAsB,WACpBL,EAASI,QAAQE,OACnB,GACF,GAAG,CAACV,EAAkBD,IAEtB,IAAMY,EAAmBC,GACvB,WAAA,MAA2B,SAApBT,EAA6BU,EAAUC,gBAAaC,CAAS,GACpE,CAACZ,IAGHa,EAAiEC,EAC/DnB,aAAA,EAAAA,EAAWU,QACXF,aAAA,EAAAA,EAAkBE,QAClB,CACEU,OAAQnB,EACRoB,UAAWR,IALCS,EAAaJ,EAArBK,OAAmCC,EAAiBN,EAA7BO,WASzBC,EAAqBtB,GAAYuB,EAAMC,SAASC,KAAKzB,GAC3D,OAAoB,QAAf0B,EAAAJ,aAAA,EAAAA,EAASK,YAAM,IAAAD,OAAA,EAAAA,EAAAE,QAMlBL,EAAAM,cAAA,MAAAC,OAAAC,OAAA,CACEC,MAAKF,OAAAC,OAAAD,OAAAC,OAAA,GAAOb,EAAce,QAAQ,CAAAC,WAAYrC,EAAO,UAAY,YAC7DuB,EAAkBa,QACtBE,IAAK/B,IAEJkB,GAAWzB,GACV0B,gBAACa,EAAsB,KACpBb,EAAMc,aAAaf,EAAOQ,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EACtBT,aAAA,EAAAA,EAASgB,OAAK,CACjBC,UAAW1C,EACX2C,WAAW,EACXzC,QAAAA,EACAoC,IAAKjC,EACLuC,2BAA4B3C,QAlBpC4C,QAAQC,MAAM,0FAA2FrB,GAClG,KAuBX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useMemo as e}from"react";import{usePopper as t}from"react-popper";import{Placement as
|
|
1
|
+
import{useMemo as e}from"react";import{usePopper as t}from"react-popper";import{Placement as r}from"./popoverConstants.js";import o from"./ssr/useIsomorphicLayoutEffect.js";import s from"./useForceUpdate.js";var i=r.RIGHT_START,a={name:"flip",options:{fallbackPlacements:[r.RIGHT_END,r.LEFT_START,r.LEFT_END]}};function n(r,n,p){var m=p.isOpen,f=p.placement,l=void 0===f?i:f,c=s();o((function(){c()}),[r,n,c]);var u=e((function(){return{placement:l,modifiers:[a,{name:"displayNone",enabled:!0,phase:"write",fn:function(e){var t=e.state;return t.styles.popper.visibility=m?"visible":"hidden",t}}]}}),[m,l]),d=t(r,n,u);return{styles:d.styles,attributes:d.attributes}}export{n as default};
|
|
2
2
|
//# sourceMappingURL=usePopover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePopover.js","sources":["../../../src/hooks/usePopover.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { usePopper } from \"react-popper\";\nimport { Placement } from \"./popoverConstants\";\nimport useIsomorphicLayoutEffect from \"./ssr/useIsomorphicLayoutEffect\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport type { Options, State } from \"@popperjs/core\";\
|
|
1
|
+
{"version":3,"file":"usePopover.js","sources":["../../../src/hooks/usePopover.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { usePopper } from \"react-popper\";\nimport { Placement } from \"./popoverConstants\";\nimport useIsomorphicLayoutEffect from \"./ssr/useIsomorphicLayoutEffect\";\nimport useForceUpdate from \"./useForceUpdate\";\nimport type { Options, State } from \"@popperjs/core\";\n\nconst { RIGHT_START, RIGHT_END, LEFT_START, LEFT_END } = Placement;\n\nconst FLIP_MODIFIER = {\n name: \"flip\",\n options: {\n fallbackPlacements: [RIGHT_END, LEFT_START, LEFT_END]\n }\n};\n\nexport default function usePopover(\n referenceElement: HTMLElement,\n popperElement: HTMLElement,\n {\n isOpen,\n placement = RIGHT_START\n }: {\n isOpen?: boolean;\n placement?: Placement;\n }\n) {\n const forceUpdate = useForceUpdate();\n\n // we have to use forceUpdate because\n // usePopper need to run again after any refs changes, even after the first render.\n useIsomorphicLayoutEffect(() => {\n forceUpdate();\n }, [referenceElement, popperElement, forceUpdate]);\n\n const popperOptions: Pick<Options, \"placement\" | \"modifiers\"> = useMemo(() => {\n return {\n placement,\n modifiers: [\n FLIP_MODIFIER,\n {\n name: \"displayNone\",\n enabled: true,\n phase: \"write\",\n fn: ({ state }: { state: State }) => {\n state.styles.popper.visibility = isOpen ? \"visible\" : \"hidden\";\n return state;\n }\n }\n ]\n };\n }, [isOpen, placement]);\n\n const { styles, attributes } = usePopper(referenceElement, popperElement, popperOptions);\n\n return { styles, attributes };\n}\n"],"names":["RIGHT_START","Placement","FLIP_MODIFIER","name","options","fallbackPlacements","RIGHT_END","LEFT_START","LEFT_END","usePopover","referenceElement","popperElement","_ref","isOpen","_ref$placement","placement","forceUpdate","useForceUpdate","useIsomorphicLayoutEffect","popperOptions","useMemo","modifiers","enabled","phase","fn","_ref2","state","styles","popper","visibility","_usePopper","usePopper","attributes"],"mappings":"gNAOA,IAAQA,EAAiDC,EAAjDD,YAEFE,EAAgB,CACpBC,KAAM,OACNC,QAAS,CACPC,mBAAoB,CALiCJ,EAApCK,UAAoCL,EAAzBM,WAAyBN,EAAbO,YASpB,SAAAC,EACtBC,EACAC,EAA0BC,GAOzB,IALCC,EAAMD,EAANC,OAAMC,EAAAF,EACNG,UAAAA,OAAYf,IAAHc,EAAGd,EAAWc,EAMnBE,EAAcC,IAIpBC,GAA0B,WACxBF,GACD,GAAE,CAACN,EAAkBC,EAAeK,IAErC,IAAMG,EAA0DC,GAAQ,WACtE,MAAO,CACLL,UAAAA,EACAM,UAAW,CACTnB,EACA,CACEC,KAAM,cACNmB,SAAS,EACTC,MAAO,QACPC,GAAI,SAAAC,GAAgC,IAA7BC,EAAKD,EAALC,MAEL,OADAA,EAAMC,OAAOC,OAAOC,WAAahB,EAAS,UAAY,SAC/Ca,CACT,IAIR,GAAG,CAACb,EAAQE,IAEZe,EAA+BC,EAAUrB,EAAkBC,EAAeQ,GAE1E,MAAO,CAAEQ,OAFKG,EAANH,OAESK,WAFSF,EAAVE,WAGlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibe/core",
|
|
3
|
-
"version": "3.16.0
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"description": "Official monday.com UI resources for application development in React.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@popperjs/core": "2.11.6",
|
|
85
|
-
"@vibe/icons": "1.3.1
|
|
85
|
+
"@vibe/icons": "1.3.1",
|
|
86
86
|
"a11y-dialog": "^7.5.2",
|
|
87
87
|
"body-scroll-lock": "^4.0.0-beta.0",
|
|
88
88
|
"browserslist-config-monday": "1.0.6",
|
|
@@ -268,5 +268,5 @@
|
|
|
268
268
|
"browserslist": [
|
|
269
269
|
"extends browserslist-config-monday"
|
|
270
270
|
],
|
|
271
|
-
"gitHead": "
|
|
271
|
+
"gitHead": "783a17128434c26a75c0094d5eb05662d885df9e"
|
|
272
272
|
}
|
package/dist/mocked_classnames/src/components/Dialog/modifiers/observeContentResizeModifier.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=function(){return{name:"observeContentResize",enabled:arguments.length>0&&void 0!==arguments[0]&&arguments[0],phase:"beforeWrite",fn:function(){},effect:function(e){var n=e.state,t=e.instance,r=new ResizeObserver((function(){t.update()}));return r.observe(n.elements.popper),function(){r.disconnect()}}}};export{e as createObserveContentResizeModifier};
|
|
2
|
-
//# sourceMappingURL=observeContentResizeModifier.js.map
|
package/dist/mocked_classnames/src/components/Dialog/modifiers/observeContentResizeModifier.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observeContentResizeModifier.js","sources":["../../../../../../src/components/Dialog/modifiers/observeContentResizeModifier.ts"],"sourcesContent":["import { Modifier } from \"react-popper\";\n\nexport const createObserveContentResizeModifier = (isEnabled = false): Modifier<\"observeContentResize\"> => ({\n name: \"observeContentResize\",\n enabled: isEnabled,\n phase: \"beforeWrite\",\n fn() {},\n effect({ state, instance }) {\n const observer = new ResizeObserver(() => {\n instance.update();\n });\n observer.observe(state.elements.popper);\n\n return () => {\n observer.disconnect();\n };\n }\n});\n"],"names":["createObserveContentResizeModifier","name","enabled","arguments","length","undefined","phase","fn","effect","_ref","state","instance","observer","ResizeObserver","update","observe","elements","popper","disconnect"],"mappings":"AAEaA,IAAAA,EAAqC,WAAkB,MAAwC,CAC1GC,KAAM,uBACNC,QAF0DC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,IAAAA,UAAA,GAG1DG,MAAO,cACPC,GAAEA,WAAK,EACPC,OAAM,SAAAC,GAAoB,IAAjBC,EAAKD,EAALC,MAAOC,EAAQF,EAARE,SACRC,EAAW,IAAIC,gBAAe,WAClCF,EAASG,QACX,IAGA,OAFAF,EAASG,QAAQL,EAAMM,SAASC,QAEzB,WACLL,EAASM,aAEb,EACD"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=function(){return{name:"observeContentResize",enabled:arguments.length>0&&void 0!==arguments[0]&&arguments[0],phase:"beforeWrite",fn:function(){},effect:function(e){var n=e.state,t=e.instance,r=new ResizeObserver((function(){t.update()}));return r.observe(n.elements.popper),function(){r.disconnect()}}}};export{e as createObserveContentResizeModifier};
|
|
2
|
-
//# sourceMappingURL=observeContentResizeModifier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observeContentResizeModifier.js","sources":["../../../../../src/components/Dialog/modifiers/observeContentResizeModifier.ts"],"sourcesContent":["import { Modifier } from \"react-popper\";\n\nexport const createObserveContentResizeModifier = (isEnabled = false): Modifier<\"observeContentResize\"> => ({\n name: \"observeContentResize\",\n enabled: isEnabled,\n phase: \"beforeWrite\",\n fn() {},\n effect({ state, instance }) {\n const observer = new ResizeObserver(() => {\n instance.update();\n });\n observer.observe(state.elements.popper);\n\n return () => {\n observer.disconnect();\n };\n }\n});\n"],"names":["createObserveContentResizeModifier","name","enabled","arguments","length","undefined","phase","fn","effect","_ref","state","instance","observer","ResizeObserver","update","observe","elements","popper","disconnect"],"mappings":"AAEaA,IAAAA,EAAqC,WAAkB,MAAwC,CAC1GC,KAAM,uBACNC,QAF0DC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,IAAAA,UAAA,GAG1DG,MAAO,cACPC,GAAEA,WAAK,EACPC,OAAM,SAAAC,GAAoB,IAAjBC,EAAKD,EAALC,MAAOC,EAAQF,EAARE,SACRC,EAAW,IAAIC,gBAAe,WAClCF,EAASG,QACX,IAGA,OAFAF,EAASG,QAAQL,EAAMM,SAASC,QAEzB,WACLL,EAASM,aAEb,EACD"}
|