@cicctencent/low-code-editor 0.0.0-stage → 1.1.9-beta.5

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 (97) hide show
  1. package/README.md +2 -2
  2. package/api-extractor.json +36 -0
  3. package/dist/ActivityBar/index.vue.d.ts +29 -0
  4. package/dist/ComponentTree/components/List.vue.d.ts +29 -0
  5. package/dist/ComponentTree/index.vue.d.ts +32 -0
  6. package/dist/DataSource/index.vue.d.ts +34 -0
  7. package/dist/HeaderBar/components/BarTooltip.vue.d.ts +37 -0
  8. package/dist/HeaderBar/index.vue.d.ts +49 -0
  9. package/dist/NavTree/index.vue.d.ts +48 -0
  10. package/dist/SchemaConfig/index.vue.d.ts +36 -0
  11. package/dist/SidebarPane/index.vue.d.ts +38 -0
  12. package/dist/components/ComponentTreeFavorites/components/List.vue.d.ts +41 -0
  13. package/dist/components/ComponentTreeFavorites/components/Tips.vue.d.ts +16 -0
  14. package/dist/components/ComponentTreeFavorites/index.vue.d.ts +44 -0
  15. package/dist/components/ImageGuide/index.vue.d.ts +45 -0
  16. package/dist/components.d.ts +7 -0
  17. package/dist/composables/useComponentTree.d.ts +13 -0
  18. package/dist/config/ace.config.d.ts +3 -0
  19. package/dist/domain/EditorDomain.d.ts +89 -0
  20. package/dist/editor.d.ts +286 -0
  21. package/dist/editor.vue.d.ts +104 -0
  22. package/dist/formily/ActivityBar/index.d.ts +4 -0
  23. package/dist/formily/ComponentTree/index.d.ts +4 -0
  24. package/dist/formily/DataBinding/index.d.ts +4 -0
  25. package/dist/formily/DataBinding/index.vue.d.ts +26 -0
  26. package/dist/formily/DataSource/index.d.ts +4 -0
  27. package/dist/formily/MenuTable/PageList.vue.d.ts +28 -0
  28. package/dist/formily/MenuTable/index.d.ts +4 -0
  29. package/dist/formily/MenuTable/index.vue.d.ts +30 -0
  30. package/dist/formily/MenuTable/useMenuTable.d.ts +227 -0
  31. package/dist/formily/NavTree/index.d.ts +4 -0
  32. package/dist/formily/SidebarPane/index.d.ts +4 -0
  33. package/dist/formily/index.d.ts +2 -0
  34. package/dist/index.css +1167 -0
  35. package/dist/index.d.ts +250 -0
  36. package/dist/index.js +34171 -0
  37. package/dist/utils/base64.d.ts +4 -0
  38. package/dist/utils/index.d.ts +27 -0
  39. package/package.json +58 -4
  40. package/rollup.config.js +3 -0
  41. package/src/ActivityBar/index.vue +71 -0
  42. package/src/ComponentTree/components/List.vue +310 -0
  43. package/src/ComponentTree/index.vue +77 -0
  44. package/src/DataSource/index.vue +640 -0
  45. package/src/HeaderBar/components/BarDialog.vue +43 -0
  46. package/src/HeaderBar/components/BarTooltip.vue +33 -0
  47. package/src/HeaderBar/index.vue +513 -0
  48. package/src/NavTree/index.vue +345 -0
  49. package/src/SchemaConfig/index.vue +150 -0
  50. package/src/SidebarPane/index.vue +199 -0
  51. package/src/SynBarComponent/index.vue +31 -0
  52. package/src/assets/font/NotoSansSC.ttf +0 -0
  53. package/src/assets/img/header/edit.png +0 -0
  54. package/src/assets/img/header/link.png +0 -0
  55. package/src/assets/img/header/link.svg +9 -0
  56. package/src/assets/img/header/preview.png +0 -0
  57. package/src/assets/img/header/preview.svg +9 -0
  58. package/src/assets/img/header/redo.svg +1 -0
  59. package/src/assets/img/header/undo.svg +1 -0
  60. package/src/assets/img/tool/all-select.svg +9 -0
  61. package/src/assets/img/tool/all.svg +9 -0
  62. package/src/assets/img/tool/collect.svg +6 -0
  63. package/src/assets/img/tool/collection-select.svg +3 -0
  64. package/src/assets/img/tool/collection-tag.svg +5 -0
  65. package/src/assets/img/tool/info.svg +4 -0
  66. package/src/assets/img/tool/union.svg +4 -0
  67. package/src/components/ComponentTreeFavorites/components/List.vue +452 -0
  68. package/src/components/ComponentTreeFavorites/components/Tips.vue +108 -0
  69. package/src/components/ComponentTreeFavorites/index.vue +180 -0
  70. package/src/components/ImageGuide/index.vue +100 -0
  71. package/src/components.ts +23 -0
  72. package/src/composables/useComponentTree.ts +38 -0
  73. package/src/config/ace.config.ts +22 -0
  74. package/src/domain/EditorDomain.ts +265 -0
  75. package/src/editor.ts +645 -0
  76. package/src/editor.vue +380 -0
  77. package/src/formily/ActivityBar/index.ts +23 -0
  78. package/src/formily/ActivityBar/index.vue +121 -0
  79. package/src/formily/ComponentTree/index.ts +22 -0
  80. package/src/formily/DataBinding/index.ts +22 -0
  81. package/src/formily/DataBinding/index.vue +285 -0
  82. package/src/formily/DataSource/index.ts +22 -0
  83. package/src/formily/MenuTable/PageList.vue +132 -0
  84. package/src/formily/MenuTable/index.ts +19 -0
  85. package/src/formily/MenuTable/index.vue +218 -0
  86. package/src/formily/MenuTable/useMenuTable.ts +147 -0
  87. package/src/formily/NavTree/index.ts +20 -0
  88. package/src/formily/SidebarPane/index.ts +23 -0
  89. package/src/formily/SidebarPane/index.vue +174 -0
  90. package/src/formily/index.ts +12 -0
  91. package/src/index.ts +29 -0
  92. package/src/typings/vue-shim.d.ts +13 -0
  93. package/src/utils/base64.ts +5 -0
  94. package/src/utils/index.ts +57 -0
  95. package/test/case.ts +67 -0
  96. package/test/utils/index.test.ts +27 -0
  97. package/tsconfig.json +8 -0
@@ -0,0 +1,108 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue';
3
+
4
+ const props = defineProps({
5
+ tipsInfo: {
6
+ type: Object,
7
+ default: () => ({}),
8
+ },
9
+ });
10
+
11
+ const guideConfig = computed(() => {
12
+ return props.tipsInfo?.guideConfig || {};
13
+ });
14
+
15
+ const skill = computed(() => {
16
+ return Array.isArray(guideConfig.value?.skill)
17
+ ? guideConfig.value?.skill
18
+ : [guideConfig.value?.skill];
19
+ });
20
+ </script>
21
+
22
+ <template>
23
+ <div class="component-tips">
24
+ <el-dialog v-bind="$attrs" :title="tipsInfo?.title">
25
+ <div class="component-tips--content">
26
+ <div class="component-tips--content__left">
27
+ <div>
28
+ <h1>组件说明:</h1>
29
+ <p>
30
+ {{ guideConfig?.explain || '' }}
31
+ </p>
32
+ </div>
33
+ <div style="margin-top: 50px">
34
+ <h1 style="">配置技巧:</h1>
35
+ <p
36
+ style="padding: 0; margin: 0"
37
+ v-for="item in skill"
38
+ :key="item"
39
+ >
40
+ {{ item || '' }}
41
+ </p>
42
+ </div>
43
+ </div>
44
+ <div class="component-tips--content__right">
45
+ <h1>组件配置效果示例</h1>
46
+ <img :src="guideConfig?.sampleUrl" alt="" />
47
+ </div>
48
+ </div>
49
+ </el-dialog>
50
+ </div>
51
+ </template>
52
+
53
+ <style scoped lang="scss">
54
+ .component-tips {
55
+ ::v-deep .el-dialog__body {
56
+ padding: 30px;
57
+ }
58
+ ::v-deep .el-dialog__title {
59
+ color: #1a1a1a;
60
+ font-size: 18px;
61
+ font-weight: 500;
62
+ line-height: 24px;
63
+ }
64
+ ::v-deep .el-dialog {
65
+ border-radius: 10px;
66
+ }
67
+ ::v-deep .el-dialog__header {
68
+ border-bottom: 1px solid #e6e6e6;
69
+ padding: 30px 0 16px 0;
70
+ margin: 0 30px;
71
+
72
+ .el-icon {
73
+ font-size: 24px;
74
+ color: #1c212d;
75
+ }
76
+ }
77
+ h1 {
78
+ color: #1a1a1a;
79
+ font-size: 16px;
80
+ font-weight: 500;
81
+ line-height: 24px;
82
+ margin-bottom: 10px;
83
+ }
84
+ &--content {
85
+ display: flex;
86
+ &__left {
87
+ flex-grow: 1;
88
+ p {
89
+ color: #1a1a1a;
90
+ font-size: 14px;
91
+ font-weight: 400;
92
+ line-height: 24px;
93
+ }
94
+ }
95
+ &__right {
96
+ display: flex;
97
+ flex-direction: column;
98
+ min-width: 270px;
99
+ max-width: 270px;
100
+ margin-left: 80px;
101
+ img {
102
+ width: 100%;
103
+ margin-top: 15px;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ </style>
@@ -0,0 +1,180 @@
1
+ <script lang="ts" setup>
2
+ import {
3
+ ref,
4
+ defineProps,
5
+ withDefaults,
6
+ defineEmits,
7
+ computed,
8
+ watch,
9
+ } from 'vue';
10
+ import { Search } from '@jt/icons-vue';
11
+ import List from './components/List.vue';
12
+ import { ComponentTreeData, LowCodeKey } from '@jt/low-code-core';
13
+ import AllIcon from '../../assets/img/tool/all.svg';
14
+ import AllSelectIcon from '../../assets/img/tool/all-select.svg';
15
+ import collectionIcon from '../../assets/img/tool/collection-tag.svg';
16
+ import collectionSelectIcon from '../../assets/img/tool/collection-select.svg';
17
+ import { favoriteRebuild } from '../../utils';
18
+ import { cloneDeep } from '@jt/ark-util';
19
+
20
+ import useComponentTree from '../../composables/useComponentTree';
21
+
22
+ // 如果直接传对象,会频繁更新DOM,这里传JSON会好很多。在vue内部判断是否需要更新是用:
23
+ // nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)
24
+ const props = withDefaults(
25
+ defineProps<{
26
+ componentTreeData?: {
27
+ key: LowCodeKey;
28
+ value: ComponentTreeData;
29
+ };
30
+ readOnly?: boolean;
31
+ favorites?: any[];
32
+ }>(),
33
+ {
34
+ componentTreeData: null,
35
+ readOnly: false,
36
+ favorites: [] as any,
37
+ }
38
+ );
39
+
40
+ const emits = defineEmits(['addItem', 'dragEnd', 'collect']);
41
+
42
+ const { onClickItem, onDragEnd, rebuild, listRef, keyword } = useComponentTree(
43
+ props,
44
+ emits
45
+ );
46
+
47
+ // 当前显示的可选择的组件
48
+ const activeComponentTree = computed(() => {
49
+ if (!props.componentTreeData) return [];
50
+ const componentTreeData = cloneDeep(props.componentTreeData.value);
51
+ if (typeValue.value === 1) {
52
+ return keyword.value
53
+ ? rebuild(componentTreeData, keyword.value)
54
+ : componentTreeData;
55
+ } else {
56
+ // 先过滤收藏 再过滤搜索筛选
57
+ return keyword.value
58
+ ? rebuild(
59
+ favoriteRebuild(componentTreeData, props.favorites),
60
+ keyword.value
61
+ )
62
+ : favoriteRebuild(componentTreeData, props.favorites);
63
+ }
64
+ });
65
+
66
+ const onCollect = async data => {
67
+ emits('collect', data);
68
+ };
69
+ // 收藏/全部分类
70
+ const typeValue = ref<number>(1);
71
+ </script>
72
+ <template>
73
+ <div class="component-tree-v2">
74
+ <div class="component-tree-v2__title">
75
+ <div class="text_info">组件库</div>
76
+ <el-input placeholder="请输入" v-model="keyword" :prefix-icon="Search" />
77
+ </div>
78
+
79
+ <div class="component-tree-v2__classify">
80
+ <div
81
+ class="classify_item"
82
+ :class="{ active: typeValue === 1 }"
83
+ @click="typeValue = 1"
84
+ >
85
+ <img :src="typeValue === 1 ? AllSelectIcon : AllIcon" />
86
+ 全部组件
87
+ </div>
88
+ <div
89
+ class="classify_item"
90
+ :class="{ active: typeValue === 2 }"
91
+ @click="typeValue = 2"
92
+ >
93
+ <img :src="typeValue === 2 ? collectionSelectIcon : collectionIcon" />
94
+ 我的收藏
95
+ </div>
96
+ <div
97
+ class="action"
98
+ :style="{ left: typeValue === 1 ? '0%' : '50%' }"
99
+ ></div>
100
+ </div>
101
+ <List
102
+ :componentTree="activeComponentTree"
103
+ :readOnly="readOnly"
104
+ @click-item="onClickItem"
105
+ @drag-end="onDragEnd"
106
+ ref="listRef"
107
+ @collect="onCollect"
108
+ :favorites="favorites"
109
+ />
110
+ </div>
111
+ </template>
112
+
113
+ <style scoped lang="scss">
114
+ .component-tree-v2 {
115
+ box-sizing: border-box;
116
+ padding: 20px;
117
+ flex-shrink: 1;
118
+ position: relative;
119
+ height: 100%;
120
+ display: flex;
121
+ flex-direction: column;
122
+ background: #fff;
123
+ &__title {
124
+ display: flex;
125
+ align-items: center;
126
+ .text_info {
127
+ min-width: 54px;
128
+ font-size: 18px;
129
+ font-weight: 500;
130
+ color: #282f40;
131
+ line-height: 24px;
132
+ display: inline-flex;
133
+ margin-right: 15px;
134
+ }
135
+ }
136
+
137
+ &__classify {
138
+ margin-top: 12px;
139
+ height: 48px;
140
+ // width: 440px;
141
+ border-radius: 6px;
142
+ background: #e6e6e6;
143
+ display: flex;
144
+ align-items: center;
145
+ position: relative;
146
+
147
+ .classify_item {
148
+ flex: 1;
149
+ color: #828690;
150
+ font-size: 16px;
151
+ line-height: 24px;
152
+ display: flex;
153
+ justify-content: center;
154
+ align-items: center;
155
+ cursor: pointer;
156
+ position: relative;
157
+ z-index: 3;
158
+ img {
159
+ margin-right: 4px;
160
+ }
161
+
162
+ &.active {
163
+ font-weight: 700;
164
+ color: #c79156;
165
+ }
166
+ }
167
+
168
+ .action {
169
+ z-index: 2;
170
+ position: absolute;
171
+ width: calc(50% - 10px);
172
+ height: 38px;
173
+ border-radius: 4px;
174
+ background: #fff;
175
+ transition: all 0.3s;
176
+ margin-left: 5px;
177
+ }
178
+ }
179
+ }
180
+ </style>
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <div class="guide-dialog">
3
+ <el-dialog
4
+ custom-class="guide-dialog"
5
+ append-to-body
6
+ @close="closeDialog"
7
+ :title="title"
8
+ :width="width"
9
+ :modelValue="modelValue"
10
+ >
11
+ <!-- 导出2倍图教程 -->
12
+ <div class="image-export-guide">
13
+ <div
14
+ v-for="(item, index) in content"
15
+ :key="index"
16
+ class="image-export-guide--item"
17
+ >
18
+ <p>{{ item.title }}</p>
19
+ <div class="image-group">
20
+ <el-image
21
+ v-for="img in item.imgs"
22
+ :key="img.url"
23
+ :preview-src-list="[]"
24
+ :src="img.url"
25
+ :style="img.style"
26
+ fit="scale-down"
27
+ ></el-image>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </el-dialog>
32
+ </div>
33
+ </template>
34
+
35
+ <script lang="ts">
36
+ import { defineComponent } from "vue";
37
+ export default defineComponent({
38
+ props: {
39
+ modelValue: {
40
+ type: Boolean,
41
+ default: true,
42
+ },
43
+ content: {
44
+ type: Array,
45
+ default: () => {
46
+ return [];
47
+ },
48
+ },
49
+ title: {
50
+ type: String,
51
+ default: "",
52
+ },
53
+ width: {
54
+ type: Number,
55
+ default: 520,
56
+ },
57
+ },
58
+ emits: ["update:modelValue"],
59
+ setup(props, { emit }) {
60
+ const closeDialog = () => {
61
+ emit("update:modelValue", false);
62
+ };
63
+ return { closeDialog };
64
+ },
65
+ });
66
+ </script>
67
+
68
+ <style lang="scss">
69
+ .guide-dialog {
70
+ .el-dialog__body {
71
+ padding: 32px;
72
+ overflow-y: scroll;
73
+ }
74
+ .image-export-guide {
75
+ box-sizing: border-box;
76
+ padding: 16px 137px 24px 22px;
77
+ background: #f3f3f3;
78
+ &--item {
79
+ margin-bottom: 22px;
80
+ p {
81
+ font-style: normal;
82
+ font-weight: 400;
83
+ font-size: 14px;
84
+ line-height: 24px;
85
+ /* identical to box height, or 171% */
86
+
87
+ display: flex;
88
+ align-items: center;
89
+
90
+ color: #000000;
91
+ margin-bottom: 12px;
92
+ }
93
+ }
94
+ .image-group {
95
+ display: flex;
96
+ justify-content: space-around;
97
+ }
98
+ }
99
+ }
100
+ </style>
@@ -0,0 +1,23 @@
1
+ import ComponentTree from './ComponentTree/index.vue';
2
+ import NavTree from './NavTree/index.vue';
3
+ import DataSource from './DataSource/index.vue';
4
+
5
+ const editorComponents = {
6
+ ComponentTree,
7
+ NavTree,
8
+ DataSource,
9
+ push(components) {
10
+ if(components) {
11
+ for(const name in components) {
12
+ if(!components.hasOwnProperty(name)) continue;
13
+ if(this[name]) {
14
+ console.warn(`${name}组件已经存在editorComponents`);
15
+ continue;
16
+ }
17
+ this[name] = components[name];
18
+ }
19
+ }
20
+ }
21
+ };
22
+
23
+ export { editorComponents };
@@ -0,0 +1,38 @@
1
+ import PinyinMatch from 'pinyin-match';
2
+ import { ref } from 'vue';
3
+ export default function (props, emits) {
4
+ const listRef = ref();
5
+
6
+ const keyword = ref('');
7
+
8
+
9
+ /* 拖拽组件 */
10
+ const onDragEnd = ({ key, value }, isCors) => {
11
+ emits('dragEnd', { key, value }, isCors);
12
+ };
13
+ /* 点击组件 */
14
+ const onClickItem = ({ key, value }) => {
15
+ emits('addItem', { key, value });
16
+ };
17
+ // 过滤组件库
18
+ const rebuild = (tree, keyword) => {
19
+ if (!tree) return [];
20
+ const newTree = [];
21
+ tree.forEach(item => {
22
+ if (PinyinMatch.match(item.title, keyword)) {
23
+ // 搜到分类展示分类下所有组件
24
+ newTree.push({ ...item, list: item.list });
25
+ } else {
26
+ if (item.list && item.list.length > 0) {
27
+ const list = rebuild(item.list, keyword);
28
+ if (list && list.length > 0) {
29
+ newTree.push({ ...item, list });
30
+ }
31
+ }
32
+ }
33
+ });
34
+ return newTree;
35
+ };
36
+
37
+ return { onDragEnd, onClickItem, rebuild, listRef, keyword }
38
+ }
@@ -0,0 +1,22 @@
1
+ import ace from 'ace-builds';
2
+
3
+ import modeJsonUrl from 'ace-builds/src-noconflict/mode-json';
4
+ ace.config.setModuleUrl('ace/mode/json', modeJsonUrl);
5
+
6
+ import modeTypescriptUrl from 'ace-builds/src-noconflict/mode-typescript';
7
+ ace.config.setModuleUrl('ace/mode/typescript', modeTypescriptUrl);
8
+
9
+ import modeMarkdownUrl from 'ace-builds/src-noconflict/mode-markdown';
10
+ ace.config.setModuleUrl('ace/mode/markdown', modeMarkdownUrl);
11
+
12
+ import themeChromeUrl from 'ace-builds/src-noconflict/theme-chrome';
13
+ ace.config.setModuleUrl('ace/theme/chrome', themeChromeUrl);
14
+
15
+ import 'ace-builds/src-noconflict/ext-language_tools';
16
+ ace.require('ace/ext/language_tools');
17
+
18
+ import 'ace-builds/src-noconflict/ext-beautify';
19
+ ace.require('ace/ext/beautify');
20
+
21
+ import 'ace-builds/src-noconflict/ext-emmet';
22
+ ace.require('ace/ext/emmet');