@zag-js/popper 1.39.1 → 1.41.0
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/get-placement.js +48 -37
- package/dist/get-placement.mjs +48 -37
- package/package.json +3 -3
package/dist/get-placement.js
CHANGED
|
@@ -77,22 +77,26 @@ function getOffsetMiddleware(arrowElement, opts) {
|
|
|
77
77
|
}
|
|
78
78
|
function getFlipMiddleware(opts) {
|
|
79
79
|
if (!opts.flip) return;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
return (0, import_dom.flip)(() => {
|
|
81
|
+
const boundary = resolveBoundaryOption(opts.boundary);
|
|
82
|
+
return {
|
|
83
|
+
...boundary ? { boundary } : void 0,
|
|
84
|
+
padding: opts.overflowPadding,
|
|
85
|
+
fallbackPlacements: opts.flip === true ? void 0 : opts.flip
|
|
86
|
+
};
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
function getShiftMiddleware(opts) {
|
|
88
90
|
if (!opts.slide && !opts.overlap) return;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
return (0, import_dom.shift)(() => {
|
|
92
|
+
const boundary = resolveBoundaryOption(opts.boundary);
|
|
93
|
+
return {
|
|
94
|
+
...boundary ? { boundary } : void 0,
|
|
95
|
+
mainAxis: opts.slide,
|
|
96
|
+
crossAxis: opts.overlap,
|
|
97
|
+
padding: opts.overflowPadding,
|
|
98
|
+
limiter: (0, import_dom.limitShift)()
|
|
99
|
+
};
|
|
96
100
|
});
|
|
97
101
|
}
|
|
98
102
|
function getSizeMiddleware(opts) {
|
|
@@ -101,36 +105,43 @@ function getSizeMiddleware(opts) {
|
|
|
101
105
|
let lastReferenceHeight;
|
|
102
106
|
let lastAvailableWidth;
|
|
103
107
|
let lastAvailableHeight;
|
|
104
|
-
return (0, import_dom.size)({
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
return (0, import_dom.size)(() => {
|
|
109
|
+
const boundary = resolveBoundaryOption(opts.boundary);
|
|
110
|
+
return {
|
|
111
|
+
padding: opts.overflowPadding,
|
|
112
|
+
...boundary ? { boundary } : void 0,
|
|
113
|
+
apply({ elements, rects, availableHeight, availableWidth }) {
|
|
114
|
+
const floating = elements.floating;
|
|
115
|
+
const referenceWidth = Math.round(rects.reference.width);
|
|
116
|
+
const referenceHeight = Math.round(rects.reference.height);
|
|
117
|
+
availableWidth = Math.floor(availableWidth);
|
|
118
|
+
availableHeight = Math.floor(availableHeight);
|
|
119
|
+
if (!isApproximatelyEqual(lastReferenceWidth, referenceWidth)) {
|
|
120
|
+
floating.style.setProperty("--reference-width", `${referenceWidth}px`);
|
|
121
|
+
lastReferenceWidth = referenceWidth;
|
|
122
|
+
}
|
|
123
|
+
if (!isApproximatelyEqual(lastReferenceHeight, referenceHeight)) {
|
|
124
|
+
floating.style.setProperty("--reference-height", `${referenceHeight}px`);
|
|
125
|
+
lastReferenceHeight = referenceHeight;
|
|
126
|
+
}
|
|
127
|
+
if (!isApproximatelyEqual(lastAvailableWidth, availableWidth)) {
|
|
128
|
+
floating.style.setProperty("--available-width", `${availableWidth}px`);
|
|
129
|
+
lastAvailableWidth = availableWidth;
|
|
130
|
+
}
|
|
131
|
+
if (!isApproximatelyEqual(lastAvailableHeight, availableHeight)) {
|
|
132
|
+
floating.style.setProperty("--available-height", `${availableHeight}px`);
|
|
133
|
+
lastAvailableHeight = availableHeight;
|
|
134
|
+
}
|
|
115
135
|
}
|
|
116
|
-
|
|
117
|
-
floating.style.setProperty("--reference-height", `${referenceHeight}px`);
|
|
118
|
-
lastReferenceHeight = referenceHeight;
|
|
119
|
-
}
|
|
120
|
-
if (!isApproximatelyEqual(lastAvailableWidth, availableWidth)) {
|
|
121
|
-
floating.style.setProperty("--available-width", `${availableWidth}px`);
|
|
122
|
-
lastAvailableWidth = availableWidth;
|
|
123
|
-
}
|
|
124
|
-
if (!isApproximatelyEqual(lastAvailableHeight, availableHeight)) {
|
|
125
|
-
floating.style.setProperty("--available-height", `${availableHeight}px`);
|
|
126
|
-
lastAvailableHeight = availableHeight;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
136
|
+
};
|
|
129
137
|
});
|
|
130
138
|
}
|
|
131
139
|
function hideWhenDetachedMiddleware(opts) {
|
|
132
140
|
if (!opts.hideWhenDetached) return;
|
|
133
|
-
return (0, import_dom.hide)(
|
|
141
|
+
return (0, import_dom.hide)(() => ({
|
|
142
|
+
strategy: "referenceHidden",
|
|
143
|
+
boundary: resolveBoundaryOption(opts.boundary) ?? "clippingAncestors"
|
|
144
|
+
}));
|
|
134
145
|
}
|
|
135
146
|
function getAutoUpdateOptions(opts) {
|
|
136
147
|
if (!opts) return {};
|
package/dist/get-placement.mjs
CHANGED
|
@@ -53,22 +53,26 @@ function getOffsetMiddleware(arrowElement, opts) {
|
|
|
53
53
|
}
|
|
54
54
|
function getFlipMiddleware(opts) {
|
|
55
55
|
if (!opts.flip) return;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
return flip(() => {
|
|
57
|
+
const boundary = resolveBoundaryOption(opts.boundary);
|
|
58
|
+
return {
|
|
59
|
+
...boundary ? { boundary } : void 0,
|
|
60
|
+
padding: opts.overflowPadding,
|
|
61
|
+
fallbackPlacements: opts.flip === true ? void 0 : opts.flip
|
|
62
|
+
};
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
function getShiftMiddleware(opts) {
|
|
64
66
|
if (!opts.slide && !opts.overlap) return;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
return shift(() => {
|
|
68
|
+
const boundary = resolveBoundaryOption(opts.boundary);
|
|
69
|
+
return {
|
|
70
|
+
...boundary ? { boundary } : void 0,
|
|
71
|
+
mainAxis: opts.slide,
|
|
72
|
+
crossAxis: opts.overlap,
|
|
73
|
+
padding: opts.overflowPadding,
|
|
74
|
+
limiter: limitShift()
|
|
75
|
+
};
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
function getSizeMiddleware(opts) {
|
|
@@ -77,36 +81,43 @@ function getSizeMiddleware(opts) {
|
|
|
77
81
|
let lastReferenceHeight;
|
|
78
82
|
let lastAvailableWidth;
|
|
79
83
|
let lastAvailableHeight;
|
|
80
|
-
return size({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
return size(() => {
|
|
85
|
+
const boundary = resolveBoundaryOption(opts.boundary);
|
|
86
|
+
return {
|
|
87
|
+
padding: opts.overflowPadding,
|
|
88
|
+
...boundary ? { boundary } : void 0,
|
|
89
|
+
apply({ elements, rects, availableHeight, availableWidth }) {
|
|
90
|
+
const floating = elements.floating;
|
|
91
|
+
const referenceWidth = Math.round(rects.reference.width);
|
|
92
|
+
const referenceHeight = Math.round(rects.reference.height);
|
|
93
|
+
availableWidth = Math.floor(availableWidth);
|
|
94
|
+
availableHeight = Math.floor(availableHeight);
|
|
95
|
+
if (!isApproximatelyEqual(lastReferenceWidth, referenceWidth)) {
|
|
96
|
+
floating.style.setProperty("--reference-width", `${referenceWidth}px`);
|
|
97
|
+
lastReferenceWidth = referenceWidth;
|
|
98
|
+
}
|
|
99
|
+
if (!isApproximatelyEqual(lastReferenceHeight, referenceHeight)) {
|
|
100
|
+
floating.style.setProperty("--reference-height", `${referenceHeight}px`);
|
|
101
|
+
lastReferenceHeight = referenceHeight;
|
|
102
|
+
}
|
|
103
|
+
if (!isApproximatelyEqual(lastAvailableWidth, availableWidth)) {
|
|
104
|
+
floating.style.setProperty("--available-width", `${availableWidth}px`);
|
|
105
|
+
lastAvailableWidth = availableWidth;
|
|
106
|
+
}
|
|
107
|
+
if (!isApproximatelyEqual(lastAvailableHeight, availableHeight)) {
|
|
108
|
+
floating.style.setProperty("--available-height", `${availableHeight}px`);
|
|
109
|
+
lastAvailableHeight = availableHeight;
|
|
110
|
+
}
|
|
91
111
|
}
|
|
92
|
-
|
|
93
|
-
floating.style.setProperty("--reference-height", `${referenceHeight}px`);
|
|
94
|
-
lastReferenceHeight = referenceHeight;
|
|
95
|
-
}
|
|
96
|
-
if (!isApproximatelyEqual(lastAvailableWidth, availableWidth)) {
|
|
97
|
-
floating.style.setProperty("--available-width", `${availableWidth}px`);
|
|
98
|
-
lastAvailableWidth = availableWidth;
|
|
99
|
-
}
|
|
100
|
-
if (!isApproximatelyEqual(lastAvailableHeight, availableHeight)) {
|
|
101
|
-
floating.style.setProperty("--available-height", `${availableHeight}px`);
|
|
102
|
-
lastAvailableHeight = availableHeight;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
112
|
+
};
|
|
105
113
|
});
|
|
106
114
|
}
|
|
107
115
|
function hideWhenDetachedMiddleware(opts) {
|
|
108
116
|
if (!opts.hideWhenDetached) return;
|
|
109
|
-
return hide(
|
|
117
|
+
return hide(() => ({
|
|
118
|
+
strategy: "referenceHidden",
|
|
119
|
+
boundary: resolveBoundaryOption(opts.boundary) ?? "clippingAncestors"
|
|
120
|
+
}));
|
|
110
121
|
}
|
|
111
122
|
function getAutoUpdateOptions(opts) {
|
|
112
123
|
if (!opts) return {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "Dynamic positioning logic for ui machines",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@floating-ui/dom": "^1.7.6",
|
|
26
|
-
"@zag-js/dom-query": "1.
|
|
27
|
-
"@zag-js/utils": "1.
|
|
26
|
+
"@zag-js/dom-query": "1.41.0",
|
|
27
|
+
"@zag-js/utils": "1.41.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"clean-package": "2.2.0"
|