{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type * as React from 'react';\n\n/**\n * Physical placement of a positioned element relative to its target, as computed by Floating UI.\n * This is a Fluent-owned equivalent of Floating UI's `Placement` type, avoiding a transitive\n * dependency on `@floating-ui/dom` in the public API surface.\n */\nexport type PositioningPlacement =\n  | 'top'\n  | 'top-start'\n  | 'top-end'\n  | 'right'\n  | 'right-start'\n  | 'right-end'\n  | 'bottom'\n  | 'bottom-start'\n  | 'bottom-end'\n  | 'left'\n  | 'left-start'\n  | 'left-end';\n\n/**\n * Detail payload of the positioning end event, providing the final computed placement\n * after all middleware (flip, shift, etc.) have run.\n */\nexport type OnPositioningEndEventDetail = {\n  /**\n   * The computed placement of the positioned element. May differ from the requested\n   * placement if flip or other middleware adjusted it.\n   */\n  placement: PositioningPlacement;\n\n  /**\n   * True when the floating element has escaped its clipping boundary,\n   * as reported by Floating UI's hide middleware.\n   */\n  escaped: boolean;\n\n  /**\n   * True when the reference element is clipped or out of view,\n   * as reported by Floating UI's hide middleware.\n   */\n  referenceHidden: boolean;\n};\n\n/**\n * Custom DOM event dispatched on the positioned container element when a\n * positioning update completes. Carries placement information in `event.detail`.\n */\nexport type OnPositioningEndEvent = CustomEvent<OnPositioningEndEventDetail>;\n\nexport type PositioningRect = {\n  width: number;\n  height: number;\n  x: number;\n  y: number;\n};\n\nexport type OffsetFunctionParam = {\n  positionedRect: PositioningRect;\n  targetRect: PositioningRect;\n  position: Position;\n  alignment?: Alignment;\n};\n\nexport type TargetElement = HTMLElement | PositioningVirtualElement;\n\n/**\n * @internal\n */\nexport interface PositionManager {\n  updatePosition: () => void;\n  dispose: () => void;\n}\n\nexport interface UsePositioningReturn {\n  // React refs are supposed to be contravariant\n  // (allows a more general type to be passed rather than a more specific one)\n  // However, Typescript currently can't infer that fact for refs\n  // See https://github.com/microsoft/TypeScript/issues/30748 for more information\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-deprecated\n  targetRef: React.MutableRefObject<any>;\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-deprecated\n  containerRef: React.MutableRefObject<any>;\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-deprecated\n  arrowRef: React.MutableRefObject<any>;\n}\n\nexport type OffsetObject = { crossAxis?: number; mainAxis: number };\n\nexport type OffsetShorthand = number;\n\nexport type OffsetFunction = (param: OffsetFunctionParam) => OffsetObject | OffsetShorthand;\n\nexport type Offset = OffsetFunction | OffsetObject | OffsetShorthand;\n\nexport type Position = 'above' | 'below' | 'before' | 'after';\nexport type Alignment = 'top' | 'bottom' | 'start' | 'end' | 'center';\n\nexport type AutoSize = 'height' | 'height-always' | 'width' | 'width-always' | 'always' | boolean;\nexport type NormalizedAutoSize = { applyMaxWidth: boolean; applyMaxHeight: boolean };\n\nexport type PositioningBoundary =\n  | PositioningRect\n  | HTMLElement\n  | Array<HTMLElement>\n  | 'clippingParents'\n  | 'scrollParent'\n  | 'window';\n/**\n * @deprecated use PositioningBoundary instead\n */\nexport type Boundary = PositioningBoundary;\n\nexport type PositioningImperativeRef = {\n  /**\n   * Updates the position imperatively.\n   * Useful when the position of the target changes from other factors than scrolling of window resize.\n   */\n  updatePosition: () => void;\n\n  /**\n   * Sets the target and updates positioning imperatively.\n   * Useful for avoiding double renders with the target option.\n   */\n  setTarget: (target: TargetElement | null) => void;\n};\n\nexport type PositioningVirtualElement = {\n  getBoundingClientRect: () => {\n    x: number;\n    y: number;\n    top: number;\n    left: number;\n    bottom: number;\n    right: number;\n    width: number;\n    height: number;\n  };\n  contextElement?: Element;\n};\n\nexport type SetVirtualMouseTarget = (event: React.MouseEvent | MouseEvent | undefined | null) => void;\n\n/**\n * Internal options for positioning\n */\nexport interface PositioningOptions {\n  /** Alignment for the component. Only has an effect if used with the @see position option */\n  align?: Alignment;\n\n  /** The element which will define the boundaries of the positioned element for the flip behavior. */\n  flipBoundary?: PositioningBoundary | null;\n\n  /** The element which will define the boundaries of the positioned element for the overflow behavior. */\n  overflowBoundary?: PositioningBoundary | null;\n\n  /**\n   * Applies a padding to the overflow bounadry, so that overflow is detected earlier before the\n   * positioned surface hits the overflow boundary.\n   */\n  overflowBoundaryPadding?: number | Partial<{ top: number; end: number; bottom: number; start: number }>;\n\n  /**\n   * Position for the component. Position has higher priority than align. If position is vertical ('above' | 'below')\n   * and align is also vertical ('top' | 'bottom') or if both position and align are horizontal ('before' | 'after'\n   * and 'start' | 'end' respectively),\n   * then provided value for 'align' will be ignored and 'center' will be used instead.\n   */\n  position?: Position;\n\n  /**\n   * Enables the position element to be positioned with 'fixed' (default value is position: 'absolute')\n   * @default false\n   * @deprecated use `strategy` instead\n   */\n  positionFixed?: boolean;\n\n  /**\n   * Specifies the type of CSS position property to use.\n   * @default absolute\n   */\n  strategy?: 'absolute' | 'fixed';\n\n  /**\n   * Lets you displace a positioned element from its reference element.\n   * This can be useful if you need to apply some margin between them or if you need to fine tune the\n   * position according to some custom logic.\n   */\n  offset?: Offset;\n\n  /**\n   * Defines padding between the corner of the popup element and the arrow.\n   * Use to prevent the arrow from overlapping a rounded corner, for example.\n   */\n  arrowPadding?: number;\n\n  /**\n   * Applies styles on the positioned element to fit it within the available space in viewport.\n   * - true: set styles for max height/width.\n   * - 'height': set styles for max height.\n   * - 'width'': set styles for max width.\n   * Note that options 'always'/'height-always'/'width-always' are now obsolete, and equivalent to true/'height'/'width'.\n   */\n  autoSize?: AutoSize;\n\n  /**\n   * Modifies position and alignment to cover the target\n   */\n  coverTarget?: boolean;\n\n  /**\n   * Disables automatic repositioning of the component; it will always be placed according to the values of `align` and\n   * `position` props, regardless of the size of the component, the reference element or the viewport.\n   */\n  pinned?: boolean;\n\n  /**\n   * When the reference element or the viewport is outside viewport allows a positioned element to be fully in viewport.\n   * \"all\" enables this behavior for all axis.\n   */\n  // eslint-disable-next-line @typescript-eslint/naming-convention\n  unstable_disableTether?: boolean | 'all';\n\n  /**\n   * If flip fails to stop the positioned element from overflowing\n   * its boundaries, use a specified fallback positions.\n   */\n  fallbackPositions?: PositioningShorthandValue[];\n\n  /**\n   * Modifies whether popover is positioned using transform.\n   * @default true\n   */\n  useTransform?: boolean;\n\n  /**\n   * If false, does not position anything\n   */\n  enabled?: boolean;\n\n  /**\n   * When set, the positioned element matches the chosen dimension(s) of the target element\n   */\n  matchTargetSize?: 'width';\n\n  /**\n   * Called when a position update has finished. Multiple position updates can happen in a single render,\n   * since positioning happens outside of the React lifecycle.\n   * The event's `detail.placement` indicates the final computed placement after middleware adjustments.\n   *\n   * It's also possible to listen to the custom DOM event `fui-positioningend`\n   */\n  onPositioningEnd?: (e: OnPositioningEndEvent) => void;\n\n  /**\n   * Disables the resize observer that updates position on target or dimension change\n   */\n  disableUpdateOnResize?: boolean;\n\n  /**\n   * When true, the positioned element will shift to cover the target element when there's not enough space.\n   * @default false\n   */\n  shiftToCoverTarget?: boolean;\n}\n\n/**\n * Public api that allows components using react-positioning to specify positioning options\n */\nexport interface PositioningProps\n  extends Pick<\n    PositioningOptions,\n    | 'align'\n    | 'arrowPadding'\n    | 'autoSize'\n    | 'coverTarget'\n    | 'fallbackPositions'\n    | 'flipBoundary'\n    | 'offset'\n    | 'overflowBoundary'\n    | 'overflowBoundaryPadding'\n    | 'pinned'\n    | 'position'\n    | 'strategy'\n    | 'useTransform'\n    | 'matchTargetSize'\n    | 'onPositioningEnd'\n    | 'disableUpdateOnResize'\n    | 'shiftToCoverTarget'\n  > {\n  /** An imperative handle to Popper methods. */\n  positioningRef?: React.Ref<PositioningImperativeRef>;\n\n  /**\n   * Manual override for the target element. Useful for scenarios where a component accepts user prop to override target\n   */\n  target?: TargetElement | null;\n}\n\nexport type PositioningShorthandValue =\n  | 'above'\n  | 'above-start'\n  | 'above-end'\n  | 'below'\n  | 'below-start'\n  | 'below-end'\n  | 'before'\n  | 'before-top'\n  | 'before-bottom'\n  | 'after'\n  | 'after-top'\n  | 'after-bottom';\n\nexport type PositioningShorthand = PositioningProps | PositioningShorthandValue;\n\n// ---\n\nexport type PositioningConfigurationFnOptions = Omit<\n  PositioningOptions,\n  // Excluded as the function will never be called if disabled\n  | 'enabled'\n  // Callback is not subscribed from options\n  | 'onPositioningEnd'\n  // Is deprecated, no need to bloat the interface\n  | 'positionFixed'\n>;\nexport type PositioningConfigurationFn = (params: {\n  container: HTMLElement;\n  arrow: HTMLElement | null;\n  options: PositioningConfigurationFnOptions;\n}) => PositioningConfigurationFnOptions;\n"],"names":[],"mappings":""}