@fluid-topics/ft-wc-utils 1.3.61 → 1.3.63

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,7 +1,7 @@
1
1
  import { Optional } from "./generic-types";
2
2
  type FluidTopicsScrollHelperInterface = {
3
- lock<T extends Element>(manager: Object, scrollable: Optional<T>): T | undefined;
4
- release(manager: Object, scrollable: Optional<Element>): void;
3
+ lock<T extends Element>(manager: object, scrollable: Optional<T>): T | undefined;
4
+ release(manager: object, scrollable: Optional<Element>): void;
5
5
  findFirstScrollableParent(element: HTMLElement): HTMLElement;
6
6
  getAbsoluteScrollOffset(scrollable: HTMLElement, target: HTMLElement): number;
7
7
  scrollIntoViewIfPossible(element: HTMLElement, options?: FtScrollIntoViewOptions): void;
@@ -1,5 +1,5 @@
1
1
  var _a;
2
- import { getComposedPathTo, minmax } from "./helpers";
2
+ import { getComposedPathTo, minmax, } from "./helpers";
3
3
  const locks = new Map();
4
4
  class FluidTopicsScrollHelper {
5
5
  lock(manager, scrollable) {
@@ -20,7 +20,7 @@ class FluidTopicsScrollHelper {
20
20
  findFirstScrollableParent(element) {
21
21
  var _a;
22
22
  let scrollable, maybeScrollable;
23
- for (let target of getComposedPathTo(element)) {
23
+ for (const target of getComposedPathTo(element)) {
24
24
  const element = target;
25
25
  const mayScroll = this.elementCanScroll(element);
26
26
  const definitelyScrolls = mayScroll && element.clientHeight && element.clientHeight < element.scrollHeight;
@@ -36,9 +36,9 @@ class FluidTopicsScrollHelper {
36
36
  }
37
37
  elementCanScroll(element) {
38
38
  try {
39
- return ["auto", "scroll"].includes(getComputedStyle(element).overflowY);
39
+ return ["auto", "scroll"].includes(getComputedStyle(element).overflowY) && !["contents"].includes(getComputedStyle(element).display);
40
40
  }
41
- catch (e) {
41
+ catch {
42
42
  return false;
43
43
  }
44
44
  }
@@ -76,7 +76,7 @@ class FluidTopicsScrollHelper {
76
76
  const top = this.computeTopOffsetRatio(options === null || options === void 0 ? void 0 : options.position, nearestValue) * (minScrollTop - maxScrollTop) + maxScrollTop;
77
77
  scrollableParent.scrollTo({
78
78
  behavior: options === null || options === void 0 ? void 0 : options.behavior,
79
- top: top
79
+ top: top,
80
80
  });
81
81
  }
82
82
  else {
@@ -1,4 +1,9 @@
1
1
  import { ComputePositionReturn, Placement, Strategy } from "@floating-ui/dom";
2
2
  import { FtCssVariable } from "@fluid-topics/design-system-variables";
3
- export declare function computeOffsetPosition(reference: HTMLElement, element: HTMLElement, placement: Placement): Promise<ComputePositionReturn>;
3
+ type PositionOptions = {
4
+ placement: Placement;
5
+ strategy?: Strategy;
6
+ };
7
+ export declare function computeOffsetPosition(reference: HTMLElement, element: HTMLElement, placementOrOptions: Placement | PositionOptions): Promise<ComputePositionReturn>;
4
8
  export declare function computeOffsetAutoPosition(reference: HTMLElement, element: HTMLElement, placement?: Placement, allowedPlacements?: Placement[], strategy?: Strategy, maxHeightCssVariable?: string | FtCssVariable, offsetValue?: number): Promise<ComputePositionReturn>;
9
+ export {};
package/build/floating.js CHANGED
@@ -1,7 +1,15 @@
1
- import { autoPlacement, computePosition, offset, platform, shift, size } from "@floating-ui/dom";
1
+ import { autoPlacement, computePosition, offset, platform, shift, size, } from "@floating-ui/dom";
2
2
  import { offsetParent } from "composed-offset-position";
3
- export async function computeOffsetPosition(reference, element, placement) {
3
+ export async function computeOffsetPosition(reference, element, placementOrOptions) {
4
+ let options;
5
+ if (typeof placementOrOptions === "object") {
6
+ options = placementOrOptions;
7
+ }
8
+ else {
9
+ options = { placement: placementOrOptions };
10
+ }
4
11
  return computePosition(reference, element, {
12
+ strategy: options.strategy,
5
13
  platform: {
6
14
  ...platform,
7
15
  getOffsetParent: (element) => {
@@ -10,7 +18,7 @@ export async function computeOffsetPosition(reference, element, placement) {
10
18
  },
11
19
  middleware: [
12
20
  shift({ crossAxis: true }),
13
- autoPlacement({ allowedPlacements: [placement] }),
21
+ autoPlacement({ allowedPlacements: [options.placement] }),
14
22
  ],
15
23
  });
16
24
  }