@bpmn-nova/studio 0.3.8-preview → 0.4.0
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/README.md +2 -2
- package/dist/canvas.js +97 -25
- package/dist/config.js +42 -0
- package/dist/context-menu.js +41 -32
- package/dist/controller.js +45 -19
- package/dist/index.d.ts +59 -2
- package/dist/index.js +1 -0
- package/dist/interactions.js +6 -1
- package/dist/modules/bpmn-model/index.d.ts +2 -1
- package/dist/modules/bpmn-model/index.js +12 -10
- package/dist/modules/core/gateway.js +16 -13
- package/dist/modules/core/index.d.ts +6 -4
- package/dist/modules/core/model.js +12 -7
- package/dist/modules/designer/index.d.ts +5 -1
- package/dist/modules/designer/index.js +36 -15
- package/dist/modules/export-svg/index.d.ts +12 -5
- package/dist/modules/export-svg/preview.js +34 -24
- package/dist/modules/export-svg/render.js +102 -50
- package/dist/modules/i18n/index.d.ts +647 -0
- package/dist/modules/i18n/index.js +247 -0
- package/dist/modules/i18n/locales/en-US.js +823 -0
- package/dist/modules/i18n/locales/zh-CN.js +805 -0
- package/dist/modules/node-presentation/index.d.ts +3 -2
- package/dist/modules/node-presentation/index.js +14 -11
- package/dist/modules/palette/index.d.ts +6 -1
- package/dist/modules/palette/index.js +26 -8
- package/dist/modules/palette/panel.js +44 -6
- package/dist/modules/properties/index.d.ts +2 -1
- package/dist/modules/properties/index.js +2 -2
- package/dist/modules/properties-activiti/index.js +84 -59
- package/dist/modules/properties-bpmn/index.js +151 -128
- package/dist/modules/properties-core/index.d.ts +9 -3
- package/dist/modules/properties-core/index.js +16 -4
- package/dist/modules/properties-flowable/index.js +55 -34
- package/dist/modules/properties-renderer/index.d.ts +5 -1
- package/dist/modules/properties-renderer/index.js +110 -42
- package/dist/modules/renderer-svg/index.d.ts +6 -2
- package/dist/modules/renderer-svg/index.js +113 -38
- package/dist/modules/runtime/index.d.ts +33 -5
- package/dist/modules/runtime/index.js +97 -73
- package/dist/modules/runtime/time.js +89 -4
- package/dist/modules/runtime/visits.js +6 -4
- package/dist/modules/theme/index.d.ts +5 -2
- package/dist/modules/theme/index.js +8 -4
- package/dist/modules/viewer/index.d.ts +28 -7
- package/dist/modules/viewer/index.js +213 -56
- package/dist/modules/viewer/runtime-content.js +26 -20
- package/dist/modules/viewer/runtime-trace.js +43 -25
- package/dist/modules/viewer/timeline.js +103 -36
- package/dist/shell.js +279 -75
- package/dist/sidebars.js +3 -1
- package/dist/styles.css +6 -3
- package/llms-full.txt +296 -49
- package/llms.txt +4 -4
- package/package.json +2 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NODE_DEFINITIONS } from '../core/index.js';
|
|
2
|
+
import { createI18n, DEFAULT_I18N, resolveI18n } from '../i18n/index.js';
|
|
2
3
|
import { normalizeOptions } from '../properties-core/index.js';
|
|
3
4
|
import { createDefaultIconRegistry, hydrateIcons, iconIdForNode } from '../icons/index.js';
|
|
4
5
|
import { ThemeController } from '../theme/index.js';
|
|
@@ -19,19 +20,21 @@ function optionHtml(options, value) {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
let selectSeed = 0;
|
|
22
|
-
function customSelectHtml(options, value, nativeAttrs, { label = '
|
|
23
|
+
function customSelectHtml(options, value, nativeAttrs, { label = '', compact = false, disabled = false, i18n = DEFAULT_I18N } = {}) {
|
|
24
|
+
const t = (key, params) => i18n.t(key, params);
|
|
25
|
+
const resolvedLabel = label || t('properties.controls.selectLabel');
|
|
23
26
|
const normalized = normalizeOptions(options);
|
|
24
27
|
const selectedValue = String(value ?? '');
|
|
25
28
|
const selected = normalized.find((option) => String(option.value) === selectedValue);
|
|
26
|
-
const selectedLabel = selected?.label ?? normalized[0]?.label ?? '
|
|
29
|
+
const selectedLabel = selected?.label ?? normalized[0]?.label ?? t('properties.controls.selectPlaceholder');
|
|
27
30
|
const listboxId = `nova-property-select-${++selectSeed}`;
|
|
28
31
|
const optionList = normalized.map((option, index) => {
|
|
29
32
|
const isSelected = String(option.value) === selectedValue;
|
|
30
33
|
return `<button type="button" class="property-select-option ${isSelected ? 'is-selected' : ''}" role="option" aria-selected="${isSelected ? 'true' : 'false'}" tabindex="-1" data-property-select-option data-option-index="${index}" data-value="${escapeHtml(option.value)}"><span>${escapeHtml(option.label)}</span><span class="nova-icon nova-icon-sm property-select-check" data-icon="ui.check"></span></button>`;
|
|
31
34
|
}).join('');
|
|
32
35
|
return `<div class="property-select ${compact ? 'property-select-compact' : ''}" data-property-select>
|
|
33
|
-
<button type="button" class="property-select-trigger" data-property-select-trigger aria-label="${escapeHtml(
|
|
34
|
-
<div class="property-select-popover" id="${listboxId}" role="listbox" aria-label="${escapeHtml(
|
|
36
|
+
<button type="button" class="property-select-trigger" data-property-select-trigger aria-label="${escapeHtml(t('properties.controls.selectAria', { label: resolvedLabel, value: selectedLabel }))}" aria-haspopup="listbox" aria-expanded="false" aria-controls="${listboxId}" ${disabled ? 'disabled' : ''}><span class="property-select-value">${escapeHtml(selectedLabel)}</span><span class="nova-icon nova-icon-sm property-select-chevron" data-icon="ui.chevron"></span></button>
|
|
37
|
+
<div class="property-select-popover" id="${listboxId}" role="listbox" aria-label="${escapeHtml(resolvedLabel)}" hidden>${optionList || `<div class="property-select-empty">${escapeHtml(t('properties.controls.selectEmpty'))}</div>`}</div>
|
|
35
38
|
<select class="property-select-native" data-property-select-native tabindex="-1" aria-hidden="true" hidden ${nativeAttrs}>${optionHtml(normalized, value)}</select>
|
|
36
39
|
</div>`;
|
|
37
40
|
}
|
|
@@ -50,6 +53,8 @@ function fieldShell(entry, control, error = null) {
|
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
function renderBasicEntry(entry, value, context) {
|
|
56
|
+
const i18n = resolveI18n(context);
|
|
57
|
+
const t = (key, params) => i18n.t(key, params);
|
|
53
58
|
const attrs = `data-property-input="${escapeHtml(entry.id)}" ${entry.readonly ? 'disabled' : ''}`;
|
|
54
59
|
const placeholder = entry.placeholder ? `placeholder="${escapeHtml(entry.placeholder)}"` : '';
|
|
55
60
|
if (entry.type === 'readonly') return fieldShell(entry, `<div class="property-readonly">${escapeHtml(resolveMaybe(entry.getValue ? value : (entry.value ?? value), context) || '—')}</div>`);
|
|
@@ -59,20 +64,20 @@ function renderBasicEntry(entry, value, context) {
|
|
|
59
64
|
}
|
|
60
65
|
if (entry.type === 'select') {
|
|
61
66
|
const options = resolveMaybe(entry.options, context) || [];
|
|
62
|
-
return fieldShell(entry, customSelectHtml(options, value, attrs, { label: entry.label, disabled: entry.readonly }));
|
|
67
|
+
return fieldShell(entry, customSelectHtml(options, value, attrs, { label: entry.label, disabled: entry.readonly, i18n }));
|
|
63
68
|
}
|
|
64
69
|
if (entry.type === 'switch') {
|
|
65
|
-
return fieldShell(entry, `<button type="button" class="property-switch ${value ? 'is-on' : ''}" data-property-switch="${escapeHtml(entry.id)}" aria-pressed="${value ? 'true' : 'false'}"><span></span><strong>${value ? '
|
|
70
|
+
return fieldShell(entry, `<button type="button" class="property-switch ${value ? 'is-on' : ''}" data-property-switch="${escapeHtml(entry.id)}" aria-pressed="${value ? 'true' : 'false'}"><span></span><strong>${escapeHtml(t(value ? 'properties.controls.switchOn' : 'properties.controls.switchOff'))}</strong></button>`);
|
|
66
71
|
}
|
|
67
72
|
if (entry.type === 'range') {
|
|
68
73
|
return fieldShell(entry, `<div class="property-range"><input type="range" min="${entry.min ?? 0}" max="${entry.max ?? 100}" step="${entry.step ?? 1}" value="${Number(value ?? entry.min ?? 0)}" ${attrs}/><span data-range-value="${escapeHtml(entry.id)}">${escapeHtml(valueText(value))}${escapeHtml(entry.unit || '')}</span></div>`);
|
|
69
74
|
}
|
|
70
75
|
if (entry.type === 'action') {
|
|
71
76
|
const actionIcon = entry.iconId ? `<span class="nova-icon nova-icon-sm" data-icon="${escapeHtml(entry.iconId)}"></span>` : '';
|
|
72
|
-
return fieldShell(entry, `<button type="button" class="property-action ${entry.variant === 'danger' ? 'is-danger' : ''}" data-property-action="${escapeHtml(entry.id)}">${actionIcon}<span>${escapeHtml(entry.actionLabel || entry.label || '
|
|
77
|
+
return fieldShell(entry, `<button type="button" class="property-action ${entry.variant === 'danger' ? 'is-danger' : ''}" data-property-action="${escapeHtml(entry.id)}">${actionIcon}<span>${escapeHtml(entry.actionLabel || entry.label || t('properties.controls.defaultAction'))}</span></button>`);
|
|
73
78
|
}
|
|
74
79
|
if (entry.type === 'tags') {
|
|
75
|
-
return fieldShell(entry, `<input class="property-control" type="text" value="${escapeHtml(valueText(value))}" ${attrs} ${placeholder}/><div class="property-inline-hint"
|
|
80
|
+
return fieldShell(entry, `<input class="property-control" type="text" value="${escapeHtml(valueText(value))}" ${attrs} ${placeholder}/><div class="property-inline-hint">${escapeHtml(t('properties.controls.tagsHint'))}</div>`);
|
|
76
81
|
}
|
|
77
82
|
if (entry.type === 'number') {
|
|
78
83
|
return fieldShell(entry, `<input class="property-control" type="number" value="${escapeHtml(valueText(value))}" min="${entry.min ?? ''}" max="${entry.max ?? ''}" step="${entry.step ?? 1}" ${attrs} ${placeholder}/>`);
|
|
@@ -81,11 +86,12 @@ function renderBasicEntry(entry, value, context) {
|
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
function renderSmartSelect(entry, value, context, panelId) {
|
|
89
|
+
const t = (key, params) => resolveI18n(context).t(key, params);
|
|
84
90
|
const options = smartOptions(entry, context);
|
|
85
91
|
const listId = `${panelId}-${entry.id}-list`;
|
|
86
92
|
const optionList = Array.isArray(options) ? options : [];
|
|
87
93
|
const datalist = `<datalist id="${escapeHtml(listId)}">${normalizeOptions(optionList).map((option) => `<option value="${escapeHtml(option.value)}">${escapeHtml(option.label)}</option>`).join('')}</datalist>`;
|
|
88
|
-
return fieldShell(entry, `<div class="property-smart-select"><input class="property-control" list="${escapeHtml(listId)}" type="text" value="${escapeHtml(valueText(value))}" data-property-input="${escapeHtml(entry.id)}" placeholder="${escapeHtml(entry.placeholder || '
|
|
94
|
+
return fieldShell(entry, `<div class="property-smart-select"><input class="property-control" list="${escapeHtml(listId)}" type="text" value="${escapeHtml(valueText(value))}" data-property-input="${escapeHtml(entry.id)}" placeholder="${escapeHtml(entry.placeholder || t('properties.controls.smartSelectPlaceholder'))}"/><span class="nova-icon nova-icon-sm property-smart-icon" data-icon="ui.chevron"></span></div>${datalist}`);
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
function smartOptions(entry, context) {
|
|
@@ -111,75 +117,82 @@ function smartOptions(entry, context) {
|
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
function renderNodeList(entry, value, context) {
|
|
120
|
+
const i18n = resolveI18n(context);
|
|
121
|
+
const t = (key, params) => i18n.t(key, params);
|
|
114
122
|
const rows = (value || []).map((id) => context.model.nodes.find((node) => node.id === id)).filter(Boolean);
|
|
115
123
|
const content = rows.length ? rows.map((node) => {
|
|
116
124
|
const definition = NODE_DEFINITIONS[node.type] || NODE_DEFINITIONS.generic;
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
return `<button type="button" class="property-node-ref" data-node-ref="${escapeHtml(node.id)}" aria-label="${escapeHtml(
|
|
125
|
+
const typeLabel = node.type ? i18n.elementTypeLabel(node.type, definition?.label) : t('properties.controls.nodeFallbackType');
|
|
126
|
+
const label = node.name || typeLabel || node.id;
|
|
127
|
+
return `<button type="button" class="property-node-ref" data-node-ref="${escapeHtml(node.id)}" aria-label="${escapeHtml(t('properties.controls.locateNodeAria', { label }))}">
|
|
120
128
|
<span class="property-node-ref-icon"><span class="nova-icon nova-icon-sm" data-icon="${escapeHtml(iconIdForNode(node.type, definition))}"></span></span>
|
|
121
129
|
<span class="property-node-ref-copy"><strong title="${escapeHtml(label)}">${escapeHtml(label)}</strong><small title="${escapeHtml(`${typeLabel} · ${node.id}`)}">${escapeHtml(typeLabel)} · ${escapeHtml(node.id)}</small></span>
|
|
122
130
|
<span class="property-node-ref-locate nova-icon nova-icon-xs" data-icon="ui.locate"></span>
|
|
123
131
|
</button>`;
|
|
124
|
-
}).join('') :
|
|
132
|
+
}).join('') : `<div class="property-empty-row">${escapeHtml(t('properties.controls.emptyNodeList'))}</div>`;
|
|
125
133
|
return fieldShell(entry, `<div class="property-node-list">${content}</div>`);
|
|
126
134
|
}
|
|
127
135
|
|
|
128
136
|
function renderFlowList(entry, value, context) {
|
|
137
|
+
const t = (key, params) => resolveI18n(context).t(key, params);
|
|
129
138
|
const rows = Array.isArray(value) ? value : [];
|
|
130
139
|
const content = rows.length ? rows.map((edge, index) => {
|
|
131
140
|
const relation = entry.relation === 'target' ? 'target' : 'source';
|
|
132
141
|
const related = context.model.nodes.find((node) => node.id === edge[relation]);
|
|
133
142
|
return `<button type="button" class="property-flow-ref" data-flow-ref="${escapeHtml(edge.id)}">
|
|
134
143
|
<span class="property-flow-index">${index + 1}</span>
|
|
135
|
-
<span class="property-flow-copy"><strong>${escapeHtml(related?.name || edge[relation] || '
|
|
144
|
+
<span class="property-flow-copy"><strong>${escapeHtml(related?.name || edge[relation] || t('properties.controls.unconnected'))}</strong><small>${escapeHtml(edge.name || edge.id)}</small></span>
|
|
136
145
|
<span class="nova-icon nova-icon-xs" data-icon="ui.locate"></span>
|
|
137
146
|
</button>`;
|
|
138
|
-
}).join('') : `<div class="property-empty-row">${escapeHtml(entry.emptyText || '
|
|
147
|
+
}).join('') : `<div class="property-empty-row">${escapeHtml(entry.emptyText || t('properties.controls.emptyFlowList'))}</div>`;
|
|
139
148
|
return fieldShell(entry, `<div class="property-flow-list">${content}</div>`);
|
|
140
149
|
}
|
|
141
150
|
|
|
142
|
-
function renderTable(entry, value) {
|
|
151
|
+
function renderTable(entry, value, context = null) {
|
|
152
|
+
const i18n = resolveI18n(context);
|
|
153
|
+
const t = (key, params) => i18n.t(key, params);
|
|
143
154
|
const rows = Array.isArray(value) ? value : [];
|
|
144
155
|
const columns = entry.columns || [];
|
|
145
156
|
const head = columns.map((column) => `<span>${escapeHtml(column.label)}</span>`).join('') + '<span></span>';
|
|
157
|
+
const removeLabel = t('properties.controls.removeRow');
|
|
146
158
|
const rowHtml = rows.map((row, rowIndex) => {
|
|
147
159
|
const cells = columns.map((column) => {
|
|
148
160
|
const cellValue = row?.[column.key] ?? '';
|
|
149
|
-
if (column.type === 'select') return customSelectHtml(column.options || [], cellValue, `data-table-input data-table-entry="${escapeHtml(entry.id)}" data-row="${rowIndex}" data-key="${escapeHtml(column.key)}"`, { label: column.label, compact: true });
|
|
161
|
+
if (column.type === 'select') return customSelectHtml(column.options || [], cellValue, `data-table-input data-table-entry="${escapeHtml(entry.id)}" data-row="${rowIndex}" data-key="${escapeHtml(column.key)}"`, { label: column.label, compact: true, i18n });
|
|
150
162
|
return `<input class="property-table-input" type="text" value="${escapeHtml(cellValue)}" data-table-entry="${escapeHtml(entry.id)}" data-row="${rowIndex}" data-key="${escapeHtml(column.key)}" placeholder="${escapeHtml(column.placeholder || '')}"/>`;
|
|
151
163
|
}).join('');
|
|
152
|
-
return `<div class="property-table-row" style="--property-columns:${Math.max(1, columns.length)}">${cells}<button type="button" class="property-row-remove" data-table-remove="${escapeHtml(entry.id)}" data-row="${rowIndex}" title="
|
|
164
|
+
return `<div class="property-table-row" style="--property-columns:${Math.max(1, columns.length)}">${cells}<button type="button" class="property-row-remove" data-table-remove="${escapeHtml(entry.id)}" data-row="${rowIndex}" title="${escapeHtml(removeLabel)}" aria-label="${escapeHtml(removeLabel)}"><span class="nova-icon nova-icon-sm" data-icon="ui.delete"></span></button></div>`;
|
|
153
165
|
}).join('');
|
|
154
|
-
return fieldShell(entry, `<div class="property-table"><div class="property-table-head" style="--property-columns:${Math.max(1, columns.length)}">${head}</div>${rowHtml ||
|
|
166
|
+
return fieldShell(entry, `<div class="property-table"><div class="property-table-head" style="--property-columns:${Math.max(1, columns.length)}">${head}</div>${rowHtml || `<div class="property-empty-row">${escapeHtml(t('properties.controls.emptyTable'))}</div>`}<button type="button" class="property-row-add" data-table-add="${escapeHtml(entry.id)}"><span class="nova-icon nova-icon-sm" data-icon="ui.add"></span><span>${escapeHtml(t('properties.controls.addRow', { label: entry.rowLabel || t('properties.controls.defaultRowLabel') }))}</span></button></div>`);
|
|
155
167
|
}
|
|
156
168
|
|
|
157
169
|
function renderBranchList(entry, value, context) {
|
|
170
|
+
const t = (key, params) => resolveI18n(context).t(key, params);
|
|
158
171
|
const rows = Array.isArray(value) ? value : [];
|
|
159
172
|
const fields = new Set(entry.fields || ['name', 'condition', 'default']);
|
|
160
173
|
const html = rows.length ? rows.map((row, index) => {
|
|
161
174
|
const target = context.model.nodes.find((node) => node.id === row.target);
|
|
162
175
|
return `<div class="property-branch-card ${row.isDefault ? 'is-default' : ''}" data-branch-index="${index}">
|
|
163
176
|
<div class="property-branch-head">
|
|
164
|
-
<div class="property-branch-identity"><span>${index + 1}</span><div><strong
|
|
165
|
-
<button type="button" class="property-branch-locate" data-branch-select="${index}"><span
|
|
177
|
+
<div class="property-branch-identity"><span>${index + 1}</span><div><strong>${escapeHtml(t('properties.branchList.title', { index: index + 1 }))}</strong><small>Sequence Flow</small></div></div>
|
|
178
|
+
<button type="button" class="property-branch-locate" data-branch-select="${index}"><span>${escapeHtml(t('properties.branchList.locate'))}</span><span class="nova-icon nova-icon-xs" data-icon="ui.locate"></span></button>
|
|
166
179
|
</div>
|
|
167
180
|
<div class="property-branch-condition ${fields.size === 1 ? 'is-single-field' : ''}">
|
|
168
|
-
${fields.has('name') ? `<label><span
|
|
169
|
-
${fields.has('condition') ? `<label><span
|
|
181
|
+
${fields.has('name') ? `<label><span>${escapeHtml(t('properties.branchList.nameLabel'))}</span><input class="property-control" type="text" value="${escapeHtml(row.name || '')}" data-branch-field="name" data-row="${index}" placeholder="${escapeHtml(t('properties.branchList.namePlaceholder'))}"/></label>` : ''}
|
|
182
|
+
${fields.has('condition') ? `<label><span>${escapeHtml(t('properties.branchList.conditionLabel'))}</span><textarea class="property-control property-expression" rows="2" data-branch-field="condition" data-row="${index}" placeholder="${escapeHtml('${condition}')}">${escapeHtml(row.condition || '')}</textarea></label>` : ''}
|
|
170
183
|
</div>
|
|
171
184
|
<div class="property-branch-foot ${fields.has('default') ? '' : 'is-target-only'}">
|
|
172
|
-
${fields.has('default') ? `<label class="property-branch-default ${row.isDefault ? 'is-active' : ''}"><input type="radio" name="default-branch-${escapeHtml(context.element.id)}" data-branch-default="${index}" ${row.isDefault ? 'checked' : ''}/><i></i><span
|
|
173
|
-
<div class="property-branch-target"><small
|
|
185
|
+
${fields.has('default') ? `<label class="property-branch-default ${row.isDefault ? 'is-active' : ''}"><input type="radio" name="default-branch-${escapeHtml(context.element.id)}" data-branch-default="${index}" ${row.isDefault ? 'checked' : ''}/><i></i><span>${escapeHtml(t('properties.branchList.defaultFlow'))}</span></label>` : ''}
|
|
186
|
+
<div class="property-branch-target"><small>${escapeHtml(t('properties.branchList.targetLabel'))}</small><strong>${escapeHtml(target?.name || row.target || t('properties.controls.unconnected'))}</strong><span>→</span></div>
|
|
174
187
|
</div>
|
|
175
188
|
</div>`;
|
|
176
|
-
}).join('') :
|
|
189
|
+
}).join('') : `<div class="property-empty-row">${escapeHtml(t('properties.branchList.empty'))}</div>`;
|
|
177
190
|
return fieldShell(entry, `<div class="property-branch-list">${html}</div>`);
|
|
178
191
|
}
|
|
179
192
|
|
|
180
193
|
let panelSeed = 0;
|
|
181
194
|
export class PropertiesPanel {
|
|
182
|
-
constructor({ container, registry, studio = registry?.studio, designer = null, canvas = null, iconRegistry = createDefaultIconRegistry(), emptyText
|
|
195
|
+
constructor({ container, registry, studio = registry?.studio, designer = null, canvas = null, iconRegistry = createDefaultIconRegistry(), emptyText, themeController = null, theme = null, onThemeChange = null, i18n = null, locale, messages } = {}) {
|
|
183
196
|
if (!container) throw new Error('PropertiesPanel requires a container.');
|
|
184
197
|
if (!registry) throw new Error('PropertiesPanel requires a PropertiesRegistry.');
|
|
185
198
|
this.container = container;
|
|
@@ -189,7 +202,24 @@ export class PropertiesPanel {
|
|
|
189
202
|
this.canvas = canvas;
|
|
190
203
|
this.iconRegistry = iconRegistry;
|
|
191
204
|
this.registry.setStudio(this.studio);
|
|
192
|
-
|
|
205
|
+
if (i18n) {
|
|
206
|
+
this.i18n = resolveI18n(i18n);
|
|
207
|
+
this._ownsI18n = false;
|
|
208
|
+
} else if (locale !== undefined || messages !== undefined) {
|
|
209
|
+
this.i18n = createI18n({ locale, messages });
|
|
210
|
+
this._ownsI18n = true;
|
|
211
|
+
} else if (this.studio?.i18n) {
|
|
212
|
+
this.i18n = this.studio.i18n;
|
|
213
|
+
this._ownsI18n = false;
|
|
214
|
+
} else if (this.registry?.i18n) {
|
|
215
|
+
this.i18n = this.registry.i18n;
|
|
216
|
+
this._ownsI18n = false;
|
|
217
|
+
} else {
|
|
218
|
+
this.i18n = createI18n();
|
|
219
|
+
this._ownsI18n = true;
|
|
220
|
+
}
|
|
221
|
+
this._customEmptyText = emptyText !== undefined ? emptyText : null;
|
|
222
|
+
this.emptyText = emptyText !== undefined ? emptyText : this.i18n.t('properties.empty');
|
|
193
223
|
this.collapseState = new Map();
|
|
194
224
|
this.id = `nova-properties-${++panelSeed}`;
|
|
195
225
|
this.container.classList.add('nova-properties');
|
|
@@ -199,17 +229,42 @@ export class PropertiesPanel {
|
|
|
199
229
|
this._offStudio = this.studio?.subscribe?.((event) => {
|
|
200
230
|
if (['selectionChanged', 'modelChanged', 'propertiesProfileChanged'].includes(event.type)) this.render();
|
|
201
231
|
});
|
|
232
|
+
this._offI18n = typeof this.i18n.subscribe === 'function'
|
|
233
|
+
? this.i18n.subscribe(() => {
|
|
234
|
+
if (this._customEmptyText === null) this.emptyText = this.i18n.t('properties.empty');
|
|
235
|
+
this.render();
|
|
236
|
+
})
|
|
237
|
+
: null;
|
|
202
238
|
}
|
|
203
239
|
|
|
204
240
|
destroy() {
|
|
205
241
|
this._customCleanups.forEach((cleanup) => cleanup?.());
|
|
206
242
|
this._customCleanups = [];
|
|
207
243
|
this._offStudio?.();
|
|
244
|
+
this._offI18n?.();
|
|
245
|
+
this._offI18n = null;
|
|
208
246
|
this.container.innerHTML = '';
|
|
209
247
|
this.container.classList.remove('nova-properties');
|
|
210
248
|
if (this._ownsThemeController) this.themeController.destroy();
|
|
211
249
|
}
|
|
212
250
|
|
|
251
|
+
setLocale(locale, messages) {
|
|
252
|
+
if (!this._ownsI18n) {
|
|
253
|
+
this._offI18n?.();
|
|
254
|
+
this.i18n = createI18n({ locale: locale ?? this.i18n.locale, messages });
|
|
255
|
+
this._ownsI18n = true;
|
|
256
|
+
this._offI18n = this.i18n.subscribe(() => {
|
|
257
|
+
if (this._customEmptyText === null) this.emptyText = this.i18n.t('properties.empty');
|
|
258
|
+
this.render();
|
|
259
|
+
});
|
|
260
|
+
if (this._customEmptyText === null) this.emptyText = this.i18n.t('properties.empty');
|
|
261
|
+
this.render();
|
|
262
|
+
return this.i18n.getState();
|
|
263
|
+
}
|
|
264
|
+
return this.i18n.setLocale(locale, messages);
|
|
265
|
+
}
|
|
266
|
+
getLocale() { return this.i18n.locale; }
|
|
267
|
+
|
|
213
268
|
setTheme(theme) { return this.themeController.setTheme(theme); }
|
|
214
269
|
setThemeMode(mode) { return this.themeController.setMode(mode); }
|
|
215
270
|
getThemeState() { return this.themeController.getState(); }
|
|
@@ -217,10 +272,11 @@ export class PropertiesPanel {
|
|
|
217
272
|
render(selection, element) {
|
|
218
273
|
this._customCleanups.forEach((cleanup) => cleanup?.());
|
|
219
274
|
this._customCleanups = [];
|
|
220
|
-
const { groups, context } = this.registry.getGroups(selection, element);
|
|
275
|
+
const { groups, context } = this.registry.getGroups(selection, element, { i18n: this.i18n });
|
|
221
276
|
const header = this._header(context);
|
|
222
277
|
const groupHtml = groups.map((group) => this._group(group, context)).join('');
|
|
223
|
-
const
|
|
278
|
+
const resolvedEmpty = this._customEmptyText !== null ? this._customEmptyText : this.i18n.t('properties.empty');
|
|
279
|
+
const emptyContent = context.kind === 'multi' ? this._multiSummary(context) : `<div class="properties-empty">${escapeHtml(resolvedEmpty)}</div>`;
|
|
224
280
|
this.container.innerHTML = `${header}<div class="properties-body">${groupHtml || emptyContent}</div>`;
|
|
225
281
|
hydrateIcons(this.container, this.iconRegistry);
|
|
226
282
|
this._bind(groups, context);
|
|
@@ -229,35 +285,47 @@ export class PropertiesPanel {
|
|
|
229
285
|
}
|
|
230
286
|
|
|
231
287
|
_multiSummary(context) {
|
|
232
|
-
const
|
|
288
|
+
const t = (key, params) => resolveI18n(context).t(key, params);
|
|
289
|
+
const labels = {
|
|
290
|
+
task: t('properties.multiSummary.kinds.task'),
|
|
291
|
+
event: t('properties.multiSummary.kinds.event'),
|
|
292
|
+
gateway: t('properties.multiSummary.kinds.gateway'),
|
|
293
|
+
container: t('properties.multiSummary.kinds.container'),
|
|
294
|
+
boundary: t('properties.multiSummary.kinds.boundary'),
|
|
295
|
+
};
|
|
233
296
|
const counts = new Map();
|
|
234
297
|
for (const element of context.element || []) {
|
|
235
298
|
const definition = element?.type ? NODE_DEFINITIONS[element.type] : null;
|
|
236
299
|
if (!definition) continue;
|
|
237
|
-
const label = labels[definition.kind] || '
|
|
300
|
+
const label = labels[definition.kind] || t('properties.multiSummary.kinds.other');
|
|
238
301
|
counts.set(label, (counts.get(label) || 0) + 1);
|
|
239
302
|
}
|
|
240
303
|
const chips = [...counts].map(([label, count]) => `<span>${escapeHtml(label)} <strong>${count}</strong></span>`).join('');
|
|
241
304
|
return `<section class="properties-multi-summary">
|
|
242
305
|
<div class="properties-multi-icon"><span class="nova-icon" data-icon="ui.layoutSelection"></span></div>
|
|
243
|
-
<strong
|
|
244
|
-
<p
|
|
306
|
+
<strong>${escapeHtml(t('properties.multiSummary.title'))}</strong>
|
|
307
|
+
<p>${escapeHtml(t('properties.multiSummary.description'))}</p>
|
|
245
308
|
<div class="properties-multi-counts">${chips}</div>
|
|
246
|
-
${this.canvas ?
|
|
309
|
+
${this.canvas ? `<button type="button" data-fit-selection><span class="nova-icon nova-icon-sm" data-icon="ui.fitSelection"></span><span>${escapeHtml(t('properties.multiSummary.fitSelection'))}</span></button>` : ''}
|
|
247
310
|
</section>`;
|
|
248
311
|
}
|
|
249
312
|
|
|
250
313
|
_header(context) {
|
|
314
|
+
const i18n = resolveI18n(context);
|
|
315
|
+
const t = (key, params) => i18n.t(key, params);
|
|
251
316
|
const profile = context.profile || 'business';
|
|
252
|
-
const profileSwitch = `<div class="properties-profile-switch" aria-label="
|
|
253
|
-
const renderHeader = (title, className = '') =>
|
|
254
|
-
|
|
255
|
-
|
|
317
|
+
const profileSwitch = `<div class="properties-profile-switch" aria-label="${escapeHtml(t('properties.profileAria'))}"><button type="button" data-properties-profile="business" class="${profile === 'business' ? 'is-active' : ''}">${escapeHtml(t('properties.profiles.business'))}</button><button type="button" data-properties-profile="developer" class="${profile === 'developer' ? 'is-active' : ''}">${escapeHtml(t('properties.profiles.developer'))}</button></div>`;
|
|
318
|
+
const renderHeader = (title, className = '') => {
|
|
319
|
+
if (className === 'properties-head-process') title = t('properties.header.process');
|
|
320
|
+
return `<div class="properties-head ${className}"><div class="properties-title-row"><div class="properties-title">${escapeHtml(title)}</div>${profileSwitch}</div></div>`;
|
|
321
|
+
};
|
|
322
|
+
if (context.kind === 'none') return renderHeader(t('properties.header.none'));
|
|
323
|
+
if (context.kind === 'multi') return renderHeader(t('properties.header.multiSelected', { count: context.element.length }));
|
|
256
324
|
if (context.kind === 'process') return renderHeader('流程与画布', 'properties-head-process');
|
|
257
325
|
if (context.kind === 'edge') {
|
|
258
|
-
return renderHeader(context.element.name || (context.element.type === 'association' ? '
|
|
326
|
+
return renderHeader(context.element.name || t(context.element.type === 'association' ? 'properties.header.association' : 'properties.header.sequenceFlow'));
|
|
259
327
|
}
|
|
260
|
-
return renderHeader(context.element.name || context.definition?.label || '
|
|
328
|
+
return renderHeader(context.element.name || (context.element.type ? i18n.elementTypeLabel(context.element.type, context.definition?.label) : null) || t('properties.header.unnamedElement'));
|
|
261
329
|
}
|
|
262
330
|
|
|
263
331
|
_group(group, context) {
|
|
@@ -277,7 +345,7 @@ export class PropertiesPanel {
|
|
|
277
345
|
const error = this.registry.validateEntry(entry, context);
|
|
278
346
|
const custom = this.registry.components.get(entry.component || entry.type);
|
|
279
347
|
if (custom) return fieldShell(entry, `<div class="property-custom-host" data-custom-entry="${escapeHtml(entry.id)}"></div>`, error);
|
|
280
|
-
if (entry.type === 'table') return renderTable(entry, value);
|
|
348
|
+
if (entry.type === 'table') return renderTable(entry, value, context);
|
|
281
349
|
if (entry.type === 'branchList') return renderBranchList(entry, value, context);
|
|
282
350
|
if (entry.type === 'flow-list') return renderFlowList(entry, value, context);
|
|
283
351
|
if (entry.type === 'node-list') return renderNodeList(entry, value, context);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AlignmentGuide, BpmnEdge, BpmnNode, ElementSelection, Point, ProcessModel, SelectionRect } from '../core/index.js'
|
|
2
|
+
import type { I18nController, NovaI18nOptions, NovaLocale, NovaLocaleState, NovaMessagesOverride } from '../i18n/index.js'
|
|
2
3
|
import type { IconRegistry, NodeVisualResolution } from '../icons/index.js'
|
|
3
4
|
import type { NodeRuntimePresentation, ProcessInstanceSnapshot, RuntimePresentation } from '../runtime/index.js'
|
|
4
5
|
import type { NovaThemeInput, NovaThemeMode, NovaThemeState, RuntimeAppearanceResolver, ThemeController } from '../theme/index.js'
|
|
@@ -70,7 +71,7 @@ export interface DiagramNodeRendererContext {
|
|
|
70
71
|
renderSemanticIcon(target?: Element, options?: { className?: string; title?: string }): SVGSVGElement | null
|
|
71
72
|
}
|
|
72
73
|
export type DiagramNodeRenderer = (context: DiagramNodeRendererContext) => void | (() => void)
|
|
73
|
-
export interface DiagramRendererOptions {
|
|
74
|
+
export interface DiagramRendererOptions extends NovaI18nOptions {
|
|
74
75
|
model?: ProcessModel
|
|
75
76
|
mode?: 'design' | 'viewer' | 'instance'
|
|
76
77
|
runtime?: ProcessInstanceSnapshot | null
|
|
@@ -78,7 +79,7 @@ export interface DiagramRendererOptions {
|
|
|
78
79
|
nodeRenderers?: Record<string, DiagramNodeRenderer>
|
|
79
80
|
nodeRenderer?: DiagramNodeRenderer
|
|
80
81
|
nodeSubtitleResolver?: NodeSubtitleResolver
|
|
81
|
-
runtimePresenter?: (context: { model: ProcessModel; runtime: ProcessInstanceSnapshot | null; appearance: RuntimeAppearanceResolver | null }) => RuntimePresentation
|
|
82
|
+
runtimePresenter?: (context: { model: ProcessModel; runtime: ProcessInstanceSnapshot | null; appearance: RuntimeAppearanceResolver | null; i18n?: I18nController }) => RuntimePresentation
|
|
82
83
|
runtimeAppearance?: RuntimeAppearanceResolver | null
|
|
83
84
|
svgExport?: SvgExportOptions & { label?: string; nodeRenderers?: Record<string, SvgNodeRenderer> }
|
|
84
85
|
themeController?: ThemeController
|
|
@@ -93,6 +94,7 @@ export interface DiagramRendererOptions {
|
|
|
93
94
|
[key: string]: unknown
|
|
94
95
|
}
|
|
95
96
|
export class DiagramRenderer {
|
|
97
|
+
readonly i18n: I18nController
|
|
96
98
|
constructor(container: HTMLElement, options?: DiagramRendererOptions)
|
|
97
99
|
model: ProcessModel
|
|
98
100
|
screenToWorld(clientX: number, clientY: number): Point
|
|
@@ -110,6 +112,8 @@ export class DiagramRenderer {
|
|
|
110
112
|
setInteractionMode(mode: string): void
|
|
111
113
|
getViewportState(): { zoom: number; pan: Point }
|
|
112
114
|
setViewportState(state: { zoom?: number; pan?: Point }): void
|
|
115
|
+
setLocale(locale?: NovaLocale | null, messages?: NovaMessagesOverride | null): NovaLocaleState
|
|
116
|
+
getLocale(): string
|
|
113
117
|
setTheme(theme: NovaThemeInput): NovaThemeState
|
|
114
118
|
setThemeMode(mode: NovaThemeMode): NovaThemeState
|
|
115
119
|
getThemeState(): NovaThemeState
|