prince-ui-dmn 1.0.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.
- package/LICENSE +21 -0
- package/dist/index.css +526 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +231 -0
- package/dist/index.js +1423 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Datenmodell der DMN-Entscheidungstabelle — geteilter Vertrag zwischen dem
|
|
6
|
+
* einstiegsfreundlichen Tabelleneditor (⑤) und dem dmn-js-Expertenmodus (⑥),
|
|
7
|
+
* damit das Umschalten verlustfrei bleibt.
|
|
8
|
+
*
|
|
9
|
+
* Anders als der maco-process-studio-Prototyp (lossy XML-Patch) wird dieses
|
|
10
|
+
* Modell verlustfrei über `dmn-moddle` serialisiert (inkl. Spaltenänderungen).
|
|
11
|
+
*/
|
|
12
|
+
type HitPolicy = "UNIQUE" | "FIRST" | "PRIORITY" | "ANY" | "COLLECT" | "RULE ORDER" | "OUTPUT ORDER";
|
|
13
|
+
/** COLLECT-Aggregation (nur bei hitPolicy === "COLLECT"). */
|
|
14
|
+
type Aggregation = "SUM" | "MIN" | "MAX" | "COUNT";
|
|
15
|
+
type DmnColumnKind = "input" | "output";
|
|
16
|
+
interface DmnColumn {
|
|
17
|
+
id: string;
|
|
18
|
+
/** Anzeigename der Spalte (Input: label, Output: name) */
|
|
19
|
+
label: string;
|
|
20
|
+
/** FEEL-Input-Expression (Input) bzw. Output-Name */
|
|
21
|
+
expression: string;
|
|
22
|
+
kind: DmnColumnKind;
|
|
23
|
+
/** FEEL-Typ, z. B. string | number | boolean | date */
|
|
24
|
+
typeRef: string;
|
|
25
|
+
/** optionale erlaubte Werte (für Validierung/Autocomplete) */
|
|
26
|
+
inputValues?: string[];
|
|
27
|
+
}
|
|
28
|
+
interface DmnRow {
|
|
29
|
+
id: string;
|
|
30
|
+
/** colId -> FEEL-Entry */
|
|
31
|
+
cells: Record<string, string>;
|
|
32
|
+
annotation?: string;
|
|
33
|
+
}
|
|
34
|
+
interface DmnTableModel {
|
|
35
|
+
/** id der Decision */
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
hitPolicy: HitPolicy;
|
|
39
|
+
aggregation?: Aggregation;
|
|
40
|
+
columns: DmnColumn[];
|
|
41
|
+
rows: DmnRow[];
|
|
42
|
+
}
|
|
43
|
+
/** Ergebnis einer FEEL-Lint-Prüfung pro Zelle. */
|
|
44
|
+
interface FeelLintResult {
|
|
45
|
+
valid: boolean;
|
|
46
|
+
message?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Light/Dark-Steuerung. */
|
|
49
|
+
type DiagramColorScheme = "auto" | "light" | "dark";
|
|
50
|
+
/**
|
|
51
|
+
* Optionales Zell-Plugin (z. B. Prüfidentifikator-Autocomplete) — hält die
|
|
52
|
+
* Pakete frei von MaCo-Domänenwissen.
|
|
53
|
+
*/
|
|
54
|
+
interface DmnCellPlugin {
|
|
55
|
+
/** trifft zu, wenn die Spalte dieses Plugin nutzen soll */
|
|
56
|
+
matches(column: DmnColumn): boolean;
|
|
57
|
+
/** liefert das Edit-Control für die Zelle */
|
|
58
|
+
renderEditor(props: {
|
|
59
|
+
value: string;
|
|
60
|
+
onChange(next: string): void;
|
|
61
|
+
onCommit(): void;
|
|
62
|
+
onCancel(): void;
|
|
63
|
+
column: DmnColumn;
|
|
64
|
+
}): react.ReactNode;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Theme-Bridge für dmn-js (DRD-SVG-Ansicht) — kolokierte Kopie des bpmn-Pakets
|
|
69
|
+
* (bewusst kein geteiltes 4. Paket). Liest prince-ui-Tokens (`--prn-*`) und
|
|
70
|
+
* hört auf `data-theme`.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
interface DiagramColors {
|
|
74
|
+
defaultFillColor: string;
|
|
75
|
+
defaultStrokeColor: string;
|
|
76
|
+
defaultLabelColor: string;
|
|
77
|
+
canvasBackground: string;
|
|
78
|
+
accent: string;
|
|
79
|
+
}
|
|
80
|
+
declare function readToken(name: string, fallback: string): string;
|
|
81
|
+
declare function isDarkMode(scheme?: DiagramColorScheme): boolean;
|
|
82
|
+
declare function getDiagramColors(scheme?: DiagramColorScheme): DiagramColors;
|
|
83
|
+
declare function onThemeChange(onChange: () => void): () => void;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Verlustfreies Mapping zwischen DMN-XML und dem geteilten `DmnTableModel`
|
|
87
|
+
* (Spec §7) — über **dmn-moddle**, NICHT über den lossy XML-String-Patch des
|
|
88
|
+
* maco-process-studio-Prototyps.
|
|
89
|
+
*
|
|
90
|
+
* - `parseDmnModel(xml)` liest die (per Index/ID wählbare) Decision-Table.
|
|
91
|
+
* - `serializeDmnModel(model, originalXml?)` schreibt das Modell zurück und
|
|
92
|
+
* bewahrt dabei alle nicht angefassten Teile des Originaldokuments
|
|
93
|
+
* (weitere Decisions, DRD/DI, Imports, Annotationen anderer Tabellen).
|
|
94
|
+
*
|
|
95
|
+
* dmn-moddle bringt keine eigenen Typdeklarationen mit — die Moddle-Elemente
|
|
96
|
+
* werden hier über schlanke lokale Interfaces typisiert (siehe `Moddle*`).
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/** Erzeugt eine stabile, gut lesbare ID. Nur für neu angelegte Elemente. */
|
|
100
|
+
declare function makeId(prefix: string): string;
|
|
101
|
+
interface DmnDecisionRef {
|
|
102
|
+
id: string;
|
|
103
|
+
name: string;
|
|
104
|
+
}
|
|
105
|
+
interface ParseOptions {
|
|
106
|
+
/** Wähle die Decision per ID; Default: erste Decision mit Table. */
|
|
107
|
+
decisionId?: string;
|
|
108
|
+
/** Alternativ per Index (0-basiert). */
|
|
109
|
+
decisionIndex?: number;
|
|
110
|
+
}
|
|
111
|
+
/** Liste der editierbaren Decisions im Dokument (für Auswahl-UI). */
|
|
112
|
+
declare function listDecisions(xml: string): Promise<DmnDecisionRef[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Parst DMN-XML zu einem `DmnTableModel`. Wirft, wenn keine Decision-Table
|
|
115
|
+
* gefunden wird oder das XML ungültig ist.
|
|
116
|
+
*/
|
|
117
|
+
declare function parseDmnModel(xml: string, options?: ParseOptions): Promise<DmnTableModel>;
|
|
118
|
+
/**
|
|
119
|
+
* Serialisiert ein `DmnTableModel` zurück nach DMN-XML.
|
|
120
|
+
*
|
|
121
|
+
* Wird `originalXml` übergeben, wird dessen Moddle-Baum wiederverwendet — so
|
|
122
|
+
* bleiben weitere Decisions, DRD/DI, Imports etc. verlustfrei erhalten und nur
|
|
123
|
+
* die Ziel-Table (per `model.id`) wird ersetzt. Ohne `originalXml` wird ein
|
|
124
|
+
* minimales, valides Definitions-Dokument neu erzeugt.
|
|
125
|
+
*/
|
|
126
|
+
declare function serializeDmnModel(model: DmnTableModel, originalXml?: string): Promise<string>;
|
|
127
|
+
/** Leere Zelle für eine neue Zeile. */
|
|
128
|
+
declare function emptyRow(model: DmnTableModel): DmnRow;
|
|
129
|
+
declare function addRow(model: DmnTableModel, at?: number): DmnTableModel;
|
|
130
|
+
declare function deleteRow(model: DmnTableModel, rowId: string): DmnTableModel;
|
|
131
|
+
declare function moveRow(model: DmnTableModel, rowId: string, direction: -1 | 1): DmnTableModel;
|
|
132
|
+
declare function updateCell(model: DmnTableModel, rowId: string, colId: string, value: string): DmnTableModel;
|
|
133
|
+
declare function updateAnnotation(model: DmnTableModel, rowId: string, annotation: string): DmnTableModel;
|
|
134
|
+
declare function setHitPolicy(model: DmnTableModel, hitPolicy: HitPolicy, aggregation?: Aggregation): DmnTableModel;
|
|
135
|
+
/** Neue Spalte (Input oder Output) am Ende ihrer Gruppe einfügen. */
|
|
136
|
+
declare function addColumn(model: DmnTableModel, kind: DmnColumn["kind"], partial?: Partial<Omit<DmnColumn, "id" | "kind">>): DmnTableModel;
|
|
137
|
+
declare function updateColumn(model: DmnTableModel, colId: string, patch: Partial<Omit<DmnColumn, "id" | "kind">>): DmnTableModel;
|
|
138
|
+
declare function deleteColumn(model: DmnTableModel, colId: string): DmnTableModel;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Heuristischer FEEL-Linter (regex-basiert) — als **nicht-blockierender Hinweis**
|
|
142
|
+
* gedacht (Spec §7): valide FEEL außerhalb der Whitelist wird abgelehnt. Ein echter
|
|
143
|
+
* FEEL-Parser (`feelin`) ist eine spätere Option. Portiert aus
|
|
144
|
+
* maco-process-studio `useFeelLinter.ts`, aber framework-frei und gegen den
|
|
145
|
+
* geteilten `DmnColumn`-Vertrag.
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/** Erkannter FEEL-Werttyp (für Token-Färbung im Editor). */
|
|
149
|
+
type FeelValueType = "string" | "number" | "boolean" | "string list" | "number range" | "expression" | "any";
|
|
150
|
+
/** Lint-Ergebnis mit erkanntem Typ (erweitert `FeelLintResult`). */
|
|
151
|
+
interface FeelLintTypedResult extends FeelLintResult {
|
|
152
|
+
type?: FeelValueType;
|
|
153
|
+
}
|
|
154
|
+
/** Erlaubte Werte aus einem `inputValues`-String der Form `"A","B"` parsen. */
|
|
155
|
+
declare function parseInputValues(inputValues: string): string[];
|
|
156
|
+
/**
|
|
157
|
+
* Prüft einen FEEL-Zellausdruck heuristisch. `column` liefert (optional) die
|
|
158
|
+
* erlaubten `inputValues` für eine Whitelist-Validierung.
|
|
159
|
+
*/
|
|
160
|
+
declare function lintFeel(expr: string, column?: Pick<DmnColumn, "inputValues">): FeelLintTypedResult;
|
|
161
|
+
|
|
162
|
+
interface DmnTableEditorProps {
|
|
163
|
+
/** Controlled DMN-XML. */
|
|
164
|
+
value?: string;
|
|
165
|
+
/** Uncontrolled Start-XML. */
|
|
166
|
+
defaultValue?: string;
|
|
167
|
+
/** Wird bei jeder Modelländerung mit serialisiertem XML aufgerufen. */
|
|
168
|
+
onChange?: (xml: string) => void;
|
|
169
|
+
/** ⌘S / Speichern-Button. */
|
|
170
|
+
onSave?: (xml: string) => void | Promise<void>;
|
|
171
|
+
/** Wählt die zu editierende Decision (Default: erste mit Table). */
|
|
172
|
+
decisionId?: string;
|
|
173
|
+
/** Anzeigename (z. B. Prüfprozess-Code). */
|
|
174
|
+
title?: ReactNode;
|
|
175
|
+
/** Untertitel/Metadaten. */
|
|
176
|
+
subtitle?: ReactNode;
|
|
177
|
+
/** Umschalten zum Experten-Modus (⑥). */
|
|
178
|
+
onSwitchToExpert?: () => void;
|
|
179
|
+
/** Optionale Zell-Plugins (z. B. Prüfi-Autocomplete). Default: leer. */
|
|
180
|
+
cellPlugins?: DmnCellPlugin[];
|
|
181
|
+
/** Zusätzliche Toolbar-Actions (z. B. KI-Fix). */
|
|
182
|
+
actionsSlot?: ReactNode;
|
|
183
|
+
/** Schreibschutz. */
|
|
184
|
+
readOnly?: boolean;
|
|
185
|
+
className?: string;
|
|
186
|
+
}
|
|
187
|
+
declare function DmnTableEditor({ value, defaultValue, onChange, onSave, decisionId, title, subtitle, onSwitchToExpert, cellPlugins, actionsSlot, readOnly, className, }: DmnTableEditorProps): react.JSX.Element;
|
|
188
|
+
|
|
189
|
+
interface DmnExpertEditorProps {
|
|
190
|
+
/** Controlled DMN-XML. */
|
|
191
|
+
value?: string;
|
|
192
|
+
/** Uncontrolled Start-XML. */
|
|
193
|
+
defaultValue?: string;
|
|
194
|
+
/** Bei Änderungen (commandStack.changed) mit serialisiertem XML. */
|
|
195
|
+
onChange?: (xml: string) => void;
|
|
196
|
+
/** Speichern-Callback. */
|
|
197
|
+
onSave?: (xml: string) => void | Promise<void>;
|
|
198
|
+
/** Light/Dark-Steuerung (Default auto via data-theme). */
|
|
199
|
+
colorScheme?: DiagramColorScheme;
|
|
200
|
+
/** Zusätzliche Toolbar-Actions. */
|
|
201
|
+
actionsSlot?: ReactNode;
|
|
202
|
+
/** Umschalten zur Tabellenansicht (⑤). */
|
|
203
|
+
onSwitchToTable?: () => void;
|
|
204
|
+
/** Properties-Panel anzeigen, falls die Pakete vorhanden sind (Default true). */
|
|
205
|
+
propertiesPanel?: boolean;
|
|
206
|
+
className?: string;
|
|
207
|
+
}
|
|
208
|
+
declare function DmnExpertEditor({ value, defaultValue, onChange, onSave, colorScheme, actionsSlot, onSwitchToTable, propertiesPanel, className, }: DmnExpertEditorProps): react.JSX.Element;
|
|
209
|
+
|
|
210
|
+
type DmnEditorMode = "table" | "expert";
|
|
211
|
+
interface DmnEditorProps {
|
|
212
|
+
value?: string;
|
|
213
|
+
defaultValue?: string;
|
|
214
|
+
onChange?: (xml: string) => void;
|
|
215
|
+
onSave?: (xml: string) => void | Promise<void>;
|
|
216
|
+
/** Start-Modus (Default 'table'). */
|
|
217
|
+
defaultMode?: DmnEditorMode;
|
|
218
|
+
/** Controlled-Modus. */
|
|
219
|
+
mode?: DmnEditorMode;
|
|
220
|
+
onModeChange?: (mode: DmnEditorMode) => void;
|
|
221
|
+
colorScheme?: DiagramColorScheme;
|
|
222
|
+
title?: ReactNode;
|
|
223
|
+
subtitle?: ReactNode;
|
|
224
|
+
cellPlugins?: DmnTableEditorProps["cellPlugins"];
|
|
225
|
+
actionsSlot?: ReactNode;
|
|
226
|
+
decisionId?: string;
|
|
227
|
+
className?: string;
|
|
228
|
+
}
|
|
229
|
+
declare function DmnEditor({ value, defaultValue, onChange, onSave, defaultMode, mode: controlledMode, onModeChange, colorScheme, title, subtitle, cellPlugins, actionsSlot, decisionId, className, }: DmnEditorProps): react.JSX.Element;
|
|
230
|
+
|
|
231
|
+
export { type Aggregation, type DiagramColorScheme, type DiagramColors, type DmnCellPlugin, type DmnColumn, type DmnColumnKind, type DmnDecisionRef, DmnEditor, type DmnEditorMode, type DmnEditorProps, DmnExpertEditor, type DmnExpertEditorProps, type DmnRow, DmnTableEditor, type DmnTableEditorProps, type DmnTableModel, type FeelLintResult, type FeelLintTypedResult, type FeelValueType, type HitPolicy, type ParseOptions, addColumn, addRow, deleteColumn, deleteRow, emptyRow, getDiagramColors, isDarkMode, lintFeel, listDecisions, makeId, moveRow, onThemeChange, parseDmnModel, parseInputValues, readToken, serializeDmnModel, setHitPolicy, updateAnnotation, updateCell, updateColumn };
|