@fluid-topics/ft-wc-utils 1.3.63 → 1.4.1
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/build/FtSlotHelper.d.ts +1 -0
- package/build/FtSlotHelper.js +14 -0
- package/build/floating.d.ts +9 -0
- package/build/floating.js +26 -4
- package/build/globals.min.js +14 -14
- package/build/index.d.ts +1 -0
- package/build/index.js +3 -0
- package/build/search.d.ts +1 -0
- package/build/search.js +18 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isSlotEmptyOrWithoutContent: (slot: HTMLSlotElement | undefined) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const isSlotEmptyOrWithoutContent = (slot) => {
|
|
2
|
+
if (!slot) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
const nodes = slot.assignedNodes({ flatten: true });
|
|
6
|
+
const meaningful = nodes.filter((node) => {
|
|
7
|
+
var _a;
|
|
8
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
9
|
+
return ((_a = node.textContent) !== null && _a !== void 0 ? _a : "").trim().length > 0;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
});
|
|
13
|
+
return meaningful.length === 0;
|
|
14
|
+
};
|
package/build/floating.d.ts
CHANGED
|
@@ -5,5 +5,14 @@ type PositionOptions = {
|
|
|
5
5
|
strategy?: Strategy;
|
|
6
6
|
};
|
|
7
7
|
export declare function computeOffsetPosition(reference: HTMLElement, element: HTMLElement, placementOrOptions: Placement | PositionOptions): Promise<ComputePositionReturn>;
|
|
8
|
+
type AutoPositionOptions = {
|
|
9
|
+
placement?: Placement;
|
|
10
|
+
allowedPlacements?: Placement[];
|
|
11
|
+
strategy?: Strategy;
|
|
12
|
+
maxHeightCssVariable?: string | FtCssVariable;
|
|
13
|
+
maxWidthCssVariable?: string | FtCssVariable;
|
|
14
|
+
offsetValue?: number;
|
|
15
|
+
};
|
|
8
16
|
export declare function computeOffsetAutoPosition(reference: HTMLElement, element: HTMLElement, placement?: Placement, allowedPlacements?: Placement[], strategy?: Strategy, maxHeightCssVariable?: string | FtCssVariable, offsetValue?: number): Promise<ComputePositionReturn>;
|
|
17
|
+
export declare function computeOffsetAutoPosition(reference: HTMLElement, element: HTMLElement, options?: AutoPositionOptions): Promise<ComputePositionReturn>;
|
|
9
18
|
export {};
|
package/build/floating.js
CHANGED
|
@@ -22,7 +22,20 @@ export async function computeOffsetPosition(reference, element, placementOrOptio
|
|
|
22
22
|
],
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
export async function computeOffsetAutoPosition(reference, element,
|
|
25
|
+
export async function computeOffsetAutoPosition(reference, element, placementOrOptions, allowedPlacements, strategy, maxHeightCssVariable, offsetValue) {
|
|
26
|
+
let placement;
|
|
27
|
+
let maxWidthCssVariable;
|
|
28
|
+
if (typeof placementOrOptions === "object") {
|
|
29
|
+
placement = placementOrOptions.placement;
|
|
30
|
+
allowedPlacements = placementOrOptions.allowedPlacements;
|
|
31
|
+
strategy = placementOrOptions.strategy;
|
|
32
|
+
maxHeightCssVariable = placementOrOptions.maxHeightCssVariable;
|
|
33
|
+
maxWidthCssVariable = placementOrOptions.maxWidthCssVariable;
|
|
34
|
+
offsetValue = placementOrOptions.offsetValue;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
placement = placementOrOptions;
|
|
38
|
+
}
|
|
26
39
|
return computePosition(reference, element, {
|
|
27
40
|
placement: placement,
|
|
28
41
|
strategy: strategy,
|
|
@@ -33,10 +46,10 @@ export async function computeOffsetAutoPosition(reference, element, placement, a
|
|
|
33
46
|
},
|
|
34
47
|
},
|
|
35
48
|
middleware: [
|
|
36
|
-
offset(offsetValue),
|
|
49
|
+
offset(offsetValue !== null && offsetValue !== void 0 ? offsetValue : 4),
|
|
37
50
|
autoPlacement({ allowedPlacements: allowedPlacements }),
|
|
38
51
|
size({
|
|
39
|
-
apply({ availableHeight, elements }) {
|
|
52
|
+
apply({ availableHeight, availableWidth, elements }) {
|
|
40
53
|
if (typeof maxHeightCssVariable === "string") {
|
|
41
54
|
maxHeightCssVariable = `var(${maxHeightCssVariable})`;
|
|
42
55
|
}
|
|
@@ -46,8 +59,17 @@ export async function computeOffsetAutoPosition(reference, element, placement, a
|
|
|
46
59
|
else {
|
|
47
60
|
elements.floating.style.maxHeight = `${Math.max(0, availableHeight)}px`;
|
|
48
61
|
}
|
|
62
|
+
if (typeof maxWidthCssVariable === "string") {
|
|
63
|
+
maxWidthCssVariable = `var(${maxWidthCssVariable})`;
|
|
64
|
+
}
|
|
65
|
+
if (maxWidthCssVariable) {
|
|
66
|
+
elements.floating.style.maxWidth = `min(${Math.max(0, availableWidth)}px, ${maxWidthCssVariable})`;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
elements.floating.style.maxWidth = `${Math.max(0, availableWidth)}px`;
|
|
70
|
+
}
|
|
49
71
|
},
|
|
50
72
|
}),
|
|
51
|
-
]
|
|
73
|
+
],
|
|
52
74
|
});
|
|
53
75
|
}
|