@steedos/steedos-plugin-schema-builder 2.2.50 → 2.2.51-beta.4

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 (55) hide show
  1. package/package.json +3 -49
  2. package/webapp/package.json +59 -0
  3. package/src/objects.action.js +0 -5
  4. package/src/objects.object.yml +0 -6
  5. package/webapp/src/custom.d.ts +0 -33
  6. package/webapp/src/g6/behavior/activate-relations/index.tsx +0 -160
  7. package/webapp/src/g6/behavior/darg/index.tsx +0 -146
  8. package/webapp/src/g6/behavior/index.tsx +0 -5
  9. package/webapp/src/g6/model/editor-background.png +0 -0
  10. package/webapp/src/g6/model/index.tsx +0 -574
  11. package/webapp/src/g6/model/model-node.tsx +0 -1080
  12. package/webapp/src/g6/model/model.scss +0 -163
  13. package/webapp/src/g6/model/toolbar.tsx +0 -360
  14. package/webapp/src/g6/shape/base-sharp/index.tsx +0 -19
  15. package/webapp/src/g6/shape/index.tsx +0 -0
  16. package/webapp/src/g6/util/graph.tsx +0 -60
  17. package/webapp/src/g6/util/hooks.tsx +0 -26
  18. package/webapp/src/g6/util/index.tsx +0 -20
  19. package/webapp/src/g6/util/intel.ts +0 -7
  20. package/webapp/src/hook/index.tsx +0 -47
  21. package/webapp/src/index.tsx +0 -25
  22. package/webapp/src/page/dva-model/index.tsx +0 -70
  23. package/webapp/src/page/dva-model/reducer/arrange.tsx +0 -16
  24. package/webapp/src/page/dva-model/reducer/index.tsx +0 -7
  25. package/webapp/src/page/dva-model/reducer/init.tsx +0 -61
  26. package/webapp/src/page/dva-model/reducer/model.tsx +0 -126
  27. package/webapp/src/page/dva-model/reducer/on-expand.tsx +0 -27
  28. package/webapp/src/page/dva-model/style.tsx +0 -88
  29. package/webapp/src/page/hooks/callback.tsx +0 -54
  30. package/webapp/src/page/hooks/fullscreen.tsx +0 -34
  31. package/webapp/src/page/hooks/pagehooks.tsx +0 -127
  32. package/webapp/src/page/hooks/resize.tsx +0 -20
  33. package/webapp/src/page/index.tsx +0 -393
  34. package/webapp/src/page/model-navi/index.tsx +0 -329
  35. package/webapp/src/page/model-navi/style.scss +0 -111
  36. package/webapp/src/page/util/index.tsx +0 -234
  37. package/webapp/src/page/util/layout-nodes/index.tsx +0 -185
  38. package/webapp/src/pdm/index.tsx +0 -50
  39. package/webapp/src/pdm/pdm-json/index.js +0 -224
  40. package/webapp/src/pdm/pdm-json/removeDiacritics.js +0 -96
  41. package/webapp/src/pdm/util.ts +0 -60
  42. package/webapp/src/style.less +0 -14
  43. package/webapp/src/tree/index.tsx +0 -46
  44. package/webapp/src/tree/style.scss +0 -26
  45. package/webapp/src/type/field.tsx +0 -10
  46. package/webapp/src/type/index.tsx +0 -3
  47. package/webapp/src/type/model.tsx +0 -12
  48. package/webapp/src/type/module.tsx +0 -4
  49. package/webapp/test/g6-test/mock/model-test.ts +0 -3620
  50. package/webapp/test/g6-test/mock/module-test.ts +0 -14
  51. package/webapp/test/g6-test/mock/steedos-test.ts +0 -86
  52. package/webapp/test/index.tsx +0 -66
  53. package/webapp/test/testg6.tsx +0 -126
  54. package/webapp/test/unstated/index.tsx +0 -19
  55. package/webapp/tsconfig.json +0 -27
@@ -1,20 +0,0 @@
1
-
2
- import { useCallback, useEffect, useState } from 'react'
3
-
4
- export const useResizeUpdate = () => {
5
-
6
- const [_, update] = useState(0)
7
-
8
- const onResize = useCallback(() => {
9
- // alert()
10
- update(+new Date())
11
- }, [])
12
-
13
- useEffect(() => {
14
- window.addEventListener('resize', onResize)
15
- return (() => {
16
- window.removeEventListener('resize', onResize)
17
- })
18
-
19
- })
20
- }
@@ -1,393 +0,0 @@
1
-
2
- import { Empty, Spin } from 'antd'
3
- import { useDispatch } from '../hook'
4
- import React, {
5
- useCallback,
6
- useEffect,
7
- useRef,
8
- useState,
9
- } from 'react'
10
- // import Pdm from '../../test/g6-test/pdm'
11
- import { toCenter } from './../g6/util/graph'
12
- // import { modelConfig , styleConfigLazy } from './config'
13
- import { useFpsHook } from './hooks/callback'
14
- import { useLocalHooks } from './hooks/pagehooks'
15
- import { useResizeUpdate } from './hooks/resize'
16
- import ModelNavi from './model-navi'
17
- // import { updateLayout } from './util'
18
-
19
- import intl from './../g6/util/intel'
20
-
21
- export default (
22
- {
23
- namespace = 'erd' , primaryColor, toolBarCommands,
24
- saveFun, delFun, modelEditFun, fieldEditFun, changeData,
25
- modelInsertFun, useAppContext, getModels,
26
- getModules, ModelEdit, ModelInsert,
27
- ErdPage, isFullScreen, ...props}) => {
28
- const {
29
- graph,
30
- models,
31
- checkedKeys,
32
- graphRef,
33
- showModel,
34
- currentModel,
35
- layouted,
36
- showInsertModel,
37
- search,
38
- layouting,
39
- style,
40
- colors,
41
- } = useLocalHooks({ namespace, useAppContext, ...props})
42
- const dispatch = useDispatch()
43
-
44
- useResizeUpdate()
45
-
46
- const onCancle = () => {
47
- dispatch({
48
- type: `${namespace}/closeModel`,
49
- })
50
- }
51
-
52
- const onInsertCancle = () => {
53
- dispatch({
54
- type: `${namespace}/closeInsertModel`,
55
- })
56
- }
57
-
58
- const [width, setWidth] = useState(0)
59
-
60
- const G6GraphDomRef = useRef({
61
- offsetWidth: 0,
62
- offsetHeight: 0,
63
- })
64
- const isKeySharp = useRef(true)
65
- const [once, setOnce] = useState(true)
66
- const [updateId, setUpdateId] = useState(0)
67
- const { tabsRouteContext } = useAppContext()
68
-
69
- useEffect(() => {
70
- if (isFullScreen) {
71
- setWidth(G6GraphDomRef.current.offsetWidth)
72
- setOnce(false)
73
- } else if (
74
- G6GraphDomRef.current.offsetWidth &&
75
- tabsRouteContext.current === '/'
76
- ) {
77
- if (layouted) {
78
- setImmediate(() => {
79
- G6GraphDomRef.current && setWidth(G6GraphDomRef.current.offsetWidth)
80
- setOnce(false)
81
- }, 100)
82
- } else {
83
- setWidth(G6GraphDomRef.current.offsetWidth)
84
- }
85
- }
86
- }, [G6GraphDomRef.current.offsetWidth])
87
-
88
- const styleConfig = style
89
-
90
- const erdLoading = models.length > 0 && !!width && !once
91
- const toolBarCommand = useCallback(
92
- (name, action) => {
93
- const _graph = graphRef.current
94
-
95
- if (name === 'keySharp') {
96
- const { isKeysharp = !isKeySharp.current, isCardSharp } = action
97
- isKeySharp.current = isKeysharp
98
-
99
- _graph
100
- .findAll('node', (node) => true)
101
- .map((node) => {
102
- _graph.updateItem(node, {
103
- isKeySharp: isKeySharp.current,
104
- isCardSharp,
105
- })
106
- })
107
-
108
- _graph.paint()
109
- }
110
- // }
111
-
112
- if(name === 'export-image') {
113
- const newZoom = 100
114
- _graph.isExporting = true
115
- _graph.getNodes().filter((a) => !a.isSys).forEach((node) => {
116
- node.getContainer().show()
117
- _graph.updateItem(node, {
118
- isKeySharp: false,
119
- isCardSharp: false ,
120
- })
121
- })
122
- const gwidth = _graph.get('width')
123
- const gheight = _graph.get('height')
124
- const point = _graph.getCanvasByPoint(gwidth / 2, gheight / 2)
125
- // graph.moveTo({x: point.x , y : point.y})
126
- _graph.zoomTo(newZoom / 100, {x: point.x , y : point.y})
127
- _graph.paint()
128
- _graph.downloadFullImage('模型图', undefined, {
129
- backgroundColor: 'rgb(245, 247, 255)',
130
- })
131
- _graph.isExporting = undefined
132
- }
133
-
134
- if (name === 'min-zoom') {
135
- const gwidth = _graph.get('width')
136
- const gheight = _graph.get('height')
137
- const point = _graph.getCanvasByPoint(gwidth / 2, gheight / 2)
138
-
139
- const zoom = _graph.getZoom()
140
- if (zoom > 0.2) {
141
- _graph.zoomTo(zoom - 0.2, point)
142
- } else {
143
- _graph.zoomTo(zoom - 0.02, point)
144
- }
145
- _graph.paint()
146
- setUpdateId(+new Date())
147
- }
148
-
149
- if (name === 'nodeClick') {
150
- dispatch({
151
- type: `${namespace}/currentModel`,
152
- model: action.node,
153
- })
154
-
155
- const currentNode = _graph
156
- .getNodes().filter((a) => !a.isSys)
157
- .find((node) => node.getModel().id === action.node)
158
-
159
- if (currentNode) {
160
- _graph.getNodes().filter((a) => !a.isSys).forEach((node) => {
161
- _graph.updateItem(node, {
162
- selected: node === currentNode,
163
- noSelected: node === currentNode,
164
- })
165
- })
166
-
167
- _graph.paint()
168
- }
169
- }
170
-
171
- if (name === 'click') {
172
-
173
- if (action.click === 'modelEdit') {
174
- const [_, ...actions] = action.node.split('-')
175
- const actionStrings = actions.join('-')
176
- if (modelEditFun)
177
- modelEditFun({
178
- model: actionStrings,
179
- })
180
- }
181
-
182
- if (action.click === 'arrangeShow') {
183
- dispatch({
184
- type: `${namespace}/` + action.click,
185
- model: action.arg,
186
- })
187
- }
188
-
189
- if (action.click === 'delModel') {
190
- dispatch({
191
- type: `${namespace}/` + action.click,
192
- model: action.node,
193
- })
194
- }
195
-
196
- if (action.click === 'delModule') {
197
- dispatch({
198
- type: `${namespace}/` + action.click,
199
- model: action.node,
200
- })
201
- }
202
-
203
- if (action.click === 'fieldSelect') {
204
- //
205
- if(action.arg.relationModelKey){
206
- dispatch({
207
- type: `${namespace}/currentModel`,
208
- model: 'model-' + action.arg.relationModelKey,
209
- })
210
-
211
- const item = _graph.findById('model-' + action.arg.relationModelKey)
212
-
213
- toCenter(item, _graph)
214
- }
215
-
216
- }
217
-
218
- if (action.click === 'fieldEdit') {
219
- const [_, ...actions] = action.node.split('-')
220
- const actionStrings = actions.join('-')
221
- if (fieldEditFun)
222
- fieldEditFun({
223
- model: actionStrings,
224
- field: action.arg,
225
- })
226
- }
227
- }
228
-
229
- if (name === 'upload') {
230
- const data = _graph.save()
231
-
232
- const nodes = data.nodes.reduce((pre, { x, y, id }) => {
233
- return {
234
- ...pre,
235
- [id]: {
236
- x,
237
- y,
238
- },
239
- }
240
- }, {})
241
- sessionStorage.setItem('console-erd-graph', JSON.stringify(nodes))
242
- alert(JSON.stringify(nodes))
243
- }
244
-
245
- if (name === 'max-zoom') {
246
-
247
- if (_graph.getZoom() >= 2.1) return
248
-
249
- const gwidth = _graph.get('width')
250
- const gheight = _graph.get('height')
251
- const point = _graph.getCanvasByPoint(gwidth / 2, gheight / 2)
252
- const zoom = _graph.getZoom()
253
- console.log(zoom / 2)
254
- if (zoom > 0.2) {
255
- _graph.zoomTo(zoom + 0.2, point)
256
- } else {
257
- _graph.zoomTo(zoom + 0.02, point)
258
- }
259
- setUpdateId(+new Date())
260
- }
261
-
262
- if (name === 'editModel') {
263
- dispatch({
264
- type: `${namespace}/openModel`,
265
- })
266
- const [_, ...actions] = currentModel.split('-')
267
- const actionStrings = actions.join('-')
268
- if (modelEditFun)
269
- modelEditFun({
270
- model: actionStrings,
271
- })
272
- }
273
-
274
- if (name === 'insertModel') {
275
- dispatch({
276
- type: `${namespace}/openInsertModel`,
277
- })
278
- if (modelInsertFun) modelInsertFun()
279
- }
280
-
281
- if (name === 'resetLayout') {
282
- _graph.refresh()
283
- }
284
-
285
- if (name === 'centerModel') {
286
- if (action && action.node) {
287
- dispatch({
288
- type: `${namespace}/currentModel`,
289
- model: action.node,
290
- })
291
-
292
- _graph.getNodes().filter((a) => !a.isSys).forEach((node) => {
293
- const current = node.getModel().id === action.node
294
- // current && toCenter(node, _graph)
295
-
296
- _graph.updateItem(node, {
297
- selected: current,
298
- isKeySharp: false,
299
- })
300
- })
301
- }
302
-
303
- const item = _graph.findById((action && action.node) || currentModel)
304
-
305
- toCenter(item, _graph)
306
- }
307
-
308
- if (name === 'save') {
309
- if (saveFun) saveFun()
310
- }
311
-
312
- if (name === 'delModel') {
313
- alert()
314
- dispatch({
315
- type: `${namespace}/delModel`,
316
- })
317
- delFun && delFun()
318
- }
319
- },
320
- [graphRef.current, currentModel],
321
- )
322
- const { fpsRef } = useFpsHook()
323
- const Pdm = props.Pdm
324
- return (
325
- <div
326
- className='console-g6-page'
327
- >
328
- {/* {Pdm && erdLoading && <Pdm />} */}
329
- <div
330
- className='console-erd-fps'
331
- ref={(ref) => {
332
- fpsRef.current = ref
333
- }}
334
- />
335
- <div
336
- className='g6-modelnavi'
337
- >
338
- <ModelNavi
339
- namespace={namespace}
340
- Tree={props.Tree}
341
- bottomHeight={props.bottomHeight || 78}
342
- Input={props.Input}
343
- Pdm={Pdm}
344
- toolBarCommand={toolBarCommand}
345
- clickModelNode={(key) => {
346
- toolBarCommand('nodeClick', {
347
- node: key,
348
- })
349
- }}
350
- primaryColor={primaryColor}
351
- getModels={getModels}
352
- getModules={getModules}
353
- />
354
- </div>
355
- <div className='g6-graph' ref={(ref) => { G6GraphDomRef.current = ref }}>
356
- {' '}
357
- <Spin tip='layout...' spinning={erdLoading && layouting}>
358
- {erdLoading ? (
359
- <ErdPage
360
- toolBarCommands={toolBarCommands}
361
- saveFun={saveFun}
362
- styleConfig={styleConfig}
363
- toolBarCommand={toolBarCommand}
364
- currentModel={currentModel}
365
- width={width}
366
- config={styleConfig}
367
- setGraph={(g) => (graphRef.current = g)}
368
- changeNodes={checkedKeys}
369
- checkedKeys={checkedKeys}
370
- height={G6GraphDomRef.current.offsetHeight - 54}
371
- graph={graph}
372
- update={updateId}
373
- colors={colors}
374
- setUpdateId={setUpdateId}
375
- namespace={namespace}
376
- />
377
- ) : (
378
- search ? <Empty
379
- description='no found model'
380
- /> :
381
- <div>
382
- {
383
- Pdm ? <Empty style={{textAlign: 'center'}} description={<Pdm />} /> : <Spin >
384
- <Empty style={{textAlign: 'center'}} description={intl.get('正在绘制模型图...').d('正在绘制模型图...')}
385
- /></Spin>
386
- }
387
- </div>
388
- )}
389
- </Spin>
390
- </div>
391
- </div>
392
- )
393
- }