@riil-frontend/component-topology 2.7.1 → 2.7.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.
- package/build/index.css +1 -1
- package/build/index.js +13 -13
- package/es/components/ResourceList/ResourceSelect.js +15 -14
- package/es/components/TagSelect/index.js +60 -0
- package/es/components/TagSelect/index.scss +27 -0
- package/es/components/TemplateButton/index.js +12 -3
- package/es/components/TemplateButton/index.module.scss +13 -26
- package/es/components/TemplateSelect/index.js +40 -18
- package/es/core/editor/components/settings/text/TextPropertyView.js +3 -2
- package/es/models/linkDynamicStyle.js +21 -6
- package/es/models/topoCreateMod.js +51 -92
- package/es/models/topoMod.js +7 -5
- package/es/topoCenter/store/topoTreeMod.js +4 -2
- package/es/utils/template.js +1 -1
- package/lib/components/ResourceList/ResourceSelect.js +15 -15
- package/lib/components/TagSelect/index.js +76 -0
- package/lib/components/TagSelect/index.scss +27 -0
- package/lib/components/TemplateButton/index.js +13 -4
- package/lib/components/TemplateButton/index.module.scss +13 -26
- package/lib/components/TemplateSelect/index.js +42 -18
- package/lib/core/editor/components/settings/text/TextPropertyView.js +3 -2
- package/lib/models/linkDynamicStyle.js +21 -6
- package/lib/models/topoCreateMod.js +51 -92
- package/lib/models/topoMod.js +7 -5
- package/lib/topoCenter/store/topoTreeMod.js +4 -2
- package/lib/utils/template.js +1 -1
- package/package.json +5 -4
|
@@ -264,68 +264,27 @@ export default function (topoApp) {
|
|
|
264
264
|
},
|
|
265
265
|
effects: function effects(dispatch) {
|
|
266
266
|
return {
|
|
267
|
-
|
|
267
|
+
getConditions: function getConditions() {
|
|
268
268
|
var _this = this;
|
|
269
269
|
|
|
270
270
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
271
|
-
var
|
|
272
|
-
|
|
271
|
+
var data, groupTopo, resources, groups;
|
|
273
272
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
274
273
|
while (1) {
|
|
275
274
|
switch (_context.prev = _context.next) {
|
|
276
275
|
case 0:
|
|
277
|
-
|
|
278
|
-
conditions = resToConditions(resources) || {};
|
|
279
|
-
|
|
280
|
-
if (!(conditions.dynamic || conditions["static"])) {
|
|
281
|
-
_context.next = 7;
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
_context.next = 5;
|
|
286
|
-
return topoService.getResourceList(conditions);
|
|
287
|
-
|
|
288
|
-
case 5:
|
|
289
|
-
data = _context.sent;
|
|
290
|
-
|
|
291
|
-
if (index < 0) {
|
|
292
|
-
_this.updateResList(data);
|
|
293
|
-
} else {
|
|
294
|
-
_this.updateGroupResList({
|
|
295
|
-
index: index,
|
|
296
|
-
data: data
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
case 7:
|
|
301
|
-
case "end":
|
|
302
|
-
return _context.stop();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}, _callee);
|
|
306
|
-
}))();
|
|
307
|
-
},
|
|
308
|
-
getConditions: function getConditions() {
|
|
309
|
-
var _this2 = this;
|
|
310
|
-
|
|
311
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
312
|
-
var data, groupTopo, resources, groups;
|
|
313
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
314
|
-
while (1) {
|
|
315
|
-
switch (_context2.prev = _context2.next) {
|
|
316
|
-
case 0:
|
|
317
|
-
_context2.next = 2;
|
|
276
|
+
_context.next = 2;
|
|
318
277
|
return topoService.getConditions(topoApp.id);
|
|
319
278
|
|
|
320
279
|
case 2:
|
|
321
|
-
data =
|
|
280
|
+
data = _context.sent;
|
|
322
281
|
|
|
323
282
|
if (isAvailableArray(data)) {
|
|
324
|
-
|
|
283
|
+
_context.next = 5;
|
|
325
284
|
break;
|
|
326
285
|
}
|
|
327
286
|
|
|
328
|
-
return
|
|
287
|
+
return _context.abrupt("return");
|
|
329
288
|
|
|
330
289
|
case 5:
|
|
331
290
|
// 视图
|
|
@@ -358,28 +317,28 @@ export default function (topoApp) {
|
|
|
358
317
|
};
|
|
359
318
|
});
|
|
360
319
|
|
|
361
|
-
|
|
320
|
+
_this.update({
|
|
362
321
|
resources: resources,
|
|
363
322
|
groups: groups
|
|
364
323
|
});
|
|
365
324
|
|
|
366
325
|
case 9:
|
|
367
326
|
case "end":
|
|
368
|
-
return
|
|
327
|
+
return _context.stop();
|
|
369
328
|
}
|
|
370
329
|
}
|
|
371
|
-
},
|
|
330
|
+
}, _callee);
|
|
372
331
|
}))();
|
|
373
332
|
},
|
|
374
333
|
fetchData: function fetchData(params, rootState) {
|
|
375
|
-
var
|
|
334
|
+
var _this2 = this;
|
|
376
335
|
|
|
377
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
336
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
378
337
|
var editState, resources, _editState$groups, groups, query, data;
|
|
379
338
|
|
|
380
|
-
return _regeneratorRuntime.wrap(function
|
|
339
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
381
340
|
while (1) {
|
|
382
|
-
switch (
|
|
341
|
+
switch (_context2.prev = _context2.next) {
|
|
383
342
|
case 0:
|
|
384
343
|
editState = rootState.topoCreateMod;
|
|
385
344
|
resources = editState.resources, _editState$groups = editState.groups, groups = _editState$groups === void 0 ? [] : _editState$groups;
|
|
@@ -388,30 +347,30 @@ export default function (topoApp) {
|
|
|
388
347
|
resources: resources,
|
|
389
348
|
groups: groups
|
|
390
349
|
};
|
|
391
|
-
|
|
392
|
-
return
|
|
350
|
+
_context2.next = 5;
|
|
351
|
+
return _this2.getTopoByConditions(query);
|
|
393
352
|
|
|
394
353
|
case 5:
|
|
395
|
-
data =
|
|
396
|
-
return
|
|
354
|
+
data = _context2.sent;
|
|
355
|
+
return _context2.abrupt("return", data);
|
|
397
356
|
|
|
398
357
|
case 7:
|
|
399
358
|
case "end":
|
|
400
|
-
return
|
|
359
|
+
return _context2.stop();
|
|
401
360
|
}
|
|
402
361
|
}
|
|
403
|
-
},
|
|
362
|
+
}, _callee2);
|
|
404
363
|
}))();
|
|
405
364
|
},
|
|
406
365
|
getTopoByConditions: function getTopoByConditions(params, state) {
|
|
407
|
-
var
|
|
366
|
+
var _this3 = this;
|
|
408
367
|
|
|
409
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
368
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
410
369
|
var topoId, resources, groups, conditions, groupInfo, data, _yield$Promise$all, ciTypeMap, links, _combTopoData, topoData, resAndMetrics, topoDataTrans;
|
|
411
370
|
|
|
412
|
-
return _regeneratorRuntime.wrap(function
|
|
371
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
413
372
|
while (1) {
|
|
414
|
-
switch (
|
|
373
|
+
switch (_context3.prev = _context3.next) {
|
|
415
374
|
case 0:
|
|
416
375
|
rlog.debug('getTopoByConditions--------', params);
|
|
417
376
|
topoId = params.id, resources = params.resources, groups = params.groups;
|
|
@@ -422,17 +381,17 @@ export default function (topoApp) {
|
|
|
422
381
|
resources: resToConditions(group.resources)
|
|
423
382
|
});
|
|
424
383
|
});
|
|
425
|
-
|
|
384
|
+
_context3.next = 6;
|
|
426
385
|
return topoService.getTopoDataByResource(topoId, conditions, groupInfo);
|
|
427
386
|
|
|
428
387
|
case 6:
|
|
429
|
-
data =
|
|
388
|
+
data = _context3.sent;
|
|
430
389
|
rlog.debug('getTopoByConditions--------', data, groupInfo);
|
|
431
|
-
|
|
390
|
+
_context3.next = 10;
|
|
432
391
|
return Promise.all([topoApp.ciTyeCache.getCiTypeMap(getCiTypes(data)), getLinksDetail(data.links), dispatch.iconManage.getIcons()]);
|
|
433
392
|
|
|
434
393
|
case 10:
|
|
435
|
-
_yield$Promise$all =
|
|
394
|
+
_yield$Promise$all = _context3.sent;
|
|
436
395
|
ciTypeMap = _yield$Promise$all[0];
|
|
437
396
|
links = _yield$Promise$all[1];
|
|
438
397
|
_combTopoData = combTopoData({
|
|
@@ -445,13 +404,13 @@ export default function (topoApp) {
|
|
|
445
404
|
ciTypeMap: ciTypeMap
|
|
446
405
|
}), topoData = _combTopoData.topoData, resAndMetrics = _combTopoData.resAndMetrics;
|
|
447
406
|
|
|
448
|
-
|
|
407
|
+
_this3.update({
|
|
449
408
|
elements: topoData
|
|
450
409
|
});
|
|
451
410
|
|
|
452
411
|
topoDataTrans = transformTopoElements(topoData);
|
|
453
412
|
|
|
454
|
-
|
|
413
|
+
_this3.updateTopo(topoDataTrans); // const allCiSet = state.topoBizMod.allCiSet;
|
|
455
414
|
// rlog.debug(
|
|
456
415
|
// '新添加资源什么情况-topoData-resAndMetrics-allCiSet',
|
|
457
416
|
// topoData,
|
|
@@ -466,41 +425,41 @@ export default function (topoApp) {
|
|
|
466
425
|
// });
|
|
467
426
|
// 返回查询后的数据,便于外部获取到数据后像HT通知更新
|
|
468
427
|
|
|
469
|
-
return
|
|
428
|
+
return _context3.abrupt("return", topoDataTrans);
|
|
470
429
|
|
|
471
430
|
case 19:
|
|
472
431
|
case "end":
|
|
473
|
-
return
|
|
432
|
+
return _context3.stop();
|
|
474
433
|
}
|
|
475
434
|
}
|
|
476
|
-
},
|
|
435
|
+
}, _callee3);
|
|
477
436
|
}))();
|
|
478
437
|
},
|
|
479
438
|
saveTopo: function saveTopo(data, state) {
|
|
480
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
439
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
481
440
|
var topoId, template, layout, global, resources, groups, serialize, layoutId, conditions, groupInfo;
|
|
482
|
-
return _regeneratorRuntime.wrap(function
|
|
441
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
483
442
|
while (1) {
|
|
484
|
-
switch (
|
|
443
|
+
switch (_context4.prev = _context4.next) {
|
|
485
444
|
case 0:
|
|
486
445
|
topoId = data.id, template = data.template, layout = data.layout, global = data.global, resources = data.resources, groups = data.groups, serialize = data.serialize; // 保存布局
|
|
487
446
|
|
|
488
447
|
if (!(template && layout)) {
|
|
489
|
-
|
|
448
|
+
_context4.next = 5;
|
|
490
449
|
break;
|
|
491
450
|
}
|
|
492
451
|
|
|
493
452
|
layoutId = getLayoutId(layout);
|
|
494
|
-
|
|
453
|
+
_context4.next = 5;
|
|
495
454
|
return topoService.changeLayout(topoId, template, layoutId);
|
|
496
455
|
|
|
497
456
|
case 5:
|
|
498
457
|
if (!global) {
|
|
499
|
-
|
|
458
|
+
_context4.next = 8;
|
|
500
459
|
break;
|
|
501
460
|
}
|
|
502
461
|
|
|
503
|
-
|
|
462
|
+
_context4.next = 8;
|
|
504
463
|
return topoService.saveTopoSettings(topoId, combSaveTopoData({
|
|
505
464
|
global: global,
|
|
506
465
|
ciSetDoc: state.topoBizMod.ciSetDoc,
|
|
@@ -509,16 +468,16 @@ export default function (topoApp) {
|
|
|
509
468
|
|
|
510
469
|
case 8:
|
|
511
470
|
if (!serialize) {
|
|
512
|
-
|
|
471
|
+
_context4.next = 11;
|
|
513
472
|
break;
|
|
514
473
|
}
|
|
515
474
|
|
|
516
|
-
|
|
475
|
+
_context4.next = 11;
|
|
517
476
|
return topoService.saveSerializeData(topoId, serialize);
|
|
518
477
|
|
|
519
478
|
case 11:
|
|
520
479
|
if (!(resources || groups)) {
|
|
521
|
-
|
|
480
|
+
_context4.next = 16;
|
|
522
481
|
break;
|
|
523
482
|
}
|
|
524
483
|
|
|
@@ -529,34 +488,34 @@ export default function (topoApp) {
|
|
|
529
488
|
resources: resToConditions(group.resources, true)
|
|
530
489
|
});
|
|
531
490
|
});
|
|
532
|
-
|
|
491
|
+
_context4.next = 16;
|
|
533
492
|
return topoService.bindResourceToTopo(topoId, conditions, groupInfo);
|
|
534
493
|
|
|
535
494
|
case 16:
|
|
536
495
|
case "end":
|
|
537
|
-
return
|
|
496
|
+
return _context4.stop();
|
|
538
497
|
}
|
|
539
498
|
}
|
|
540
|
-
},
|
|
499
|
+
}, _callee4);
|
|
541
500
|
}))();
|
|
542
501
|
},
|
|
543
502
|
addToBlockList: function addToBlockList(data) {
|
|
544
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
503
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
545
504
|
var topoId, ciIdList;
|
|
546
|
-
return _regeneratorRuntime.wrap(function
|
|
505
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
547
506
|
while (1) {
|
|
548
|
-
switch (
|
|
507
|
+
switch (_context5.prev = _context5.next) {
|
|
549
508
|
case 0:
|
|
550
509
|
topoId = data.id, ciIdList = data.ciIdList;
|
|
551
|
-
|
|
510
|
+
_context5.next = 3;
|
|
552
511
|
return topoService.addToBlocklist(topoId, ciIdList);
|
|
553
512
|
|
|
554
513
|
case 3:
|
|
555
514
|
case "end":
|
|
556
|
-
return
|
|
515
|
+
return _context5.stop();
|
|
557
516
|
}
|
|
558
517
|
}
|
|
559
|
-
},
|
|
518
|
+
}, _callee5);
|
|
560
519
|
}))();
|
|
561
520
|
},
|
|
562
521
|
switchToEditMode: function switchToEditMode() {},
|
package/es/models/topoMod.js
CHANGED
|
@@ -19,14 +19,13 @@ export default function (topoApp) {
|
|
|
19
19
|
urlParams: {},
|
|
20
20
|
topoLoading: true,
|
|
21
21
|
topoLoadError: false,
|
|
22
|
-
topoId: '',
|
|
23
|
-
topoName: '',
|
|
24
|
-
topoPermission: undefined,
|
|
25
22
|
viewState: 'view',
|
|
26
23
|
// view, create, 2种模式
|
|
27
|
-
|
|
24
|
+
topoId: '',
|
|
25
|
+
topoName: '',
|
|
28
26
|
topoData: null,
|
|
29
27
|
currentTopo: undefined,
|
|
28
|
+
topoPermission: undefined,
|
|
30
29
|
currentNode: {
|
|
31
30
|
id: '',
|
|
32
31
|
name: '无数据'
|
|
@@ -175,7 +174,10 @@ export default function (topoApp) {
|
|
|
175
174
|
},
|
|
176
175
|
clearData: function clearData() {
|
|
177
176
|
this.update({
|
|
178
|
-
|
|
177
|
+
topoId: '',
|
|
178
|
+
topoName: '',
|
|
179
|
+
topoData: null,
|
|
180
|
+
currentTopo: undefined
|
|
179
181
|
});
|
|
180
182
|
},
|
|
181
183
|
switchToViewMode: function switchToViewMode(playload, rootState) {
|
|
@@ -24,7 +24,9 @@ function findSelectedParentIds(data, selectedId) {
|
|
|
24
24
|
if (!node.item) return [];
|
|
25
25
|
|
|
26
26
|
if (node.pid != -1 && node.item.id) {
|
|
27
|
-
|
|
27
|
+
var _node$children;
|
|
28
|
+
|
|
29
|
+
return (_node$children = node.children) !== null && _node$children !== void 0 && _node$children.length ? ["" + node.item.id].concat(findSelectedParentIds(data, node.pid)) : [].concat(findSelectedParentIds(data, node.pid));
|
|
28
30
|
} else {
|
|
29
31
|
return ["" + node.item.id];
|
|
30
32
|
}
|
|
@@ -369,7 +371,7 @@ export default function (topoApp) {
|
|
|
369
371
|
var parentIds = findSelectedParentIds(treeState.treeData, id);
|
|
370
372
|
expandedKeys.push.apply(expandedKeys, parentIds);
|
|
371
373
|
this.update({
|
|
372
|
-
selectedNode: [id],
|
|
374
|
+
selectedNode: ["" + id],
|
|
373
375
|
expandedKeys: expandedKeys
|
|
374
376
|
});
|
|
375
377
|
}
|
package/es/utils/template.js
CHANGED
|
@@ -46,7 +46,7 @@ var getTableData = /*#__PURE__*/function () {
|
|
|
46
46
|
switch (_context.prev = _context.next) {
|
|
47
47
|
case 0:
|
|
48
48
|
_params$current = params.current, current = _params$current === void 0 ? 1 : _params$current, _params$pageSize = params.pageSize, pageSize = _params$pageSize === void 0 ? 20 : _params$pageSize, _params$sortBy = params.sortBy, sortBy = _params$sortBy === void 0 ? 'displayName' : _params$sortBy, _params$sortOrder = params.sortOrder, sortOrder = _params$sortOrder === void 0 ? 'asc' : _params$sortOrder, like = params.like, typeCode = params.typeCode;
|
|
49
|
-
condition = 'category(\'resource\')';
|
|
49
|
+
condition = 'type(\'common_network\',\'switch\',\'switch_cluster\',\'linux\',\'windows\',\'oracle\',\'oracle.asm_disk_group\',\'tomcat\',\'application\',\'service\') && category(\'resource\')';
|
|
50
50
|
|
|
51
51
|
if (like) {
|
|
52
52
|
condition = {
|
|
@@ -90,7 +90,7 @@ var getTableData = /*#__PURE__*/function () {
|
|
|
90
90
|
|
|
91
91
|
};
|
|
92
92
|
});
|
|
93
|
-
return _context.abrupt("return", (0, _format.formatDataForTable)(dataSource, data.
|
|
93
|
+
return _context.abrupt("return", (0, _format.formatDataForTable)(dataSource, data.totalRecord, data.pageIndex, data.pageSize));
|
|
94
94
|
|
|
95
95
|
case 9:
|
|
96
96
|
case "end":
|
|
@@ -172,7 +172,7 @@ var ResourceList = function ResourceList(props, ref) {
|
|
|
172
172
|
|
|
173
173
|
};
|
|
174
174
|
var defaultColumns = [{
|
|
175
|
-
title: '
|
|
175
|
+
title: '资源名称',
|
|
176
176
|
dataIndex: 'displayName',
|
|
177
177
|
sortable: true,
|
|
178
178
|
cell: _table.getTitleCell
|
|
@@ -184,7 +184,7 @@ var ResourceList = function ResourceList(props, ref) {
|
|
|
184
184
|
return (0, _table.getTitleCell)((0, _format.getIp)(ip));
|
|
185
185
|
}
|
|
186
186
|
}, {
|
|
187
|
-
title: '
|
|
187
|
+
title: '资源类型',
|
|
188
188
|
dataIndex: 'typeCode',
|
|
189
189
|
filters: filters.typeCode,
|
|
190
190
|
cell: function cell(code) {
|
|
@@ -194,17 +194,17 @@ var ResourceList = function ResourceList(props, ref) {
|
|
|
194
194
|
var name = dict && dict.label || code;
|
|
195
195
|
return (0, _table.getTitleCell)(name);
|
|
196
196
|
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
197
|
+
} // {
|
|
198
|
+
// title: '厂商',
|
|
199
|
+
// sortable: true,
|
|
200
|
+
// dataIndex: 'company',
|
|
201
|
+
// cell: (code) => {
|
|
202
|
+
// const dict = DICT.get(code);
|
|
203
|
+
// const name = (dict && dict.name) || code;
|
|
204
|
+
// return getTitleCell(name);
|
|
205
|
+
// },
|
|
206
|
+
// }
|
|
207
|
+
];
|
|
208
208
|
return /*#__PURE__*/_react["default"].createElement(_FormTable["default"], {
|
|
209
209
|
className: className || _ResourceSelectModule["default"].table,
|
|
210
210
|
formProps: formProps,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
exports.__esModule = true;
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _box = _interopRequireDefault(require("@alifd/next/lib/box"));
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _tag = _interopRequireDefault(require("@alifd/next/lib/tag"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
+
|
|
20
|
+
require("./index.scss");
|
|
21
|
+
|
|
22
|
+
var SelectableTag = _tag["default"].Selectable;
|
|
23
|
+
|
|
24
|
+
var TagSelect = function TagSelect(props) {
|
|
25
|
+
var _onChange = props.onChange,
|
|
26
|
+
value = props.value,
|
|
27
|
+
dataSource = props.dataSource,
|
|
28
|
+
defaultValue = props.defaultValue,
|
|
29
|
+
boxProps = props.boxProps,
|
|
30
|
+
tagProps = props.tagProps;
|
|
31
|
+
|
|
32
|
+
var _useState = (0, _react.useState)(value || defaultValue),
|
|
33
|
+
current = _useState[0],
|
|
34
|
+
setCurrent = _useState[1];
|
|
35
|
+
|
|
36
|
+
(0, _react.useEffect)(function () {
|
|
37
|
+
if (value) {
|
|
38
|
+
setCurrent(value);
|
|
39
|
+
}
|
|
40
|
+
}, [value]);
|
|
41
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
42
|
+
className: "tag-select-wrap"
|
|
43
|
+
}, /*#__PURE__*/_react["default"].createElement(_box["default"], (0, _extends2["default"])({
|
|
44
|
+
spacing: 8,
|
|
45
|
+
wrap: true,
|
|
46
|
+
direction: "row"
|
|
47
|
+
}, boxProps), dataSource.map(function (item) {
|
|
48
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
49
|
+
className: "tag-select-item",
|
|
50
|
+
key: "wrap-" + item.key
|
|
51
|
+
}, /*#__PURE__*/_react["default"].createElement(SelectableTag, (0, _extends2["default"])({
|
|
52
|
+
key: item.key,
|
|
53
|
+
checked: current === item.key,
|
|
54
|
+
onChange: function onChange(checked) {
|
|
55
|
+
_onChange && _onChange(item.key);
|
|
56
|
+
|
|
57
|
+
if (!('value' in props)) {
|
|
58
|
+
setCurrent(item.key);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, tagProps), item.content));
|
|
62
|
+
})));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
TagSelect.propTypes = {
|
|
66
|
+
onChange: _propTypes["default"].func,
|
|
67
|
+
value: _propTypes["default"].string,
|
|
68
|
+
defaultValue: _propTypes["default"].string,
|
|
69
|
+
dataSource: _propTypes["default"].array,
|
|
70
|
+
boxProps: _propTypes["default"].any
|
|
71
|
+
};
|
|
72
|
+
TagSelect.defaultProps = {
|
|
73
|
+
boxProps: {}
|
|
74
|
+
};
|
|
75
|
+
var _default = TagSelect;
|
|
76
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* write style here */
|
|
2
|
+
@import '@alifd/next/variables.scss';
|
|
3
|
+
.tag-select-wrap {
|
|
4
|
+
.tag-select-item {
|
|
5
|
+
text-align: -webkit-center;
|
|
6
|
+
.#{$css-prefix}tag {
|
|
7
|
+
height: auto;
|
|
8
|
+
line-height: 0;
|
|
9
|
+
&::before {
|
|
10
|
+
z-index: 1;
|
|
11
|
+
}
|
|
12
|
+
&::after {
|
|
13
|
+
z-index: 1;
|
|
14
|
+
}
|
|
15
|
+
.#{$css-prefix}tag-body {
|
|
16
|
+
width: 100%;
|
|
17
|
+
padding: 0;
|
|
18
|
+
.tag-select-img {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
.tag-select-label {
|
|
23
|
+
margin-top: 4px;
|
|
24
|
+
max-width: fit-content;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -11,7 +11,7 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
15
|
|
|
16
16
|
var _Icon = _interopRequireDefault(require("./Icon"));
|
|
17
17
|
|
|
@@ -20,8 +20,6 @@ var _indexModule = _interopRequireDefault(require("./index.module.scss"));
|
|
|
20
20
|
var _excluded = ["className", "children", "icon", "id", "selected", "onSelect", "size"];
|
|
21
21
|
|
|
22
22
|
var TemplateButton = function TemplateButton(props) {
|
|
23
|
-
var _classnames;
|
|
24
|
-
|
|
25
23
|
var className = props.className,
|
|
26
24
|
children = props.children,
|
|
27
25
|
icon = props.icon,
|
|
@@ -37,7 +35,18 @@ var TemplateButton = function TemplateButton(props) {
|
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
40
|
-
className: (0,
|
|
38
|
+
className: (0, _classnames["default"])(_indexModule["default"].card, className),
|
|
39
|
+
onClick: handleClick
|
|
40
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
41
|
+
className: _indexModule["default"].iconWrapper
|
|
42
|
+
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], (0, _extends2["default"])({
|
|
43
|
+
className: _indexModule["default"].icon,
|
|
44
|
+
type: icon
|
|
45
|
+
}, rest))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
46
|
+
className: _indexModule["default"].text
|
|
47
|
+
}, children));
|
|
48
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
49
|
+
className: (0, _classnames["default"])(_indexModule["default"].card, className),
|
|
41
50
|
onClick: handleClick
|
|
42
51
|
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], (0, _extends2["default"])({
|
|
43
52
|
className: _indexModule["default"].icon,
|
|
@@ -1,41 +1,28 @@
|
|
|
1
1
|
@import "@alifd/next/variables";
|
|
2
2
|
|
|
3
3
|
.card {
|
|
4
|
-
display:
|
|
4
|
+
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
border: 1px solid #c4c6cf;
|
|
9
|
-
width: 120px;
|
|
10
|
-
height: 136px;
|
|
11
|
-
background-color: #fff;
|
|
12
|
-
text-align: center;
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 100%;
|
|
13
8
|
cursor: pointer;
|
|
14
|
-
|
|
15
|
-
margin-right: 12px;
|
|
16
|
-
|
|
17
|
-
&:hover, &:focus, &.selected {
|
|
18
|
-
border-color: $color-brand1-5;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&.sizeNormal {
|
|
22
|
-
width: 120px;
|
|
23
|
-
height: 136px;
|
|
24
|
-
}
|
|
9
|
+
}
|
|
25
10
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
.iconWrapper {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex: 1;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
30
16
|
}
|
|
31
17
|
|
|
32
18
|
.icon {
|
|
33
|
-
width:
|
|
19
|
+
width: 120px;
|
|
34
20
|
}
|
|
35
21
|
|
|
36
22
|
.text {
|
|
37
|
-
font-size:
|
|
38
|
-
margin-top:
|
|
23
|
+
font-size: 18px;
|
|
24
|
+
margin-top: 16px;
|
|
25
|
+
padding-bottom: 24px;
|
|
39
26
|
color: $color-text1-3;
|
|
40
27
|
outline: none;
|
|
41
28
|
}
|