@diagrammo/dgmo 0.5.1 → 0.5.3

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.cjs CHANGED
@@ -19433,7 +19433,7 @@ function buildEventTooltipHtml(ev) {
19433
19433
  function buildEraTooltipHtml(era) {
19434
19434
  return `<strong>${era.label}</strong><br>${formatDateLabel(era.startDate)} \u2192 ${formatDateLabel(era.endDate)}`;
19435
19435
  }
19436
- function renderTimeline(container, parsed, palette, isDark, onClickItem, exportDims, activeTagGroup, swimlaneTagGroup, onTagStateChange) {
19436
+ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportDims, activeTagGroup, swimlaneTagGroup, onTagStateChange, viewMode) {
19437
19437
  d3Selection12.select(container).selectAll(":not([data-d3-tooltip])").remove();
19438
19438
  const {
19439
19439
  timelineEvents,
@@ -20198,27 +20198,36 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
20198
20198
  exportDims,
20199
20199
  currentActiveGroup,
20200
20200
  currentSwimlaneGroup,
20201
- onTagStateChange
20201
+ onTagStateChange,
20202
+ viewMode
20202
20203
  );
20203
20204
  }, drawLegend2 = function() {
20204
20205
  mainSvg.selectAll(".tl-tag-legend-group").remove();
20205
- const totalW = legendGroups.reduce((s, lg) => {
20206
- const isActive = currentActiveGroup != null && lg.group.name.toLowerCase() === currentActiveGroup.toLowerCase();
20206
+ const effectiveColorKey = (currentActiveGroup ?? currentSwimlaneGroup)?.toLowerCase() ?? null;
20207
+ const visibleGroups = viewMode ? legendGroups.filter(
20208
+ (lg) => effectiveColorKey != null && lg.group.name.toLowerCase() === effectiveColorKey
20209
+ ) : legendGroups;
20210
+ if (visibleGroups.length === 0) return;
20211
+ const totalW = visibleGroups.reduce((s, lg) => {
20212
+ const isActive = viewMode || currentActiveGroup != null && lg.group.name.toLowerCase() === currentActiveGroup.toLowerCase();
20207
20213
  return s + (isActive ? lg.expandedWidth : lg.minifiedWidth);
20208
- }, 0) + (legendGroups.length - 1) * LG_GROUP_GAP;
20214
+ }, 0) + (visibleGroups.length - 1) * LG_GROUP_GAP;
20209
20215
  let cx = (width - totalW) / 2;
20210
- for (const lg of legendGroups) {
20216
+ for (const lg of visibleGroups) {
20211
20217
  const groupKey = lg.group.name.toLowerCase();
20212
- const isActive = currentActiveGroup != null && currentActiveGroup.toLowerCase() === groupKey;
20218
+ const isActive = viewMode || currentActiveGroup != null && currentActiveGroup.toLowerCase() === groupKey;
20213
20219
  const isSwimActive = currentSwimlaneGroup != null && currentSwimlaneGroup.toLowerCase() === groupKey;
20214
20220
  const pillLabel = lg.group.name;
20215
20221
  const pillWidth = pillLabel.length * LG_PILL_FONT_W + LG_PILL_PAD;
20216
- const gEl = mainSvg.append("g").attr("transform", `translate(${cx}, ${legendY})`).attr("class", "tl-tag-legend-group tl-tag-legend-entry").attr("data-legend-group", groupKey).attr("data-tag-group", groupKey).attr("data-legend-entry", "__group__").style("cursor", "pointer").on("click", () => {
20217
- currentActiveGroup = currentActiveGroup === groupKey ? null : groupKey;
20218
- drawLegend2();
20219
- recolorEvents2();
20220
- onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20221
- });
20222
+ const gEl = mainSvg.append("g").attr("transform", `translate(${cx}, ${legendY})`).attr("class", "tl-tag-legend-group tl-tag-legend-entry").attr("data-legend-group", groupKey).attr("data-tag-group", groupKey).attr("data-legend-entry", "__group__");
20223
+ if (!viewMode) {
20224
+ gEl.style("cursor", "pointer").on("click", () => {
20225
+ currentActiveGroup = currentActiveGroup === groupKey ? null : groupKey;
20226
+ drawLegend2();
20227
+ recolorEvents2();
20228
+ onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20229
+ });
20230
+ }
20222
20231
  if (isActive) {
20223
20232
  gEl.append("rect").attr("width", lg.expandedWidth).attr("height", LG_HEIGHT).attr("rx", LG_HEIGHT / 2).attr("fill", groupBg);
20224
20233
  }
@@ -20231,36 +20240,44 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
20231
20240
  }
20232
20241
  gEl.append("text").attr("x", pillXOff + pillWidth / 2).attr("y", LG_HEIGHT / 2 + LG_PILL_FONT_SIZE / 2 - 2).attr("font-size", LG_PILL_FONT_SIZE).attr("font-weight", "500").attr("font-family", FONT_FAMILY).attr("fill", isActive ? palette.text : palette.textMuted).attr("text-anchor", "middle").text(pillLabel);
20233
20242
  if (isActive) {
20234
- const iconX = pillXOff + pillWidth + 5;
20235
- const iconY = (LG_HEIGHT - 10) / 2;
20236
- const iconEl = drawSwimlaneIcon2(gEl, iconX, iconY, isSwimActive);
20237
- iconEl.attr("data-swimlane-toggle", groupKey).on("click", (event) => {
20238
- event.stopPropagation();
20239
- currentSwimlaneGroup = currentSwimlaneGroup === groupKey ? null : groupKey;
20240
- onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20241
- relayout2();
20242
- });
20243
- let entryX = pillXOff + pillWidth + LG_ICON_W + 4;
20243
+ let entryX;
20244
+ if (!viewMode) {
20245
+ const iconX = pillXOff + pillWidth + 5;
20246
+ const iconY = (LG_HEIGHT - 10) / 2;
20247
+ const iconEl = drawSwimlaneIcon2(gEl, iconX, iconY, isSwimActive);
20248
+ iconEl.attr("data-swimlane-toggle", groupKey).on("click", (event) => {
20249
+ event.stopPropagation();
20250
+ currentSwimlaneGroup = currentSwimlaneGroup === groupKey ? null : groupKey;
20251
+ onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20252
+ relayout2();
20253
+ });
20254
+ entryX = pillXOff + pillWidth + LG_ICON_W + 4;
20255
+ } else {
20256
+ entryX = pillXOff + pillWidth + 8;
20257
+ }
20244
20258
  for (const entry of lg.group.entries) {
20245
20259
  const tagKey = lg.group.name.toLowerCase();
20246
20260
  const tagVal = entry.value.toLowerCase();
20247
- const entryG = gEl.append("g").attr("class", "tl-tag-legend-entry").attr("data-tag-group", tagKey).attr("data-legend-entry", tagVal).style("cursor", "pointer").on("mouseenter", (event) => {
20248
- event.stopPropagation();
20249
- fadeToTagValue(mainG, tagKey, tagVal);
20250
- mainSvg.selectAll(".tl-tag-legend-entry").each(function() {
20251
- const el = d3Selection12.select(this);
20252
- const ev = el.attr("data-legend-entry");
20253
- if (ev === "__group__") return;
20254
- const eg = el.attr("data-tag-group");
20255
- el.attr("opacity", eg === tagKey && ev === tagVal ? 1 : FADE_OPACITY);
20261
+ const entryG = gEl.append("g").attr("class", "tl-tag-legend-entry").attr("data-tag-group", tagKey).attr("data-legend-entry", tagVal);
20262
+ if (!viewMode) {
20263
+ entryG.style("cursor", "pointer").on("mouseenter", (event) => {
20264
+ event.stopPropagation();
20265
+ fadeToTagValue(mainG, tagKey, tagVal);
20266
+ mainSvg.selectAll(".tl-tag-legend-entry").each(function() {
20267
+ const el = d3Selection12.select(this);
20268
+ const ev = el.attr("data-legend-entry");
20269
+ if (ev === "__group__") return;
20270
+ const eg = el.attr("data-tag-group");
20271
+ el.attr("opacity", eg === tagKey && ev === tagVal ? 1 : FADE_OPACITY);
20272
+ });
20273
+ }).on("mouseleave", (event) => {
20274
+ event.stopPropagation();
20275
+ fadeReset(mainG);
20276
+ mainSvg.selectAll(".tl-tag-legend-entry").attr("opacity", 1);
20277
+ }).on("click", (event) => {
20278
+ event.stopPropagation();
20256
20279
  });
20257
- }).on("mouseleave", (event) => {
20258
- event.stopPropagation();
20259
- fadeReset(mainG);
20260
- mainSvg.selectAll(".tl-tag-legend-entry").attr("opacity", 1);
20261
- }).on("click", (event) => {
20262
- event.stopPropagation();
20263
- });
20280
+ }
20264
20281
  entryG.append("circle").attr("cx", entryX + LG_DOT_R).attr("cy", LG_HEIGHT / 2).attr("r", LG_DOT_R).attr("fill", entry.color);
20265
20282
  const textX = entryX + LG_DOT_R * 2 + LG_ENTRY_DOT_GAP;
20266
20283
  entryG.append("text").attr("x", textX).attr("y", LG_HEIGHT / 2 + LG_ENTRY_FONT_SIZE / 2 - 1).attr("font-size", LG_ENTRY_FONT_SIZE).attr("font-family", FONT_FAMILY).attr("fill", palette.textMuted).text(entry.value);
@@ -20296,7 +20313,8 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
20296
20313
  const groupBg = isDark ? mix(palette.surface, palette.bg, 50) : mix(palette.surface, palette.bg, 30);
20297
20314
  const legendGroups = parsed.timelineTagGroups.map((g) => {
20298
20315
  const pillW = g.name.length * LG_PILL_FONT_W + LG_PILL_PAD;
20299
- let entryX = LG_CAPSULE_PAD + pillW + LG_ICON_W + 4;
20316
+ const iconSpace = viewMode ? 8 : LG_ICON_W + 4;
20317
+ let entryX = LG_CAPSULE_PAD + pillW + iconSpace;
20300
20318
  for (const entry of g.entries) {
20301
20319
  const textX = entryX + LG_DOT_R * 2 + LG_ENTRY_DOT_GAP;
20302
20320
  entryX = textX + entry.value.length * LG_ENTRY_FONT_W + LG_ENTRY_TRAIL;