@bit-sun/business-component 2.0.39-alpha.7 → 2.0.40

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 (47) hide show
  1. package/.fatherrc.ts +1 -3
  2. package/.umirc.ts +6 -6
  3. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +0 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.esm.js +2698 -7753
  6. package/dist/index.js +2689 -7749
  7. package/package.json +4 -10
  8. package/src/assets/list-no-img.svg +22 -0
  9. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +0 -1
  10. package/src/components/Business/BsLayouts/utils.tsx +4 -1
  11. package/src/components/Business/BsSulaQueryTable/index.tsx +93 -123
  12. package/src/components/Business/BsSulaQueryTable/setting.tsx +55 -71
  13. package/src/components/Business/BsSulaQueryTable/utils.tsx +5 -8
  14. package/src/components/Business/DetailPageWrapper/index.tsx +1 -1
  15. package/src/components/Business/columnSettingTable/index.tsx +25 -19
  16. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +25 -19
  17. package/src/components/Functional/DataImport/index.tsx +6 -0
  18. package/src/components/Functional/DataValidation/index.md +1 -0
  19. package/src/components/Functional/DataValidation/index.tsx +8 -2
  20. package/src/index.ts +0 -2
  21. package/src/styles/bsDefault.less +11 -0
  22. package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +0 -2
  23. package/dist/components/Business/JsonQueryTable/index.d.ts +0 -3
  24. package/src/assets/defaultBusiness.less +0 -1896
  25. package/src/components/Business/JsonQueryTable/configButton/index.js +0 -20
  26. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +0 -25
  27. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +0 -30
  28. package/src/components/Business/JsonQueryTable/configTree/index.js +0 -82
  29. package/src/components/Business/JsonQueryTable/configTree/index.less +0 -44
  30. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +0 -57
  31. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +0 -124
  32. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +0 -29
  33. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +0 -22
  34. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +0 -116
  35. package/src/components/Business/JsonQueryTable/drawer/index.tsx +0 -12
  36. package/src/components/Business/JsonQueryTable/index.md +0 -275
  37. package/src/components/Business/JsonQueryTable/index.tsx +0 -216
  38. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +0 -340
  39. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +0 -22
  40. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +0 -147
  41. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +0 -389
  42. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +0 -118
  43. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +0 -22
  44. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +0 -21
  45. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +0 -65
  46. package/src/utils/getFormMode.js +0 -12
  47. package/src/utils/serialize.js +0 -7
@@ -1,340 +0,0 @@
1
- import React, { useEffect } from 'react';
2
- import {
3
- Typography,
4
- Button,
5
- message,
6
- Popconfirm,
7
- Tooltip,
8
- Row,
9
- Col,
10
- Space,
11
- } from 'antd';
12
- import Editor, { monaco } from '@monaco-editor/react';
13
- import serialize, { deserialize } from '@/utils/serialize';
14
- import {
15
- BulbOutlined,
16
- PlayCircleOutlined,
17
- DeleteOutlined,
18
- CopyOutlined,
19
- SaveOutlined,
20
- FullscreenOutlined,
21
- FullscreenExitOutlined,
22
- } from '@ant-design/icons';
23
- import validateSulaConfig from './lint';
24
- import * as acorn from 'acorn';
25
- import * as walk from 'acorn-walk';
26
- import ConfigTree, { iconRender, nameRender } from '../configTree';
27
- import registerSuggestions from './suggestions';
28
- import style from './index.less';
29
-
30
- const { Title } = Typography;
31
- const STRTEMP = 'const config = ';
32
-
33
- const getEditorValue = data => {
34
- return `${STRTEMP}${serialize(data, { space: 2, unsafe: true })}`;
35
- };
36
-
37
- let isRegister;
38
- let decorations = [];
39
-
40
- export default props => {
41
- const monacoRef = React.useRef(null);
42
- const {
43
- onRun,
44
- value,
45
- type,
46
- onFullScreen = () => {},
47
- shallowHeight = 0,
48
- } = props;
49
-
50
- const editorRef = React.useRef(null);
51
- const [highLightLine, setHighLightLine] = React.useState();
52
- const [isFull, setFull] = React.useState(false);
53
-
54
- const isTableAllValue = !!value?.columns;
55
-
56
- const finalValue = getEditorValue(isTableAllValue ? {columns: value?.columns, fields: value?.fields} : value);
57
- const [treeData, setTreeData] = React.useState(finalValue);
58
-
59
- const handleCopy = () => {
60
- const jsonEditorValue = editorRef.current.getValue();
61
- const val = serialize(jsonEditorValue, { space: 2 });
62
- message.success('JSON Schema Copied 🎉');
63
- };
64
-
65
- const formatDocument = () => {
66
- setTimeout(() => {
67
- editorRef.current &&
68
- editorRef.current.getAction('editor.action.formatDocument').run();
69
- }, 300);
70
- };
71
-
72
- monaco.init().then(ref => {
73
- monacoRef.current = ref;
74
- if (!isRegister) {
75
- registerSuggestions(ref);
76
- isRegister = true;
77
- }
78
- });
79
-
80
- const onEditorDidMount = (_monaco, editor) => {
81
- editorRef.current = editor;
82
- const model = editor.getModel();
83
-
84
- formatDocument();
85
-
86
- editor.onKeyDown(e => {
87
- if (e.shiftKey) {
88
- editorRef.current &&
89
- editorRef.current.trigger(
90
- 'auto completion',
91
- 'editor.action.triggerSuggest',
92
- );
93
- }
94
- });
95
-
96
- editor.onDidChangeCursorPosition(e => {
97
- const lineCount = editor.getModel().getLineCount();
98
- if (e.position.lineNumber === 1) {
99
- editor.setPosition({
100
- lineNumber: 2,
101
- column: 1,
102
- });
103
- } else if (e.position.lineNumber === lineCount) {
104
- editor.setPosition({
105
- lineNumber: lineCount - 1,
106
- column: 1,
107
- });
108
- }
109
- });
110
-
111
- editor.onMouseDown(event => {
112
- clearDecorations();
113
- onEditorLineChange(event.target.position);
114
- });
115
-
116
- editor.onKeyDown(event => {
117
- setTimeout(() => {
118
- const position = editor.getPosition();
119
- onEditorLineChange(position);
120
- setTreeData(editor.getValue());
121
- });
122
- });
123
-
124
- editor.onDidChangeModelContent(() => {
125
- const content = editor.getValue();
126
- const markers = monacoRef.current.editor.getModelMarkers();
127
-
128
- if (markers.length > 0) {
129
- markers.forEach(marker => {
130
- monacoRef.current.editor.setModelMarkers(
131
- editor.getModel(),
132
- marker.owner,
133
- [],
134
- );
135
- });
136
- }
137
- const ast = acorn.parse(content, { locations: true });
138
- walk.full(ast, node => {
139
- // if (node?.loc?.start?.column < 5) {
140
- validateSulaConfig(node, monacoRef.current, editor);
141
- // }
142
- });
143
- });
144
- };
145
-
146
- function onEditorLineChange(position) {
147
- const { lineNumber } = position || {};
148
- setHighLightLine(lineNumber);
149
- }
150
-
151
- // console.log(`点击字段: ${clickType}, 点击字段所属字段: ${type}, 提示: ${suggestionType}`);
152
-
153
- const onClickRun = () => {
154
- const value1 = editorRef.current.getValue().slice(STRTEMP.length);
155
-
156
- try {
157
- const res = deserialize(value1);
158
- debugger
159
- onRun(isTableAllValue ? {...value, columns: res.columns, fields: res.fields}: res);
160
- formatDocument();
161
- setFull(false);
162
- message.success(`Run Success 🎉`);
163
- } catch (e) {
164
- message.error(`JSON 格式错误`);
165
- }
166
- };
167
-
168
- const onClickDelete = () => {
169
- editorRef.current.setValue(`${STRTEMP}{\n\n}`);
170
- };
171
-
172
- function clearDecorations() {
173
- if (decorations.length) {
174
- decorations = editorRef.current.deltaDecorations(decorations, []);
175
- }
176
- }
177
-
178
- function setDecorations(range) {
179
- const [startLineNumber, startColumn, endLineNumber, endColumn] = range;
180
- const newDecorations = editorRef.current.deltaDecorations(
181
- [],
182
- [
183
- {
184
- range: {
185
- endColumn,
186
- endLineNumber,
187
- startColumn,
188
- startLineNumber,
189
- },
190
- options: {
191
- className: 'si-editor-highlight',
192
- },
193
- },
194
- ],
195
- );
196
- decorations = decorations.concat(newDecorations);
197
- }
198
-
199
- const handleSelect = (node, hasChildren) => {
200
- const { loc, name } = node;
201
- clearDecorations();
202
- // 高亮
203
- if (hasChildren) {
204
- const [line, startColumn] = loc;
205
- const keyPosition = [line, startColumn, line, 100];
206
- setDecorations(keyPosition);
207
- } else {
208
- setDecorations(loc);
209
- }
210
- editorRef.current.revealLine(loc[0]); // 行跳转
211
- };
212
-
213
- const handleFullScreen = () => {
214
- setFull(true);
215
- };
216
-
217
- const handleExitFullScreen = () => {
218
- setFull(false);
219
- };
220
-
221
- useEffect(() => {
222
- editorRef?.current?.layout();
223
- onFullScreen && onFullScreen(isFull);
224
- }, [isFull]);
225
-
226
- useEffect(() => {
227
- editorRef?.current?.layout();
228
- }, [shallowHeight]);
229
-
230
- const hasConfigTree = type !== 'editor';
231
-
232
- return (
233
- <div className={isFull ? style.editorWrapper : ''}>
234
- <div style={{ overflow: 'hidden' }}>
235
- <Title style={{ float: 'left' }} level={4}>
236
- 代码展示
237
- </Title>
238
- <Tooltip title="按 shift 键快速呼出提示">
239
- <BulbOutlined
240
- style={{ marginLeft: 8, lineHeight: '32px', cursor: 'pointer' }}
241
- />
242
- </Tooltip>
243
- <Space style={{ float: 'right' }}>
244
- <Tooltip title="运行代码">
245
- <Button
246
- shape="circle"
247
- size="small"
248
- type="primary"
249
- icon={<PlayCircleOutlined />}
250
- onClick={onClickRun}
251
- shape="circle"
252
- />
253
- </Tooltip>
254
- {/* <Popconfirm title="确定要清空吗?" onConfirm={onClickDelete}>
255
- <Tooltip title="清空代码">
256
- <Button
257
- type="primary"
258
- icon={<DeleteOutlined />}
259
- size="small"
260
- shape="circle"
261
- />
262
- </Tooltip>
263
- </Popconfirm> */}
264
- <Tooltip title="保存">
265
- <Button
266
- type="primary"
267
- icon={<SaveOutlined />}
268
- onClick={handleCopy}
269
- style={{
270
- border: 'none',
271
- }}
272
- shape="circle"
273
- size="small"
274
- />
275
- </Tooltip>
276
- <div>
277
- <Tooltip title="退出全屏">
278
- <Button
279
- type="primary"
280
- icon={<FullscreenExitOutlined />}
281
- onClick={handleExitFullScreen}
282
- style={{
283
- border: 'none',
284
- display: !isFull ? 'none' : '',
285
- }}
286
- shape="circle"
287
- size="small"
288
- />
289
- </Tooltip>
290
- <Tooltip title="全屏编辑">
291
- <Button
292
- type="primary"
293
- icon={<FullscreenOutlined />}
294
- onClick={handleFullScreen}
295
- style={{
296
- border: 'none',
297
- display: isFull ? 'none' : '',
298
- }}
299
- shape="circle"
300
- size="small"
301
- />
302
- </Tooltip>
303
- </div>
304
- </Space>
305
- </div>
306
- <Row>
307
- <Col span={hasConfigTree ? 16 : 24}>
308
- <Editor
309
- height={`calc(100vh - ${shallowHeight + 100}px)`}
310
- language="javascript"
311
- editorDidMount={onEditorDidMount}
312
- options={{
313
- selectOnLineNumbers: true,
314
- renderSideBySide: false,
315
- }}
316
- value={finalValue}
317
- // value={{columns: finalValue.columns, fields: finalValue.fields}}
318
- />
319
- </Col>
320
- {hasConfigTree && (
321
- <Col span={8}>
322
- <div className={style.title}>属性节点树</div>
323
- <ConfigTree
324
- style={{
325
- height: 'calc(100vh - 300px)',
326
- overflowY: 'scroll',
327
- }}
328
- level={1}
329
- data={treeData}
330
- onSelect={handleSelect}
331
- currentLine={highLightLine}
332
- iconRender={iconRender}
333
- nameRender={nameRender}
334
- />
335
- </Col>
336
- )}
337
- </Row>
338
- </div>
339
- );
340
- };
@@ -1,22 +0,0 @@
1
- :global {
2
- .si-editor-highlight {
3
- background: #1990ffab;
4
- }
5
- }
6
-
7
- .title {
8
- color: #1890ff;
9
- padding: 12px;
10
- font-weight: bold;
11
- }
12
-
13
- .editorWrapper {
14
- position: fixed;
15
- left: 0;
16
- right: 0;
17
- top: 0;
18
- bottom: 0;
19
- padding: 24px;
20
- background-color: #fff;
21
- z-index: 10000;
22
- }
@@ -1,147 +0,0 @@
1
- import { isString, isNumber, isBoolean, lowerCase } from 'lodash';
2
-
3
- const getData = data => data.value || data;
4
-
5
- /**
6
- *
7
- * 其他类型暂时忽略
8
- */
9
-
10
- const isIgnoreType = node => {
11
- return getData(node).type === 'ConditionalExpression';
12
- };
13
-
14
- /**
15
- * 基础类型
16
- */
17
- export const isStringType = node => {
18
- if (isIgnoreType(node)) {
19
- return true;
20
- }
21
- return isString(getData(node).value);
22
- };
23
-
24
- export const isArrayType = node => {
25
- if (isIgnoreType(node)) {
26
- return true;
27
- }
28
- return getData(node).type === 'ArrayExpression';
29
- };
30
-
31
- export const isNumberType = node => {
32
- if (isIgnoreType(node)) {
33
- return true;
34
- }
35
- return isNumber(getData(node).value);
36
- };
37
-
38
- export const isBooleanType = node => {
39
- if (isIgnoreType(node)) {
40
- return true;
41
- }
42
- return isBoolean(getData(node).value);
43
- };
44
-
45
- export const isObjectType = node => {
46
- if (isIgnoreType(node)) {
47
- return true;
48
- }
49
- return getData(node).type === 'ObjectExpression';
50
- };
51
-
52
- export const isEmptyObjectType = node => {
53
- if (isIgnoreType(node)) {
54
- return true;
55
- }
56
- return isObjectType(node) && !getData(node).value;
57
- };
58
-
59
- export const isFunctionType = node => {
60
- if (isIgnoreType(node)) {
61
- return true;
62
- }
63
- return (
64
- getData(node).type === 'ArrowFunctionExpression' ||
65
- getData(node).type === 'FunctionExpression' ||
66
- getData(node).type === 'ObjectMethod'
67
- );
68
- };
69
-
70
- /**
71
- * field
72
- */
73
-
74
- export const isNameType = node => {
75
- return isStringType(node) || isNumberType(node) || isArrayType(node);
76
- };
77
-
78
- export const isFieldRenderType = node => {
79
- return isStringType(node) || isObjectType(node) || isFunctionType(node);
80
- };
81
-
82
- export const isLayoutType = node => {
83
- if (isIgnoreType(node)) {
84
- return true;
85
- }
86
- return ['vertical', 'horizontal', 'inline'].indexOf(getData(node).value) > -1;
87
- };
88
-
89
- export const isModeType = node => {
90
- // console.log(getv(node).value);
91
- if (isIgnoreType(node)) {
92
- return true;
93
- }
94
- return ['view', 'create', 'edit'].indexOf(getData(node).value) > -1;
95
- };
96
-
97
- /**
98
- * 通用
99
- */
100
- export const isFetchType = node => {
101
- const { properties } = getData(node);
102
- if (!properties.length) return false;
103
- return properties.some(item => {
104
- const { key, value } = item || {};
105
- if ((key.name || key.value) === 'url') {
106
- return true;
107
- }
108
- });
109
- };
110
-
111
- export const isMethodType = node => {
112
- if (isIgnoreType(node)) {
113
- return true;
114
- }
115
- return ['post', 'get', 'delete'].indexOf(lowerCase(getData(node).value)) > -1;
116
- };
117
-
118
- /**
119
- * table
120
- */
121
-
122
- export const isColumnRender = node => {
123
- if (isIgnoreType(node)) {
124
- return true;
125
- }
126
- return (
127
- isStringType(node) ||
128
- isObjectType(node) ||
129
- isArrayType(node) ||
130
- isFunctionType(node)
131
- );
132
- };
133
-
134
- /**
135
- * action
136
- */
137
- export const isActionType = node => {
138
- if (isIgnoreType(node)) {
139
- return true;
140
- }
141
- return (
142
- isStringType(node) ||
143
- isObjectType(node) ||
144
- isArrayType(node) ||
145
- isFunctionType(node)
146
- );
147
- };