uidex 0.5.0 → 0.5.2

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.cts CHANGED
@@ -434,6 +434,11 @@ interface InspectorOptions {
434
434
  x: number;
435
435
  y: number;
436
436
  }) => void;
437
+ /** Fired when the cursor enters an iframe or otherwise leaves the inspectable document. */
438
+ onObscured?: (cursor: {
439
+ x: number;
440
+ y: number;
441
+ }) => void;
437
442
  }
438
443
  interface Inspector {
439
444
  mount(): void;
package/dist/index.d.ts CHANGED
@@ -434,6 +434,11 @@ interface InspectorOptions {
434
434
  x: number;
435
435
  y: number;
436
436
  }) => void;
437
+ /** Fired when the cursor enters an iframe or otherwise leaves the inspectable document. */
438
+ onObscured?: (cursor: {
439
+ x: number;
440
+ y: number;
441
+ }) => void;
437
442
  }
438
443
  interface Inspector {
439
444
  mount(): void;
package/dist/index.js CHANGED
@@ -1300,6 +1300,9 @@ var tailwind_built_default = `/*! tailwindcss v4.2.2 | MIT License | https://tai
1300
1300
  .w-4 {
1301
1301
  width: calc(var(--spacing) * 4);
1302
1302
  }
1303
+ .w-12 {
1304
+ width: calc(var(--spacing) * 12);
1305
+ }
1303
1306
  .w-20 {
1304
1307
  width: calc(var(--spacing) * 20);
1305
1308
  }
@@ -3481,16 +3484,18 @@ function createCursorTooltip(deps) {
3481
3484
  const renderBody = () => {
3482
3485
  body.replaceChildren();
3483
3486
  if (typeof currentContent === "string") {
3484
- applyColor(DEFAULT_TOOLTIP_COLOR);
3487
+ applyColor("#a1a1aa");
3488
+ el2.style.opacity = "0.6";
3485
3489
  body.append(document.createTextNode(currentContent));
3486
3490
  return;
3487
3491
  }
3488
3492
  if (!currentContent) return;
3493
+ el2.style.opacity = "1";
3489
3494
  const { entity, node } = currentContent;
3490
3495
  const style = KIND_STYLE[entity.kind];
3491
3496
  const demoted = entity.kind === "primitive";
3492
3497
  applyColor(style?.color ?? DEFAULT_TOOLTIP_COLOR);
3493
- el2.style.opacity = demoted ? "0.55" : "1";
3498
+ if (demoted) el2.style.opacity = "0.55";
3494
3499
  if (style) {
3495
3500
  const svg2 = createLucideElement(style.icon);
3496
3501
  svg2.setAttribute("aria-hidden", "true");
@@ -3651,7 +3656,8 @@ function createInspector(options) {
3651
3656
  resolveAll = (target) => defaultResolveAllMatches(target, registry),
3652
3657
  onHover,
3653
3658
  onSelect,
3654
- onCycle
3659
+ onCycle,
3660
+ onObscured
3655
3661
  } = options;
3656
3662
  let mounted = false;
3657
3663
  let currentEl = null;
@@ -3660,6 +3666,13 @@ function createInspector(options) {
3660
3666
  let layerIndex = 0;
3661
3667
  let lastCursor = { x: 0, y: 0 };
3662
3668
  const makeStack = () => stack.length > 0 ? { matches: stack, index: layerIndex, current: stack[layerIndex] } : null;
3669
+ const onDocumentLeave = () => {
3670
+ currentEl = null;
3671
+ stack = [];
3672
+ layerIndex = 0;
3673
+ session.highlight.unhover();
3674
+ onObscured?.(lastCursor);
3675
+ };
3663
3676
  const onMouseMove = (e) => {
3664
3677
  if (!(e.target instanceof Element)) return;
3665
3678
  const matches = resolveAll(e.target);
@@ -3712,6 +3725,7 @@ function createInspector(options) {
3712
3725
  document.head.appendChild(cursorStyleEl);
3713
3726
  }
3714
3727
  document.addEventListener("mousemove", onMouseMove);
3728
+ document.addEventListener("mouseleave", onDocumentLeave);
3715
3729
  document.addEventListener("click", onClick, true);
3716
3730
  document.addEventListener("contextmenu", onContextMenu, true);
3717
3731
  },
@@ -3726,6 +3740,7 @@ function createInspector(options) {
3726
3740
  cursorStyleEl = null;
3727
3741
  }
3728
3742
  document.removeEventListener("mousemove", onMouseMove);
3743
+ document.removeEventListener("mouseleave", onDocumentLeave);
3729
3744
  document.removeEventListener("click", onClick, true);
3730
3745
  document.removeEventListener("contextmenu", onContextMenu, true);
3731
3746
  session.highlight.unhover();
@@ -4633,6 +4648,10 @@ function createSurfaceShell(options) {
4633
4648
  },
4634
4649
  onCycle: (stack, cursor) => {
4635
4650
  showStack(stack, cursor);
4651
+ },
4652
+ onObscured: (cursor) => {
4653
+ overlay.hide();
4654
+ tooltip.update("iframe", cursor);
4636
4655
  }
4637
4656
  });
4638
4657
  cleanup.add(inspector);