@zag-js/tooltip 0.2.5 → 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.
package/dist/index.js CHANGED
@@ -31,10 +31,12 @@ var import_anatomy = require("@zag-js/anatomy");
31
31
  var anatomy = (0, import_anatomy.createAnatomy)("tooltip").parts("trigger", "arrow", "arrowTip", "positioner", "content", "label");
32
32
  var parts = anatomy.build();
33
33
 
34
- // ../../utilities/dom/dist/index.mjs
34
+ // ../../utilities/dom/src/attrs.ts
35
35
  var dataAttr = (guard) => {
36
36
  return guard ? "" : void 0;
37
37
  };
38
+
39
+ // ../../utilities/dom/src/get-computed-style.ts
38
40
  function getCache() {
39
41
  const g = globalThis;
40
42
  g.__styleCache = g.__styleCache || /* @__PURE__ */ new WeakMap();
@@ -53,13 +55,28 @@ function getComputedStyle(el) {
53
55
  }
54
56
  return style;
55
57
  }
58
+
59
+ // ../../utilities/core/src/functions.ts
56
60
  var runIfFn = (v, ...a) => {
57
61
  const res = typeof v === "function" ? v(...a) : v;
58
62
  return res != null ? res : void 0;
59
63
  };
64
+
65
+ // ../../utilities/core/src/guard.ts
60
66
  var isArray = (v) => Array.isArray(v);
61
67
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
62
68
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
69
+
70
+ // ../../utilities/core/src/object.ts
71
+ function compact(obj) {
72
+ if (obj === void 0)
73
+ return obj;
74
+ return Object.fromEntries(
75
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
76
+ );
77
+ }
78
+
79
+ // ../../utilities/dom/src/platform.ts
63
80
  var isDom = () => typeof window !== "undefined";
64
81
  function getPlatform() {
65
82
  var _a;
@@ -70,6 +87,8 @@ var pt = (v) => isDom() && v.test(getPlatform());
70
87
  var vn = (v) => isDom() && v.test(navigator.vendor);
71
88
  var isSafari = () => isApple() && vn(/apple/i);
72
89
  var isApple = () => pt(/mac|iphone|ipad|ipod/i);
90
+
91
+ // ../../utilities/dom/src/query.ts
73
92
  function isDocument(el) {
74
93
  return el.nodeType === Node.DOCUMENT_NODE;
75
94
  }
@@ -110,25 +129,7 @@ function defineDomHelpers(helpers) {
110
129
  return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
111
130
  },
112
131
  getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
113
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
114
- createEmitter: (ctx, target) => {
115
- const win = dom2.getWin(ctx);
116
- return function emit(evt, detail, options) {
117
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
118
- const eventName = `zag:${evt}`;
119
- const init = { bubbles, cancelable, composed, detail };
120
- const event = new win.CustomEvent(eventName, init);
121
- target.dispatchEvent(event);
122
- };
123
- },
124
- createListener: (target) => {
125
- return function listen(evt, handler) {
126
- const eventName = `zag:${evt}`;
127
- const listener = (e) => handler(e);
128
- target.addEventListener(eventName, listener);
129
- return () => target.removeEventListener(eventName, listener);
130
- };
131
- }
132
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
132
133
  };
133
134
  return {
134
135
  ...dom2,
@@ -138,14 +139,18 @@ function defineDomHelpers(helpers) {
138
139
  function isHTMLElement(v) {
139
140
  return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
140
141
  }
142
+
143
+ // ../../utilities/dom/src/event.ts
141
144
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
142
145
  var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
143
146
  var supportsMouseEvent = () => isDom() && window.onmousedown === null;
144
147
  var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
148
+
149
+ // ../../utilities/dom/src/listener.ts
145
150
  var isRef = (v) => hasProp(v, "current");
146
- var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
151
+ var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
147
152
  function extractInfo(event, type = "page") {
148
- const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
153
+ const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
149
154
  return {
150
155
  point: {
151
156
  x: point[`${type}X`],
@@ -175,8 +180,8 @@ function filterPrimaryPointer(fn) {
175
180
  return (event) => {
176
181
  var _a;
177
182
  const win = (_a = event.view) != null ? _a : window;
178
- const isMouseEvent2 = event instanceof win.MouseEvent;
179
- const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
183
+ const isMouseEvent = event instanceof win.MouseEvent;
184
+ const isPrimary = !isMouseEvent || isMouseEvent && event.button === 0;
180
185
  if (isPrimary)
181
186
  fn(event);
182
187
  };
@@ -206,15 +211,21 @@ function getEventName(evt) {
206
211
  return mouseEventNames[evt];
207
212
  return evt;
208
213
  }
214
+
215
+ // ../../utilities/dom/src/next-tick.ts
209
216
  function raf(fn) {
210
217
  const id = globalThis.requestAnimationFrame(fn);
211
218
  return function cleanup() {
212
219
  globalThis.cancelAnimationFrame(id);
213
220
  };
214
221
  }
222
+
223
+ // ../../utilities/dom/src/pointerlock.ts
215
224
  function addPointerlockChangeListener(doc, fn) {
216
225
  return addDomEvent(doc, "pointerlockchange", fn, false);
217
226
  }
227
+
228
+ // ../../utilities/dom/src/scrollable.ts
218
229
  function isScrollParent(el) {
219
230
  const { overflow, overflowX, overflowY } = getComputedStyle(el);
220
231
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
@@ -238,6 +249,8 @@ function getScrollParents(el, list = []) {
238
249
  return parents;
239
250
  return parents.concat(getScrollParents(getParent(target)));
240
251
  }
252
+
253
+ // ../../utilities/dom/src/visually-hidden.ts
241
254
  var visuallyHiddenStyle = {
242
255
  border: "0",
243
256
  clip: "rect(0 0 0 0)",
@@ -408,19 +421,6 @@ function connect(state, send, normalize) {
408
421
  // src/tooltip.machine.ts
409
422
  var import_core2 = require("@zag-js/core");
410
423
  var import_popper2 = require("@zag-js/popper");
411
-
412
- // ../../utilities/core/dist/index.mjs
413
- var isArray2 = (v) => Array.isArray(v);
414
- var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
415
- function compact(obj) {
416
- if (obj === void 0)
417
- return obj;
418
- return Object.fromEntries(
419
- Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject2(value) ? compact(value) : value])
420
- );
421
- }
422
-
423
- // src/tooltip.machine.ts
424
424
  function machine(userContext) {
425
425
  const ctx = compact(userContext);
426
426
  return (0, import_core2.createMachine)(