@wordpress/components 21.0.2 → 21.1.2-next.4d3b314fd5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -4
- package/build/autocomplete/get-default-use-items.js +3 -3
- package/build/autocomplete/get-default-use-items.js.map +1 -1
- package/build/box-control/unit-control.js +0 -1
- package/build/box-control/unit-control.js.map +1 -1
- package/build/button/index.js +5 -1
- package/build/button/index.js.map +1 -1
- package/build/draggable/index.js +3 -6
- package/build/draggable/index.js.map +1 -1
- package/build/drop-zone/index.js +7 -1
- package/build/drop-zone/index.js.map +1 -1
- package/build/higher-order/with-filters/index.js +1 -1
- package/build/higher-order/with-filters/index.js.map +1 -1
- package/build/index.js +6 -0
- package/build/index.js.map +1 -1
- package/build/menu-item/index.js +4 -3
- package/build/menu-item/index.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +15 -6
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build/mobile/color-settings/index.native.js +3 -1
- package/build/mobile/color-settings/index.native.js.map +1 -1
- package/build/mobile/color-settings/picker-screen.native.js +3 -1
- package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build/mobile/image/index.native.js +3 -1
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-avoiding-view/index.ios.js +3 -1
- package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build/mobile/link-picker/index.native.js +3 -1
- package/build/mobile/link-picker/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +6 -4
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-screen.native.js +3 -1
- package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +24 -6
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/mobile/link-settings/link-settings-screen.native.js +3 -1
- package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build/mobile/segmented-control/index.native.js +6 -2
- package/build/mobile/segmented-control/index.native.js.map +1 -1
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build/notice/index.native.js +15 -19
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +2 -3
- package/build/notice/list.native.js.map +1 -1
- package/build/palette-edit/index.js +1 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +29 -32
- package/build/popover/index.js.map +1 -1
- package/build/popover/limit-shift.js +145 -0
- package/build/popover/limit-shift.js.map +1 -0
- package/build/popover/utils.js +55 -15
- package/build/popover/utils.js.map +1 -1
- package/build/range-control/input-range.js +1 -15
- package/build/range-control/input-range.js.map +1 -1
- package/build/range-control/tooltip.js +1 -1
- package/build/range-control/tooltip.js.map +1 -1
- package/build/range-control/utils.js +2 -58
- package/build/range-control/utils.js.map +1 -1
- package/build/tools-panel/styles.js +27 -12
- package/build/tools-panel/styles.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +19 -6
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/hook.js +4 -0
- package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build/tree-grid/index.js +13 -8
- package/build/tree-grid/index.js.map +1 -1
- package/build/unit-control/index.js +2 -2
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/index.native.js +10 -2
- package/build/unit-control/index.native.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +21 -32
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/utils/hooks/use-controlled-state.js +2 -3
- package/build/utils/hooks/use-controlled-state.js.map +1 -1
- package/build-module/autocomplete/get-default-use-items.js +1 -1
- package/build-module/autocomplete/get-default-use-items.js.map +1 -1
- package/build-module/box-control/unit-control.js +0 -1
- package/build-module/box-control/unit-control.js.map +1 -1
- package/build-module/button/index.js +5 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/draggable/index.js +2 -5
- package/build-module/draggable/index.js.map +1 -1
- package/build-module/drop-zone/index.js +7 -1
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/higher-order/with-filters/index.js +2 -2
- package/build-module/higher-order/with-filters/index.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/menu-item/index.js +4 -3
- package/build-module/menu-item/index.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +13 -4
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/index.native.js +3 -1
- package/build-module/mobile/color-settings/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/picker-screen.native.js +3 -1
- package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +3 -1
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js +3 -1
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build-module/mobile/link-picker/index.native.js +3 -1
- package/build-module/mobile/link-picker/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +4 -2
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js +3 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +24 -6
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/mobile/link-settings/link-settings-screen.native.js +3 -1
- package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build-module/mobile/segmented-control/index.native.js +6 -2
- package/build-module/mobile/segmented-control/index.native.js.map +1 -1
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build-module/notice/index.native.js +16 -21
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +3 -3
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/palette-edit/index.js +1 -1
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +31 -35
- package/build-module/popover/index.js.map +1 -1
- package/build-module/popover/limit-shift.js +136 -0
- package/build-module/popover/limit-shift.js.map +1 -0
- package/build-module/popover/utils.js +55 -15
- package/build-module/popover/utils.js.map +1 -1
- package/build-module/range-control/input-range.js +1 -14
- package/build-module/range-control/input-range.js.map +1 -1
- package/build-module/range-control/tooltip.js +1 -1
- package/build-module/range-control/tooltip.js.map +1 -1
- package/build-module/range-control/utils.js +2 -57
- package/build-module/range-control/utils.js.map +1 -1
- package/build-module/tools-panel/styles.js +23 -12
- package/build-module/tools-panel/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +19 -7
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/hook.js +4 -0
- package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build-module/tree-grid/index.js +13 -8
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-module/unit-control/index.js +2 -2
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/index.native.js +10 -2
- package/build-module/unit-control/index.native.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +20 -31
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/utils/hooks/use-controlled-state.js +3 -4
- package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
- package/build-style/style-rtl.css +13 -2
- package/build-style/style.css +13 -2
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/drop-zone/index.d.ts.map +1 -1
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/focal-point-picker/styles/focal-point-style.d.ts +3 -3
- package/build-types/menu-item/index.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/limit-shift.d.ts +87 -0
- package/build-types/popover/limit-shift.d.ts.map +1 -0
- package/build-types/popover/stories/e2e/index.d.ts +8 -0
- package/build-types/popover/stories/e2e/index.d.ts.map +1 -0
- package/build-types/popover/test/index.d.ts +2 -0
- package/build-types/popover/test/index.d.ts.map +1 -0
- package/build-types/popover/types.d.ts +1 -1
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts.map +1 -1
- package/build-types/range-control/input-range.d.ts.map +1 -1
- package/build-types/range-control/stories/index.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +0 -34
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/range-control/utils.d.ts +1 -12
- package/build-types/range-control/utils.d.ts.map +1 -1
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/tools-panel/styles.d.ts +6 -0
- package/build-types/tools-panel/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +1 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -4
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/autocomplete/get-default-use-items.js +1 -1
- package/src/box-control/unit-control.js +0 -1
- package/src/button/index.js +7 -1
- package/src/button/test/index.js +36 -0
- package/src/color-palette/test/__snapshots__/index.js.snap +169 -1106
- package/src/color-palette/test/index.js +107 -61
- package/src/draggable/index.js +2 -5
- package/src/drop-zone/index.tsx +4 -1
- package/src/font-size-picker/stories/e2e/index.js +47 -0
- package/src/higher-order/with-filters/index.js +2 -2
- package/src/index.js +1 -1
- package/src/menu-item/README.md +7 -0
- package/src/menu-item/index.js +11 -5
- package/src/menu-item/style.scss +1 -0
- package/src/menu-item/test/index.js +36 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +9 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -2
- package/src/mobile/bottom-sheet/sub-sheet/index.native.js +3 -0
- package/src/mobile/color-settings/index.native.js +3 -0
- package/src/mobile/color-settings/picker-screen.native.js +3 -0
- package/src/mobile/image/index.native.js +3 -0
- package/src/mobile/keyboard-avoiding-view/index.ios.js +3 -0
- package/src/mobile/link-picker/index.native.js +3 -0
- package/src/mobile/link-picker/link-picker-results.native.js +4 -1
- package/src/mobile/link-picker/link-picker-screen.native.js +3 -0
- package/src/mobile/link-settings/index.native.js +18 -0
- package/src/mobile/link-settings/link-settings-screen.native.js +3 -0
- package/src/mobile/segmented-control/index.native.js +6 -0
- package/src/mobile/utils/use-unit-converter-to-mobile.native.js +6 -0
- package/src/notice/index.native.js +17 -20
- package/src/notice/list.native.js +7 -3
- package/src/palette-edit/index.js +1 -1
- package/src/placeholder/style.scss +1 -1
- package/src/popover/index.tsx +26 -42
- package/src/popover/limit-shift.ts +205 -0
- package/src/popover/stories/e2e/index.tsx +25 -0
- package/src/popover/test/index.tsx +230 -0
- package/src/popover/types.ts +1 -0
- package/src/popover/utils.ts +58 -16
- package/src/range-control/README.md +6 -7
- package/src/range-control/input-range.tsx +1 -21
- package/src/range-control/stories/index.tsx +2 -1
- package/src/range-control/tooltip.tsx +1 -1
- package/src/range-control/types.ts +0 -35
- package/src/range-control/utils.ts +3 -75
- package/src/tools-panel/stories/index.js +27 -0
- package/src/tools-panel/styles.ts +28 -1
- package/src/tools-panel/tools-panel-header/component.tsx +12 -5
- package/src/tools-panel/tools-panel-header/hook.ts +5 -0
- package/src/tools-panel/types.ts +1 -0
- package/src/tree-grid/index.js +23 -14
- package/src/tree-grid/test/__snapshots__/cell.js.snap +21 -17
- package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
- package/src/unit-control/index.native.js +8 -0
- package/src/unit-control/index.tsx +2 -2
- package/src/unit-control/styles/unit-control-styles.ts +0 -20
- package/src/unit-control/test/index.tsx +6 -3
- package/src/utils/hooks/use-controlled-state.js +9 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/src/popover/test/__snapshots__/index.js.snap +0 -34
- package/src/popover/test/index.js +0 -164
- package/src/unit-control/test/__snapshots__/index.tsx.snap +0 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/popover/index.tsx"],"names":["classnames","useFloating","flip","flipMiddleware","shift","shiftMiddleware","autoUpdate","arrow","offset","offsetMiddleware","limitShift","size","motion","useReducedMotion","useRef","useLayoutEffect","forwardRef","createContext","useContext","useMemo","useState","useCallback","useEffect","useViewportMatch","useMergeRefs","__experimentalUseDialog","useDialog","close","deprecated","Path","SVG","Button","ScrollLock","Slot","Fill","useSlot","getFrameOffset","positionToPlacement","placementToMotionAnimationProps","getReferenceOwnerDocument","getReferenceElement","SLOT_NAME","ArrowTriangle","AnimatedWrapper","forwardedRef","style","receivedInlineStyles","placement","shouldAnimate","props","hasAnimatedOnce","setHasAnimatedOnce","shouldReduceMotion","motionInlineStyles","otherMotionProps","onAnimationComplete","computedAnimationProps","animate","slotNameContext","undefined","UnforwardedPopover","headerTitle","onClose","children","className","noArrow","isAlternate","position","placementProp","offsetProp","focusOnMount","anchor","expandOnMobile","onFocusOutside","__unstableSlotName","resize","__unstableForcePosition","__unstableShift","anchorRef","anchorRect","getAnchorRect","range","contentProps","since","version","computedFlipProp","computedResizeProp","alternative","shouldShift","arrowRef","fallbackReferenceElement","setFallbackReferenceElement","referenceOwnerDocument","setReferenceOwnerDocument","anchorRefFallback","node","isMobileViewport","isExpanded","hasArrow","normalizedPlacementFromProps","frameOffsetRef","offsetRef","middleware","currentPlacement","current","isTopBottomPlacement","includes","mainAxis","crossAxis","hasBeforePlacement","mainAxisModifier","apply","sizeProps","firstElementChild","refs","floating","HTMLElement","Object","assign","maxHeight","availableHeight","overflow","limiter","padding","element","filter","m","slotName","slot","onDialogClose","type","event","dialogRef","dialogProps","__unstableOnClose","x","y","reference","referenceCallbackRef","strategy","update","computedPlacement","middlewareData","arrowData","whileElementsMounted","referenceParam","floatingParam","updateParam","animationFrame","arrowCallbackRef","resultingReferenceOwnerDoc","fallbackDocument","document","resultingReferenceElement","top","bottom","startContainer","ownerDocument","defaultView","frameElement","updateFrameOffset","addEventListener","removeEventListener","mergedFloatingRef","content","left","Number","isNaN","split","join","isFinite","ref","Popover","PopoverSlot","name","__unstableSlotNameProvider","Provider"],"mappings":";;;AAAA;AACA;AACA;AAEA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SACCC,WADD,EAECC,IAAI,IAAIC,cAFT,EAGCC,KAAK,IAAIC,eAHV,EAICC,UAJD,EAKCC,KALD,EAMCC,MAAM,IAAIC,gBANX,EAOCC,UAPD,EAQCC,IARD,QAUO,wBAVP,C,CAWA;;AACA,SACCC,MADD,EAECC,gBAFD,QAKO,eALP;AAOA;AACA;AACA;;AACA,SACCC,MADD,EAECC,eAFD,EAGCC,UAHD,EAICC,aAJD,EAKCC,UALD,EAMCC,OAND,EAOCC,QAPD,EAQCC,WARD,EASCC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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMQ,OAAO,GAAG5J,UAAU,CAAE4C,kBAAF,CAA1B;;AAEP,SAASiH,WAAT,QAECF,GAFD,EAGE;AAAA,MAFD;AAAEG,IAAAA,IAAI,GAAGrI;AAAT,GAEC;AACD,SACC,cAAC,IAAD,CACC;AADD;AAEC,IAAA,gBAAgB,MAFjB;AAGC,IAAA,IAAI,EAAGqI,IAHR;AAIC,IAAA,SAAS,EAAC,cAJX;AAKC,IAAA,GAAG,EAAGH;AALP,IADD;AASA,C,CAED;;;AACAC,OAAO,CAAC3I,IAAR,GAAejB,UAAU,CAAE6J,WAAF,CAAzB,C,CACA;;AACAD,OAAO,CAACG,0BAAR,GAAqCrH,eAAe,CAACsH,QAArD;AAEA,eAAeJ,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, SyntheticEvent, RefCallback } from 'react';\nimport classnames from 'classnames';\nimport {\n\tuseFloating,\n\tflip as flipMiddleware,\n\tshift as shiftMiddleware,\n\tautoUpdate,\n\tarrow,\n\toffset as offsetMiddleware,\n\tlimitShift,\n\tsize,\n\tMiddleware,\n} from '@floating-ui/react-dom';\n// eslint-disable-next-line no-restricted-imports\nimport {\n\tmotion,\n\tuseReducedMotion,\n\tHTMLMotionProps,\n\tMotionProps,\n} from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseLayoutEffect,\n\tforwardRef,\n\tcreateContext,\n\tuseContext,\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseEffect,\n} from '@wordpress/element';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport {\n\tgetFrameOffset,\n\tpositionToPlacement,\n\tplacementToMotionAnimationProps,\n\tgetReferenceOwnerDocument,\n\tgetReferenceElement,\n} from './utils';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type {\n\tPopoverProps,\n\tAnimatedWrapperProps,\n\tPopoverAnchorRefReference,\n\tPopoverAnchorRefTopBottom,\n} from './types';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nconst SLOT_NAME = 'Popover';\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\tviewBox={ `0 0 100 100` }\n\t\tclassName=\"components-popover__triangle\"\n\t\trole=\"presentation\"\n\t>\n\t\t<Path\n\t\t\tclassName=\"components-popover__triangle-bg\"\n\t\t\td=\"M 0 0 L 50 50 L 100 0\"\n\t\t/>\n\t\t<Path\n\t\t\tclassName=\"components-popover__triangle-border\"\n\t\t\td=\"M 0 0 L 50 50 L 100 0\"\n\t\t\tvectorEffect=\"non-scaling-stroke\"\n\t\t/>\n\t</SVG>\n);\n\nconst AnimatedWrapper = forwardRef(\n\t(\n\t\t{\n\t\t\tstyle: receivedInlineStyles,\n\t\t\tplacement,\n\t\t\tshouldAnimate = false,\n\t\t\t...props\n\t\t}: HTMLMotionProps< 'div' > & AnimatedWrapperProps,\n\t\tforwardedRef: ForwardedRef< any >\n\t) => {\n\t\t// When animating, animate only once (i.e. when the popover is opened), and\n\t\t// do not animate on subsequent prop changes (as it conflicts with\n\t\t// floating-ui's positioning updates).\n\t\tconst [ hasAnimatedOnce, setHasAnimatedOnce ] = useState( false );\n\t\tconst shouldReduceMotion = useReducedMotion();\n\n\t\tconst { style: motionInlineStyles, ...otherMotionProps } = useMemo(\n\t\t\t() => placementToMotionAnimationProps( placement ),\n\t\t\t[ placement ]\n\t\t);\n\n\t\tconst onAnimationComplete = useCallback(\n\t\t\t() => setHasAnimatedOnce( true ),\n\t\t\t[]\n\t\t);\n\n\t\tconst computedAnimationProps: HTMLMotionProps< 'div' > =\n\t\t\tshouldAnimate && ! shouldReduceMotion\n\t\t\t\t? {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...motionInlineStyles,\n\t\t\t\t\t\t\t...receivedInlineStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...otherMotionProps,\n\t\t\t\t\t\tonAnimationComplete,\n\t\t\t\t\t\tanimate: hasAnimatedOnce\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: otherMotionProps.animate,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tanimate: false,\n\t\t\t\t\t\tstyle: receivedInlineStyles,\n\t\t\t\t };\n\n\t\treturn (\n\t\t\t<motion.div\n\t\t\t\t{ ...computedAnimationProps }\n\t\t\t\t{ ...props }\n\t\t\t\tref={ forwardedRef }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nconst slotNameContext = createContext< string | undefined >( undefined );\n\nconst UnforwardedPopover = (\n\tprops: Omit<\n\t\tWordPressComponentProps< PopoverProps, 'div', false >,\n\t\t// To avoid overlaps between the standard HTML attributes and the props\n\t\t// expected by `framer-motion`, omit all framer motion props from popover\n\t\t// props (except for `animate`, which is re-defined in `PopoverProps`).\n\t\tkeyof Omit< MotionProps, 'animate' >\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tanimate = true,\n\t\theaderTitle,\n\t\tonClose,\n\t\tchildren,\n\t\tclassName,\n\t\tnoArrow = true,\n\t\tisAlternate,\n\t\tposition,\n\t\tplacement: placementProp = 'bottom-start',\n\t\toffset: offsetProp = 0,\n\t\tfocusOnMount = 'firstElement',\n\t\tanchor,\n\t\texpandOnMobile,\n\t\tonFocusOutside,\n\t\t__unstableSlotName = SLOT_NAME,\n\t\tflip = true,\n\t\tresize = true,\n\t\tshift = false,\n\n\t\t// Deprecated props\n\t\t__unstableForcePosition,\n\t\t__unstableShift,\n\t\tanchorRef,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\trange,\n\n\t\t// Rest\n\t\t...contentProps\n\t} = props;\n\n\tif ( range ) {\n\t\tdeprecated( '`range` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t} );\n\t}\n\n\tlet computedFlipProp = flip;\n\tlet computedResizeProp = resize;\n\tif ( __unstableForcePosition !== undefined ) {\n\t\tdeprecated( '`__unstableForcePosition` prop wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`flip={ false }` and `resize={ false }`',\n\t\t} );\n\n\t\t// Back-compat, set the `flip` and `resize` props\n\t\t// to `false` to replicate `__unstableForcePosition`.\n\t\tcomputedFlipProp = ! __unstableForcePosition;\n\t\tcomputedResizeProp = ! __unstableForcePosition;\n\t}\n\n\tlet shouldShift = shift;\n\tif ( __unstableShift !== undefined ) {\n\t\tdeprecated( '`__unstableShift` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`shift` prop`',\n\t\t} );\n\n\t\t// Back-compat.\n\t\tshouldShift = __unstableShift;\n\t}\n\n\tif ( anchorRef !== undefined ) {\n\t\tdeprecated( '`anchorRef` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tif ( anchorRect !== undefined ) {\n\t\tdeprecated( '`anchorRect` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tif ( getAnchorRect !== undefined ) {\n\t\tdeprecated( '`getAnchorRect` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tconst arrowRef = useRef( null );\n\n\tconst [ fallbackReferenceElement, setFallbackReferenceElement ] =\n\t\tuseState< HTMLSpanElement | null >( null );\n\tconst [ referenceOwnerDocument, setReferenceOwnerDocument ] = useState<\n\t\tDocument | undefined\n\t>();\n\n\tconst anchorRefFallback: RefCallback< HTMLSpanElement > = useCallback(\n\t\t( node ) => {\n\t\t\tsetFallbackReferenceElement( node );\n\t\t},\n\t\t[]\n\t);\n\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isExpanded = expandOnMobile && isMobileViewport;\n\tconst hasArrow = ! isExpanded && ! noArrow;\n\tconst normalizedPlacementFromProps = position\n\t\t? positionToPlacement( position )\n\t\t: placementProp;\n\n\t/**\n\t * Offsets the position of the popover when the anchor is inside an iframe.\n\t *\n\t * Store the offset in a ref, due to constraints with floating-ui:\n\t * https://floating-ui.com/docs/react-dom#variables-inside-middleware-functions.\n\t */\n\tconst frameOffsetRef = useRef( getFrameOffset( referenceOwnerDocument ) );\n\t/**\n\t * Store the offset prop in a ref, due to constraints with floating-ui:\n\t * https://floating-ui.com/docs/react-dom#variables-inside-middleware-functions.\n\t */\n\tconst offsetRef = useRef( offsetProp );\n\n\tconst middleware = [\n\t\toffsetMiddleware( ( { placement: currentPlacement } ) => {\n\t\t\tif ( ! frameOffsetRef.current ) {\n\t\t\t\treturn offsetRef.current;\n\t\t\t}\n\n\t\t\tconst isTopBottomPlacement =\n\t\t\t\tcurrentPlacement.includes( 'top' ) ||\n\t\t\t\tcurrentPlacement.includes( 'bottom' );\n\n\t\t\t// The main axis should represent the gap between the\n\t\t\t// floating element and the reference element. The cross\n\t\t\t// axis is always perpendicular to the main axis.\n\t\t\tconst mainAxis = isTopBottomPlacement ? 'y' : 'x';\n\t\t\tconst crossAxis = mainAxis === 'x' ? 'y' : 'x';\n\n\t\t\t// When the popover is before the reference, subtract the offset,\n\t\t\t// of the main axis else add it.\n\t\t\tconst hasBeforePlacement =\n\t\t\t\tcurrentPlacement.includes( 'top' ) ||\n\t\t\t\tcurrentPlacement.includes( 'left' );\n\t\t\tconst mainAxisModifier = hasBeforePlacement ? -1 : 1;\n\n\t\t\treturn {\n\t\t\t\tmainAxis:\n\t\t\t\t\toffsetRef.current +\n\t\t\t\t\tframeOffsetRef.current[ mainAxis ] * mainAxisModifier,\n\t\t\t\tcrossAxis: frameOffsetRef.current[ crossAxis ],\n\t\t\t};\n\t\t} ),\n\t\tcomputedFlipProp ? flipMiddleware() : undefined,\n\t\tcomputedResizeProp\n\t\t\t? size( {\n\t\t\t\t\tapply( sizeProps ) {\n\t\t\t\t\t\tconst { firstElementChild } =\n\t\t\t\t\t\t\trefs.floating.current ?? {};\n\n\t\t\t\t\t\t// Only HTMLElement instances have the `style` property.\n\t\t\t\t\t\tif ( ! ( firstElementChild instanceof HTMLElement ) )\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t// Reduce the height of the popover to the available space.\n\t\t\t\t\t\tObject.assign( firstElementChild.style, {\n\t\t\t\t\t\t\tmaxHeight: `${ sizeProps.availableHeight }px`,\n\t\t\t\t\t\t\toverflow: 'auto',\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t } )\n\t\t\t: undefined,\n\t\tshouldShift\n\t\t\t? shiftMiddleware( {\n\t\t\t\t\tcrossAxis: true,\n\t\t\t\t\tlimiter: limitShift(),\n\t\t\t\t\tpadding: 1, // Necessary to avoid flickering at the edge of the viewport.\n\t\t\t } )\n\t\t\t: undefined,\n\t\tarrow( { element: arrowRef } ),\n\t].filter(\n\t\t( m: Middleware | undefined ): m is Middleware => m !== undefined\n\t);\n\tconst slotName = useContext( slotNameContext ) || __unstableSlotName;\n\tconst slot = useSlot( slotName );\n\n\tlet onDialogClose;\n\n\tif ( onClose || onFocusOutside ) {\n\t\tonDialogClose = ( type: string | undefined, event: SyntheticEvent ) => {\n\t\t\t// Ideally the popover should have just a single onClose prop and\n\t\t\t// not three props that potentially do the same thing.\n\t\t\tif ( type === 'focus-outside' && onFocusOutside ) {\n\t\t\t\tonFocusOutside( event );\n\t\t\t} else if ( onClose ) {\n\t\t\t\tonClose();\n\t\t\t}\n\t\t};\n\t}\n\n\tconst [ dialogRef, dialogProps ] = useDialog( {\n\t\tfocusOnMount,\n\t\t__unstableOnClose: onDialogClose,\n\t\t// @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n\t\tonClose: onDialogClose,\n\t} );\n\n\tconst {\n\t\t// Positioning coordinates\n\t\tx,\n\t\ty,\n\t\t// Callback refs (not regular refs). This allows the position to be updated.\n\t\t// when either elements change.\n\t\treference: referenceCallbackRef,\n\t\tfloating,\n\t\t// Object with \"regular\" refs to both \"reference\" and \"floating\"\n\t\trefs,\n\t\t// Type of CSS position property to use (absolute or fixed)\n\t\tstrategy,\n\t\tupdate,\n\t\tplacement: computedPlacement,\n\t\tmiddlewareData: { arrow: arrowData },\n\t} = useFloating( {\n\t\tplacement: normalizedPlacementFromProps,\n\t\tmiddleware,\n\t\twhileElementsMounted: ( referenceParam, floatingParam, updateParam ) =>\n\t\t\tautoUpdate( referenceParam, floatingParam, updateParam, {\n\t\t\t\tanimationFrame: true,\n\t\t\t} ),\n\t} );\n\n\tuseEffect( () => {\n\t\toffsetRef.current = offsetProp;\n\t\tupdate();\n\t}, [ offsetProp, update ] );\n\n\tconst arrowCallbackRef = useCallback(\n\t\t( node ) => {\n\t\t\tarrowRef.current = node;\n\t\t\tupdate();\n\t\t},\n\t\t[ update ]\n\t);\n\n\t// When any of the possible anchor \"sources\" change,\n\t// recompute the reference element (real or virtual) and its owner document.\n\tuseLayoutEffect( () => {\n\t\tconst resultingReferenceOwnerDoc = getReferenceOwnerDocument( {\n\t\t\tanchor,\n\t\t\tanchorRef,\n\t\t\tanchorRect,\n\t\t\tgetAnchorRect,\n\t\t\tfallbackReferenceElement,\n\t\t\tfallbackDocument: document,\n\t\t} );\n\t\tconst resultingReferenceElement = getReferenceElement( {\n\t\t\tanchor,\n\t\t\tanchorRef,\n\t\t\tanchorRect,\n\t\t\tgetAnchorRect,\n\t\t\tfallbackReferenceElement,\n\t\t} );\n\n\t\treferenceCallbackRef( resultingReferenceElement );\n\n\t\tsetReferenceOwnerDocument( resultingReferenceOwnerDoc );\n\t}, [\n\t\tanchor,\n\t\tanchorRef as Element | undefined,\n\t\t( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top,\n\t\t( anchorRef as PopoverAnchorRefTopBottom | undefined )?.bottom,\n\t\t( anchorRef as Range | undefined )?.startContainer,\n\t\t( anchorRef as PopoverAnchorRefReference )?.current,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\tfallbackReferenceElement,\n\t\treferenceCallbackRef,\n\t] );\n\n\t// If the reference element is in a different ownerDocument (e.g. iFrame),\n\t// we need to manually update the floating's position as the reference's owner\n\t// document scrolls. Also update the frame offset if the view resizes.\n\tuseLayoutEffect( () => {\n\t\tif (\n\t\t\t// Reference and root documents are the same.\n\t\t\treferenceOwnerDocument === document ||\n\t\t\t// Reference and floating are in the same document.\n\t\t\treferenceOwnerDocument === refs?.floating?.current?.ownerDocument ||\n\t\t\t// The reference's document has no view (i.e. window)\n\t\t\t// or frame element (ie. it's not an iframe).\n\t\t\t! referenceOwnerDocument?.defaultView?.frameElement\n\t\t) {\n\t\t\tframeOffsetRef.current = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tconst { defaultView } = referenceOwnerDocument;\n\n\t\tconst updateFrameOffset = () => {\n\t\t\tframeOffsetRef.current = getFrameOffset( referenceOwnerDocument );\n\t\t\tupdate();\n\t\t};\n\t\tdefaultView.addEventListener( 'resize', updateFrameOffset );\n\n\t\tupdateFrameOffset();\n\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'resize', updateFrameOffset );\n\t\t};\n\t}, [ referenceOwnerDocument, update ] );\n\n\tconst mergedFloatingRef = useMergeRefs( [\n\t\tfloating,\n\t\tdialogRef,\n\t\tforwardedRef,\n\t] );\n\n\t// Disable reason: We care to capture the _bubbled_ events from inputs\n\t// within popover as inferring close intent.\n\n\tlet content = (\n\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<AnimatedWrapper\n\t\t\tshouldAnimate={ animate && ! isExpanded }\n\t\t\tplacement={ computedPlacement }\n\t\t\tclassName={ classnames( 'components-popover', className, {\n\t\t\t\t'is-expanded': isExpanded,\n\t\t\t\t'is-alternate': isAlternate,\n\t\t\t} ) }\n\t\t\t{ ...contentProps }\n\t\t\tref={ mergedFloatingRef }\n\t\t\t{ ...dialogProps }\n\t\t\ttabIndex={ -1 }\n\t\t\tstyle={\n\t\t\t\tisExpanded\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\t\tleft: Number.isNaN( x ) ? 0 : x ?? undefined,\n\t\t\t\t\t\t\ttop: Number.isNaN( y ) ? 0 : y ?? undefined,\n\t\t\t\t\t }\n\t\t\t}\n\t\t>\n\t\t\t{ /* Prevents scroll on the document */ }\n\t\t\t{ isExpanded && <ScrollLock /> }\n\t\t\t{ isExpanded && (\n\t\t\t\t<div className=\"components-popover__header\">\n\t\t\t\t\t<span className=\"components-popover__header-title\">\n\t\t\t\t\t\t{ headerTitle }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-popover__close\"\n\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"components-popover__content\">{ children }</div>\n\t\t\t{ hasArrow && (\n\t\t\t\t<div\n\t\t\t\t\tref={ arrowCallbackRef }\n\t\t\t\t\tclassName={ [\n\t\t\t\t\t\t'components-popover__arrow',\n\t\t\t\t\t\t`is-${ computedPlacement.split( '-' )[ 0 ] }`,\n\t\t\t\t\t].join( ' ' ) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\ttypeof arrowData?.x !== 'undefined' &&\n\t\t\t\t\t\t\tNumber.isFinite( arrowData.x )\n\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\tarrowData.x +\n\t\t\t\t\t\t\t\t\t\t( frameOffsetRef.current?.x ?? 0 )\n\t\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\ttypeof arrowData?.y !== 'undefined' &&\n\t\t\t\t\t\t\tNumber.isFinite( arrowData.y )\n\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\tarrowData.y +\n\t\t\t\t\t\t\t\t\t\t( frameOffsetRef.current?.y ?? 0 )\n\t\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<ArrowTriangle />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</AnimatedWrapper>\n\t);\n\n\tif ( slot.ref ) {\n\t\tcontent = <Fill name={ slotName }>{ content }</Fill>;\n\t}\n\n\tif ( anchorRef || anchorRect || anchor ) {\n\t\treturn content;\n\t}\n\n\treturn <span ref={ anchorRefFallback }>{ content }</span>;\n};\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = forwardRef( UnforwardedPopover );\n\nfunction PopoverSlot(\n\t{ name = SLOT_NAME }: { name?: string },\n\tref: ForwardedRef< any >\n) {\n\treturn (\n\t\t<Slot\n\t\t\t// @ts-expect-error Need to type `SlotFill`\n\t\t\tbubblesVirtually\n\t\t\tname={ name }\n\t\t\tclassName=\"popover-slot\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\n// @ts-expect-error For Legacy Reasons\nPopover.Slot = forwardRef( PopoverSlot );\n// @ts-expect-error For Legacy Reasons\nPopover.__unstableSlotNameProvider = slotNameContext.Provider;\n\nexport default Popover;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/popover/index.tsx"],"names":["classnames","useFloating","flip","flipMiddleware","shift","shiftMiddleware","autoUpdate","arrow","offset","offsetMiddleware","size","motion","useReducedMotion","useRef","useLayoutEffect","forwardRef","createContext","useContext","useMemo","useState","useCallback","useViewportMatch","useMergeRefs","__experimentalUseDialog","useDialog","close","deprecated","Path","SVG","Button","ScrollLock","Slot","Fill","useSlot","getFrameOffset","positionToPlacement","placementToMotionAnimationProps","getReferenceOwnerDocument","getReferenceElement","limitShift","customLimitShift","SLOT_NAME","ArrowTriangle","AnimatedWrapper","forwardedRef","style","receivedInlineStyles","placement","shouldAnimate","props","hasAnimatedOnce","setHasAnimatedOnce","shouldReduceMotion","motionInlineStyles","otherMotionProps","onAnimationComplete","computedAnimationProps","animate","slotNameContext","undefined","UnforwardedPopover","headerTitle","onClose","children","className","noArrow","isAlternate","position","placementProp","offsetProp","focusOnMount","anchor","expandOnMobile","onFocusOutside","__unstableSlotName","resize","__unstableForcePosition","__unstableShift","anchorRef","anchorRect","getAnchorRect","range","contentProps","since","version","computedFlipProp","computedResizeProp","alternative","shouldShift","arrowRef","fallbackReferenceElement","setFallbackReferenceElement","referenceOwnerDocument","setReferenceOwnerDocument","anchorRefFallback","node","isMobileViewport","isExpanded","hasArrow","normalizedPlacementFromProps","frameOffsetRef","middleware","name","fn","x","y","current","data","amount","apply","sizeProps","firstElementChild","refs","floating","HTMLElement","Object","assign","maxHeight","availableHeight","overflow","crossAxis","limiter","padding","element","filter","m","slotName","slot","onDialogClose","type","event","dialogRef","dialogProps","__unstableOnClose","reference","referenceCallbackRef","strategy","update","computedPlacement","middlewareData","arrowData","whileElementsMounted","referenceParam","floatingParam","updateParam","animationFrame","arrowCallbackRef","resultingReferenceOwnerDoc","fallbackDocument","document","resultingReferenceElement","top","bottom","startContainer","ownerDocument","defaultView","frameElement","updateFrameOffset","addEventListener","removeEventListener","mergedFloatingRef","content","left","Number","isNaN","split","join","isFinite","ref","Popover","PopoverSlot","__unstableSlotNameProvider","Provider"],"mappings":";;;AAAA;AACA;AACA;AAEA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SACCC,WADD,EAECC,IAAI,IAAIC,cAFT,EAGCC,KAAK,IAAIC,eAHV,EAICC,UAJD,EAKCC,KALD,EAMCC,MAAM,IAAIC,gBANX,EAOCC,IAPD,QAUO,wBAVP,C,CAWA;;AACA,SACCC,MADD,EAECC,gBAFD,QAKO,eALP;AAOA;AACA;AACA;;AACA,SACCC,MADD,EAECC,eAFD,EAGCC,UAHD,EAICC,aAJD,EAKCC,UALD,EAMCC,OAND,EAOCC,QAPD,EAQCC,WARD,QASO,oBATP;AAUA,SACCC,gBADD,EAECC,YAFD,EAGCC,uBAAuB,IAAIC,SAH5B,QAIO,oBAJP;AAKA,SAASC,KAAT,QAAsB,kBAAtB;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,IAAT,EAAeC,GAAf,QAA0B,uBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,OAArB,QAAoC,cAApC;AACA,SACCC,cADD,EAECC,mBAFD,EAGCC,+BAHD,EAICC,yBAJD,EAKCC,mBALD,QAMO,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C,aAAD,OAzBD,CArCF,CAHD;;AAuEA,MAAKsB,IAAI,CAACyC,GAAV,EAAgB;AACfP,IAAAA,OAAO,GAAG,cAAC,IAAD;AAAM,MAAA,IAAI,EAAGnC;AAAb,OAA0BmC,OAA1B,CAAV;AACA;;AAED,MAAKnF,SAAS,IAAIC,UAAb,IAA2BR,MAAhC,EAAyC;AACxC,WAAO0F,OAAP;AACA;;AAED,SAAO;AAAM,IAAA,GAAG,EAAGnE;AAAZ,KAAkCmE,OAAlC,CAAP;AACA,CA5YD;AA8YA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMQ,OAAO,GAAG1J,UAAU,CAAE6C,kBAAF,CAA1B;;AAEP,SAAS8G,WAAT,QAECF,GAFD,EAGE;AAAA,MAFD;AAAElE,IAAAA,IAAI,GAAG7D;AAAT,GAEC;AACD,SACC,cAAC,IAAD,CACC;AADD;AAEC,IAAA,gBAAgB,MAFjB;AAGC,IAAA,IAAI,EAAG6D,IAHR;AAIC,IAAA,SAAS,EAAC,cAJX;AAKC,IAAA,GAAG,EAAGkE;AALP,IADD;AASA,C,CAED;;;AACAC,OAAO,CAAC1I,IAAR,GAAehB,UAAU,CAAE2J,WAAF,CAAzB,C,CACA;;AACAD,OAAO,CAACE,0BAAR,GAAqCjH,eAAe,CAACkH,QAArD;AAEA,eAAeH,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, SyntheticEvent, RefCallback } from 'react';\nimport classnames from 'classnames';\nimport {\n\tuseFloating,\n\tflip as flipMiddleware,\n\tshift as shiftMiddleware,\n\tautoUpdate,\n\tarrow,\n\toffset as offsetMiddleware,\n\tsize,\n\tMiddleware,\n\tMiddlewareArguments,\n} from '@floating-ui/react-dom';\n// eslint-disable-next-line no-restricted-imports\nimport {\n\tmotion,\n\tuseReducedMotion,\n\tHTMLMotionProps,\n\tMotionProps,\n} from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseLayoutEffect,\n\tforwardRef,\n\tcreateContext,\n\tuseContext,\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport {\n\tgetFrameOffset,\n\tpositionToPlacement,\n\tplacementToMotionAnimationProps,\n\tgetReferenceOwnerDocument,\n\tgetReferenceElement,\n} from './utils';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type {\n\tPopoverProps,\n\tAnimatedWrapperProps,\n\tPopoverAnchorRefReference,\n\tPopoverAnchorRefTopBottom,\n} from './types';\nimport { limitShift as customLimitShift } from './limit-shift';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nconst SLOT_NAME = 'Popover';\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\tviewBox={ `0 0 100 100` }\n\t\tclassName=\"components-popover__triangle\"\n\t\trole=\"presentation\"\n\t>\n\t\t<Path\n\t\t\tclassName=\"components-popover__triangle-bg\"\n\t\t\td=\"M 0 0 L 50 50 L 100 0\"\n\t\t/>\n\t\t<Path\n\t\t\tclassName=\"components-popover__triangle-border\"\n\t\t\td=\"M 0 0 L 50 50 L 100 0\"\n\t\t\tvectorEffect=\"non-scaling-stroke\"\n\t\t/>\n\t</SVG>\n);\n\nconst AnimatedWrapper = forwardRef(\n\t(\n\t\t{\n\t\t\tstyle: receivedInlineStyles,\n\t\t\tplacement,\n\t\t\tshouldAnimate = false,\n\t\t\t...props\n\t\t}: HTMLMotionProps< 'div' > & AnimatedWrapperProps,\n\t\tforwardedRef: ForwardedRef< any >\n\t) => {\n\t\t// When animating, animate only once (i.e. when the popover is opened), and\n\t\t// do not animate on subsequent prop changes (as it conflicts with\n\t\t// floating-ui's positioning updates).\n\t\tconst [ hasAnimatedOnce, setHasAnimatedOnce ] = useState( false );\n\t\tconst shouldReduceMotion = useReducedMotion();\n\n\t\tconst { style: motionInlineStyles, ...otherMotionProps } = useMemo(\n\t\t\t() => placementToMotionAnimationProps( placement ),\n\t\t\t[ placement ]\n\t\t);\n\n\t\tconst onAnimationComplete = useCallback(\n\t\t\t() => setHasAnimatedOnce( true ),\n\t\t\t[]\n\t\t);\n\n\t\tconst computedAnimationProps: HTMLMotionProps< 'div' > =\n\t\t\tshouldAnimate && ! shouldReduceMotion\n\t\t\t\t? {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...motionInlineStyles,\n\t\t\t\t\t\t\t...receivedInlineStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...otherMotionProps,\n\t\t\t\t\t\tonAnimationComplete,\n\t\t\t\t\t\tanimate: hasAnimatedOnce\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: otherMotionProps.animate,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tanimate: false,\n\t\t\t\t\t\tstyle: receivedInlineStyles,\n\t\t\t\t };\n\n\t\treturn (\n\t\t\t<motion.div\n\t\t\t\t{ ...computedAnimationProps }\n\t\t\t\t{ ...props }\n\t\t\t\tref={ forwardedRef }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nconst slotNameContext = createContext< string | undefined >( undefined );\n\nconst UnforwardedPopover = (\n\tprops: Omit<\n\t\tWordPressComponentProps< PopoverProps, 'div', false >,\n\t\t// To avoid overlaps between the standard HTML attributes and the props\n\t\t// expected by `framer-motion`, omit all framer motion props from popover\n\t\t// props (except for `animate`, which is re-defined in `PopoverProps`).\n\t\tkeyof Omit< MotionProps, 'animate' >\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tanimate = true,\n\t\theaderTitle,\n\t\tonClose,\n\t\tchildren,\n\t\tclassName,\n\t\tnoArrow = true,\n\t\tisAlternate,\n\t\tposition,\n\t\tplacement: placementProp = 'bottom-start',\n\t\toffset: offsetProp = 0,\n\t\tfocusOnMount = 'firstElement',\n\t\tanchor,\n\t\texpandOnMobile,\n\t\tonFocusOutside,\n\t\t__unstableSlotName = SLOT_NAME,\n\t\tflip = true,\n\t\tresize = true,\n\t\tshift = false,\n\n\t\t// Deprecated props\n\t\t__unstableForcePosition,\n\t\t__unstableShift,\n\t\tanchorRef,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\trange,\n\n\t\t// Rest\n\t\t...contentProps\n\t} = props;\n\n\tif ( range ) {\n\t\tdeprecated( '`range` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t} );\n\t}\n\n\tlet computedFlipProp = flip;\n\tlet computedResizeProp = resize;\n\tif ( __unstableForcePosition !== undefined ) {\n\t\tdeprecated( '`__unstableForcePosition` prop wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`flip={ false }` and `resize={ false }`',\n\t\t} );\n\n\t\t// Back-compat, set the `flip` and `resize` props\n\t\t// to `false` to replicate `__unstableForcePosition`.\n\t\tcomputedFlipProp = ! __unstableForcePosition;\n\t\tcomputedResizeProp = ! __unstableForcePosition;\n\t}\n\n\tlet shouldShift = shift;\n\tif ( __unstableShift !== undefined ) {\n\t\tdeprecated( '`__unstableShift` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`shift` prop`',\n\t\t} );\n\n\t\t// Back-compat.\n\t\tshouldShift = __unstableShift;\n\t}\n\n\tif ( anchorRef !== undefined ) {\n\t\tdeprecated( '`anchorRef` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tif ( anchorRect !== undefined ) {\n\t\tdeprecated( '`anchorRect` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tif ( getAnchorRect !== undefined ) {\n\t\tdeprecated( '`getAnchorRect` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tconst arrowRef = useRef( null );\n\n\tconst [ fallbackReferenceElement, setFallbackReferenceElement ] =\n\t\tuseState< HTMLSpanElement | null >( null );\n\tconst [ referenceOwnerDocument, setReferenceOwnerDocument ] = useState<\n\t\tDocument | undefined\n\t>();\n\n\tconst anchorRefFallback: RefCallback< HTMLSpanElement > = useCallback(\n\t\t( node ) => {\n\t\t\tsetFallbackReferenceElement( node );\n\t\t},\n\t\t[]\n\t);\n\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isExpanded = expandOnMobile && isMobileViewport;\n\tconst hasArrow = ! isExpanded && ! noArrow;\n\tconst normalizedPlacementFromProps = position\n\t\t? positionToPlacement( position )\n\t\t: placementProp;\n\n\t/**\n\t * Offsets the position of the popover when the anchor is inside an iframe.\n\t *\n\t * Store the offset in a ref, due to constraints with floating-ui:\n\t * https://floating-ui.com/docs/react-dom#variables-inside-middleware-functions.\n\t */\n\tconst frameOffsetRef = useRef( getFrameOffset( referenceOwnerDocument ) );\n\n\tconst middleware = [\n\t\t// Custom middleware which adjusts the popover's position by taking into\n\t\t// account the offset of the anchor's iframe (if any) compared to the page.\n\t\t{\n\t\t\tname: 'frameOffset',\n\t\t\tfn( { x, y }: MiddlewareArguments ) {\n\t\t\t\tif ( ! frameOffsetRef.current ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tx: x + frameOffsetRef.current.x,\n\t\t\t\t\ty: y + frameOffsetRef.current.y,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t// This will be used in the customLimitShift() function.\n\t\t\t\t\t\tamount: frameOffsetRef.current,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toffsetMiddleware( offsetProp ),\n\t\tcomputedFlipProp ? flipMiddleware() : undefined,\n\t\tcomputedResizeProp\n\t\t\t? size( {\n\t\t\t\t\tapply( sizeProps ) {\n\t\t\t\t\t\tconst { firstElementChild } =\n\t\t\t\t\t\t\trefs.floating.current ?? {};\n\n\t\t\t\t\t\t// Only HTMLElement instances have the `style` property.\n\t\t\t\t\t\tif ( ! ( firstElementChild instanceof HTMLElement ) )\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t// Reduce the height of the popover to the available space.\n\t\t\t\t\t\tObject.assign( firstElementChild.style, {\n\t\t\t\t\t\t\tmaxHeight: `${ sizeProps.availableHeight }px`,\n\t\t\t\t\t\t\toverflow: 'auto',\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t } )\n\t\t\t: undefined,\n\t\tshouldShift\n\t\t\t? shiftMiddleware( {\n\t\t\t\t\tcrossAxis: true,\n\t\t\t\t\tlimiter: customLimitShift(),\n\t\t\t\t\tpadding: 1, // Necessary to avoid flickering at the edge of the viewport.\n\t\t\t } )\n\t\t\t: undefined,\n\t\tarrow( { element: arrowRef } ),\n\t].filter(\n\t\t( m: Middleware | undefined ): m is Middleware => m !== undefined\n\t);\n\tconst slotName = useContext( slotNameContext ) || __unstableSlotName;\n\tconst slot = useSlot( slotName );\n\n\tlet onDialogClose;\n\n\tif ( onClose || onFocusOutside ) {\n\t\tonDialogClose = ( type: string | undefined, event: SyntheticEvent ) => {\n\t\t\t// Ideally the popover should have just a single onClose prop and\n\t\t\t// not three props that potentially do the same thing.\n\t\t\tif ( type === 'focus-outside' && onFocusOutside ) {\n\t\t\t\tonFocusOutside( event );\n\t\t\t} else if ( onClose ) {\n\t\t\t\tonClose();\n\t\t\t}\n\t\t};\n\t}\n\n\tconst [ dialogRef, dialogProps ] = useDialog( {\n\t\tfocusOnMount,\n\t\t__unstableOnClose: onDialogClose,\n\t\t// @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n\t\tonClose: onDialogClose,\n\t} );\n\n\tconst {\n\t\t// Positioning coordinates\n\t\tx,\n\t\ty,\n\t\t// Callback refs (not regular refs). This allows the position to be updated.\n\t\t// when either elements change.\n\t\treference: referenceCallbackRef,\n\t\tfloating,\n\t\t// Object with \"regular\" refs to both \"reference\" and \"floating\"\n\t\trefs,\n\t\t// Type of CSS position property to use (absolute or fixed)\n\t\tstrategy,\n\t\tupdate,\n\t\tplacement: computedPlacement,\n\t\tmiddlewareData: { arrow: arrowData },\n\t} = useFloating( {\n\t\tplacement: normalizedPlacementFromProps,\n\t\tmiddleware,\n\t\twhileElementsMounted: ( referenceParam, floatingParam, updateParam ) =>\n\t\t\tautoUpdate( referenceParam, floatingParam, updateParam, {\n\t\t\t\tanimationFrame: true,\n\t\t\t} ),\n\t} );\n\n\tconst arrowCallbackRef = useCallback(\n\t\t( node ) => {\n\t\t\tarrowRef.current = node;\n\t\t\tupdate();\n\t\t},\n\t\t[ update ]\n\t);\n\n\t// When any of the possible anchor \"sources\" change,\n\t// recompute the reference element (real or virtual) and its owner document.\n\tuseLayoutEffect( () => {\n\t\tconst resultingReferenceOwnerDoc = getReferenceOwnerDocument( {\n\t\t\tanchor,\n\t\t\tanchorRef,\n\t\t\tanchorRect,\n\t\t\tgetAnchorRect,\n\t\t\tfallbackReferenceElement,\n\t\t\tfallbackDocument: document,\n\t\t} );\n\t\tconst resultingReferenceElement = getReferenceElement( {\n\t\t\tanchor,\n\t\t\tanchorRef,\n\t\t\tanchorRect,\n\t\t\tgetAnchorRect,\n\t\t\tfallbackReferenceElement,\n\t\t} );\n\n\t\treferenceCallbackRef( resultingReferenceElement );\n\n\t\tsetReferenceOwnerDocument( resultingReferenceOwnerDoc );\n\t}, [\n\t\tanchor,\n\t\tanchorRef as Element | undefined,\n\t\t( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top,\n\t\t( anchorRef as PopoverAnchorRefTopBottom | undefined )?.bottom,\n\t\t( anchorRef as Range | undefined )?.startContainer,\n\t\t( anchorRef as PopoverAnchorRefReference )?.current,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\tfallbackReferenceElement,\n\t\treferenceCallbackRef,\n\t] );\n\n\t// If the reference element is in a different ownerDocument (e.g. iFrame),\n\t// we need to manually update the floating's position as the reference's owner\n\t// document scrolls. Also update the frame offset if the view resizes.\n\tuseLayoutEffect( () => {\n\t\tif (\n\t\t\t// Reference and root documents are the same.\n\t\t\treferenceOwnerDocument === document ||\n\t\t\t// Reference and floating are in the same document.\n\t\t\treferenceOwnerDocument === refs?.floating?.current?.ownerDocument ||\n\t\t\t// The reference's document has no view (i.e. window)\n\t\t\t// or frame element (ie. it's not an iframe).\n\t\t\t! referenceOwnerDocument?.defaultView?.frameElement\n\t\t) {\n\t\t\tframeOffsetRef.current = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tconst { defaultView } = referenceOwnerDocument;\n\n\t\tconst updateFrameOffset = () => {\n\t\t\tframeOffsetRef.current = getFrameOffset( referenceOwnerDocument );\n\t\t\tupdate();\n\t\t};\n\t\tdefaultView.addEventListener( 'resize', updateFrameOffset );\n\n\t\tupdateFrameOffset();\n\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'resize', updateFrameOffset );\n\t\t};\n\t}, [ referenceOwnerDocument, update ] );\n\n\tconst mergedFloatingRef = useMergeRefs( [\n\t\tfloating,\n\t\tdialogRef,\n\t\tforwardedRef,\n\t] );\n\n\t// Disable reason: We care to capture the _bubbled_ events from inputs\n\t// within popover as inferring close intent.\n\n\tlet content = (\n\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<AnimatedWrapper\n\t\t\tshouldAnimate={ animate && ! isExpanded }\n\t\t\tplacement={ computedPlacement }\n\t\t\tclassName={ classnames( 'components-popover', className, {\n\t\t\t\t'is-expanded': isExpanded,\n\t\t\t\t'is-alternate': isAlternate,\n\t\t\t} ) }\n\t\t\t{ ...contentProps }\n\t\t\tref={ mergedFloatingRef }\n\t\t\t{ ...dialogProps }\n\t\t\ttabIndex={ -1 }\n\t\t\tstyle={\n\t\t\t\tisExpanded\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\t\tleft: Number.isNaN( x ) ? 0 : x ?? undefined,\n\t\t\t\t\t\t\ttop: Number.isNaN( y ) ? 0 : y ?? undefined,\n\t\t\t\t\t }\n\t\t\t}\n\t\t>\n\t\t\t{ /* Prevents scroll on the document */ }\n\t\t\t{ isExpanded && <ScrollLock /> }\n\t\t\t{ isExpanded && (\n\t\t\t\t<div className=\"components-popover__header\">\n\t\t\t\t\t<span className=\"components-popover__header-title\">\n\t\t\t\t\t\t{ headerTitle }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-popover__close\"\n\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"components-popover__content\">{ children }</div>\n\t\t\t{ hasArrow && (\n\t\t\t\t<div\n\t\t\t\t\tref={ arrowCallbackRef }\n\t\t\t\t\tclassName={ [\n\t\t\t\t\t\t'components-popover__arrow',\n\t\t\t\t\t\t`is-${ computedPlacement.split( '-' )[ 0 ] }`,\n\t\t\t\t\t].join( ' ' ) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\ttypeof arrowData?.x !== 'undefined' &&\n\t\t\t\t\t\t\tNumber.isFinite( arrowData.x )\n\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\tarrowData.x +\n\t\t\t\t\t\t\t\t\t\t( frameOffsetRef.current?.x ?? 0 )\n\t\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\ttypeof arrowData?.y !== 'undefined' &&\n\t\t\t\t\t\t\tNumber.isFinite( arrowData.y )\n\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\tarrowData.y +\n\t\t\t\t\t\t\t\t\t\t( frameOffsetRef.current?.y ?? 0 )\n\t\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<ArrowTriangle />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</AnimatedWrapper>\n\t);\n\n\tif ( slot.ref ) {\n\t\tcontent = <Fill name={ slotName }>{ content }</Fill>;\n\t}\n\n\tif ( anchorRef || anchorRect || anchor ) {\n\t\treturn content;\n\t}\n\n\treturn <span ref={ anchorRefFallback }>{ content }</span>;\n};\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = forwardRef( UnforwardedPopover );\n\nfunction PopoverSlot(\n\t{ name = SLOT_NAME }: { name?: string },\n\tref: ForwardedRef< any >\n) {\n\treturn (\n\t\t<Slot\n\t\t\t// @ts-expect-error Need to type `SlotFill`\n\t\t\tbubblesVirtually\n\t\t\tname={ name }\n\t\t\tclassName=\"popover-slot\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\n// @ts-expect-error For Legacy Reasons\nPopover.Slot = forwardRef( PopoverSlot );\n// @ts-expect-error For Legacy Reasons\nPopover.__unstableSlotNameProvider = slotNameContext.Provider;\n\nexport default Popover;\n"]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parts of this source were derived and modified from `floating-ui`,
|
|
7
|
+
* released under the MIT license.
|
|
8
|
+
*
|
|
9
|
+
* https://github.com/floating-ui/floating-ui
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2021 Floating UI contributors
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Custom limiter function for the `shift` middleware.
|
|
34
|
+
* This function is mostly identical default `limitShift` from ``@floating-ui`;
|
|
35
|
+
* the only difference is that, when computing the min/max shift limits, it
|
|
36
|
+
* also takes into account the iframe offset that is added by the
|
|
37
|
+
* custom "frameOffset" middleware.
|
|
38
|
+
*
|
|
39
|
+
* All unexported types and functions are also from the `@floating-ui` library,
|
|
40
|
+
* and have been copied to this file for convenience.
|
|
41
|
+
*/
|
|
42
|
+
function getSide(placement) {
|
|
43
|
+
return placement.split('-')[0];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getMainAxisFromPlacement(placement) {
|
|
47
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getCrossAxis(axis) {
|
|
51
|
+
return axis === 'x' ? 'y' : 'x';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const limitShift = function () {
|
|
55
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
56
|
+
return {
|
|
57
|
+
options,
|
|
58
|
+
|
|
59
|
+
fn(middlewareArguments) {
|
|
60
|
+
var _middlewareData$frame;
|
|
61
|
+
|
|
62
|
+
const {
|
|
63
|
+
x,
|
|
64
|
+
y,
|
|
65
|
+
placement,
|
|
66
|
+
rects,
|
|
67
|
+
middlewareData
|
|
68
|
+
} = middlewareArguments;
|
|
69
|
+
const {
|
|
70
|
+
offset = 0,
|
|
71
|
+
mainAxis: checkMainAxis = true,
|
|
72
|
+
crossAxis: checkCrossAxis = true
|
|
73
|
+
} = options;
|
|
74
|
+
const coords = {
|
|
75
|
+
x,
|
|
76
|
+
y
|
|
77
|
+
};
|
|
78
|
+
const mainAxis = getMainAxisFromPlacement(placement);
|
|
79
|
+
const crossAxis = getCrossAxis(mainAxis);
|
|
80
|
+
let mainAxisCoord = coords[mainAxis];
|
|
81
|
+
let crossAxisCoord = coords[crossAxis];
|
|
82
|
+
const rawOffset = typeof offset === 'function' ? offset(middlewareArguments) : offset;
|
|
83
|
+
const computedOffset = typeof rawOffset === 'number' ? {
|
|
84
|
+
mainAxis: rawOffset,
|
|
85
|
+
crossAxis: 0
|
|
86
|
+
} : {
|
|
87
|
+
mainAxis: 0,
|
|
88
|
+
crossAxis: 0,
|
|
89
|
+
...rawOffset
|
|
90
|
+
}; // At the moment of writing, this is the only difference
|
|
91
|
+
// with the `limitShift` function from `@floating-ui`.
|
|
92
|
+
// This offset needs to be added to all min/max limits
|
|
93
|
+
// in order to make the shift-limiting work as expected.
|
|
94
|
+
|
|
95
|
+
const additionalFrameOffset = {
|
|
96
|
+
x: 0,
|
|
97
|
+
y: 0,
|
|
98
|
+
...((_middlewareData$frame = middlewareData.frameOffset) === null || _middlewareData$frame === void 0 ? void 0 : _middlewareData$frame.amount)
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
if (checkMainAxis) {
|
|
102
|
+
const len = mainAxis === 'y' ? 'height' : 'width';
|
|
103
|
+
const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis + additionalFrameOffset[mainAxis];
|
|
104
|
+
const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis + additionalFrameOffset[mainAxis];
|
|
105
|
+
|
|
106
|
+
if (mainAxisCoord < limitMin) {
|
|
107
|
+
mainAxisCoord = limitMin;
|
|
108
|
+
} else if (mainAxisCoord > limitMax) {
|
|
109
|
+
mainAxisCoord = limitMax;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (checkCrossAxis) {
|
|
114
|
+
var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;
|
|
115
|
+
|
|
116
|
+
const len = mainAxis === 'y' ? 'width' : 'height';
|
|
117
|
+
const isOriginSide = ['top', 'left'].includes(getSide(placement));
|
|
118
|
+
const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? (_middlewareData$offse = (_middlewareData$offse2 = middlewareData.offset) === null || _middlewareData$offse2 === void 0 ? void 0 : _middlewareData$offse2[crossAxis]) !== null && _middlewareData$offse !== void 0 ? _middlewareData$offse : 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis) + additionalFrameOffset[crossAxis];
|
|
119
|
+
const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : (_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) === null || _middlewareData$offse4 === void 0 ? void 0 : _middlewareData$offse4[crossAxis]) !== null && _middlewareData$offse3 !== void 0 ? _middlewareData$offse3 : 0) - (isOriginSide ? computedOffset.crossAxis : 0) + additionalFrameOffset[crossAxis];
|
|
120
|
+
|
|
121
|
+
if (crossAxisCoord < limitMin) {
|
|
122
|
+
crossAxisCoord = limitMin;
|
|
123
|
+
} else if (crossAxisCoord > limitMax) {
|
|
124
|
+
crossAxisCoord = limitMax;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
[mainAxis]: mainAxisCoord,
|
|
130
|
+
[crossAxis]: crossAxisCoord
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=limit-shift.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/popover/limit-shift.ts"],"names":["getSide","placement","split","getMainAxisFromPlacement","includes","getCrossAxis","axis","limitShift","options","fn","middlewareArguments","x","y","rects","middlewareData","offset","mainAxis","checkMainAxis","crossAxis","checkCrossAxis","coords","mainAxisCoord","crossAxisCoord","rawOffset","computedOffset","additionalFrameOffset","frameOffset","amount","len","limitMin","reference","floating","limitMax","isOriginSide"],"mappings":"AAAA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAkDA,SAASA,OAAT,CAAkBC,SAAlB,EAA+C;AAC9C,SAAOA,SAAS,CAACC,KAAV,CAAiB,GAAjB,EAAwB,CAAxB,CAAP;AACA;;AAED,SAASC,wBAAT,CAAmCF,SAAnC,EAAgE;AAC/D,SAAO,CAAE,KAAF,EAAS,QAAT,EAAoBG,QAApB,CAA8BJ,OAAO,CAAEC,SAAF,CAArC,IAAuD,GAAvD,GAA6D,GAApE;AACA;;AAED,SAASI,YAAT,CAAuBC,IAAvB,EAA0C;AACzC,SAAOA,IAAI,KAAK,GAAT,GAAe,GAAf,GAAqB,GAA5B;AACA;;AAED,OAAO,MAAMC,UAAU,GAAG;AAAA,MACzBC,OADyB,uEACe,EADf;AAAA,SAKnB;AACNA,IAAAA,OADM;;AAENC,IAAAA,EAAE,CAAEC,mBAAF,EAAwB;AAAA;;AACzB,YAAM;AAAEC,QAAAA,CAAF;AAAKC,QAAAA,CAAL;AAAQX,QAAAA,SAAR;AAAmBY,QAAAA,KAAnB;AAA0BC,QAAAA;AAA1B,UAA6CJ,mBAAnD;AACA,YAAM;AACLK,QAAAA,MAAM,GAAG,CADJ;AAELC,QAAAA,QAAQ,EAAEC,aAAa,GAAG,IAFrB;AAGLC,QAAAA,SAAS,EAAEC,cAAc,GAAG;AAHvB,UAIFX,OAJJ;AAMA,YAAMY,MAAM,GAAG;AAAET,QAAAA,CAAF;AAAKC,QAAAA;AAAL,OAAf;AACA,YAAMI,QAAQ,GAAGb,wBAAwB,CAAEF,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oords,\n\tPlacement,\n\tSide,\n\tMiddlewareArguments,\n} from '@floating-ui/react-dom';\n\n/**\n * Parts of this source were derived and modified from `floating-ui`,\n * released under the MIT license.\n *\n * https://github.com/floating-ui/floating-ui\n *\n * Copyright (c) 2021 Floating UI contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Custom limiter function for the `shift` middleware.\n * This function is mostly identical default `limitShift` from ``@floating-ui`;\n * the only difference is that, when computing the min/max shift limits, it\n * also takes into account the iframe offset that is added by the\n * custom \"frameOffset\" middleware.\n *\n * All unexported types and functions are also from the `@floating-ui` library,\n * and have been copied to this file for convenience.\n */\n\ntype LimitShiftOffset =\n\t| ( ( args: MiddlewareArguments ) =>\n\t\t\t| number\n\t\t\t| {\n\t\t\t\t\t/**\n\t\t\t\t\t * Offset the limiting of the axis that runs along the alignment of the\n\t\t\t\t\t * floating element.\n\t\t\t\t\t */\n\t\t\t\t\tmainAxis?: number;\n\t\t\t\t\t/**\n\t\t\t\t\t * Offset the limiting of the axis that runs along the side of the\n\t\t\t\t\t * floating element.\n\t\t\t\t\t */\n\t\t\t\t\tcrossAxis?: number;\n\t\t\t } )\n\t| number\n\t| {\n\t\t\t/**\n\t\t\t * Offset the limiting of the axis that runs along the alignment of the\n\t\t\t * floating element.\n\t\t\t */\n\t\t\tmainAxis?: number;\n\t\t\t/**\n\t\t\t * Offset the limiting of the axis that runs along the side of the\n\t\t\t * floating element.\n\t\t\t */\n\t\t\tcrossAxis?: number;\n\t };\n\ntype LimitShiftOptions = {\n\t/**\n\t * Offset when limiting starts. `0` will limit when the opposite edges of the\n\t * reference and floating elements are aligned.\n\t * - positive = start limiting earlier\n\t * - negative = start limiting later\n\t */\n\toffset: LimitShiftOffset;\n\t/**\n\t * Whether to limit the axis that runs along the alignment of the floating\n\t * element.\n\t */\n\tmainAxis: boolean;\n\t/**\n\t * Whether to limit the axis that runs along the side of the floating element.\n\t */\n\tcrossAxis: boolean;\n};\n\nfunction getSide( placement: Placement ): Side {\n\treturn placement.split( '-' )[ 0 ] as Side;\n}\n\nfunction getMainAxisFromPlacement( placement: Placement ): Axis {\n\treturn [ 'top', 'bottom' ].includes( getSide( placement ) ) ? 'x' : 'y';\n}\n\nfunction getCrossAxis( axis: Axis ): Axis {\n\treturn axis === 'x' ? 'y' : 'x';\n}\n\nexport const limitShift = (\n\toptions: Partial< LimitShiftOptions > = {}\n): {\n\toptions: Partial< LimitShiftOffset >;\n\tfn: ( middlewareArguments: MiddlewareArguments ) => Coords;\n} => ( {\n\toptions,\n\tfn( middlewareArguments ) {\n\t\tconst { x, y, placement, rects, middlewareData } = middlewareArguments;\n\t\tconst {\n\t\t\toffset = 0,\n\t\t\tmainAxis: checkMainAxis = true,\n\t\t\tcrossAxis: checkCrossAxis = true,\n\t\t} = options;\n\n\t\tconst coords = { x, y };\n\t\tconst mainAxis = getMainAxisFromPlacement( placement );\n\t\tconst crossAxis = getCrossAxis( mainAxis );\n\n\t\tlet mainAxisCoord = coords[ mainAxis ];\n\t\tlet crossAxisCoord = coords[ crossAxis ];\n\n\t\tconst rawOffset =\n\t\t\ttypeof offset === 'function'\n\t\t\t\t? offset( middlewareArguments )\n\t\t\t\t: offset;\n\t\tconst computedOffset =\n\t\t\ttypeof rawOffset === 'number'\n\t\t\t\t? { mainAxis: rawOffset, crossAxis: 0 }\n\t\t\t\t: { mainAxis: 0, crossAxis: 0, ...rawOffset };\n\n\t\t// At the moment of writing, this is the only difference\n\t\t// with the `limitShift` function from `@floating-ui`.\n\t\t// This offset needs to be added to all min/max limits\n\t\t// in order to make the shift-limiting work as expected.\n\t\tconst additionalFrameOffset = {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\t...middlewareData.frameOffset?.amount,\n\t\t};\n\n\t\tif ( checkMainAxis ) {\n\t\t\tconst len = mainAxis === 'y' ? 'height' : 'width';\n\t\t\tconst limitMin =\n\t\t\t\trects.reference[ mainAxis ] -\n\t\t\t\trects.floating[ len ] +\n\t\t\t\tcomputedOffset.mainAxis +\n\t\t\t\tadditionalFrameOffset[ mainAxis ];\n\t\t\tconst limitMax =\n\t\t\t\trects.reference[ mainAxis ] +\n\t\t\t\trects.reference[ len ] -\n\t\t\t\tcomputedOffset.mainAxis +\n\t\t\t\tadditionalFrameOffset[ mainAxis ];\n\n\t\t\tif ( mainAxisCoord < limitMin ) {\n\t\t\t\tmainAxisCoord = limitMin;\n\t\t\t} else if ( mainAxisCoord > limitMax ) {\n\t\t\t\tmainAxisCoord = limitMax;\n\t\t\t}\n\t\t}\n\n\t\tif ( checkCrossAxis ) {\n\t\t\tconst len = mainAxis === 'y' ? 'width' : 'height';\n\t\t\tconst isOriginSide = [ 'top', 'left' ].includes(\n\t\t\t\tgetSide( placement )\n\t\t\t);\n\t\t\tconst limitMin =\n\t\t\t\trects.reference[ crossAxis ] -\n\t\t\t\trects.floating[ len ] +\n\t\t\t\t( isOriginSide\n\t\t\t\t\t? middlewareData.offset?.[ crossAxis ] ?? 0\n\t\t\t\t\t: 0 ) +\n\t\t\t\t( isOriginSide ? 0 : computedOffset.crossAxis ) +\n\t\t\t\tadditionalFrameOffset[ crossAxis ];\n\t\t\tconst limitMax =\n\t\t\t\trects.reference[ crossAxis ] +\n\t\t\t\trects.reference[ len ] +\n\t\t\t\t( isOriginSide\n\t\t\t\t\t? 0\n\t\t\t\t\t: middlewareData.offset?.[ crossAxis ] ?? 0 ) -\n\t\t\t\t( isOriginSide ? computedOffset.crossAxis : 0 ) +\n\t\t\t\tadditionalFrameOffset[ crossAxis ];\n\n\t\t\tif ( crossAxisCoord < limitMin ) {\n\t\t\t\tcrossAxisCoord = limitMin;\n\t\t\t} else if ( crossAxisCoord > limitMax ) {\n\t\t\t\tcrossAxisCoord = limitMax;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t[ mainAxis ]: mainAxisCoord,\n\t\t\t[ crossAxis ]: crossAxisCoord,\n\t\t} as Coords;\n\t},\n} );\n"]}
|
|
@@ -6,7 +6,58 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
const POSITION_TO_PLACEMENT = {
|
|
10
|
+
bottom: 'bottom',
|
|
11
|
+
top: 'top',
|
|
12
|
+
'middle left': 'left',
|
|
13
|
+
'middle right': 'right',
|
|
14
|
+
'bottom left': 'bottom-end',
|
|
15
|
+
'bottom center': 'bottom',
|
|
16
|
+
'bottom right': 'bottom-start',
|
|
17
|
+
'top left': 'top-end',
|
|
18
|
+
'top center': 'top',
|
|
19
|
+
'top right': 'top-start',
|
|
20
|
+
'middle left left': 'left',
|
|
21
|
+
'middle left right': 'left',
|
|
22
|
+
'middle left bottom': 'left-end',
|
|
23
|
+
'middle left top': 'left-start',
|
|
24
|
+
'middle right left': 'right',
|
|
25
|
+
'middle right right': 'right',
|
|
26
|
+
'middle right bottom': 'right-end',
|
|
27
|
+
'middle right top': 'right-start',
|
|
28
|
+
'bottom left left': 'bottom-end',
|
|
29
|
+
'bottom left right': 'bottom-end',
|
|
30
|
+
'bottom left bottom': 'bottom-end',
|
|
31
|
+
'bottom left top': 'bottom-end',
|
|
32
|
+
'bottom center left': 'bottom',
|
|
33
|
+
'bottom center right': 'bottom',
|
|
34
|
+
'bottom center bottom': 'bottom',
|
|
35
|
+
'bottom center top': 'bottom',
|
|
36
|
+
'bottom right left': 'bottom-start',
|
|
37
|
+
'bottom right right': 'bottom-start',
|
|
38
|
+
'bottom right bottom': 'bottom-start',
|
|
39
|
+
'bottom right top': 'bottom-start',
|
|
40
|
+
'top left left': 'top-end',
|
|
41
|
+
'top left right': 'top-end',
|
|
42
|
+
'top left bottom': 'top-end',
|
|
43
|
+
'top left top': 'top-end',
|
|
44
|
+
'top center left': 'top',
|
|
45
|
+
'top center right': 'top',
|
|
46
|
+
'top center bottom': 'top',
|
|
47
|
+
'top center top': 'top',
|
|
48
|
+
'top right left': 'top-start',
|
|
49
|
+
'top right right': 'top-start',
|
|
50
|
+
'top right bottom': 'top-start',
|
|
51
|
+
'top right top': 'top-start',
|
|
52
|
+
// `middle`/`middle center [corner?]` positions are associated to a fallback
|
|
53
|
+
// `bottom` placement because there aren't any corresponding placement values.
|
|
54
|
+
middle: 'bottom',
|
|
55
|
+
'middle center': 'bottom',
|
|
56
|
+
'middle center bottom': 'bottom',
|
|
57
|
+
'middle center left': 'bottom',
|
|
58
|
+
'middle center right': 'bottom',
|
|
59
|
+
'middle center top': 'bottom'
|
|
60
|
+
};
|
|
10
61
|
/**
|
|
11
62
|
* Converts the `Popover`'s legacy "position" prop to the new "placement" prop
|
|
12
63
|
* (used by `floating-ui`).
|
|
@@ -14,22 +65,11 @@
|
|
|
14
65
|
* @param position The legacy position
|
|
15
66
|
* @return The corresponding placement
|
|
16
67
|
*/
|
|
17
|
-
export const positionToPlacement = position => {
|
|
18
|
-
const [x, y, z] = position.split(' ');
|
|
19
|
-
|
|
20
|
-
if (['top', 'bottom'].includes(x)) {
|
|
21
|
-
let suffix = '';
|
|
22
68
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} else if (!!z && z === 'right' || y === 'left') {
|
|
26
|
-
suffix = '-end';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return x + suffix;
|
|
30
|
-
}
|
|
69
|
+
export const positionToPlacement = position => {
|
|
70
|
+
var _POSITION_TO_PLACEMEN;
|
|
31
71
|
|
|
32
|
-
return
|
|
72
|
+
return (_POSITION_TO_PLACEMEN = POSITION_TO_PLACEMENT[position]) !== null && _POSITION_TO_PLACEMEN !== void 0 ? _POSITION_TO_PLACEMEN : 'bottom';
|
|
33
73
|
};
|
|
34
74
|
/**
|
|
35
75
|
* @typedef AnimationOrigin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/popover/utils.ts"],"names":["positionToPlacement","position","x","y","z","split","includes","suffix","PLACEMENT_TO_ANIMATION_ORIGIN","top","originX","originY","right","bottom","left","placementToMotionAnimationProps","placement","translateProp","startsWith","translateDirection","style","initial","opacity","scale","animate","transition","duration","ease","getFrameOffset","document","frameElement","defaultView","iframeRect","getBoundingClientRect","getReferenceOwnerDocument","anchor","anchorRef","anchorRect","getAnchorRect","fallbackReferenceElement","fallbackDocument","resultingReferenceOwnerDoc","ownerDocument","startContainer","current","getReferenceElement","referenceElement","topRect","bottomRect","window","DOMRect","width","rect","height","parentElement"],"mappings":"AAAA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,mBAAmB,GAC/BC,QADkC,IAEc;AAChD,QAAM,CAAEC,CAAF,EAAKC,CAAL,EAAQC,CAAR,IAAcH,QAAQ,CAACI,KAAT,CAAgB,GAAhB,CAApB;;AAEA,MAAK,CAAE,KAAF,EAAS,QAAT,EAAoBC,QAApB,CAA8BJ,CAA9B,CAAL,EAAyC;AACxC,QAAIK,MAAM,GAAG,EAAb;;AACA,QAAO,CAAC,CAAEH,CAAH,IAAQA,CAAC,KAAK,MAAhB,IAA4BD,CAAC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,SAAL,EAAwC;AAC9C;AACA;AACAU,IAAAA,gBAAgB,GAAGV,SAAnB;AACA,GAJM,MAIA,IAAKC,UAAL,EAAkB;AACxB;AACAS,IAAAA,gBAAgB,GAAG;AAClBb,MAAAA,qBAAqB,GAAG;AACvB,eAAOI,UAAP;AACA;;AAHiB,KAAnB;AAKA,GAPM,MAOA,IAAKC,aAAL,EAAqB;AAC3B;AACAQ,IAAAA,gBAAgB,GAAG;AAClBb,MAAAA,qBAAqB,GAAG;AAAA;;AACvB,cAAMmB,IAAI,GAAGd,aAAa,CAAEC,wBAAF,CAA1B;AACA,eAAO,IAAIU,MAAM,CAACC,OAAX,YACNE,IAAI,CAAClD,CADC,6CACIkD,IAAI,CAACtC,IADT,aAENsC,IAAI,CAACjD,CAFC,6CAEIiD,IAAI,CAAC3C,GAFT,iBAGN2C,IAAI,CAACD,KAHC,qDAGQC,IAAI,CAACxC,KAAL,GAAawC,IAAI,CAACtC,IAH1B,kBAINsC,IAAI,CAACC,MAJC,uDAISD,IAAI,CAACvC,MAAL,GAAcuC,IAAI,CAAC3C,GAJ5B,CAAP;AAMA;;AATiB,KAAnB;AAWA,GAbM,MAaA,IAAK8B,wBAAL,EAAgC;AACtC;AACA;AACAO,IAAAA,gBAAgB,GAAGP,wBAAwB,CAACe,aAA5C;AACA,GA3D2B,CA6D5B;;;AACA,8BAAOR,gBAAP,iEAA2B,IAA3B;AACA,CA1EM","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { MotionProps } from 'framer-motion';\nimport type { ReferenceType } from '@floating-ui/react-dom';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tPopoverProps,\n\tPopoverAnchorRefReference,\n\tPopoverAnchorRefTopBottom,\n} from './types';\n\n/**\n * Converts the `Popover`'s legacy \"position\" prop to the new \"placement\" prop\n * (used by `floating-ui`).\n *\n * @param position The legacy position\n * @return The corresponding placement\n */\nexport const positionToPlacement = (\n\tposition: NonNullable< PopoverProps[ 'position' ] >\n): NonNullable< PopoverProps[ 'placement' ] > => {\n\tconst [ x, y, z ] = position.split( ' ' );\n\n\tif ( [ 'top', 'bottom' ].includes( x ) ) {\n\t\tlet suffix = '';\n\t\tif ( ( !! z && z === 'left' ) || y === 'right' ) {\n\t\t\tsuffix = '-start';\n\t\t} else if ( ( !! z && z === 'right' ) || y === 'left' ) {\n\t\t\tsuffix = '-end';\n\t\t}\n\n\t\treturn ( x + suffix ) as NonNullable< PopoverProps[ 'placement' ] >;\n\t}\n\n\treturn y as NonNullable< PopoverProps[ 'placement' ] >;\n};\n\n/**\n * @typedef AnimationOrigin\n * @type {Object}\n * @property {number} originX A number between 0 and 1 (in CSS logical properties jargon, 0 is \"start\", 0.5 is \"center\", and 1 is \"end\")\n * @property {number} originY A number between 0 and 1 (0 is top, 0.5 is center, and 1 is bottom)\n */\n\nconst PLACEMENT_TO_ANIMATION_ORIGIN: Record<\n\tNonNullable< PopoverProps[ 'placement' ] >,\n\t{ originX: number; originY: number }\n> = {\n\ttop: { originX: 0.5, originY: 1 }, // open from bottom, center\n\t'top-start': { originX: 0, originY: 1 }, // open from bottom, left\n\t'top-end': { originX: 1, originY: 1 }, // open from bottom, right\n\tright: { originX: 0, originY: 0.5 }, // open from middle, left\n\t'right-start': { originX: 0, originY: 0 }, // open from top, left\n\t'right-end': { originX: 0, originY: 1 }, // open from bottom, left\n\tbottom: { originX: 0.5, originY: 0 }, // open from top, center\n\t'bottom-start': { originX: 0, originY: 0 }, // open from top, left\n\t'bottom-end': { originX: 1, originY: 0 }, // open from top, right\n\tleft: { originX: 1, originY: 0.5 }, // open from middle, right\n\t'left-start': { originX: 1, originY: 0 }, // open from top, right\n\t'left-end': { originX: 1, originY: 1 }, // open from bottom, right\n};\n\n/**\n * Given the floating-ui `placement`, compute the framer-motion props for the\n * popover's entry animation.\n *\n * @param placement A placement string from floating ui\n * @return The object containing the motion props\n */\nexport const placementToMotionAnimationProps = (\n\tplacement: NonNullable< PopoverProps[ 'placement' ] >\n): MotionProps => {\n\tconst translateProp =\n\t\tplacement.startsWith( 'top' ) || placement.startsWith( 'bottom' )\n\t\t\t? 'translateY'\n\t\t\t: 'translateX';\n\tconst translateDirection =\n\t\tplacement.startsWith( 'top' ) || placement.startsWith( 'left' )\n\t\t\t? 1\n\t\t\t: -1;\n\n\treturn {\n\t\tstyle: PLACEMENT_TO_ANIMATION_ORIGIN[ placement ],\n\t\tinitial: {\n\t\t\topacity: 0,\n\t\t\tscale: 0,\n\t\t\t[ translateProp ]: `${ 2 * translateDirection }em`,\n\t\t},\n\t\tanimate: { opacity: 1, scale: 1, [ translateProp ]: 0 },\n\t\ttransition: { duration: 0.1, ease: [ 0, 0, 0.2, 1 ] },\n\t};\n};\n\n/**\n * Returns the offset of a document's frame element.\n *\n * @param document The iframe's owner document.\n *\n * @return The offset of the document's frame element, or undefined if the\n * document has no frame element.\n */\nexport const getFrameOffset = (\n\tdocument?: Document\n): { x: number; y: number } | undefined => {\n\tconst frameElement = document?.defaultView?.frameElement;\n\tif ( ! frameElement ) {\n\t\treturn;\n\t}\n\tconst iframeRect = frameElement.getBoundingClientRect();\n\treturn { x: iframeRect.left, y: iframeRect.top };\n};\n\nexport const getReferenceOwnerDocument = ( {\n\tanchor,\n\tanchorRef,\n\tanchorRect,\n\tgetAnchorRect,\n\tfallbackReferenceElement,\n\tfallbackDocument,\n}: Pick<\n\tPopoverProps,\n\t'anchorRef' | 'anchorRect' | 'getAnchorRect' | 'anchor'\n> & {\n\tfallbackReferenceElement: Element | null;\n\tfallbackDocument: Document;\n} ): Document => {\n\t// In floating-ui's terms:\n\t// - \"reference\" refers to the popover's anchor element.\n\t// - \"floating\" refers the floating popover's element.\n\t// A floating element can also be positioned relative to a virtual element,\n\t// instead of a real one. A virtual element is represented by an object\n\t// with the `getBoundingClientRect()` function (like real elements).\n\t// See https://floating-ui.com/docs/virtual-elements for more info.\n\tlet resultingReferenceOwnerDoc;\n\tif ( anchor ) {\n\t\tresultingReferenceOwnerDoc = anchor.ownerDocument;\n\t} else if ( ( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top ) {\n\t\tresultingReferenceOwnerDoc = ( anchorRef as PopoverAnchorRefTopBottom )\n\t\t\t?.top.ownerDocument;\n\t} else if ( ( anchorRef as Range | undefined )?.startContainer ) {\n\t\tresultingReferenceOwnerDoc = ( anchorRef as Range ).startContainer\n\t\t\t.ownerDocument;\n\t} else if (\n\t\t( anchorRef as PopoverAnchorRefReference | undefined )?.current\n\t) {\n\t\tresultingReferenceOwnerDoc = (\n\t\t\t( anchorRef as PopoverAnchorRefReference ).current as Element\n\t\t ).ownerDocument;\n\t} else if ( anchorRef as Element | undefined ) {\n\t\t// This one should be deprecated.\n\t\tresultingReferenceOwnerDoc = ( anchorRef as Element ).ownerDocument;\n\t} else if ( anchorRect && anchorRect?.ownerDocument ) {\n\t\tresultingReferenceOwnerDoc = anchorRect.ownerDocument;\n\t} else if ( getAnchorRect ) {\n\t\tresultingReferenceOwnerDoc = getAnchorRect(\n\t\t\tfallbackReferenceElement\n\t\t)?.ownerDocument;\n\t}\n\n\treturn resultingReferenceOwnerDoc ?? fallbackDocument;\n};\n\nexport const getReferenceElement = ( {\n\tanchor,\n\tanchorRef,\n\tanchorRect,\n\tgetAnchorRect,\n\tfallbackReferenceElement,\n}: Pick<\n\tPopoverProps,\n\t'anchorRef' | 'anchorRect' | 'getAnchorRect' | 'anchor'\n> & {\n\tfallbackReferenceElement: Element | null;\n} ): ReferenceType | null => {\n\tlet referenceElement = null;\n\n\tif ( anchor ) {\n\t\treferenceElement = anchor;\n\t} else if ( ( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top ) {\n\t\t// Create a virtual element for the ref. The expectation is that\n\t\t// if anchorRef.top is defined, then anchorRef.bottom is defined too.\n\t\t// Seems to be used by the block toolbar, when multiple blocks are selected\n\t\t// (top and bottom blocks are used to calculate the resulting rect).\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst topRect = (\n\t\t\t\t\tanchorRef as PopoverAnchorRefTopBottom\n\t\t\t\t ).top.getBoundingClientRect();\n\t\t\t\tconst bottomRect = (\n\t\t\t\t\tanchorRef as PopoverAnchorRefTopBottom\n\t\t\t\t ).bottom.getBoundingClientRect();\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\ttopRect.x,\n\t\t\t\t\ttopRect.y,\n\t\t\t\t\ttopRect.width,\n\t\t\t\t\tbottomRect.bottom - topRect.top\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t} else if (\n\t\t( anchorRef as PopoverAnchorRefReference | undefined )?.current\n\t) {\n\t\t// Standard React ref.\n\t\treferenceElement = ( anchorRef as PopoverAnchorRefReference ).current;\n\t} else if ( anchorRef as Element | undefined ) {\n\t\t// If `anchorRef` holds directly the element's value (no `current` key)\n\t\t// This is a weird scenario and should be deprecated.\n\t\treferenceElement = anchorRef as Element;\n\t} else if ( anchorRect ) {\n\t\t// Create a virtual element for the ref.\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn anchorRect;\n\t\t\t},\n\t\t};\n\t} else if ( getAnchorRect ) {\n\t\t// Create a virtual element for the ref.\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = getAnchorRect( fallbackReferenceElement );\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\trect.x ?? rect.left,\n\t\t\t\t\trect.y ?? rect.top,\n\t\t\t\t\trect.width ?? rect.right - rect.left,\n\t\t\t\t\trect.height ?? rect.bottom - rect.top\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t} else if ( fallbackReferenceElement ) {\n\t\t// If no explicit ref is passed via props, fall back to\n\t\t// anchoring to the popover's parent node.\n\t\treferenceElement = fallbackReferenceElement.parentElement;\n\t}\n\n\t// Convert any `undefined` value to `null`.\n\treturn referenceElement ?? null;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/popover/utils.ts"],"names":["POSITION_TO_PLACEMENT","bottom","top","middle","positionToPlacement","position","PLACEMENT_TO_ANIMATION_ORIGIN","originX","originY","right","left","placementToMotionAnimationProps","placement","translateProp","startsWith","translateDirection","style","initial","opacity","scale","animate","transition","duration","ease","getFrameOffset","document","frameElement","defaultView","iframeRect","getBoundingClientRect","x","y","getReferenceOwnerDocument","anchor","anchorRef","anchorRect","getAnchorRect","fallbackReferenceElement","fallbackDocument","resultingReferenceOwnerDoc","ownerDocument","startContainer","current","getReferenceElement","referenceElement","topRect","bottomRect","window","DOMRect","width","rect","height","parentElement"],"mappings":"AAAA;AACA;AACA;AACA;;AAIA;AACA;AACA;AAOA,MAAMA,qBAGL,GAAG;AACHC,EAAAA,MAAM,EAAE,QADL;AAEHC,EAAAA,GAAG,EAAE,KAFF;AAGH,iBAAe,MAHZ;AAIH,kBAAgB,OAJb;AAKH,iBAAe,YALZ;AAMH,mBAAiB,QANd;AAOH,kBAAgB,cAPb;AAQH,cAAY,SART;AASH,gBAAc,KATX;AAUH,eAAa,WAVV;AAWH,sBAAoB,MAXjB;AAYH,uBAAqB,MAZlB;AAaH,wBAAsB,UAbnB;AAcH,qBAAmB,YAdhB;AAeH,uBAAqB,OAflB;AAgBH,wBAAsB,OAhBnB;AAiBH,yBAAuB,WAjBpB;AAkBH,sBAAoB,aAlBjB;AAmBH,sBAAoB,YAnBjB;AAoBH,uBAAqB,YApBlB;AAqBH,wBAAsB,YArBnB;AAsBH,qBAAmB,YAtBhB;AAuBH,wBAAsB,QAvBnB;AAwBH,yBAAuB,QAxBpB;AAyBH,0BAAwB,QAzBrB;AA0BH,uBAAqB,QA1BlB;AA2BH,uBAAqB,cA3BlB;AA4BH,wBAAsB,cA5BnB;AA6BH,yBAAuB,cA7BpB;AA8BH,sBAAoB,cA9BjB;AA+BH,mBAAiB,SA/Bd;AAgCH,oBAAkB,SAhCf;AAiCH,qBAAmB,SAjChB;AAkCH,kBAAgB,SAlCb;AAmCH,qBAAmB,KAnChB;AAoCH,sBAAoB,KApCjB;AAqCH,uBAAqB,K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AMA;;AAdiB,KAAnB;AAgBA,GArBM,MAqBA,IACJgC,SADI,aACJA,SADI,eACJA,SAAF,CAAwDQ,OADlD,EAEL;AACD;AACAE,IAAAA,gBAAgB,GAAKV,SAAF,CAA2CQ,OAA9D;AACA,GALM,MAKA,IAAKR,SAAL,EAAwC;AAC9C;AACA;AACAU,IAAAA,gBAAgB,GAAGV,SAAnB;AACA,GAJM,MAIA,IAAKC,UAAL,EAAkB;AACxB;AACAS,IAAAA,gBAAgB,GAAG;AAClBf,MAAAA,qBAAqB,GAAG;AACvB,eAAOM,UAAP;AACA;;AAHiB,KAAnB;AAKA,GAPM,MAOA,IAAKC,aAAL,EAAqB;AAC3B;AACAQ,IAAAA,gBAAgB,GAAG;AAClBf,MAAAA,qBAAqB,GAAG;AAAA;;AACvB,cAAMqB,IAAI,GAAGd,aAAa,CAAEC,wBAAF,CAA1B;AACA,eAAO,IAAIU,MAAM,CAACC,OAAX,YACNE,IAAI,CAACpB,CADC,6CACIoB,IAAI,CAACxC,IADT,aAENwC,IAAI,CAACnB,CAFC,6CAEImB,IAAI,CAAChD,GAFT,iBAGNgD,IAAI,CAACD,KAHC,qDAGQC,IAAI,CAACzC,KAAL,GAAayC,IAAI,CAACxC,IAH1B,kBAINwC,IAAI,CAACC,MAJC,uDAISD,IAAI,CAACjD,MAAL,GAAciD,IAAI,CAAChD,GAJ5B,CAAP;AAMA;;AATiB,KAAnB;AAWA,GAbM,MAaA,IAAKmC,wBAAL,EAAgC;AACtC;AACA;AACAO,IAAAA,gBAAgB,GAAGP,wBAAwB,CAACe,aAA5C;AACA,GA3D2B,CA6D5B;;;AACA,8BAAOR,gBAAP,iEAA2B,IAA3B;AACA,CA1EM","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { MotionProps } from 'framer-motion';\nimport type { ReferenceType } from '@floating-ui/react-dom';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tPopoverProps,\n\tPopoverAnchorRefReference,\n\tPopoverAnchorRefTopBottom,\n} from './types';\n\nconst POSITION_TO_PLACEMENT: Record<\n\tNonNullable< PopoverProps[ 'position' ] >,\n\tNonNullable< PopoverProps[ 'placement' ] >\n> = {\n\tbottom: 'bottom',\n\ttop: 'top',\n\t'middle left': 'left',\n\t'middle right': 'right',\n\t'bottom left': 'bottom-end',\n\t'bottom center': 'bottom',\n\t'bottom right': 'bottom-start',\n\t'top left': 'top-end',\n\t'top center': 'top',\n\t'top right': 'top-start',\n\t'middle left left': 'left',\n\t'middle left right': 'left',\n\t'middle left bottom': 'left-end',\n\t'middle left top': 'left-start',\n\t'middle right left': 'right',\n\t'middle right right': 'right',\n\t'middle right bottom': 'right-end',\n\t'middle right top': 'right-start',\n\t'bottom left left': 'bottom-end',\n\t'bottom left right': 'bottom-end',\n\t'bottom left bottom': 'bottom-end',\n\t'bottom left top': 'bottom-end',\n\t'bottom center left': 'bottom',\n\t'bottom center right': 'bottom',\n\t'bottom center bottom': 'bottom',\n\t'bottom center top': 'bottom',\n\t'bottom right left': 'bottom-start',\n\t'bottom right right': 'bottom-start',\n\t'bottom right bottom': 'bottom-start',\n\t'bottom right top': 'bottom-start',\n\t'top left left': 'top-end',\n\t'top left right': 'top-end',\n\t'top left bottom': 'top-end',\n\t'top left top': 'top-end',\n\t'top center left': 'top',\n\t'top center right': 'top',\n\t'top center bottom': 'top',\n\t'top center top': 'top',\n\t'top right left': 'top-start',\n\t'top right right': 'top-start',\n\t'top right bottom': 'top-start',\n\t'top right top': 'top-start',\n\t// `middle`/`middle center [corner?]` positions are associated to a fallback\n\t// `bottom` placement because there aren't any corresponding placement values.\n\tmiddle: 'bottom',\n\t'middle center': 'bottom',\n\t'middle center bottom': 'bottom',\n\t'middle center left': 'bottom',\n\t'middle center right': 'bottom',\n\t'middle center top': 'bottom',\n};\n\n/**\n * Converts the `Popover`'s legacy \"position\" prop to the new \"placement\" prop\n * (used by `floating-ui`).\n *\n * @param position The legacy position\n * @return The corresponding placement\n */\nexport const positionToPlacement = (\n\tposition: NonNullable< PopoverProps[ 'position' ] >\n): NonNullable< PopoverProps[ 'placement' ] > =>\n\tPOSITION_TO_PLACEMENT[ position ] ?? 'bottom';\n\n/**\n * @typedef AnimationOrigin\n * @type {Object}\n * @property {number} originX A number between 0 and 1 (in CSS logical properties jargon, 0 is \"start\", 0.5 is \"center\", and 1 is \"end\")\n * @property {number} originY A number between 0 and 1 (0 is top, 0.5 is center, and 1 is bottom)\n */\n\nconst PLACEMENT_TO_ANIMATION_ORIGIN: Record<\n\tNonNullable< PopoverProps[ 'placement' ] >,\n\t{ originX: number; originY: number }\n> = {\n\ttop: { originX: 0.5, originY: 1 }, // open from bottom, center\n\t'top-start': { originX: 0, originY: 1 }, // open from bottom, left\n\t'top-end': { originX: 1, originY: 1 }, // open from bottom, right\n\tright: { originX: 0, originY: 0.5 }, // open from middle, left\n\t'right-start': { originX: 0, originY: 0 }, // open from top, left\n\t'right-end': { originX: 0, originY: 1 }, // open from bottom, left\n\tbottom: { originX: 0.5, originY: 0 }, // open from top, center\n\t'bottom-start': { originX: 0, originY: 0 }, // open from top, left\n\t'bottom-end': { originX: 1, originY: 0 }, // open from top, right\n\tleft: { originX: 1, originY: 0.5 }, // open from middle, right\n\t'left-start': { originX: 1, originY: 0 }, // open from top, right\n\t'left-end': { originX: 1, originY: 1 }, // open from bottom, right\n};\n\n/**\n * Given the floating-ui `placement`, compute the framer-motion props for the\n * popover's entry animation.\n *\n * @param placement A placement string from floating ui\n * @return The object containing the motion props\n */\nexport const placementToMotionAnimationProps = (\n\tplacement: NonNullable< PopoverProps[ 'placement' ] >\n): MotionProps => {\n\tconst translateProp =\n\t\tplacement.startsWith( 'top' ) || placement.startsWith( 'bottom' )\n\t\t\t? 'translateY'\n\t\t\t: 'translateX';\n\tconst translateDirection =\n\t\tplacement.startsWith( 'top' ) || placement.startsWith( 'left' )\n\t\t\t? 1\n\t\t\t: -1;\n\n\treturn {\n\t\tstyle: PLACEMENT_TO_ANIMATION_ORIGIN[ placement ],\n\t\tinitial: {\n\t\t\topacity: 0,\n\t\t\tscale: 0,\n\t\t\t[ translateProp ]: `${ 2 * translateDirection }em`,\n\t\t},\n\t\tanimate: { opacity: 1, scale: 1, [ translateProp ]: 0 },\n\t\ttransition: { duration: 0.1, ease: [ 0, 0, 0.2, 1 ] },\n\t};\n};\n\n/**\n * Returns the offset of a document's frame element.\n *\n * @param document The iframe's owner document.\n *\n * @return The offset of the document's frame element, or undefined if the\n * document has no frame element.\n */\nexport const getFrameOffset = (\n\tdocument?: Document\n): { x: number; y: number } | undefined => {\n\tconst frameElement = document?.defaultView?.frameElement;\n\tif ( ! frameElement ) {\n\t\treturn;\n\t}\n\tconst iframeRect = frameElement.getBoundingClientRect();\n\treturn { x: iframeRect.left, y: iframeRect.top };\n};\n\nexport const getReferenceOwnerDocument = ( {\n\tanchor,\n\tanchorRef,\n\tanchorRect,\n\tgetAnchorRect,\n\tfallbackReferenceElement,\n\tfallbackDocument,\n}: Pick<\n\tPopoverProps,\n\t'anchorRef' | 'anchorRect' | 'getAnchorRect' | 'anchor'\n> & {\n\tfallbackReferenceElement: Element | null;\n\tfallbackDocument: Document;\n} ): Document => {\n\t// In floating-ui's terms:\n\t// - \"reference\" refers to the popover's anchor element.\n\t// - \"floating\" refers the floating popover's element.\n\t// A floating element can also be positioned relative to a virtual element,\n\t// instead of a real one. A virtual element is represented by an object\n\t// with the `getBoundingClientRect()` function (like real elements).\n\t// See https://floating-ui.com/docs/virtual-elements for more info.\n\tlet resultingReferenceOwnerDoc;\n\tif ( anchor ) {\n\t\tresultingReferenceOwnerDoc = anchor.ownerDocument;\n\t} else if ( ( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top ) {\n\t\tresultingReferenceOwnerDoc = ( anchorRef as PopoverAnchorRefTopBottom )\n\t\t\t?.top.ownerDocument;\n\t} else if ( ( anchorRef as Range | undefined )?.startContainer ) {\n\t\tresultingReferenceOwnerDoc = ( anchorRef as Range ).startContainer\n\t\t\t.ownerDocument;\n\t} else if (\n\t\t( anchorRef as PopoverAnchorRefReference | undefined )?.current\n\t) {\n\t\tresultingReferenceOwnerDoc = (\n\t\t\t( anchorRef as PopoverAnchorRefReference ).current as Element\n\t\t ).ownerDocument;\n\t} else if ( anchorRef as Element | undefined ) {\n\t\t// This one should be deprecated.\n\t\tresultingReferenceOwnerDoc = ( anchorRef as Element ).ownerDocument;\n\t} else if ( anchorRect && anchorRect?.ownerDocument ) {\n\t\tresultingReferenceOwnerDoc = anchorRect.ownerDocument;\n\t} else if ( getAnchorRect ) {\n\t\tresultingReferenceOwnerDoc = getAnchorRect(\n\t\t\tfallbackReferenceElement\n\t\t)?.ownerDocument;\n\t}\n\n\treturn resultingReferenceOwnerDoc ?? fallbackDocument;\n};\n\nexport const getReferenceElement = ( {\n\tanchor,\n\tanchorRef,\n\tanchorRect,\n\tgetAnchorRect,\n\tfallbackReferenceElement,\n}: Pick<\n\tPopoverProps,\n\t'anchorRef' | 'anchorRect' | 'getAnchorRect' | 'anchor'\n> & {\n\tfallbackReferenceElement: Element | null;\n} ): ReferenceType | null => {\n\tlet referenceElement = null;\n\n\tif ( anchor ) {\n\t\treferenceElement = anchor;\n\t} else if ( ( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top ) {\n\t\t// Create a virtual element for the ref. The expectation is that\n\t\t// if anchorRef.top is defined, then anchorRef.bottom is defined too.\n\t\t// Seems to be used by the block toolbar, when multiple blocks are selected\n\t\t// (top and bottom blocks are used to calculate the resulting rect).\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst topRect = (\n\t\t\t\t\tanchorRef as PopoverAnchorRefTopBottom\n\t\t\t\t ).top.getBoundingClientRect();\n\t\t\t\tconst bottomRect = (\n\t\t\t\t\tanchorRef as PopoverAnchorRefTopBottom\n\t\t\t\t ).bottom.getBoundingClientRect();\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\ttopRect.x,\n\t\t\t\t\ttopRect.y,\n\t\t\t\t\ttopRect.width,\n\t\t\t\t\tbottomRect.bottom - topRect.top\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t} else if (\n\t\t( anchorRef as PopoverAnchorRefReference | undefined )?.current\n\t) {\n\t\t// Standard React ref.\n\t\treferenceElement = ( anchorRef as PopoverAnchorRefReference ).current;\n\t} else if ( anchorRef as Element | undefined ) {\n\t\t// If `anchorRef` holds directly the element's value (no `current` key)\n\t\t// This is a weird scenario and should be deprecated.\n\t\treferenceElement = anchorRef as Element;\n\t} else if ( anchorRect ) {\n\t\t// Create a virtual element for the ref.\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn anchorRect;\n\t\t\t},\n\t\t};\n\t} else if ( getAnchorRect ) {\n\t\t// Create a virtual element for the ref.\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = getAnchorRect( fallbackReferenceElement );\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\trect.x ?? rect.left,\n\t\t\t\t\trect.y ?? rect.top,\n\t\t\t\t\trect.width ?? rect.right - rect.left,\n\t\t\t\t\trect.height ?? rect.bottom - rect.top\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t} else if ( fallbackReferenceElement ) {\n\t\t// If no explicit ref is passed via props, fall back to\n\t\t// anchoring to the popover's parent node.\n\t\treferenceElement = fallbackReferenceElement.parentElement;\n\t}\n\n\t// Convert any `undefined` value to `null`.\n\treturn referenceElement ?? null;\n};\n"]}
|
|
@@ -10,28 +10,15 @@ import { forwardRef } from '@wordpress/element';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { InputRange as BaseInputRange } from './styles/range-control-styles';
|
|
13
|
-
import { useDebouncedHoverInteraction } from './utils';
|
|
14
|
-
|
|
15
|
-
const noop = () => {};
|
|
16
13
|
|
|
17
14
|
function InputRange(props, ref) {
|
|
18
15
|
const {
|
|
19
16
|
describedBy,
|
|
20
17
|
label,
|
|
21
|
-
onHideTooltip = noop,
|
|
22
|
-
onMouseLeave = noop,
|
|
23
|
-
onMouseMove = noop,
|
|
24
|
-
onShowTooltip = noop,
|
|
25
18
|
value,
|
|
26
19
|
...otherProps
|
|
27
20
|
} = props;
|
|
28
|
-
|
|
29
|
-
onHide: onHideTooltip,
|
|
30
|
-
onMouseLeave,
|
|
31
|
-
onMouseMove,
|
|
32
|
-
onShow: onShowTooltip
|
|
33
|
-
});
|
|
34
|
-
return createElement(BaseInputRange, _extends({}, otherProps, hoverInteractions, {
|
|
21
|
+
return createElement(BaseInputRange, _extends({}, otherProps, {
|
|
35
22
|
"aria-describedby": describedBy,
|
|
36
23
|
"aria-label": label,
|
|
37
24
|
"aria-hidden": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/range-control/input-range.tsx"],"names":["forwardRef","InputRange","BaseInputRange","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/range-control/input-range.tsx"],"names":["forwardRef","InputRange","BaseInputRange","props","ref","describedBy","label","value","otherProps","ForwardedComponent"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,SAASC,UAAU,IAAIC,cAAvB,QAA6C,+BAA7C;;AAKA,SAASD,UAAT,CACCE,KADD,EAECC,GAFD,EAGE;AACD,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,KAAf;AAAsBC,IAAAA,KAAtB;AAA6B,OAAGC;AAAhC,MAA+CL,KAArD;AAEA,SACC,cAAC,cAAD,eACMK,UADN;AAEC,wBAAmBH,WAFpB;AAGC,kBAAaC,KAHd;AAIC,mBAAc,KAJf;AAKC,IAAA,GAAG,EAAGF,GALP;AAMC,IAAA,QAAQ,EAAG,CANZ;AAOC,IAAA,IAAI,EAAC,OAPN;AAQC,IAAA,KAAK,EAAGG;AART,KADD;AAYA;;AAED,MAAME,kBAAkB,GAAGT,UAAU,CAAEC,UAAF,CAArC;AAEA,eAAeQ,kBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InputRange as BaseInputRange } from './styles/range-control-styles';\n\nimport type { InputRangeProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nfunction InputRange(\n\tprops: WordPressComponentProps< InputRangeProps, 'input' >,\n\tref: React.ForwardedRef< HTMLInputElement >\n) {\n\tconst { describedBy, label, value, ...otherProps } = props;\n\n\treturn (\n\t\t<BaseInputRange\n\t\t\t{ ...otherProps }\n\t\t\taria-describedby={ describedBy }\n\t\t\taria-label={ label }\n\t\t\taria-hidden={ false }\n\t\t\tref={ ref }\n\t\t\ttabIndex={ 0 }\n\t\t\ttype=\"range\"\n\t\t\tvalue={ value }\n\t\t/>\n\t);\n}\n\nconst ForwardedComponent = forwardRef( InputRange );\n\nexport default ForwardedComponent;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/range-control/tooltip.tsx"],"names":["classnames","useCallback","useEffect","useState","Tooltip","SimpleTooltip","props","className","inputRef","tooltipPosition","show","style","value","renderTooltipContent","v","zIndex","restProps","position","useTooltipPosition","classes","styles","setPosition","setTooltipPosition","current","window","addEventListener","removeEventListener"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,QAAjC,QAAiD,oBAAjD;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,+BAAxB;AAKA,eAAe,SAASC,aAAT,CACdC,KADc,EAEb;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,IAAI,GAAG,KAJF;AAKLC,IAAAA,KAAK,GAAG,EALH;AAMLC,IAAAA,KAAK,GAAG,CANH;AAOLC,IAAAA,oBAAoB,GAAKC,CAAF,IAASA,CAP3B;AAQLC,IAAAA,MAAM,GAAG,GARJ;AASL,OAAGC;AATE,MAUFV,KAVJ;AAWA,QAAMW,QAAQ,GAAGC,kBAAkB,CAAE;AAAEV,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAF,CAAnC;AACA,QAAMU,OAAO,GAAGnB,UAAU,CAAE,2BAAF,EAA+BO,SAA/B,CAA1B;AACA,QAAMa,MAAM,GAAG,EACd,GAAGT,KADW;AAEdI,IAAAA;AAFc,GAAf;AAKA,SACC,cAAC,OAAD,eACMC,SADN;AAEC,mBAAcN,IAFf;AAGC,IAAA,SAAS,EAAGS,OAHb;AAIC,IAAA,QAAQ,EAAGF,QAJZ;AAKC,IAAA,IAAI,EAAGP,IALR;AAMC,IAAA,IAAI,EAAC,SANN;AAOC,IAAA,KAAK,EAAGU;AAPT,MASGP,oBAAoB,CAAED,KAAF,CATvB,CADD;AAaA;;AAED,SAASM,kBAAT,OAA2E;AAAA,MAA9C;AAAEV,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA8C;AAC1E,QAAM,CAAEQ,QAAF,EAAYI,WAAZ,IAA4BlB,QAAQ,EAA1C;AAEA,QAAMmB,kBAAkB,GAAGrB,WAAW,CAAE,MAAM;AAC7C,QAAKO,QAAQ,IAAIA,QAAQ,CAACe,OAA1B,EAAoC;AACnCF,MAAAA,WAAW,CAAEZ,eAAF,CAAX;AACA;AACD,GAJqC,EAInC,CAAEA,eAAF,CAJmC,CAAtC;
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/range-control/tooltip.tsx"],"names":["classnames","useCallback","useEffect","useState","Tooltip","SimpleTooltip","props","className","inputRef","tooltipPosition","show","style","value","renderTooltipContent","v","zIndex","restProps","position","useTooltipPosition","classes","styles","setPosition","setTooltipPosition","current","window","addEventListener","removeEventListener"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,QAAjC,QAAiD,oBAAjD;AAEA;AACA;A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E,MAAM;AAChBoB,IAAAA,kBAAkB;AAClB,GAFQ,EAEN,CAAEA,kBAAF,CAFM,CAAT;AAIApB,EAAAA,SAAS,CAAE,MAAM;AAChBsB,IAAAA,MAAM,CAACC,gBAAP,CAAyB,QAAzB,EAAmCH,kBAAnC;AAEA,WAAO,MAAM;AACZE,MAAAA,MAAM,CAACE,mBAAP,CAA4B,QAA5B,EAAsCJ,kBAAtC;AACA,KAFD;AAGA,GANQ,CAAT;AAQA,SAAOL,QAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Tooltip } from './styles/range-control-styles';\n\nimport type { TooltipProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nexport default function SimpleTooltip(\n\tprops: WordPressComponentProps< TooltipProps, 'span' >\n) {\n\tconst {\n\t\tclassName,\n\t\tinputRef,\n\t\ttooltipPosition,\n\t\tshow = false,\n\t\tstyle = {},\n\t\tvalue = 0,\n\t\trenderTooltipContent = ( v ) => v,\n\t\tzIndex = 100,\n\t\t...restProps\n\t} = props;\n\tconst position = useTooltipPosition( { inputRef, tooltipPosition } );\n\tconst classes = classnames( 'components-simple-tooltip', className );\n\tconst styles = {\n\t\t...style,\n\t\tzIndex,\n\t};\n\n\treturn (\n\t\t<Tooltip\n\t\t\t{ ...restProps }\n\t\t\taria-hidden={ show }\n\t\t\tclassName={ classes }\n\t\t\tposition={ position }\n\t\t\tshow={ show }\n\t\t\trole=\"tooltip\"\n\t\t\tstyle={ styles }\n\t\t>\n\t\t\t{ renderTooltipContent( value ) }\n\t\t</Tooltip>\n\t);\n}\n\nfunction useTooltipPosition( { inputRef, tooltipPosition }: TooltipProps ) {\n\tconst [ position, setPosition ] = useState< string >();\n\n\tconst setTooltipPosition = useCallback( () => {\n\t\tif ( inputRef && inputRef.current ) {\n\t\t\tsetPosition( tooltipPosition );\n\t\t}\n\t}, [ tooltipPosition, inputRef ] );\n\n\tuseEffect( () => {\n\t\tsetTooltipPosition();\n\t}, [ setTooltipPosition ] );\n\n\tuseEffect( () => {\n\t\twindow.addEventListener( 'resize', setTooltipPosition );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'resize', setTooltipPosition );\n\t\t};\n\t} );\n\n\treturn position;\n}\n"]}
|