@bpmn-nova/studio 0.3.9-preview → 0.4.1

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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/dist/canvas.js +97 -25
  3. package/dist/config.js +13 -0
  4. package/dist/context-menu.js +41 -32
  5. package/dist/controller.js +45 -19
  6. package/dist/flow-tree.d.ts +4 -0
  7. package/dist/flow-tree.js +14 -0
  8. package/dist/index.d.ts +47 -2
  9. package/dist/index.js +1 -0
  10. package/dist/interactions.js +6 -1
  11. package/dist/modules/bpmn-model/index.d.ts +2 -1
  12. package/dist/modules/bpmn-model/index.js +12 -10
  13. package/dist/modules/core/gateway.js +16 -13
  14. package/dist/modules/core/index.d.ts +6 -4
  15. package/dist/modules/core/model.js +12 -7
  16. package/dist/modules/designer/index.d.ts +5 -1
  17. package/dist/modules/designer/index.js +36 -15
  18. package/dist/modules/export-svg/index.d.ts +12 -5
  19. package/dist/modules/export-svg/preview.js +34 -24
  20. package/dist/modules/export-svg/render.js +102 -50
  21. package/dist/modules/flow-tree/controller.js +364 -0
  22. package/dist/modules/flow-tree/index.d.ts +248 -0
  23. package/dist/modules/flow-tree/index.js +5 -0
  24. package/dist/modules/flow-tree/operations.js +484 -0
  25. package/dist/modules/flow-tree/sample.js +445 -0
  26. package/dist/modules/flow-tree/schema.js +588 -0
  27. package/dist/modules/flow-tree/validate.js +125 -0
  28. package/dist/modules/flow-tree-bpmn/compiler.js +547 -0
  29. package/dist/modules/flow-tree-bpmn/decompiler.js +524 -0
  30. package/dist/modules/flow-tree-bpmn/expression.js +135 -0
  31. package/dist/modules/flow-tree-bpmn/index.d.ts +53 -0
  32. package/dist/modules/flow-tree-bpmn/index.js +14 -0
  33. package/dist/modules/flow-tree-renderer/canvas.js +1003 -0
  34. package/dist/modules/flow-tree-renderer/export-svg.js +325 -0
  35. package/dist/modules/flow-tree-renderer/index.d.ts +143 -0
  36. package/dist/modules/flow-tree-renderer/index.js +3 -0
  37. package/dist/modules/flow-tree-renderer/shell.js +970 -0
  38. package/dist/modules/i18n/index.d.ts +647 -0
  39. package/dist/modules/i18n/index.js +247 -0
  40. package/dist/modules/i18n/locales/en-US.js +1222 -0
  41. package/dist/modules/i18n/locales/zh-CN.js +1204 -0
  42. package/dist/modules/icons/index.js +23 -0
  43. package/dist/modules/node-presentation/index.d.ts +3 -2
  44. package/dist/modules/node-presentation/index.js +14 -11
  45. package/dist/modules/palette/index.d.ts +6 -1
  46. package/dist/modules/palette/index.js +26 -8
  47. package/dist/modules/palette/panel.js +44 -6
  48. package/dist/modules/properties/index.d.ts +2 -1
  49. package/dist/modules/properties/index.js +2 -2
  50. package/dist/modules/properties-activiti/index.js +84 -59
  51. package/dist/modules/properties-bpmn/index.js +151 -128
  52. package/dist/modules/properties-core/index.d.ts +9 -3
  53. package/dist/modules/properties-core/index.js +16 -4
  54. package/dist/modules/properties-flow-tree/index.d.ts +56 -0
  55. package/dist/modules/properties-flow-tree/index.js +2 -0
  56. package/dist/modules/properties-flow-tree/panel.js +1136 -0
  57. package/dist/modules/properties-flow-tree/widgets.js +625 -0
  58. package/dist/modules/properties-flowable/index.js +55 -34
  59. package/dist/modules/properties-renderer/index.d.ts +5 -1
  60. package/dist/modules/properties-renderer/index.js +110 -42
  61. package/dist/modules/renderer-svg/index.d.ts +6 -2
  62. package/dist/modules/renderer-svg/index.js +113 -38
  63. package/dist/modules/runtime/index.d.ts +33 -5
  64. package/dist/modules/runtime/index.js +97 -73
  65. package/dist/modules/runtime/time.js +89 -4
  66. package/dist/modules/runtime/visits.js +6 -4
  67. package/dist/modules/theme/index.d.ts +5 -2
  68. package/dist/modules/theme/index.js +8 -4
  69. package/dist/modules/viewer/index.d.ts +28 -7
  70. package/dist/modules/viewer/index.js +223 -58
  71. package/dist/modules/viewer/runtime-content.js +26 -20
  72. package/dist/modules/viewer/runtime-trace.js +43 -25
  73. package/dist/modules/viewer/timeline.js +103 -36
  74. package/dist/shell.js +258 -75
  75. package/dist/sidebars.js +3 -1
  76. package/dist/styles.css +2371 -2
  77. package/llms-full.txt +586 -47
  78. package/llms.txt +6 -5
  79. package/package.json +7 -3
@@ -68,6 +68,29 @@ export const DEFAULT_ICONS = Object.freeze([
68
68
  uiIcon('ui.statusRejected', ['M8 8H4v4', 'M4.5 11.5C6.2 7.8 9 6 12.5 6a6 6 0 1 1-5.2 9', 'm5 15 2.5.2L7.2 18']),
69
69
  uiIcon('ui.statusSkipped', ['M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17Z', 'M8 12h8']),
70
70
  uiIcon('ui.statusIdle', 'M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17Z'),
71
+ uiIcon('flowTree.starter', ['M12 4.5a3.2 3.2 0 1 1 0 6.4 3.2 3.2 0 0 1 0-6.4Z', 'M5.5 19.5c.6-3.7 2.8-5.7 6.5-5.7s5.9 2 6.5 5.7']),
72
+ uiIcon('flowTree.approver', ['M12 3.5 5.5 6.2v5.3c0 4.3 2.8 7.5 6.5 9 3.7-1.5 6.5-4.7 6.5-9V6.2L12 3.5Z', 'm9 12 2.1 2.1 4.1-4.3']),
73
+ uiIcon('flowTree.cc', ['M20.5 4.5 3.5 11.2l6.4 2.5 2.5 6.4 8.1-15.6Z', 'm9.9 13.7 4.8-4.8']),
74
+ uiIcon('flowTree.handler', ['M5 19h4.2L18.8 9.4l-4.2-4.2L5 14.8V19Z', 'm12.8 7 4.2 4.2']),
75
+ uiIcon('flowTree.conditionRoute', ['M12 4v5', 'M12 9 6 14v6', 'M12 9l6 5v6', 'm4 18 2 2 2-2', 'm16 18 2 2 2-2']),
76
+ uiIcon('flowTree.parallelRoute', ['M12 3.5v4.5', 'M6 8h12', 'M6 8v11.5', 'M18 8v11.5', 'M12 8v11.5']),
77
+ uiIcon('flowTree.inclusiveRoute', ['M12 4a3 3 0 1 0 0 6 3 3 0 0 0 0-6Z', 'M10 9.5 6 14v6', 'M14 9.5 18 14v6', 'M12 10v10']),
78
+ uiIcon('flowTree.delay', ['M12 4.5a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15Z', 'M12 8v4.2l3 1.8']),
79
+ uiIcon('flowTree.trigger', ['M13.2 3.5 5.8 13h5.4l-1 7.5 8-9.8h-5.3l.3-7.2Z']),
80
+ uiIcon('flowTree.subFlow', ['M4.5 5.5h15v13h-15Z', 'M8.5 12h7', 'M12 8.5v7']),
81
+ uiIcon('flowTree.end', ['M12 4.5a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15Z', 'M9.2 9.2h5.6v5.6H9.2Z']),
82
+ uiIcon('flowTree.copy', ['M9 9h10v10H9Z', 'M15 9V5H5v10h4']),
83
+ uiIcon('flowTree.collapse', ['M5 12h14']),
84
+ uiIcon('flowTree.expand', ['M12 5v14', 'M5 12h14']),
85
+ uiIcon('flowTree.moveLeft', ['M15 6 9 12l6 6']),
86
+ uiIcon('flowTree.moveRight', ['M9 6l6 6-6 6']),
87
+ uiIcon('flowTree.drag', ['M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01']),
88
+ uiIcon('flowTree.warning', ['M12 4 3.5 19h17L12 4Z', 'M12 10v4', 'M12 16.5h.01']),
89
+ uiIcon('flowTree.xml', ['m8.5 7.5-4.5 4.5 4.5 4.5', 'm15.5 7.5 4.5 4.5-4.5 4.5', 'm13.5 5.5-3 13']),
90
+ uiIcon('flowTree.tree', ['M12 4v4', 'M6 12h12', 'M6 12v4', 'M18 12v4', 'M9.5 4h5v3.5h-5Z', 'M3.5 16h5v3.5h-5Z', 'M15.5 16h5v3.5h-5Z']),
91
+ uiIcon('flowTree.chevronRight', ['m9.5 7 5 5-5 5']),
92
+ uiIcon('flowTree.download', ['M12 4v11', 'm7.5 10.5 4.5 4.5 4.5-4.5', 'M5 19.5h14']),
93
+ uiIcon('flowTree.upload', ['M12 15V4', 'm7.5 8.5 4.5-4.5 4.5 4.5', 'M5 19.5h14']),
71
94
  icon('node.generic', 'M5 5h14v14H5z'),
72
95
  icon('node.task', 'M4 5.5h16v13H4z'),
73
96
  icon('node.userTask', ['M12 4.2a3 3 0 1 1 0 6 3 3 0 0 1 0-6Z', 'M6.5 19.5c.4-4 2.2-6.1 5.5-6.1s5.1 2.1 5.5 6.1']),
@@ -1,4 +1,5 @@
1
1
  import type { BpmnNode, NodeDefinition, ProcessModel } from '../core/index.js'
2
+ import type { NovaI18nOptions } from '../i18n/index.js'
2
3
 
3
4
  export interface NodeSubtitleResolverContext {
4
5
  readonly node: BpmnNode
@@ -13,7 +14,7 @@ export type NodeSubtitleResolver = (
13
14
  context: Readonly<NodeSubtitleResolverContext>,
14
15
  ) => string | null | undefined
15
16
 
16
- export function resolveDefaultNodeSubtitle(node: BpmnNode): string
17
+ export function resolveDefaultNodeSubtitle(node: BpmnNode, options?: NovaI18nOptions | null): string
17
18
  export function supportsNodeSubtitle(definition: NodeDefinition): boolean
18
19
  export function resolveNodeSubtitle(context: {
19
20
  node: BpmnNode
@@ -22,4 +23,4 @@ export function resolveNodeSubtitle(context: {
22
23
  mode: 'design' | 'viewer'
23
24
  surface: 'canvas' | 'svg-export'
24
25
  resolver?: NodeSubtitleResolver | null
25
- }): string | null
26
+ } & NovaI18nOptions): string | null
@@ -1,3 +1,5 @@
1
+ import { resolveI18n } from '../i18n/index.js';
2
+
1
3
  function resolverError(node, reason) {
2
4
  const nodeId = node?.id || '<unknown>';
3
5
  const detail = reason instanceof Error ? reason.message : String(reason);
@@ -6,17 +8,18 @@ function resolverError(node, reason) {
6
8
  return error;
7
9
  }
8
10
 
9
- export function resolveDefaultNodeSubtitle(node) {
11
+ export function resolveDefaultNodeSubtitle(node, options = null) {
12
+ const i18n = resolveI18n(options);
10
13
  const properties = node?.properties || {};
11
- if (node?.type === 'userTask') return properties.assignee || properties.candidateGroups || properties.candidateUsers || '待配置审批人';
12
- if (['serviceTask', 'sendTask', 'businessRuleTask'].includes(node?.type)) return properties.implementation || '待配置执行实现';
14
+ if (node?.type === 'userTask') return properties.assignee || properties.candidateGroups || properties.candidateUsers || i18n.t('canvas.defaultSubtitles.userTask');
15
+ if (['serviceTask', 'sendTask', 'businessRuleTask'].includes(node?.type)) return properties.implementation || i18n.t('canvas.defaultSubtitles.serviceTask');
13
16
  if (node?.type === 'scriptTask') return properties.scriptFormat || 'Script';
14
- if (node?.type === 'callActivity') return properties.calledElement || '待配置调用流程';
15
- if (node?.type === 'receiveTask') return '等待消息或外部触发';
16
- if (node?.type === 'manualTask') return '人工线下处理';
17
- if (node?.type === 'subProcess') return '可折叠子流程';
18
- if (node?.type === 'eventSubProcess') return '事件触发子流程';
19
- if (node?.type === 'transaction') return '事务边界';
17
+ if (node?.type === 'callActivity') return properties.calledElement || i18n.t('canvas.defaultSubtitles.callActivity');
18
+ if (node?.type === 'receiveTask') return i18n.t('canvas.defaultSubtitles.receiveTask');
19
+ if (node?.type === 'manualTask') return i18n.t('canvas.defaultSubtitles.manualTask');
20
+ if (node?.type === 'subProcess') return i18n.t('canvas.defaultSubtitles.subProcess');
21
+ if (node?.type === 'eventSubProcess') return i18n.t('canvas.defaultSubtitles.eventSubProcess');
22
+ if (node?.type === 'transaction') return i18n.t('canvas.defaultSubtitles.transaction');
20
23
  return node?.bpmnType?.replace('bpmn:', '') || '';
21
24
  }
22
25
 
@@ -24,8 +27,8 @@ export function supportsNodeSubtitle(definition) {
24
27
  return definition?.kind === 'task' || definition?.kind === 'container';
25
28
  }
26
29
 
27
- export function resolveNodeSubtitle({ node, definition, model, mode, surface, resolver }) {
28
- const defaultSubtitle = resolveDefaultNodeSubtitle(node);
30
+ export function resolveNodeSubtitle({ node, definition, model, mode, surface, resolver, i18n = null, locale, messages }) {
31
+ const defaultSubtitle = resolveDefaultNodeSubtitle(node, { i18n, locale, messages });
29
32
  if (typeof resolver !== 'function') return defaultSubtitle;
30
33
 
31
34
  let result;
@@ -1,4 +1,5 @@
1
1
  import type { NodeType } from '../core/index.js'
2
+ import type { I18nController, NovaI18nOptions, NovaLocale, NovaLocaleState, NovaMessagesOverride } from '../i18n/index.js'
2
3
  import type { IconRegistry } from '../icons/index.js'
3
4
  import type { NovaThemeInput, NovaThemeMode, NovaThemeState, ThemeController } from '../theme/index.js'
4
5
 
@@ -51,12 +52,13 @@ export type PaletteSectionRenderer = (context: {
51
52
  panel: PalettePanel
52
53
  }) => void | (() => void)
53
54
 
54
- export interface PalettePanelOptions {
55
+ export interface PalettePanelOptions extends NovaI18nOptions {
55
56
  container: HTMLElement
56
57
  registry: PaletteRegistry
57
58
  studio: {
58
59
  getState(): unknown
59
60
  model?: unknown
61
+ i18n?: I18nController
60
62
  /** When present, the panel refreshes item availability on modelChanged. */
61
63
  subscribe?(listener: (event: { type: string }) => void): () => void
62
64
  canAddNode?(nodeType: NodeType, count?: number): boolean
@@ -77,8 +79,11 @@ export interface PalettePanelOptions {
77
79
  onThemeChange?: ((state: NovaThemeState) => void) | null
78
80
  }
79
81
  export class PalettePanel {
82
+ readonly i18n: I18nController
80
83
  constructor(options: PalettePanelOptions)
81
84
  render(): void
85
+ setLocale(locale?: NovaLocale | null, messages?: NovaMessagesOverride | null): NovaLocaleState
86
+ getLocale(): string
82
87
  setTheme(theme: NovaThemeInput): NovaThemeState
83
88
  setThemeMode(mode: NovaThemeMode): NovaThemeState
84
89
  getThemeState(): NovaThemeState
@@ -1,4 +1,5 @@
1
1
  import { NODE_DEFINITIONS, PALETTE_GROUPS, PARALLEL_GATEWAY_PRESETS } from '../core/index.js';
2
+ import { resolveI18n } from '../i18n/index.js';
2
3
  import { resolveNodeVisual } from '../icons/index.js';
3
4
 
4
5
  function insert(records, record) {
@@ -57,34 +58,51 @@ export const defaultBpmnPaletteProvider = {
57
58
  id: 'bpmn-default-palette',
58
59
  priority: 100,
59
60
  getSections(context = {}) {
61
+ const i18n = resolveI18n(context.i18n || context.studio?.i18n || context);
60
62
  return PALETTE_GROUPS.map((group) => {
61
63
  const items = [];
62
64
  for (const nodeType of group.types.filter((type) => context.studio?.allowsNodeType?.(type) !== false)) {
63
65
  if (nodeType === 'parallelGateway') {
66
+ const divergingLabel = i18n.t('elementTypes.parallelDiverging');
67
+ const convergingLabel = i18n.t('elementTypes.parallelConverging');
64
68
  items.push({
65
69
  id: 'node-parallelGateway',
66
- label: PARALLEL_GATEWAY_PRESETS.diverging.label,
67
- description: '并行启动多条后续线路',
70
+ label: divergingLabel,
71
+ description: i18n.t('palette.parallelDivergingDesc'),
68
72
  iconId: PARALLEL_GATEWAY_PRESETS.diverging.iconId,
69
- create: { kind: 'node', nodeType, preset: PARALLEL_GATEWAY_PRESETS.diverging.preset },
73
+ create: {
74
+ kind: 'node',
75
+ nodeType,
76
+ preset: {
77
+ ...PARALLEL_GATEWAY_PRESETS.diverging.preset,
78
+ name: divergingLabel,
79
+ },
80
+ },
70
81
  }, {
71
82
  id: 'node-parallelGateway-converging',
72
- label: PARALLEL_GATEWAY_PRESETS.converging.label,
73
- description: '等待所有并行入口到达',
83
+ label: convergingLabel,
84
+ description: i18n.t('palette.parallelConvergingDesc'),
74
85
  iconId: PARALLEL_GATEWAY_PRESETS.converging.iconId,
75
- create: { kind: 'node', nodeType, preset: PARALLEL_GATEWAY_PRESETS.converging.preset },
86
+ create: {
87
+ kind: 'node',
88
+ nodeType,
89
+ preset: {
90
+ ...PARALLEL_GATEWAY_PRESETS.converging.preset,
91
+ name: convergingLabel,
92
+ },
93
+ },
76
94
  });
77
95
  continue;
78
96
  }
79
97
  items.push({
80
98
  id: `node-${nodeType}`,
81
- label: NODE_DEFINITIONS[nodeType].label,
99
+ label: i18n.elementTypeLabel(nodeType, NODE_DEFINITIONS[nodeType].label),
82
100
  description: NODE_DEFINITIONS[nodeType].bpmnType,
83
101
  iconId: resolveNodeVisual(nodeType, { surface: 'palette' }).iconId,
84
102
  create: { kind: 'node', nodeType },
85
103
  });
86
104
  }
87
- return { id: group.id, label: group.label, collapsed: group.id !== 'favorites', items };
105
+ return { id: group.id, label: i18n.t(`palette.groups.${group.id}`), collapsed: group.id !== 'favorites', items };
88
106
  }).filter((section) => section.items.length);
89
107
  },
90
108
  };
@@ -1,3 +1,4 @@
1
+ import { createI18n, resolveI18n } from '../i18n/index.js';
1
2
  import { createDefaultIconRegistry, createIconElement, hydrateIcons } from '../icons/index.js';
2
3
  import { ThemeController } from '../theme/index.js';
3
4
 
@@ -13,18 +14,35 @@ function element(tag, className, text) {
13
14
  }
14
15
 
15
16
  export class PalettePanel {
16
- constructor({ container, registry, studio, interactions, canvas = null, iconRegistry = createDefaultIconRegistry(), renderItem = null, renderSection = null, themeController = null, theme = null, onThemeChange = null } = {}) {
17
+ constructor({ container, registry, studio, interactions, canvas = null, iconRegistry = createDefaultIconRegistry(), renderItem = null, renderSection = null, themeController = null, theme = null, onThemeChange = null, i18n = null, locale, messages } = {}) {
17
18
  if (!container || !registry || !studio || !interactions) throw new Error('PalettePanel requires container, registry, studio and interactions.');
18
19
  Object.assign(this, { container, registry, studio, interactions, canvas, iconRegistry, renderItem, renderSection });
20
+ if (i18n) {
21
+ this.i18n = resolveI18n(i18n);
22
+ this._ownsI18n = false;
23
+ } else if (locale !== undefined || messages !== undefined) {
24
+ this.i18n = createI18n({ locale, messages });
25
+ this._ownsI18n = true;
26
+ } else if (studio?.i18n) {
27
+ this.i18n = studio.i18n;
28
+ this._ownsI18n = false;
29
+ } else {
30
+ this.i18n = createI18n();
31
+ this._ownsI18n = true;
32
+ }
19
33
  this.themeController = themeController || new ThemeController({ root: container, theme, onChange: onThemeChange });
20
34
  this._ownsThemeController = !themeController;
21
35
  this._cleanups = [];
22
36
  this._itemButtons = [];
37
+ this._collapsedSections = new Map();
23
38
  // Node-limit availability changes with the model. Refresh item state in
24
39
  // place instead of re-rendering so section expansion and focus survive.
25
40
  this._offStudio = typeof studio.subscribe === 'function'
26
41
  ? studio.subscribe((event) => { if (event.type === 'modelChanged') this._refreshAvailability(); })
27
42
  : null;
43
+ this._offI18n = typeof this.i18n.subscribe === 'function'
44
+ ? this.i18n.subscribe(() => this.render())
45
+ : null;
28
46
  this.render();
29
47
  }
30
48
 
@@ -33,24 +51,29 @@ export class PalettePanel {
33
51
  this._itemButtons = [];
34
52
  this.container.innerHTML = '';
35
53
  this.container.classList.add('nova-palette');
36
- const sections = this.registry.resolve({ studio: this.studio, model: this.studio.model });
54
+ const sections = this.registry.resolve({ studio: this.studio, model: this.studio.model, i18n: this.i18n });
37
55
  for (const section of sections) {
38
56
  if (this.renderSection) {
39
57
  const cleanup = this.renderSection({ container: this.container, section, panel: this });
40
58
  if (typeof cleanup === 'function') this._cleanups.push(cleanup);
41
59
  continue;
42
60
  }
43
- const wrapper = element('section', `nova-palette-section${section.collapsed ? ' is-collapsed' : ''}`);
61
+ const collapsed = this._collapsedSections.has(section.id)
62
+ ? this._collapsedSections.get(section.id)
63
+ : Boolean(section.collapsed);
64
+ const wrapper = element('section', `nova-palette-section${collapsed ? ' is-collapsed' : ''}`);
44
65
  wrapper.dataset.sectionId = section.id;
45
66
  const toggle = element('button', 'nova-palette-section-toggle');
46
67
  toggle.type = 'button';
47
- toggle.setAttribute('aria-expanded', section.collapsed ? 'false' : 'true');
68
+ toggle.setAttribute('aria-expanded', collapsed ? 'false' : 'true');
48
69
  const chevron = element('span', 'nova-icon nova-icon-sm nova-palette-chevron');
49
70
  chevron.dataset.icon = 'ui.chevron';
50
71
  toggle.append(chevron, element('strong', '', section.label), element('small', '', String(section.items.length)));
51
72
  toggle.addEventListener('click', () => {
52
73
  wrapper.classList.toggle('is-collapsed');
53
- toggle.setAttribute('aria-expanded', wrapper.classList.contains('is-collapsed') ? 'false' : 'true');
74
+ const nextCollapsed = wrapper.classList.contains('is-collapsed');
75
+ this._collapsedSections.set(section.id, nextCollapsed);
76
+ toggle.setAttribute('aria-expanded', nextCollapsed ? 'false' : 'true');
54
77
  });
55
78
  const items = element('div', 'nova-palette-items');
56
79
  for (const item of section.items) items.appendChild(this._item(item));
@@ -100,7 +123,7 @@ export class PalettePanel {
100
123
  const create = item.create;
101
124
  if (create?.kind === 'node') {
102
125
  if (this.studio.canAddNode?.(create.nodeType) !== false) return null;
103
- return this.studio.nodeLimitReason?.(create.nodeType) || '该节点类型当前不可用';
126
+ return this.studio.nodeLimitReason?.(create.nodeType) || this.i18n.t('palette.itemUnavailable');
104
127
  }
105
128
  if (create?.kind === 'template') {
106
129
  // Templates are judged by their combined per-type counts; the interaction
@@ -127,6 +150,8 @@ export class PalettePanel {
127
150
  destroy() {
128
151
  this._offStudio?.();
129
152
  this._offStudio = null;
153
+ this._offI18n?.();
154
+ this._offI18n = null;
130
155
  this._cleanups.splice(0).forEach((cleanup) => cleanup?.());
131
156
  this._itemButtons = [];
132
157
  this.container.innerHTML = '';
@@ -134,6 +159,19 @@ export class PalettePanel {
134
159
  if (this._ownsThemeController) this.themeController.destroy();
135
160
  }
136
161
 
162
+ setLocale(locale, messages) {
163
+ if (!this._ownsI18n) {
164
+ this._offI18n?.();
165
+ this.i18n = createI18n({ locale: locale ?? this.i18n.locale, messages });
166
+ this._ownsI18n = true;
167
+ this._offI18n = this.i18n.subscribe(() => this.render());
168
+ this.render();
169
+ return this.i18n.getState();
170
+ }
171
+ return this.i18n.setLocale(locale, messages);
172
+ }
173
+ getLocale() { return this.i18n.locale; }
174
+
137
175
  setTheme(theme) { return this.themeController.setTheme(theme); }
138
176
  setThemeMode(mode) { return this.themeController.setMode(mode); }
139
177
  getThemeState() { return this.themeController.getState(); }
@@ -4,6 +4,7 @@ export * from '../properties-flowable/index.js'
4
4
  export * from '../properties-activiti/index.js'
5
5
  export * from '../properties-renderer/index.js'
6
6
 
7
+ import type { NovaI18nOptions } from '../i18n/index.js'
7
8
  import type {
8
9
  PropertiesProvider,
9
10
  PropertiesRegistry,
@@ -17,4 +18,4 @@ export function createDefaultPropertiesRegistry(options?: {
17
18
  components?: Record<string, PropertyComponentRenderer>
18
19
  dataProviders?: Record<string, unknown>
19
20
  providers?: PropertiesProvider[]
20
- }): PropertiesRegistry
21
+ } & NovaI18nOptions): PropertiesRegistry
@@ -9,8 +9,8 @@ import { registerBpmnProperties } from '../properties-bpmn/index.js';
9
9
  import { registerFlowableProperties } from '../properties-flowable/index.js';
10
10
  import { registerActivitiProperties } from '../properties-activiti/index.js';
11
11
 
12
- export function createDefaultPropertiesRegistry({ studio = null, designer = null, components = {}, dataProviders = {}, providers = [] } = {}) {
13
- const registry = createPropertiesRegistry({ studio: studio || designer, components, dataProviders });
12
+ export function createDefaultPropertiesRegistry({ studio = null, designer = null, components = {}, dataProviders = {}, providers = [], i18n = null, locale, messages } = {}) {
13
+ const registry = createPropertiesRegistry({ studio: studio || designer, components, dataProviders, i18n, locale, messages });
14
14
  registerBpmnProperties(registry);
15
15
  registerFlowableProperties(registry);
16
16
  registerActivitiProperties(registry);
@@ -1,92 +1,117 @@
1
+ import { resolveI18n } from '../i18n/index.js';
1
2
  import { propertyEntry, propertyGroup } from '../properties-core/index.js';
2
3
 
3
4
  const activityTypes = new Set(['task', 'userTask', 'manualTask', 'serviceTask', 'scriptTask', 'businessRuleTask', 'sendTask', 'receiveTask', 'callActivity', 'subProcess', 'eventSubProcess', 'transaction', 'adHocSubProcess']);
4
5
  const implementationTypes = [['class', 'Java Class'], ['delegateExpression', 'Delegate Expression'], ['expression', 'Expression']];
5
- const executionColumns = [
6
- { key: 'event', label: 'Event', type: 'select', options: [['start', 'start'], ['end', 'end'], ['take', 'take']] },
7
- { key: 'implementationType', label: '类型', type: 'select', options: implementationTypes },
8
- { key: 'implementation', label: '实现' },
9
- ];
10
- const taskListenerColumns = [
11
- { key: 'event', label: 'Event', type: 'select', options: [['create', 'create'], ['assignment', 'assignment'], ['complete', 'complete'], ['delete', 'delete'], ['all', 'all']] },
12
- { key: 'implementationType', label: '类型', type: 'select', options: implementationTypes },
13
- { key: 'implementation', label: '实现' },
14
- ];
6
+
7
+ function executionColumns(t, eventOptions = [['start', 'start'], ['end', 'end'], ['take', 'take']]) {
8
+ return [
9
+ { key: 'event', label: 'Event', type: 'select', options: eventOptions },
10
+ { key: 'implementationType', label: t('properties.engine.columnType'), type: 'select', options: implementationTypes },
11
+ { key: 'implementation', label: t('properties.engine.columnImplementation') },
12
+ ];
13
+ }
14
+
15
+ function taskListenerColumns(t) {
16
+ return [
17
+ { key: 'event', label: 'Event', type: 'select', options: [['create', 'create'], ['assignment', 'assignment'], ['complete', 'complete'], ['delete', 'delete'], ['all', 'all']] },
18
+ { key: 'implementationType', label: t('properties.engine.columnType'), type: 'select', options: implementationTypes },
19
+ { key: 'implementation', label: t('properties.engine.columnImplementation') },
20
+ ];
21
+ }
15
22
 
16
23
  const processProvider = {
17
24
  id: 'activiti-process', priority: 640, appliesTo: { kind: 'process', engine: 'activiti' },
18
- getGroups() { return [propertyGroup({ id: 'activiti-process-execution', label: 'Activiti 执行监听器', collapsed: true, position: { after: 'global-resources' }, entries: [
19
- propertyEntry({ id: 'process-listeners', type: 'table', label: 'Execution Listeners', path: 'properties.executionListeners', rowLabel: '监听器', defaultRow: () => ({ event: 'start', implementationType: 'class', implementation: '' }), columns: executionColumns }),
20
- ] })]; },
25
+ getGroups(context) {
26
+ const t = (key, params) => resolveI18n(context).t(key, params);
27
+ return [propertyGroup({ id: 'activiti-process-execution', label: t('properties.engine.activitiProcessExecutionGroup'), collapsed: true, position: { after: 'global-resources' }, entries: [
28
+ propertyEntry({ id: 'process-listeners', type: 'table', label: 'Execution Listeners', path: 'properties.executionListeners', rowLabel: t('properties.engine.listenerRow'), defaultRow: () => ({ event: 'start', implementationType: 'class', implementation: '' }), columns: executionColumns(t) }),
29
+ ] })];
30
+ },
21
31
  };
22
32
 
23
33
  const userTaskProvider = {
24
34
  id: 'activiti-user-task', priority: 660, appliesTo: { kind: 'node', nodeType: 'userTask', engine: 'activiti' },
25
- getGroups() { return [
26
- propertyGroup({ id: 'assignment', label: '人员分配 · Activiti', position: { after: 'basic' }, entries: [
27
- propertyEntry({ id: 'assignee', type: 'user-select', label: '负责人 Assignee', path: 'properties.assignee', dataProvider: 'identity', allowExpression: true, placeholder: '${manager}' }),
28
- propertyEntry({ id: 'owner', type: 'user-select', label: 'Owner', path: 'properties.owner', dataProvider: 'identity', allowExpression: true }),
29
- propertyEntry({ id: 'candidate-users', type: 'tags', label: '候选用户', path: 'properties.candidateUsers', dataProvider: 'identity' }),
30
- propertyEntry({ id: 'candidate-groups', type: 'tags', label: '候选组', path: 'properties.candidateGroups', dataProvider: 'identity' }),
31
- ] }),
32
- propertyGroup({ id: 'task-config', label: '任务属性', position: { after: 'assignment' }, entries: [
33
- propertyEntry({ id: 'form-key', type: 'form-select', label: 'Form Key', path: 'properties.formKey', dataProvider: 'forms', allowCustom: true }),
34
- propertyEntry({ id: 'due-date', type: 'expression', label: 'Due Date', path: 'properties.dueDate' }),
35
- propertyEntry({ id: 'priority', type: 'number', label: 'Priority', path: 'properties.priority', min: 0, max: 100 }),
36
- propertyEntry({ id: 'category', label: 'Category', path: 'properties.category' }),
37
- propertyEntry({ id: 'skip-expression', type: 'expression', label: 'Skip Expression', path: 'properties.skipExpression' }),
38
- ] }),
39
- propertyGroup({ id: 'task-listeners', label: 'Task Listeners', collapsed: true, position: { after: 'multi-instance' }, entries: [
40
- propertyEntry({ id: 'task-listener-table', type: 'table', label: '任务监听器', path: 'properties.taskListeners', rowLabel: 'Task Listener', defaultRow: () => ({ event: 'create', implementationType: 'class', implementation: '' }), columns: taskListenerColumns }),
41
- ] }),
42
- ]; },
35
+ getGroups(context) {
36
+ const t = (key, params) => resolveI18n(context).t(key, params);
37
+ return [
38
+ propertyGroup({ id: 'assignment', label: t('properties.engine.activitiAssignmentGroup'), position: { after: 'basic' }, entries: [
39
+ propertyEntry({ id: 'assignee', type: 'user-select', label: t('properties.engine.assignee'), path: 'properties.assignee', dataProvider: 'identity', allowExpression: true, placeholder: '${manager}' }),
40
+ propertyEntry({ id: 'owner', type: 'user-select', label: 'Owner', path: 'properties.owner', dataProvider: 'identity', allowExpression: true }),
41
+ propertyEntry({ id: 'candidate-users', type: 'tags', label: t('properties.engine.candidateUsers'), path: 'properties.candidateUsers', dataProvider: 'identity' }),
42
+ propertyEntry({ id: 'candidate-groups', type: 'tags', label: t('properties.engine.candidateGroups'), path: 'properties.candidateGroups', dataProvider: 'identity' }),
43
+ ] }),
44
+ propertyGroup({ id: 'task-config', label: t('properties.engine.taskConfigGroup'), position: { after: 'assignment' }, entries: [
45
+ propertyEntry({ id: 'form-key', type: 'form-select', label: 'Form Key', path: 'properties.formKey', dataProvider: 'forms', allowCustom: true }),
46
+ propertyEntry({ id: 'due-date', type: 'expression', label: 'Due Date', path: 'properties.dueDate' }),
47
+ propertyEntry({ id: 'priority', type: 'number', label: 'Priority', path: 'properties.priority', min: 0, max: 100 }),
48
+ propertyEntry({ id: 'category', label: 'Category', path: 'properties.category' }),
49
+ propertyEntry({ id: 'skip-expression', type: 'expression', label: 'Skip Expression', path: 'properties.skipExpression' }),
50
+ ] }),
51
+ propertyGroup({ id: 'task-listeners', label: 'Task Listeners', collapsed: true, position: { after: 'multi-instance' }, entries: [
52
+ propertyEntry({ id: 'task-listener-table', type: 'table', label: t('properties.engine.taskListenersLabel'), path: 'properties.taskListeners', rowLabel: 'Task Listener', defaultRow: () => ({ event: 'create', implementationType: 'class', implementation: '' }), columns: taskListenerColumns(t) }),
53
+ ] }),
54
+ ];
55
+ },
43
56
  };
44
57
 
45
58
  const implementationProvider = {
46
59
  id: 'activiti-implementation', priority: 660,
47
60
  appliesTo: (ctx) => ctx.kind === 'node' && ctx.model.engine === 'activiti' && ['serviceTask', 'sendTask', 'businessRuleTask'].includes(ctx.element.type),
48
- getGroups() { return [
49
- propertyGroup({ id: 'engine-implementation', label: '执行实现 · Activiti', position: { after: 'basic' }, entries: [
50
- propertyEntry({ id: 'implementation-type', type: 'select', label: '实现方式', path: 'properties.implementationType', options: implementationTypes }),
51
- propertyEntry({ id: 'implementation', type: 'expression', label: '实现值', path: 'properties.implementation', placeholder: 'com.example.MyDelegate / ${delegateBean}' }),
52
- propertyEntry({ id: 'result-variable', label: 'Result Variable', path: 'properties.resultVariable' }),
53
- ] }),
54
- propertyGroup({ id: 'field-injection', label: 'Field Injection', collapsed: true, position: { after: 'engine-implementation' }, entries: [
55
- propertyEntry({ id: 'fields', type: 'table', label: '字段注入', path: 'properties.fields', rowLabel: 'Field', defaultRow: () => ({ name: '', type: 'string', value: '' }), columns: [{ key: 'name', label: 'Name' }, { key: 'type', label: '类型', type: 'select', options: [['string', 'String'], ['expression', 'Expression']] }, { key: 'value', label: 'Value' }] }),
56
- ] }),
57
- ]; },
61
+ getGroups(context) {
62
+ const t = (key, params) => resolveI18n(context).t(key, params);
63
+ return [
64
+ propertyGroup({ id: 'engine-implementation', label: t('properties.engine.activitiImplGroup'), position: { after: 'basic' }, entries: [
65
+ propertyEntry({ id: 'implementation-type', type: 'select', label: t('properties.engine.implementationType'), path: 'properties.implementationType', options: implementationTypes }),
66
+ propertyEntry({ id: 'implementation', type: 'expression', label: t('properties.engine.implementationValue'), path: 'properties.implementation', placeholder: 'com.example.MyDelegate / ${delegateBean}' }),
67
+ propertyEntry({ id: 'result-variable', label: 'Result Variable', path: 'properties.resultVariable' }),
68
+ ] }),
69
+ propertyGroup({ id: 'field-injection', label: 'Field Injection', collapsed: true, position: { after: 'engine-implementation' }, entries: [
70
+ propertyEntry({ id: 'fields', type: 'table', label: t('properties.engine.fieldInjectionLabel'), path: 'properties.fields', rowLabel: 'Field', defaultRow: () => ({ name: '', type: 'string', value: '' }), columns: [{ key: 'name', label: 'Name' }, { key: 'type', label: t('properties.engine.columnType'), type: 'select', options: [['string', 'String'], ['expression', 'Expression']] }, { key: 'value', label: 'Value' }] }),
71
+ ] }),
72
+ ];
73
+ },
58
74
  };
59
75
 
60
76
  const activityProvider = {
61
77
  id: 'activiti-activity-execution', priority: 610,
62
78
  appliesTo: (ctx) => ctx.kind === 'node' && ctx.model.engine === 'activiti' && activityTypes.has(ctx.element.type),
63
- getGroups() { return [
64
- propertyGroup({ id: 'engine-execution', label: '执行配置 · Activiti', collapsed: true, position: { after: 'multi-instance' }, entries: [
65
- propertyEntry({ id: 'async', type: 'switch', label: 'Async', path: 'properties.async' }),
66
- propertyEntry({ id: 'exclusive', type: 'switch', label: 'Exclusive Job', path: 'properties.exclusive' }),
67
- propertyEntry({ id: 'async-leave', type: 'switch', label: 'Async Leave', path: 'properties.asyncLeave' }),
68
- propertyEntry({ id: 'failed-retry', type: 'expression', label: 'Failed Job Retry Cycle', path: 'properties.failedJobRetryTimeCycle', placeholder: 'R3/PT5M' }),
69
- ] }),
70
- propertyGroup({ id: 'execution-listeners', label: 'Execution Listeners', collapsed: true, position: { after: 'engine-execution' }, entries: [
71
- propertyEntry({ id: 'execution-listener-table', type: 'table', label: '执行监听器', path: 'properties.executionListeners', rowLabel: 'Execution Listener', defaultRow: () => ({ event: 'start', implementationType: 'class', implementation: '' }), columns: executionColumns.map((column) => column.key === 'event' ? { ...column, options: [['start', 'start'], ['end', 'end']] } : column) }),
72
- ] }),
73
- ]; },
79
+ getGroups(context) {
80
+ const t = (key, params) => resolveI18n(context).t(key, params);
81
+ return [
82
+ propertyGroup({ id: 'engine-execution', label: t('properties.engine.activitiExecutionGroup'), collapsed: true, position: { after: 'multi-instance' }, entries: [
83
+ propertyEntry({ id: 'async', type: 'switch', label: 'Async', path: 'properties.async' }),
84
+ propertyEntry({ id: 'exclusive', type: 'switch', label: 'Exclusive Job', path: 'properties.exclusive' }),
85
+ propertyEntry({ id: 'async-leave', type: 'switch', label: 'Async Leave', path: 'properties.asyncLeave' }),
86
+ propertyEntry({ id: 'failed-retry', type: 'expression', label: 'Failed Job Retry Cycle', path: 'properties.failedJobRetryTimeCycle', placeholder: 'R3/PT5M' }),
87
+ ] }),
88
+ propertyGroup({ id: 'execution-listeners', label: 'Execution Listeners', collapsed: true, position: { after: 'engine-execution' }, entries: [
89
+ propertyEntry({ id: 'execution-listener-table', type: 'table', label: t('properties.engine.executionListenersLabel'), path: 'properties.executionListeners', rowLabel: 'Execution Listener', defaultRow: () => ({ event: 'start', implementationType: 'class', implementation: '' }), columns: executionColumns(t, [['start', 'start'], ['end', 'end']]) }),
90
+ ] }),
91
+ ];
92
+ },
74
93
  };
75
94
 
76
95
  const callProvider = {
77
96
  id: 'activiti-call-activity', priority: 650, appliesTo: { kind: 'node', nodeType: 'callActivity', engine: 'activiti' },
78
- getGroups() { return [propertyGroup({ id: 'activiti-call', label: 'Activiti 调用选项', collapsed: true, position: { after: 'call-activity' }, entries: [
79
- propertyEntry({ id: 'inherit-business-key', type: 'switch', label: 'Inherit Business Key', path: 'properties.inheritBusinessKey' }),
80
- propertyEntry({ id: 'inherit-variables', type: 'switch', label: 'Inherit Variables', path: 'properties.inheritVariables' }),
81
- ] })]; },
97
+ getGroups(context) {
98
+ const t = (key, params) => resolveI18n(context).t(key, params);
99
+ return [propertyGroup({ id: 'activiti-call', label: t('properties.engine.activitiCallGroup'), collapsed: true, position: { after: 'call-activity' }, entries: [
100
+ propertyEntry({ id: 'inherit-business-key', type: 'switch', label: 'Inherit Business Key', path: 'properties.inheritBusinessKey' }),
101
+ propertyEntry({ id: 'inherit-variables', type: 'switch', label: 'Inherit Variables', path: 'properties.inheritVariables' }),
102
+ ] })];
103
+ },
82
104
  };
83
105
 
84
106
  const edgeProvider = {
85
107
  id: 'activiti-edge-listeners', priority: 620,
86
108
  appliesTo: (ctx) => ctx.kind === 'edge' && ctx.model.engine === 'activiti' && (ctx.element.type || 'sequenceFlow') === 'sequenceFlow',
87
- getGroups() { return [propertyGroup({ id: 'edge-listeners', label: 'Take Listener · Activiti', collapsed: true, position: { after: 'condition' }, entries: [
88
- propertyEntry({ id: 'edge-execution-listeners', type: 'table', label: 'Execution Listeners', path: 'properties.executionListeners', rowLabel: 'Take Listener', defaultRow: () => ({ event: 'take', implementationType: 'class', implementation: '' }), columns: executionColumns.map((column) => column.key === 'event' ? { ...column, options: [['take', 'take']] } : column) }),
89
- ] })]; },
109
+ getGroups(context) {
110
+ const t = (key, params) => resolveI18n(context).t(key, params);
111
+ return [propertyGroup({ id: 'edge-listeners', label: 'Take Listener · Activiti', collapsed: true, position: { after: 'condition' }, entries: [
112
+ propertyEntry({ id: 'edge-execution-listeners', type: 'table', label: 'Execution Listeners', path: 'properties.executionListeners', rowLabel: 'Take Listener', defaultRow: () => ({ event: 'take', implementationType: 'class', implementation: '' }), columns: executionColumns(t, [['take', 'take']]) }),
113
+ ] })];
114
+ },
90
115
  };
91
116
 
92
117
  export const activitiPropertiesProviders = [processProvider, userTaskProvider, implementationProvider, activityProvider, callProvider, edgeProvider];