@dckj-npm/dc-material 0.1.278 → 0.1.280

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.
@@ -0,0 +1,221 @@
1
+
2
+ import { IPublicTypeComponentMetadata, IPublicTypeSnippet } from '@alilc/lowcode-types';
3
+
4
+ const CustomDrawerMeta: IPublicTypeComponentMetadata = {
5
+ "componentName": "CustomDrawer",
6
+ "title": "CustomDrawer",
7
+ "docUrl": "",
8
+ "screenshot": "",
9
+ "devMode": "proCode",
10
+ "npm": {
11
+ "package": "@dckj-npm/dc-material",
12
+ "version": "0.1.279",
13
+ "exportName": "CustomDrawer",
14
+ "main": "src\\index.tsx",
15
+ "destructuring": true,
16
+ "subName": ""
17
+ },
18
+ "configure": {
19
+ "props": [
20
+ {
21
+ "title": {
22
+ "label": {
23
+ "type": "i18n",
24
+ "en-US": "title",
25
+ "zh-CN": "标题"
26
+ },
27
+ "tip": "title | 标题"
28
+ },
29
+ "name": "title",
30
+ "description": "标题",
31
+ "setter": {
32
+ "componentName": "StringSetter",
33
+ "isRequired": true,
34
+ "initialValue": ""
35
+ }
36
+ },
37
+ {
38
+ "title": {
39
+ "label": {
40
+ "type": "i18n",
41
+ "en-US": "placement",
42
+ "zh-CN": "弹出位置"
43
+ },
44
+ "tip": "placement | 弹出位置"
45
+ },
46
+ "name": "placement",
47
+ "description": "弹出位置",
48
+ "setter": {
49
+ "componentName": "SelectSetter",
50
+ "props": {
51
+ "dataSource": [
52
+ {
53
+ "label": "left",
54
+ "value": "left"
55
+ },
56
+ {
57
+ "label": "right",
58
+ "value": "right"
59
+ },
60
+ {
61
+ "label": "top",
62
+ "value": "top"
63
+ },
64
+ {
65
+ "label": "bottom",
66
+ "value": "bottom"
67
+ }
68
+ ],
69
+ "options": [
70
+ {
71
+ "label": "left",
72
+ "value": "left"
73
+ },
74
+ {
75
+ "label": "right",
76
+ "value": "right"
77
+ },
78
+ {
79
+ "label": "top",
80
+ "value": "top"
81
+ },
82
+ {
83
+ "label": "bottom",
84
+ "value": "bottom"
85
+ }
86
+ ]
87
+ },
88
+ "isRequired": true,
89
+ "initialValue": "left"
90
+ }
91
+ },
92
+ {
93
+ "title": {
94
+ "label": {
95
+ "type": "i18n",
96
+ "en-US": "actions",
97
+ "zh-CN": "操作项"
98
+ },
99
+ "tip": "actions | 操作项"
100
+ },
101
+ "name": "actions",
102
+ "description": "操作项",
103
+ "setter": {
104
+ "componentName": "ArraySetter",
105
+ "props": {
106
+ "itemSetter": {
107
+ "componentName": "ObjectSetter",
108
+ "props": {
109
+ "config": {
110
+ "items": [
111
+ {
112
+ "title": {
113
+ "label": {
114
+ "type": "i18n",
115
+ "en-US": "text",
116
+ "zh-CN": "text"
117
+ }
118
+ },
119
+ "name": "text",
120
+ "setter": {
121
+ "componentName": "StringSetter",
122
+ "isRequired": true,
123
+ "initialValue": ""
124
+ }
125
+ },
126
+ {
127
+ "title": {
128
+ "label": {
129
+ "type": "i18n",
130
+ "en-US": "action",
131
+ "zh-CN": "action"
132
+ }
133
+ },
134
+ "name": "action",
135
+ "setter": {
136
+ "componentName": "StringSetter",
137
+ "isRequired": true,
138
+ "initialValue": ""
139
+ }
140
+ },
141
+ {
142
+ "title": {
143
+ "label": {
144
+ "type": "i18n",
145
+ "en-US": "style",
146
+ "zh-CN": "style"
147
+ }
148
+ },
149
+ "name": "style",
150
+ "setter": {
151
+ "componentName": "RadioGroupSetter",
152
+ "props": {
153
+ "dataSource": [
154
+ {
155
+ "label": "primary",
156
+ "value": "primary"
157
+ },
158
+ {
159
+ "label": "secondary",
160
+ "value": "secondary"
161
+ },
162
+ {
163
+ "label": "normal",
164
+ "value": "normal"
165
+ }
166
+ ],
167
+ "options": [
168
+ {
169
+ "label": "primary",
170
+ "value": "primary"
171
+ },
172
+ {
173
+ "label": "secondary",
174
+ "value": "secondary"
175
+ },
176
+ {
177
+ "label": "normal",
178
+ "value": "normal"
179
+ }
180
+ ]
181
+ },
182
+ "isRequired": true,
183
+ "initialValue": "primary"
184
+ }
185
+ }
186
+ ],
187
+ "extraSetter": {
188
+ "componentName": "MixedSetter",
189
+ "isRequired": false,
190
+ "props": {}
191
+ }
192
+ }
193
+ }
194
+ }
195
+ },
196
+ "isRequired": true,
197
+ "initialValue": []
198
+ }
199
+ }
200
+ ],
201
+ "supports": {
202
+ "style": true
203
+ },
204
+ "component": {}
205
+ }
206
+ };
207
+ const snippets: IPublicTypeSnippet[] = [
208
+ {
209
+ "title": "CustomDrawer",
210
+ "screenshot": "",
211
+ "schema": {
212
+ "componentName": "CustomDrawer",
213
+ "props": {}
214
+ }
215
+ }
216
+ ];
217
+
218
+ export default {
219
+ ...CustomDrawerMeta,
220
+ snippets
221
+ };
@@ -53,6 +53,7 @@ const CustomDrawerMeta: IPublicTypeComponentMetadata = {
53
53
  { label: '下', value: 'bottom' },
54
54
  ],
55
55
  },
56
+ initialValue: 'left',
56
57
  },
57
58
  },
58
59
  {
@@ -126,12 +127,164 @@ const CustomDrawerMeta: IPublicTypeComponentMetadata = {
126
127
  isContainer: true,
127
128
  isModal: true,
128
129
  disableBehaviors: ['copy'],
130
+ rootSelector: '.next-drawer',
129
131
  nestingRule: {
130
132
  parentWhitelist: (testNode, currentNode) => {
131
133
  return testNode.componentName === 'Page'
132
134
  },
133
135
  },
134
136
  },
137
+ advanced: {
138
+ callbacks: {
139
+ // 与 next-page 的 onNodeAdd 一模一样
140
+ onNodeAdd: (dragment, currentNode) => {
141
+ // 拖入的组件为 P、Block、Slot(把NextPage拖入到面板里时,NextPage的Slot也会触发onNodeAdd事件) 时,不进行包裹
142
+ // 拖入的组件 isModal为true时(例如drawer dialog 这类有单独组件树结构的),不进行包裹
143
+ if (
144
+ !dragment ||
145
+ ['NextP', 'NextBlock', 'Slot'].includes(dragment.componentName) ||
146
+ (dragment.componentMeta.isModal && dragment.componentMeta.isModal())
147
+ ) {
148
+ console.log(
149
+ `[${dragment.componentName}] doesn\'n need to wrap with NextBlock > NextBlockCell`,
150
+ )
151
+ return
152
+ }
153
+
154
+ const NextPProps = {
155
+ wrap: false,
156
+ type: 'body2',
157
+ verAlign: 'middle',
158
+ textSpacing: true,
159
+ align: 'left',
160
+ }
161
+
162
+ if (
163
+ [
164
+ 'Form',
165
+ 'ResponsiveGrid',
166
+ 'Box',
167
+ 'Card',
168
+ 'List',
169
+ 'Message',
170
+ 'Slider',
171
+ 'NextTable',
172
+ ].includes(dragment.componentName) ||
173
+ dragment.getPropValue('isFillContainer')
174
+ ) {
175
+ NextPProps.full = true
176
+ }
177
+ const layoutPSchema = {
178
+ componentName: 'NextP',
179
+ title: '段落',
180
+ props: NextPProps,
181
+ children: [dragment.exportSchema()],
182
+ }
183
+
184
+ // 为目标元素包裹一层 Block
185
+ const layoutBlockNode = (len) =>
186
+ currentNode.document.createNode({
187
+ componentName: 'NextBlock',
188
+ title: '区块',
189
+ props: {
190
+ childTotalColumns: len || 12,
191
+ },
192
+ children: [
193
+ {
194
+ componentName: 'NextBlockCell',
195
+ title: '子区块',
196
+ props: {
197
+ isAutoContainer: true,
198
+ colSpan: 12,
199
+ rowSpan: 1,
200
+ },
201
+ children: [layoutPSchema],
202
+ },
203
+ ],
204
+ })
205
+
206
+ const dropLocation = dragment.document.canvas.dropLocation
207
+
208
+ if (!dropLocation) {
209
+ // 没有 dropLocation 一般是 slot, slot 元素不用特殊处理 不做任何包裹
210
+ return
211
+ }
212
+ const dropTarget = dropLocation.target
213
+ const dropTargetName = dropLocation.target.componentName || ''
214
+
215
+ // 找到要拖入进去的节点 ID
216
+ const targetId = (dropLocation && dropLocation.target.id) || ''
217
+ // 找到要拖入进去的节点
218
+ let slotTarget =
219
+ currentNode.slots.length > 0 && currentNode.slots.find((item) => item.id === targetId)
220
+
221
+ const layoutPNode = currentNode.document.createNode(layoutPSchema)
222
+
223
+ // 是否为 aside slot
224
+ const isAsideSlot = slotTarget && ['aside'].indexOf(slotTarget._slotFor.key) > -1
225
+ // 是否为需要被 P 包裹的 Slot
226
+ const isNeedPSlot =
227
+ slotTarget && ['header', 'footer', 'nav'].indexOf(slotTarget._slotFor.key) > -1
228
+
229
+ const wrapWithBlock = (dragment, node, dropTargetName, blockLen) => {
230
+ setTimeout(() => {
231
+ console.log(
232
+ `[${dragment.componentName}] to [${dropTargetName}] need to wrap with NextBlock > NextBlockCell > NextP [from NextPage2]`,
233
+ )
234
+ const newNode = node.document.createNode(layoutBlockNode(blockLen).exportSchema())
235
+ node.insertBefore(newNode, dragment, false)
236
+ dragment.remove(false)
237
+ newNode.children.get(0).children.get(0).children.get(0).select()
238
+ }, 1)
239
+ }
240
+
241
+ const wrapWithP = (dragment, node, dropTargetName) => {
242
+ setTimeout(() => {
243
+ // const dragmentTarget = dropTarget;
244
+ // 要拖入的地方如果是 NextP 那就 不再自动包裹 P了
245
+ if (dropTargetName === 'NextP') {
246
+ console.log(
247
+ `[${dragment.componentName}] to [${dropTargetName}] does't need to wrap with NextP. [from NextPage3]`,
248
+ )
249
+ return
250
+ }
251
+
252
+ console.log(
253
+ `[${dragment.componentName}] to [${dropTargetName}] need to wrap with NextP [from NextPage3]`,
254
+ )
255
+ const newNode = node.document.createNode(Object.assign(layoutPNode.exportSchema()))
256
+ node.insertBefore(newNode, dragment, false)
257
+ dragment.remove(false)
258
+ newNode.children.get(0).select()
259
+ }, 1)
260
+ }
261
+
262
+ // 需要包裹 Block BlockCell P 的情况:
263
+ // 1. 组件拖入到 NextPage,的直接子元素下(不包括slot), 此时Block宽度为12
264
+ if (['NextPage'].includes(dropTargetName) && currentNode.children.has(dragment)) {
265
+ wrapWithBlock(dragment, currentNode, dropTargetName, 12)
266
+
267
+ // 需要包裹 Block BlockCell P 的情况:
268
+ // 2. 组件拖入到 NextPage 的 aside slot, 的直接子元素下 (不包括slot下的进一步内容),此时Block宽度为1
269
+ } else if (isAsideSlot && slotTarget && slotTarget.children.has(dragment)) {
270
+ wrapWithBlock(dragment, slotTarget, dropTargetName, 1)
271
+
272
+ // 需要包裹 P 的情况:
273
+ // 1. 如果是处于,开启了自然布局模式的容器组件中 (或者Tab里)
274
+ // 这里的Tab主要是给纪元epoch使用的,因为他们用到了 @ali/vc-deep 的TabLayout组件,没办法在这个组件上再增加属性 isAutoContainer
275
+ } else if (dropTarget.getPropValue('isAutoContainer') || dropTargetName === 'Tab.Item') {
276
+ wrapWithP(dragment, dropTarget, dropTargetName)
277
+
278
+ // 需要包裹 P 的情况:
279
+ // 2. 如果是处于,Page 的 nav header footer 中
280
+ } else if (isNeedPSlot && slotTarget) {
281
+ wrapWithP(dragment, slotTarget, dropTargetName)
282
+ }
283
+
284
+ // 其他维持原状,不进行其他设置
285
+ },
286
+ },
287
+ },
135
288
  },
136
289
  }
137
290
 
@@ -0,0 +1,22 @@
1
+ import { IPublicTypeSnippet } from '@alilc/lowcode-types';
2
+ declare const _default: {
3
+ snippets: IPublicTypeSnippet[];
4
+ componentName: string;
5
+ uri?: string;
6
+ title?: import("@alilc/lowcode-types").IPublicTypeTitleContent;
7
+ icon?: import("@alilc/lowcode-types").IPublicTypeIconType;
8
+ tags?: string[];
9
+ description?: string;
10
+ docUrl?: string;
11
+ screenshot?: string;
12
+ devMode?: "proCode" | "lowCode";
13
+ npm?: import("@alilc/lowcode-types").IPublicTypeNpmInfo;
14
+ props?: import("@alilc/lowcode-types").IPublicTypePropConfig[];
15
+ configure?: import("@alilc/lowcode-types").IPublicTypeFieldConfig[] | import("@alilc/lowcode-types").IPublicTypeConfigure;
16
+ experimental?: import("@alilc/lowcode-types").IPublicTypeAdvanced;
17
+ schema?: import("@alilc/lowcode-types").IPublicTypeComponentSchema;
18
+ group?: string | import("@alilc/lowcode-types").IPublicTypeI18nData;
19
+ category?: string | import("@alilc/lowcode-types").IPublicTypeI18nData;
20
+ priority?: number;
21
+ };
22
+ export default _default;
@@ -0,0 +1,189 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ var CustomDrawerMeta = {
3
+ "componentName": "CustomDrawer",
4
+ "title": "CustomDrawer",
5
+ "docUrl": "",
6
+ "screenshot": "",
7
+ "devMode": "proCode",
8
+ "npm": {
9
+ "package": "@dckj-npm/dc-material",
10
+ "version": "0.1.279",
11
+ "exportName": "CustomDrawer",
12
+ "main": "src\\index.tsx",
13
+ "destructuring": true,
14
+ "subName": ""
15
+ },
16
+ "configure": {
17
+ "props": [{
18
+ "title": {
19
+ "label": {
20
+ "type": "i18n",
21
+ "en-US": "title",
22
+ "zh-CN": "标题"
23
+ },
24
+ "tip": "title | 标题"
25
+ },
26
+ "name": "title",
27
+ "description": "标题",
28
+ "setter": {
29
+ "componentName": "StringSetter",
30
+ "isRequired": true,
31
+ "initialValue": ""
32
+ }
33
+ }, {
34
+ "title": {
35
+ "label": {
36
+ "type": "i18n",
37
+ "en-US": "placement",
38
+ "zh-CN": "弹出位置"
39
+ },
40
+ "tip": "placement | 弹出位置"
41
+ },
42
+ "name": "placement",
43
+ "description": "弹出位置",
44
+ "setter": {
45
+ "componentName": "SelectSetter",
46
+ "props": {
47
+ "dataSource": [{
48
+ "label": "left",
49
+ "value": "left"
50
+ }, {
51
+ "label": "right",
52
+ "value": "right"
53
+ }, {
54
+ "label": "top",
55
+ "value": "top"
56
+ }, {
57
+ "label": "bottom",
58
+ "value": "bottom"
59
+ }],
60
+ "options": [{
61
+ "label": "left",
62
+ "value": "left"
63
+ }, {
64
+ "label": "right",
65
+ "value": "right"
66
+ }, {
67
+ "label": "top",
68
+ "value": "top"
69
+ }, {
70
+ "label": "bottom",
71
+ "value": "bottom"
72
+ }]
73
+ },
74
+ "isRequired": true,
75
+ "initialValue": "left"
76
+ }
77
+ }, {
78
+ "title": {
79
+ "label": {
80
+ "type": "i18n",
81
+ "en-US": "actions",
82
+ "zh-CN": "操作项"
83
+ },
84
+ "tip": "actions | 操作项"
85
+ },
86
+ "name": "actions",
87
+ "description": "操作项",
88
+ "setter": {
89
+ "componentName": "ArraySetter",
90
+ "props": {
91
+ "itemSetter": {
92
+ "componentName": "ObjectSetter",
93
+ "props": {
94
+ "config": {
95
+ "items": [{
96
+ "title": {
97
+ "label": {
98
+ "type": "i18n",
99
+ "en-US": "text",
100
+ "zh-CN": "text"
101
+ }
102
+ },
103
+ "name": "text",
104
+ "setter": {
105
+ "componentName": "StringSetter",
106
+ "isRequired": true,
107
+ "initialValue": ""
108
+ }
109
+ }, {
110
+ "title": {
111
+ "label": {
112
+ "type": "i18n",
113
+ "en-US": "action",
114
+ "zh-CN": "action"
115
+ }
116
+ },
117
+ "name": "action",
118
+ "setter": {
119
+ "componentName": "StringSetter",
120
+ "isRequired": true,
121
+ "initialValue": ""
122
+ }
123
+ }, {
124
+ "title": {
125
+ "label": {
126
+ "type": "i18n",
127
+ "en-US": "style",
128
+ "zh-CN": "style"
129
+ }
130
+ },
131
+ "name": "style",
132
+ "setter": {
133
+ "componentName": "RadioGroupSetter",
134
+ "props": {
135
+ "dataSource": [{
136
+ "label": "primary",
137
+ "value": "primary"
138
+ }, {
139
+ "label": "secondary",
140
+ "value": "secondary"
141
+ }, {
142
+ "label": "normal",
143
+ "value": "normal"
144
+ }],
145
+ "options": [{
146
+ "label": "primary",
147
+ "value": "primary"
148
+ }, {
149
+ "label": "secondary",
150
+ "value": "secondary"
151
+ }, {
152
+ "label": "normal",
153
+ "value": "normal"
154
+ }]
155
+ },
156
+ "isRequired": true,
157
+ "initialValue": "primary"
158
+ }
159
+ }],
160
+ "extraSetter": {
161
+ "componentName": "MixedSetter",
162
+ "isRequired": false,
163
+ "props": {}
164
+ }
165
+ }
166
+ }
167
+ }
168
+ },
169
+ "isRequired": true,
170
+ "initialValue": []
171
+ }
172
+ }],
173
+ "supports": {
174
+ "style": true
175
+ },
176
+ "component": {}
177
+ }
178
+ };
179
+ var snippets = [{
180
+ "title": "CustomDrawer",
181
+ "screenshot": "",
182
+ "schema": {
183
+ "componentName": "CustomDrawer",
184
+ "props": {}
185
+ }
186
+ }];
187
+ export default _extends({}, CustomDrawerMeta, {
188
+ snippets: snippets
189
+ });