km-card-layout-component-miniprogram 0.1.6 → 0.1.8
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.
- package/example/pages/home/index.js +1 -351
- package/miniprogram_dist/components/card-layout/index.js +25 -188
- package/miniprogram_dist/components/card-layout/index.wxml +17 -9
- package/miniprogram_dist/components/card-layout/index.wxss +11 -8
- package/miniprogram_dist/vendor/km-card-layout-core/bindings.js +74 -0
- package/miniprogram_dist/vendor/km-card-layout-core/data.js +38 -0
- package/miniprogram_dist/vendor/km-card-layout-core/helpers.js +72 -0
- package/miniprogram_dist/vendor/km-card-layout-core/index.js +15 -366
- package/miniprogram_dist/vendor/km-card-layout-core/interface/index.js +1 -0
- package/miniprogram_dist/vendor/km-card-layout-core/layout.js +117 -0
- package/miniprogram_dist/vendor/km-card-layout-core/ops/changeBackground.js +135 -0
- package/miniprogram_dist/vendor/km-card-layout-core/render/builder.js +210 -0
- package/miniprogram_dist/vendor/km-card-layout-core/utils.js +25 -0
- package/package.json +1 -1
- package/script/sync-core.js +10 -2
- package/src/components/card-layout/index.ts +30 -278
- package/src/components/card-layout/index.wxml +17 -9
- package/src/components/card-layout/index.wxss +11 -8
- package/src/vendor/km-card-layout-core/bindings.ts +84 -0
- package/src/vendor/km-card-layout-core/data.ts +38 -0
- package/src/vendor/km-card-layout-core/helpers.ts +76 -0
- package/src/vendor/km-card-layout-core/index.ts +21 -458
- package/src/vendor/km-card-layout-core/interface/data/payload.ts +20 -2
- package/src/vendor/km-card-layout-core/interface/index.ts +1 -0
- package/src/vendor/km-card-layout-core/interface/render.ts +1 -0
- package/src/vendor/km-card-layout-core/layout.ts +129 -0
- package/src/vendor/km-card-layout-core/ops/changeBackground.ts +169 -0
- package/src/vendor/km-card-layout-core/render/builder.ts +288 -0
- package/src/vendor/km-card-layout-core/types.d.ts +97 -8
- package/src/vendor/km-card-layout-core/utils.ts +9 -0
|
@@ -1,356 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
const layouts = [
|
|
4
|
-
{
|
|
5
|
-
"name": "内置布局-左侧头像",
|
|
6
|
-
"width": 343,
|
|
7
|
-
"height": 210,
|
|
8
|
-
"children": [
|
|
9
|
-
{
|
|
10
|
-
"id": "1",
|
|
11
|
-
"key": "name",
|
|
12
|
-
"type": "text",
|
|
13
|
-
"style": {
|
|
14
|
-
"color": "",
|
|
15
|
-
"fontSize": 18,
|
|
16
|
-
"textAlign": "left",
|
|
17
|
-
"fontWeight": "bold",
|
|
18
|
-
"lineHeight": 25
|
|
19
|
-
},
|
|
20
|
-
"layout": {
|
|
21
|
-
"x": 107,
|
|
22
|
-
"y": 23,
|
|
23
|
-
"mode": "absolute",
|
|
24
|
-
"width": 190,
|
|
25
|
-
"height": 25,
|
|
26
|
-
"zIndex": 1
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"id": "2",
|
|
31
|
-
"key": "company",
|
|
32
|
-
"type": "text",
|
|
33
|
-
"style": {
|
|
34
|
-
"color": "",
|
|
35
|
-
"fontSize": 13,
|
|
36
|
-
"textAlign": "left",
|
|
37
|
-
"fontWeight": "normal",
|
|
38
|
-
"lineHeight": 18
|
|
39
|
-
},
|
|
40
|
-
"layout": {
|
|
41
|
-
"x": 107,
|
|
42
|
-
"y": 51,
|
|
43
|
-
"mode": "absolute",
|
|
44
|
-
"width": 190,
|
|
45
|
-
"height": 18,
|
|
46
|
-
"zIndex": 2
|
|
47
|
-
},
|
|
48
|
-
"visible": true
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"id": "3",
|
|
52
|
-
"key": "mobile",
|
|
53
|
-
"icon": {
|
|
54
|
-
"size": 8,
|
|
55
|
-
"style": "dot",
|
|
56
|
-
"enable": true
|
|
57
|
-
},
|
|
58
|
-
"type": "text",
|
|
59
|
-
"style": {
|
|
60
|
-
"color": "",
|
|
61
|
-
"fontSize": 13,
|
|
62
|
-
"textAlign": "left",
|
|
63
|
-
"fontWeight": "normal"
|
|
64
|
-
},
|
|
65
|
-
"layout": {
|
|
66
|
-
"x": 18,
|
|
67
|
-
"y": 131,
|
|
68
|
-
"mode": "absolute",
|
|
69
|
-
"width": 290,
|
|
70
|
-
"height": 14,
|
|
71
|
-
"zIndex": 8
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"id": "4",
|
|
76
|
-
"key": "duty",
|
|
77
|
-
"type": "text",
|
|
78
|
-
"style": {
|
|
79
|
-
"color": "",
|
|
80
|
-
"fontSize": 13,
|
|
81
|
-
"textAlign": "left",
|
|
82
|
-
"fontWeight": "normal",
|
|
83
|
-
"lineHeight": 18
|
|
84
|
-
},
|
|
85
|
-
"layout": {
|
|
86
|
-
"x": 107,
|
|
87
|
-
"y": 72,
|
|
88
|
-
"mode": "absolute",
|
|
89
|
-
"width": 190,
|
|
90
|
-
"height": 18,
|
|
91
|
-
"zIndex": 3
|
|
92
|
-
},
|
|
93
|
-
"visible": true
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"id": "6",
|
|
97
|
-
"key": "image",
|
|
98
|
-
"url": "https://km-1257079185.cos.ap-chengdu.myqcloud.com/local/image/202505/3c6d8cc2b1df2cfad624376ae37d3b9e.png",
|
|
99
|
-
"type": "image",
|
|
100
|
-
"style": {
|
|
101
|
-
"borderColor": "#f6f7fb",
|
|
102
|
-
"borderStyle": "solid",
|
|
103
|
-
"borderWidth": 1,
|
|
104
|
-
"borderRadius": 100
|
|
105
|
-
},
|
|
106
|
-
"layout": {
|
|
107
|
-
"x": 18,
|
|
108
|
-
"y": 16,
|
|
109
|
-
"mode": "absolute",
|
|
110
|
-
"width": 80,
|
|
111
|
-
"height": 80,
|
|
112
|
-
"zIndex": 7
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"id": "5",
|
|
117
|
-
"key": "email",
|
|
118
|
-
"icon": {
|
|
119
|
-
"size": 8,
|
|
120
|
-
"style": "dot",
|
|
121
|
-
"enable": true
|
|
122
|
-
},
|
|
123
|
-
"type": "text",
|
|
124
|
-
"style": {
|
|
125
|
-
"color": "",
|
|
126
|
-
"fontSize": 13,
|
|
127
|
-
"textAlign": "left",
|
|
128
|
-
"fontWeight": "normal"
|
|
129
|
-
},
|
|
130
|
-
"layout": {
|
|
131
|
-
"x": 18,
|
|
132
|
-
"y": 152,
|
|
133
|
-
"mode": "absolute",
|
|
134
|
-
"width": 290,
|
|
135
|
-
"height": 14,
|
|
136
|
-
"zIndex": 9
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"id": "9",
|
|
141
|
-
"key": "address",
|
|
142
|
-
"icon": {
|
|
143
|
-
"size": 8,
|
|
144
|
-
"style": "dot",
|
|
145
|
-
"enable": true
|
|
146
|
-
},
|
|
147
|
-
"type": "text",
|
|
148
|
-
"style": {
|
|
149
|
-
"color": "",
|
|
150
|
-
"fontSize": 13,
|
|
151
|
-
"textAlign": "left",
|
|
152
|
-
"fontWeight": "normal"
|
|
153
|
-
},
|
|
154
|
-
"layout": {
|
|
155
|
-
"x": 18,
|
|
156
|
-
"y": 173,
|
|
157
|
-
"mode": "absolute",
|
|
158
|
-
"width": 290,
|
|
159
|
-
"height": 34,
|
|
160
|
-
"zIndex": 10
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
"id": "repeatable-1764640366125",
|
|
165
|
-
"type": "repeatable-group",
|
|
166
|
-
"items": [
|
|
167
|
-
{
|
|
168
|
-
"id": "item-1764640366125-d4ea",
|
|
169
|
-
"data": {
|
|
170
|
-
"duty": "CEO",
|
|
171
|
-
"company": "合肥魅客网络有限公司"
|
|
172
|
-
},
|
|
173
|
-
"elements": [
|
|
174
|
-
{
|
|
175
|
-
"id": "company-duty-1764640366125-d4ea",
|
|
176
|
-
"type": "text",
|
|
177
|
-
"style": {
|
|
178
|
-
"fontSize": 12,
|
|
179
|
-
"textAlign": "left",
|
|
180
|
-
"fontWeight": "normal",
|
|
181
|
-
"lineHeight": 14
|
|
182
|
-
},
|
|
183
|
-
"layout": {
|
|
184
|
-
"x": 107,
|
|
185
|
-
"y": 52,
|
|
186
|
-
"mode": "absolute",
|
|
187
|
-
"width": 220,
|
|
188
|
-
"height": 14,
|
|
189
|
-
"zIndex": 2
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
]
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
"id": "item-1764640369647-8b58",
|
|
196
|
-
"data": {
|
|
197
|
-
"duty": "副会长",
|
|
198
|
-
"company": "人力资源协会"
|
|
199
|
-
},
|
|
200
|
-
"elements": [
|
|
201
|
-
{
|
|
202
|
-
"id": "company-duty-1764640369647-8b58",
|
|
203
|
-
"type": "text",
|
|
204
|
-
"style": {
|
|
205
|
-
"fontSize": 12,
|
|
206
|
-
"textAlign": "left",
|
|
207
|
-
"fontWeight": "normal",
|
|
208
|
-
"lineHeight": 14
|
|
209
|
-
},
|
|
210
|
-
"layout": {
|
|
211
|
-
"x": 107,
|
|
212
|
-
"y": 67,
|
|
213
|
-
"mode": "absolute",
|
|
214
|
-
"width": 220,
|
|
215
|
-
"height": 14,
|
|
216
|
-
"zIndex": 2
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
]
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
"id": "item-1764640371911-e6ae",
|
|
223
|
-
"data": {
|
|
224
|
-
"duty": "高级顾问",
|
|
225
|
-
"company": "北京博然思维咨询有限公司"
|
|
226
|
-
},
|
|
227
|
-
"elements": [
|
|
228
|
-
{
|
|
229
|
-
"id": "company-duty-1764640371911-e6ae",
|
|
230
|
-
"type": "text",
|
|
231
|
-
"style": {
|
|
232
|
-
"fontSize": 12,
|
|
233
|
-
"textAlign": "left",
|
|
234
|
-
"fontWeight": "normal",
|
|
235
|
-
"lineHeight": 14
|
|
236
|
-
},
|
|
237
|
-
"layout": {
|
|
238
|
-
"x": 107,
|
|
239
|
-
"y": 83,
|
|
240
|
-
"mode": "absolute",
|
|
241
|
-
"width": 220,
|
|
242
|
-
"height": 14,
|
|
243
|
-
"zIndex": 2
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
]
|
|
247
|
-
}
|
|
248
|
-
],
|
|
249
|
-
"layout": {
|
|
250
|
-
"x": 0,
|
|
251
|
-
"y": 0,
|
|
252
|
-
"mode": "absolute",
|
|
253
|
-
"width": 0,
|
|
254
|
-
"height": 0,
|
|
255
|
-
"zIndex": 1
|
|
256
|
-
},
|
|
257
|
-
"visible": false,
|
|
258
|
-
"dataPath": "user.multiCompanyDuty",
|
|
259
|
-
"maxItems": 3,
|
|
260
|
-
"itemTemplate": [
|
|
261
|
-
{
|
|
262
|
-
"id": "company-duty",
|
|
263
|
-
"type": "text",
|
|
264
|
-
"style": {
|
|
265
|
-
"fontSize": 13,
|
|
266
|
-
"textAlign": "left",
|
|
267
|
-
"fontWeight": "normal",
|
|
268
|
-
"lineHeight": 18
|
|
269
|
-
},
|
|
270
|
-
"layout": {
|
|
271
|
-
"x": 107,
|
|
272
|
-
"y": 51,
|
|
273
|
-
"mode": "absolute",
|
|
274
|
-
"width": 190,
|
|
275
|
-
"height": 18,
|
|
276
|
-
"zIndex": 2
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
],
|
|
280
|
-
"mutualExcludes": [
|
|
281
|
-
"user.company",
|
|
282
|
-
"user.duty"
|
|
283
|
-
]
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
"id": "multiple-company-1",
|
|
287
|
-
"type": "text",
|
|
288
|
-
"style": {
|
|
289
|
-
"color": "",
|
|
290
|
-
"fontSize": 11,
|
|
291
|
-
"textAlign": "left",
|
|
292
|
-
"fontWeight": "normal",
|
|
293
|
-
"lineHeight": 11
|
|
294
|
-
},
|
|
295
|
-
"layout": {
|
|
296
|
-
"x": 107,
|
|
297
|
-
"y": 51,
|
|
298
|
-
"mode": "absolute",
|
|
299
|
-
"width": 190,
|
|
300
|
-
"height": 11,
|
|
301
|
-
"zIndex": 2
|
|
302
|
-
},
|
|
303
|
-
"visible": false
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
"id": "multiple-company-2",
|
|
307
|
-
"type": "text",
|
|
308
|
-
"style": {
|
|
309
|
-
"color": "",
|
|
310
|
-
"fontSize": 11,
|
|
311
|
-
"textAlign": "left",
|
|
312
|
-
"fontWeight": "normal",
|
|
313
|
-
"lineHeight": 11
|
|
314
|
-
},
|
|
315
|
-
"layout": {
|
|
316
|
-
"x": 107,
|
|
317
|
-
"y": 65,
|
|
318
|
-
"mode": "absolute",
|
|
319
|
-
"width": 190,
|
|
320
|
-
"height": 11,
|
|
321
|
-
"zIndex": 2
|
|
322
|
-
},
|
|
323
|
-
"visible": false
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
"id": "multiple-company-3",
|
|
327
|
-
"type": "text",
|
|
328
|
-
"style": {
|
|
329
|
-
"color": "",
|
|
330
|
-
"fontSize": 11,
|
|
331
|
-
"textAlign": "left",
|
|
332
|
-
"fontWeight": "normal",
|
|
333
|
-
"lineHeight": 11
|
|
334
|
-
},
|
|
335
|
-
"layout": {
|
|
336
|
-
"x": 107,
|
|
337
|
-
"y": 79,
|
|
338
|
-
"mode": "absolute",
|
|
339
|
-
"width": 190,
|
|
340
|
-
"height": 11,
|
|
341
|
-
"zIndex": 2
|
|
342
|
-
},
|
|
343
|
-
"visible": false
|
|
344
|
-
}
|
|
345
|
-
],
|
|
346
|
-
"container": {
|
|
347
|
-
"mode": "absolute"
|
|
348
|
-
},
|
|
349
|
-
"fontColor": "#ffffff",
|
|
350
|
-
"backgroundImage": "https://km-1257079185.cos.ap-chengdu.myqcloud.com/local/image/202511/21dd21c0d693a1eb44e53bad64b9b94a.png",
|
|
351
|
-
"backgroundZIndex": 0
|
|
352
|
-
}
|
|
353
|
-
]
|
|
3
|
+
const layouts = [{"name":"内置布局-右侧logo","width":343,"height":210,"children":[{"id":"f2dd3515-2147-460a-b788-3f58dd5f858b","type":"custom","style":{"borderRadius":0,"backgroundColor":"currentColor"},"layout":{"x":20,"y":104,"mode":"absolute","width":12,"height":1,"zIndex":8}},{"id":"7fd4c8cd-6bea-42d0-9a80-b1ba27f4abd3","type":"custom","style":{"borderRadius":0,"backgroundColor":"currentColor"},"layout":{"x":37,"y":104,"mode":"absolute","width":105,"height":1,"zIndex":9}},{"id":"1","key":"name","type":"text","style":{"color":"","fontSize":16,"textAlign":"left","fontWeight":"bold","lineHeight":22},"layout":{"x":20,"y":45,"mode":"absolute","width":210,"height":22,"zIndex":1},"binding":"user.name","defaultValue":"名片君"},{"id":"2","key":"company","type":"text","style":{"color":"","fontSize":11,"textAlign":"left","fontWeight":"normal","lineHeight":15},"layout":{"x":20,"y":74,"mode":"absolute","width":210,"height":15,"zIndex":3},"binding":"user.company","defaultValue":"合肥魅客网络有限公司"},{"id":"4","key":"duty","type":"text","style":{"color":"","fontSize":10,"textAlign":"left","fontWeight":"normal","lineHeight":15},"layout":{"x":20,"y":21,"mode":"absolute","width":210,"height":15,"zIndex":2},"binding":"user.duty","defaultValue":"销售经理"},{"id":"3","key":"mobile","icon":{"style":"fill","enable":true},"type":"text","style":{"color":"","fontSize":10,"textAlign":"left","fontWeight":"normal","lineHeight":15},"layout":{"x":20,"y":123,"mode":"absolute","width":280,"height":15,"zIndex":5},"binding":"user.mobile","defaultValue":"18888888888"},{"id":"5","key":"email","icon":{"style":"fill","enable":true},"type":"text","style":{"color":"","fontSize":10,"textAlign":"left","fontWeight":"normal","lineHeight":15},"layout":{"x":20,"y":145,"mode":"absolute","width":280,"height":15,"zIndex":6},"binding":"user.email","defaultValue":"km@kuanmai.com"},{"id":"8","key":"logo","type":"image","style":{"color":"#000000","objectFit":"contain","borderRadius":0},"layout":{"x":263,"y":20,"mode":"absolute","width":60,"height":60,"zIndex":4},"binding":"user.logo","defaultValue":"https://km-1257079185.cos.ap-chengdu.myqcloud.com/local/image/202511/4c71811adfa51e1e3ab4181a88cebc87.png"},{"id":"9","key":"address","icon":{"style":"fill","enable":true},"type":"text","style":{"color":"","fontSize":10,"textAlign":"left","fontWeight":"normal","lineHeight":15},"layout":{"x":20,"y":167,"mode":"absolute","width":280,"height":33,"zIndex":7},"binding":"user.address","defaultValue":"安徽省合肥市包河区硅谷大厦"}],"container":{"mode":"absolute"},"fontColor":"#333333","backgroundImage":"https://km-1257079185.cos.ap-chengdu.myqcloud.com/local/image/202511/0a7331e2e1a9a4cbc828afe6c338aaae.png","backgroundZIndex":1}]
|
|
354
4
|
|
|
355
5
|
|
|
356
6
|
const cardData = {
|
|
@@ -12,75 +12,6 @@ const pickCardId = (layout, idx) => {
|
|
|
12
12
|
return layout.name || layout.id;
|
|
13
13
|
return `card-${idx}`;
|
|
14
14
|
};
|
|
15
|
-
const withUnit = (value, unit) => (0, index_1.addUnit)(value, unit);
|
|
16
|
-
const buildCardStyle = (layout, unit) => (0, index_1.styleObjectToString)({
|
|
17
|
-
width: withUnit(layout.width, unit),
|
|
18
|
-
height: withUnit(layout.height, unit),
|
|
19
|
-
color: layout.fontColor,
|
|
20
|
-
borderRadius: layout.borderRadius !== undefined
|
|
21
|
-
? withUnit(layout.borderRadius, unit)
|
|
22
|
-
: undefined,
|
|
23
|
-
padding: layout.padding !== undefined ? withUnit(layout.padding, unit) : undefined,
|
|
24
|
-
position: 'relative',
|
|
25
|
-
overflow: 'hidden',
|
|
26
|
-
boxSizing: 'border-box',
|
|
27
|
-
backgroundColor: 'transparent',
|
|
28
|
-
}, unit);
|
|
29
|
-
const buildBackgroundStyle = (layout, unit) => (0, index_1.styleObjectToString)({
|
|
30
|
-
zIndex: layout.backgroundZIndex,
|
|
31
|
-
borderRadius: layout.borderRadius !== undefined
|
|
32
|
-
? withUnit(layout.borderRadius, unit)
|
|
33
|
-
: undefined,
|
|
34
|
-
width: '100%',
|
|
35
|
-
height: '100%',
|
|
36
|
-
position: 'absolute',
|
|
37
|
-
left: 0,
|
|
38
|
-
top: 0,
|
|
39
|
-
}, unit);
|
|
40
|
-
const buildWrapperStyle = (el, unit) => {
|
|
41
|
-
if (!el.layout || el.layout.mode !== 'absolute')
|
|
42
|
-
return '';
|
|
43
|
-
return (0, index_1.styleObjectToString)({
|
|
44
|
-
position: 'absolute',
|
|
45
|
-
left: withUnit(el.layout.x, unit),
|
|
46
|
-
top: withUnit(el.layout.y, unit),
|
|
47
|
-
width: withUnit(el.layout.width, unit),
|
|
48
|
-
height: withUnit(el.layout.height, unit),
|
|
49
|
-
zIndex: el.layout.zIndex,
|
|
50
|
-
boxSizing: 'border-box',
|
|
51
|
-
display: 'flex',
|
|
52
|
-
alignItems: 'center',
|
|
53
|
-
}, unit);
|
|
54
|
-
};
|
|
55
|
-
const buildPanelContentStyle = (el, unit) => (0, index_1.styleObjectToString)({
|
|
56
|
-
position: 'relative',
|
|
57
|
-
width: '100%',
|
|
58
|
-
height: '100%',
|
|
59
|
-
display: 'block',
|
|
60
|
-
boxSizing: 'border-box',
|
|
61
|
-
...(el.style || {}),
|
|
62
|
-
}, unit);
|
|
63
|
-
const buildTextContentStyle = (el, unit) => {
|
|
64
|
-
var _a, _b, _c;
|
|
65
|
-
const textAlign = ((_a = el.style) === null || _a === void 0 ? void 0 : _a.textAlign) || el.align || undefined;
|
|
66
|
-
const style = {
|
|
67
|
-
...el.style,
|
|
68
|
-
whiteSpace: 'pre-wrap',
|
|
69
|
-
wordBreak: 'break-word',
|
|
70
|
-
lineHeight: ((_b = el.style) === null || _b === void 0 ? void 0 : _b.lineHeight) !== undefined && ((_c = el.style) === null || _c === void 0 ? void 0 : _c.lineHeight) !== null
|
|
71
|
-
? el.style.lineHeight
|
|
72
|
-
: '1.2',
|
|
73
|
-
display: 'inline-flex',
|
|
74
|
-
alignItems: 'center',
|
|
75
|
-
};
|
|
76
|
-
if (textAlign)
|
|
77
|
-
style.textAlign = textAlign;
|
|
78
|
-
return (0, index_1.styleObjectToString)(style, unit);
|
|
79
|
-
};
|
|
80
|
-
const buildBaseContentStyle = (el, unit) => (0, index_1.styleObjectToString)({
|
|
81
|
-
...(el.style || {}),
|
|
82
|
-
boxSizing: 'border-box',
|
|
83
|
-
}, unit);
|
|
84
15
|
const mapIconGlyph = (name, fallback) => {
|
|
85
16
|
if (!name)
|
|
86
17
|
return fallback;
|
|
@@ -89,125 +20,34 @@ const mapIconGlyph = (name, fallback) => {
|
|
|
89
20
|
return String.fromCharCode(parseInt(glyph, 16));
|
|
90
21
|
return fallback || name;
|
|
91
22
|
};
|
|
92
|
-
const
|
|
93
|
-
var _a
|
|
94
|
-
const icon =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
else if (style === 'line')
|
|
103
|
-
name = baseName ? `${baseName}-line` : undefined;
|
|
104
|
-
else
|
|
105
|
-
name = baseName || undefined;
|
|
106
|
-
if (!name)
|
|
107
|
-
return undefined;
|
|
108
|
-
const size = icon.size !== undefined && icon.size !== null
|
|
109
|
-
? icon.size
|
|
110
|
-
: (_a = el.style) === null || _a === void 0 ? void 0 : _a.fontSize;
|
|
111
|
-
const gap = icon.gap !== undefined && icon.gap !== null ? icon.gap : 4;
|
|
112
|
-
const color = (_d = (_b = icon.color) !== null && _b !== void 0 ? _b : (_c = el.style) === null || _c === void 0 ? void 0 : _c.color) !== null && _d !== void 0 ? _d : undefined;
|
|
113
|
-
const text = mapIconGlyph(name, name);
|
|
23
|
+
const mapRenderNode = (node) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const icon = node.icon
|
|
26
|
+
? {
|
|
27
|
+
...node.icon,
|
|
28
|
+
text: mapIconGlyph(node.icon.name, node.icon.text),
|
|
29
|
+
}
|
|
30
|
+
: undefined;
|
|
31
|
+
const children = (_a = node.children) === null || _a === void 0 ? void 0 : _a.map(mapRenderNode);
|
|
32
|
+
const mappedText = node.type === 'icon' ? mapIconGlyph(node.name, node.text) : node.text;
|
|
114
33
|
return {
|
|
115
|
-
|
|
116
|
-
text,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
color,
|
|
120
|
-
align: icon.align || 'left',
|
|
34
|
+
...node,
|
|
35
|
+
text: mappedText,
|
|
36
|
+
icon,
|
|
37
|
+
children,
|
|
121
38
|
};
|
|
122
39
|
};
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
wrapperStyle,
|
|
134
|
-
contentStyle: buildPanelContentStyle(panel, unit),
|
|
135
|
-
children: buildRenderNodes(panel.children || [], data, unit),
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
if (el.type === 'text') {
|
|
139
|
-
const textValue = (_b = (_a = (0, index_1.resolveBindingValue)(el.binding, data)) !== null && _a !== void 0 ? _a : el.defaultValue) !== null && _b !== void 0 ? _b : '';
|
|
140
|
-
return {
|
|
141
|
-
id: el.id,
|
|
142
|
-
type: el.type,
|
|
143
|
-
wrapperStyle,
|
|
144
|
-
contentStyle: buildTextContentStyle(el, unit),
|
|
145
|
-
text: `${textValue}`,
|
|
146
|
-
icon: buildTextIcon(el, unit),
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
if (el.type === 'image') {
|
|
150
|
-
const style = { ...(el.style || {}) };
|
|
151
|
-
const borderWidth = Number(style.borderWidth);
|
|
152
|
-
if (Number.isFinite(borderWidth) && borderWidth > 0) {
|
|
153
|
-
if (!style.borderStyle)
|
|
154
|
-
style.borderStyle = 'solid';
|
|
155
|
-
if (!style.borderColor)
|
|
156
|
-
style.borderColor = '#000000';
|
|
157
|
-
}
|
|
158
|
-
const src = (_e = (_d = (_c = (0, index_1.resolveBindingValue)(el.binding, data)) !== null && _c !== void 0 ? _c : el.defaultUrl) !== null && _d !== void 0 ? _d : el.defaultValue) !== null && _e !== void 0 ? _e : '';
|
|
159
|
-
const mode = el.fit === 'contain' ? 'aspectFit' : 'aspectFill';
|
|
160
|
-
return {
|
|
161
|
-
id: el.id,
|
|
162
|
-
type: el.type,
|
|
163
|
-
wrapperStyle,
|
|
164
|
-
contentStyle: (0, index_1.styleObjectToString)(style, unit),
|
|
165
|
-
src,
|
|
166
|
-
mode,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
if (el.type === 'icon') {
|
|
170
|
-
const resolved = (_h = (_g = (_f = (0, index_1.resolveBindingValue)(el.binding, data)) !== null && _f !== void 0 ? _f : el.name) !== null && _g !== void 0 ? _g : el.defaultValue) !== null && _h !== void 0 ? _h : '';
|
|
171
|
-
const text = mapIconGlyph(`${resolved}`, `${resolved}`);
|
|
172
|
-
return {
|
|
173
|
-
id: el.id,
|
|
174
|
-
type: el.type,
|
|
175
|
-
wrapperStyle,
|
|
176
|
-
contentStyle: buildBaseContentStyle(el, unit),
|
|
177
|
-
name: `${resolved}`,
|
|
178
|
-
text,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
if (el.type === 'custom') {
|
|
182
|
-
return {
|
|
183
|
-
id: el.id,
|
|
184
|
-
type: el.type,
|
|
185
|
-
wrapperStyle,
|
|
186
|
-
contentStyle: buildBaseContentStyle(el, unit),
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
return null;
|
|
190
|
-
};
|
|
191
|
-
const buildRenderNodes = (children, data, unit) => {
|
|
192
|
-
if (!Array.isArray(children))
|
|
193
|
-
return [];
|
|
194
|
-
const nodes = [];
|
|
195
|
-
children.forEach(el => {
|
|
196
|
-
if (!el || el.visible === false)
|
|
197
|
-
return;
|
|
198
|
-
const node = buildRenderNode(el, data, unit);
|
|
199
|
-
if (node)
|
|
200
|
-
nodes.push(node);
|
|
201
|
-
});
|
|
202
|
-
return nodes;
|
|
40
|
+
const mapRenderTree = (nodes) => Array.isArray(nodes) ? nodes.map(mapRenderNode) : [];
|
|
41
|
+
const buildCards = (layouts, data) => {
|
|
42
|
+
const renders = (0, index_1.buildRenderResult)(layouts, data, 'rpx');
|
|
43
|
+
return renders.map((render, idx) => ({
|
|
44
|
+
id: pickCardId(layouts[idx], idx),
|
|
45
|
+
cardStyle: render.cardStyle,
|
|
46
|
+
backgroundImage: render.backgroundImage || '',
|
|
47
|
+
backgroundStyle: render.backgroundStyle,
|
|
48
|
+
nodes: mapRenderTree(render.renderTree),
|
|
49
|
+
}));
|
|
203
50
|
};
|
|
204
|
-
const buildCards = (layouts, data, unit) => layouts.map(layout => ({
|
|
205
|
-
id: layout.name || layout.id || '',
|
|
206
|
-
cardStyle: buildCardStyle(layout, unit),
|
|
207
|
-
backgroundImage: layout.backgroundImage || '',
|
|
208
|
-
backgroundStyle: buildBackgroundStyle(layout, unit),
|
|
209
|
-
nodes: buildRenderNodes(layout.children || [], data, unit),
|
|
210
|
-
}));
|
|
211
51
|
Component({
|
|
212
52
|
options: {
|
|
213
53
|
styleIsolation: 'apply-shared',
|
|
@@ -250,10 +90,7 @@ Component({
|
|
|
250
90
|
return;
|
|
251
91
|
}
|
|
252
92
|
const normalizedLayouts = (0, index_1.normalizeLayout)(layoutInput);
|
|
253
|
-
const cards = buildCards(normalizedLayouts, dataInput
|
|
254
|
-
...card,
|
|
255
|
-
id: pickCardId(layoutInput[idx], idx),
|
|
256
|
-
}));
|
|
93
|
+
const cards = buildCards(normalizedLayouts, dataInput);
|
|
257
94
|
this.setData({ cards });
|
|
258
95
|
},
|
|
259
96
|
},
|
|
@@ -62,15 +62,23 @@
|
|
|
62
62
|
<view class="km-node km-node--text" style="{{node.wrapperStyle}}">
|
|
63
63
|
<view class="km-node__text" style="{{node.contentStyle}}">
|
|
64
64
|
<block wx:if="{{node.icon && node.icon.name}}">
|
|
65
|
-
<view
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
<view class="km-node__text-content">
|
|
66
|
+
<block wx:if="{{node.icon.align === 'right'}}">
|
|
67
|
+
<text class="km-node__text-value">{{node.text || ''}}</text>
|
|
68
|
+
<view style="{{node.icon.wrapperStyle}}">
|
|
69
|
+
<text
|
|
70
|
+
class="km-node__text-icon icon"
|
|
71
|
+
style="font-size: {{node.icon.size || '16px'}}; color: {{node.icon.color || ''}}; margin-right: {{node.icon.gap || ''}};">{{node.icon.text || node.icon.name || ''}}</text>
|
|
72
|
+
</view>
|
|
73
|
+
</block>
|
|
74
|
+
<block wx:else>
|
|
75
|
+
<view style="{{node.icon.wrapperStyle}}">
|
|
76
|
+
<text
|
|
77
|
+
class="km-node__text-icon icon"
|
|
78
|
+
style="font-size: {{node.icon.size || '16px'}}; color: {{node.icon.color || ''}}; margin-right: {{node.icon.gap || ''}};">{{node.icon.text || node.icon.name || ''}}</text>
|
|
79
|
+
</view>
|
|
80
|
+
<text class="km-node__text-value">{{node.text || ''}}</text>
|
|
81
|
+
</block>
|
|
74
82
|
</view>
|
|
75
83
|
</block>
|
|
76
84
|
<block wx:else>
|
|
@@ -78,25 +78,28 @@
|
|
|
78
78
|
.km-node__text {
|
|
79
79
|
width: 100%;
|
|
80
80
|
height: 100%;
|
|
81
|
-
display:
|
|
82
|
-
|
|
81
|
+
display: block;
|
|
82
|
+
box-sizing: border-box;
|
|
83
|
+
text-align: inherit;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
.km-node__text-content {
|
|
86
|
-
display: inline-
|
|
87
|
-
align
|
|
87
|
+
display: inline-block;
|
|
88
|
+
vertical-align: middle;
|
|
89
|
+
height: 100%;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
.km-node__text-value {
|
|
91
93
|
display: inline-block;
|
|
92
94
|
white-space: pre-wrap;
|
|
93
95
|
word-break: break-word;
|
|
96
|
+
vertical-align: middle;
|
|
97
|
+
}
|
|
98
|
+
.km-node--text{
|
|
99
|
+
/* 溢出隐藏 */
|
|
94
100
|
}
|
|
95
|
-
|
|
96
101
|
.km-node--text text {
|
|
97
|
-
display:
|
|
98
|
-
white-space: pre-wrap;
|
|
99
|
-
word-break: break-word;
|
|
102
|
+
display: inline;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
/* ICON */
|