Typescript fixes

This commit is contained in:
Knut Sveidqvist 2024-10-30 13:32:03 +01:00
parent c1ca3511c4
commit 8ef5d324fd
2 changed files with 11 additions and 9 deletions

View File

@ -27,7 +27,7 @@ export async function kanbanItem<T extends SVGGraphicsElement>(
{ config }: ShapeRenderOptions { config }: ShapeRenderOptions
) { ) {
const { labelStyles, nodeStyles } = styles2String(kanbanNode); const { labelStyles, nodeStyles } = styles2String(kanbanNode);
kanbanNode.labelStyle = labelStyles; kanbanNode.labelStyle = labelStyles || '';
const labelPaddingX = 10; const labelPaddingX = 10;
const orgWidth = kanbanNode.width; const orgWidth = kanbanNode.width;
@ -54,11 +54,10 @@ export async function kanbanItem<T extends SVGGraphicsElement>(
const options = { const options = {
useHtmlLabels: kanbanNode.useHtmlLabels, useHtmlLabels: kanbanNode.useHtmlLabels,
labelStyle: kanbanNode.labelStyle, labelStyle: kanbanNode.labelStyle || '',
width: kanbanNode.width, width: kanbanNode.width,
icon: kanbanNode.icon,
img: kanbanNode.img, img: kanbanNode.img,
padding: kanbanNode.padding, padding: kanbanNode.padding || 8,
centerLabel: false, centerLabel: false,
}; };
let labelEl, bbox2; let labelEl, bbox2;
@ -121,15 +120,15 @@ export async function kanbanItem<T extends SVGGraphicsElement>(
: rc.rectangle(x, y, totalWidth, totalHeight, options); : rc.rectangle(x, y, totalWidth, totalHeight, options);
rect = shapeSvg.insert(() => roughNode, ':first-child'); rect = shapeSvg.insert(() => roughNode, ':first-child');
rect.attr('class', 'basic label-container').attr('style', cssStyles); rect.attr('class', 'basic label-container').attr('style', cssStyles ? cssStyles : null);
} else { } else {
rect = shapeSvg.insert('rect', ':first-child'); rect = shapeSvg.insert('rect', ':first-child');
rect rect
.attr('class', 'basic label-container __APA__') .attr('class', 'basic label-container __APA__')
.attr('style', nodeStyles) .attr('style', nodeStyles)
.attr('rx', rx) .attr('rx', rx ?? 5)
.attr('ry', ry) .attr('ry', ry ?? 5)
.attr('x', x) .attr('x', x)
.attr('y', y) .attr('y', y)
.attr('width', totalWidth) .attr('width', totalWidth)
@ -137,7 +136,7 @@ export async function kanbanItem<T extends SVGGraphicsElement>(
const priority = 'priority' in kanbanNode && kanbanNode.priority; const priority = 'priority' in kanbanNode && kanbanNode.priority;
if (priority) { if (priority) {
const line = shapeSvg.append('line', ':first-child'); const line = shapeSvg.append('line');
const lineX = x + 2; const lineX = x + 2;
const y1 = y + Math.floor((rx ?? 0) / 2); const y1 = y + Math.floor((rx ?? 0) / 2);

View File

@ -133,7 +133,10 @@ export const insertLabel = async <T extends SVGGraphicsElement>(
const useHtmlLabels = options.useHtmlLabels || evaluate(getConfig()?.flowchart?.htmlLabels); const useHtmlLabels = options.useHtmlLabels || evaluate(getConfig()?.flowchart?.htmlLabels);
// Create the label and insert it after the rect // Create the label and insert it after the rect
const labelEl = parent.insert('g').attr('class', 'label').attr('style', options.labelStyle); const labelEl = parent
.insert('g')
.attr('class', 'label')
.attr('style', options.labelStyle || '');
const text = await createText(labelEl, sanitizeText(decodeEntities(label), getConfig()), { const text = await createText(labelEl, sanitizeText(decodeEntities(label), getConfig()), {
useHtmlLabels, useHtmlLabels,