You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Example (structural editing, starting with empty "flow")](#example-structural-editing-starting-with-empty-flow)
31
+
11
32
## Demo
12
33
13
34
Have a look at the [![Storybook][storybook-image]][storybook-url]
@@ -26,14 +47,14 @@ npm i react-flow-modeler
26
47
Describing the whole data model being displayed, expecting an object with two fields:
27
48
-`flow.firstElementId` – string containing the key to the `flow.elements` entry, that should follow the start node
28
49
-`flow.elements` – object containing all "step" nodes and "diverging gateway" nodes as values
29
-
- "step" nodes are represented by an object that may contain the following fields:
30
-
-`data` – object in which any kind of additional information may be stored (in order to consider it in the `renderStep` function
31
-
-`nextElementId` – string containing the key to the `flow.elements` entry, that should follow this step (if omitted or without matching entry in `flow.elements`, it will point to the end node)
32
-
- "diverging gateway" nodes are represented by an object that may contain the following fields:
33
-
-`data` – object in which any kind of additional information may be stored (in order to consider it in the `renderGatewayConditionType` function
34
-
-`nextElements` (required, otherwise it is treated as "step" node) – array of branches from this gateway, each branch being represented by an object with the following fields:
35
-
-`conditionData` – object in which any kind of additional information may be stored (in order to consider it in the `renderGatewayConditionValue` function
36
-
-`id` – string containing the key to the `flow.elements` entry, that should follow this gateway branch (if omitted or without matching entry in `flow.elements`, it will point to the end node)
50
+
- "step" nodes are represented by an object that may contain the following fields:
51
+
- `data` – object in which any kind of additional information may be stored (in order to consider it in the `renderStep` function
52
+
- `nextElementId` – string containing the key to the `flow.elements` entry, that should follow this step (if omitted or without matching entry in `flow.elements`, it will point to the end node)
53
+
- "diverging gateway" nodes are represented by an object that may contain the following fields:
54
+
-`data` – object in which any kind of additional information may be stored (in order to consider it in the `renderGatewayConditionType` function
55
+
-`nextElements` (required, otherwise it is treated as "step" node) – array of branches from this gateway, each branch being represented by an object with the following fields:
56
+
-`conditionData` – object in which any kind of additional information may be stored (in order to consider it in the `renderGatewayConditionValue` function
57
+
-`id` – string containing the key to the `flow.elements` entry, that should follow this gateway branch (if omitted or without matching entry in `flow.elements`, it will point to the end node)
37
58
38
59
#### `options`
39
60
Currently only catering for one setting:
@@ -64,35 +85,82 @@ Render function for the condition label on a branch from a diverging gateway exp
64
85
-`followingElement` – reference to the directly following element in the flow
65
86
66
87
#### `onChange`
67
-
Callback function that when present enables structural editing, receiving a single input object containing the following field:
68
-
-`changedFlow` – updated `flow` that should be stored in some external state and provided again via the `flow` prop
88
+
Callback function that when present enables structural editing,
89
+
- receiving a single input object containing the following field:
90
+
-`changedFlow` – updated `flow` that should be stored in some external state and provided again via the `flow` prop to the `<Modeler>`
69
91
70
92
#### `editActions`
71
93
Object containing various customization options for the structural editing feature in the following fields:
72
94
-`addDivergingBranch` – object for customizing the adding of branches to a diverging gateway, expecting any of the following fields:
73
-
-`className` – string overriding the default `"menu-item add-branch"` css classes on the corresponding context menu item
74
-
-`title` – string defining the tool-tip to show for the corresponding context menu item
75
-
-`isActionAllowed` – function for preventing adding branches to certain gateway, expecting a `boolean` to be returned based on the same single input object as on `renderGatewayConditionType` referring to the selected element
76
-
-`getBranchConditionData` – function for providing the default `conditionData` on a newly added diverging gateway branch based on the same single input object as on `renderGatewayConditionType`
95
+
-`className` – string overriding the default `"menu-item add-branch"` css classes on the corresponding context menu item
96
+
-`title` – string defining the tool-tip to show for the corresponding context menu item
97
+
-`isActionAllowed` – function for preventing adding branches to certain gateway, expecting a `boolean` to be returned based on the same single input object as on `renderGatewayConditionType` referring to the selected element
98
+
-`getBranchConditionData` – function for providing the default `conditionData` on a newly added diverging gateway branch based on the same single input object as on `renderGatewayConditionType`
77
99
-`addFollowingStepElement` – object for customizing the adding of step nodes, expecting any of the following fields:
78
-
-`className` – string overriding the default `"menu-item add-step"` css classes on the corresponding context menu item
79
-
-`title` – string defining the tool-tip to show for the corresponding context menu item
80
-
-`isActionAllowed` – function for preventing adding step nodes after certain elements, expecting a `boolean` to be returned based on the reference to the selected element
81
-
-`getStepData` – function for providing the default `data` on a newly added step node based on the reference to the element where the corresponding context menu item was clicked
100
+
-`className` – string overriding the default `"menu-item add-step"` css classes on the corresponding context menu item
101
+
-`title` – string defining the tool-tip to show for the corresponding context menu item
102
+
-`isActionAllowed` – function for preventing adding step nodes after certain elements, expecting a `boolean` to be returned based on the reference to the selected element
103
+
-`getStepData` – function for providing the default `data` on a newly added step node based on the reference to the element where the corresponding context menu item was clicked
82
104
-`addFollowingDivergingGateway` – object for customizing the adding of diverging gateway nodes, expecting any of the following fields:
83
-
-`className` – string overriding the default `"menu-item add-gateway"` css classes on the corresponding context menu item
84
-
-`title` – string defining the tool-tip to show for the corresponding context menu item
85
-
-`isActionAllowed` – function for preventing adding diverging gateways after certain elements, expecting a `boolean` to be returned based on the reference to the element where the corresponding context menu item was clicked
86
-
-`getGatewayData` – function for providing the default `data` on a newly added diverging gateway based on the reference to the selected element
87
-
-`getBranchConditionData`– function for providing an array of the default `conditionData` objects for each branch of a newly added diverging gateway based on the reference to the element where the corresponding context menu item was clicked; thereby also determining how many branches there are by default
105
+
-`className` – string overriding the default `"menu-item add-gateway"` css classes on the corresponding context menu item
106
+
-`title` – string defining the tool-tip to show for the corresponding context menu item
107
+
-`isActionAllowed` – function for preventing adding diverging gateways after certain elements, expecting a `boolean` to be returned based on the reference to the element where the corresponding context menu item was clicked
108
+
-`getGatewayData` – function for providing the default `data` on a newly added diverging gateway based on the reference to the selected element
109
+
-`getBranchConditionData`– function for providing an array of the default `conditionData` objects for each branch of a newly added diverging gateway based on the reference to the element where the corresponding context menu item was clicked; thereby also determining how many branches there are by default
88
110
-`changeNextElement` – object for customizing the links between elements in the flow, expecting any of the following fields:
89
-
-`className` – string overriding the default `"menu-item change-next"` css classes on the corresponding context menu item
90
-
-`title` – string defining the tool-tip to show for the corresponding context menu item
91
-
-`isActionAllowed` – function for preventing links from certain elements to be changed, expecting a `boolean` to be returned based on the reference to the selected element
111
+
-`className` – string overriding the default `"menu-item change-next"` css classes on the corresponding context menu item
112
+
-`title` – string defining the tool-tip to show for the corresponding context menu item
113
+
-`isActionAllowed` – function for preventing links from certain elements to be changed, expecting a `boolean` to be returned based on the reference to the selected element
92
114
-`removeElement` – object for customizing the removal of elements in the flow, expecting any of the following fields:
93
-
-`className` – string overriding the default `"menu-item remove"` css classes on the corresponding context menu item
94
-
-`title` – string defining the tool-tip to show for the corresponding context menu item
95
-
-`isActionAllowed` – function for preventing certain elements to be removed, expecting a `boolean` to be returned based on the reference to the selected element
115
+
-`className` – string overriding the default `"menu-item remove"` css classes on the corresponding context menu item
116
+
-`title` – string defining the tool-tip to show for the corresponding context menu item
117
+
-`isActionAllowed` – function for preventing certain elements to be removed, expecting a `boolean` to be returned based on the reference to the selected element
118
+
119
+
### Additional Exports
120
+
#### `isFlowValid` function
121
+
- input: expecting a complete `flow` as single input parameter
122
+
- output: returning a `boolean` response to indicate whether the given `flow` is deemed valid by the `<Modeler>`
123
+
124
+
#### `validateFlow` function
125
+
- input: expecting a complete `flow` as single input parameter
126
+
- output: not returning anything in case of a valid `flow` but throwing an `Error` otherwise
127
+
128
+
#### `updateStepData` function
129
+
- inputs:
130
+
1. expecting a complete `flow` as first input parameter
131
+
2. expecting the `id` of a step node (i.e. identifying the step node under `flow.elements[id]`) as second input parameter
132
+
3. expecting a callback function as third input parameter
133
+
- input: the current `data` of the targeted step node will be provided as single input parameter
134
+
- output: the new `data` object to set on the targeted step node is expected to be returned
135
+
- output: returning an object (that can be provided to your `onChange` function) containing the following field:
136
+
-`changedFlow` – updated `flow` that should be stored in some external state and provided again via the `flow` prop to the `<Modeler>`
137
+
138
+
#### `updateGatewayData` function
139
+
- inputs:
140
+
1. expecting a complete `flow` as first input parameter
141
+
2. expecting the `id` of a gateway node (i.e. identifying the gateway node under `flow.elements[id]`) as second input parameter
142
+
3. expecting a callback function as third input parameter
143
+
- input: the current `data` of the targeted gateway node will be provided as single input parameter
144
+
- output: the new `data` object to set on the targeted gateway node is expected to be returned
145
+
4. optionally catering for another callback function to be provided as fourth input parameter
146
+
- inputs:
147
+
1. the current `conditionData` of a branch of the targeted gateway node will be provided as first input parameter
148
+
2. the index of the respective branch of the targeted gateway node will be provided as second input parameter
149
+
3. an array of the current `conditionData` of all branches of the targeted gateway node will be provided as third input parameter
150
+
- ooutput: the new `conditionData` object to set on the respective branch of the targeted gateway node is expected to be returned
151
+
- output: returning an object (that can be provided to your `onChange` function) containing the following field:
152
+
-`changedFlow` – updated `flow` that should be stored in some external state and provided again via the `flow` prop to the `<Modeler>`
153
+
154
+
#### `updateGatewayBranchData` function
155
+
- inputs:
156
+
1. expecting a complete `flow` as first input parameter
157
+
2. expecting the `id` of a gateway node (i.e. identifying the gateway node under `flow.elements[id]`) as second input parameter
158
+
3. expecting the index of the targeted branch of the gateway node (i.e. referring to `flow.elements[id].nextElements[index]`) as third input parameter
159
+
4. expecting a callback function as fourth input parameter
160
+
- input: the current `conditionData` of the targeted gateway branch will be provided as single input parameter
161
+
- output: the new `conditionData` object to set on the targeted gateway branch is expected to be returned
162
+
- output: returning an object (that can be provided to your `onChange` function) containing the following field:
163
+
-`changedFlow` – updated `flow` that should be stored in some external state and provided again via the `flow` prop to the `<Modeler>`
0 commit comments