@motifx-community/ui 0.1.0-beta.14 → 0.1.0-beta.16
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/CHANGELOG.md +113 -0
- package/README.md +2 -2
- package/dist/components/diagram/Diagram.d.ts +607 -0
- package/dist/components/diagram/DiagramAutoPan.d.ts +17 -0
- package/dist/components/diagram/DiagramBends.d.ts +70 -0
- package/dist/components/diagram/DiagramDragging.d.ts +66 -0
- package/dist/components/diagram/DiagramEdgeView.d.ts +78 -0
- package/dist/components/diagram/DiagramGrid.d.ts +13 -0
- package/dist/components/diagram/DiagramHistory.d.ts +16 -0
- package/dist/components/diagram/DiagramLinks.d.ts +177 -0
- package/dist/components/diagram/DiagramMap.d.ts +62 -0
- package/dist/components/diagram/DiagramNodeView.d.ts +143 -0
- package/dist/components/diagram/DiagramOverview.d.ts +20 -0
- package/dist/components/diagram/DiagramPanning.d.ts +34 -0
- package/dist/components/diagram/diagram-alignment.d.ts +2 -0
- package/dist/components/diagram/diagram-auto-pan-host.d.ts +8 -0
- package/dist/components/diagram/diagram-background.d.ts +2 -0
- package/dist/components/diagram/diagram-bends-host.d.ts +17 -0
- package/dist/components/diagram/diagram-card-kind.d.ts +42 -0
- package/dist/components/diagram/diagram-card-node.d.ts +11 -0
- package/dist/components/diagram/diagram-center-options.d.ts +6 -0
- package/dist/components/diagram/diagram-change.d.ts +11 -0
- package/dist/components/diagram/diagram-class-member.d.ts +13 -0
- package/dist/components/diagram/diagram-class-node.d.ts +12 -0
- package/dist/components/diagram/diagram-column-checked-event-args.d.ts +9 -0
- package/dist/components/diagram/diagram-connected-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-connecting-event-args.d.ts +9 -0
- package/dist/components/diagram/diagram-connection.d.ts +7 -0
- package/dist/components/diagram/diagram-data.d.ts +12 -0
- package/dist/components/diagram/diagram-deleted-event-args.d.ts +8 -0
- package/dist/components/diagram/diagram-deleting-event-args.d.ts +9 -0
- package/dist/components/diagram/diagram-dragging-host.d.ts +47 -0
- package/dist/components/diagram/diagram-drawn-node.d.ts +10 -0
- package/dist/components/diagram/diagram-edge-end.d.ts +2 -0
- package/dist/components/diagram/diagram-edge-path.d.ts +5 -0
- package/dist/components/diagram/diagram-edge-reshaped-event-args.d.ts +8 -0
- package/dist/components/diagram/diagram-edge-reshaping-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-edge.d.ts +49 -0
- package/dist/components/diagram/diagram-edit.d.ts +10 -0
- package/dist/components/diagram/diagram-export-options.d.ts +14 -0
- package/dist/components/diagram/diagram-export.d.ts +28 -0
- package/dist/components/diagram/diagram-fit-options.d.ts +12 -0
- package/dist/components/diagram/diagram-history-changed-event-args.d.ts +14 -0
- package/dist/components/diagram/diagram-history-step.d.ts +9 -0
- package/dist/components/diagram/diagram-kinds.d.ts +9 -0
- package/dist/components/diagram/diagram-layered.d.ts +39 -0
- package/dist/components/diagram/diagram-layout-direction.d.ts +2 -0
- package/dist/components/diagram/diagram-layout-options.d.ts +24 -0
- package/dist/components/diagram/diagram-layout-type.d.ts +5 -0
- package/dist/components/diagram/diagram-layout.d.ts +33 -0
- package/dist/components/diagram/diagram-line-look.d.ts +6 -0
- package/dist/components/diagram/diagram-line.d.ts +11 -0
- package/dist/components/diagram/diagram-links-host.d.ts +45 -0
- package/dist/components/diagram/diagram-links-options.d.ts +7 -0
- package/dist/components/diagram/diagram-map-props.d.ts +10 -0
- package/dist/components/diagram/diagram-map-target.d.ts +27 -0
- package/dist/components/diagram/diagram-marker.d.ts +6 -0
- package/dist/components/diagram/diagram-mini-map-options.d.ts +13 -0
- package/dist/components/diagram/diagram-mini-map-position.d.ts +2 -0
- package/dist/components/diagram/diagram-node-context.d.ts +26 -0
- package/dist/components/diagram/diagram-node-host.d.ts +23 -0
- package/dist/components/diagram/diagram-node-kind.d.ts +43 -0
- package/dist/components/diagram/diagram-node-move.d.ts +11 -0
- package/dist/components/diagram/diagram-node-resized-event-args.d.ts +8 -0
- package/dist/components/diagram/diagram-node-resizing-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-node-size.d.ts +8 -0
- package/dist/components/diagram/diagram-node-status.d.ts +2 -0
- package/dist/components/diagram/diagram-node-toggled-event-args.d.ts +7 -0
- package/dist/components/diagram/diagram-node.d.ts +56 -0
- package/dist/components/diagram/diagram-nodes-moved-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-nodes-moving-event-args.d.ts +6 -0
- package/dist/components/diagram/diagram-panning-host.d.ts +19 -0
- package/dist/components/diagram/diagram-pasted-event-args.d.ts +7 -0
- package/dist/components/diagram/diagram-pasting-event-args.d.ts +11 -0
- package/dist/components/diagram/diagram-path-ends.d.ts +11 -0
- package/dist/components/diagram/diagram-path-result.d.ts +6 -0
- package/dist/components/diagram/diagram-paths.d.ts +35 -0
- package/dist/components/diagram/diagram-point.d.ts +5 -0
- package/dist/components/diagram/diagram-port-place.d.ts +9 -0
- package/dist/components/diagram/diagram-port.d.ts +27 -0
- package/dist/components/diagram/diagram-props.d.ts +159 -0
- package/dist/components/diagram/diagram-reconnected-event-args.d.ts +10 -0
- package/dist/components/diagram/diagram-reconnecting-event-args.d.ts +11 -0
- package/dist/components/diagram/diagram-rect.d.ts +7 -0
- package/dist/components/diagram/diagram-resize-side.d.ts +2 -0
- package/dist/components/diagram/diagram-route.d.ts +10 -0
- package/dist/components/diagram/diagram-selection-changed-event-args.d.ts +9 -0
- package/dist/components/diagram/diagram-selection.d.ts +5 -0
- package/dist/components/diagram/diagram-side.d.ts +2 -0
- package/dist/components/diagram/diagram-table-column.d.ts +13 -0
- package/dist/components/diagram/diagram-table-node.d.ts +12 -0
- package/dist/components/diagram/diagram-tree.d.ts +14 -0
- package/dist/components/diagram/diagram-viewport-changed-event-args.d.ts +8 -0
- package/dist/components/diagram/diagram-viewport-options.d.ts +5 -0
- package/dist/components/diagram/diagram-viewport.d.ts +6 -0
- package/dist/components/diagram/index.d.ts +65 -0
- package/dist/components/diagram/swallow-next-click.d.ts +5 -0
- package/dist/components/expressioneditor/ExpressionEditor.d.ts +111 -0
- package/dist/components/expressioneditor/expression-editor-props.d.ts +24 -0
- package/dist/components/expressioneditor/index.d.ts +2 -0
- package/dist/components/formlayout/FormLayout.d.ts +10 -3
- package/dist/components/formlayout/form-editor-type.d.ts +1 -1
- package/dist/components/formlayout/form-item.d.ts +4 -1
- package/dist/components/formlayout/form-layout-props.d.ts +1 -1
- package/dist/components/formlayout/index.d.ts +1 -0
- package/dist/components/formlayout/schema-items.d.ts +26 -0
- package/dist/components/pivotgrid/model/PivotAxisWindow.d.ts +53 -1
- package/dist/components/pivotgrid/model/PivotCellWindow.d.ts +2 -0
- package/dist/components/pivotgrid/model/PivotWindows.d.ts +3 -6
- package/dist/components/toolbar/Toolbar.d.ts +5 -3
- package/dist/core/control.d.ts +2 -0
- package/dist/core/keyboard.d.ts +5 -0
- package/dist/core/measure/index.d.ts +2 -0
- package/dist/core/measure/picture.d.ts +27 -0
- package/dist/core/shortcut-options.d.ts +5 -2
- package/dist/core/ui-strings.d.ts +191 -0
- package/dist/generated/tokens.d.ts +1615 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11501 -705
- package/dist/index.js.map +1 -1
- package/dist/locales/en.json +180 -1
- package/dist/locales/tr.json +180 -1
- package/dist/styles.css +2262 -3
- package/dist/tokens/index.d.ts +1615 -0
- package/dist/tokens/index.js +1615 -0
- package/dist/tokens/index.js.map +1 -1
- package/dist/{tr-BGbF9uCs.js → tr-4GNbFdQh.js} +361 -3
- package/dist/{tr-BGbF9uCs.js.map → tr-4GNbFdQh.js.map} +1 -1
- package/docs/accordion.md +1 -1
- package/docs/actionsheet.md +1 -1
- package/docs/appbar.md +1 -1
- package/docs/appmenu-api.md +1 -1
- package/docs/appmenu-programmatic.md +1 -1
- package/docs/appmenu-search.md +1 -1
- package/docs/appmenu.md +1 -1
- package/docs/avatar.md +1 -1
- package/docs/badge.md +1 -1
- package/docs/bar-gauge-angles.md +1 -1
- package/docs/bar-gauge-data.md +1 -1
- package/docs/bar-gauge-labels.md +1 -1
- package/docs/bar-gauge.md +1 -1
- package/docs/barcode.md +1 -1
- package/docs/bottomnavigation.md +1 -1
- package/docs/bottomsheet.md +1 -1
- package/docs/breadcrumb.md +1 -1
- package/docs/button.md +1 -1
- package/docs/buttongroup.md +1 -1
- package/docs/buttons.md +1 -1
- package/docs/calendar.md +1 -1
- package/docs/card.md +1 -1
- package/docs/chart-bars.md +1 -1
- package/docs/chart-candles.md +1 -1
- package/docs/chart-funnel.md +1 -1
- package/docs/chart-heatmap.md +1 -1
- package/docs/chart-lines.md +1 -1
- package/docs/chart-live.md +1 -1
- package/docs/chart-pie.md +1 -1
- package/docs/chart-radar.md +1 -1
- package/docs/chart-ranges.md +1 -1
- package/docs/chart-references.md +1 -1
- package/docs/chart-scatter.md +1 -1
- package/docs/chart-waterfall.md +1 -1
- package/docs/chart-zoom.md +1 -1
- package/docs/chart.md +1 -1
- package/docs/chat.md +1 -1
- package/docs/checkbox.md +1 -1
- package/docs/chip.md +1 -1
- package/docs/choice.md +1 -1
- package/docs/colorbox.md +1 -1
- package/docs/combobox.md +1 -1
- package/docs/commands.md +1 -1
- package/docs/control.md +1 -1
- package/docs/data.md +2 -2
- package/docs/datagrid-api.md +1 -1
- package/docs/datagrid-bands.md +1 -1
- package/docs/datagrid-drag-select.md +1 -1
- package/docs/datagrid-drag.md +1 -1
- package/docs/datagrid-editing.md +1 -1
- package/docs/datagrid-filtering.md +1 -1
- package/docs/datagrid-forms.md +1 -1
- package/docs/datagrid-grouping.md +1 -1
- package/docs/datagrid-layout.md +1 -1
- package/docs/datagrid-lookups.md +1 -1
- package/docs/datagrid-master-detail.md +1 -1
- package/docs/datagrid-scrolling.md +1 -1
- package/docs/datagrid-selection.md +1 -1
- package/docs/datagrid.md +1 -1
- package/docs/datalayer-api.md +491 -0
- package/docs/datalayer-changes.md +501 -0
- package/docs/datalayer-odata.md +998 -0
- package/docs/datalayer-pivot.md +850 -0
- package/docs/datalayer-queries.md +516 -0
- package/docs/datalayer-rest.md +529 -0
- package/docs/datalayer-soap.md +576 -0
- package/docs/datalayer-source.md +464 -0
- package/docs/datalayer.md +264 -0
- package/docs/datebox.md +1 -1
- package/docs/daterangebox.md +1 -1
- package/docs/diagram-api.md +200 -0
- package/docs/diagram-commands.md +79 -0
- package/docs/diagram-connections.md +157 -0
- package/docs/diagram-custom-nodes.md +325 -0
- package/docs/diagram-designer.md +816 -0
- package/docs/diagram-editing.md +62 -0
- package/docs/diagram-flow.md +157 -0
- package/docs/diagram-keyboard.md +58 -0
- package/docs/diagram-layout.md +354 -0
- package/docs/diagram-nodes.md +206 -0
- package/docs/diagram-tables.md +212 -0
- package/docs/diagram.md +217 -0
- package/docs/display.md +1 -1
- package/docs/draggable.md +1 -1
- package/docs/drawer.md +1 -1
- package/docs/dropdown.md +1 -1
- package/docs/editors.md +1 -1
- package/docs/expressioneditor.md +469 -0
- package/docs/expressions.md +431 -0
- package/docs/feedback.md +1 -1
- package/docs/fileuploader.md +1 -1
- package/docs/filterbuilder.md +1 -1
- package/docs/formlayout-schema.md +143 -0
- package/docs/formlayout.md +16 -4
- package/docs/foundations.md +1 -1
- package/docs/gallery.md +1 -1
- package/docs/gauge-base.md +1 -1
- package/docs/gauge-circular.md +1 -1
- package/docs/gauge-dashboards.md +1 -1
- package/docs/gauge-linear.md +1 -1
- package/docs/gauge-markers.md +1 -1
- package/docs/gauge-marks.md +1 -1
- package/docs/gauge-ranges.md +1 -1
- package/docs/gauge-scales.md +1 -1
- package/docs/gauge.md +1 -1
- package/docs/home.md +1 -1
- package/docs/keyboard.md +2 -2
- package/docs/language.md +1 -1
- package/docs/layout.md +1 -1
- package/docs/listbox.md +1 -1
- package/docs/loadpanel.md +1 -1
- package/docs/lookup.md +1 -1
- package/docs/markdown.md +1 -1
- package/docs/menus-api.md +1 -1
- package/docs/menus-context.md +1 -1
- package/docs/menus-customization.md +1 -1
- package/docs/menus-merging.md +1 -1
- package/docs/menus-programmatic.md +1 -1
- package/docs/menus.md +1 -1
- package/docs/multiview.md +1 -1
- package/docs/navigation.md +1 -1
- package/docs/numberbox.md +1 -1
- package/docs/otpinput.md +1 -1
- package/docs/pagination.md +1 -1
- package/docs/pivotgrid-api.md +1 -1
- package/docs/pivotgrid-chart.md +1 -1
- package/docs/pivotgrid-drilldown.md +1 -1
- package/docs/pivotgrid-export.md +1 -1
- package/docs/pivotgrid-fields.md +1 -1
- package/docs/pivotgrid-keyboard.md +1 -1
- package/docs/pivotgrid-layout.md +1 -1
- package/docs/pivotgrid-panel.md +1 -1
- package/docs/pivotgrid-remote.md +122 -44
- package/docs/pivotgrid-sorting.md +3 -3
- package/docs/pivotgrid-state.md +1 -1
- package/docs/pivotgrid-summaries.md +1 -1
- package/docs/pivotgrid.md +1 -1
- package/docs/popover.md +1 -1
- package/docs/progress.md +1 -1
- package/docs/qrcode.md +1 -1
- package/docs/radiogroup.md +1 -1
- package/docs/rating.md +1 -1
- package/docs/resizable.md +1 -1
- package/docs/ribbonmenu-api.md +1 -1
- package/docs/ribbonmenu-commands.md +1 -1
- package/docs/ribbonmenu-customization.md +1 -1
- package/docs/ribbonmenu-display.md +1 -1
- package/docs/ribbonmenu-layouts.md +1 -1
- package/docs/ribbonmenu-programmatic.md +1 -1
- package/docs/ribbonmenu.md +1 -1
- package/docs/scheduler-agenda.md +1 -1
- package/docs/scheduler-big-data.md +1 -1
- package/docs/scheduler-editing.md +1 -1
- package/docs/scheduler-form.md +1 -1
- package/docs/scheduler-icalendar.md +1 -1
- package/docs/scheduler-mobile.md +1 -1
- package/docs/scheduler-recurrence.md +1 -1
- package/docs/scheduler-resources.md +1 -1
- package/docs/scheduler-timeline.md +1 -1
- package/docs/scheduler.md +1 -1
- package/docs/scrollview.md +1 -1
- package/docs/shortcuteditor.md +1 -1
- package/docs/showcase-flowstudio.md +61 -0
- package/docs/showcase-home.md +1 -1
- package/docs/showcase-mail.md +1 -1
- package/docs/showcase.md +1 -1
- package/docs/signature.md +1 -1
- package/docs/skeleton.md +1 -1
- package/docs/slider.md +1 -1
- package/docs/sortable.md +1 -1
- package/docs/sparkline.md +1 -1
- package/docs/speeddial.md +1 -1
- package/docs/splitter.md +1 -1
- package/docs/stepper.md +1 -1
- package/docs/switch.md +1 -1
- package/docs/tabdocs-dock.md +1 -1
- package/docs/tabdocs-drag.md +1 -1
- package/docs/tabdocs-menus.md +1 -1
- package/docs/tabdocs-mobile.md +1 -1
- package/docs/tabdocs-tabs.md +1 -1
- package/docs/tabdocs-windows.md +1 -1
- package/docs/tabdocs-workspace.md +1 -1
- package/docs/tabdocs.md +1 -1
- package/docs/tabs.md +1 -1
- package/docs/tagbox.md +1 -1
- package/docs/textarea.md +1 -1
- package/docs/textbox.md +1 -1
- package/docs/tileview.md +1 -1
- package/docs/timeline.md +1 -1
- package/docs/toast.md +1 -1
- package/docs/tokens.md +324 -1
- package/docs/toolbar-api.md +1 -1
- package/docs/toolbar-customization.md +1 -1
- package/docs/toolbar.md +1 -1
- package/docs/tooltip.md +1 -1
- package/docs/treeview.md +1 -1
- package/docs/validationsummary.md +1 -1
- package/docs/window.md +1 -1
- package/docs/wizard.md +1 -1
- package/llms-full.txt +10142 -462
- package/llms.txt +32 -1
- package/package.json +2 -2
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Data layer
|
|
2
|
+
|
|
3
|
+
> Data layer · @motifx-community/data 0.1.0-beta.3
|
|
4
|
+
|
|
5
|
+
The data package, `@motifx-community/data`, loads and saves the rows of an application through one contract, whether they are held in memory or served by a REST endpoint, an OData service or a SOAP service. It filters, sorts, groups, summarizes and pivots rows on the backend where the backend supports it, and in memory where it does not.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
npm i @motifx/core @motifx-community/data
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The package exports three namespace objects: `data` for adapters, data sources, change tracking, filters and pivots; `expression` for the expression language; and `jsonSchema` for schema validation. Because they are ES module namespaces, a bundler still removes the members an application does not use, and types are referenced through them as well, as in `data.LoadOptions`.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { data } from '@motifx-community/data';
|
|
17
|
+
|
|
18
|
+
const orders = new data.ArrayAdapter<Order, number>({ data: rows, key: 'id' });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Without a bundler, the UMD build adds the same three objects to the global `motif` object of `@motifx/core`: `motif.data`, `motif.expression` and `motif.jsonSchema`.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
<script src="https://unpkg.com/@motifx/core/dist/index.umd.min.js"></script>
|
|
25
|
+
<script src="https://unpkg.com/@motifx-community/data/dist/index.umd.js"></script>
|
|
26
|
+
<script>
|
|
27
|
+
const orders = new motif.data.ODataAdapter({ url: 'https://host/odata/Orders', key: 'OrderID' });
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
An adapter is created with the address of its backend and the key of its rows. `load` takes a query and resolves to a `LoadResult` that holds the rows and, when `count` is set, the total number of matching rows. `insert` resolves to the saved row, including the key the backend assigned.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { data } from '@motifx-community/data';
|
|
37
|
+
|
|
38
|
+
const orders = new data.RestAdapter<Order, number>({
|
|
39
|
+
url: '/api/orders',
|
|
40
|
+
key: 'id',
|
|
41
|
+
headers: () => ({ Authorization: `Bearer ${session.token}` }),
|
|
42
|
+
timeoutMs: 15_000,
|
|
43
|
+
retry: { retries: 2 },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const page = await orders.load({
|
|
47
|
+
filter: data.and(data.where('city', '=', 'Ankara'), data.where('amount', '>=', 100)),
|
|
48
|
+
sort: [{ field: 'customer', dir: 'asc' }],
|
|
49
|
+
skip: 0,
|
|
50
|
+
take: 20,
|
|
51
|
+
count: true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const saved = await orders.insert({ customer: 'Elif Demir', amount: 5 });
|
|
55
|
+
await orders.update(saved.id, { amount: 6 });
|
|
56
|
+
await orders.remove(saved.id);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
A component rarely calls the adapter itself. It reads a `DataSource`, which loads through the adapter, keeps the query and the loaded rows, and reports every change; see [DataSource](datalayer-source.md).
|
|
60
|
+
|
|
61
|
+
## Parts of the data layer
|
|
62
|
+
|
|
63
|
+
| Member | Purpose |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `ArrayAdapter RestAdapter ODataAdapter SoapAdapter` | Adapters. Each one loads and saves the rows of one kind of backend through the same contract. |
|
|
66
|
+
| `DataSource` | The rows a component shows: the query, the loaded rows, pages or blocks, groups, summaries and the loading status. See [DataSource](datalayer-source.md). |
|
|
67
|
+
| `ChangeTracker` | Unsaved edits, new rows and deletions over a data source, validated and saved row by row or in a batch. See [Tracking and saving changes](datalayer-changes.md). |
|
|
68
|
+
| `where and or not` | Filters as plain data. Every adapter translates them for its backend or applies them in memory. See [Filtering, sorting and grouping](datalayer-queries.md). |
|
|
69
|
+
| `loadPivot` | Pivots, loaded whole or in parts, computed by the backend or in memory. See [Pivots and loading in parts](datalayer-pivot.md). |
|
|
70
|
+
| `expression` | An expression language for conditions, computed values and text templates, checked against a schema. See [Expression language](expressions.md). |
|
|
71
|
+
| `jsonSchema` | Validation and default values from a JSON Schema; forms built from a schema use it. See [FormLayout: From a schema](formlayout-schema.md). |
|
|
72
|
+
|
|
73
|
+
## Choosing an adapter
|
|
74
|
+
|
|
75
|
+
Every adapter provides the same operations: `load`, `count`, `byKey`, `insert`, `update`, `remove`, `save` for several changes with one outcome per change, and `push` for changes made elsewhere. Code written against one adapter therefore works against another, and a data source accepts any of them.
|
|
76
|
+
|
|
77
|
+
| Adapter | Backend | Details |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `ArrayAdapter` | Rows in memory: an array the application holds, or a function that returns one. | [Rows in memory](#memory) |
|
|
80
|
+
| `RestAdapter` | An HTTP endpoint with a JSON protocol. Every request and answer can be changed. | [REST](datalayer-rest.md) |
|
|
81
|
+
| `ODataAdapter` | An OData v4 service: queries, aggregation with `$apply`, entity tags and `$batch`. | [OData](datalayer-odata.md) |
|
|
82
|
+
| `SoapAdapter` | A SOAP 1.1 or 1.2 service, such as a WCF service, called through named operations. | [SOAP and WCF](datalayer-soap.md) |
|
|
83
|
+
| `DataAdapter HttpAdapter` | The base classes for an adapter of your own, for any other backend. | [Custom adapters](datalayer-api.md#custom) |
|
|
84
|
+
|
|
85
|
+
## Rows in memory
|
|
86
|
+
|
|
87
|
+
`ArrayAdapter` serves rows the application already holds, with the same API as the adapters of remote backends. It keeps the row objects as they are: `insert(row)` adds that object to the array and resolves to the same object, and loads, `byKey`, `update`, `push` and the events return the same objects. Rows may be plain objects or reactive objects; the adapter stores them as it receives them.
|
|
88
|
+
|
|
89
|
+
A new row without a key receives one from `createKey`, which is written onto the object; without `createKey`, inserting such a row fails with `MJD304`. `adapter.rows` returns the current array. `setData(rows)`, or an assignment to `adapter.data`, replaces it with an array or with a function that is read on every operation; every data source over the adapter then loads the new rows from the first row.
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
/** An order of the examples on this page. */
|
|
93
|
+
export interface Order {
|
|
94
|
+
id: number;
|
|
95
|
+
customer: string;
|
|
96
|
+
city: string;
|
|
97
|
+
orderedOn: string;
|
|
98
|
+
amount: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const CUSTOMERS = ['Elif Demir', 'Can Yılmaz', 'Zeynep Kaya', 'Mert Şahin', 'Ayşe Çelik', 'Deniz Arslan', 'Burak Koç', 'Selin Aydın'];
|
|
102
|
+
const CITIES = ['Ankara', 'Bursa', 'İstanbul', 'İzmir', 'Konya', 'Trabzon'];
|
|
103
|
+
|
|
104
|
+
/** `n` orders, the same ones every time. */
|
|
105
|
+
export function makeOrders(n: number): Order[] {
|
|
106
|
+
const day = Date.UTC(2026, 0, 1);
|
|
107
|
+
return Array.from({ length: n }, (_, i) => ({
|
|
108
|
+
id: i + 1,
|
|
109
|
+
customer: CUSTOMERS[(i * 5) % CUSTOMERS.length],
|
|
110
|
+
city: CITIES[(i * 7) % CITIES.length],
|
|
111
|
+
orderedOn: new Date(day + ((i * 37) % 300) * 86_400_000).toISOString().slice(0, 10),
|
|
112
|
+
amount: ((i * 7919) % 50_000) / 100,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The example above holds 1,000 orders in an `ArrayAdapter`. The data source searches the customer and city fields, and the grid shows its rows. An order added through the adapter appears in the grid at once, because changes saved through an adapter reach every data source over it. The list under the grid shows the adapter's events as they occur.
|
|
118
|
+
|
|
119
|
+
## Where the work runs
|
|
120
|
+
|
|
121
|
+
An adapter describes what its backend does itself with `Capabilities`: filtering, sorting, paging, counting, field selection, grouping, summaries, pivots, inserts, updates and removals. A backend runs the parts of a query its capabilities include; the adapter runs the rest in memory over the rows the backend returns. The option `capabilities` turns off what a particular endpoint does not support:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
// The endpoint returns every row: filtering, sorting and paging run in memory.
|
|
125
|
+
const cities = new data.RestAdapter<City, string>({
|
|
126
|
+
url: '/api/cities',
|
|
127
|
+
key: 'code',
|
|
128
|
+
capabilities: { filter: false, sort: false, paging: false },
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
In memory, text is compared without regard to case, using the case rules of the adapter's `locale`; with `locale: 'tr'`, `İ` matches `i` and `I` matches `ı`. The option `fields` declares the type of a field (`string`, `number`, `boolean`, `date`, `datetime` or `guid`), which decides how its values are compared and how adapters such as OData write them in a request. [Filtering, sorting and grouping](datalayer-queries.md) describes the per-field options `sortValue`, `compare` and `filterValue`, and [the API reference](datalayer-api.md#capabilities) lists every capability.
|
|
133
|
+
|
|
134
|
+
## Events
|
|
135
|
+
|
|
136
|
+
`onLoading`, `onInserting`, `onUpdating` and `onRemoving` occur before the backend is called; a listener can change what is sent, or cancel the operation by setting `cancel` to `true`. `onLoaded`, `onInserted`, `onUpdated`, `onRemoved`, `onChanged` and `onError` occur after it. They are `@motifx/core` events: subscribing returns an `IDisposable`, which a component registers so that the subscription ends with the component.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
class OrderList extends Component<HTMLDivElement> {
|
|
140
|
+
onConfig() {
|
|
141
|
+
this.motif.register(orders.onChanged(({ changes }) => this.apply(changes)));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Errors
|
|
147
|
+
|
|
148
|
+
Every operation that fails rejects with a `DataError`, a `MotifError` whose message reads `[motifjs-data] MJD202: Must be positive`. Its `code` is stable, `kind` is the category to react to, `plainMessage` is the message without the prefix, and `fields` holds the messages of a validation error by field. The loads of a data source do not reject: a failed load sets its `status` to `'error'` and its `error` to the `DataError`, and `retry()` loads again.
|
|
149
|
+
|
|
150
|
+
| Codes | Concern |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `MJD101–MJD109` | The request: the backend cannot be reached, it does not answer in time, it answers with an HTTP error status or with content that cannot be read, the request is cancelled, or the resilience policy holds it back. |
|
|
153
|
+
| `MJD201–MJD205` | The answer of the backend: a server error, a validation error with messages by field, a key that exists already, a row that does not exist, or a row changed elsewhere since it was read. |
|
|
154
|
+
| `MJD301–MJD305` | The use of the adapter: an operation the adapter cannot perform, invalid options, a missing `key` setting, a new row without a key, or a change saved without the row as it was read. |
|
|
155
|
+
|
|
156
|
+
[The API reference](datalayer-api.md#errors) lists every code with its kind.
|
|
157
|
+
|
|
158
|
+
## Components that take a data source
|
|
159
|
+
|
|
160
|
+
The components of `@motifx-community/ui` that show rows accept a `DataSource` as `dataSource` and read it through its public API. A `FilterBuilder` produces the data layer's filter format, ready for a data source or an adapter.
|
|
161
|
+
|
|
162
|
+
| Component | Use of the source |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `DataGrid` | Pages, scrolls, sorts, filters, groups and edits the rows of the source. See [DataGrid](datagrid.md). |
|
|
165
|
+
| `PivotGrid` | Loads a pivot of the source, whole or in parts as it scrolls. See [PivotGrid](pivotgrid.md). |
|
|
166
|
+
| `ListBox TagBox` | Show and select items of the source; long lists load as they scroll. See [ListBox](listbox.md) and [TagBox](tagbox.md). |
|
|
167
|
+
| `DropDown ComboBox Lookup` | Select a value from the source; the selected row is found by its key even when it is on no loaded page. See [Lookup](lookup.md). |
|
|
168
|
+
| `Chart Scheduler` | Draw the rows of the source as series, or as appointments. See [Chart](chart.md) and [Scheduler](scheduler.md). |
|
|
169
|
+
|
|
170
|
+
## Feedback
|
|
171
|
+
|
|
172
|
+
Loading issues…
|
|
173
|
+
|
|
174
|
+
## Example files
|
|
175
|
+
|
|
176
|
+
`Overview.tsx`
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { reactive } from '@motifx/core';
|
|
180
|
+
import { data } from '@motifx-community/data';
|
|
181
|
+
import { Button, DataGrid, Stack, TextBox, type GridColumn } from '@motifx-community/ui';
|
|
182
|
+
import { makeOrders, type Order } from './orders';
|
|
183
|
+
|
|
184
|
+
const columns: GridColumn<Order>[] = [
|
|
185
|
+
{ field: 'id', title: 'No', type: 'number', width: 80 },
|
|
186
|
+
{ field: 'customer', title: 'Customer', width: 160, flex: 1 },
|
|
187
|
+
{ field: 'city', title: 'City', width: 120 },
|
|
188
|
+
{ field: 'orderedOn', title: 'Ordered on', type: 'date', width: 130 },
|
|
189
|
+
{ field: 'amount', title: 'Amount', type: 'number', width: 110 },
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
/** Orders in memory behind an adapter, a data source that searches them for a grid, and the adapter's events. */
|
|
193
|
+
export default function Overview() {
|
|
194
|
+
const s = reactive({ total: 0, events: [] as { id: number; text: string }[] });
|
|
195
|
+
let seq = 0;
|
|
196
|
+
const log = (text: string) => {
|
|
197
|
+
s.events.unshift({ id: ++seq, text });
|
|
198
|
+
if (s.events.length > 5) s.events.pop();
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const orders = new data.ArrayAdapter<Order, number>({
|
|
202
|
+
data: makeOrders(1000),
|
|
203
|
+
key: 'id',
|
|
204
|
+
createKey: (_values, rows) => rows.length + 1,
|
|
205
|
+
});
|
|
206
|
+
orders.onLoading(({ options }) => log(`onLoading: filter ${JSON.stringify(options.filter ?? null)}`));
|
|
207
|
+
orders.onLoaded(({ result }) => log(`onLoaded: ${result.rows.length} rows`));
|
|
208
|
+
orders.onInserted(({ key }) => log(`onInserted: order ${key}`));
|
|
209
|
+
|
|
210
|
+
const source = new data.DataSource<Order, number>({
|
|
211
|
+
adapter: orders,
|
|
212
|
+
loadMode: 'all',
|
|
213
|
+
sort: [{ field: 'id', dir: 'desc' }],
|
|
214
|
+
searchFields: ['customer', 'city'],
|
|
215
|
+
});
|
|
216
|
+
source.onChanged(() => (s.total = source.total ?? source.rows.length));
|
|
217
|
+
|
|
218
|
+
const add = () => orders.insert({ customer: 'New customer', city: 'Ankara', orderedOn: '2026-11-26', amount: 0 });
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<>
|
|
222
|
+
<Stack orientation="horizontal" wrap align="end">
|
|
223
|
+
<TextBox label="Search" placeholder="Customer or city" updateOn="input" onValueChanged={(e) => source.search(String(e.value ?? ''))} />
|
|
224
|
+
<Button text="Add an order" variant="outline" onclick={add} />
|
|
225
|
+
<output>{() => `${s.total.toLocaleString('en')} orders`}</output>
|
|
226
|
+
</Stack>
|
|
227
|
+
<DataGrid style="block-size: 22rem" dataSource={source} columns={columns} label="Orders in memory" locale="en" />
|
|
228
|
+
<ol aria-label="Adapter events" aria-live="polite">
|
|
229
|
+
{s.events.map((e) => (
|
|
230
|
+
<li key={e.id}>{e.text}</li>
|
|
231
|
+
))}
|
|
232
|
+
</ol>
|
|
233
|
+
</>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
`orders.ts`
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
/** An order of the examples on this page. */
|
|
242
|
+
export interface Order {
|
|
243
|
+
id: number;
|
|
244
|
+
customer: string;
|
|
245
|
+
city: string;
|
|
246
|
+
orderedOn: string;
|
|
247
|
+
amount: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const CUSTOMERS = ['Elif Demir', 'Can Yılmaz', 'Zeynep Kaya', 'Mert Şahin', 'Ayşe Çelik', 'Deniz Arslan', 'Burak Koç', 'Selin Aydın'];
|
|
251
|
+
const CITIES = ['Ankara', 'Bursa', 'İstanbul', 'İzmir', 'Konya', 'Trabzon'];
|
|
252
|
+
|
|
253
|
+
/** `n` orders, the same ones every time. */
|
|
254
|
+
export function makeOrders(n: number): Order[] {
|
|
255
|
+
const day = Date.UTC(2026, 0, 1);
|
|
256
|
+
return Array.from({ length: n }, (_, i) => ({
|
|
257
|
+
id: i + 1,
|
|
258
|
+
customer: CUSTOMERS[(i * 5) % CUSTOMERS.length],
|
|
259
|
+
city: CITIES[(i * 7) % CITIES.length],
|
|
260
|
+
orderedOn: new Date(day + ((i * 37) % 300) * 86_400_000).toISOString().slice(0, 10),
|
|
261
|
+
amount: ((i * 7919) % 50_000) / 100,
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
```
|
package/docs/datebox.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DateBox
|
|
2
2
|
|
|
3
|
-
> Editors · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Editors · @motifx-community/ui 0.1.0-beta.16
|
|
4
4
|
|
|
5
5
|
An input for a date, a time or both. Users can type through a mask in the locale's order, or pick from a calendar and a list of times. `min`, `max` and `disabledDates` apply to both methods.
|
|
6
6
|
|
package/docs/daterangebox.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DateRangeBox
|
|
2
2
|
|
|
3
|
-
> Editors · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Editors · @motifx-community/ui 0.1.0-beta.16
|
|
4
4
|
|
|
5
5
|
A single field for a start date and an end date. Users can type through two masks, or pick from two side-by-side months and a list of presets, within the allowed dates and range length. The value is a `[start, end]` pair.
|
|
6
6
|
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Diagram: API reference
|
|
2
|
+
|
|
3
|
+
> Diagram · @motifx-community/ui 0.1.0-beta.16
|
|
4
|
+
|
|
5
|
+
The props, members, events, styling hooks and design tokens of `Diagram` and `DiagramMap`.
|
|
6
|
+
|
|
7
|
+
## API reference
|
|
8
|
+
|
|
9
|
+
### Props
|
|
10
|
+
|
|
11
|
+
| Prop | Type | Default | Description |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| `nodes` | `Bind<DiagramNode[]>` | `[]` | The nodes. Later nodes are drawn over earlier ones. When the array is given again, nodes are matched by `id`, so a node that stays keeps its element and only the values that changed are written. |
|
|
14
|
+
| `edges` | `Bind<DiagramEdge[]>` | `[]` | The connections, matched by `id`. A connection the user draws is added to this array, and an end the user moves is written to its edge, so the data always matches the diagram. |
|
|
15
|
+
| `kinds` | `Bind<Record<string, DiagramNodeKind>>` | `{}` | The app’s kinds of node, by the name a node gives in `kind`: the content of its nodes, their ports, look and size limits, whether they are resized and whether they hold other nodes. A kind of the app’s own takes the place of a built-in one of the same name (`group`, `lane`, `note`). |
|
|
16
|
+
| `edgePath` | `Bind<'straight' \| 'curve' \| 'step' \| 'rounded-step' \| 'orthogonal' \| 'rounded-orthogonal'>` | `'curve'` | The shape of a connection that does not set its own. `orthogonal` lines go around the nodes in their way. |
|
|
17
|
+
| `connectable` | `Bind<boolean>` | `true` | Whether the user can draw connections from the ports and move their ends. |
|
|
18
|
+
| `canConnect` | `(connection: DiagramConnection) => boolean` | | The app’s own rule for a connection, applied after the diagram’s rules. Return `false` to refuse it. |
|
|
19
|
+
| `draggable` | `Bind<boolean>` | `true` | Whether the user can drag nodes. |
|
|
20
|
+
| `selectable` | `Bind<boolean>` | `true` | Whether the user can select nodes and connections. |
|
|
21
|
+
| `deletable` | `Bind<boolean>` | `true` | Whether the user can delete the selection with Delete or Backspace. |
|
|
22
|
+
| `readOnly` | `Bind<boolean>` | `false` | Shows the diagram as it is: the user selects, pans, zooms and copies, and changes nothing. No node or connection is added, moved, resized, collapsed, reshaped, pasted or deleted, and undo and redo are off. What the app changes in code (`record`, `undo`, `setCollapsed`, the arrays) still changes it. |
|
|
23
|
+
| `snapToGrid` | `Bind<boolean>` | `false` | Snaps dragged nodes to the grid of `gridSize`. |
|
|
24
|
+
| `guides` | `Bind<boolean>` | `true` | Lines a dragged node up with the edges and middles of the other nodes, and shows guides while it does. |
|
|
25
|
+
| `history` | `Bind<boolean>` | `true` | Keeps the user’s steps to undo and redo. `false` clears the history. |
|
|
26
|
+
| `commandScope` | `Bind<ComponentBase \| null>` | The diagram | The component the diagram’s commands are held to. Their keys work while focus is inside it, and the toolbars and menus inside it run this diagram’s commands. Give the editor that holds the diagram and its toolbar. |
|
|
27
|
+
| `viewport` | `Bind<DiagramViewport>` | `{ x: 0, y: 0, zoom: 1 }` | The position of the view. Panning and zooming change it, and `onViewportChanged` reports each change. |
|
|
28
|
+
| `minZoom, maxZoom` | `Bind<number>` | `0.1`, `4` | The smallest and the largest zoom. |
|
|
29
|
+
| `bounds` | `Bind<DiagramRect \| null>` | `null` | The area of the diagram that the view stays over, in diagram units. `null` lets the view move anywhere. |
|
|
30
|
+
| `background` | `Bind<'dots' \| 'lines' \| 'cross' \| 'none'>` | `'dots'` | The marks drawn on the surface at each step of the grid. |
|
|
31
|
+
| `gridSize` | `Bind<number>` | `20` | The step of the grid, in diagram units. |
|
|
32
|
+
| `pannable` | `Bind<boolean>` | `true` | Whether the user can pan the view. |
|
|
33
|
+
| `zoomable` | `Bind<boolean>` | `true` | Whether the user can zoom the view. |
|
|
34
|
+
| `autoFit` | `Bind<boolean>` | `false` | Fits the nodes into view once they are first laid out. |
|
|
35
|
+
| `autoLayout` | `Bind<boolean>` | `false` | Places the nodes as `layoutOptions` say once they are first laid out, as a part of showing them: neither a step of the history nor told. |
|
|
36
|
+
| `layoutOptions` | `Bind<DiagramLayoutOptions>` | Layers from the top down | How `layout()` without options, `autoLayout` and the `layout` command place the nodes. |
|
|
37
|
+
| `detailLimit` | `Bind<number>` | `400` | The most nodes kept on the page at once. A diagram of more makes a node when it first comes into view and takes it off the page, its content kept, when it leaves; with more than this in view, it draws a sketch of the nodes and lines. |
|
|
38
|
+
| `miniMap` | `Bind<boolean \| DiagramMiniMapOptions>` | `false` | A map of the whole diagram in a corner of it: `true`, or `{ visible?, position?, width?, height?, label? }`. `position` is `'top-start'`, `'top-end'`, `'bottom-start'` or `'bottom-end'`. |
|
|
39
|
+
| `label` | `Bind<string>` | The kit string “Diagram” | The accessible name of the diagram. |
|
|
40
|
+
|
|
41
|
+
### Properties and methods
|
|
42
|
+
|
|
43
|
+
| Member | Type | Description |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `setViewport(viewport, options?)` | `void` | Moves the view, within the zoom limits and the bounds. |
|
|
46
|
+
| `zoomIn(options?), zoomOut(options?)` | `void` | Zooms in or out by one step around the middle of the view. |
|
|
47
|
+
| `zoomTo(zoom, options?)` | `void` | Zooms to the given value around the middle of the view. |
|
|
48
|
+
| `fit(options?)` | `void` | Fits the nodes into view. If they are not laid out yet, the fit is made as soon as they are. |
|
|
49
|
+
| `centerOn(target, options?)` | `void` | Moves a node, given by `id`, or a point of the diagram to the middle of the view. |
|
|
50
|
+
| `nodeRect(id)` | `DiagramRect \| null` | The position and size of a node in diagram units. |
|
|
51
|
+
| `connect(connection)` | `DiagramEdge \| null` | Connects two nodes if the rules allow it, and adds the connection to `edges` after `onConnecting`. Returns the new edge, or `null`. |
|
|
52
|
+
| `selectedNodes, selectedEdges` | `DiagramNode[]`, `DiagramEdge[]` | The selected nodes and connections, in the order of `nodes` and `edges`. |
|
|
53
|
+
| `select(selection, add?)` | `void` | Selects nodes and connections by `id`, replacing the selection or, with `add`, adding to it. The keys go on from a node selected alone. |
|
|
54
|
+
| `selectAll(), clearSelection()` | `void` | Selects every node and connection that can be selected, or none. |
|
|
55
|
+
| `deleteSelection()` | `boolean` | Deletes the selected nodes with their connections and the selected connections, except those that cannot be deleted, after `onDeleting`. A group goes with the nodes inside it. Returns whether anything was deleted. |
|
|
56
|
+
| `setCollapsed(id, collapsed)` | `boolean` | Collapses a node to its header or opens it, as the button in its header does: a group, a lane, a table or a class. Returns whether it changed. |
|
|
57
|
+
| `setNodeStatus(id, status, text?)` | `boolean` | Shows what a node is doing as a run goes through it, or takes it away with `null`: a mark on its corner and a ring, and a screen reader hears it with the node’s name. Not a step of the history. Returns whether it changed. |
|
|
58
|
+
| `edgesOf(id, options?), nodesOf(id, options?)` | `DiagramEdge[]`, `DiagramNode[]` | The connections of a node, by `direction` (`'in'`, `'out'`, `'both'`) and `port`, and the nodes at their other ends. Read in a getter, they follow the connections. |
|
|
59
|
+
| `setColumnChecked(id, column, checked)` | `boolean` | Ticks or clears the box of a column of a table that shows one, as the user does: a step of the history. Returns whether it changed. |
|
|
60
|
+
| `undo(), redo()` | `boolean` | Undoes the last step, or makes the last undone step again: a move, a resize, a node collapsed or opened, a connection made or moved, its line reshaped, a deletion, a paste, an alignment, a layout or a change the app recorded. Returns whether there was a step. |
|
|
61
|
+
| `record(edit)` | `boolean` | Adds a change the app made to the history, as a step the user undoes and redoes like the diagram's own: `undo` puts it back and `redo` makes it again, and the diagram is drawn again after each. `onHistoryChanged` tells it as an `'edit'` of the nodes and connections it names. Returns whether it was kept: not while `history` is off. |
|
|
62
|
+
| `canUndo, canRedo, clearHistory()` | `boolean`, `void` | Whether there is a step to undo or to redo, and clearing the history. |
|
|
63
|
+
| `copy(), cut(), paste()` | `boolean` | Copies the selected nodes and the connections between them to the clipboard and in the page, cuts them, or pastes what was copied in the page as new items, one step of the grid further at each paste. |
|
|
64
|
+
| `duplicate()` | `boolean` | Adds copies of the selected nodes and the connections between them next to them, without the clipboard. |
|
|
65
|
+
| `align(how)` | `boolean` | Lines the selected nodes up: `'left'`, `'center'`, `'right'`, `'top'`, `'middle'` or `'bottom'`, on the edge or the middle of all of them. |
|
|
66
|
+
| `toDiagram(point), toClient(point)` | `DiagramPoint` | Converts between a point of the page in pixels, such as the `clientX` and `clientY` of an event, and a point of the diagram. |
|
|
67
|
+
| `refresh()` | `void` | Reads the nodes again: changes made in place, and nodes added to or removed from the same array. |
|
|
68
|
+
| `layout(options?)` | `void` | Places the nodes in layers, as a tree or in rows, after `onNodesMoving`, as a step of the history; if they are not laid out yet, as soon as they are. |
|
|
69
|
+
| `drawnNodes()` | `DiagramDrawnNode[]` | The nodes on the surface, in the order they lie, each with its place and size and whether it holds other nodes; in a large diagram, a node not laid out yet with the size it is likely to have. |
|
|
70
|
+
| `visibleArea` | `DiagramRect` | The part of the diagram in view, in diagram units. |
|
|
71
|
+
| `save(), load(data)` | `DiagramData`, `boolean` | The nodes, the connections and the view as plain data, and that data, or its JSON text, shown again. `load` clears the selection and the history, and returns whether the data could be read. |
|
|
72
|
+
| `toSVG(options?), toDataURL(type?, options?), toBlob(type?, options?)` | `string`, `Promise<string>`, `Promise<Blob \| null>` | The diagram as an SVG document that stands alone, or as a PNG, without the selection. |
|
|
73
|
+
| `viewLayer, edgeLayer, labelLayer, nodeLayer, handleLayer` | `Component` | The layer that moves with the view, and the connection, label, node and handle layers inside it. |
|
|
74
|
+
|
|
75
|
+
### Method options
|
|
76
|
+
|
|
77
|
+
| Option | Type | Default | Description |
|
|
78
|
+
| --- | --- | --- | --- |
|
|
79
|
+
| `animate` | `boolean` | `false` | Moves the view with the motion of the design language instead of at once. Every method that moves the view accepts it. |
|
|
80
|
+
| `nodes` | `readonly string[]` | All nodes | `fit`: the nodes to fit. `layout`: the nodes to place. An image: the nodes to draw. |
|
|
81
|
+
| `padding` | `number` | `32`, `16` | `fit`: the space kept around the nodes, in pixels. An image: the room around the drawing, in diagram units. |
|
|
82
|
+
| `minZoom, maxZoom` | `number` | `minZoom`, `1` | `fit`: the zoom range of the fit. By default a fit does not zoom in beyond the actual size. |
|
|
83
|
+
| `zoom` | `number` | The current zoom | `centerOn`: the zoom to show the target at. |
|
|
84
|
+
| `type, direction` | `'layered' \| 'tree' \| 'grid'`, `'down' \| 'right' \| 'up' \| 'left'` | `'layered'`, `'down'` | `layout`: layers, a tree or rows, and the way the connections run. |
|
|
85
|
+
| `nodeGap, layerGap, columns` | `number` | `40`, `80`, about square | `layout`: the room between two nodes side by side and between two layers, in diagram units, and the nodes in a row of a grid. |
|
|
86
|
+
| `fit` | `boolean` | `false` | `layout`: fits the nodes into view once they are placed. |
|
|
87
|
+
| `background, scale` | `string`, `number` | The color behind the diagram, `2` | An image: the background, or `'transparent'`, and the pixels of a PNG for a unit of the diagram. |
|
|
88
|
+
|
|
89
|
+
### Types
|
|
90
|
+
|
|
91
|
+
| Type | Shape | Description |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `DiagramNode` | `{ id, x, y, width?, height?, text?, kind?, parent?, collapsed?, resizable?, ports?, cssClass?, style?, draggable?, selectable?, connectable?, deletable?, status?, statusText? }` | A node. `status` (`running`, `done`, `error`, `waiting`, `skipped`) and `statusText` show what it is doing as a run goes through it. `x` and `y` are its top left corner in diagram units; dragging writes them. Without `width` and `height` the node takes the size of its content. `kind` names its kind, `parent` the group it is in, and `collapsed` keeps a group, a table or a class collapsed to its header. Without `ports` it has a port in the middle of each side, named `top`, `right`, `bottom` and `left`. `cssClass` and `style` add classes and CSS properties to its element. The object is kept as it is given, so it can carry the app’s own fields. |
|
|
94
|
+
| `DiagramNodeKind` | `{ content?, update?, ports?, cssClass?, resizable?, minWidth?, minHeight?, group?, collapsible?, collapse? }` | A kind of node. `content(context)` makes the content of each node once and returns a component or a text, or adds to `context.host`; `update(context)` writes what changed when the node is drawn again. `ports` may be a function that makes the ports from the node. `group` makes its nodes hold others, `collapsible` makes them collapse to their header, and `collapse` says whether a collapsed one keeps its width (`'vertical'`) or its height (`'horizontal'`). |
|
|
95
|
+
| `DiagramNodeContext` | `{ node, host, diagram, selected, dragHandle(part), anchor(id, part), label(read) }` | What `content` and `update` receive: the node, the part its content goes into, the diagram, whether the node is selected, `dragHandle`, which makes one part the only place that drags the node, `anchor`, which stands a port beside a part of the content, such as a row, and `label`, which names the node with a function the node follows as the reactive data it reads changes. |
|
|
96
|
+
| `DiagramTableNode, DiagramTableColumn` | `{ …DiagramNode, columns, checkable? }`, `{ name, type?, primaryKey?, foreignKey?, unique?, checked? }` | A node of the `table` kind: its `text` is its name, and each column has a port named by it beside its row, on the left and on the right. `checkable` shows a box before each column, which the user ticks and clears, as columns are chosen for a query; the column’s `checked` holds it. |
|
|
97
|
+
| `DiagramClassNode, DiagramClassMember` | `{ …DiagramNode, stereotype?, abstract?, attributes?, methods? }`, `{ name, type?, visibility?, static?, abstract? }` | A node of the `class` kind: its `text` is its name. `visibility` is `'public'`, `'private'`, `'protected'` or `'package'`. |
|
|
98
|
+
| `DiagramCardNode` | `{ …DiagramNode, icon?, subtitle? }` | A node of the `card` kind: its icon and `text` in its header with the `subtitle` under them. `cardKind(options)` makes a kind of one’s own from it. |
|
|
99
|
+
| `DiagramPort` | `{ id, side, offset?, direction?, type?, maxConnections?, label? }` | A port on a side of a node, or on several: a connection then takes the one that faces its other end. `offset` places it along the side, from `0` at the left or top end to `1`; the default is the middle, and a port the content anchors stands beside its part. `direction` is `'source'` for an output, `'target'` for an input, or `'both'`, the default for ports of the app’s own. |
|
|
100
|
+
| `DiagramEdge` | `{ id, source, target, sourcePort?, targetPort?, path?, points?, label?, sourceLabel?, targetLabel?, sourceMarker?, targetMarker?, dashed?, animated?, reconnectable?, color?, width?, cssClass?, style?, selectable?, deletable? }` | A connection. Without a port, an end takes the output or input that faces the other node. The markers are `none`, `arrow`, `arrow-open`, `circle`, `triangle-open`, `diamond`, `diamond-open` and the crow’s feet `one`, `many`, `zero-or-one`, `one-or-many` and `zero-or-many`; the default is an arrow at the target. `sourceLabel` and `targetLabel` write a text at each end. `color` and `width` set its line, and `cssClass` and `style` add classes and CSS properties to its element. `points` are the points the line passes through, which the user adds, moves and takes away. `path` can also be a function that receives the ends and the points and returns an SVG path and the position of the label. `reconnectable: false` keeps its ends and its points. |
|
|
101
|
+
| `DiagramNodeMove` | `{ node, from, to, fromParent?, toParent? }` | A node the user moved, with its position before and after, and the groups it left and joined when the drop took it into a group or out of one. |
|
|
102
|
+
| `DiagramEdit` | `{ undo(), redo(), nodes?, edges? }` | A change the app made, for `record`: `undo` puts it back, `redo` makes it again, and `nodes` and `edges` say what it changed. |
|
|
103
|
+
| `DiagramChange` | `{ kind, nodes, edges }` | What a step of the history did: `kind` is `'move'`, `'resize'`, `'collapse'`, `'connect'`, `'reconnect'`, `'reshape'`, `'delete'`, `'paste'`, `'layout'` or `'edit'` (a change the app recorded). |
|
|
104
|
+
| `DiagramData` | `{ version?, nodes, edges?, viewport? }` | What `save` gives and `load` takes: copies of the nodes and connections, and the view. |
|
|
105
|
+
| `DiagramDrawnNode` | `{ node, rect, group }` | A node on the surface, as `drawnNodes` gives it. |
|
|
106
|
+
| `DiagramConnection` | `{ source, sourcePort?, target, targetPort? }` | The two ends of a connection. |
|
|
107
|
+
| `DiagramViewport` | `{ x, y, zoom }` | The position of the diagram’s origin on the surface, in pixels, and the zoom, where `1` is the actual size. |
|
|
108
|
+
| `DiagramPoint, DiagramRect` | `{ x, y }`, `{ x, y, width, height }` | A point and a rectangle. |
|
|
109
|
+
|
|
110
|
+
### Events
|
|
111
|
+
|
|
112
|
+
| Event | Type | Description |
|
|
113
|
+
| --- | --- | --- |
|
|
114
|
+
| `onViewportChanged` | `{ viewport, previous, byUser }` | Occurs whenever the view moves. `byUser` is `true` when the user panned or zoomed. |
|
|
115
|
+
| `onConnecting` | `{ connection, edge, byUser, cancel }` | Occurs before a new connection is added. Change the fields of `edge`, such as its `id` or `label`, or set `cancel`. |
|
|
116
|
+
| `onConnected` | `{ edge, byUser }` | Occurs after a new connection was added to `edges`. |
|
|
117
|
+
| `onReconnecting` | `{ edge, end, connection, cancel }` | Occurs before an end of a connection moves to another node or port. Set `cancel` to keep it. |
|
|
118
|
+
| `onReconnected` | `{ edge, end, previous }` | Occurs after an end of a connection moved. The edge’s fields hold the new ends. |
|
|
119
|
+
| `onSelectionChanged` | `{ nodes, edges, byUser }` | Occurs whenever the selected nodes or connections change. |
|
|
120
|
+
| `onNodesMoving` | `{ nodes, cancel }` | Occurs when the user starts to drag nodes or moves them with the keys, and before an alignment or a layout. Set `cancel` to keep them in place. |
|
|
121
|
+
| `onNodesMoved` | `{ moves }` | Occurs after the user dropped the nodes or moved them with the keys, and after an alignment or a layout. Each move holds the node and its position before and after. |
|
|
122
|
+
| `onDeleting` | `{ nodes, edges, byUser, cancel }` | Occurs before nodes and connections are deleted. `edges` includes the connections of the nodes. Set `cancel` to keep them. |
|
|
123
|
+
| `onDeleted` | `{ nodes, edges, byUser }` | Occurs after nodes and connections were removed from `nodes` and `edges`. |
|
|
124
|
+
| `onNodeResizing` | `{ node, cancel }` | Occurs when the user starts to resize a node. Set `cancel` to keep its size. |
|
|
125
|
+
| `onNodeResized` | `{ node, from, to }` | Occurs after the user resized a node, with its place and size before and after. |
|
|
126
|
+
| `onNodeToggled` | `{ node, collapsed, byUser }` | Occurs after a node collapsed to its header or opened, by the button in its header or by `setCollapsed`. |
|
|
127
|
+
| `onColumnChecked` | `{ node, column, checked, byUser }` | Occurs after the box of a column of a table was ticked or cleared, by the user or by `setColumnChecked`. |
|
|
128
|
+
| `onEdgeReshaping` | `{ edge, cancel }` | Occurs when the user starts to move, add or remove a point of a connection’s line. Set `cancel` to keep the line as it is. |
|
|
129
|
+
| `onEdgeReshaped` | `{ edge, previous }` | Occurs after the user moved, added or removed points of a connection’s line. `previous` holds the points it had before. |
|
|
130
|
+
| `onPasting` | `{ nodes, edges, cancel }` | Occurs before copies are added by a paste or a duplicate. They are new objects with new ids; change their fields, such as an id of the app’s own, or set `cancel`. |
|
|
131
|
+
| `onPasted` | `{ nodes, edges }` | Occurs after copies were added to `nodes` and `edges`. They are the selection. |
|
|
132
|
+
| `onHistoryChanged` | `{ reason, change, canUndo, canRedo }` | Occurs whenever the history changes. `reason` is `'add'`, `'undo'`, `'redo'` or `'clear'`. After an undo or a redo, `nodes`, `edges` and their objects already match the diagram, so this is the event to save the diagram on. |
|
|
133
|
+
| `onContentChanged` | `void` | Occurs at most once a frame after nodes moved or changed their size, came, went, were hidden in a group or shown again, or the surface changed its size. A map follows the diagram with it. |
|
|
134
|
+
|
|
135
|
+
### DiagramMap
|
|
136
|
+
|
|
137
|
+
| Prop | Type | Default | Description |
|
|
138
|
+
| --- | --- | --- | --- |
|
|
139
|
+
| `diagram` | `Bind<Diagram \| null>` | `null` | The diagram the map shows and moves the view of. |
|
|
140
|
+
| `label` | `Bind<string>` | The kit string “Diagram map” | The accessible name of the map. |
|
|
141
|
+
|
|
142
|
+
### Commands
|
|
143
|
+
|
|
144
|
+
| Command | Keys | Description |
|
|
145
|
+
| --- | --- | --- |
|
|
146
|
+
| `undo, redo` | Ctrl+Z; Ctrl+Shift+Z, Ctrl+Y | Undo and redo. |
|
|
147
|
+
| `cut, copy, paste` | The browser’s own keys | The clipboard. The keys work through the browser’s clipboard, so a copy can be pasted in another tab. |
|
|
148
|
+
| `duplicate` | Ctrl+D | Copies the selected nodes next to them. |
|
|
149
|
+
| `delete` | Delete, Backspace | Deletes the selection. |
|
|
150
|
+
| `selectAll` | Ctrl+A | Selects everything. |
|
|
151
|
+
| `alignLeft, alignCenter, alignRight, alignTop, alignMiddle, alignBottom` | | Line the selected nodes up. |
|
|
152
|
+
| `zoomIn, zoomOut, zoomToFit` | Plus, Minus | Zoom in, zoom out, fit the nodes into view. |
|
|
153
|
+
| `layout` | | Places the nodes as `layoutOptions` says, gliding. |
|
|
154
|
+
|
|
155
|
+
### Styling hooks
|
|
156
|
+
|
|
157
|
+
| Hook | Description |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `.mx-diagram` | The surface. `data-background`, `data-panning`, `data-space`, `data-connecting`, `data-reshaping`, `data-fixed` and `data-disabled` describe its state. |
|
|
160
|
+
| `.mx-diagram__grid, .mx-diagram__grid-mark` | The background and its marks. |
|
|
161
|
+
| `.mx-diagram__view, .mx-diagram__edges, .mx-diagram__nodes` | The layer that moves with the view, and the connection and node layers inside it. |
|
|
162
|
+
| `.mx-diagram__node, .mx-diagram__node-content, .mx-diagram__node-text` | A node, with its `id` in `data-id`, its kind in `data-kind`, and `data-movable`, `data-selected`, `data-dragging`, `data-active`, `data-resizable`, `data-group`, `data-collapsed` and `data-drop-target` for its state; the part its kind’s content goes into, and its text. |
|
|
163
|
+
| `.mx-diagram__resizer` | A resize handle of a selected node, with its side or corner in `data-side`. `data-resizing` on the surface holds it while a node is resized. |
|
|
164
|
+
| `.mx-diagram__group, .mx-diagram__lane, .mx-diagram__group-header, .mx-diagram__group-title, .mx-diagram__group-body, .mx-diagram__note` | The built-in kinds: a group or a lane, its header and title, the space under or beside it, and a note. |
|
|
165
|
+
| `.mx-diagram__table, .mx-diagram__table-header, .mx-diagram__table-title, .mx-diagram__table-rows, .mx-diagram__table-row, .mx-diagram__table-key, .mx-diagram__table-name, .mx-diagram__table-type` | A table: its header and name, and its rows, with the column in `data-column` and its keys in `data-key`. |
|
|
166
|
+
| `.mx-diagram__class, .mx-diagram__class-header, .mx-diagram__class-stereotype, .mx-diagram__class-name, .mx-diagram__class-compartment, .mx-diagram__class-member` | A class: its header, stereotype and name, its compartments (`data-compartment`) and members, with `data-abstract` and `data-static`. |
|
|
167
|
+
| `.mx-diagram__toggle, .mx-diagram__edge-end-label` | The button in a header that collapses its node, and a text at an end of a connection, with `data-end` and `data-side`. |
|
|
168
|
+
| `.mx-diagram__guides, .mx-diagram__guide` | The guides a dragged node lines up with. |
|
|
169
|
+
| `.mx-diagram__port` | A port. `data-port`, `data-side` and `data-direction` describe it, and `data-available`, `data-target` and `data-refused` mark it while a connection is drawn. |
|
|
170
|
+
| `.mx-diagram__edge, .mx-diagram__edge-line, .mx-diagram__edge-marker, .mx-diagram__edge-label` | A connection, with its `id` in `data-id` and `data-dashed`, `data-animated`, `data-selected` and `data-moving` for its state; its line, its markers and its label. |
|
|
171
|
+
| `.mx-diagram__handle, .mx-diagram__marquee` | The handles over the ends of a selected connection, with `data-end`, and the selection rectangle. |
|
|
172
|
+
| `.mx-diagram__bend` | A handle on the line of a selected connection: `data-kind` is `point` on a point of its own, `add` in the middle of a run, `segment` on a run of a right-angled line, with `data-axis`. |
|
|
173
|
+
| `.mx-diagram__connection` | The line of a connection being drawn. `data-connecting` is on the surface while it is drawn. |
|
|
174
|
+
| `.mx-diagram__overview, .mx-diagram__overview-node, .mx-diagram__overview-line` | The sketch of a far view: `data-far` is on the surface while it stands in place of the nodes and lines; a node path has `data-group` or `data-selected`. |
|
|
175
|
+
| `.mx-diagram-map, .mx-diagram-map__surface, .mx-diagram-map__node, .mx-diagram-map__mask, .mx-diagram-map__view` | A map: its drawing, a node (`data-group`, `data-selected`), what lies out of view and the outline of the view. `data-dragging` is on the map while the view is dragged on it. |
|
|
176
|
+
|
|
177
|
+
### Design tokens
|
|
178
|
+
|
|
179
|
+
| Token | Description |
|
|
180
|
+
| --- | --- |
|
|
181
|
+
| `diagram.height` | The height of the diagram when the app sets none. |
|
|
182
|
+
| `diagram.grid-dot-size, .grid-line-width, .grid-cross-size` | The size of the marks on the screen. They do not change with the zoom. |
|
|
183
|
+
| `diagram.edge-width, .marker-size, .edge-corner, .edge-step-gap, .edge-dash-length, .edge-dash-gap` | The width of a line, the size of its markers, the corners and the first run of a step, and the dashes, in diagram units. |
|
|
184
|
+
| `diagram.edge-hit-width, .connect-reach` | How wide the pointer finds a line, and how near a port a connection snaps, on the screen. |
|
|
185
|
+
| `diagram.surface, .grid, .node, .node-text` | Units: the surface (`focus`, `grab`, `panning`, `connecting`, `reshaping`, `disabled`), the marks, whose `color` paints them, a node’s box (`movable`, `hover`, `selected`, `dragging`, `active`) and its text. |
|
|
186
|
+
| `diagram.port, .edge, .edge-label, .connection` | Units: a port (`input`, `output`, `shown`, `available`, `hover`, `target`, `refused`), a connection, whose `color` paints its line and markers (`hover`, `selected`, `moving`), its label (`selected`), and the line being drawn. |
|
|
187
|
+
| `diagram.handle, .marquee, .guide` | Units: the handle over an end of a selected connection (`hover`), the selection rectangle, and the guides, whose `color` paints them. |
|
|
188
|
+
| `diagram.bend` | The unit of a handle on the line of a selected connection: on a point (`hover`), `add`, and on a run that lies `horizontal` or `vertical`. |
|
|
189
|
+
| `diagram.resizer, .resize-reach` | The unit of a corner handle of a resize (`hover`), and how near a side the pointer takes it, in diagram units. |
|
|
190
|
+
| `diagram.group, .group-header, .lane-header, .group-title, .toggle, .note` | Units: a group’s box (`movable`, `dragging`, `hover`, `drop-target`), its header (`movable`, `dragging`, `collapsed`), a lane’s header (`collapsed`), the title, the button that collapses a node (`collapsed`, `collapsed-rtl`), and a note. |
|
|
191
|
+
| `diagram.table, .table-header, .table-title, .table-row, .table-key, .table-type` | Units: a table’s box, its header (`collapsed`) and name, a row, the key mark (`primary`, `foreign`, `unique`) and the type. |
|
|
192
|
+
| `diagram.class, .class-header, .class-stereotype, .class-name, .class-compartment, .class-member, .edge-end-label` | Units: a class’s box, its header (`collapsed`), stereotype and name, a compartment (`attributes`) and a member, and a text at an end of a connection (`selected`). |
|
|
193
|
+
| `diagram.guide-width` | The width of the guides on the screen. |
|
|
194
|
+
| `diagram.overview-node, .overview-line` | Units: a node in the sketch of a far view, whose `color` fills it (`selected`, `group`), and a line of it, whose `color` paints it. |
|
|
195
|
+
| `diagram-map.width, .height, .view-width, .offset` | The size of a map when the app sets none, the width of the outline of the view on the screen, and the room between a diagram’s own map and the edges of the diagram. |
|
|
196
|
+
| `diagram-map.surface, .node, .mask, .view` | Units: the map (`focus`, `dragging`, `disabled`), a node, whose `color` fills it (`selected`, `group`), what lies out of view and the outline of the view, whose `color` paints them. |
|
|
197
|
+
|
|
198
|
+
## Feedback
|
|
199
|
+
|
|
200
|
+
Loading issues…
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Diagram: History and commands
|
|
2
|
+
|
|
3
|
+
> Diagram · @motifx-community/ui 0.1.0-beta.16
|
|
4
|
+
|
|
5
|
+
Undo and redo, the clipboard and alignment, as commands that the app’s toolbars and menus name and the user runs with keys of their choice.
|
|
6
|
+
|
|
7
|
+
## History, clipboard and commands
|
|
8
|
+
|
|
9
|
+
Every step the user takes is kept to undo and redo: a move, a connection made or moved, a deletion, a paste and an alignment. The diagram adds its commands to the app’s command registry, so toolbars and menus name them by key and take their text, state and action from them, and the user can change their keys. A dragged node lines up with the edges and middles of the other nodes, and guides show where. `onHistoryChanged` occurs after every change the user makes, undone and redone ones too: the event to save the diagram on.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Component } from '@motifx/core';
|
|
13
|
+
import { Diagram, Stack, Toolbar, type DiagramEdge, type DiagramNode } from '@motifx-community/ui';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A toolbar of the app that names the diagram's commands. The diagram holds its commands to this editor
|
|
17
|
+
* (`commandScope`): the toolbar runs this diagram's, and the keys work while focus is anywhere in the editor.
|
|
18
|
+
*/
|
|
19
|
+
export default class Commands extends Component<HTMLDivElement> {
|
|
20
|
+
constructor() {
|
|
21
|
+
super('div');
|
|
22
|
+
this.class.add('docs-wide');
|
|
23
|
+
const nodes: DiagramNode[] = [
|
|
24
|
+
{ id: 'idea', x: 0, y: 40, text: 'Idea' },
|
|
25
|
+
{ id: 'draft', x: 220, y: 0, text: 'Draft' },
|
|
26
|
+
{ id: 'review', x: 440, y: 70, text: 'Review' },
|
|
27
|
+
{ id: 'publish', x: 660, y: 30, text: 'Publish' },
|
|
28
|
+
];
|
|
29
|
+
const edges: DiagramEdge[] = [
|
|
30
|
+
{ id: 'e1', source: 'idea', target: 'draft' },
|
|
31
|
+
{ id: 'e2', source: 'draft', target: 'review' },
|
|
32
|
+
{ id: 'e3', source: 'review', target: 'publish' },
|
|
33
|
+
];
|
|
34
|
+
const toolbar = new Toolbar({
|
|
35
|
+
label: 'Diagram',
|
|
36
|
+
items: [
|
|
37
|
+
{ command: 'undo' },
|
|
38
|
+
{ command: 'redo' },
|
|
39
|
+
{ type: 'separator' },
|
|
40
|
+
{ command: 'cut' },
|
|
41
|
+
{ command: 'copy' },
|
|
42
|
+
{ command: 'paste' },
|
|
43
|
+
{ command: 'duplicate' },
|
|
44
|
+
{ command: 'delete' },
|
|
45
|
+
{ type: 'separator' },
|
|
46
|
+
{ command: 'alignTop' },
|
|
47
|
+
{ command: 'alignMiddle' },
|
|
48
|
+
{ command: 'alignBottom' },
|
|
49
|
+
{ command: 'alignLeft' },
|
|
50
|
+
{ command: 'alignCenter' },
|
|
51
|
+
{ command: 'alignRight' },
|
|
52
|
+
{ type: 'separator' },
|
|
53
|
+
{ command: 'zoomIn' },
|
|
54
|
+
{ command: 'zoomOut' },
|
|
55
|
+
{ command: 'zoomToFit' },
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
const diagram = new Diagram({ label: 'Publishing flow', nodes, edges, autoFit: true, edgePath: 'rounded-step', commandScope: this });
|
|
59
|
+
const stack = new Stack({ gap: 'md' });
|
|
60
|
+
stack.controls.add(toolbar, diagram);
|
|
61
|
+
this.controls.add(stack);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| Command | Keys | Description |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `undo, redo` | Ctrl+Z; Ctrl+Shift+Z, Ctrl+Y | Undo and redo. |
|
|
69
|
+
| `cut, copy, paste` | The browser’s own keys | The clipboard. The keys work through the browser’s clipboard, so a copy can be pasted in another tab. |
|
|
70
|
+
| `duplicate` | Ctrl+D | Copies the selected nodes next to them. |
|
|
71
|
+
| `delete` | Delete, Backspace | Deletes the selection. |
|
|
72
|
+
| `selectAll` | Ctrl+A | Selects everything. |
|
|
73
|
+
| `alignLeft, alignCenter, alignRight, alignTop, alignMiddle, alignBottom` | | Line the selected nodes up. |
|
|
74
|
+
| `zoomIn, zoomOut, zoomToFit` | Plus, Minus | Zoom in, zoom out, fit the nodes into view. |
|
|
75
|
+
| `layout` | | Places the nodes as `layoutOptions` says, gliding. |
|
|
76
|
+
|
|
77
|
+
## Feedback
|
|
78
|
+
|
|
79
|
+
Loading issues…
|