@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.
@@ -77,22 +77,26 @@ function getOffsetMiddleware(arrowElement, opts) {
77
77
  }
78
78
  function getFlipMiddleware(opts) {
79
79
  if (!opts.flip) return;
80
- const boundary = resolveBoundaryOption(opts.boundary);
81
- return (0, import_dom.flip)({
82
- ...boundary ? { boundary } : void 0,
83
- padding: opts.overflowPadding,
84
- fallbackPlacements: opts.flip === true ? void 0 : opts.flip
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
- const boundary = resolveBoundaryOption(opts.boundary);
90
- return (0, import_dom.shift)({
91
- ...boundary ? { boundary } : void 0,
92
- mainAxis: opts.slide,
93
- crossAxis: opts.overlap,
94
- padding: opts.overflowPadding,
95
- limiter: (0, import_dom.limitShift)()
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
- padding: opts.overflowPadding,
106
- apply({ elements, rects, availableHeight, availableWidth }) {
107
- const floating = elements.floating;
108
- const referenceWidth = Math.round(rects.reference.width);
109
- const referenceHeight = Math.round(rects.reference.height);
110
- availableWidth = Math.floor(availableWidth);
111
- availableHeight = Math.floor(availableHeight);
112
- if (!isApproximatelyEqual(lastReferenceWidth, referenceWidth)) {
113
- floating.style.setProperty("--reference-width", `${referenceWidth}px`);
114
- lastReferenceWidth = referenceWidth;
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
- if (!isApproximatelyEqual(lastReferenceHeight, referenceHeight)) {
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)({ strategy: "referenceHidden", boundary: resolveBoundaryOption(opts.boundary) ?? "clippingAncestors" });
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 {};
@@ -53,22 +53,26 @@ function getOffsetMiddleware(arrowElement, opts) {
53
53
  }
54
54
  function getFlipMiddleware(opts) {
55
55
  if (!opts.flip) return;
56
- const boundary = resolveBoundaryOption(opts.boundary);
57
- return flip({
58
- ...boundary ? { boundary } : void 0,
59
- padding: opts.overflowPadding,
60
- fallbackPlacements: opts.flip === true ? void 0 : opts.flip
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
- const boundary = resolveBoundaryOption(opts.boundary);
66
- return shift({
67
- ...boundary ? { boundary } : void 0,
68
- mainAxis: opts.slide,
69
- crossAxis: opts.overlap,
70
- padding: opts.overflowPadding,
71
- limiter: limitShift()
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
- padding: opts.overflowPadding,
82
- apply({ elements, rects, availableHeight, availableWidth }) {
83
- const floating = elements.floating;
84
- const referenceWidth = Math.round(rects.reference.width);
85
- const referenceHeight = Math.round(rects.reference.height);
86
- availableWidth = Math.floor(availableWidth);
87
- availableHeight = Math.floor(availableHeight);
88
- if (!isApproximatelyEqual(lastReferenceWidth, referenceWidth)) {
89
- floating.style.setProperty("--reference-width", `${referenceWidth}px`);
90
- lastReferenceWidth = referenceWidth;
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
- if (!isApproximatelyEqual(lastReferenceHeight, referenceHeight)) {
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({ strategy: "referenceHidden", boundary: resolveBoundaryOption(opts.boundary) ?? "clippingAncestors" });
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.39.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.39.1",
27
- "@zag-js/utils": "1.39.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"