@next-bricks/diagram 0.1.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.
Files changed (108) hide show
  1. package/dist/bricks.json +10 -0
  2. package/dist/chunks/1303.70dabf75.js +2 -0
  3. package/dist/chunks/1303.70dabf75.js.map +1 -0
  4. package/dist/chunks/1646.75d03d05.js +2 -0
  5. package/dist/chunks/1646.75d03d05.js.map +1 -0
  6. package/dist/chunks/1874.85ba64ca.js +2 -0
  7. package/dist/chunks/1874.85ba64ca.js.map +1 -0
  8. package/dist/chunks/2024.53d97685.js +2 -0
  9. package/dist/chunks/2024.53d97685.js.map +1 -0
  10. package/dist/chunks/2108.5684dc40.js +2 -0
  11. package/dist/chunks/2108.5684dc40.js.map +1 -0
  12. package/dist/chunks/2754.cbea5866.js +2 -0
  13. package/dist/chunks/2754.cbea5866.js.map +1 -0
  14. package/dist/chunks/2784.70c3fd78.js +2 -0
  15. package/dist/chunks/2784.70c3fd78.js.LICENSE.txt +9 -0
  16. package/dist/chunks/2993.ec4c251f.js +2 -0
  17. package/dist/chunks/2993.ec4c251f.js.map +1 -0
  18. package/dist/chunks/3166.bf4f0b41.js +3 -0
  19. package/dist/chunks/3166.bf4f0b41.js.LICENSE.txt +5 -0
  20. package/dist/chunks/3166.bf4f0b41.js.map +1 -0
  21. package/dist/chunks/3458.9ab412e3.js +2 -0
  22. package/dist/chunks/3458.9ab412e3.js.map +1 -0
  23. package/dist/chunks/4031.e35a7582.js +2 -0
  24. package/dist/chunks/4031.e35a7582.js.map +1 -0
  25. package/dist/chunks/4049.cdda8f99.js +2 -0
  26. package/dist/chunks/4049.cdda8f99.js.map +1 -0
  27. package/dist/chunks/4275.7315c167.js +2 -0
  28. package/dist/chunks/4275.7315c167.js.map +1 -0
  29. package/dist/chunks/4504.1f4df127.js +2 -0
  30. package/dist/chunks/4504.1f4df127.js.map +1 -0
  31. package/dist/chunks/4717.34d53aaa.js +2 -0
  32. package/dist/chunks/4717.34d53aaa.js.map +1 -0
  33. package/dist/chunks/5151.614d7062.js +2 -0
  34. package/dist/chunks/5151.614d7062.js.map +1 -0
  35. package/dist/chunks/5381.0bd4813d.js +2 -0
  36. package/dist/chunks/5381.0bd4813d.js.map +1 -0
  37. package/dist/chunks/5628.c306b668.js +2 -0
  38. package/dist/chunks/5628.c306b668.js.map +1 -0
  39. package/dist/chunks/5725.c89afa5f.js +2 -0
  40. package/dist/chunks/5725.c89afa5f.js.map +1 -0
  41. package/dist/chunks/6205.8038d239.js +2 -0
  42. package/dist/chunks/6205.8038d239.js.map +1 -0
  43. package/dist/chunks/6473.6f9b77d8.js +2 -0
  44. package/dist/chunks/6473.6f9b77d8.js.map +1 -0
  45. package/dist/chunks/6635.41cb938a.js +3 -0
  46. package/dist/chunks/6635.41cb938a.js.LICENSE.txt +8 -0
  47. package/dist/chunks/6635.41cb938a.js.map +1 -0
  48. package/dist/chunks/6653.e9c85257.js +2 -0
  49. package/dist/chunks/6653.e9c85257.js.map +1 -0
  50. package/dist/chunks/6660.df1815e2.js +2 -0
  51. package/dist/chunks/6660.df1815e2.js.map +1 -0
  52. package/dist/chunks/7067.3f1f372f.js +2 -0
  53. package/dist/chunks/7067.3f1f372f.js.map +1 -0
  54. package/dist/chunks/7110.8e981c34.js +2 -0
  55. package/dist/chunks/7110.8e981c34.js.map +1 -0
  56. package/dist/chunks/7164.38d06595.js +2 -0
  57. package/dist/chunks/7164.38d06595.js.map +1 -0
  58. package/dist/chunks/7672.bc4d7191.js +2 -0
  59. package/dist/chunks/7672.bc4d7191.js.map +1 -0
  60. package/dist/chunks/7746.1188f0ba.js +2 -0
  61. package/dist/chunks/7746.1188f0ba.js.map +1 -0
  62. package/dist/chunks/7915.26a8005c.js +2 -0
  63. package/dist/chunks/7915.26a8005c.js.map +1 -0
  64. package/dist/chunks/8008.5a59b5bb.js +3 -0
  65. package/dist/chunks/8008.5a59b5bb.js.LICENSE.txt +3 -0
  66. package/dist/chunks/8008.5a59b5bb.js.map +1 -0
  67. package/dist/chunks/8279.4c8718cb.js +2 -0
  68. package/dist/chunks/8279.4c8718cb.js.map +1 -0
  69. package/dist/chunks/8316.19210606.js +2 -0
  70. package/dist/chunks/8316.19210606.js.LICENSE.txt +19 -0
  71. package/dist/chunks/8498.e0c035d5.js +2 -0
  72. package/dist/chunks/8498.e0c035d5.js.map +1 -0
  73. package/dist/chunks/8691.26116604.js +2 -0
  74. package/dist/chunks/8691.26116604.js.map +1 -0
  75. package/dist/chunks/9431.968072ff.js +2 -0
  76. package/dist/chunks/9431.968072ff.js.map +1 -0
  77. package/dist/chunks/9549.09d4fb2e.js +2 -0
  78. package/dist/chunks/9549.09d4fb2e.js.map +1 -0
  79. package/dist/chunks/eo-diagram.97f0898f.js +2 -0
  80. package/dist/chunks/eo-diagram.97f0898f.js.map +1 -0
  81. package/dist/chunks/main.4f2df642.js +2 -0
  82. package/dist/chunks/main.4f2df642.js.map +1 -0
  83. package/dist/examples.json +5 -0
  84. package/dist/index.a7fb8eb0.js +2 -0
  85. package/dist/index.a7fb8eb0.js.map +1 -0
  86. package/dist/manifest.json +68 -0
  87. package/dist/types.json +468 -0
  88. package/dist-types/bootstrap.d.ts +1 -0
  89. package/dist-types/diagram/NodeComponent.d.ts +15 -0
  90. package/dist-types/diagram/constants.d.ts +3 -0
  91. package/dist-types/diagram/index.d.ts +36 -0
  92. package/dist-types/diagram/index.spec.d.ts +1 -0
  93. package/dist-types/diagram/interfaces.d.ts +69 -0
  94. package/dist-types/diagram/lines/curveLine.d.ts +5 -0
  95. package/dist-types/diagram/lines/curveLine.spec.d.ts +1 -0
  96. package/dist-types/diagram/processors/findNodeBrick.d.ts +2 -0
  97. package/dist-types/diagram/processors/findNodeBrick.spec.d.ts +1 -0
  98. package/dist-types/diagram/processors/getCenterOffsets.d.ts +2 -0
  99. package/dist-types/diagram/processors/getCenterOffsets.spec.d.ts +1 -0
  100. package/dist-types/diagram/processors/getRenderedLinesAndMarkers.d.ts +5 -0
  101. package/dist-types/diagram/processors/getRenderedLinesAndMarkers.spec.d.ts +1 -0
  102. package/dist-types/diagram/processors/handleKeyboard.d.ts +15 -0
  103. package/dist-types/diagram/processors/handleKeyboard.spec.d.ts +1 -0
  104. package/dist-types/diagram/processors/matchEdgeByFilter.d.ts +2 -0
  105. package/dist-types/diagram/processors/matchEdgeByFilter.spec.d.ts +1 -0
  106. package/dist-types/index.d.ts +0 -0
  107. package/docs/eo-diagram.md +369 -0
  108. package/package.json +44 -0
@@ -0,0 +1,5 @@
1
+ import type { LineConf, LineMarker, RenderedEdge, RenderedLine } from "../interfaces";
2
+ export declare function getRenderedLinesAndMarkers(renderedEdges: RenderedEdge[], lines: LineConf[] | undefined): {
3
+ renderedLines: RenderedLine[];
4
+ markers: LineMarker[];
5
+ };
@@ -0,0 +1,15 @@
1
+ import type { DiagramNode, RenderedEdge, RenderedNode } from "../interfaces";
2
+ export type KeyboardAction = KeyboardActionSwitchActiveNode | KeyboardActionDeleteNode;
3
+ export interface KeyboardActionSwitchActiveNode {
4
+ action: "switch-active-node";
5
+ node?: DiagramNode;
6
+ }
7
+ export interface KeyboardActionDeleteNode {
8
+ action: "delete-node";
9
+ node: DiagramNode;
10
+ }
11
+ export declare function handleKeyboard(event: KeyboardEvent, { renderedNodes, renderedEdges, activeNodeId, }: {
12
+ renderedNodes: RenderedNode[];
13
+ renderedEdges: RenderedEdge[];
14
+ activeNodeId: string | undefined;
15
+ }): KeyboardAction | undefined;
@@ -0,0 +1,2 @@
1
+ import type { DiagramEdge, LineConf } from "../interfaces";
2
+ export declare function matchEdgeByFilter(edge: DiagramEdge, filter: LineConf): boolean;
File without changes
@@ -0,0 +1,369 @@
1
+ 构件 `eo-diagram`
2
+
3
+ ## Examples
4
+
5
+ ### Basic
6
+
7
+ ```yaml preview minHeight="600px"
8
+ brick: div
9
+ properties:
10
+ style:
11
+ position: fixed
12
+ height: 100vh
13
+ width: 100vw
14
+ top: 0px
15
+ left: 0px
16
+ context:
17
+ - name: activeNodeId
18
+ - name: nodes
19
+ value:
20
+ - id: kspacey
21
+ label: Kevin Spacey
22
+ - id: swilliams
23
+ label: Saul Williams
24
+ - id: bpitt
25
+ label: Brad Pitt
26
+ # - id: hford
27
+ # label: Harrison Ford
28
+ - id: lwilson
29
+ label: Luke Wilson
30
+ - id: kbacon
31
+ label: Kevin Bacon
32
+ - name: edges
33
+ value:
34
+ - source: kspacey
35
+ target: swilliams
36
+ - source: swilliams
37
+ target: kbacon
38
+ - source: bpitt
39
+ target: kbacon
40
+ # - source: hford
41
+ # target: lwilson
42
+ - source: lwilson
43
+ target: kbacon
44
+ children:
45
+ - brick: eo-button
46
+ properties:
47
+ textContent: Add Harrison Ford
48
+ events:
49
+ click:
50
+ - action: context.replace
51
+ args:
52
+ - nodes
53
+ - |
54
+ <%
55
+ CTX.nodes.concat({
56
+ id: "hford",
57
+ label: "Harrison Ford",
58
+ })
59
+ %>
60
+ - action: context.replace
61
+ args:
62
+ - edges
63
+ - |
64
+ <%
65
+ CTX.edges.concat({
66
+ source: "hford",
67
+ target: "lwilson",
68
+ })
69
+ %>
70
+ - target: _self
71
+ properties:
72
+ style:
73
+ visibility: hidden
74
+ - brick: eo-button
75
+ properties:
76
+ textContent: Remove Kevin Spacey
77
+ events:
78
+ click:
79
+ - action: context.replace
80
+ args:
81
+ - nodes
82
+ - |
83
+ <%
84
+ CTX.nodes.filter(node => node.id !== "kspacey")
85
+ %>
86
+ - action: context.replace
87
+ args:
88
+ - edges
89
+ - |
90
+ <%
91
+ CTX.edges.filter(({ source, target }) => source !== "kspacey" && target !== "kspacey")
92
+ %>
93
+ - target: _self
94
+ properties:
95
+ style:
96
+ visibility: hidden
97
+ - brick: eo-diagram
98
+ properties:
99
+ layout: dagre
100
+ nodes: <%= CTX.nodes %>
101
+ edges: <%= CTX.edges %>
102
+ lines:
103
+ - arrow: true
104
+ activeNodeId: <%= CTX.activeNodeId %>
105
+ nodeBricks:
106
+ - useBrick:
107
+ # if: <% DATA.node.id !== "kbacon" %>
108
+ brick: div
109
+ properties:
110
+ style: |
111
+ <%=
112
+ {
113
+ width: "180px",
114
+ height: "100px",
115
+ border: "2px solid green",
116
+ display: "flex",
117
+ alignItems: "center",
118
+ justifyContent: "center",
119
+ outline: DATA.node.id === CTX.activeNodeId ? "2px solid orange" : "none",
120
+ outlineOffset: "2px",
121
+ }
122
+ %>
123
+ children:
124
+ - brick: span
125
+ properties:
126
+ textContent: <% DATA.node.label %>
127
+ events:
128
+ click:
129
+ action: context.replace
130
+ args:
131
+ - activeNodeId
132
+ - <% DATA.node.id %>
133
+ events:
134
+ activeNode.change:
135
+ action: context.replace
136
+ if: <% CTX.activeNodeId !== EVENT.detail.id %>
137
+ args:
138
+ - activeNodeId
139
+ - <% EVENT.detail?.id %>
140
+ ```
141
+
142
+ ### Page Architecture
143
+
144
+ ```yaml preview minHeight="600px"
145
+ brick: div
146
+ properties:
147
+ style:
148
+ position: fixed
149
+ height: 100vh
150
+ width: 100vw
151
+ top: 0px
152
+ left: 0px
153
+ context:
154
+ - name: activeNodeId
155
+ - name: tempNodeId
156
+ - name: targetNode
157
+ - name: editingLabelNodes
158
+ value: []
159
+ - name: nodes
160
+ value:
161
+ - type: board
162
+ id: 60bf6078b095f
163
+ name: Visual Builder
164
+ depth: 0
165
+ parentId:
166
+ description: 某某产品
167
+ - type: page
168
+ id: 60bf60848d6d2
169
+ name: 项目列表
170
+ depth: 1
171
+ parentId: 60bf6078b095f
172
+ description: 列表页
173
+ - type: page
174
+ id: 60d533eba4ab2
175
+ name: ccc
176
+ depth: 1
177
+ parentId: 60bf6078b095f
178
+ description: cccc
179
+ - type: link
180
+ id: 60bf6091a1089
181
+ name: 新建项目
182
+ pageType: information:form:basic-form
183
+ description: 新建页213
184
+ to:
185
+ "@":
186
+ description: 无项目
187
+ instanceId: 60c5fea301b32
188
+ description: 新建页213
189
+ instanceId: 60bf6091a1089
190
+ module: []
191
+ name: 新建项目
192
+ pageType: information:form:basic-form
193
+ depth: -1
194
+ parentId:
195
+ - type: link
196
+ id: 60bf60a258613
197
+ name: 项目首页-路由管理
198
+ description: 路由管理
199
+ to:
200
+ description: 路由管理
201
+ instanceId: 60bf60a258613
202
+ module:
203
+ - instanceId: 60bf609b26889
204
+ name: Project
205
+ name: 项目首页-路由管理
206
+ depth: -1
207
+ parentId:
208
+ - type: link
209
+ id: 60c5f39a2c2e1
210
+ name: Launchpad 出厂配置
211
+ description: Launchpad 出厂配置
212
+ to:
213
+ description: Launchpad 出厂配置
214
+ instanceId: 60c5f39a2c2e1
215
+ module: []
216
+ name: Launchpad 出厂配置
217
+ depth: -1
218
+ parentId:
219
+ - name: edges
220
+ value:
221
+ - type: menu
222
+ source: 60bf6078b095f
223
+ target: 60bf60848d6d2
224
+ - type: menu
225
+ source: 60bf6078b095f
226
+ target: 60d533eba4ab2
227
+ - type: link
228
+ source: 60bf60848d6d2
229
+ target: 60bf6091a1089
230
+ description: 无项目
231
+ - type: link
232
+ source: 60bf60848d6d2
233
+ target: 60bf60a258613
234
+ - type: link
235
+ source: 60bf60848d6d2
236
+ target: 60c5f39a2c2e1
237
+ children:
238
+ - brick: eo-diagram
239
+ properties:
240
+ layout: dagre
241
+ nodes: <%= CTX.nodes %>
242
+ edges: <%= CTX.edges %>
243
+ lines:
244
+ - edgeType: link
245
+ strokeColor: var(--theme-blue-color)
246
+ arrow: true
247
+ - edgeType: menu
248
+ strokeColor: var(--palette-gray-5)
249
+ arrow: true
250
+ layoutOptions:
251
+ nodePadding: 10
252
+ activeNodeId: <%= CTX.activeNodeId %>
253
+ disableKeyboardAction: <%= CTX.editingLabelNodes.length > 0 %>
254
+ nodeBricks:
255
+ - useBrick:
256
+ brick: visual-builder.page-arch-node
257
+ properties:
258
+ label: <% DATA.node.name %>
259
+ type: <% DATA.node.type %>
260
+ autoFocusOnce: |
261
+ <% DATA.node.$temp ? DATA.node.id : undefined %>
262
+ active: <%= CTX.activeNodeId === DATA.node.id %>
263
+ events:
264
+ click:
265
+ action: context.replace
266
+ args:
267
+ - activeNodeId
268
+ - <% DATA.node.id %>
269
+ label.editing.change:
270
+ action: context.replace
271
+ args:
272
+ - editingLabelNodes
273
+ - |
274
+ <%
275
+ EVENT.detail
276
+ ? CTX.editingLabelNodes.concat(DATA.node.id)
277
+ : CTX.editingLabelNodes.filter(
278
+ id => id !== DATA.node.id
279
+ )
280
+ %>
281
+ label.change:
282
+ - if: <% CTX.nodes.find(({id}) => id === DATA.node.id)?.$temp %>
283
+ action: context.replace
284
+ args:
285
+ args:
286
+ - nodes
287
+ - |
288
+ <%
289
+ CTX.nodes.map((node) => (
290
+ node.id === DATA.node.id
291
+ ? { ...node, $temp: false, name: EVENT.detail }
292
+ : node
293
+ ))
294
+ %>
295
+ # Take reaction only if the label has been changed
296
+ - if: <% CTX.nodes.find(({id}) => id === DATA.node.id)?.name !== EVENT.detail %>
297
+ action: context.replace
298
+ args:
299
+ - nodes
300
+ - |
301
+ <%
302
+ CTX.nodes.map((node) => (
303
+ node.id === DATA.node.id
304
+ ? { ...node, name: EVENT.detail }
305
+ : node
306
+ ))
307
+ %>
308
+ child.append:
309
+ - action: context.replace
310
+ args:
311
+ - tempNodeId
312
+ - <% _.uniqueId('$temp-') %>
313
+ - action: context.replace
314
+ args:
315
+ - nodes
316
+ - |
317
+ <% CTX.nodes.concat({ id: CTX.tempNodeId, name: "未命名", $temp: true }) %>
318
+ - action: context.replace
319
+ args:
320
+ - edges
321
+ - |
322
+ <% CTX.edges.concat({ source: DATA.node.id, target: CTX.tempNodeId, name: "未命名", type: "link", $temp: true }) %>
323
+ - action: context.replace
324
+ args:
325
+ - activeNodeId
326
+ - <% CTX.tempNodeId %>
327
+ events:
328
+ activeNode.change:
329
+ - action: context.replace
330
+ # Take reaction only if the active node has been changed
331
+ # Otherwise it may cause infinite loop
332
+ if: <% CTX.activeNodeId !== EVENT.detail?.id %>
333
+ args:
334
+ - activeNodeId
335
+ - <% EVENT.detail?.id %>
336
+ node.delete:
337
+ - action: context.replace
338
+ args:
339
+ - targetNode
340
+ - <% EVENT.detail %>
341
+ - useProvider: basic.show-dialog
342
+ args:
343
+ - type: delete
344
+ title: Delete Confirm
345
+ content: Please enter {{ expect }} to delete the node.
346
+ expect: <% EVENT.detail.name || "未命名" %>
347
+ callback:
348
+ success:
349
+ - action: context.replace
350
+ args:
351
+ - nodes
352
+ - |-
353
+ <%
354
+ CTX.nodes.filter(
355
+ ({ id }) => id !== CTX.targetNode.id
356
+ )
357
+ %>
358
+ - action: context.replace
359
+ args:
360
+ - edges
361
+ - |-
362
+ <%
363
+ CTX.edges.filter(
364
+ ({ source, target }) =>
365
+ source !== CTX.targetNode.id &&
366
+ target !== CTX.targetNode.id
367
+ )
368
+ %>
369
+ ```
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@next-bricks/diagram",
3
+ "version": "0.1.0",
4
+ "homepage": "https://github.com/easyops-cn/next-bricks/tree/master/bricks/diagram",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git@github.com:easyops-cn/next-bricks.git"
8
+ },
9
+ "license": "GPL-3.0",
10
+ "type": "module",
11
+ "sideEffects": true,
12
+ "files": [
13
+ "dist",
14
+ "dist-types",
15
+ "docs"
16
+ ],
17
+ "exports": {
18
+ "./package.json": "./package.json",
19
+ "./dist/bricks.json": "./dist/bricks.json",
20
+ "./dist/manifest.json": "./dist/manifest.json",
21
+ "./*": {
22
+ "types": "./dist-types/*/index.d.ts"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "start": "cross-env NODE_ENV=development build-next-bricks --watch",
27
+ "build": "npm run build:main && npm run build:types",
28
+ "build:main": "cross-env NODE_ENV=production build-next-bricks",
29
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json",
30
+ "build:manifest": "cross-env NODE_ENV=production build-next-bricks --manifest-only",
31
+ "test": "cross-env NODE_ENV='test' test-next",
32
+ "test:ci": "cross-env NODE_ENV='test' CI=true test-next",
33
+ "prepublishOnly": "cp package.json package.json.bak && npm pkg delete dependencies",
34
+ "postpublish": "mv package.json.bak package.json"
35
+ },
36
+ "devDependencies": {
37
+ "@next-core/build-next-bricks": "^1.20.0",
38
+ "@next-core/test-next": "^1.0.13"
39
+ },
40
+ "peerDependencies": {
41
+ "@next-bricks/icons": "*"
42
+ },
43
+ "gitHead": "b8264f0baebbf6c4f39eb8e8fd17f272f3c79df8"
44
+ }