@tylertech/forge-core 2.4.0-dev.1 → 2.4.0-dev.2

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.
@@ -1,22 +1,12 @@
1
- import { computePosition, flip as flipMiddleware, hide as hideMiddleware, shift as shiftMiddleware, autoPlacement as autoPlacementMiddleware } from '@floating-ui/dom';
1
+ import { computePosition, flip as flipMiddleware, hide as hideMiddleware, shift as shiftMiddleware, offset as offsetMiddleware, autoPlacement as autoPlacementMiddleware } from '@floating-ui/dom';
2
2
  import { getContainingBlock } from '@floating-ui/utils/dom';
3
3
  import { topLayer as topLayerMiddleware } from './top-layer-middleware';
4
- /** Adjusts the x and y axes by a specified offset amount. */
5
- export const positionOffsetMiddleware = ({ x: offsetX, y: offsetY }) => ({
6
- name: 'positionOffset',
7
- fn({ x, y }) {
8
- return {
9
- x: x + offsetX,
10
- y: y + offsetY
11
- };
12
- }
13
- });
14
4
  /**
15
5
  * Calculates an elements position relative to another element.
16
6
  * @param {IPositionElementConfig} config Configuration to provide when positioning the element.
17
7
  * @returns {IElementPositionResult} The result of the positioning logic.
18
8
  */
19
- export async function positionElementAsync({ element, targetElement, placement = 'bottom-start', offset, strategy = 'absolute', apply = true, flip = true, flipOptions = {
9
+ export async function positionElementAsync({ element, targetElement, placement = 'bottom-start', offset = false, offsetOptions, strategy = 'absolute', apply = true, flip = true, flipOptions = {
20
10
  fallbackPlacements: ['top-start', 'top', 'top-end', 'left-start', 'left', 'left-end', 'right-start', 'right', 'right-end'],
21
11
  fallbackStrategy: 'initialPlacement'
22
12
  }, auto = false, autoOptions, shift = true, shiftOptions, hide = false, hideOptions, topLayer = false, transform = true, translateFunction = 'translate3d' }) {
@@ -24,7 +14,7 @@ export async function positionElementAsync({ element, targetElement, placement =
24
14
  const middleware = [];
25
15
  // Order of the following middleware is **important**
26
16
  if (offset) {
27
- middleware.push(positionOffsetMiddleware(offset));
17
+ middleware.push(offsetMiddleware(offsetOptions));
28
18
  }
29
19
  if (shift) {
30
20
  middleware.push(shiftMiddleware(shiftOptions));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tylertech/forge-core",
3
- "version": "2.4.0-dev.1",
3
+ "version": "2.4.0-dev.2",
4
4
  "description": "A library of core web utilities that support Forge Web Component libraries.",
5
5
  "author": "Tyler Technologies, Inc.",
6
6
  "license": "Apache-2.0",
@@ -1,13 +1,11 @@
1
- import { FlipOptions, ShiftOptions, AutoPlacementOptions, HideOptions, Middleware, Placement, Strategy } from '@floating-ui/dom';
1
+ import { FlipOptions, ShiftOptions, AutoPlacementOptions, HideOptions, Placement, Strategy, OffsetOptions } from '@floating-ui/dom';
2
2
  export declare type PositionPlacement = Placement;
3
3
  export declare type PositionStrategy = Strategy;
4
- export interface IElementPosition {
4
+ export interface IElementPositionResult {
5
+ visibility: 'visible' | 'hidden';
5
6
  x: number;
6
7
  y: number;
7
8
  }
8
- export interface IElementPositionResult extends IElementPosition {
9
- visibility: 'visible' | 'hidden';
10
- }
11
9
  export interface IPositionElementConfig {
12
10
  /** The element to apply position to. */
13
11
  element: HTMLElement;
@@ -33,8 +31,10 @@ export interface IPositionElementConfig {
33
31
  auto?: boolean;
34
32
  /** Options to provide to the autoPlacement middleware. */
35
33
  autoOptions?: Partial<AutoPlacementOptions>;
36
- /** Offset positioning to apply to the placement. */
37
- offset?: IElementPosition;
34
+ /** Should any offset values be applied to the element. */
35
+ offset?: boolean;
36
+ /** */
37
+ offsetOptions?: Partial<OffsetOptions>;
38
38
  /** Should the top-layer middleware be applied or not. */
39
39
  topLayer?: boolean;
40
40
  /** The positioning strategy. */
@@ -44,14 +44,12 @@ export interface IPositionElementConfig {
44
44
  /** The CSS `translate` function to apply to the `transform`. Only applied when `transform` is `true`. */
45
45
  translateFunction?: 'translate3d' | 'translate';
46
46
  }
47
- /** Adjusts the x and y axes by a specified offset amount. */
48
- export declare const positionOffsetMiddleware: ({ x: offsetX, y: offsetY }: IElementPosition) => Middleware;
49
47
  /**
50
48
  * Calculates an elements position relative to another element.
51
49
  * @param {IPositionElementConfig} config Configuration to provide when positioning the element.
52
50
  * @returns {IElementPositionResult} The result of the positioning logic.
53
51
  */
54
- export declare function positionElementAsync({ element, targetElement, placement, offset, strategy, apply, flip, flipOptions, auto, autoOptions, shift, shiftOptions, hide, hideOptions, topLayer, transform, translateFunction }: IPositionElementConfig): Promise<IElementPositionResult>;
52
+ export declare function positionElementAsync({ element, targetElement, placement, offset, offsetOptions, strategy, apply, flip, flipOptions, auto, autoOptions, shift, shiftOptions, hide, hideOptions, topLayer, transform, translateFunction }: IPositionElementConfig): Promise<IElementPositionResult>;
55
53
  /**
56
54
  * Determines if the provided element is a child of a containment block.
57
55
  * @param element The element to check.