Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/few-eyes-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@studiocms/ui": patch
---

Fixes global window augmentation for tooltips (no user-facing changes, just better types!)
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@
"material-icon-theme.files.associations": {
"*.e2e.ts": "playwright",
"*.test.ts": "vitest"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
4 changes: 0 additions & 4 deletions packages/studiocms_ui/src/components/Tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ function loadTooltips() {
const anchor = tooltipInstance.getAnchor();
const popup = tooltipInstance.tooltip;

// @ts-expect-error
window.sui.tooltips.instances.set(tooltipInstance.container.id, tooltipInstance);

anchor.addEventListener('mouseenter', () => {
Expand Down Expand Up @@ -394,11 +393,8 @@ function loadTooltips() {
});
}

// TODO: Investigate why global type definitions are not being recognized
// @ts-expect-error
window.sui = window.sui ?? {};

// @ts-expect-error
window.sui.tooltips = {
instances: new Map<string, Tooltip>(),

Expand Down
26 changes: 14 additions & 12 deletions packages/studiocms_ui/src/events.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/** biome-ignore-all lint/correctness/noUnusedVariables: Global augments */

/**
* CustomEventMap defines the custom events used in the application.
*
Expand Down Expand Up @@ -39,6 +41,18 @@ interface SuiTooltipApi {
hide: (id: string) => void;
}

interface Window {
/**
* The StudioCMS UI API, which includes various tools and utilities for the UI.
*/
sui: {
/**
* The tooltip API, which provides methods for managing tooltips in the UI.
*/
tooltips: SuiTooltipApi;
};
}

/**
* Extends the global `Document` interface to include custom event handling methods.
*
Expand Down Expand Up @@ -89,16 +103,4 @@ declare global {
*/
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K]): void;
}

interface Window {
/**
* The StudioCMS UI API, which includes various tools and utilities for the UI.
*/
sui: {
/**
* The tooltip API, which provides methods for managing tooltips in the UI.
*/
tooltips: SuiTooltipApi;
};
}
}
Loading