@wemake4u/dmn-boxed
v1.0.1
Published
DMN boxed expression editors
Maintainers
Readme
@wemake4u/dmn-boxed
The editors of DMN boxed expressions for Angular 22, used by the complete
@wemake4u/dmn-editor:
ElementEditorShell(dmn-element-editor-shell): the editor of the logic of a decision or business knowledge model (expression kind, result type, function signature and parameters, names in scope).- One editor per expression kind, found through a plugin registry and nested at any depth:
literal FEEL expression, decision table (hit policy, rules, columns, keyboard grid, gap and
overlap analysis), context, relation, list, invocation, function definition, conditional,
filter,
for,some,every. FeelCell(dmn-feel-cell): FEEL editing based on the editor of@wemake4u/feel-editor, with completion of the names in scope and a larger editing window (⤢ or Alt+Enter). In the window «Formatta» (Shift+Alt+F) formats the expression (spaces, line breaks only where it does not fit, indentation;formatFeelof the feel-editor), undone with Ctrl+Z; a text with syntax errors stays as it is. Inputformattinggives the same to a cell, methodformat().DataTypesEditor(dmn-data-types-editor) andDecisionServiceEditor(dmn-decision-service-editor).
Installation
npm install @wemake4u/dmn-boxed @wemake4u/dmn-core @wemake4u/code-editor @angular/formsPeer dependencies: @angular/core, @angular/common and @angular/forms 22.2.x,
@wemake4u/code-editor 2.x and @wemake4u/dmn-core 1.x. @wemake4u/code-editor and @angular/forms
are needed by @wemake4u/feel-editor (2.3 or later), which is installed with dmn-boxed, as tslib.
Usage
<dmn-element-editor-shell [store]="store" [elementId]="'Decision_1'" (back)="close()" />
<dmn-data-types-editor [store]="store" (back)="close()" />
<dmn-decision-service-editor [store]="store" [serviceId]="'DecisionService_1'" (back)="close()" />Every change goes through the commands of @wemake4u/dmn-core on the given store, so it is part
of the shared undo/redo history. With store.readOnly set, the editors show the model without
allowing changes.
Functions of the host
DmnFeelFunctions (root service) holds the functions of the host callable from FEEL
(entries, a list of FeelEntry of @wemake4u/dmn-core). The FEEL cells of the editors and
of "Prova" offer them in the completion, and ElementEditorShell lists them by namespace in its
side panel. DmnEditor fills its own instance from its feelFunctions input; an application
that composes the editors itself sets inject(DmnFeelFunctions).entries.
"Prova" and diagnostics
TestPanel (dmn-test-panel) is the "Prova" panel of the editors (inputs store, elementId,
evaluator; output diagnose with the evaluation and its trace). Its fields follow the types
of the inputs (TypedControl, dmn-typed-control), structures and lists are edited in
StructuredValueDialog (StructuredValueEditor inside, three widths), and a "Fields | FEEL"
switch shows the FEEL text that is sent; the shapes come from inputShape of dmn-core.
TraceStepDetail
(dmn-trace-step-detail) shows one step of a trace (inputs store, step, root, wide;
output selectStep). ValueViewer (dmn-value-viewer; inputs value, text, type, name,
context, open, toolbar) shows a value of an evaluation, with ValueWindow for large
values; value-model has the helpers (kinds, summaries, rows, search, tables). The diagnostics
on the diagram are DmnDiagnostics in @wemake4u/dmn-editor.
Custom expression editors
The editor of each expression kind comes from the EXPRESSION_EDITORS registry. A component
registered for a kind receives two inputs, expression (the semantic expression) and path
(its location in the element), and changes the model only with commands executed through the
ExpressionEditingContext:
import { Component, inject, input } from '@angular/core';
import { setExpressionText, type ExpressionPath, type LiteralExpression } from '@wemake4u/dmn-core';
import { ExpressionEditingContext, provideExpressionEditors } from '@wemake4u/dmn-boxed';
@Component({
selector: 'app-plain-literal',
template: `<textarea
[value]="expression().text"
[readOnly]="context.readOnly()"
(change)="save($event)"
></textarea>`,
})
export class PlainLiteralEditor {
readonly expression = input.required<LiteralExpression>();
readonly path = input.required<ExpressionPath>();
protected readonly context = inject(ExpressionEditingContext);
protected save(event: Event): void {
const text = (event.target as HTMLTextAreaElement).value;
this.context.execute(
setExpressionText({ elementId: this.context.elementId()!, path: this.path(), text }),
);
}
}
// in the providers of the application (or of the component hosting the editor):
provideExpressionEditors([
{ kind: 'literal', component: PlainLiteralEditor, creatable: 'literal' },
]);Later registrations override earlier ones for the same kind. Nested expressions are shown with
ExpressionHost (dmn-expression-host), which picks the registered editor.
Long relations and lists scroll in an area of their own, with the header row and the column of the numbers kept in place, so that both scroll bars and what follows the table (e.g. «Prova») stay at hand. The heights can be changed with CSS variables:
| Variable | Default | Area |
| ------------------------------- | ------------------ | ---------------------------------- |
| --dmn-boxed-max-height | max(240px, 60vh) | a relation or a list of the editor |
| --dmn-boxed-nested-max-height | 320px | a nested relation or list |
Spinner
DmnSpinner (dmn-spinner, input size, colour --dmn-spinner-color) is the spinner shown while a handler of the host is working; it is decorative (aria-hidden), the text next to it says what is happening.
License
MIT. The licenses of the dependencies are in THIRD_PARTY_NOTICES.txt.
