@johly/bits-ui 2.18.4 → 2.18.5
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/dist/bits/filter/components/filter-menu-node.svelte +5 -1
- package/dist/bits/utilities/floating-layer/components/floating-layer-content.svelte +2 -0
- package/dist/bits/utilities/floating-layer/types.d.ts +13 -0
- package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.d.ts +4 -0
- package/dist/bits/utilities/floating-layer/use-floating-layer.svelte.js +24 -2
- package/dist/bits/utilities/popper-layer/popper-layer-force-mount.svelte +2 -0
- package/dist/bits/utilities/popper-layer/popper-layer-inner.svelte +2 -0
- package/dist/bits/utilities/popper-layer/popper-layer.svelte +2 -0
- package/package.json +1 -1
|
@@ -136,7 +136,11 @@
|
|
|
136
136
|
</span>
|
|
137
137
|
</MenuSubTrigger>
|
|
138
138
|
<Portal>
|
|
139
|
-
<MenuSubContent
|
|
139
|
+
<MenuSubContent
|
|
140
|
+
sideOffset={8}
|
|
141
|
+
align={getSubmenuAlign(meta)}
|
|
142
|
+
collisionAvoidance={{ side: "shift", align: "shift" }}
|
|
143
|
+
>
|
|
140
144
|
{#if column && meta?.kind === "column" && meta.editor === "text"}
|
|
141
145
|
<FilterTextEditor column={column as Column<unknown, "text">} {actions} />
|
|
142
146
|
{:else if column && meta?.kind === "column" && meta.editor === "number"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
id,
|
|
14
14
|
arrowPadding = 0,
|
|
15
15
|
avoidCollisions = true,
|
|
16
|
+
collisionAvoidance,
|
|
16
17
|
collisionBoundary = [],
|
|
17
18
|
collisionPadding = 0,
|
|
18
19
|
hideWhenDetached = false,
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
id: boxWith(() => id),
|
|
38
39
|
arrowPadding: boxWith(() => arrowPadding),
|
|
39
40
|
avoidCollisions: boxWith(() => avoidCollisions),
|
|
41
|
+
collisionAvoidance: boxWith(() => collisionAvoidance),
|
|
40
42
|
collisionBoundary: boxWith(() => collisionBoundary),
|
|
41
43
|
collisionPadding: boxWith(() => collisionPadding),
|
|
42
44
|
hideWhenDetached: boxWith(() => hideWhenDetached),
|
|
@@ -43,6 +43,19 @@ export type FloatingLayerContentProps = {
|
|
|
43
43
|
* @see https://floating-ui.com/docs/flip
|
|
44
44
|
*/
|
|
45
45
|
avoidCollisions?: boolean | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Controls how the floating element avoids boundary collisions.
|
|
48
|
+
*
|
|
49
|
+
* - `side: "flip"` preserves the existing behavior and may move the
|
|
50
|
+
* floating element to the opposite side of its anchor.
|
|
51
|
+
* - `side: "shift"` keeps the preferred side and shifts the floating
|
|
52
|
+
* element back into view, which can intentionally overlap the anchor.
|
|
53
|
+
* - `align: "shift"` allows shifting on the alignment axis.
|
|
54
|
+
*/
|
|
55
|
+
collisionAvoidance?: {
|
|
56
|
+
side?: "flip" | "shift" | "none";
|
|
57
|
+
align?: "shift" | "none";
|
|
58
|
+
};
|
|
46
59
|
/**
|
|
47
60
|
* A boundary element or array of elements to check for collisions against.
|
|
48
61
|
*
|
|
@@ -24,6 +24,10 @@ export interface FloatingContentStateOpts extends ReadableBoxedValues<{
|
|
|
24
24
|
alignOffset: number;
|
|
25
25
|
arrowPadding: number;
|
|
26
26
|
avoidCollisions: boolean;
|
|
27
|
+
collisionAvoidance: {
|
|
28
|
+
side?: "flip" | "shift" | "none";
|
|
29
|
+
align?: "shift" | "none";
|
|
30
|
+
} | undefined;
|
|
27
31
|
collisionBoundary: Arrayable<Boundary>;
|
|
28
32
|
collisionPadding: number | Partial<Record<Side, number>>;
|
|
29
33
|
sticky: "partial" | "always";
|
|
@@ -84,19 +84,41 @@ export class FloatingContentState {
|
|
|
84
84
|
#availableHeight = $state(undefined);
|
|
85
85
|
#anchorWidth = $state(undefined);
|
|
86
86
|
#anchorHeight = $state(undefined);
|
|
87
|
+
#collisionAvoidance = $derived.by(() => {
|
|
88
|
+
if (this.opts.collisionAvoidance.current)
|
|
89
|
+
return this.opts.collisionAvoidance.current;
|
|
90
|
+
if (!this.opts.avoidCollisions.current)
|
|
91
|
+
return { side: "none", align: "none" };
|
|
92
|
+
return { side: "flip", align: "none" };
|
|
93
|
+
});
|
|
87
94
|
middleware = $derived.by(() => [
|
|
88
95
|
offset({
|
|
89
96
|
mainAxis: this.opts.sideOffset.current + this.#arrowHeight,
|
|
90
97
|
alignmentAxis: this.opts.alignOffset.current,
|
|
91
98
|
}),
|
|
92
99
|
this.opts.avoidCollisions.current &&
|
|
100
|
+
(this.#collisionAvoidance.side === "shift" ||
|
|
101
|
+
this.#collisionAvoidance.align === "shift") &&
|
|
102
|
+
shift({
|
|
103
|
+
mainAxis: this.#collisionAvoidance.side === "shift",
|
|
104
|
+
crossAxis: this.#collisionAvoidance.align === "shift",
|
|
105
|
+
limiter: this.opts.sticky.current === "partial" &&
|
|
106
|
+
this.#collisionAvoidance.side !== "shift"
|
|
107
|
+
? limitShift()
|
|
108
|
+
: undefined,
|
|
109
|
+
...this.detectOverflowOptions,
|
|
110
|
+
}),
|
|
111
|
+
this.opts.avoidCollisions.current &&
|
|
112
|
+
this.#collisionAvoidance.side === "flip" &&
|
|
93
113
|
shift({
|
|
94
114
|
mainAxis: true,
|
|
95
|
-
crossAxis:
|
|
115
|
+
crossAxis: this.#collisionAvoidance.align === "shift",
|
|
96
116
|
limiter: this.opts.sticky.current === "partial" ? limitShift() : undefined,
|
|
97
117
|
...this.detectOverflowOptions,
|
|
98
118
|
}),
|
|
99
|
-
this.opts.avoidCollisions.current &&
|
|
119
|
+
this.opts.avoidCollisions.current &&
|
|
120
|
+
this.#collisionAvoidance.side === "flip" &&
|
|
121
|
+
flip({ ...this.detectOverflowOptions }),
|
|
100
122
|
size({
|
|
101
123
|
...this.detectOverflowOptions,
|
|
102
124
|
apply: ({ rects, availableWidth, availableHeight }) => {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
alignOffset,
|
|
17
17
|
arrowPadding,
|
|
18
18
|
avoidCollisions,
|
|
19
|
+
collisionAvoidance,
|
|
19
20
|
collisionBoundary,
|
|
20
21
|
collisionPadding,
|
|
21
22
|
sticky,
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
{alignOffset}
|
|
59
60
|
{arrowPadding}
|
|
60
61
|
{avoidCollisions}
|
|
62
|
+
{collisionAvoidance}
|
|
61
63
|
{collisionBoundary}
|
|
62
64
|
{collisionPadding}
|
|
63
65
|
{sticky}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
alignOffset,
|
|
23
23
|
arrowPadding,
|
|
24
24
|
avoidCollisions,
|
|
25
|
+
collisionAvoidance,
|
|
25
26
|
collisionBoundary,
|
|
26
27
|
collisionPadding,
|
|
27
28
|
sticky,
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
{alignOffset}
|
|
67
68
|
{arrowPadding}
|
|
68
69
|
{avoidCollisions}
|
|
70
|
+
{collisionAvoidance}
|
|
69
71
|
{collisionBoundary}
|
|
70
72
|
{collisionPadding}
|
|
71
73
|
{sticky}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
alignOffset,
|
|
18
18
|
arrowPadding,
|
|
19
19
|
avoidCollisions,
|
|
20
|
+
collisionAvoidance,
|
|
20
21
|
collisionBoundary,
|
|
21
22
|
collisionPadding,
|
|
22
23
|
sticky,
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
{alignOffset}
|
|
60
61
|
{arrowPadding}
|
|
61
62
|
{avoidCollisions}
|
|
63
|
+
{collisionAvoidance}
|
|
62
64
|
{collisionBoundary}
|
|
63
65
|
{collisionPadding}
|
|
64
66
|
{sticky}
|