@zag-js/popper 0.2.4 → 0.2.7

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.
@@ -49,7 +49,7 @@ function autoUpdate(reference, floating, update, options = false) {
49
49
  ancestors.push(...(0, import_dom.getOverflowAncestors)(reference));
50
50
  }
51
51
  function addResizeListeners() {
52
- let cleanups = [(0, import_element_rect.trackElementRect)(floating, update)];
52
+ let cleanups = [(0, import_element_rect.trackElementRect)(floating, update, { scope: "size" })];
53
53
  if (referenceResize && isHTMLElement(reference)) {
54
54
  cleanups.push((0, import_element_rect.trackElementRect)(reference, update));
55
55
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  autoUpdate
3
- } from "./chunk-KMOWWEFH.mjs";
3
+ } from "./chunk-AVEWKGZP.mjs";
4
4
  export {
5
5
  autoUpdate
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  autoUpdate
3
- } from "./chunk-KMOWWEFH.mjs";
3
+ } from "./chunk-AVEWKGZP.mjs";
4
4
  import {
5
5
  shiftArrow,
6
6
  transformOrigin
@@ -80,7 +80,7 @@ function getPlacement(reference, floating, opts = {}) {
80
80
  function compute(config = {}) {
81
81
  if (!reference || !floating)
82
82
  return;
83
- const { placement, strategy } = options;
83
+ const { placement, strategy, onComplete } = options;
84
84
  computePosition(reference, floating, {
85
85
  placement,
86
86
  middleware,
@@ -91,11 +91,11 @@ function getPlacement(reference, floating, opts = {}) {
91
91
  const y = Math.round(data.y);
92
92
  Object.assign(floating.style, {
93
93
  position: data.strategy,
94
- top: "0",
95
- left: "0",
94
+ top: "0px",
95
+ left: "0px",
96
96
  transform: `translate3d(${x}px, ${y}px, 0)`
97
97
  });
98
- options.onComplete?.({ ...data, compute });
98
+ onComplete?.(data);
99
99
  });
100
100
  }
101
101
  compute();
@@ -25,7 +25,7 @@ function autoUpdate(reference, floating, update, options = false) {
25
25
  ancestors.push(...getOverflowAncestors(reference));
26
26
  }
27
27
  function addResizeListeners() {
28
- let cleanups = [trackElementRect(floating, update)];
28
+ let cleanups = [trackElementRect(floating, update, { scope: "size" })];
29
29
  if (referenceResize && isHTMLElement(reference)) {
30
30
  cleanups.push(trackElementRect(reference, update));
31
31
  }
@@ -3,14 +3,6 @@ import {
3
3
  } from "./chunk-X5LLREVI.mjs";
4
4
 
5
5
  // src/get-styles.ts
6
- var UNMEASURED_FLOATING_STYLE = {
7
- position: "fixed",
8
- top: 0,
9
- left: 0,
10
- opacity: 0,
11
- transform: "translate3d(0, -200%, 0)",
12
- pointerEvents: "none"
13
- };
14
6
  var ARROW_FLOATING_STYLE = {
15
7
  bottom: "rotate(45deg)",
16
8
  left: "rotate(135deg)",
@@ -18,15 +10,14 @@ var ARROW_FLOATING_STYLE = {
18
10
  right: "rotate(315deg)"
19
11
  };
20
12
  function getPlacementStyles(options) {
21
- const { measured, strategy = "absolute", placement = "bottom" } = options;
13
+ const { placement = "bottom" } = options;
22
14
  return {
23
15
  arrow: {
24
16
  position: "absolute",
25
17
  width: cssVars.arrowSize.reference,
26
18
  height: cssVars.arrowSize.reference,
27
19
  [cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
28
- [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
29
- opacity: !measured ? 0 : void 0
20
+ [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`
30
21
  },
31
22
  arrowTip: {
32
23
  transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
@@ -39,9 +30,10 @@ function getPlacementStyles(options) {
39
30
  zIndex: "inherit"
40
31
  },
41
32
  floating: {
42
- position: strategy,
33
+ position: "absolute",
43
34
  minWidth: "max-content",
44
- ...!measured && UNMEASURED_FLOATING_STYLE
35
+ top: "0px",
36
+ left: "0px"
45
37
  }
46
38
  };
47
39
  }
@@ -54,7 +54,7 @@ function autoUpdate(reference, floating, update, options = false) {
54
54
  ancestors.push(...(0, import_dom.getOverflowAncestors)(reference));
55
55
  }
56
56
  function addResizeListeners() {
57
- let cleanups = [(0, import_element_rect.trackElementRect)(floating, update)];
57
+ let cleanups = [(0, import_element_rect.trackElementRect)(floating, update, { scope: "size" })];
58
58
  if (referenceResize && isHTMLElement(reference)) {
59
59
  cleanups.push((0, import_element_rect.trackElementRect)(reference, update));
60
60
  }
@@ -191,7 +191,7 @@ function getPlacement(reference, floating, opts = {}) {
191
191
  function compute(config = {}) {
192
192
  if (!reference || !floating)
193
193
  return;
194
- const { placement, strategy } = options;
194
+ const { placement, strategy, onComplete } = options;
195
195
  (0, import_dom2.computePosition)(reference, floating, {
196
196
  placement,
197
197
  middleware,
@@ -202,11 +202,11 @@ function getPlacement(reference, floating, opts = {}) {
202
202
  const y = Math.round(data.y);
203
203
  Object.assign(floating.style, {
204
204
  position: data.strategy,
205
- top: "0",
206
- left: "0",
205
+ top: "0px",
206
+ left: "0px",
207
207
  transform: `translate3d(${x}px, ${y}px, 0)`
208
208
  });
209
- options.onComplete?.({ ...data, compute });
209
+ onComplete?.(data);
210
210
  });
211
211
  }
212
212
  compute();
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getBasePlacement,
3
3
  getPlacement
4
- } from "./chunk-K6E3OR2A.mjs";
5
- import "./chunk-KMOWWEFH.mjs";
4
+ } from "./chunk-6B3BV5TE.mjs";
5
+ import "./chunk-AVEWKGZP.mjs";
6
6
  import "./chunk-X5LLREVI.mjs";
7
7
  export {
8
8
  getBasePlacement,
@@ -1,17 +1,14 @@
1
1
  import { Placement } from '@floating-ui/dom';
2
2
 
3
3
  type Options = {
4
- measured: boolean;
5
- strategy?: "absolute" | "fixed";
6
4
  placement?: Placement;
7
5
  };
8
6
  declare function getPlacementStyles(options: Options): {
9
7
  arrow: {
10
- readonly [x: string]: string | 0 | undefined;
8
+ readonly [x: string]: string;
11
9
  readonly position: "absolute";
12
10
  readonly width: string;
13
11
  readonly height: string;
14
- readonly opacity: 0 | undefined;
15
12
  };
16
13
  arrowTip: {
17
14
  readonly transform: any;
@@ -24,13 +21,10 @@ declare function getPlacementStyles(options: Options): {
24
21
  readonly zIndex: "inherit";
25
22
  };
26
23
  floating: {
27
- position: "absolute" | "fixed";
28
- readonly top?: 0 | undefined;
29
- readonly left?: 0 | undefined;
30
- readonly opacity?: 0 | undefined;
31
- readonly transform?: "translate3d(0, -200%, 0)" | undefined;
32
- readonly pointerEvents?: "none" | undefined;
24
+ readonly position: "absolute";
33
25
  readonly minWidth: "max-content";
26
+ readonly top: "0px";
27
+ readonly left: "0px";
34
28
  };
35
29
  };
36
30
 
@@ -35,14 +35,6 @@ var cssVars = {
35
35
  };
36
36
 
37
37
  // src/get-styles.ts
38
- var UNMEASURED_FLOATING_STYLE = {
39
- position: "fixed",
40
- top: 0,
41
- left: 0,
42
- opacity: 0,
43
- transform: "translate3d(0, -200%, 0)",
44
- pointerEvents: "none"
45
- };
46
38
  var ARROW_FLOATING_STYLE = {
47
39
  bottom: "rotate(45deg)",
48
40
  left: "rotate(135deg)",
@@ -50,15 +42,14 @@ var ARROW_FLOATING_STYLE = {
50
42
  right: "rotate(315deg)"
51
43
  };
52
44
  function getPlacementStyles(options) {
53
- const { measured, strategy = "absolute", placement = "bottom" } = options;
45
+ const { placement = "bottom" } = options;
54
46
  return {
55
47
  arrow: {
56
48
  position: "absolute",
57
49
  width: cssVars.arrowSize.reference,
58
50
  height: cssVars.arrowSize.reference,
59
51
  [cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
60
- [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
61
- opacity: !measured ? 0 : void 0
52
+ [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`
62
53
  },
63
54
  arrowTip: {
64
55
  transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
@@ -71,9 +62,10 @@ function getPlacementStyles(options) {
71
62
  zIndex: "inherit"
72
63
  },
73
64
  floating: {
74
- position: strategy,
65
+ position: "absolute",
75
66
  minWidth: "max-content",
76
- ...!measured && UNMEASURED_FLOATING_STYLE
67
+ top: "0px",
68
+ left: "0px"
77
69
  }
78
70
  };
79
71
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getPlacementStyles
3
- } from "./chunk-I46LTIWB.mjs";
3
+ } from "./chunk-V4C4UQPN.mjs";
4
4
  import "./chunk-X5LLREVI.mjs";
5
5
  export {
6
6
  getPlacementStyles
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ function autoUpdate(reference, floating, update, options = false) {
57
57
  ancestors.push(...(0, import_dom.getOverflowAncestors)(reference));
58
58
  }
59
59
  function addResizeListeners() {
60
- let cleanups = [(0, import_element_rect.trackElementRect)(floating, update)];
60
+ let cleanups = [(0, import_element_rect.trackElementRect)(floating, update, { scope: "size" })];
61
61
  if (referenceResize && isHTMLElement(reference)) {
62
62
  cleanups.push((0, import_element_rect.trackElementRect)(reference, update));
63
63
  }
@@ -194,7 +194,7 @@ function getPlacement(reference, floating, opts = {}) {
194
194
  function compute(config = {}) {
195
195
  if (!reference || !floating)
196
196
  return;
197
- const { placement, strategy } = options;
197
+ const { placement, strategy, onComplete } = options;
198
198
  (0, import_dom2.computePosition)(reference, floating, {
199
199
  placement,
200
200
  middleware,
@@ -205,11 +205,11 @@ function getPlacement(reference, floating, opts = {}) {
205
205
  const y = Math.round(data.y);
206
206
  Object.assign(floating.style, {
207
207
  position: data.strategy,
208
- top: "0",
209
- left: "0",
208
+ top: "0px",
209
+ left: "0px",
210
210
  transform: `translate3d(${x}px, ${y}px, 0)`
211
211
  });
212
- options.onComplete?.({ ...data, compute });
212
+ onComplete?.(data);
213
213
  });
214
214
  }
215
215
  compute();
@@ -223,14 +223,6 @@ function getBasePlacement(placement) {
223
223
  }
224
224
 
225
225
  // src/get-styles.ts
226
- var UNMEASURED_FLOATING_STYLE = {
227
- position: "fixed",
228
- top: 0,
229
- left: 0,
230
- opacity: 0,
231
- transform: "translate3d(0, -200%, 0)",
232
- pointerEvents: "none"
233
- };
234
226
  var ARROW_FLOATING_STYLE = {
235
227
  bottom: "rotate(45deg)",
236
228
  left: "rotate(135deg)",
@@ -238,15 +230,14 @@ var ARROW_FLOATING_STYLE = {
238
230
  right: "rotate(315deg)"
239
231
  };
240
232
  function getPlacementStyles(options) {
241
- const { measured, strategy = "absolute", placement = "bottom" } = options;
233
+ const { placement = "bottom" } = options;
242
234
  return {
243
235
  arrow: {
244
236
  position: "absolute",
245
237
  width: cssVars.arrowSize.reference,
246
238
  height: cssVars.arrowSize.reference,
247
239
  [cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
248
- [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
249
- opacity: !measured ? 0 : void 0
240
+ [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`
250
241
  },
251
242
  arrowTip: {
252
243
  transform: ARROW_FLOATING_STYLE[placement.split("-")[0]],
@@ -259,9 +250,10 @@ function getPlacementStyles(options) {
259
250
  zIndex: "inherit"
260
251
  },
261
252
  floating: {
262
- position: strategy,
253
+ position: "absolute",
263
254
  minWidth: "max-content",
264
- ...!measured && UNMEASURED_FLOATING_STYLE
255
+ top: "0px",
256
+ left: "0px"
265
257
  }
266
258
  };
267
259
  }
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getBasePlacement,
3
3
  getPlacement
4
- } from "./chunk-K6E3OR2A.mjs";
5
- import "./chunk-KMOWWEFH.mjs";
4
+ } from "./chunk-6B3BV5TE.mjs";
5
+ import "./chunk-AVEWKGZP.mjs";
6
6
  import {
7
7
  getPlacementStyles
8
- } from "./chunk-I46LTIWB.mjs";
8
+ } from "./chunk-V4C4UQPN.mjs";
9
9
  import "./chunk-X5LLREVI.mjs";
10
10
  export {
11
11
  getBasePlacement,
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Placement, Boundary, ComputePositionReturn, ComputePositionConfig } from '@floating-ui/dom';
1
+ import { Placement, Boundary, ComputePositionReturn } from '@floating-ui/dom';
2
2
  export { Placement } from '@floating-ui/dom';
3
3
  import { AutoUpdateOptions } from './auto-update.js';
4
4
 
@@ -54,9 +54,7 @@ type PositioningOptions = {
54
54
  /**
55
55
  * Function called when the placement is computed
56
56
  */
57
- onComplete?(data: ComputePositionReturn & {
58
- compute: (config?: Omit<ComputePositionConfig, "platform">) => void;
59
- }): void;
57
+ onComplete?(data: ComputePositionReturn): void;
60
58
  /**
61
59
  * Function called on cleanup of all listeners
62
60
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/popper",
3
- "version": "0.2.4",
3
+ "version": "0.2.7",
4
4
  "description": "Dynamic positioning logic for ui machines",
5
5
  "keywords": [
6
6
  "js",
@@ -22,10 +22,10 @@
22
22
  "url": "https://github.com/chakra-ui/zag/issues"
23
23
  },
24
24
  "dependencies": {
25
- "@floating-ui/dom": "1.2.1",
26
- "@zag-js/dom-query": "0.1.3",
27
- "@zag-js/utils": "0.3.3",
28
- "@zag-js/element-rect": "0.2.2"
25
+ "@floating-ui/dom": "1.2.5",
26
+ "@zag-js/dom-query": "0.1.4",
27
+ "@zag-js/element-rect": "0.3.0",
28
+ "@zag-js/utils": "0.3.4"
29
29
  },
30
30
  "devDependencies": {
31
31
  "clean-package": "2.2.0"