@cratis/stage.runtime 4.204.0 → 4.205.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/dist/src/StageChrome.d.ts +2 -2
- package/dist/src/app.css +1 -1
- package/dist/src/index.js +929 -832
- package/dist/src/stageItemChange.d.ts +106 -0
- package/package.json +1 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { BindingExpression, ExternalComponent } from '@cratis/scene.model';
|
|
2
|
+
import { type ComponentBindingOutputs, type RegisteredComponentProps } from '@cratis/scene.react';
|
|
3
|
+
/** The binding path `with <input> from value` reads: the value the item changed to. */
|
|
4
|
+
export declare const changedValuePath = "value";
|
|
5
|
+
/** The binding path `with <input> from previous` reads: the value the item had before it changed. */
|
|
6
|
+
export declare const previousValuePath = "previous";
|
|
7
|
+
/** What a component reports for one of its items. */
|
|
8
|
+
export interface ReportedItem {
|
|
9
|
+
id: unknown;
|
|
10
|
+
column: unknown;
|
|
11
|
+
}
|
|
12
|
+
/** The item the user changed, as `item`, `value` and `previous` mean it to a binding. */
|
|
13
|
+
export interface ItemChange {
|
|
14
|
+
/** The item's row, with the changed property already holding its new value. */
|
|
15
|
+
item: Record<string, unknown>;
|
|
16
|
+
/** The value the item changed to. */
|
|
17
|
+
value: unknown;
|
|
18
|
+
/** The value the item had before. */
|
|
19
|
+
previous: unknown;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Finds the one item whose value differs between two reports of a component's items.
|
|
23
|
+
*
|
|
24
|
+
* @param before What the component reported before.
|
|
25
|
+
* @param after What it reports now.
|
|
26
|
+
* @returns The changed item and the value it had, or `undefined` when nothing changed or the report is not a list of items.
|
|
27
|
+
*/
|
|
28
|
+
export declare function changedItem(before: unknown, after: unknown): {
|
|
29
|
+
item: ReportedItem;
|
|
30
|
+
previous: unknown;
|
|
31
|
+
} | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Builds the change a binding reads from the rows a component presents.
|
|
34
|
+
*
|
|
35
|
+
* The component's own report names an item by its identifier and the value it changed to. The row the component was
|
|
36
|
+
* given for that item is what the document binds to, so the row is found by `idField` and the property that holds
|
|
37
|
+
* the value (`valueField`) takes the new value.
|
|
38
|
+
*
|
|
39
|
+
* @param rows The rows the component was given.
|
|
40
|
+
* @param changed The item the component reported as changed.
|
|
41
|
+
* @param idField The row property that identifies an item.
|
|
42
|
+
* @param valueField The row property the user changes.
|
|
43
|
+
* @returns The change, or `undefined` when the component presents no row for the item.
|
|
44
|
+
*/
|
|
45
|
+
export declare function itemChangeOf(rows: unknown, changed: {
|
|
46
|
+
item: ReportedItem;
|
|
47
|
+
previous: unknown;
|
|
48
|
+
}, idField: string, valueField: string): ItemChange | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Resolves what a change's bindings read: `item.<field>` from the changed row, `value` and `previous` from the
|
|
51
|
+
* change, and a guarded `when ... otherwise` against the changed row. Everything else is the screen's own.
|
|
52
|
+
*
|
|
53
|
+
* @param change The change.
|
|
54
|
+
* @param fallback Resolves any other binding.
|
|
55
|
+
* @returns The resolver the interaction engine runs the bindings with.
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveChange(change: ItemChange, fallback: (binding: BindingExpression) => unknown): (binding: BindingExpression) => unknown;
|
|
58
|
+
/** What a component that lets the user change its items needs to run the document's `on change`. */
|
|
59
|
+
export interface ItemChangeBinding {
|
|
60
|
+
/** The element the bindings are attached to. */
|
|
61
|
+
element: ExternalComponent;
|
|
62
|
+
/** The property of the element that holds the rows the component presents. */
|
|
63
|
+
rowsProperty: string;
|
|
64
|
+
/** The row property that identifies an item. */
|
|
65
|
+
idField: string;
|
|
66
|
+
/** The row property the user changes. */
|
|
67
|
+
valueField: string;
|
|
68
|
+
}
|
|
69
|
+
/** What the wrapped component is given in place of its own handlers and outputs. */
|
|
70
|
+
export interface ItemChangeHandlers {
|
|
71
|
+
/** Whether the document declares an `on change` for the component. */
|
|
72
|
+
declared: boolean;
|
|
73
|
+
/** Replaces the component's `onChange`: remembers that the next report is the user's. */
|
|
74
|
+
onChange: () => void;
|
|
75
|
+
/** Wraps the outputs the component publishes, running the bindings when the user's change is reported. */
|
|
76
|
+
outputs: ComponentBindingOutputs | undefined;
|
|
77
|
+
/** Changes whenever the component must be shown the data again, because the change was not applied. Use it as the component's `key`. */
|
|
78
|
+
revision: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Runs a component's `on change` for the item the user changed.
|
|
82
|
+
*
|
|
83
|
+
* A component that lets the user change an item (a card dropped in another column) says so through its `onChange`
|
|
84
|
+
* handler and then reports its items through its `value` output. The handler alone carries no item, so the change is
|
|
85
|
+
* the difference between the report before and after. A report that follows no `onChange` is the data changing
|
|
86
|
+
* under the component, which is not the user and so runs nothing.
|
|
87
|
+
*
|
|
88
|
+
* The bindings are the element's own, resolved and run by the Scene interaction engine - the same engine that runs
|
|
89
|
+
* every other interaction. Once they have run the data is read again. A change that no command applied (the
|
|
90
|
+
* `otherwise` branch only notified, or the command was refused) is shown as the data says it is rather than as the
|
|
91
|
+
* user left it: the `revision` changes, and the component, keyed by it, starts again from the data.
|
|
92
|
+
*
|
|
93
|
+
* @param binding What the component is and which of its row properties identify and change an item.
|
|
94
|
+
* @param outputs The outputs the component publishes.
|
|
95
|
+
* @returns The handlers to give the component.
|
|
96
|
+
*/
|
|
97
|
+
export declare function useItemChange(binding: ItemChangeBinding, outputs: ComponentBindingOutputs | undefined): ItemChangeHandlers;
|
|
98
|
+
/**
|
|
99
|
+
* The default blueprint's kanban board, running the document's `on change` for the card the user moved.
|
|
100
|
+
*
|
|
101
|
+
* The board is the blueprint's own; this only gives it what the document's interaction needs: the card, as its row
|
|
102
|
+
* with the column it was dropped in, and that column as `value`.
|
|
103
|
+
*/
|
|
104
|
+
export declare function StageKanbanBoard(props: RegisteredComponentProps): import("react").JSX.Element;
|
|
105
|
+
/** The registry key the default blueprint's kanban board is registered under, which the Stage's own board replaces. */
|
|
106
|
+
export declare const kanbanBoardKey: string;
|