@bpmn-nova/studio 0.3.6-preview → 0.3.8-preview

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.
@@ -19,7 +19,7 @@ function nodeTypeOptions(context) {
19
19
  return Object.entries(NODE_DEFINITIONS)
20
20
  .filter(([type, def]) => type !== 'generic'
21
21
  && compatible.includes(def.kind)
22
- && context.studio?.allowsNodeType?.(type) !== false)
22
+ && context.studio?.canChangeNodeType?.(context.element?.id, type) !== false)
23
23
  .map(([value, def]) => ({ value, label: def.label }));
24
24
  }
25
25
 
@@ -5,6 +5,9 @@ import type { NovaThemeInput, NovaThemeMode, NovaThemeState, RuntimeAppearanceRe
5
5
  import type { SvgExportArtifact, SvgExportOptions, SvgExportPreviewController, SvgNodeRenderer } from '../export-svg/index.js'
6
6
  import type { NodeSubtitleResolver } from '../node-presentation/index.js'
7
7
 
8
+ /** Viewport zoom range shared by the renderer and callers that clamp a requested zoom. */
9
+ export const ZOOM_LIMITS: { readonly min: number; readonly max: number }
10
+
8
11
  export interface SceneBounds {
9
12
  left: number
10
13
  top: number
@@ -9,12 +9,19 @@ import { exportDiagramSvg, openSvgExportPreview } from '../export-svg/index.js';
9
9
  const SVG_NS = 'http://www.w3.org/2000/svg';
10
10
  const XHTML_NS = 'http://www.w3.org/1999/xhtml';
11
11
 
12
+ /**
13
+ * Single source of truth for the viewport zoom range. Callers that need to
14
+ * clamp a requested zoom (for example BpmnCanvas.revealElement) read these
15
+ * limits instead of duplicating the numbers.
16
+ */
17
+ export const ZOOM_LIMITS = Object.freeze({ min: 0.25, max: 2.25 });
18
+
12
19
  function clamp(value, min, max) {
13
20
  return Math.max(min, Math.min(max, value));
14
21
  }
15
22
 
16
23
  function quantizeZoom(value, step = 0.05) {
17
- const clamped = clamp(value, 0.25, 2.25);
24
+ const clamped = clamp(value, ZOOM_LIMITS.min, ZOOM_LIMITS.max);
18
25
  return Math.round(Math.round(clamped / step) * step * 1000) / 1000;
19
26
  }
20
27
 
@@ -739,7 +746,7 @@ export class DiagramRenderer {
739
746
  const rect = this.viewport.getBoundingClientRect();
740
747
  if (rect.width < 1 || rect.height < 1) return;
741
748
  const maxZoom = options.maxZoom ?? 1.15;
742
- const minZoom = options.minZoom ?? 0.25;
749
+ const minZoom = options.minZoom ?? ZOOM_LIMITS.min;
743
750
  const rawZoom = Math.min((rect.width - padding * 2) / boundsW, (rect.height - padding * 2) / boundsH, maxZoom);
744
751
  let nextZoom = clamp(rawZoom, minZoom, maxZoom);
745
752
  if (options.snapZoom !== false) nextZoom = quantizeZoom(nextZoom, options.zoomStep ?? 0.05);
@@ -0,0 +1,49 @@
1
+ function element(tag, className, text) {
2
+ const node = document.createElement(tag);
3
+ if (className) node.className = className;
4
+ if (text !== undefined) node.textContent = text;
5
+ return node;
6
+ }
7
+
8
+ function participantInitial(participant) {
9
+ const name = String(participant?.name || '').trim();
10
+ return name.slice(0, 1) || '?';
11
+ }
12
+
13
+ export function renderRuntimeAvatar(participant, className = 'mb-runtime-details-avatar') {
14
+ const initial = participantInitial(participant);
15
+ const avatar = element('span', className, initial);
16
+ avatar.setAttribute('aria-hidden', 'true');
17
+ const url = String(participant?.avatarUrl || '').trim();
18
+ if (!url) return avatar;
19
+ const image = document.createElement('img');
20
+ image.src = url;
21
+ image.alt = '';
22
+ image.addEventListener('error', () => {
23
+ image.remove();
24
+ if (!avatar.textContent) avatar.textContent = initial;
25
+ }, { once: true });
26
+ avatar.textContent = '';
27
+ avatar.appendChild(image);
28
+ return avatar;
29
+ }
30
+
31
+ export function renderRuntimeAvatarStack(participants = [], { visibleLimit = 2 } = {}) {
32
+ const people = (participants || []).filter((item) => String(item?.name || '').trim());
33
+ if (!people.length) return null;
34
+ const stack = element('span', 'mb-runtime-timeline-avatars');
35
+ stack.setAttribute('aria-hidden', 'true');
36
+ people.slice(0, visibleLimit).forEach((participant) => {
37
+ stack.appendChild(renderRuntimeAvatar(participant));
38
+ });
39
+ const overflow = people.length - visibleLimit;
40
+ if (overflow > 0) {
41
+ stack.appendChild(element('span', 'mb-runtime-details-avatar mb-runtime-timeline-avatar-more', `+${overflow}`));
42
+ }
43
+ return stack;
44
+ }
45
+
46
+ export function shouldRenderTimelineAvatars(item) {
47
+ if (!item || item.predicted || item.automated) return false;
48
+ return (item.participants || []).some((participant) => String(participant?.name || '').trim());
49
+ }
@@ -1,6 +1,7 @@
1
1
  import { createDefaultIconRegistry, createIconElement } from '../icons/index.js';
2
2
  import { formatRuntimeInstant } from '../runtime/index.js';
3
3
  import { renderRuntimeApprovalContent } from './runtime-content.js';
4
+ import { renderRuntimeAvatarStack, shouldRenderTimelineAvatars } from './runtime-avatar.js';
4
5
  import { applyRuntimeTone } from '../theme/index.js';
5
6
 
6
7
  function element(tag, className, text) {
@@ -100,7 +101,15 @@ function renderActivityItem({ item, registry, conditionLabel, onItemClick, onDet
100
101
  heading.append(title, element('em', '', resultText(item)));
101
102
  const meta = element('div', 'mb-runtime-timeline-meta');
102
103
  meta.append(element('span', '', item.summary || (item.automated ? item.statusLabel : '')), element('time', '', formatTime(item.time)));
103
- trigger.append(heading, meta);
104
+ const copy = element('div', 'mb-runtime-timeline-card-copy');
105
+ copy.append(heading, meta);
106
+ const avatars = shouldRenderTimelineAvatars(item) ? renderRuntimeAvatarStack(item.participants) : null;
107
+ if (avatars) {
108
+ trigger.classList.add('has-avatars');
109
+ trigger.append(avatars, copy);
110
+ } else {
111
+ trigger.appendChild(copy);
112
+ }
104
113
  trigger.addEventListener('click', (event) => {
105
114
  onItemClick?.(item, event);
106
115
  onDetailsRequest?.(item, event.currentTarget, event);
package/dist/styles.css CHANGED
@@ -938,6 +938,11 @@ button.mb-runtime-action-summary:hover, button.mb-runtime-action-summary:focus-v
938
938
  .mb-runtime-timeline-content { min-width: 0; display: grid; gap: 4px; }
939
939
  .mb-runtime-timeline-card { width: 100%; min-width: 0; overflow: visible; border: 0; border-radius: 0; display: grid; color: inherit; background: transparent; box-shadow: none; }
940
940
  .mb-runtime-timeline-card-main { width: 100%; min-width: 0; border: 0; border-radius: 8px; padding: 5px 7px; display: grid; gap: 3px; color: inherit; background: transparent; text-align: left; font: inherit; cursor: pointer; transition: background-color .14s ease, box-shadow .14s ease; }
941
+ .mb-runtime-timeline-card-main.has-avatars { grid-template-columns: auto minmax(0, 1fr); align-items: start; column-gap: 8px; }
942
+ .mb-runtime-timeline-card-copy { min-width: 0; display: grid; gap: 3px; }
943
+ .mb-runtime-timeline-avatars { display: flex; align-items: center; margin-top: 2px; }
944
+ .mb-runtime-timeline-avatars .mb-runtime-details-avatar + .mb-runtime-details-avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--nova-color-surface, #fff); }
945
+ .mb-runtime-timeline-avatar-more { font-size: var(--nova-font-size-xs, 10px); }
941
946
  .mb-runtime-timeline-card-main:hover { background: var(--nova-color-primary-soft, #f5f6ff); }
942
947
  .mb-runtime-timeline-card-main:focus-visible { outline: none; background: var(--nova-color-primary-soft, #f5f6ff); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--nova-color-primary) 22%, transparent); }
943
948
  .mb-runtime-timeline-card-main:active { background: color-mix(in srgb, var(--nova-color-primary-soft) 84%, var(--nova-color-primary)); }