@diagrammo/dgmo 0.5.1 → 0.5.2

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,35 @@ 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 visibleGroups = viewMode ? legendGroups.filter(
20207
+ (lg) => currentActiveGroup != null && lg.group.name.toLowerCase() === currentActiveGroup.toLowerCase()
20208
+ ) : legendGroups;
20209
+ if (visibleGroups.length === 0) return;
20210
+ const totalW = visibleGroups.reduce((s, lg) => {
20206
20211
  const isActive = currentActiveGroup != null && lg.group.name.toLowerCase() === currentActiveGroup.toLowerCase();
20207
20212
  return s + (isActive ? lg.expandedWidth : lg.minifiedWidth);
20208
- }, 0) + (legendGroups.length - 1) * LG_GROUP_GAP;
20213
+ }, 0) + (visibleGroups.length - 1) * LG_GROUP_GAP;
20209
20214
  let cx = (width - totalW) / 2;
20210
- for (const lg of legendGroups) {
20215
+ for (const lg of visibleGroups) {
20211
20216
  const groupKey = lg.group.name.toLowerCase();
20212
20217
  const isActive = currentActiveGroup != null && currentActiveGroup.toLowerCase() === groupKey;
20213
20218
  const isSwimActive = currentSwimlaneGroup != null && currentSwimlaneGroup.toLowerCase() === groupKey;
20214
20219
  const pillLabel = lg.group.name;
20215
20220
  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
- });
20221
+ 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__");
20222
+ if (!viewMode) {
20223
+ gEl.style("cursor", "pointer").on("click", () => {
20224
+ currentActiveGroup = currentActiveGroup === groupKey ? null : groupKey;
20225
+ drawLegend2();
20226
+ recolorEvents2();
20227
+ onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20228
+ });
20229
+ }
20222
20230
  if (isActive) {
20223
20231
  gEl.append("rect").attr("width", lg.expandedWidth).attr("height", LG_HEIGHT).attr("rx", LG_HEIGHT / 2).attr("fill", groupBg);
20224
20232
  }
@@ -20231,36 +20239,44 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
20231
20239
  }
20232
20240
  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
20241
  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;
20242
+ let entryX;
20243
+ if (!viewMode) {
20244
+ const iconX = pillXOff + pillWidth + 5;
20245
+ const iconY = (LG_HEIGHT - 10) / 2;
20246
+ const iconEl = drawSwimlaneIcon2(gEl, iconX, iconY, isSwimActive);
20247
+ iconEl.attr("data-swimlane-toggle", groupKey).on("click", (event) => {
20248
+ event.stopPropagation();
20249
+ currentSwimlaneGroup = currentSwimlaneGroup === groupKey ? null : groupKey;
20250
+ onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20251
+ relayout2();
20252
+ });
20253
+ entryX = pillXOff + pillWidth + LG_ICON_W + 4;
20254
+ } else {
20255
+ entryX = pillXOff + pillWidth + 8;
20256
+ }
20244
20257
  for (const entry of lg.group.entries) {
20245
20258
  const tagKey = lg.group.name.toLowerCase();
20246
20259
  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);
20260
+ const entryG = gEl.append("g").attr("class", "tl-tag-legend-entry").attr("data-tag-group", tagKey).attr("data-legend-entry", tagVal);
20261
+ if (!viewMode) {
20262
+ entryG.style("cursor", "pointer").on("mouseenter", (event) => {
20263
+ event.stopPropagation();
20264
+ fadeToTagValue(mainG, tagKey, tagVal);
20265
+ mainSvg.selectAll(".tl-tag-legend-entry").each(function() {
20266
+ const el = d3Selection12.select(this);
20267
+ const ev = el.attr("data-legend-entry");
20268
+ if (ev === "__group__") return;
20269
+ const eg = el.attr("data-tag-group");
20270
+ el.attr("opacity", eg === tagKey && ev === tagVal ? 1 : FADE_OPACITY);
20271
+ });
20272
+ }).on("mouseleave", (event) => {
20273
+ event.stopPropagation();
20274
+ fadeReset(mainG);
20275
+ mainSvg.selectAll(".tl-tag-legend-entry").attr("opacity", 1);
20276
+ }).on("click", (event) => {
20277
+ event.stopPropagation();
20256
20278
  });
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
- });
20279
+ }
20264
20280
  entryG.append("circle").attr("cx", entryX + LG_DOT_R).attr("cy", LG_HEIGHT / 2).attr("r", LG_DOT_R).attr("fill", entry.color);
20265
20281
  const textX = entryX + LG_DOT_R * 2 + LG_ENTRY_DOT_GAP;
20266
20282
  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 +20312,8 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
20296
20312
  const groupBg = isDark ? mix(palette.surface, palette.bg, 50) : mix(palette.surface, palette.bg, 30);
20297
20313
  const legendGroups = parsed.timelineTagGroups.map((g) => {
20298
20314
  const pillW = g.name.length * LG_PILL_FONT_W + LG_PILL_PAD;
20299
- let entryX = LG_CAPSULE_PAD + pillW + LG_ICON_W + 4;
20315
+ const iconSpace = viewMode ? 8 : LG_ICON_W + 4;
20316
+ let entryX = LG_CAPSULE_PAD + pillW + iconSpace;
20300
20317
  for (const entry of g.entries) {
20301
20318
  const textX = entryX + LG_DOT_R * 2 + LG_ENTRY_DOT_GAP;
20302
20319
  entryX = textX + entry.value.length * LG_ENTRY_FONT_W + LG_ENTRY_TRAIL;