@zag-js/popper 0.1.13 → 0.2.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/index.d.ts CHANGED
@@ -51,7 +51,7 @@ declare type PositioningOptions = {
51
51
  /**
52
52
  * The overflow boundary of the reference element
53
53
  */
54
- boundary?: Boundary;
54
+ boundary?: Boundary | (() => Boundary);
55
55
  /**
56
56
  * Options to activate auto-update listeners
57
57
  */
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ var import_dom = require("@floating-ui/dom");
43
43
  // ../dom/dist/index.mjs
44
44
  var runIfFn = (v, ...a) => {
45
45
  const res = typeof v === "function" ? v(...a) : v;
46
- return res ?? void 0;
46
+ return res != null ? res : void 0;
47
47
  };
48
48
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
49
49
  function isHTMLElement(v) {
@@ -112,11 +112,12 @@ function isEqual(rect1, rect2) {
112
112
 
113
113
  // src/auto-update.ts
114
114
  function resolveOptions(option) {
115
+ var _a, _b, _c;
115
116
  const bool = isBoolean(option);
116
117
  return {
117
- ancestorResize: bool ? option : option.ancestorResize ?? true,
118
- ancestorScroll: bool ? option : option.ancestorScroll ?? true,
119
- referenceResize: bool ? option : option.referenceResize ?? true
118
+ ancestorResize: bool ? option : (_a = option.ancestorResize) != null ? _a : true,
119
+ ancestorScroll: bool ? option : (_b = option.ancestorScroll) != null ? _b : true,
120
+ referenceResize: bool ? option : (_c = option.referenceResize) != null ? _c : true
120
121
  };
121
122
  }
122
123
  function autoUpdate(reference, floating, update, options = false) {
@@ -208,10 +209,11 @@ function getPlacement(reference, floating, opts = {}) {
208
209
  const options = Object.assign({}, defaultOptions, opts);
209
210
  const arrowEl = floating.querySelector("[data-part=arrow]");
210
211
  const middleware = [];
212
+ const boundary = typeof options.boundary === "function" ? options.boundary() : options.boundary;
211
213
  if (options.flip) {
212
214
  middleware.push(
213
215
  (0, import_dom2.flip)({
214
- boundary: options.boundary,
216
+ boundary,
215
217
  padding: options.overflowPadding
216
218
  })
217
219
  );
@@ -225,7 +227,7 @@ function getPlacement(reference, floating, opts = {}) {
225
227
  }
226
228
  middleware.push(
227
229
  (0, import_dom2.shift)({
228
- boundary: options.boundary,
230
+ boundary,
229
231
  crossAxis: options.overlap,
230
232
  padding: options.overflowPadding
231
233
  })
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ import { getOverflowAncestors } from "@floating-ui/dom";
15
15
  // ../dom/dist/index.mjs
16
16
  var runIfFn = (v, ...a) => {
17
17
  const res = typeof v === "function" ? v(...a) : v;
18
- return res ?? void 0;
18
+ return res != null ? res : void 0;
19
19
  };
20
20
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
21
21
  function isHTMLElement(v) {
@@ -84,11 +84,12 @@ function isEqual(rect1, rect2) {
84
84
 
85
85
  // src/auto-update.ts
86
86
  function resolveOptions(option) {
87
+ var _a, _b, _c;
87
88
  const bool = isBoolean(option);
88
89
  return {
89
- ancestorResize: bool ? option : option.ancestorResize ?? true,
90
- ancestorScroll: bool ? option : option.ancestorScroll ?? true,
91
- referenceResize: bool ? option : option.referenceResize ?? true
90
+ ancestorResize: bool ? option : (_a = option.ancestorResize) != null ? _a : true,
91
+ ancestorScroll: bool ? option : (_b = option.ancestorScroll) != null ? _b : true,
92
+ referenceResize: bool ? option : (_c = option.referenceResize) != null ? _c : true
92
93
  };
93
94
  }
94
95
  function autoUpdate(reference, floating, update, options = false) {
@@ -180,10 +181,11 @@ function getPlacement(reference, floating, opts = {}) {
180
181
  const options = Object.assign({}, defaultOptions, opts);
181
182
  const arrowEl = floating.querySelector("[data-part=arrow]");
182
183
  const middleware = [];
184
+ const boundary = typeof options.boundary === "function" ? options.boundary() : options.boundary;
183
185
  if (options.flip) {
184
186
  middleware.push(
185
187
  flip({
186
- boundary: options.boundary,
188
+ boundary,
187
189
  padding: options.overflowPadding
188
190
  })
189
191
  );
@@ -197,7 +199,7 @@ function getPlacement(reference, floating, opts = {}) {
197
199
  }
198
200
  middleware.push(
199
201
  shift({
200
- boundary: options.boundary,
202
+ boundary,
201
203
  crossAxis: options.overlap,
202
204
  padding: options.overflowPadding
203
205
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/popper",
3
- "version": "0.1.13",
3
+ "version": "0.2.0",
4
4
  "description": "Dynamic positioning logic for ui machines",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -25,11 +25,11 @@
25
25
  "url": "https://github.com/chakra-ui/zag/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@floating-ui/dom": "1.0.1"
28
+ "@floating-ui/dom": "1.0.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@zag-js/dom-utils": "0.1.13",
32
- "@zag-js/utils": "0.1.6"
31
+ "@zag-js/dom-utils": "0.2.0",
32
+ "@zag-js/utils": "0.2.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build-fast": "tsup src/index.ts --format=esm,cjs",