mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-04 08:06:43 +02:00
refactor: Fir classDB types
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
// @ts-nocheck - don't check until handle it
|
|
||||||
import type { Selection } from 'd3';
|
import type { Selection } from 'd3';
|
||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { log } from '../../logger.js';
|
import { log } from '../../logger.js';
|
||||||
@@ -71,21 +70,21 @@ export const setClassLabel = function (id: string, label: string) {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export const addClass = function (id: string) {
|
export const addClass = function (id: string) {
|
||||||
const classId = splitClassNameAndType(id);
|
const { className, type } = splitClassNameAndType(id);
|
||||||
// Only add class if not exists
|
// Only add class if not exists
|
||||||
if (classes[classId.className] !== undefined) {
|
if (Object.hasOwn(classes, className)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
classes[classId.className] = {
|
classes[className] = {
|
||||||
id: classId.className,
|
id: className,
|
||||||
type: classId.type,
|
type: type,
|
||||||
label: classId.className,
|
label: className,
|
||||||
cssClasses: [],
|
cssClasses: [],
|
||||||
methods: [],
|
methods: [],
|
||||||
members: [],
|
members: [],
|
||||||
annotations: [],
|
annotations: [],
|
||||||
domId: MERMAID_DOM_ID_PREFIX + classId.className + '-' + classCounter,
|
domId: MERMAID_DOM_ID_PREFIX + className + '-' + classCounter,
|
||||||
} as ClassNode;
|
} as ClassNode;
|
||||||
|
|
||||||
classCounter++;
|
classCounter++;
|
||||||
@@ -368,6 +367,7 @@ export const relationType = {
|
|||||||
const setupToolTips = function (element: Element) {
|
const setupToolTips = function (element: Element) {
|
||||||
let tooltipElem: Selection<HTMLDivElement, unknown, HTMLElement, unknown> =
|
let tooltipElem: Selection<HTMLDivElement, unknown, HTMLElement, unknown> =
|
||||||
select('.mermaidTooltip');
|
select('.mermaidTooltip');
|
||||||
|
// @ts-expect-error - Incorrect types
|
||||||
if ((tooltipElem._groups || tooltipElem)[0][0] === null) {
|
if ((tooltipElem._groups || tooltipElem)[0][0] === null) {
|
||||||
tooltipElem = select('body').append('div').attr('class', 'mermaidTooltip').style('opacity', 0);
|
tooltipElem = select('body').append('div').attr('class', 'mermaidTooltip').style('opacity', 0);
|
||||||
}
|
}
|
||||||
@@ -377,7 +377,6 @@ const setupToolTips = function (element: Element) {
|
|||||||
const nodes = svg.selectAll('g.node');
|
const nodes = svg.selectAll('g.node');
|
||||||
nodes
|
nodes
|
||||||
.on('mouseover', function () {
|
.on('mouseover', function () {
|
||||||
// @ts-expect-error - select is not part of the d3 type definition
|
|
||||||
const el = select(this);
|
const el = select(this);
|
||||||
const title = el.attr('title');
|
const title = el.attr('title');
|
||||||
// Don't try to draw a tooltip if no data is provided
|
// Don't try to draw a tooltip if no data is provided
|
||||||
@@ -387,6 +386,7 @@ const setupToolTips = function (element: Element) {
|
|||||||
// @ts-ignore - getBoundingClientRect is not part of the d3 type definition
|
// @ts-ignore - getBoundingClientRect is not part of the d3 type definition
|
||||||
const rect = this.getBoundingClientRect();
|
const rect = this.getBoundingClientRect();
|
||||||
|
|
||||||
|
// @ts-expect-error - Incorrect types
|
||||||
tooltipElem.transition().duration(200).style('opacity', '.9');
|
tooltipElem.transition().duration(200).style('opacity', '.9');
|
||||||
tooltipElem
|
tooltipElem
|
||||||
.text(el.attr('title'))
|
.text(el.attr('title'))
|
||||||
@@ -396,8 +396,8 @@ const setupToolTips = function (element: Element) {
|
|||||||
el.classed('hover', true);
|
el.classed('hover', true);
|
||||||
})
|
})
|
||||||
.on('mouseout', function () {
|
.on('mouseout', function () {
|
||||||
|
// @ts-expect-error - Incorrect types
|
||||||
tooltipElem.transition().duration(500).style('opacity', 0);
|
tooltipElem.transition().duration(500).style('opacity', 0);
|
||||||
// @ts-expect-error - select is not part of the d3 type definition
|
|
||||||
const el = select(this);
|
const el = select(this);
|
||||||
el.classed('hover', false);
|
el.classed('hover', false);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user