@fluentui/react-positioning 9.0.0-alpha.6 → 9.0.0-alpha.60
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +1116 -1
- package/CHANGELOG.md +520 -2
- package/dist/react-positioning.d.ts +72 -27
- package/lib/createVirtualElementFromClick.d.ts +6 -0
- package/lib/createVirtualElementFromClick.js +24 -0
- package/lib/createVirtualElementFromClick.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +22 -27
- package/lib/types.js +1 -0
- package/lib/types.js.map +1 -1
- package/lib/usePopper.d.ts +21 -1
- package/lib/usePopper.js +67 -29
- package/lib/usePopper.js.map +1 -1
- package/lib/usePopperMouseTarget.d.ts +11 -0
- package/lib/usePopperMouseTarget.js +34 -0
- package/lib/usePopperMouseTarget.js.map +1 -0
- package/lib/utils/getBasePlacement.d.ts +8 -0
- package/lib/utils/getBasePlacement.js +10 -0
- package/lib/utils/getBasePlacement.js.map +1 -0
- package/lib/utils/getBoundary.d.ts +1 -1
- package/lib/utils/getBoundary.js +2 -3
- package/lib/utils/getBoundary.js.map +1 -1
- package/lib/utils/getReactFiberFromNode.js.map +1 -1
- package/lib/utils/getScrollParent.js.map +1 -1
- package/lib/utils/index.d.ts +5 -3
- package/lib/utils/index.js +5 -3
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/mergeArrowOffset.d.ts +10 -0
- package/lib/utils/mergeArrowOffset.js +37 -0
- package/lib/utils/mergeArrowOffset.js.map +1 -0
- package/lib/utils/positioningHelper.d.ts +2 -2
- package/lib/utils/positioningHelper.js.map +1 -1
- package/lib/utils/resolvePositioningShorthand.d.ts +2 -0
- package/lib/utils/resolvePositioningShorthand.js +25 -0
- package/lib/utils/resolvePositioningShorthand.js.map +1 -0
- package/lib/utils/useCallbackRef.js.map +1 -1
- package/lib-commonjs/createVirtualElementFromClick.d.ts +6 -0
- package/lib-commonjs/createVirtualElementFromClick.js +28 -0
- package/lib-commonjs/createVirtualElementFromClick.js.map +1 -0
- package/lib-commonjs/index.d.ts +3 -0
- package/lib-commonjs/index.js +7 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types.d.ts +22 -27
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/usePopper.d.ts +21 -1
- package/lib-commonjs/usePopper.js +67 -28
- package/lib-commonjs/usePopper.js.map +1 -1
- package/lib-commonjs/usePopperMouseTarget.d.ts +11 -0
- package/lib-commonjs/usePopperMouseTarget.js +38 -0
- package/lib-commonjs/usePopperMouseTarget.js.map +1 -0
- package/lib-commonjs/utils/getBasePlacement.d.ts +8 -0
- package/lib-commonjs/utils/getBasePlacement.js +14 -0
- package/lib-commonjs/utils/getBasePlacement.js.map +1 -0
- package/lib-commonjs/utils/getBoundary.d.ts +1 -1
- package/lib-commonjs/utils/getBoundary.js +3 -3
- package/lib-commonjs/utils/getBoundary.js.map +1 -1
- package/lib-commonjs/utils/getReactFiberFromNode.js +1 -0
- package/lib-commonjs/utils/getReactFiberFromNode.js.map +1 -1
- package/lib-commonjs/utils/getScrollParent.js +5 -2
- package/lib-commonjs/utils/getScrollParent.js.map +1 -1
- package/lib-commonjs/utils/index.d.ts +5 -3
- package/lib-commonjs/utils/index.js +5 -3
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/mergeArrowOffset.d.ts +10 -0
- package/lib-commonjs/utils/mergeArrowOffset.js +41 -0
- package/lib-commonjs/utils/mergeArrowOffset.js.map +1 -0
- package/lib-commonjs/utils/positioningHelper.d.ts +2 -2
- package/lib-commonjs/utils/positioningHelper.js +5 -2
- package/lib-commonjs/utils/positioningHelper.js.map +1 -1
- package/lib-commonjs/utils/resolvePositioningShorthand.d.ts +2 -0
- package/lib-commonjs/utils/resolvePositioningShorthand.js +29 -0
- package/lib-commonjs/utils/resolvePositioningShorthand.js.map +1 -0
- package/lib-commonjs/utils/useCallbackRef.js +1 -0
- package/lib-commonjs/utils/useCallbackRef.js.map +1 -1
- package/package.json +11 -8
- package/NOTICE.txt +0 -0
- package/config/api-extractor.json +0 -3
- package/etc/react-positioning.api.md +0 -69
- package/just.config.ts +0 -3
- package/lib/utils/isBrowser.d.ts +0 -1
- package/lib/utils/isBrowser.js +0 -4
- package/lib/utils/isBrowser.js.map +0 -1
- package/lib-amd/index.d.ts +0 -2
- package/lib-amd/index.js +0 -6
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/types.d.ts +0 -73
- package/lib-amd/types.js +0 -5
- package/lib-amd/types.js.map +0 -1
- package/lib-amd/usePopper.d.ts +0 -15
- package/lib-amd/usePopper.js +0 -280
- package/lib-amd/usePopper.js.map +0 -1
- package/lib-amd/utils/getBoundary.d.ts +0 -6
- package/lib-amd/utils/getBoundary.js +0 -23
- package/lib-amd/utils/getBoundary.js.map +0 -1
- package/lib-amd/utils/getReactFiberFromNode.d.ts +0 -109
- package/lib-amd/utils/getReactFiberFromNode.js +0 -47
- package/lib-amd/utils/getReactFiberFromNode.js.map +0 -1
- package/lib-amd/utils/getScrollParent.d.ts +0 -12
- package/lib-amd/utils/getScrollParent.js +0 -55
- package/lib-amd/utils/getScrollParent.js.map +0 -1
- package/lib-amd/utils/index.d.ts +0 -6
- package/lib-amd/utils/index.js +0 -11
- package/lib-amd/utils/index.js.map +0 -1
- package/lib-amd/utils/isBrowser.d.ts +0 -1
- package/lib-amd/utils/isBrowser.js +0 -8
- package/lib-amd/utils/isBrowser.js.map +0 -1
- package/lib-amd/utils/positioningHelper.d.ts +0 -7
- package/lib-amd/utils/positioningHelper.js +0 -45
- package/lib-amd/utils/positioningHelper.js.map +0 -1
- package/lib-amd/utils/useCallbackRef.d.ts +0 -19
- package/lib-amd/utils/useCallbackRef.js +0 -54
- package/lib-amd/utils/useCallbackRef.js.map +0 -1
- package/lib-commonjs/utils/isBrowser.d.ts +0 -1
- package/lib-commonjs/utils/isBrowser.js +0 -6
- package/lib-commonjs/utils/isBrowser.js.map +0 -1
package/lib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BAEH,aAAO,UAAU,0CAAE,QAAQ,IAAI;oBAC7B,IAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC;oBACpC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;oBAChC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CACV;wBACE,gGAAgG;wBAChG,qGAAqG;wBACrG,2EAA2E;wBAC3E,uEAAuE;wBACvE,IAAI;wBACJ,yFAAyF;wBACzF,oGAAoG;wBACpG,kGAAkG;wBAClG,WAAW;wBACX,8FAA4F;wBAC5F,6FAA6F;wBAC7F,IAAI;wBACJ,2FAA2F;wBAC3F,2CAA2C;wBAC3C,8EAA8E;qBAC/E,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;iBACH;aACF;YACD,mDAAmD;YACnD,0EAA0E;YAC1E,uDAAuD;QACzD,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;IAED,OAAO,EAAE,SAAS,WAAA,EAAE,YAAY,cAAA,EAAE,QAAQ,UAAA,EAAE,CAAC;AAC/C,CAAC","sourcesContent":["import { useEventCallback, useIsomorphicLayoutEffect, useFirstMount } from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-provider';\nimport {\n isBrowser,\n getScrollParent,\n applyRtlToOffset,\n getPlacement,\n getReactFiberFromNode,\n getBoundary,\n useCallbackRef,\n} from './utils/index';\nimport * as PopperJs from '@popperjs/core';\nimport * as React from 'react';\n\nimport { PopperOptions } from './types';\ntype PopperInstance = PopperJs.Instance & { isFirstRun?: boolean };\n\n//\n// Dev utils to detect if nodes have \"autoFocus\" props.\n//\n\n/**\n * Detects if a passed HTML node has \"autoFocus\" prop on a React's fiber. Is needed as React handles autofocus behavior\n * in React DOM and will not pass \"autoFocus\" to an actual HTML.\n */\nfunction hasAutofocusProp(node: Node): boolean {\n // https://github.com/facebook/react/blob/848bb2426e44606e0a55dfe44c7b3ece33772485/packages/react-dom/src/client/ReactDOMHostConfig.js#L157-L166\n const isAutoFocusableElement =\n node.nodeName === 'BUTTON' ||\n node.nodeName === 'INPUT' ||\n node.nodeName === 'SELECT' ||\n node.nodeName === 'TEXTAREA';\n\n if (isAutoFocusableElement) {\n return !!getReactFiberFromNode(node)?.pendingProps.autoFocus;\n }\n\n return false;\n}\n\nfunction hasAutofocusFilter(node: Node) {\n return hasAutofocusProp(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;\n}\n\n/**\n * Provides a callback to resolve Popper options, it's stable and should be used as a dependency to trigger updates\n * of Popper options.\n *\n * A callback is used there intentionally as some of Popper.js modifiers require DOM nodes (targer, container, arrow)\n * that can't be resolved properly during an initial rendering.\n */\nfunction usePopperOptions(options: PopperOptions, popperOriginalPositionRef: React.MutableRefObject<string>) {\n const {\n autoSize,\n flipBoundary,\n offset,\n onStateUpdate,\n overflowBoundary,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_disableTether,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unstable_pinned,\n } = options;\n\n const isRtl = useFluent().dir === 'rtl';\n const placement = getPlacement(options.align, options.position, isRtl);\n const strategy = options.positionFixed ? 'fixed' : 'absolute';\n\n const handleStateUpdate = useEventCallback(({ state }: { state: Partial<PopperJs.State> }) => {\n if (onStateUpdate) {\n onStateUpdate(state);\n }\n });\n\n const offsetModifier = React.useMemo(\n () =>\n offset\n ? {\n name: 'offset',\n options: { offset: isRtl ? applyRtlToOffset(offset) : offset },\n }\n : null,\n [offset, isRtl],\n );\n\n return React.useCallback(\n (\n target: HTMLElement | PopperJs.VirtualElement | null,\n container: HTMLElement | null,\n arrow: HTMLElement | null,\n ): PopperJs.Options => {\n const scrollParentElement: HTMLElement = getScrollParent(container);\n const hasScrollableElement = scrollParentElement\n ? scrollParentElement !== scrollParentElement.ownerDocument?.body\n : false;\n\n const modifiers: PopperJs.Options['modifiers'] = [\n /**\n * We are setting the position to `fixed` in the first effect to prevent scroll jumps in case of the content\n * with managed focus. Modifier sets the position to `fixed` before all other modifier effects. Another part of\n * a patch modifies \".forceUpdate()\" directly after a Popper will be created.\n */\n {\n name: 'positionStyleFix',\n enabled: true,\n phase: 'afterWrite' as PopperJs.ModifierPhases,\n effect: ({ state, instance }: { state: PopperJs.State; instance: PopperInstance }) => {\n // \".isFirstRun\" is a part of our patch, on a first evaluation it will \"undefined\"\n // should be disabled for subsequent runs as it breaks positioning for them\n if (instance.isFirstRun !== false) {\n popperOriginalPositionRef.current = state.elements.popper.style.position;\n state.elements.popper.style.position = 'fixed';\n }\n\n return () => undefined;\n },\n requires: [],\n },\n\n { name: 'flip', options: { flipVariations: true } },\n\n /**\n * unstable_pinned disables the flip modifier by setting flip.enabled to false; this\n * disables automatic repositioning of the popper box; it will always be placed according to\n * the values of `align` and `position` props, regardless of the size of the component, the\n * reference element or the viewport.\n */\n unstable_pinned && { name: 'flip', enabled: false },\n\n /**\n * When the popper box is placed in the context of a scrollable element, we need to set\n * preventOverflow.escapeWithReference to true and flip.boundariesElement to 'scrollParent'\n * (default is 'viewport') so that the popper box will stick with the targetRef when we\n * scroll targetRef out of the viewport.\n */\n hasScrollableElement && { name: 'flip', options: { boundary: 'clippingParents' } },\n hasScrollableElement && { name: 'preventOverflow', options: { boundary: 'clippingParents' } },\n\n offsetModifier,\n\n /**\n * This modifier is necessary to retain behaviour from popper v1 where untethered poppers are allowed by\n * default. i.e. popper is still rendered fully in the viewport even if anchor element is no longer in the\n * viewport.\n */\n unstable_disableTether && {\n name: 'preventOverflow',\n options: { altAxis: unstable_disableTether === 'all', tether: false },\n },\n\n flipBoundary && {\n name: 'flip',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, flipBoundary),\n },\n },\n overflowBoundary && {\n name: 'preventOverflow',\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n },\n\n {\n name: 'onUpdate',\n enabled: true,\n phase: 'afterWrite' as PopperJs.ModifierPhases,\n fn: handleStateUpdate,\n },\n\n autoSize && {\n // Similar code as popper-maxsize-modifier: https://github.com/atomiks/popper.js/blob/master/src/modifiers/maxSize.js\n // popper-maxsize-modifier only calculates the max sizes.\n // This modifier applies the max sizes when overflow is detected\n name: 'applyMaxSize',\n enabled: true,\n phase: 'beforeWrite' as PopperJs.ModifierPhases,\n requiresIfExists: ['offset', 'preventOverflow', 'flip'],\n options: {\n altBoundary: true,\n boundary: getBoundary(container, overflowBoundary),\n },\n fn({ state, options: modifierOptions }: PopperJs.ModifierArguments<{}>) {\n const overflow = PopperJs.detectOverflow(state, modifierOptions);\n const { x, y } = state.modifiersData.preventOverflow || { x: 0, y: 0 };\n const { width, height } = state.rects.popper;\n const [basePlacement] = state.placement.split('-');\n\n const widthProp: keyof PopperJs.SideObject = basePlacement === 'left' ? 'left' : 'right';\n const heightProp: keyof PopperJs.SideObject = basePlacement === 'top' ? 'top' : 'bottom';\n\n if (overflow[widthProp] > 0 && (autoSize === true || autoSize === 'width')) {\n state.styles.popper.maxWidth = `${width - overflow[widthProp] - x}px`;\n }\n if (overflow[heightProp] > 0 && (autoSize === true || autoSize === 'height')) {\n state.styles.popper.maxHeight = `${height - overflow[heightProp] - y}px`;\n }\n },\n },\n\n /**\n * This modifier is necessary in order to render the pointer. Refs are resolved in effects, so it can't be\n * placed under computed modifiers. Deep merge is not required as this modifier has only these properties.\n */\n {\n name: 'arrow',\n enabled: !!arrow,\n options: { element: arrow },\n },\n ].filter(Boolean) as PopperJs.Options['modifiers']; // filter boolean conditional spreading values\n\n const popperOptions: PopperJs.Options = {\n modifiers,\n\n placement,\n strategy,\n onFirstUpdate: state => handleStateUpdate({ state }),\n };\n\n return popperOptions;\n },\n [\n autoSize,\n flipBoundary,\n offsetModifier,\n overflowBoundary,\n placement,\n strategy,\n unstable_disableTether,\n unstable_pinned,\n\n // These can be skipped from deps as they will not ever change\n handleStateUpdate,\n popperOriginalPositionRef,\n ],\n );\n}\n\n/**\n * Exposes Popper positioning API via React hook. Contains few important differences between an official \"react-popper\"\n * package:\n * - style attributes are applied directly on DOM to avoid re-renders\n * - refs changes and resolution is handled properly without re-renders\n * - contains a specific to React fix related to initial positioning when containers have components with managed focus\n * to avoid focus jumps\n */\nexport function usePopper(\n options: PopperOptions = {},\n): {\n // React refs are supposed to be contravariant\n // (allows a more general type to be passed rather than a more specific one)\n // However, Typescript currently can't infer that fact for refs\n // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n targetRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n containerRef: React.MutableRefObject<any>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n arrowRef: React.MutableRefObject<any>;\n} {\n const { enabled = true } = options;\n const isFirstMount = useFirstMount();\n\n const popperOriginalPositionRef = React.useRef<string>('absolute');\n const resolvePopperOptions = usePopperOptions(options, popperOriginalPositionRef);\n\n const popperInstanceRef = React.useRef<PopperInstance | null>(null);\n\n const handlePopperUpdate = useEventCallback(() => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n\n let popperInstance: PopperInstance | null = null;\n\n if (isBrowser() && enabled) {\n if (targetRef.current && containerRef.current) {\n popperInstance = PopperJs.createPopper(\n targetRef.current,\n containerRef.current,\n resolvePopperOptions(targetRef.current, containerRef.current, arrowRef.current),\n );\n }\n }\n\n if (popperInstance) {\n /**\n * The patch updates `.forceUpdate()` Popper function which restores the original position before the first\n * forceUpdate() call. See also \"positionStyleFix\" modifier in usePopperOptions().\n */\n const originalForceUpdate = popperInstance.forceUpdate;\n\n popperInstance.isFirstRun = true;\n popperInstance.forceUpdate = () => {\n if (popperInstance?.isFirstRun) {\n popperInstance.state.elements.popper.style.position = popperOriginalPositionRef.current;\n popperInstance.isFirstRun = false;\n }\n\n originalForceUpdate();\n };\n }\n\n popperInstanceRef.current = popperInstance;\n });\n\n // Refs are managed by useCallbackRef() to handle ref updates scenarios.\n //\n // The first scenario are updates for a targetRef, we can handle it properly only via callback refs, but it causes\n // re-renders (we would like to avoid them).\n //\n // The second problem is related to refs resolution on React's layer: refs are resolved in the same order as effects\n // that causes an issue when you have a container inside a target, for example: a menu in ChatMessage.\n //\n // function ChatMessage(props) {\n // <div className=\"message\" ref={targetRef}> // 3) ref will be resolved only now, but it's too late already\n // <Popper target={targetRef}> // 2) create a popper instance\n // <div className=\"menu\" /> // 1) capture ref from this element\n // </Popper>\n // </div>\n // }\n //\n // Check a demo on CodeSandbox: https://codesandbox.io/s/popper-refs-emy60.\n //\n // This again can be solved with callback refs. It's not a huge issue as with hooks we are moving popper's creation\n // to ChatMessage itself, however, without `useCallback()` refs it's still a Pandora box.\n const targetRef = useCallbackRef<HTMLElement | PopperJs.VirtualElement | null>(null, handlePopperUpdate, true);\n const containerRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n const arrowRef = useCallbackRef<HTMLElement | null>(null, handlePopperUpdate, true);\n\n React.useImperativeHandle(\n options.containerRef,\n () => ({\n updatePosition: () => {\n popperInstanceRef.current?.update();\n },\n }),\n [],\n );\n\n useIsomorphicLayoutEffect(() => {\n handlePopperUpdate();\n\n return () => {\n popperInstanceRef.current?.destroy();\n popperInstanceRef.current = null;\n };\n }, [options.enabled]);\n useIsomorphicLayoutEffect(() => {\n if (!isFirstMount) {\n popperInstanceRef.current?.setOptions(\n resolvePopperOptions(targetRef.current, containerRef.current, arrowRef.current),\n );\n }\n }, [resolvePopperOptions]);\n\n if (process.env.NODE_ENV !== 'production') {\n // This checked should run only in development mode\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (containerRef.current) {\n const contentNode = containerRef.current;\n // eslint-disable-next-line deprecation/deprecation\n const treeWalker = contentNode.ownerDocument?.createTreeWalker(contentNode, NodeFilter.SHOW_ELEMENT, {\n acceptNode: hasAutofocusFilter,\n });\n\n while (treeWalker?.nextNode()) {\n const node = treeWalker.currentNode;\n // eslint-disable-next-line no-console\n console.warn('<Popper>:', node);\n // eslint-disable-next-line no-console\n console.warn(\n [\n '<Popper>: ^ this node contains \"autoFocus\" prop on a React element. This can break the initial',\n 'positioning of an element and cause a window jump effect. This issue occurs because React polyfills',\n '\"autoFocus\" behavior to solve inconsistencies between different browsers:',\n 'https://github.com/facebook/react/issues/11851#issuecomment-351787078',\n '\\n',\n 'However, \".focus()\" in this case occurs before any other React effects will be executed',\n '(React.useEffect(), componentDidMount(), etc.) and we can not prevent this behavior. If you really',\n 'want to use \"autoFocus\" please add \"position: fixed\" to styles of the element that is wrapped by',\n '\"Popper\".',\n `In general, it's not recommended to use \"autoFocus\" as it may break accessibility aspects:`,\n 'https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md',\n '\\n',\n 'We suggest to use the \"trapFocus\" prop on Fluent components or a catch \"ref\" and then use',\n '\"ref.current.focus\" in React.useEffect():',\n 'https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element',\n ].join(' '),\n );\n }\n }\n // We run this check once, no need to add deps here\n // TODO: Should be rework to handle options.enabled and contentRef updates\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n }\n\n return { targetRef, containerRef, arrowRef };\n}\n"]}
|
1
|
+
{"version":3,"file":"usePopper.js","sourceRoot":"","sources":["../src/usePopper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAClH,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA4B/B,EAAE;AACF,uDAAuD;AACvD,EAAE;AAEF;;;GAGG;AACH,SAAS,gBAAgB,CAAC,IAAU;;IAClC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,IAAI;oBAC7B,IAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC;oBACpC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;oBAChC,sCAAsC;oBACtC,OAAO,CAAC,IAAI,CACV;wBACE,gGAAgG;wBAChG,qGAAqG;wBACrG,2EAA2E;wBAC3E,uEAAuE;wBACvE,IAAI;wBACJ,yFAAyF;wBACzF,oGAAoG;wBACpG,kGAAkG;wBAClG,WAAW;wBACX,8FAA4F;wBAC5F,6FAA6F;wBAC7F,IAAI;wBACJ,2FAA2F;wBAC3F,2CAA2C;wBAC3C,8EAA8E;qBAC/E,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;iBACH;aACF;YACD,mDAAmD;YACnD,0EAA0E;YAC1E,uDAAuD;QACzD,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;IAED,OAAO,EAAE,SAAS,WAAA,EAAE,YAAY,cAAA,EAAE,QAAQ,UAAA,EAAE,CAAC;AAC/C,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import * as PopperJs from '@popperjs/core';
|
3
|
+
/**
|
4
|
+
* A state hook that manages a popper virtual element from mouseevents.
|
5
|
+
* Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
|
6
|
+
* React synthetic events are not persisted by this hook
|
7
|
+
*
|
8
|
+
* @param initialState - initializes a user provided state similare to useState
|
9
|
+
* @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
|
10
|
+
*/
|
11
|
+
export declare const usePopperMouseTarget: (initialState?: PopperJs.VirtualElement | (() => PopperJs.VirtualElement) | undefined) => readonly [PopperJs.VirtualElement | undefined, (event: React.MouseEvent | MouseEvent | undefined | null) => void];
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { createVirtualElementFromClick } from './createVirtualElementFromClick';
|
3
|
+
/**
|
4
|
+
* A state hook that manages a popper virtual element from mouseevents.
|
5
|
+
* Useful for scenarios where a component needs to be positioned by mouse click (e.g. contextmenu)
|
6
|
+
* React synthetic events are not persisted by this hook
|
7
|
+
*
|
8
|
+
* @param initialState - initializes a user provided state similare to useState
|
9
|
+
* @returns state and dispatcher for a Popper virtual element that uses native/synthetic mouse events
|
10
|
+
*/
|
11
|
+
export var usePopperMouseTarget = function (initialState) {
|
12
|
+
var _a = React.useState(initialState), virtualElement = _a[0], setVirtualElement = _a[1];
|
13
|
+
var setVirtualMouseTarget = function (event) {
|
14
|
+
if (event === undefined || event === null) {
|
15
|
+
setVirtualElement(undefined);
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
var mouseevent;
|
19
|
+
if (!(event instanceof MouseEvent)) {
|
20
|
+
mouseevent = event.nativeEvent;
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
mouseevent = event;
|
24
|
+
}
|
25
|
+
if (!(mouseevent instanceof MouseEvent) && process.env.NODE_ENV !== 'production') {
|
26
|
+
// eslint-disable-next-line no-console
|
27
|
+
console.error('usePopperMouseTarget should only be used with MouseEvent');
|
28
|
+
}
|
29
|
+
var contextTarget = createVirtualElementFromClick(mouseevent);
|
30
|
+
setVirtualElement(contextTarget);
|
31
|
+
};
|
32
|
+
return [virtualElement, setVirtualMouseTarget];
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=usePopperMouseTarget.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"usePopperMouseTarget.js","sourceRoot":"","sources":["../src/usePopperMouseTarget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAGhF;;;;;;;GAOG;AACH,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAAC,YAAwE;IACrG,IAAA,KAAsC,KAAK,CAAC,QAAQ,CAAsC,YAAY,CAAC,EAAtG,cAAc,QAAA,EAAE,iBAAiB,QAAqE,CAAC;IAE9G,IAAM,qBAAqB,GAAG,UAAC,KAAuD;QACpF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;YACzC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC7B,OAAO;SACR;QAED,IAAI,UAAsB,CAAC;QAC3B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;YAClC,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;SAChC;aAAM;YACL,UAAU,GAAG,KAAK,CAAC;SACpB;QAED,IAAI,CAAC,CAAC,UAAU,YAAY,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;YAChF,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;SAC3E;QAED,IAAM,aAAa,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;QAChE,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,OAAO,CAAC,cAAc,EAAE,qBAAqB,CAAU,CAAC;AAC1D,CAAC,CAAC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import * as PopperJs from '@popperjs/core';
|
2
|
+
/**
|
3
|
+
* Returns the base placement value
|
4
|
+
* @param placement - the popper placement (i.e. bottom-start)
|
5
|
+
*
|
6
|
+
* @returns bottom-start -> bottom
|
7
|
+
*/
|
8
|
+
export declare function getBasePlacement(placement: PopperJs.Placement): PopperJs.BasePlacement;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* Returns the base placement value
|
3
|
+
* @param placement - the popper placement (i.e. bottom-start)
|
4
|
+
*
|
5
|
+
* @returns bottom-start -> bottom
|
6
|
+
*/
|
7
|
+
export function getBasePlacement(placement) {
|
8
|
+
return placement.split('-')[0];
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=getBasePlacement.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getBasePlacement.js","sourceRoot":"","sources":["../../src/utils/getBasePlacement.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA6B;IAC5D,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAA2B,CAAC;AAC3D,CAAC"}
|
package/lib/utils/getBoundary.js
CHANGED
@@ -3,14 +3,13 @@ import { getScrollParent } from './getScrollParent';
|
|
3
3
|
* Allows to mimic a behavior from V1 of Popper and accept `window` and `scrollParent` as strings.
|
4
4
|
*/
|
5
5
|
export function getBoundary(element, boundary) {
|
6
|
-
var _a, _b;
|
7
6
|
if (boundary === 'window') {
|
8
|
-
return
|
7
|
+
return element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
9
8
|
}
|
10
9
|
if (boundary === 'scrollParent') {
|
11
10
|
var boundariesNode = getScrollParent(element);
|
12
11
|
if (boundariesNode.nodeName === 'BODY') {
|
13
|
-
boundariesNode =
|
12
|
+
boundariesNode = element === null || element === void 0 ? void 0 : element.ownerDocument.documentElement;
|
14
13
|
}
|
15
14
|
return boundariesNode;
|
16
15
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getBoundary.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"getBoundary.js","sourceRoot":"","sources":["../../src/utils/getBoundary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B,EAAE,QAAmB;IAC1E,IAAI,QAAQ,KAAK,QAAQ,EAAE;QACzB,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,CAAE,eAAe,CAAC;KAChD;IAED,IAAI,QAAQ,KAAK,cAAc,EAAE;QAC/B,IAAI,cAAc,GAA4B,eAAe,CAAC,OAAO,CAAC,CAAC;QAEvE,IAAI,cAAc,CAAC,QAAQ,KAAK,MAAM,EAAE;YACtC,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sourcesContent":["import * as React from 'react';\n\n// ========================================================\n// react/packages/shared/ReactTypes.js\n// ========================================================\n\ntype ReactEventResponder<E, C> = {\n $$typeof: Symbol | number;\n displayName: string;\n targetEventTypes: null | string[];\n rootEventTypes: null | string[];\n getInitialState: null | ((props: Object) => Object);\n onEvent: null | ((event: E, context: C, props: Object, state: Object) => void);\n onRootEvent: null | ((event: E, context: C, props: Object, state: Object) => void);\n onMount: null | ((context: C, props: Object, state: Object) => void);\n onUnmount: null | ((context: C, props: Object, state: Object) => void);\n};\n\ntype ReactEventResponderInstance<E, C> = {\n fiber: Object;\n props: Object;\n responder: ReactEventResponder<E, C>;\n rootEventTypes: null | Set<string>;\n state: Object;\n};\n\n// ========================================================\n// react/packages/react-reconciler/src/ReactFiberHooks.js\n// ========================================================\n\nexport type HookType =\n | 'useState'\n | 'useReducer'\n | 'useContext'\n | 'useRef'\n | 'useEffect'\n | 'useLayoutEffect'\n | 'useCallback'\n | 'useMemo'\n | 'useImperativeHandle'\n | 'useDebugValue'\n | 'useResponder';\n\ntype ReactProviderType<T> = {\n $$typeof: Symbol | number;\n _context: ReactContext<T>;\n};\n\ntype ReactContext<T> = {\n $$typeof: Symbol | number;\n Consumer: ReactContext<T>;\n Provider: ReactProviderType<T>;\n\n _calculateChangedBits: ((a: T, b: T) => number) | null;\n\n _currentValue: T;\n _currentValue2: T;\n _threadCount: number;\n\n // DEV only\n _currentRenderer?: Object | null;\n _currentRenderer2?: Object | null;\n};\n\ntype ContextDependency<T> = {\n context: ReactContext<T>;\n observedBits: number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n next: ContextDependency<any> | null;\n};\n\nenum WorkTag {\n FunctionComponent = 0,\n ClassComponent = 1,\n IndeterminateComponent = 2, // Before we know whether it is function or class\n HostRoot = 3, // Root of a host tree. Could be nested inside another node.\n HostPortal = 4, // A subtree. Could be an entry point to a different renderer.\n HostComponent = 5,\n HostText = 6,\n Fragment = 7,\n Mode = 8,\n ContextConsumer = 9,\n ContextProvider = 10,\n ForwardRef = 11,\n Profiler = 12,\n SuspenseComponent = 13,\n MemoComponent = 14,\n SimpleMemoComponent = 15,\n LazyComponent = 16,\n IncompleteClassComponent = 17,\n DehydratedFragment = 18,\n SuspenseListComponent = 19,\n FundamentalComponent = 20,\n ScopeComponent = 21,\n}\n\ntype Source = {\n fileName: string;\n lineNumber: number;\n};\n\ntype ExpirationTime = number;\n\ntype Dependencies = {\n expirationTime: ExpirationTime;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n firstContext: ContextDependency<any> | null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responders: Map<ReactEventResponder<any, any>, ReactEventResponderInstance<any, any>> | null;\n};\n\n// ========================================================\n// react/packages/react-reconciler/src/ReactFiber.js\n// ========================================================\n\n// A Fiber is work on a Component that needs to be done or was done. There can\n// be more than one per component.\n\nexport type Fiber = {\n // These first fields are conceptually members of an Instance. This used to\n // be split into a separate type and intersected with the other Fiber fields,\n // but until Flow fixes its intersection bugs, we've merged them into a\n // single type.\n\n // An Instance is shared between all versions of a component. We can easily\n // break this out into a separate object to avoid copying so much to the\n // alternate versions of the tree. We put this on a single object for now to\n // minimize the number of objects created during the initial render.\n\n // Tag identifying the type of fiber.\n tag: WorkTag;\n\n // Unique identifier of this child.\n key: null | string;\n\n // The value of element.type which is used to preserve the identity during\n // reconciliation of this child.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementType: any;\n\n // The resolved function/class/ associated with this fiber.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type: any;\n\n // The local state associated with this fiber.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stateNode: any;\n\n // Conceptual aliases\n // parent : Instance -> return The parent happens to be the same as the\n // return fiber since we've merged the fiber and instance.\n\n // Remaining fields belong to Fiber\n\n // The Fiber to return to after finishing processing this one.\n // This is effectively the parent, but there can be multiple parents (two)\n // so this is only the parent of the thing we're currently processing.\n // It is conceptually the same as the return address of a stack frame.\n return: Fiber | null;\n\n // Singly Linked List Tree Structure.\n child: Fiber | null;\n sibling: Fiber | null;\n index: number;\n\n // The ref last used to attach this node.\n // I'll avoid adding an owner field for prod and model that as functions.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref: React.Ref<any>;\n\n // Input is the data coming into process this fiber. Arguments. Props.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pendingProps: any; // This type will be more specific once we overload the tag.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n memoizedProps: any; // The props used to create the output.\n\n // A queue of state updates and callbacks.\n // updateQueue: UpdateQueue<any> | null,\n\n // The state used to create the output\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n memoizedState: any;\n\n // Dependencies (contexts, events) for this fiber, if it has any\n dependencies: Dependencies | null;\n\n // // Bitfield that describes properties about the fiber and its subtree. E.g.\n // // the ConcurrentMode flag indicates whether the subtree should be async-by-\n // // default. When a fiber is created, it inherits the mode of its\n // // parent. Additional flags can be set at creation time, but after that the\n // // value should remain unchanged throughout the fiber's lifetime, particularly\n // // before its child fibers are created.\n // mode: TypeOfMode\n //\n // // Effect\n // effectTag: SideEffectTag\n\n // Singly linked list fast path to the next fiber with side-effects.\n nextEffect: Fiber | null;\n\n // The first and last fiber with side-effect within this subtree. This allows\n // us to reuse a slice of the linked list when we reuse the work done within\n // this fiber.\n firstEffect: Fiber | null;\n lastEffect: Fiber | null;\n\n // Represents a time in the future by which this work should be completed.\n // Does not include work found in its subtree.\n expirationTime: ExpirationTime;\n\n // This is used to quickly determine if a subtree has no pending changes.\n childExpirationTime: ExpirationTime;\n\n // This is a pooled version of a Fiber. Every fiber that gets updated will\n // eventually have a pair. There are cases when we can clean up pairs to save\n // memory if we need to.\n alternate: Fiber | null;\n\n // Time spent rendering this Fiber and its descendants for the current update.\n // This tells us how well the tree makes use of sCU for memoization.\n // It is reset to 0 each time we render and only updated when we don't bailout.\n // This field is only set when the enableProfilerTimer flag is enabled.\n actualDuration?: number;\n\n // If the Fiber is currently active in the \"render\" phase,\n // This marks the time at which the work began.\n // This field is only set when the enableProfilerTimer flag is enabled.\n actualStartTime?: number;\n\n // Duration of the most recent render time for this Fiber.\n // This value is not updated when we bailout for memoization purposes.\n // This field is only set when the enableProfilerTimer flag is enabled.\n selfBaseDuration?: number;\n\n // Sum of base times for all descendants of this Fiber.\n // This value bubbles up during the \"complete\" phase.\n // This field is only set when the enableProfilerTimer flag is enabled.\n treeBaseDuration?: number;\n\n // Conceptual aliases\n // workInProgress : Fiber -> alternate The alternate used for reuse happens\n // to be the same as work in progress.\n // __DEV__ only\n _debugID?: number;\n _debugSource?: Source | null;\n _debugOwner?: Fiber | null;\n _debugIsCurrentlyTiming?: boolean;\n _debugNeedsRemount?: boolean;\n\n // Used to verify that the order of hooks does not change between renders.\n _debugHookTypes?: HookType[] | null;\n};\n\nexport function getReactFiberFromNode(elm: Node | undefined): Fiber | null {\n if (!elm) {\n return null;\n }\n\n for (const k in elm) {\n // React 16 uses \"__reactInternalInstance$\" prefix\n // React 17 uses \"__reactFiber$\" prefix\n // https://github.com/facebook/react/pull/18377\n if (k.indexOf('__reactInternalInstance$') === 0 || k.indexOf('__reactFiber$') === 0) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return elm[k];\n }\n }\n\n throw new Error('getReactFiber(): Failed to find a React Fiber on a node');\n}\n"]}
|
1
|
+
{"version":3,"file":"getReactFiberFromNode.js","sourceRoot":"","sources":["../../src/utils/getReactFiberFromNode.ts"],"names":[],"mappings":"AAuEA,IAAK,OAuBJ;AAvBD,WAAK,OAAO;IACV,+DAAqB,CAAA;IACrB,yDAAkB,CAAA;IAClB,yEAA0B,CAAA;IAC1B,6CAAY,CAAA;IACZ,iDAAc,CAAA;IACd,uDAAiB,CAAA;IACjB,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,qCAAQ,CAAA;IACR,2DAAmB,CAAA;IACnB,4DAAoB,CAAA;IACpB,kDAAe,CAAA;IACf,8CAAa,CAAA;IACb,gEAAsB,CAAA;IACtB,wDAAkB,CAAA;IAClB,oEAAwB,CAAA;IACxB,wDAAkB,CAAA;IAClB,8EAA6B,CAAA;IAC7B,kEAAuB,CAAA;IACvB,wEAA0B,CAAA;IAC1B,sEAAyB,CAAA;IACzB,0DAAmB,CAAA;AACrB,CAAC,EAvBI,OAAO,KAAP,OAAO,QAuBX;AA+JD,MAAM,UAAU,qBAAqB,CAAC,GAAqB;IACzD,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,IAAI,CAAC;KACb;IAED,KAAK,IAAM,CAAC,IAAI,GAAG,EAAE;QACnB,kDAAkD;QAClD,uCAAuC;QACvC,+CAA+C;QAC/C,IAAI,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;YACnF,6DAA6D;YAC7D,aAAa;YACb,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;SACf;KACF;IAED,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;AAC7E,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getScrollParent.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"getScrollParent.js","sourceRoot":"","sources":["../../src/utils/getScrollParent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,IAAM,aAAa,GAAG,UAAC,IAAiB;IAC7C,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE;QAC5B,OAAO,IAAI,CAAC;KACb;IACD,8DAA8D;IAC9D,OAAO,IAAI,CAAC,UAAU,IAAK,IAAY,CAAC,IAAI,CAAC;AAC/C,CAAC,CAAC;AAEF;;;;GAIG;AACH,IAAM,wBAAwB,GAAG,UAAC,IAAiB;;IACjD,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE;QACvB,OAAO,EAAE,CAAC;KACX;IAED,IAAM,MAAM,SAAG,IAAI,CAAC,aAAa,0CAAE,WAAW,CAAC;IAC/C,OAAO,MAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,IAAM,eAAe,GAAG,UAAC,IAAmC;IACjE,iFAAiF;IACjF,IAAM,UAAU,GAAG,IAAI,IAAI,aAAa,CAAC,IAAmB,CAAC,CAAC;IAC9D,2BAA2B;IAC3B,IAAI,CAAC,UAAU;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;IAEtC,QAAQ,UAAU,CAAC,QAAQ,EAAE;QAC3B,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,UAAU,CAAC,aAAc,CAAC,IAAI,CAAC;QACxC,KAAK,WAAW;YACd,OAAS,UAAmC,CAAC,IAAI,CAAC;KACrD;IAED,uFAAuF;IACjF,IAAA,KAAqC,wBAAwB,CAAC,UAAU,CAAC,EAAvE,QAAQ,cAAA,EAAE,SAAS,eAAA,EAAE,SAAS,eAAyC,CAAC;IAChF,IAAI,uBAAuB,CAAC,IAAI,CAAC,QAAS,GAAG,SAAU,GAAG,SAAS,CAAC,EAAE;QACpE,OAAO,UAAU,CAAC;KACnB;IAED,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC"}
|
package/lib/utils/index.d.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
export * from './
|
2
|
-
export * from './positioningHelper';
|
1
|
+
export * from './getBasePlacement';
|
3
2
|
export * from './getBoundary';
|
4
|
-
export * from './getScrollParent';
|
5
3
|
export * from './getReactFiberFromNode';
|
4
|
+
export * from './getScrollParent';
|
5
|
+
export * from './mergeArrowOffset';
|
6
|
+
export * from './positioningHelper';
|
7
|
+
export * from './resolvePositioningShorthand';
|
6
8
|
export * from './useCallbackRef';
|
package/lib/utils/index.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
export * from './
|
2
|
-
export * from './positioningHelper';
|
1
|
+
export * from './getBasePlacement';
|
3
2
|
export * from './getBoundary';
|
4
|
-
export * from './getScrollParent';
|
5
3
|
export * from './getReactFiberFromNode';
|
4
|
+
export * from './getScrollParent';
|
5
|
+
export * from './mergeArrowOffset';
|
6
|
+
export * from './positioningHelper';
|
7
|
+
export * from './resolvePositioningShorthand';
|
6
8
|
export * from './useCallbackRef';
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/lib/utils/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Offset } from '../types';
|
2
|
+
/**
|
3
|
+
* Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
|
4
|
+
* height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
|
5
|
+
*
|
6
|
+
* @param userOffset - The offset provided by the user
|
7
|
+
* @param arrowHeight - The height of the arrow in px
|
8
|
+
* @returns User offset augmented with arrow height
|
9
|
+
*/
|
10
|
+
export declare function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/**
|
2
|
+
* Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the
|
3
|
+
* height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset
|
4
|
+
*
|
5
|
+
* @param userOffset - The offset provided by the user
|
6
|
+
* @param arrowHeight - The height of the arrow in px
|
7
|
+
* @returns User offset augmented with arrow height
|
8
|
+
*/
|
9
|
+
export function mergeArrowOffset(userOffset, arrowHeight) {
|
10
|
+
var offsetWithArrow = userOffset;
|
11
|
+
if (!userOffset) {
|
12
|
+
return [0, arrowHeight];
|
13
|
+
}
|
14
|
+
if (Array.isArray(offsetWithArrow)) {
|
15
|
+
setArrowOffset(offsetWithArrow, arrowHeight);
|
16
|
+
return offsetWithArrow;
|
17
|
+
}
|
18
|
+
if (typeof offsetWithArrow === 'function') {
|
19
|
+
var userOffsetFn_1 = offsetWithArrow;
|
20
|
+
offsetWithArrow = function (offsetParams) {
|
21
|
+
var offset = userOffsetFn_1(offsetParams);
|
22
|
+
setArrowOffset(offset, arrowHeight);
|
23
|
+
return offset;
|
24
|
+
};
|
25
|
+
}
|
26
|
+
// This should never happen
|
27
|
+
return [0, 0];
|
28
|
+
}
|
29
|
+
var setArrowOffset = function (offset, arrowHeight) {
|
30
|
+
if (offset[1] !== null && offset[1] !== undefined) {
|
31
|
+
offset[1] += arrowHeight;
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
offset[1] = arrowHeight;
|
35
|
+
}
|
36
|
+
};
|
37
|
+
//# sourceMappingURL=mergeArrowOffset.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mergeArrowOffset.js","sourceRoot":"","sources":["../../src/utils/mergeArrowOffset.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAqC,EAAE,WAAmB;IACzF,IAAI,eAAe,GAAG,UAAU,CAAC;IACjC,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;KACzB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAClC,cAAc,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QAC7C,OAAO,eAAe,CAAC;KACxB;IAED,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE;QACzC,IAAM,cAAY,GAAG,eAAe,CAAC;QACrC,eAAe,GAAG,UAAA,YAAY;YAC5B,IAAM,MAAM,GAAG,cAAY,CAAC,YAAY,CAAC,CAAC;YAC1C,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACpC,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,EAAE,CAAC,CAAU,CAAC;AACzB,CAAC;AAED,IAAM,cAAc,GAAG,UAAC,MAA8D,EAAE,WAAmB;IACzG,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;QACjD,MAAM,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC;KAC1B;SAAM;QACL,MAAM,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;KACzB;AACH,CAAC,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as PopperJs from '@popperjs/core';
|
2
|
-
import {
|
2
|
+
import type { Offset } from '../types';
|
3
3
|
/**
|
4
4
|
* @see positioninHelper.test.ts for expected placement values
|
5
5
|
*/
|
6
6
|
export declare const getPlacement: (align?: "top" | "bottom" | "start" | "end" | "center" | undefined, position?: "above" | "below" | "before" | "after" | undefined, rtl?: boolean | undefined) => PopperJs.Placement;
|
7
|
-
export declare const applyRtlToOffset: (offset:
|
7
|
+
export declare const applyRtlToOffset: (offset: Offset | undefined) => Offset | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"positioningHelper.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"positioningHelper.js","sourceRoot":"","sources":["../../src/utils/positioningHelper.ts"],"names":[],"mappings":"AAMA,IAAM,cAAc,GAAG,UAAC,GAAa,IAA0C,OAAA,CAAC;IAC9E,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;IAC9B,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,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MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,MAA0B;IACzD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC;QAE5B,OAAO,MAAM,CAAC;KACf;IAED,OAAO,CAAC,UAAC,KAA0B,IAAK,OAAA,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAA/B,CAA+B,CAAmB,CAAC;AAC7F,CAAC,CAAC"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// Look up table for shorthand to avoid parsing strings
|
2
|
+
var shorthandLookup = {
|
3
|
+
above: { position: 'above', align: 'center' },
|
4
|
+
'above-start': { position: 'above', align: 'start' },
|
5
|
+
'above-end': { position: 'above', align: 'end' },
|
6
|
+
below: { position: 'below', align: 'center' },
|
7
|
+
'below-start': { position: 'below', align: 'start' },
|
8
|
+
'below-end': { position: 'below', align: 'end' },
|
9
|
+
before: { position: 'before', align: 'center' },
|
10
|
+
'before-top': { position: 'before', align: 'top' },
|
11
|
+
'before-bottom': { position: 'before', align: 'bottom' },
|
12
|
+
after: { position: 'after', align: 'center' },
|
13
|
+
'after-top': { position: 'after', align: 'top' },
|
14
|
+
'after-bottom': { position: 'after', align: 'bottom' },
|
15
|
+
};
|
16
|
+
export function resolvePositioningShorthand(shorthand) {
|
17
|
+
if (shorthand === undefined || shorthand === null) {
|
18
|
+
return {};
|
19
|
+
}
|
20
|
+
if (typeof shorthand === 'string') {
|
21
|
+
return shorthandLookup[shorthand];
|
22
|
+
}
|
23
|
+
return shorthand;
|
24
|
+
}
|
25
|
+
//# sourceMappingURL=resolvePositioningShorthand.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"resolvePositioningShorthand.js","sourceRoot":"","sources":["../../src/utils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AAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCallbackRef.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"useCallbackRef.js","sourceRoot":"","sources":["../../src/utils/useCallbackRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAC5B,YAAsB,EACtB,QAA2D,EAC3D,kBAA4B;IAE5B,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAA,GAAG,GAAI,KAAK,CAAC,QAAQ,CAAC,cAAM,OAAA,CAAC;QAClC,QAAQ;QACR,KAAK,EAAE,YAAY;QACnB,gBAAgB;QAChB,QAAQ,UAAA;QACR,8BAA8B;QAC9B,MAAM,EAAE;YACN,IAAI,OAAO;gBACT,OAAO,GAAG,CAAC,KAAK,CAAC;YACnB,CAAC;YACD,IAAI,OAAO,CAAC,KAAK;gBACf,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC;gBAEvB,IAAI,IAAI,KAAK,KAAK,EAAE;oBAClB,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;oBAElB,IAAI,kBAAkB,IAAI,OAAO,CAAC,OAAO,EAAE;wBACzC,OAAO;qBACR;oBAED,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;iBAC3B;YACH,CAAC;SACF;KACF,CAAC,EAxBiC,CAwBjC,CAAC,GAxBO,CAwBN;IAEJ,yBAAyB,CAAC;QACxB,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;IAC1B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,kBAAkB;IAClB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAExB,OAAO,GAAG,CAAC,MAAM,CAAC;AACpB,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { PopperVirtualElement } from './types';
|
2
|
+
/**
|
3
|
+
* Creates a virtual element based on the position of a click event
|
4
|
+
* Can be used as a target for popper in scenarios such as context menus
|
5
|
+
*/
|
6
|
+
export declare function createVirtualElementFromClick(nativeEvent: MouseEvent): PopperVirtualElement;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createVirtualElementFromClick = void 0;
|
4
|
+
/**
|
5
|
+
* Creates a virtual element based on the position of a click event
|
6
|
+
* Can be used as a target for popper in scenarios such as context menus
|
7
|
+
*/
|
8
|
+
function createVirtualElementFromClick(nativeEvent) {
|
9
|
+
var left = nativeEvent.clientX;
|
10
|
+
var top = nativeEvent.clientY;
|
11
|
+
var right = left + 1;
|
12
|
+
var bottom = top + 1;
|
13
|
+
function getBoundingClientRect() {
|
14
|
+
return {
|
15
|
+
left: left,
|
16
|
+
top: top,
|
17
|
+
right: right,
|
18
|
+
bottom: bottom,
|
19
|
+
height: 1,
|
20
|
+
width: 1,
|
21
|
+
};
|
22
|
+
}
|
23
|
+
return {
|
24
|
+
getBoundingClientRect: getBoundingClientRect,
|
25
|
+
};
|
26
|
+
}
|
27
|
+
exports.createVirtualElementFromClick = createVirtualElementFromClick;
|
28
|
+
//# sourceMappingURL=createVirtualElementFromClick.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createVirtualElementFromClick.js","sourceRoot":"","sources":["../src/createVirtualElementFromClick.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,WAAuB;IACnE,IAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC;IACjC,IAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC;IAChC,IAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC;IACvB,IAAM,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC;IAEvB,SAAS,qBAAqB;QAC5B,OAAO;YACL,IAAI,MAAA;YACJ,GAAG,KAAA;YACH,KAAK,OAAA;YACL,MAAM,QAAA;YAEN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,CAAC;SACT,CAAC;IACJ,CAAC;IAED,OAAO;QACL,qBAAqB,uBAAA;KACtB,CAAC;AACJ,CAAC;AArBD,sEAqBC"}
|
package/lib-commonjs/index.d.ts
CHANGED
package/lib-commonjs/index.js
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.mergeArrowOffset = exports.resolvePositioningShorthand = void 0;
|
3
4
|
var tslib_1 = require("tslib");
|
4
5
|
tslib_1.__exportStar(require("./usePopper"), exports);
|
6
|
+
tslib_1.__exportStar(require("./createVirtualElementFromClick"), exports);
|
7
|
+
tslib_1.__exportStar(require("./usePopperMouseTarget"), exports);
|
8
|
+
var index_1 = require("./utils/index");
|
9
|
+
Object.defineProperty(exports, "resolvePositioningShorthand", { enumerable: true, get: function () { return index_1.resolvePositioningShorthand; } });
|
10
|
+
Object.defineProperty(exports, "mergeArrowOffset", { enumerable: true, get: function () { return index_1.mergeArrowOffset; } });
|
11
|
+
tslib_1.__exportStar(require("./types"), exports);
|
5
12
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,sDAA4B;AAC5B,0EAAgD;AAChD,iEAAuC;AACvC,uCAA8E;AAArE,oHAAA,2BAA2B,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AACtD,kDAAwB"}
|
package/lib-commonjs/types.d.ts
CHANGED
@@ -9,21 +9,21 @@ export declare type OffsetFunction = (param: OffsetFunctionParam) => [number | n
|
|
9
9
|
export declare type Offset = OffsetFunction | [number | null | undefined, number | null | undefined];
|
10
10
|
export declare type Position = 'above' | 'below' | 'before' | 'after';
|
11
11
|
export declare type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';
|
12
|
+
export declare type AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;
|
12
13
|
export declare type Boundary = PopperJs.Boundary | 'scrollParent' | 'window';
|
13
14
|
export declare type PopperRefHandle = {
|
14
15
|
updatePosition: () => void;
|
15
16
|
};
|
17
|
+
export declare type PopperVirtualElement = PopperJs.VirtualElement;
|
16
18
|
export interface PositioningProps {
|
17
|
-
/**
|
18
|
-
* Alignment for the component.
|
19
|
-
*/
|
19
|
+
/** Alignment for the component. Only has an effect if used with the @see position option */
|
20
20
|
align?: Alignment;
|
21
21
|
/** The element which will define the boundaries of the popper position for the flip behavior. */
|
22
22
|
flipBoundary?: Boundary;
|
23
23
|
/** The element which will define the boundaries of the popper position for the overflow behavior. */
|
24
24
|
overflowBoundary?: Boundary;
|
25
25
|
/** An imperative handle to Popper methods. */
|
26
|
-
|
26
|
+
popperRef?: React.Ref<PopperRefHandle>;
|
27
27
|
/**
|
28
28
|
* Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')
|
29
29
|
* and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'
|
@@ -31,11 +31,6 @@ export interface PositioningProps {
|
|
31
31
|
* then provided value for 'align' will be ignored and 'center' will be used instead.
|
32
32
|
*/
|
33
33
|
position?: Position;
|
34
|
-
/**
|
35
|
-
* Enables the Popper box to position itself in 'fixed' mode (default value is position: 'absolute')
|
36
|
-
* @default false
|
37
|
-
*/
|
38
|
-
positionFixed?: boolean;
|
39
34
|
/**
|
40
35
|
* Lets you displace a popper element from its reference element.
|
41
36
|
* This can be useful if you need to apply some margin between them or if you need to fine tune the
|
@@ -43,31 +38,31 @@ export interface PositioningProps {
|
|
43
38
|
*/
|
44
39
|
offset?: Offset;
|
45
40
|
/**
|
46
|
-
*
|
47
|
-
*
|
41
|
+
* Defines padding between the corner of the popup element and the arrow.
|
42
|
+
* Use to prevent the arrow from overlapping a rounded corner, for example.
|
48
43
|
*/
|
49
|
-
|
44
|
+
arrowPadding?: number;
|
50
45
|
/**
|
51
|
-
*
|
52
|
-
*
|
46
|
+
* Applies max-height and max-width on popper to fit it within the available space in viewport.
|
47
|
+
* true enables this for both width and height when overflow happens.
|
48
|
+
* 'always' applies `max-height`/`max-width` regardless of overflow.
|
49
|
+
* 'height' applies `max-height` when overflow happens, and 'width' for `max-width`
|
50
|
+
* `height-always` applies `max-height` regardless of overflow, and 'width-always' for always applying `max-width`
|
53
51
|
*/
|
54
|
-
|
52
|
+
autoSize?: AutoSize;
|
55
53
|
/**
|
56
|
-
*
|
57
|
-
* true enables this for both width and height.
|
58
|
-
* 'height' applies only `max-height` and 'width' for `max-width`
|
54
|
+
* Manual override for popper target. Useful for scenarios where a component accepts user prop to override target
|
59
55
|
*/
|
60
|
-
|
61
|
-
}
|
62
|
-
export interface PopperOptions extends PositioningProps {
|
56
|
+
target?: HTMLElement | PopperVirtualElement | null;
|
63
57
|
/**
|
64
|
-
*
|
65
|
-
* @default true
|
58
|
+
* Modifies position and alignment to cover the target
|
66
59
|
*/
|
67
|
-
|
60
|
+
coverTarget?: boolean;
|
68
61
|
/**
|
69
|
-
*
|
62
|
+
* Disables automatic repositioning of the component; it will always be placed according to the values of `align` and
|
63
|
+
* `position` props, regardless of the size of the component, the reference element or the viewport.
|
70
64
|
*/
|
71
|
-
|
72
|
-
onStateUpdate?: (state: Partial<PopperJs.State>) => void;
|
65
|
+
pinned?: boolean;
|
73
66
|
}
|
67
|
+
export declare type PositioningShorthandValue = 'above' | 'above-start' | 'above-end' | 'below' | 'below-start' | 'below-end' | 'before' | 'before-top' | 'before-bottom' | 'after' | 'after-top' | 'after-bottom';
|
68
|
+
export declare type PositioningShorthand = PositioningProps | PositioningShorthandValue;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|