@salutejs/plasma-new-hope 0.175.3-canary.1512.11555735717.0 → 0.175.3-canary.1515.11569861732.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js.map +1 -1
- package/cjs/components/Dropdown/ui/DropdownOld/DropdownOld.js +2 -4
- package/cjs/components/Dropdown/ui/DropdownOld/DropdownOld.js.map +1 -1
- package/cjs/components/Popover/Popover.js +1 -2
- package/cjs/components/Popover/Popover.js.map +1 -1
- package/cjs/components/Popup/Popup.js +2 -2
- package/cjs/components/Popup/Popup.js.map +1 -1
- package/cjs/components/Popup/PopupContext.js +1 -1
- package/cjs/components/Popup/PopupContext.js.map +1 -1
- package/cjs/components/Portal/Portal.js +4 -0
- package/cjs/components/Portal/Portal.js.map +1 -1
- package/emotion/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/emotion/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/emotion/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/emotion/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/emotion/cjs/components/Dropdown/ui/DropdownOld/DropdownOld.js +4 -6
- package/emotion/cjs/components/Popover/Popover.js +1 -2
- package/emotion/cjs/components/Popup/Popup.js +1 -1
- package/emotion/cjs/components/Popup/PopupContext.js +1 -1
- package/emotion/cjs/components/Portal/Portal.js +4 -0
- package/emotion/es/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/emotion/es/components/Dropdown/ui/DropdownOld/DropdownOld.js +2 -4
- package/emotion/es/components/Popover/Popover.js +1 -2
- package/emotion/es/components/Popup/Popup.js +1 -1
- package/emotion/es/components/Popup/PopupContext.js +1 -1
- package/emotion/es/components/Portal/Portal.js +4 -0
- package/es/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/es/components/Dropdown/ui/DropdownDivider/DropdownDivider.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/es/components/Dropdown/ui/DropdownFooter/DropdownFooter.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/es/components/Dropdown/ui/DropdownGroup/DropdownGroup.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/es/components/Dropdown/ui/DropdownHeader/DropdownHeader.js.map +1 -1
- package/es/components/Dropdown/ui/DropdownOld/DropdownOld.js +2 -4
- package/es/components/Dropdown/ui/DropdownOld/DropdownOld.js.map +1 -1
- package/es/components/Popover/Popover.js +1 -2
- package/es/components/Popover/Popover.js.map +1 -1
- package/es/components/Popup/Popup.js +2 -2
- package/es/components/Popup/Popup.js.map +1 -1
- package/es/components/Popup/PopupContext.js +1 -1
- package/es/components/Popup/PopupContext.js.map +1 -1
- package/es/components/Portal/Portal.js +4 -0
- package/es/components/Portal/Portal.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/styled-components/cjs/components/Dropdown/ui/DropdownOld/DropdownOld.js +4 -6
- package/styled-components/cjs/components/Popover/Popover.js +1 -2
- package/styled-components/cjs/components/Popup/Popup.js +1 -1
- package/styled-components/cjs/components/Popup/PopupContext.js +1 -1
- package/styled-components/cjs/components/Portal/Portal.js +4 -0
- package/styled-components/es/components/Dropdown/ui/DropdownDivider/DropdownDivider.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownFooter/DropdownFooter.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownGroup/DropdownGroup.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownHeader/DropdownHeader.js +2 -2
- package/styled-components/es/components/Dropdown/ui/DropdownOld/DropdownOld.js +2 -4
- package/styled-components/es/components/Popover/Popover.js +1 -2
- package/styled-components/es/components/Popup/Popup.js +1 -1
- package/styled-components/es/components/Popup/PopupContext.js +1 -1
- package/styled-components/es/components/Portal/Portal.js +4 -0
- package/types/components/Dropdown/ui/DropdownDivider/DropdownDivider.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownFooter/DropdownFooter.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownGroup/DropdownGroup.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownHeader/DropdownHeader.d.ts.map +1 -1
- package/types/components/Dropdown/ui/DropdownOld/DropdownOld.d.ts.map +1 -1
- package/types/components/Popover/Popover.d.ts.map +1 -1
- package/types/components/Popup/PopupContext.d.ts.map +1 -1
- package/types/components/Portal/Portal.d.ts.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popover.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import React, { useRef, useCallback, useEffect, useState, forwardRef } from 'react';\nimport type { CSSProperties } from 'react';\nimport { usePopper } from 'react-popper';\nimport { useForkRef } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../engines/types';\nimport { useFocusTrap } from '../../hooks';\nimport { cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport type { PopoverPlacement, PopoverProps } from './Popover.types';\nimport { StyledArrow, StyledPopover, StyledRoot, StyledWrapper } from './Popover.styles';\nimport { classes } from './Popover.tokens';\n\nexport const ESCAPE_KEYCODE = 27;\nexport const POPOVER_PORTAL_ID = 'plasma-popover-root';\n\n/**\n * Всплывающее окно с возможностью позиционирования\n * и вызова по клику либо ховеру.\n */\nexport const popoverRoot = (Root: RootProps<HTMLDivElement, PopoverProps>) =>\n forwardRef<HTMLDivElement, PopoverProps>(\n (\n {\n target,\n children,\n isOpen,\n opened,\n trigger = 'click',\n hasArrow,\n frame = 'document',\n className,\n placement = 'auto',\n offset = [0, 0],\n zIndex,\n isFocusTrapped = true,\n closeOnEsc = true,\n preventOverflow = true,\n usePortal = false,\n view,\n onToggle,\n closeOnOverlayClick,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = Boolean(isOpen || opened);\n\n const rootRef = useRef<HTMLDivElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const handleRef = useForkRef<HTMLDivElement>(rootRef, outerRootRef);\n const portalRef = useRef<HTMLElement | null>(null);\n\n const trapRef = useFocusTrap(innerIsOpen && isFocusTrapped);\n\n const popoverForkRef = useForkRef<HTMLDivElement>(popoverRef, trapRef);\n\n const [arrowElement, setArrowElement] = useState<HTMLSpanElement | null>(null);\n\n const [, forceRender] = useState(false);\n\n const isAutoArray = Array.isArray(placement);\n const isAuto = isAutoArray || (placement as PopoverPlacement).startsWith('auto');\n\n const initialStyles = {\n visibility: innerIsOpen ? 'visible' : 'hidden',\n opacity: innerIsOpen ? 1 : 0,\n } as CSSProperties;\n\n const { styles, attributes, forceUpdate } = usePopper(rootRef.current, popoverRef.current, {\n // TODO: #1121\n // eslint-disable-next-line no-nested-ternary\n placement: isAutoArray\n ? placement[0]?.endsWith('start')\n ? 'auto-start'\n : 'auto'\n : (placement as PopoverPlacement),\n modifiers: [\n {\n name: 'preventOverflow',\n options: {\n mainAxis: preventOverflow,\n },\n },\n { name: 'offset', options: { offset: [offset[0], offset[1]] } },\n {\n name: 'flip',\n enabled: isAuto,\n options: {\n allowedAutoPlacements: isAutoArray ? (placement as PopoverPlacement[]) : [],\n },\n },\n {\n name: 'arrow',\n options: {\n element: arrowElement,\n },\n },\n ],\n });\n\n const onEscape = useCallback(\n (event: KeyboardEvent) => {\n if (innerIsOpen && closeOnEsc && event.keyCode === ESCAPE_KEYCODE) {\n onToggle?.(false, event);\n }\n },\n [closeOnEsc, innerIsOpen, onToggle],\n );\n\n const onDocumentClick = useCallback(\n (event: MouseEvent) => {\n if (innerIsOpen && closeOnOverlayClick && onToggle) {\n const targetIsRoot = event.target === rootRef.current;\n const rootHasTarget = rootRef.current?.contains(event.target as Element);\n const popoverRootHasTarget = popoverRef.current?.contains(event.target as Element);\n\n if (!targetIsRoot && !rootHasTarget && !popoverRootHasTarget) {\n onToggle(false, event);\n }\n }\n },\n [closeOnOverlayClick, innerIsOpen, onToggle],\n );\n\n const onClick = useCallback<React.MouseEventHandler>(\n (event) => {\n if (trigger === 'click') {\n const targetIsPopover = event.target === popoverRef.current;\n const rootHasTarget = popoverRef.current?.contains(event.target as Element);\n\n if (!targetIsPopover && !rootHasTarget) {\n onToggle?.(!innerIsOpen, event);\n }\n }\n },\n [trigger, innerIsOpen, onToggle],\n );\n\n const onMouseEnter = useCallback<React.MouseEventHandler>(\n (event) => {\n if (trigger === 'hover') {\n onToggle?.(true, event);\n }\n },\n [trigger, onToggle],\n );\n\n const onMouseLeave = useCallback<React.MouseEventHandler>(\n (event) => {\n if (trigger === 'hover') {\n onToggle?.(false, event);\n }\n },\n [trigger, onToggle],\n );\n\n const onFocus = useCallback<React.FocusEventHandler>(\n (event) => {\n if (trigger === 'hover') {\n onToggle?.(true, event);\n }\n },\n [trigger, onToggle],\n );\n\n const onBlur = useCallback<React.FocusEventHandler>(\n (event) => {\n if (trigger === 'hover') {\n onToggle?.(false, event);\n }\n },\n [trigger, onToggle],\n );\n\n useEffect(() => {\n document.addEventListener('click', onDocumentClick);\n return () => document.removeEventListener('click', onDocumentClick);\n }, [innerIsOpen, onToggle]);\n\n useEffect(() => {\n window.addEventListener('keydown', onEscape);\n return () => window.removeEventListener('keydown', onEscape);\n }, [closeOnEsc, innerIsOpen, onToggle]);\n\n useEffect(() => {\n let portal = document.getElementById(POPOVER_PORTAL_ID);\n\n if (typeof frame !== 'string' && frame && frame.current) {\n portal = frame.current;\n }\n\n if (!usePortal) {\n portal = rootRef.current;\n }\n\n if (!portal) {\n portal = document.createElement('div');\n portal.setAttribute('id', POPOVER_PORTAL_ID);\n\n if (typeof frame === 'string' && frame !== 'document') {\n document.getElementById(frame)?.appendChild(portal);\n } else {\n document.body.appendChild(portal);\n }\n }\n\n portalRef.current = portal;\n\n /**\n * Изменение стейта нужно для того, чтобы Popup\n * отобразился после записи DOM элемента в portalRef.current\n */\n forceRender(true);\n }, []);\n\n useEffect(() => {\n if (!innerIsOpen || !forceUpdate) {\n return;\n }\n\n /*\n * INFO: Метод forceUpdate содержит в себе flushSync и приводит\n * к повторному рендеру компонента, который уже находится в процессе рендера.\n * Данный хак, нужен для того, чтобы это поведение избежать и перенаправить\n * вызов метода в очередь микрозадач.\n */\n Promise.resolve().then(forceUpdate);\n }, [innerIsOpen, children, forceUpdate]);\n\n return (\n <StyledWrapper className={classes.wrapper} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>\n <StyledRoot\n ref={handleRef}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n className={cx(className, classes.target)}\n >\n {target}\n </StyledRoot>\n {children && portalRef.current && (\n <Portal container={portalRef.current}>\n <Root view={view} className={className} {...rest}>\n <StyledPopover\n {...attributes.popper}\n className={classes.root}\n ref={popoverForkRef}\n style={{\n ...styles.popper,\n ...{ display: innerIsOpen ? 'block' : 'none' },\n ...initialStyles,\n }}\n zIndex={zIndex}\n >\n {hasArrow && (\n <StyledArrow\n className={classes.arrow}\n ref={setArrowElement}\n style={styles.arrow}\n {...attributes.arrow}\n />\n )}\n {children}\n </StyledPopover>\n </Root>\n </Portal>\n )}\n </StyledWrapper>\n );\n },\n );\n\nexport const popoverConfig = {\n name: 'Popover',\n tag: 'div',\n layout: popoverRoot,\n base: '',\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["ESCAPE_KEYCODE","POPOVER_PORTAL_ID","popoverRoot","Root","forwardRef","_ref","outerRootRef","_placement$","target","children","isOpen","opened","_ref$trigger","trigger","hasArrow","_ref$frame","frame","className","_ref$placement","placement","_ref$offset","offset","zIndex","_ref$isFocusTrapped","isFocusTrapped","_ref$closeOnEsc","closeOnEsc","_ref$preventOverflow","preventOverflow","_ref$usePortal","usePortal","view","onToggle","closeOnOverlayClick","rest","_objectWithoutProperties","_excluded","innerIsOpen","Boolean","rootRef","useRef","popoverRef","handleRef","useForkRef","portalRef","trapRef","useFocusTrap","popoverForkRef","_useState","useState","_useState2","_slicedToArray","arrowElement","setArrowElement","_useState3","_useState4","forceRender","isAutoArray","Array","isArray","isAuto","startsWith","initialStyles","visibility","opacity","_usePopper","usePopper","current","endsWith","modifiers","name","options","mainAxis","enabled","allowedAutoPlacements","element","styles","attributes","forceUpdate","onEscape","useCallback","event","keyCode","onDocumentClick","_rootRef$current","_popoverRef$current","targetIsRoot","rootHasTarget","contains","popoverRootHasTarget","onClick","_popoverRef$current2","targetIsPopover","onMouseEnter","onMouseLeave","onFocus","onBlur","useEffect","document","addEventListener","removeEventListener","window","portal","getElementById","createElement","setAttribute","_document$getElementB","appendChild","body","Promise","resolve","then","React","StyledWrapper","classes","wrapper","StyledRoot","ref","cx","Portal","container","_extends","StyledPopover","popper","root","style","_objectSpread","display","StyledArrow","arrow","popoverConfig","tag","layout","base","variations","css","viewCSS","def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AI,CAAA,eAC5C8E,KAAA,CAAAR,aAAA,CAACkB,aAAa,EAAAD,QAAA,CAAA,EAAA,EACN5C,UAAU,CAAC8C,MAAM,EAAA;MACrB1G,SAAS,EAAEiG,OAAO,CAACU,IAAK;AACxBP,MAAAA,GAAG,EAAEtE,cAAe;MACpB8E,KAAK,EAAAC,cAAA,CAAAA,cAAA,CAAAA,cAAA,CACElD,EAAAA,EAAAA,MAAM,CAAC+C,MAAM,CACb,EAAA;AAAEI,QAAAA,OAAO,EAAE1F,WAAW,GAAG,OAAO,GAAG,MAAA;OAAQ,CAAA,EAC3CyB,aAAa,CAClB;AACFxC,MAAAA,MAAM,EAAEA,MAAAA;KAEPR,CAAAA,EAAAA,QAAQ,iBACLkG,KAAA,CAAAR,aAAA,CAACwB,WAAW,EAAAP,QAAA,CAAA;MACRxG,SAAS,EAAEiG,OAAO,CAACe,KAAM;AACzBZ,MAAAA,GAAG,EAAEhE,eAAgB;MACrBwE,KAAK,EAAEjD,MAAM,CAACqD,KAAAA;KACVpD,EAAAA,UAAU,CAACoD,KAAK,CACvB,CACJ,EACAxH,QACU,CACb,CACF,CAED,CAAC,CAAA;AAExB,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMyH,aAAa,GAAG;AACzB5D,EAAAA,IAAI,EAAE,SAAS;AACf6D,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElI,WAAW;AACnBmI,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,UAAU,EAAE;AACRvG,IAAAA,IAAI,EAAE;AACFwG,MAAAA,GAAG,EAAEC,IAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN1G,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"Popover.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import React, { useRef, useCallback, useEffect, useState, forwardRef } from 'react';\nimport type { CSSProperties } from 'react';\nimport { usePopper } from 'react-popper';\nimport { useFocusTrap, useForkRef } from '@salutejs/plasma-core';\n\nimport type { RootProps } from '../../engines/types';\nimport { cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport type { PopoverPlacement, PopoverProps } from './Popover.types';\nimport { StyledArrow, StyledPopover, StyledRoot, StyledWrapper } from './Popover.styles';\nimport { classes } from './Popover.tokens';\n\nexport const ESCAPE_KEYCODE = 27;\nexport const POPOVER_PORTAL_ID = 'plasma-popover-root';\n\n/**\n * Всплывающее окно с возможностью позиционирования\n * и вызова по клику либо ховеру.\n */\nexport const popoverRoot = (Root: RootProps<HTMLDivElement, PopoverProps>) =>\n forwardRef<HTMLDivElement, PopoverProps>(\n (\n {\n target,\n children,\n isOpen,\n opened,\n trigger = 'click',\n hasArrow,\n frame = 'document',\n className,\n placement = 'auto',\n offset = [0, 0],\n zIndex,\n isFocusTrapped = true,\n closeOnEsc = true,\n preventOverflow = true,\n usePortal = false,\n view,\n onToggle,\n closeOnOverlayClick,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = Boolean(isOpen || opened);\n\n const rootRef = useRef<HTMLDivElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const handleRef = useForkRef<HTMLDivElement>(rootRef, outerRootRef);\n const portalRef = useRef<HTMLElement | null>(null);\n\n const trapRef = useFocusTrap(innerIsOpen && isFocusTrapped);\n\n const popoverForkRef = useForkRef<HTMLDivElement>(popoverRef, trapRef);\n\n const [arrowElement, setArrowElement] = useState<HTMLSpanElement | null>(null);\n\n const [, forceRender] = useState(false);\n\n const isAutoArray = Array.isArray(placement);\n const isAuto = isAutoArray || (placement as PopoverPlacement).startsWith('auto');\n\n const initialStyles = {\n visibility: innerIsOpen ? 'visible' : 'hidden',\n opacity: innerIsOpen ? 1 : 0,\n } as CSSProperties;\n\n const { styles, attributes, forceUpdate } = usePopper(rootRef.current, popoverRef.current, {\n // TODO: #1121\n // eslint-disable-next-line no-nested-ternary\n placement: isAutoArray\n ? placement[0]?.endsWith('start')\n ? 'auto-start'\n : 'auto'\n : (placement as PopoverPlacement),\n modifiers: [\n {\n name: 'preventOverflow',\n options: {\n mainAxis: preventOverflow,\n },\n },\n { name: 'offset', options: { offset: [offset[0], offset[1]] } },\n {\n name: 'flip',\n enabled: isAuto,\n options: {\n allowedAutoPlacements: isAutoArray ? (placement as PopoverPlacement[]) : [],\n },\n },\n {\n name: 'arrow',\n options: {\n element: arrowElement,\n },\n },\n ],\n });\n\n const onEscape = useCallback(\n (event: KeyboardEvent) => {\n if (innerIsOpen && closeOnEsc && event.keyCode === ESCAPE_KEYCODE) {\n onToggle?.(false, event);\n }\n },\n [closeOnEsc, innerIsOpen, onToggle],\n );\n\n const onDocumentClick = useCallback(\n (event: MouseEvent) => {\n if (innerIsOpen && closeOnOverlayClick && onToggle) {\n const targetIsRoot = event.target === rootRef.current;\n const rootHasTarget = rootRef.current?.contains(event.target as Element);\n const popoverRootHasTarget = popoverRef.current?.contains(event.target as Element);\n\n if (!targetIsRoot && !rootHasTarget && !popoverRootHasTarget) {\n onToggle(false, event);\n }\n }\n },\n [closeOnOverlayClick, innerIsOpen, onToggle],\n );\n\n const onClick = useCallback<React.MouseEventHandler>(\n (event) => {\n if (trigger === 'click') {\n const targetIsPopover = event.target === popoverRef.current;\n const rootHasTarget = popoverRef.current?.contains(event.target as Element);\n\n if (!targetIsPopover && !rootHasTarget) {\n onToggle?.(!innerIsOpen, event);\n }\n }\n },\n [trigger, innerIsOpen, onToggle],\n );\n\n const onMouseEnter = useCallback<React.MouseEventHandler>(\n (event) => {\n if (trigger === 'hover') {\n onToggle?.(true, event);\n }\n },\n [trigger, onToggle],\n );\n\n const onMouseLeave = useCallback<React.MouseEventHandler>(\n (event) => {\n if (trigger === 'hover') {\n onToggle?.(false, event);\n }\n },\n [trigger, onToggle],\n );\n\n const onFocus = useCallback<React.FocusEventHandler>(\n (event) => {\n if (trigger === 'hover') {\n onToggle?.(true, event);\n }\n },\n [trigger, onToggle],\n );\n\n const onBlur = useCallback<React.FocusEventHandler>(\n (event) => {\n if (trigger === 'hover') {\n onToggle?.(false, event);\n }\n },\n [trigger, onToggle],\n );\n\n useEffect(() => {\n document.addEventListener('click', onDocumentClick);\n return () => document.removeEventListener('click', onDocumentClick);\n }, [innerIsOpen, onToggle]);\n\n useEffect(() => {\n window.addEventListener('keydown', onEscape);\n return () => window.removeEventListener('keydown', onEscape);\n }, [closeOnEsc, innerIsOpen, onToggle]);\n\n useEffect(() => {\n let portal = document.getElementById(POPOVER_PORTAL_ID);\n\n if (typeof frame !== 'string' && frame && frame.current) {\n portal = frame.current;\n }\n\n if (!usePortal) {\n portal = rootRef.current;\n }\n\n if (!portal) {\n portal = document.createElement('div');\n portal.setAttribute('id', POPOVER_PORTAL_ID);\n\n if (typeof frame === 'string' && frame !== 'document') {\n document.getElementById(frame)?.appendChild(portal);\n } else {\n document.body.appendChild(portal);\n }\n }\n\n portalRef.current = portal;\n\n /**\n * Изменение стейта нужно для того, чтобы Popup\n * отобразился после записи DOM элемента в portalRef.current\n */\n forceRender(true);\n }, []);\n\n useEffect(() => {\n if (!innerIsOpen || !forceUpdate) {\n return;\n }\n\n /*\n * INFO: Метод forceUpdate содержит в себе flushSync и приводит\n * к повторному рендеру компонента, который уже находится в процессе рендера.\n * Данный хак, нужен для того, чтобы это поведение избежать и перенаправить\n * вызов метода в очередь микрозадач.\n */\n Promise.resolve().then(forceUpdate);\n }, [innerIsOpen, children, forceUpdate]);\n\n return (\n <StyledWrapper className={classes.wrapper} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>\n <StyledRoot\n ref={handleRef}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n className={cx(className, classes.target)}\n >\n {target}\n </StyledRoot>\n {children && portalRef.current && (\n <Portal container={portalRef.current}>\n <Root view={view} className={className} {...rest}>\n <StyledPopover\n {...attributes.popper}\n className={classes.root}\n ref={popoverForkRef}\n style={{\n ...styles.popper,\n ...{ display: innerIsOpen ? 'block' : 'none' },\n ...initialStyles,\n }}\n zIndex={zIndex}\n >\n {hasArrow && (\n <StyledArrow\n className={classes.arrow}\n ref={setArrowElement}\n style={styles.arrow}\n {...attributes.arrow}\n />\n )}\n {children}\n </StyledPopover>\n </Root>\n </Portal>\n )}\n </StyledWrapper>\n );\n },\n );\n\nexport const popoverConfig = {\n name: 'Popover',\n tag: 'div',\n layout: popoverRoot,\n base: '',\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["ESCAPE_KEYCODE","POPOVER_PORTAL_ID","popoverRoot","Root","forwardRef","_ref","outerRootRef","_placement$","target","children","isOpen","opened","_ref$trigger","trigger","hasArrow","_ref$frame","frame","className","_ref$placement","placement","_ref$offset","offset","zIndex","_ref$isFocusTrapped","isFocusTrapped","_ref$closeOnEsc","closeOnEsc","_ref$preventOverflow","preventOverflow","_ref$usePortal","usePortal","view","onToggle","closeOnOverlayClick","rest","_objectWithoutProperties","_excluded","innerIsOpen","Boolean","rootRef","useRef","popoverRef","handleRef","useForkRef","portalRef","trapRef","useFocusTrap","popoverForkRef","_useState","useState","_useState2","_slicedToArray","arrowElement","setArrowElement","_useState3","_useState4","forceRender","isAutoArray","Array","isArray","isAuto","startsWith","initialStyles","visibility","opacity","_usePopper","usePopper","current","endsWith","modifiers","name","options","mainAxis","enabled","allowedAutoPlacements","element","styles","attributes","forceUpdate","onEscape","useCallback","event","keyCode","onDocumentClick","_rootRef$current","_popoverRef$current","targetIsRoot","rootHasTarget","contains","popoverRootHasTarget","onClick","_popoverRef$current2","targetIsPopover","onMouseEnter","onMouseLeave","onFocus","onBlur","useEffect","document","addEventListener","removeEventListener","window","portal","getElementById","createElement","setAttribute","_document$getElementB","appendChild","body","Promise","resolve","then","React","StyledWrapper","classes","wrapper","StyledRoot","ref","cx","Portal","container","_extends","StyledPopover","popper","root","style","_objectSpread","display","StyledArrow","arrow","popoverConfig","tag","layout","base","variations","css","vi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iB,IAAI,CAAA,eAC5C8E,KAAA,CAAAR,aAAA,CAACkB,aAAa,EAAAD,QAAA,CAAA,EAAA,EACN5C,UAAU,CAAC8C,MAAM,EAAA;MACrB1G,SAAS,EAAEiG,OAAO,CAACU,IAAK;AACxBP,MAAAA,GAAG,EAAEtE,cAAe;MACpB8E,KAAK,EAAAC,cAAA,CAAAA,cAAA,CAAAA,cAAA,CACElD,EAAAA,EAAAA,MAAM,CAAC+C,MAAM,CACb,EAAA;AAAEI,QAAAA,OAAO,EAAE1F,WAAW,GAAG,OAAO,GAAG,MAAA;OAAQ,CAAA,EAC3CyB,aAAa,CAClB;AACFxC,MAAAA,MAAM,EAAEA,MAAAA;KAEPR,CAAAA,EAAAA,QAAQ,iBACLkG,KAAA,CAAAR,aAAA,CAACwB,WAAW,EAAAP,QAAA,CAAA;MACRxG,SAAS,EAAEiG,OAAO,CAACe,KAAM;AACzBZ,MAAAA,GAAG,EAAEhE,eAAgB;MACrBwE,KAAK,EAAEjD,MAAM,CAACqD,KAAAA;KACVpD,EAAAA,UAAU,CAACoD,KAAK,CACvB,CACJ,EACAxH,QACU,CACb,CACF,CAED,CAAC,CAAA;AAExB,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMyH,aAAa,GAAG;AACzB5D,EAAAA,IAAI,EAAE,SAAS;AACf6D,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElI,WAAW;AACnBmI,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,UAAU,EAAE;AACRvG,IAAAA,IAAI,EAAE;AACFwG,MAAAA,GAAG,EAAEC,IAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN1G,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
|
@@ -6,8 +6,8 @@ import { PopupRoot } from './PopupRoot.js';
|
|
6
6
|
import { classes } from './Popup.tokens.js';
|
7
7
|
import { StyledPortalContainer } from './Popup.styles.js';
|
8
8
|
import { usePopup } from './hooks/usePopup.js';
|
9
|
-
import { Portal } from '../Portal/Portal.js';
|
10
9
|
import { canUseDOM } from '../../utils/canUseDOM.js';
|
10
|
+
import { Portal } from '../Portal/Portal.js';
|
11
11
|
|
12
12
|
var _excluded = ["id", "isOpen", "opened", "placement", "offset", "frame", "children", "overlay", "role", "zIndex", "popupInfo", "withAnimation", "className"];
|
13
13
|
var handlePosition = function handlePosition(placement, offset) {
|
@@ -121,7 +121,7 @@ var popupRoot = function popupRoot(Root) {
|
|
121
121
|
animationInfo: animationInfo,
|
122
122
|
setVisible: setVisible
|
123
123
|
}, children));
|
124
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
124
|
+
if (typeof frame !== 'string' && frame && frame.current && canUseDOM) {
|
125
125
|
return /*#__PURE__*/React.createElement(Portal, {
|
126
126
|
container: frame.current
|
127
127
|
}, rootNode);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines/types';\nimport { canUseDOM, cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupPlacementBasic, PopupPlacement, PopupPositionType, PopupProps } from './Popup.types';\nimport { PopupRoot } from './PopupRoot';\nimport { usePopup } from './hooks';\nimport { classes } from './Popup.tokens';\nimport { StyledPortalContainer } from './Popup.styles';\n\nexport const handlePosition = (\n placement: PopupPlacement,\n offset: [number, number] | [string, string],\n): PopupPositionType => {\n let x = '0rem';\n let y = '0rem';\n\n if (offset) {\n const [_x, _y] = offset;\n x = typeof _x === 'number' ? `${_x}rem` : _x;\n y = typeof _y === 'number' ? `${_y}rem` : _y;\n }\n\n if (!placement || placement === 'center') {\n return {\n left: `calc(50% + ${x})`,\n top: `calc(50% - ${y})`,\n transform: 'translate(-50%, -50%)',\n };\n }\n\n let left;\n let right;\n let top;\n let bottom;\n let transform;\n const placements = placement.split('-') as PopupPlacementBasic[];\n\n placements.forEach((placementValue: PopupPlacementBasic) => {\n switch (placementValue) {\n case 'left':\n left = x;\n break;\n case 'right':\n right = x;\n break;\n case 'top':\n top = y;\n break;\n case 'bottom':\n bottom = y;\n break;\n default:\n break;\n }\n });\n\n const isCenteredX = left === undefined && right === undefined;\n const isCenteredY = top === undefined && bottom === undefined;\n\n if (isCenteredX) {\n transform = 'translateX(-50%)';\n }\n\n if (isCenteredY) {\n transform = 'translateY(-50%)';\n }\n\n return {\n left: isCenteredX ? `calc(50% + ${x})` : left,\n right,\n top: isCenteredY ? `calc(50% - ${y})` : top,\n bottom,\n transform,\n };\n};\n\n/**\n * Базовый компонент Popup.\n */\nexport const popupRoot = (Root: RootProps<HTMLDivElement, PopupProps>) =>\n forwardRef<HTMLDivElement, PopupProps>(\n (\n {\n id,\n isOpen = false,\n opened = false,\n placement = 'center',\n offset = [0, 0],\n frame = 'document',\n children,\n overlay,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n role,\n zIndex,\n popupInfo,\n withAnimation = false,\n className,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = isOpen || opened;\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n\n const { isVisible, animationInfo, setVisible, rootId } = usePopup({\n isOpen: innerIsOpen,\n id: innerId,\n popupInfo,\n withAnimation,\n });\n\n const portalRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const innerRef = useForkRef<HTMLDivElement>(contentRef, outerRootRef);\n\n if (!isVisible && !innerIsOpen) {\n return null;\n }\n\n const cls = cx(\n className,\n animationInfo?.endAnimation ? classes.endAnimation : '',\n animationInfo?.endTransition ? classes.endTransition : '',\n );\n\n const rootNode = (\n <Root className={cls} {...rest}>\n {overlay}\n <PopupRoot\n id={innerId}\n ref={innerRef}\n position={handlePosition(placement, offset)}\n zIndex={zIndex}\n frame={frame}\n animationInfo={animationInfo}\n setVisible={setVisible}\n >\n {children}\n </PopupRoot>\n </Root>\n );\n\n if (typeof frame !== 'string' && frame && frame.current) {\n return <Portal container={frame.current}>{rootNode}</Portal>;\n }\n\n const withFrameId = typeof frame === 'string' && frame !== 'document';\n const containerElement = withFrameId && canUseDOM && document.getElementById(frame as string);\n\n if (containerElement) {\n return (\n <Portal container={containerElement}>\n <StyledPortalContainer ref={portalRef}>\n {portalRef.current && <Portal container={portalRef.current}>{rootNode}</Portal>}\n </StyledPortalContainer>{' '}\n </Portal>\n );\n }\n\n const globalPortal = canUseDOM && document.getElementById(rootId);\n\n return <>{globalPortal && <Portal container={globalPortal}>{rootNode}</Portal>}</>;\n },\n );\n\nexport const popupConfig = {\n name: 'Popup',\n tag: 'div',\n layout: popupRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["handlePosition","placement","offset","x","y","_offset","_slicedToArray","_x","_y","concat","left","top","transform","right","bottom","placements","split","forEach","placementValue","isCenteredX","undefined","isCenteredY","popupRoot","Root","forwardRef","_ref","outerRootRef","id","_ref$isOpen","isOpen","_ref$opened","opened","_ref$placement","_ref$offset","_ref$frame","frame","children","overlay","zIndex","popupInfo","_ref$withAnimation","withAnimation","className","rest","_objectWithoutProperties","_excluded","innerIsOpen","uniqId","safeUseId","innerId","_usePopup","usePopup","isVisible","animationInfo","setVisible","rootId","portalRef","useRef","contentRef","innerRef","useForkRef","cls","cx","endAnimation","classes","endTransition","rootNode","React","createElement","_extends","PopupRoot","ref","position","current","Portal","container","withFrameId","containerElement","canUseDOM","document","getElementById","StyledPortalContainer","globalPortal","Fragment","popupConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;AAaO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,SAAyB,EACzBC,MAA2C,EACvB;EACpB,IAAIC,CAAC,GAAG,MAAM,CAAA;EACd,IAAIC,CAAC,GAAG,MAAM,CAAA;AAEd,EAAA,IAAIF,MAAM,EAAE;AACR,IAAA,IAAAG,OAAA,GAAA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AAE,KAAK;AACVC,EAAAA,MAAM,EAAEjE,SAAS;AACjBkE,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;"}
|
1
|
+
{"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines/types';\nimport { canUseDOM, cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupPlacementBasic, PopupPlacement, PopupPositionType, PopupProps } from './Popup.types';\nimport { PopupRoot } from './PopupRoot';\nimport { usePopup } from './hooks';\nimport { classes } from './Popup.tokens';\nimport { StyledPortalContainer } from './Popup.styles';\n\nexport const handlePosition = (\n placement: PopupPlacement,\n offset: [number, number] | [string, string],\n): PopupPositionType => {\n let x = '0rem';\n let y = '0rem';\n\n if (offset) {\n const [_x, _y] = offset;\n x = typeof _x === 'number' ? `${_x}rem` : _x;\n y = typeof _y === 'number' ? `${_y}rem` : _y;\n }\n\n if (!placement || placement === 'center') {\n return {\n left: `calc(50% + ${x})`,\n top: `calc(50% - ${y})`,\n transform: 'translate(-50%, -50%)',\n };\n }\n\n let left;\n let right;\n let top;\n let bottom;\n let transform;\n const placements = placement.split('-') as PopupPlacementBasic[];\n\n placements.forEach((placementValue: PopupPlacementBasic) => {\n switch (placementValue) {\n case 'left':\n left = x;\n break;\n case 'right':\n right = x;\n break;\n case 'top':\n top = y;\n break;\n case 'bottom':\n bottom = y;\n break;\n default:\n break;\n }\n });\n\n const isCenteredX = left === undefined && right === undefined;\n const isCenteredY = top === undefined && bottom === undefined;\n\n if (isCenteredX) {\n transform = 'translateX(-50%)';\n }\n\n if (isCenteredY) {\n transform = 'translateY(-50%)';\n }\n\n return {\n left: isCenteredX ? `calc(50% + ${x})` : left,\n right,\n top: isCenteredY ? `calc(50% - ${y})` : top,\n bottom,\n transform,\n };\n};\n\n/**\n * Базовый компонент Popup.\n */\nexport const popupRoot = (Root: RootProps<HTMLDivElement, PopupProps>) =>\n forwardRef<HTMLDivElement, PopupProps>(\n (\n {\n id,\n isOpen = false,\n opened = false,\n placement = 'center',\n offset = [0, 0],\n frame = 'document',\n children,\n overlay,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n role,\n zIndex,\n popupInfo,\n withAnimation = false,\n className,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = isOpen || opened;\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n\n const { isVisible, animationInfo, setVisible, rootId } = usePopup({\n isOpen: innerIsOpen,\n id: innerId,\n popupInfo,\n withAnimation,\n });\n\n const portalRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const innerRef = useForkRef<HTMLDivElement>(contentRef, outerRootRef);\n\n if (!isVisible && !innerIsOpen) {\n return null;\n }\n\n const cls = cx(\n className,\n animationInfo?.endAnimation ? classes.endAnimation : '',\n animationInfo?.endTransition ? classes.endTransition : '',\n );\n\n const rootNode = (\n <Root className={cls} {...rest}>\n {overlay}\n <PopupRoot\n id={innerId}\n ref={innerRef}\n position={handlePosition(placement, offset)}\n zIndex={zIndex}\n frame={frame}\n animationInfo={animationInfo}\n setVisible={setVisible}\n >\n {children}\n </PopupRoot>\n </Root>\n );\n\n if (typeof frame !== 'string' && frame && frame.current && canUseDOM) {\n return <Portal container={frame.current}>{rootNode}</Portal>;\n }\n\n const withFrameId = typeof frame === 'string' && frame !== 'document';\n const containerElement = withFrameId && canUseDOM && document.getElementById(frame as string);\n\n if (containerElement) {\n return (\n <Portal container={containerElement}>\n <StyledPortalContainer ref={portalRef}>\n {portalRef.current && <Portal container={portalRef.current}>{rootNode}</Portal>}\n </StyledPortalContainer>{' '}\n </Portal>\n );\n }\n\n const globalPortal = canUseDOM && document.getElementById(rootId);\n\n return <>{globalPortal && <Portal container={globalPortal}>{rootNode}</Portal>}</>;\n },\n );\n\nexport const popupConfig = {\n name: 'Popup',\n tag: 'div',\n layout: popupRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["handlePosition","placement","offset","x","y","_offset","_slicedToArray","_x","_y","concat","left","top","transform","right","bottom","placements","split","forEach","placementValue","isCenteredX","undefined","isCenteredY","popupRoot","Root","forwardRef","_ref","outerRootRef","id","_ref$isOpen","isOpen","_ref$opened","opened","_ref$placement","_ref$offset","_ref$frame","frame","children","overlay","zIndex","popupInfo","_ref$withAnimation","withAnimation","className","rest","_objectWithoutProperties","_excluded","innerIsOpen","uniqId","safeUseId","innerId","_usePopup","usePopup","isVisible","animationInfo","setVisible","rootId","portalRef","useRef","contentRef","innerRef","useForkRef","cls","cx","endAnimation","classes","endTransition","rootNode","React","createElement","_extends","PopupRoot","ref","position","current","canUseDOM","Portal","container","withFrameId","containerElement","document","getElementById","StyledPortalContainer","globalPortal","Fragment","popupConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;AAaO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,SAAyB,EACzBC,MAA2C,EACvB;EACpB,IAAIC,CAAC,GAAG,MAAM,CAAA;EACd,IAAIC,CAAC,GAAG,MAAM,CAAA;AAEd,EAAA,IAAIF,MAAM,EAAE;AACR,IAAA,IAAAG,OAAA,GAAAC,cAAA,CAAiBJ,MAAM,EAAA,CAAA,CAAA;AAAhBK,MAAAA,EAAE,GAAAF,OAAA,CAAA,CAAA,CAAA;AAAEG,MAAAA,EAAE,GAAAH,OAAA,CAAA,CAAA,CAAA,CAAA;IACbF,CAAC,GAAG,OAAOI,EAAE,KAAK,QAAQ,MAAAE,MAAA,CAAMF,EAAE,EAAA,KAAA,CAAA,GAAQA,EAAE,CAAA;IAC5CH,CAAC,GAAG,OAAOI,EAAE,KAAK,QAAQ,MAAAC,MAAA,CAAMD,EAAE,EAAA,KAAA,CAAA,GAAQA,EAAE,CAAA;AAChD,GAAA;AAEA,EAAA,IAAI,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e,CAAC,CAAA;AAE7F,IAAA,IAAI2C,gBAAgB,EAAE;AAClB,MAAA,oBACIX,KAAA,CAAAC,aAAA,CAACO,MAAM,EAAA;AAACC,QAAAA,SAAS,EAAEE,gBAAAA;AAAiB,OAAA,eAChCX,KAAA,CAAAC,aAAA,CAACa,qBAAqB,EAAA;AAACV,QAAAA,GAAG,EAAEf,SAAAA;OACvBA,EAAAA,SAAS,CAACiB,OAAO,iBAAIN,KAAA,CAAAC,aAAA,CAACO,MAAM,EAAA;QAACC,SAAS,EAAEpB,SAAS,CAACiB,OAAAA;AAAQ,OAAA,EAAEP,QAAiB,CAC3D,CAAC,EAAC,GACrB,CAAC,CAAA;AAEjB,KAAA;IAEA,IAAMgB,YAAY,GAAGR,SAAS,IAAIK,QAAQ,CAACC,cAAc,CAACzB,MAAM,CAAC,CAAA;AAEjE,IAAA,oBAAOY,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAgB,QAAA,EAAGD,IAAAA,EAAAA,YAAY,iBAAIf,KAAA,CAAAC,aAAA,CAACO,MAAM,EAAA;AAACC,MAAAA,SAAS,EAAEM,YAAAA;KAAehB,EAAAA,QAAiB,CAAI,CAAC,CAAA;AACtF,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMkB,WAAW,GAAG;AACvBC,EAAAA,IAAI,EAAE,OAAO;AACbC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEjE,SAAS;AACjBkE,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;"}
|
@@ -75,7 +75,7 @@ var PopupProvider = function PopupProvider(_ref) {
|
|
75
75
|
};
|
76
76
|
return /*#__PURE__*/React.createElement(PopupContext.Provider, {
|
77
77
|
value: context
|
78
|
-
}, children, /*#__PURE__*/React.createElement(Portal, {
|
78
|
+
}, children, canUseDOM && /*#__PURE__*/React.createElement(Portal, {
|
79
79
|
container: document.body
|
80
80
|
}, /*#__PURE__*/React.createElement(StyledPortal, {
|
81
81
|
id: rootId
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PopupContext.js","sources":["../../../src/components/Popup/PopupContext.tsx"],"sourcesContent":["import React, { createContext, useState, useContext, FC, PropsWithChildren, useRef } from 'react';\n\nimport { hasModals } from '../Modal/ModalContext';\nimport { canUseDOM, safeUseId } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupContextType, PopupInfo } from './Popup.types';\nimport { StyledPortal } from './Popup.styles';\n\nexport const POPUP_PORTAL_ID = 'plasma-popup-root';\n\nconst items: PopupInfo[] = [];\n\nconst PopupContext = createContext<PopupContextType>({\n items,\n rootId: POPUP_PORTAL_ID,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n register(_info: PopupInfo): void {\n throw new Error('Function not implemented. Add PopupProvider');\n },\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n unregister(_id: string): void {\n throw new Error('Function not implemented. Add PopupProvider');\n },\n});\n\nexport const usePopupContext = () => useContext(PopupContext);\n\nexport const PopupProvider: FC<PropsWithChildren> = ({ children }) => {\n const prevBodyOverflowY = useRef(canUseDOM ? document.body.style.overflowY : '');\n // eslint-disable-next-line no-shadow\n const [items, setItems] = useState<PopupInfo[]>([]);\n\n const uuid = safeUseId();\n const rootId = `${POPUP_PORTAL_ID}-${uuid}`;\n\n const register = (info: PopupInfo) => {\n if (!canUseDOM) {\n return;\n }\n\n setItems((prevItems) => {\n if (info.info?.isModal && !hasModals(prevItems)) {\n prevBodyOverflowY.current = document.body.style.overflowY;\n document.body.style.overflowY = 'hidden';\n }\n\n return [...prevItems, info];\n });\n };\n\n const unregister = (id: string) => {\n if (!canUseDOM) {\n return;\n }\n\n setItems((prevItems) => {\n const index = prevItems.findIndex((item: PopupInfo) => id === item.id);\n\n if (index === -1) {\n return prevItems;\n }\n\n const prevHasModals = hasModals(prevItems);\n prevItems.splice(index, 1);\n\n if (prevHasModals && !hasModals(prevItems)) {\n document.body.style.overflowY = prevBodyOverflowY.current;\n }\n\n // при return prevItems не обновится контекст\n return [...prevItems];\n });\n };\n\n const context = {\n items,\n rootId,\n register,\n unregister,\n };\n\n return (\n <PopupContext.Provider value={context}>\n {children}\n <Portal container={document.body}>\n
|
1
|
+
{"version":3,"file":"PopupContext.js","sources":["../../../src/components/Popup/PopupContext.tsx"],"sourcesContent":["import React, { createContext, useState, useContext, FC, PropsWithChildren, useRef } from 'react';\n\nimport { hasModals } from '../Modal/ModalContext';\nimport { canUseDOM, safeUseId } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupContextType, PopupInfo } from './Popup.types';\nimport { StyledPortal } from './Popup.styles';\n\nexport const POPUP_PORTAL_ID = 'plasma-popup-root';\n\nconst items: PopupInfo[] = [];\n\nconst PopupContext = createContext<PopupContextType>({\n items,\n rootId: POPUP_PORTAL_ID,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n register(_info: PopupInfo): void {\n throw new Error('Function not implemented. Add PopupProvider');\n },\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n unregister(_id: string): void {\n throw new Error('Function not implemented. Add PopupProvider');\n },\n});\n\nexport const usePopupContext = () => useContext(PopupContext);\n\nexport const PopupProvider: FC<PropsWithChildren> = ({ children }) => {\n const prevBodyOverflowY = useRef(canUseDOM ? document.body.style.overflowY : '');\n // eslint-disable-next-line no-shadow\n const [items, setItems] = useState<PopupInfo[]>([]);\n\n const uuid = safeUseId();\n const rootId = `${POPUP_PORTAL_ID}-${uuid}`;\n\n const register = (info: PopupInfo) => {\n if (!canUseDOM) {\n return;\n }\n\n setItems((prevItems) => {\n if (info.info?.isModal && !hasModals(prevItems)) {\n prevBodyOverflowY.current = document.body.style.overflowY;\n document.body.style.overflowY = 'hidden';\n }\n\n return [...prevItems, info];\n });\n };\n\n const unregister = (id: string) => {\n if (!canUseDOM) {\n return;\n }\n\n setItems((prevItems) => {\n const index = prevItems.findIndex((item: PopupInfo) => id === item.id);\n\n if (index === -1) {\n return prevItems;\n }\n\n const prevHasModals = hasModals(prevItems);\n prevItems.splice(index, 1);\n\n if (prevHasModals && !hasModals(prevItems)) {\n document.body.style.overflowY = prevBodyOverflowY.current;\n }\n\n // при return prevItems не обновится контекст\n return [...prevItems];\n });\n };\n\n const context = {\n items,\n rootId,\n register,\n unregister,\n };\n\n return (\n <PopupContext.Provider value={context}>\n {children}\n {canUseDOM && (\n <Portal container={document.body}>\n <StyledPortal id={rootId} />\n </Portal>\n )}\n </PopupContext.Provider>\n );\n};\n"],"names":["POPUP_PORTAL_ID","items","PopupContext","createContext","rootId","register","_info","Error","unregister","_id","usePopupContext","useContext","PopupProvider","_ref","children","prevBodyOverflowY","useRef","canUseDOM","document","body","style","overflowY","_useState","useState","_useState2","_slicedToArray","setItems","uuid","safeUseId","concat","info","prevItems","_info$info","isModal","hasModals","current","_toConsumableArray","id","index","findIndex","item","prevHasModals","splice","context","React","createElement","Provider","value","Portal","container","StyledPortal"],"mappings":";;;;;;;;AASO,IAAMA,eAAe,GAAG,oBAAmB;AAElD,IAAMC,KAAkB,GAAG,EAAE,CAAA;AAE7B,IAAMC,YAAY,gBAAGC,aAAa,CAAmB;AACjDF,EAAAA,KAAK,EAALA,KAAK;AACLG,EAAAA,MAAM,EAAEJ,eAAe;AACvB;EACAK,QAAQ,EAAA,SAAAA,QAACC,CAAAA,KAAgB,EAAQ;AAC7B,IAAA,MAAM,IAAIC,KAAK,CAAC,6CAA6C,CAAC,CAAA;GACjE;AACD;EACAC,UAAU,EAAA,SAAAA,UAACC,CAAAA,GAAW,EAAQ;AAC1B,IAAA,MAAM,IAAIF,KAAK,CAAC,6CAA6C,CAAC,CAAA;AAClE,GAAA;AACJ,CAAC,CAAC,CAAA;AAEWG,IAAAA,eAAe,GAAG,SAAlBA,eAAeA,GAAA;EAAA,OAASC,UAAU,CAACT,YAAY,CAAC,CAAA;AAAA,EAAA;IAEhDU,aAAoC,GAAG,SAAvCA,aAAoCA,CAAAC,IAAA,EAAqB;AA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eAC7ByB,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAA;AAACb,IAAAA,EAAE,EAAEjC,MAAAA;GAAS,CACvB,CAEO,CAAC,CAAA;AAEhC;;;;"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
|
+
import { canUseDOM } from '../../utils/canUseDOM.js';
|
3
4
|
|
4
5
|
/**
|
5
6
|
* Вспомогательный компонент. Используется в Popup, Popover.
|
@@ -10,6 +11,9 @@ var Portal = function Portal(_ref) {
|
|
10
11
|
container = _ref.container,
|
11
12
|
_ref$disabled = _ref.disabled,
|
12
13
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
14
|
+
if (!canUseDOM) {
|
15
|
+
return null;
|
16
|
+
}
|
13
17
|
var portalContainer = typeof container === 'function' ? container() : container;
|
14
18
|
return /*#__PURE__*/React.createElement(React.Fragment, null, disabled && children, !disabled && /*#__PURE__*/ReactDOM.createPortal(children, portalContainer));
|
15
19
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Portal.js","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { PortalProps } from './Portal.types';\n\n/**\n * Вспомогательный компонент. Используется в Popup, Popover.\n * Представляет собой ReactDOM.createPortal() в форме компонента.\n */\nexport const Portal: FC<PortalProps> = ({ children, container, disabled = false }) => {\n const portalContainer = typeof container === 'function' ? container() : container;\n\n return (\n <>\n {disabled && children}\n {!disabled && ReactDOM.createPortal(children, portalContainer)}\n </>\n );\n};\n"],"names":["Portal","_ref","children","container","_ref$disabled","disabled","portalContainer","React","createElement","Fragment","ReactDOM","createPortal"],"mappings":"
|
1
|
+
{"version":3,"file":"Portal.js","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { canUseDOM } from '../../utils';\n\nimport { PortalProps } from './Portal.types';\n\n/**\n * Вспомогательный компонент. Используется в Popup, Popover.\n * Представляет собой ReactDOM.createPortal() в форме компонента.\n */\nexport const Portal: FC<PortalProps> = ({ children, container, disabled = false }) => {\n if (!canUseDOM) {\n return null;\n }\n\n const portalContainer = typeof container === 'function' ? container() : container;\n\n return (\n <>\n {disabled && children}\n {!disabled && ReactDOM.createPortal(children, portalContainer)}\n </>\n );\n};\n"],"names":["Portal","_ref","children","container","_ref$disabled","disabled","canUseDOM","portalContainer","React","createElement","Fragment","ReactDOM","createPortal"],"mappings":";;;;AAOA;AACA;AACA;AACA;IACaA,MAAuB,GAAG,SAA1BA,MAAuBA,CAAAC,IAAA,EAAkD;AAAA,EAAA,IAA5CC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,SAAS,GAAAF,IAAA,CAATE,SAAS;IAAAC,aAAA,GAAAH,IAAA,CAAEI,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA,CAAA;EAC3E,IAAI,CAACE,SAAS,EAAE;AACZ,IAAA,OAAO,IAAI,CAAA;AACf,GAAA;EAEA,IAAMC,eAAe,GAAG,OAAOJ,SAAS,KAAK,UAAU,GAAGA,SAAS,EAAE,GAAGA,SAAS,CAAA;EAEjF,oBACIK,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAE,QAAA,EACKL,IAAAA,EAAAA,QAAQ,IAAIH,QAAQ,EACpB,CAACG,QAAQ,iBAAIM,QAAQ,CAACC,YAAY,CAACV,QAAQ,EAAEK,eAAe,CAC/D,CAAC,CAAA;AAEX;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.175.3-canary.
|
3
|
+
"version": "0.175.3-canary.1515.11569861732.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -128,5 +128,5 @@
|
|
128
128
|
"sideEffects": [
|
129
129
|
"*.css"
|
130
130
|
],
|
131
|
-
"gitHead": "
|
131
|
+
"gitHead": "7b28c9d2677245f593173d3eab9c8351eff637f4"
|
132
132
|
}
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.dropdownDividerRoot = exports.dropdownDividerConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var
|
9
|
+
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
10
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
12
|
var _DropdownDivider = /*#__PURE__*/require("./DropdownDivider.styles");
|
@@ -26,7 +26,7 @@ var dropdownDividerRoot = exports.dropdownDividerRoot = function dropdownDivider
|
|
26
26
|
view = _ref.view,
|
27
27
|
size = _ref.size,
|
28
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
29
|
-
var uniqId = (0,
|
29
|
+
var uniqId = (0, _plasmaCore.useUniqId)();
|
30
30
|
var innerId = id || uniqId;
|
31
31
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
32
32
|
id: innerId,
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.dropdownFooterRoot = exports.dropdownFooterConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var
|
9
|
+
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
10
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
12
|
var _DropdownFooter = /*#__PURE__*/require("./DropdownFooter.styles");
|
@@ -27,7 +27,7 @@ var dropdownFooterRoot = exports.dropdownFooterRoot = function dropdownFooterRoo
|
|
27
27
|
view = _ref.view,
|
28
28
|
size = _ref.size,
|
29
29
|
rest = _objectWithoutProperties(_ref, _excluded);
|
30
|
-
var uniqId = (0,
|
30
|
+
var uniqId = (0, _plasmaCore.useUniqId)();
|
31
31
|
var innerId = id || uniqId;
|
32
32
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
33
33
|
id: innerId,
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.dropdownGroupRoot = exports.dropdownGroupConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var
|
9
|
+
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
10
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
12
|
var _DropdownGroup = /*#__PURE__*/require("./DropdownGroup.styles");
|
@@ -30,7 +30,7 @@ var dropdownGroupRoot = exports.dropdownGroupRoot = function dropdownGroupRoot(R
|
|
30
30
|
view = _ref.view,
|
31
31
|
size = _ref.size,
|
32
32
|
rest = _objectWithoutProperties(_ref, _excluded);
|
33
|
-
var uniqId = (0,
|
33
|
+
var uniqId = (0, _plasmaCore.useUniqId)();
|
34
34
|
var innerId = id || uniqId;
|
35
35
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
36
36
|
id: innerId,
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.dropdownHeaderRoot = exports.dropdownHeaderConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var
|
9
|
+
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
10
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
11
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
12
12
|
var _DropdownHeader = /*#__PURE__*/require("./DropdownHeader.styles");
|
@@ -27,7 +27,7 @@ var dropdownHeaderRoot = exports.dropdownHeaderRoot = function dropdownHeaderRoo
|
|
27
27
|
size = _ref.size,
|
28
28
|
children = _ref.children,
|
29
29
|
rest = _objectWithoutProperties(_ref, _excluded);
|
30
|
-
var uniqId = (0,
|
30
|
+
var uniqId = (0, _plasmaCore.useUniqId)();
|
31
31
|
var innerId = id || uniqId;
|
32
32
|
return /*#__PURE__*/_react["default"].createElement(Root, {
|
33
33
|
id: innerId,
|
@@ -7,12 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
exports.dropdownOldRoot = exports.dropdownOldConfig = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
9
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
10
|
-
var _hooks = /*#__PURE__*/require("../../../../hooks");
|
11
|
-
var _utils = /*#__PURE__*/require("../../../../utils");
|
12
10
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
13
11
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
14
12
|
var _Dropdown = /*#__PURE__*/require("./Dropdown.styles");
|
15
|
-
var
|
13
|
+
var _utils = /*#__PURE__*/require("./utils");
|
16
14
|
var _excluded = ["id", "target", "children", "hasArrow", "role", "view", "size", "frame", "onToggle", "isFocusTrapped", "isOpen", "opened", "placement", "trigger", "offset", "preventOverflow", "closeOnOverlayClick", "closeOnEsc"];
|
17
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
18
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
@@ -53,12 +51,12 @@ var dropdownOldRoot = exports.dropdownOldRoot = function dropdownOldRoot(Root) {
|
|
53
51
|
closeOnEsc = _ref$closeOnEsc === void 0 ? false : _ref$closeOnEsc,
|
54
52
|
rest = _objectWithoutProperties(_ref, _excluded);
|
55
53
|
var innerIsOpen = Boolean(isOpen || opened);
|
56
|
-
var uniqId = (0,
|
54
|
+
var uniqId = (0, _plasmaCore.useUniqId)();
|
57
55
|
var innerId = id || uniqId;
|
58
56
|
var rootRef = (0, _react.useRef)(null);
|
59
57
|
var dropdownRef = (0, _react.useRef)(null);
|
60
58
|
var handleRef = (0, _plasmaCore.useForkRef)(rootRef, outerRootRef);
|
61
|
-
var trapRef = (0,
|
59
|
+
var trapRef = (0, _plasmaCore.useFocusTrap)(innerIsOpen && isFocusTrapped);
|
62
60
|
var dropdownForkRef = (0, _plasmaCore.useForkRef)(dropdownRef, trapRef);
|
63
61
|
return /*#__PURE__*/_react["default"].createElement(_Dropdown.StyledPopover, {
|
64
62
|
role: role,
|
@@ -73,7 +71,7 @@ var dropdownOldRoot = exports.dropdownOldRoot = function dropdownOldRoot(Root) {
|
|
73
71
|
offset: offset,
|
74
72
|
preventOverflow: preventOverflow,
|
75
73
|
hasArrow: hasArrow,
|
76
|
-
placement: (0,
|
74
|
+
placement: (0, _utils.getPlacements)(placement),
|
77
75
|
trigger: trigger,
|
78
76
|
closeOnOverlayClick: closeOnOverlayClick,
|
79
77
|
closeOnEsc: closeOnEsc,
|
@@ -8,7 +8,6 @@ exports.popoverRoot = exports.popoverConfig = exports.POPOVER_PORTAL_ID = export
|
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
9
|
var _reactPopper = /*#__PURE__*/require("react-popper");
|
10
10
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
11
|
-
var _hooks = /*#__PURE__*/require("../../hooks");
|
12
11
|
var _utils = /*#__PURE__*/require("../../utils");
|
13
12
|
var _Portal = /*#__PURE__*/require("../Portal");
|
14
13
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
@@ -73,7 +72,7 @@ var popoverRoot = exports.popoverRoot = function popoverRoot(Root) {
|
|
73
72
|
var popoverRef = (0, _react.useRef)(null);
|
74
73
|
var handleRef = (0, _plasmaCore.useForkRef)(rootRef, outerRootRef);
|
75
74
|
var portalRef = (0, _react.useRef)(null);
|
76
|
-
var trapRef = (0,
|
75
|
+
var trapRef = (0, _plasmaCore.useFocusTrap)(innerIsOpen && isFocusTrapped);
|
77
76
|
var popoverForkRef = (0, _plasmaCore.useForkRef)(popoverRef, trapRef);
|
78
77
|
var _useState = (0, _react.useState)(null),
|
79
78
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -139,7 +139,7 @@ var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
|
139
139
|
animationInfo: animationInfo,
|
140
140
|
setVisible: setVisible
|
141
141
|
}, children));
|
142
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
142
|
+
if (typeof frame !== 'string' && frame && frame.current && _utils.canUseDOM) {
|
143
143
|
return /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
144
144
|
container: frame.current
|
145
145
|
}, rootNode);
|
@@ -91,7 +91,7 @@ var PopupProvider = exports.PopupProvider = function PopupProvider(_ref) {
|
|
91
91
|
};
|
92
92
|
return /*#__PURE__*/_react["default"].createElement(PopupContext.Provider, {
|
93
93
|
value: context
|
94
|
-
}, children, /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
94
|
+
}, children, _utils.canUseDOM && /*#__PURE__*/_react["default"].createElement(_Portal.Portal, {
|
95
95
|
container: document.body
|
96
96
|
}, /*#__PURE__*/_react["default"].createElement(_Popup.StyledPortal, {
|
97
97
|
id: rootId
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.Portal = void 0;
|
7
7
|
var _react = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react"));
|
8
8
|
var _reactDom = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-dom"));
|
9
|
+
var _utils = /*#__PURE__*/require("../../utils");
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
10
11
|
/**
|
11
12
|
* Вспомогательный компонент. Используется в Popup, Popover.
|
@@ -16,6 +17,9 @@ var Portal = exports.Portal = function Portal(_ref) {
|
|
16
17
|
container = _ref.container,
|
17
18
|
_ref$disabled = _ref.disabled,
|
18
19
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
20
|
+
if (!_utils.canUseDOM) {
|
21
|
+
return null;
|
22
|
+
}
|
19
23
|
var portalContainer = typeof container === 'function' ? container() : container;
|
20
24
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, disabled && children, !disabled && /*#__PURE__*/_reactDom["default"].createPortal(children, portalContainer));
|
21
25
|
};
|
@@ -3,7 +3,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
5
5
|
import React, { forwardRef } from 'react';
|
6
|
-
import {
|
6
|
+
import { useUniqId } from '@salutejs/plasma-core';
|
7
7
|
import { base as viewCSS } from './variations/_view/base';
|
8
8
|
import { base as sizeCSS } from './variations/_size/base';
|
9
9
|
import { StyledDropdownDivider } from './DropdownDivider.styles';
|
@@ -17,7 +17,7 @@ export var dropdownDividerRoot = function dropdownDividerRoot(Root) {
|
|
17
17
|
view = _ref.view,
|
18
18
|
size = _ref.size,
|
19
19
|
rest = _objectWithoutProperties(_ref, _excluded);
|
20
|
-
var uniqId =
|
20
|
+
var uniqId = useUniqId();
|
21
21
|
var innerId = id || uniqId;
|
22
22
|
return /*#__PURE__*/React.createElement(Root, {
|
23
23
|
id: innerId,
|
@@ -3,7 +3,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
5
5
|
import React, { forwardRef } from 'react';
|
6
|
-
import {
|
6
|
+
import { useUniqId } from '@salutejs/plasma-core';
|
7
7
|
import { base as viewCSS } from './variations/_view/base';
|
8
8
|
import { base as sizeCSS } from './variations/_size/base';
|
9
9
|
import { StyledDropdownFooter } from './DropdownFooter.styles';
|
@@ -18,7 +18,7 @@ export var dropdownFooterRoot = function dropdownFooterRoot(Root) {
|
|
18
18
|
view = _ref.view,
|
19
19
|
size = _ref.size,
|
20
20
|
rest = _objectWithoutProperties(_ref, _excluded);
|
21
|
-
var uniqId =
|
21
|
+
var uniqId = useUniqId();
|
22
22
|
var innerId = id || uniqId;
|
23
23
|
return /*#__PURE__*/React.createElement(Root, {
|
24
24
|
id: innerId,
|
@@ -3,7 +3,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
5
5
|
import React, { forwardRef } from 'react';
|
6
|
-
import {
|
6
|
+
import { useUniqId } from '@salutejs/plasma-core';
|
7
7
|
import { base as viewCSS } from './variations/_view/base';
|
8
8
|
import { base as sizeCSS } from './variations/_size/base';
|
9
9
|
import { StyledDropdownGroup, StyledDropdownLabel } from './DropdownGroup.styles';
|
@@ -21,7 +21,7 @@ export var dropdownGroupRoot = function dropdownGroupRoot(Root) {
|
|
21
21
|
view = _ref.view,
|
22
22
|
size = _ref.size,
|
23
23
|
rest = _objectWithoutProperties(_ref, _excluded);
|
24
|
-
var uniqId =
|
24
|
+
var uniqId = useUniqId();
|
25
25
|
var innerId = id || uniqId;
|
26
26
|
return /*#__PURE__*/React.createElement(Root, {
|
27
27
|
id: innerId,
|
@@ -3,7 +3,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
5
5
|
import React, { forwardRef } from 'react';
|
6
|
-
import {
|
6
|
+
import { useUniqId } from '@salutejs/plasma-core';
|
7
7
|
import { base as viewCSS } from './variations/_view/base';
|
8
8
|
import { base as sizeCSS } from './variations/_size/base';
|
9
9
|
import { StyledDropdownHeader } from './DropdownHeader.styles';
|
@@ -18,7 +18,7 @@ export var dropdownHeaderRoot = function dropdownHeaderRoot(Root) {
|
|
18
18
|
size = _ref.size,
|
19
19
|
children = _ref.children,
|
20
20
|
rest = _objectWithoutProperties(_ref, _excluded);
|
21
|
-
var uniqId =
|
21
|
+
var uniqId = useUniqId();
|
22
22
|
var innerId = id || uniqId;
|
23
23
|
return /*#__PURE__*/React.createElement(Root, {
|
24
24
|
id: innerId,
|
@@ -3,9 +3,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
5
5
|
import React, { forwardRef, useRef } from 'react';
|
6
|
-
import { useForkRef } from '@salutejs/plasma-core';
|
7
|
-
import { useFocusTrap } from '../../../../hooks';
|
8
|
-
import { safeUseId } from '../../../../utils';
|
6
|
+
import { useFocusTrap, useForkRef, useUniqId } from '@salutejs/plasma-core';
|
9
7
|
import { base as viewCSS } from './variations/_view/base';
|
10
8
|
import { base as sizeCSS } from './variations/_size/base';
|
11
9
|
import { StyledDropdown, StyledPopover } from './Dropdown.styles';
|
@@ -44,7 +42,7 @@ export var dropdownOldRoot = function dropdownOldRoot(Root) {
|
|
44
42
|
closeOnEsc = _ref$closeOnEsc === void 0 ? false : _ref$closeOnEsc,
|
45
43
|
rest = _objectWithoutProperties(_ref, _excluded);
|
46
44
|
var innerIsOpen = Boolean(isOpen || opened);
|
47
|
-
var uniqId =
|
45
|
+
var uniqId = useUniqId();
|
48
46
|
var innerId = id || uniqId;
|
49
47
|
var rootRef = useRef(null);
|
50
48
|
var dropdownRef = useRef(null);
|
@@ -16,8 +16,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
17
17
|
import React, { useRef, useCallback, useEffect, useState, forwardRef } from 'react';
|
18
18
|
import { usePopper } from 'react-popper';
|
19
|
-
import { useForkRef } from '@salutejs/plasma-core';
|
20
|
-
import { useFocusTrap } from '../../hooks';
|
19
|
+
import { useFocusTrap, useForkRef } from '@salutejs/plasma-core';
|
21
20
|
import { cx } from '../../utils';
|
22
21
|
import { Portal } from '../Portal';
|
23
22
|
import { base as viewCSS } from './variations/_view/base';
|
@@ -130,7 +130,7 @@ export var popupRoot = function popupRoot(Root) {
|
|
130
130
|
animationInfo: animationInfo,
|
131
131
|
setVisible: setVisible
|
132
132
|
}, children));
|
133
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
133
|
+
if (typeof frame !== 'string' && frame && frame.current && canUseDOM) {
|
134
134
|
return /*#__PURE__*/React.createElement(Portal, {
|
135
135
|
container: frame.current
|
136
136
|
}, rootNode);
|
@@ -82,7 +82,7 @@ export var PopupProvider = function PopupProvider(_ref) {
|
|
82
82
|
};
|
83
83
|
return /*#__PURE__*/React.createElement(PopupContext.Provider, {
|
84
84
|
value: context
|
85
|
-
}, children, /*#__PURE__*/React.createElement(Portal, {
|
85
|
+
}, children, canUseDOM && /*#__PURE__*/React.createElement(Portal, {
|
86
86
|
container: document.body
|
87
87
|
}, /*#__PURE__*/React.createElement(StyledPortal, {
|
88
88
|
id: rootId
|