@inspecto-dev/core 0.3.5 → 0.3.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.
@@ -2928,7 +2928,7 @@ function createBadge(ctx) {
2928
2928
  const state = asLauncherContext(ctx);
2929
2929
  const btn = document.createElement("div");
2930
2930
  btn.className = badgeClass;
2931
- btn.style.display = "flex";
2931
+ btn.style.visibility = "hidden";
2932
2932
  const indicator = document.createElement("span");
2933
2933
  indicator.className = `${badgeClass}-indicator`;
2934
2934
  indicator.dataset.inspectoLauncherIndicator = "true";
@@ -3013,14 +3013,85 @@ function createBadge(ctx) {
3013
3013
  titleBlock.append(titleSpan, stateSpan);
3014
3014
  content.append(indicator, titleBlock);
3015
3015
  btn.append(content, eyes, panel);
3016
+ let isDragging = false;
3017
+ let dragStartX = 0;
3018
+ let dragStartY = 0;
3019
+ let initialBadgeX = 0;
3020
+ let initialBadgeY = 0;
3021
+ const handleDragStart = (e) => {
3022
+ const target = e.target;
3023
+ if (target.closest(`.${badgeClass}-panel`) || target.closest(`[data-inspecto-launcher-action]`)) {
3024
+ return;
3025
+ }
3026
+ if (e.type === "mousedown" && e.button !== 0) return;
3027
+ const clientX = e.type === "touchstart" ? e.touches[0].clientX : e.clientX;
3028
+ const clientY = e.type === "touchstart" ? e.touches[0].clientY : e.clientY;
3029
+ dragStartX = clientX;
3030
+ dragStartY = clientY;
3031
+ const rect = btn.getBoundingClientRect();
3032
+ initialBadgeX = rect.left;
3033
+ initialBadgeY = rect.top;
3034
+ isDragging = false;
3035
+ document.addEventListener("mousemove", handleDragMove, { passive: false });
3036
+ document.addEventListener("mouseup", handleDragEnd);
3037
+ document.addEventListener("touchmove", handleDragMove, { passive: false });
3038
+ document.addEventListener("touchend", handleDragEnd);
3039
+ };
3040
+ const handleDragMove = (e) => {
3041
+ const clientX = e.type === "touchmove" ? e.touches[0].clientX : e.clientX;
3042
+ const clientY = e.type === "touchmove" ? e.touches[0].clientY : e.clientY;
3043
+ const dx = clientX - dragStartX;
3044
+ const dy = clientY - dragStartY;
3045
+ if (!isDragging && Math.hypot(dx, dy) > 5) {
3046
+ isDragging = true;
3047
+ btn.style.transition = "none";
3048
+ }
3049
+ if (isDragging) {
3050
+ e.preventDefault();
3051
+ const maxX = window.innerWidth - btn.offsetWidth;
3052
+ const maxY = window.innerHeight - btn.offsetHeight;
3053
+ let newX = initialBadgeX + dx;
3054
+ let newY = initialBadgeY + dy;
3055
+ newX = Math.max(0, Math.min(newX, maxX));
3056
+ newY = Math.max(0, Math.min(newY, maxY));
3057
+ btn.style.bottom = "auto";
3058
+ btn.style.right = "auto";
3059
+ btn.style.left = `${newX}px`;
3060
+ btn.style.top = `${newY}px`;
3061
+ }
3062
+ };
3063
+ const handleDragEnd = () => {
3064
+ document.removeEventListener("mousemove", handleDragMove);
3065
+ document.removeEventListener("mouseup", handleDragEnd);
3066
+ document.removeEventListener("touchmove", handleDragMove);
3067
+ document.removeEventListener("touchend", handleDragEnd);
3068
+ if (isDragging) {
3069
+ btn.style.transition = "";
3070
+ setTimeout(() => {
3071
+ isDragging = false;
3072
+ }, 0);
3073
+ }
3074
+ };
3075
+ btn.addEventListener("mousedown", handleDragStart);
3076
+ btn.addEventListener("touchstart", handleDragStart, { passive: false });
3016
3077
  btn.addEventListener("click", (event) => {
3017
3078
  var _a2, _b;
3079
+ if (isDragging) {
3080
+ event.preventDefault();
3081
+ event.stopPropagation();
3082
+ return;
3083
+ }
3018
3084
  if ((_b = (_a2 = event.target).closest) == null ? void 0 : _b.call(_a2, `[data-inspecto-launcher-action]`)) return;
3019
3085
  state.launcherPanelOpen = !state.launcherPanelOpen;
3020
3086
  state.updateBadgeContent();
3021
3087
  });
3022
3088
  state.shadowRootEl.appendChild(btn);
3023
3089
  updateLauncherEye(state);
3090
+ requestAnimationFrame(() => {
3091
+ requestAnimationFrame(() => {
3092
+ btn.style.visibility = "";
3093
+ });
3094
+ });
3024
3095
  return btn;
3025
3096
  }
3026
3097
  function setPaused(ctx, value) {
@@ -3854,8 +3925,70 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
3854
3925
  };
3855
3926
  updatePosition();
3856
3927
  menu.style.visibility = "visible";
3857
- setTimeout(() => input.focus(), 0);
3928
+ const teardownDocFocusGuards = () => {
3929
+ document.removeEventListener("focusin", onDocFocusIn, true);
3930
+ document.removeEventListener("focusout", onDocFocusOut, true);
3931
+ };
3932
+ const onDocFocusIn = (e) => {
3933
+ var _a3, _b2;
3934
+ if (!menu.isConnected) {
3935
+ teardownDocFocusGuards();
3936
+ return;
3937
+ }
3938
+ const path = (_b2 = (_a3 = e.composedPath) == null ? void 0 : _a3.call(e)) != null ? _b2 : [];
3939
+ if (path.includes(menu)) {
3940
+ e.stopImmediatePropagation();
3941
+ }
3942
+ };
3943
+ const onDocFocusOut = (e) => {
3944
+ if (!menu.isConnected) {
3945
+ teardownDocFocusGuards();
3946
+ return;
3947
+ }
3948
+ const related = e.relatedTarget;
3949
+ if (!related) return;
3950
+ if (related === shadowRoot.host) {
3951
+ e.stopImmediatePropagation();
3952
+ return;
3953
+ }
3954
+ if (related instanceof Node && menu.contains(related)) {
3955
+ e.stopImmediatePropagation();
3956
+ }
3957
+ };
3958
+ document.addEventListener("focusin", onDocFocusIn, true);
3959
+ document.addEventListener("focusout", onDocFocusOut, true);
3960
+ const focusAskInput = () => {
3961
+ try {
3962
+ input.focus({ preventScroll: true });
3963
+ } catch (e) {
3964
+ input.focus();
3965
+ }
3966
+ };
3967
+ const isAskInputFocused = () => {
3968
+ try {
3969
+ return shadowRoot.activeElement === input;
3970
+ } catch (e) {
3971
+ return false;
3972
+ }
3973
+ };
3974
+ focusAskInput();
3975
+ const rafId = requestAnimationFrame(() => {
3976
+ if (!menu.isConnected) return;
3977
+ if (!isAskInputFocused()) focusAskInput();
3978
+ });
3979
+ const focusTimeoutId = setTimeout(() => {
3980
+ if (!menu.isConnected) return;
3981
+ if (!isAskInputFocused()) focusAskInput();
3982
+ }, 50);
3858
3983
  const onDocClick = (e) => {
3984
+ const eventTarget = e.target;
3985
+ if (eventTarget) {
3986
+ if (eventTarget.closest(
3987
+ '[role="dialog"], [role="menu"], [role="tooltip"], [role="presentation"], [role="listbox"], [data-radix-popper-content-wrapper], [data-radix-focus-guard]'
3988
+ )) {
3989
+ return;
3990
+ }
3991
+ }
3859
3992
  const path = e.composedPath();
3860
3993
  if (path.includes(menu)) return;
3861
3994
  cleanup();
@@ -3863,6 +3996,9 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
3863
3996
  setTimeout(() => document.addEventListener("click", onDocClick, { capture: true }), 0);
3864
3997
  function cleanup() {
3865
3998
  document.removeEventListener("click", onDocClick, { capture: true });
3999
+ teardownDocFocusGuards();
4000
+ cancelAnimationFrame(rafId);
4001
+ clearTimeout(focusTimeoutId);
3866
4002
  menu.remove();
3867
4003
  onClose();
3868
4004
  }
@@ -4672,6 +4808,14 @@ function handleMouseMove(ctx, event) {
4672
4808
  state.lastPointerY = event.clientY;
4673
4809
  state.updateLauncherEye();
4674
4810
  if (state.cleanupMenu !== null) {
4811
+ const eventTarget = event.target;
4812
+ if (eventTarget) {
4813
+ if (eventTarget.closest(
4814
+ '[role="dialog"], [role="menu"], [role="tooltip"], [role="presentation"], [role="listbox"], [data-radix-popper-content-wrapper], [data-radix-focus-guard]'
4815
+ )) {
4816
+ return;
4817
+ }
4818
+ }
4675
4819
  state.overlay.hide();
4676
4820
  return;
4677
4821
  }
@@ -4697,7 +4841,17 @@ function handleMouseMove(ctx, event) {
4697
4841
  }
4698
4842
  function handleTrigger(ctx, event) {
4699
4843
  const state = asInteractionContext(ctx);
4700
- if (state.cleanupMenu !== null) return;
4844
+ if (state.cleanupMenu !== null) {
4845
+ const eventTarget = event.target;
4846
+ if (eventTarget) {
4847
+ if (eventTarget.closest(
4848
+ '[role="dialog"], [role="menu"], [role="tooltip"], [role="presentation"], [role="listbox"], [data-radix-popper-content-wrapper], [data-radix-focus-guard]'
4849
+ )) {
4850
+ return;
4851
+ }
4852
+ }
4853
+ return;
4854
+ }
4701
4855
  if (!state.isInspectorActive(event)) return;
4702
4856
  const target = findInspectable(event.target);
4703
4857
  if (!target) return;
@@ -5778,6 +5932,7 @@ function createOverlay(shadowRoot) {
5778
5932
  overlay.style.display = "none";
5779
5933
  const tooltip = document.createElement("div");
5780
5934
  tooltip.className = tooltipClass;
5935
+ tooltip.style.display = "none";
5781
5936
  const tagSpan = document.createElement("span");
5782
5937
  tagSpan.className = tagClass;
5783
5938
  const idSpan = document.createElement("span");
@@ -6401,4 +6556,4 @@ if (typeof customElements !== "undefined" && !customElements.get("inspecto-overl
6401
6556
  export {
6402
6557
  InspectoElement
6403
6558
  };
6404
- //# sourceMappingURL=component-RQ76TEPZ.js.map
6559
+ //# sourceMappingURL=component-PVWVSPVZ.js.map