@nutui/nutui-react 1.4.1 → 1.4.2-beta.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # v1.4.2
2
+ `2023-01-04`
3
+
4
+ * :sparkles: feat: taro适配 sidenavbar 组件 (#558) @libin0824
5
+ * :bug: fix: input error 状态重置失效问题修改;校验格式 onBlur 失效问题修改 (#567) @vickyYe
6
+ * 🔨 chore: picker 组件删除无用的日志输出 (#566) @oasis-cloud
7
+
1
8
  # v1.4.1
2
9
  `2022-12-28`
3
10
 
package/README.md CHANGED
@@ -42,14 +42,14 @@
42
42
 
43
43
  ## Features
44
44
 
45
- * 🚀 60+ High Quality Components
46
- * 📖 Based on JD APP 10.0 Visual Specifications
45
+ * 🚀 70+ High Quality Components
46
+ * 📖 Based on JD APP 11.0 Visual Specifications
47
47
  * 🍭 Support Tree Shaking
48
48
  * 📖 Extensive Documentation and Demos
49
49
  * 💪 Written in TypeScript
50
50
  * 💪 Support SSR (Experimental)
51
51
  * 🍭 Support Custom Themes
52
- * 🍭 80%+ Unit Test Coverage
52
+ * 🍭 90%+ Unit Test Coverage
53
53
  * 📖 Provide Sketch Design Resources
54
54
 
55
55
 
@@ -148,4 +148,4 @@ NutUI follows [Angular Style Commit Message Conventions](https://gist.github.com
148
148
 
149
149
  ## Open Source License
150
150
 
151
- This project is based on **MIT** protocol
151
+ This project is based on **MIT** protocol
@@ -279,32 +279,34 @@ var CustomRender = function CustomRender(props) {
279
279
  if (modelValue.length > 0) {
280
280
  var tagIndex = 0;
281
281
  var selectedRegionC = selectedRegion && Object.assign(selectedRegion);
282
- for (var index = 0; index < modelValue.length; index++) {
282
+ var _loop = function _loop() {
283
283
  if (regionList[tabName[index]].length === 0) {
284
284
  tagIndex = index - 1;
285
285
  setTabIndex(index - 1);
286
- break;
286
+ return "break";
287
287
  } else {
288
- (function () {
289
- var val = modelValue[index];
290
- var arr = regionList[tabName[index]];
291
- if (privateType === 'custom') {
292
- selectedRegionC[[tabName[index]]] = arr.filter(function (item) {
293
- return item.id === val;
294
- })[0];
295
- } else if (privateType === 'custom2') {
296
- var sumArr = [];
297
- arr.forEach(function (item) {
298
- sumArr.push.apply(sumArr, _toConsumableArray(item.list));
299
- });
300
- selectedRegionC[[tabName[index]]] = sumArr.filter(function (item) {
301
- return item.id === val;
302
- })[0];
303
- }
304
- tagIndex = index;
305
- setSelectedRegion(selectedRegionC);
306
- })();
288
+ var val = modelValue[index];
289
+ var arr = regionList[tabName[index]];
290
+ if (privateType === 'custom') {
291
+ selectedRegionC[[tabName[index]]] = arr.filter(function (item) {
292
+ return item.id === val;
293
+ })[0];
294
+ } else if (privateType === 'custom2') {
295
+ var sumArr = [];
296
+ arr.forEach(function (item) {
297
+ sumArr.push.apply(sumArr, _toConsumableArray(item.list));
298
+ });
299
+ selectedRegionC[[tabName[index]]] = sumArr.filter(function (item) {
300
+ return item.id === val;
301
+ })[0];
302
+ }
303
+ tagIndex = index;
304
+ setSelectedRegion(selectedRegionC);
307
305
  }
306
+ };
307
+ for (var index = 0; index < modelValue.length; index++) {
308
+ var _ret = _loop();
309
+ if (_ret === "break") break;
308
310
  }
309
311
  setTabIndex(tagIndex);
310
312
  lineAnimation(tagIndex);
@@ -321,44 +321,42 @@ var InternalCascader = function InternalCascader(props) {
321
321
  var initData = /*#__PURE__*/function () {
322
322
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
323
323
  return _regeneratorRuntime.wrap(function _callee$(_context) {
324
- while (1) {
325
- switch (_context.prev = _context.next) {
326
- case 0:
327
- // 初始化开始处理数据
328
- state.lazyLoadMap.clear();
329
- if (convertConfig && Object.keys(convertConfig).length > 0) {
330
- state.optionsData = convertListToOptions(options, convertConfig);
331
- } else {
332
- state.optionsData = options;
333
- }
334
- state.tree = new Tree(state.optionsData, {
335
- value: state.configs.valueKey,
336
- text: state.configs.textKey,
337
- children: state.configs.childrenKey
338
- });
339
- if (!(isLazy() && !state.tree.nodes.length)) {
340
- _context.next = 6;
341
- break;
342
- }
324
+ while (1) switch (_context.prev = _context.next) {
325
+ case 0:
326
+ // 初始化开始处理数据
327
+ state.lazyLoadMap.clear();
328
+ if (convertConfig && Object.keys(convertConfig).length > 0) {
329
+ state.optionsData = convertListToOptions(options, convertConfig);
330
+ } else {
331
+ state.optionsData = options;
332
+ }
333
+ state.tree = new Tree(state.optionsData, {
334
+ value: state.configs.valueKey,
335
+ text: state.configs.textKey,
336
+ children: state.configs.childrenKey
337
+ });
338
+ if (!(isLazy() && !state.tree.nodes.length)) {
343
339
  _context.next = 6;
344
- return invokeLazyLoad({
345
- root: true,
346
- loading: true,
347
- text: '',
348
- value: ''
349
- });
350
- case 6:
351
- state.panes = [{
352
- nodes: state.tree.nodes,
353
- selectedNode: null,
354
- paneKey: 'c1'
355
- }];
356
- syncValue();
357
- setOptiosData(state.panes);
358
- case 9:
359
- case "end":
360
- return _context.stop();
361
- }
340
+ break;
341
+ }
342
+ _context.next = 6;
343
+ return invokeLazyLoad({
344
+ root: true,
345
+ loading: true,
346
+ text: '',
347
+ value: ''
348
+ });
349
+ case 6:
350
+ state.panes = [{
351
+ nodes: state.tree.nodes,
352
+ selectedNode: null,
353
+ paneKey: 'c1'
354
+ }];
355
+ syncValue();
356
+ setOptiosData(state.panes);
357
+ case 9:
358
+ case "end":
359
+ return _context.stop();
362
360
  }
363
361
  }, _callee);
364
362
  }));
@@ -371,92 +369,88 @@ var InternalCascader = function InternalCascader(props) {
371
369
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
372
370
  var currentValue, needToSync, parent, last, pathNodes;
373
371
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
374
- while (1) {
375
- switch (_context3.prev = _context3.next) {
376
- case 0:
377
- currentValue = state.innerValue;
378
- if (!(currentValue === undefined || !state.tree.nodes.length)) {
379
- _context3.next = 3;
380
- break;
381
- }
382
- return _context3.abrupt("return");
383
- case 3:
384
- if (!(currentValue.length === 0)) {
385
- _context3.next = 6;
386
- break;
387
- }
388
- state.tabsCursor = 0;
389
- // state.panes = [{ nodes: state.tree.nodes, selectedNode: null }];
390
- return _context3.abrupt("return");
391
- case 6:
392
- needToSync = currentValue;
393
- if (!(isLazy() && Array.isArray(currentValue) && currentValue.length)) {
394
- _context3.next = 19;
395
- break;
396
- }
397
- needToSync = [];
398
- parent = state.tree.nodes.find(function (node) {
399
- return node.value === currentValue[0];
400
- });
401
- if (!parent) {
402
- _context3.next = 19;
403
- break;
404
- }
405
- needToSync = [parent.value];
406
- state.initLoading = true;
407
- _context3.next = 15;
408
- return currentValue.slice(1).reduce( /*#__PURE__*/function () {
409
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(p, value) {
410
- var _parent$children;
411
- var parent, node;
412
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
413
- while (1) {
414
- switch (_context2.prev = _context2.next) {
415
- case 0:
416
- _context2.next = 2;
417
- return p;
418
- case 2:
419
- parent = _context2.sent;
420
- _context2.next = 5;
421
- return invokeLazyLoad(parent);
422
- case 5:
423
- node = parent === null || parent === void 0 ? void 0 : (_parent$children = parent.children) === null || _parent$children === void 0 ? void 0 : _parent$children.find(function (item) {
424
- return item.value === value;
425
- });
426
- if (node) {
427
- needToSync.push(value);
428
- }
429
- return _context2.abrupt("return", Promise.resolve(node));
430
- case 8:
431
- case "end":
432
- return _context2.stop();
372
+ while (1) switch (_context3.prev = _context3.next) {
373
+ case 0:
374
+ currentValue = state.innerValue;
375
+ if (!(currentValue === undefined || !state.tree.nodes.length)) {
376
+ _context3.next = 3;
377
+ break;
378
+ }
379
+ return _context3.abrupt("return");
380
+ case 3:
381
+ if (!(currentValue.length === 0)) {
382
+ _context3.next = 6;
383
+ break;
384
+ }
385
+ state.tabsCursor = 0;
386
+ // state.panes = [{ nodes: state.tree.nodes, selectedNode: null }];
387
+ return _context3.abrupt("return");
388
+ case 6:
389
+ needToSync = currentValue;
390
+ if (!(isLazy() && Array.isArray(currentValue) && currentValue.length)) {
391
+ _context3.next = 19;
392
+ break;
393
+ }
394
+ needToSync = [];
395
+ parent = state.tree.nodes.find(function (node) {
396
+ return node.value === currentValue[0];
397
+ });
398
+ if (!parent) {
399
+ _context3.next = 19;
400
+ break;
401
+ }
402
+ needToSync = [parent.value];
403
+ state.initLoading = true;
404
+ _context3.next = 15;
405
+ return currentValue.slice(1).reduce( /*#__PURE__*/function () {
406
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(p, value) {
407
+ var _parent$children;
408
+ var parent, node;
409
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
410
+ while (1) switch (_context2.prev = _context2.next) {
411
+ case 0:
412
+ _context2.next = 2;
413
+ return p;
414
+ case 2:
415
+ parent = _context2.sent;
416
+ _context2.next = 5;
417
+ return invokeLazyLoad(parent);
418
+ case 5:
419
+ node = parent === null || parent === void 0 ? void 0 : (_parent$children = parent.children) === null || _parent$children === void 0 ? void 0 : _parent$children.find(function (item) {
420
+ return item.value === value;
421
+ });
422
+ if (node) {
423
+ needToSync.push(value);
433
424
  }
434
- }
435
- }, _callee2);
436
- }));
437
- return function (_x, _x2) {
438
- return _ref3.apply(this, arguments);
439
- };
440
- }(), Promise.resolve(parent));
441
- case 15:
442
- last = _context3.sent;
443
- _context3.next = 18;
444
- return invokeLazyLoad(last);
445
- case 18:
446
- state.initLoading = false;
447
- case 19:
448
- if (needToSync.length && currentValue === value) {
449
- pathNodes = state.tree.getPathNodesByValue(needToSync);
450
- pathNodes.forEach(function (node, index) {
451
- state.tabsCursor = index;
452
- // 当有默认值时,不触发 chooseItem 里的 emit 事件
453
- _chooseItem(node, true);
454
- });
455
- }
456
- case 20:
457
- case "end":
458
- return _context3.stop();
459
- }
425
+ return _context2.abrupt("return", Promise.resolve(node));
426
+ case 8:
427
+ case "end":
428
+ return _context2.stop();
429
+ }
430
+ }, _callee2);
431
+ }));
432
+ return function (_x, _x2) {
433
+ return _ref3.apply(this, arguments);
434
+ };
435
+ }(), Promise.resolve(parent));
436
+ case 15:
437
+ last = _context3.sent;
438
+ _context3.next = 18;
439
+ return invokeLazyLoad(last);
440
+ case 18:
441
+ state.initLoading = false;
442
+ case 19:
443
+ if (needToSync.length && currentValue === value) {
444
+ pathNodes = state.tree.getPathNodesByValue(needToSync);
445
+ pathNodes.forEach(function (node, index) {
446
+ state.tabsCursor = index;
447
+ // 当有默认值时,不触发 chooseItem 里的 emit 事件
448
+ _chooseItem(node, true);
449
+ });
450
+ }
451
+ case 20:
452
+ case "end":
453
+ return _context3.stop();
460
454
  }
461
455
  }, _callee3);
462
456
  }));
@@ -468,55 +462,53 @@ var InternalCascader = function InternalCascader(props) {
468
462
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(node) {
469
463
  var parent, lazyLoadPromise, nodes;
470
464
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
471
- while (1) {
472
- switch (_context4.prev = _context4.next) {
473
- case 0:
474
- if (node) {
475
- _context4.next = 2;
476
- break;
477
- }
478
- return _context4.abrupt("return");
479
- case 2:
480
- if (state.configs.lazyLoad) {
481
- _context4.next = 5;
482
- break;
483
- }
465
+ while (1) switch (_context4.prev = _context4.next) {
466
+ case 0:
467
+ if (node) {
468
+ _context4.next = 2;
469
+ break;
470
+ }
471
+ return _context4.abrupt("return");
472
+ case 2:
473
+ if (state.configs.lazyLoad) {
474
+ _context4.next = 5;
475
+ break;
476
+ }
477
+ node.leaf = true;
478
+ return _context4.abrupt("return");
479
+ case 5:
480
+ if (!(state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy()))) {
481
+ _context4.next = 7;
482
+ break;
483
+ }
484
+ return _context4.abrupt("return");
485
+ case 7:
486
+ node.loading = true;
487
+ parent = node.root ? null : node;
488
+ lazyLoadPromise = state.lazyLoadMap.get(node);
489
+ if (!lazyLoadPromise) {
490
+ lazyLoadPromise = new Promise(function (resolve) {
491
+ var _state$configs$lazyLo, _state$configs;
492
+ // 外部必须resolve
493
+ (_state$configs$lazyLo = (_state$configs = state.configs).lazyLoad) === null || _state$configs$lazyLo === void 0 ? void 0 : _state$configs$lazyLo.call(_state$configs, node, resolve);
494
+ });
495
+ state.lazyLoadMap.set(node, lazyLoadPromise);
496
+ }
497
+ _context4.next = 13;
498
+ return lazyLoadPromise;
499
+ case 13:
500
+ nodes = _context4.sent;
501
+ if (Array.isArray(nodes) && nodes.length > 0) {
502
+ state.tree.updateChildren(nodes, parent);
503
+ } else {
504
+ // 如果加载完成后没有提供子节点,作为叶子节点处理
484
505
  node.leaf = true;
485
- return _context4.abrupt("return");
486
- case 5:
487
- if (!(state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy()))) {
488
- _context4.next = 7;
489
- break;
490
- }
491
- return _context4.abrupt("return");
492
- case 7:
493
- node.loading = true;
494
- parent = node.root ? null : node;
495
- lazyLoadPromise = state.lazyLoadMap.get(node);
496
- if (!lazyLoadPromise) {
497
- lazyLoadPromise = new Promise(function (resolve) {
498
- var _state$configs$lazyLo, _state$configs;
499
- // 外部必须resolve
500
- (_state$configs$lazyLo = (_state$configs = state.configs).lazyLoad) === null || _state$configs$lazyLo === void 0 ? void 0 : _state$configs$lazyLo.call(_state$configs, node, resolve);
501
- });
502
- state.lazyLoadMap.set(node, lazyLoadPromise);
503
- }
504
- _context4.next = 13;
505
- return lazyLoadPromise;
506
- case 13:
507
- nodes = _context4.sent;
508
- if (Array.isArray(nodes) && nodes.length > 0) {
509
- state.tree.updateChildren(nodes, parent);
510
- } else {
511
- // 如果加载完成后没有提供子节点,作为叶子节点处理
512
- node.leaf = true;
513
- }
514
- node.loading = false;
515
- state.lazyLoadMap["delete"](node);
516
- case 17:
517
- case "end":
518
- return _context4.stop();
519
- }
506
+ }
507
+ node.loading = false;
508
+ state.lazyLoadMap["delete"](node);
509
+ case 17:
510
+ case "end":
511
+ return _context4.stop();
520
512
  }
521
513
  }, _callee4);
522
514
  }));
@@ -536,81 +528,79 @@ var InternalCascader = function InternalCascader(props) {
536
528
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(node, type) {
537
529
  var pathNodes, optionParams, level, _pathNodes, _optionParams;
538
530
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
539
- while (1) {
540
- switch (_context5.prev = _context5.next) {
541
- case 0:
542
- if (!(!type && node.disabled || !state.panes[state.tabsCursor])) {
543
- _context5.next = 2;
544
- break;
545
- }
546
- return _context5.abrupt("return");
547
- case 2:
548
- if (!state.tree.isLeaf(node, isLazy())) {
549
- _context5.next = 10;
550
- break;
551
- }
552
- node.leaf = true;
553
- state.panes[state.tabsCursor].selectedNode = node;
554
- state.panes = state.panes.slice(0, node.level + 1);
555
- if (!type) {
556
- pathNodes = state.panes.map(function (item) {
557
- return item.selectedNode;
558
- });
559
- optionParams = pathNodes.map(function (item) {
560
- return item.value;
561
- });
562
- onChange(optionParams, pathNodes);
563
- onPathChange(optionParams, pathNodes);
564
- }
565
- setOptiosData(state.panes);
566
- close();
567
- return _context5.abrupt("return");
568
- case 10:
569
- if (!state.tree.hasChildren(node, isLazy())) {
570
- _context5.next = 20;
571
- break;
572
- }
573
- level = node.level + 1;
574
- state.panes[state.tabsCursor].selectedNode = node;
575
- state.panes = state.panes.slice(0, level);
576
- state.tabsCursor = level;
577
- state.panes.push({
578
- nodes: node.children || [],
579
- selectedNode: null,
580
- paneKey: "c".concat(state.tabsCursor + 1)
531
+ while (1) switch (_context5.prev = _context5.next) {
532
+ case 0:
533
+ if (!(!type && node.disabled || !state.panes[state.tabsCursor])) {
534
+ _context5.next = 2;
535
+ break;
536
+ }
537
+ return _context5.abrupt("return");
538
+ case 2:
539
+ if (!state.tree.isLeaf(node, isLazy())) {
540
+ _context5.next = 10;
541
+ break;
542
+ }
543
+ node.leaf = true;
544
+ state.panes[state.tabsCursor].selectedNode = node;
545
+ state.panes = state.panes.slice(0, node.level + 1);
546
+ if (!type) {
547
+ pathNodes = state.panes.map(function (item) {
548
+ return item.selectedNode;
581
549
  });
582
- setTabvalue("c".concat(state.tabsCursor + 1));
583
- setOptiosData(state.panes);
584
- if (!type) {
585
- _pathNodes = state.panes.map(function (item) {
586
- return item.selectedNode;
587
- });
588
- _optionParams = _pathNodes.map(function (item) {
589
- return item === null || item === void 0 ? void 0 : item.value;
590
- });
591
- onPathChange(_optionParams, _pathNodes);
592
- }
593
- return _context5.abrupt("return");
594
- case 20:
595
- state.currentProcessNode = node;
596
- if (!node.loading) {
597
- _context5.next = 23;
598
- break;
599
- }
600
- return _context5.abrupt("return");
601
- case 23:
602
- _context5.next = 25;
603
- return invokeLazyLoad(node);
604
- case 25:
605
- if (state.currentProcessNode === node) {
606
- state.panes[state.tabsCursor].selectedNode = node;
607
- _chooseItem(node, type);
608
- }
609
- setOptiosData(state.panes);
610
- case 27:
611
- case "end":
612
- return _context5.stop();
613
- }
550
+ optionParams = pathNodes.map(function (item) {
551
+ return item.value;
552
+ });
553
+ onChange(optionParams, pathNodes);
554
+ onPathChange(optionParams, pathNodes);
555
+ }
556
+ setOptiosData(state.panes);
557
+ close();
558
+ return _context5.abrupt("return");
559
+ case 10:
560
+ if (!state.tree.hasChildren(node, isLazy())) {
561
+ _context5.next = 20;
562
+ break;
563
+ }
564
+ level = node.level + 1;
565
+ state.panes[state.tabsCursor].selectedNode = node;
566
+ state.panes = state.panes.slice(0, level);
567
+ state.tabsCursor = level;
568
+ state.panes.push({
569
+ nodes: node.children || [],
570
+ selectedNode: null,
571
+ paneKey: "c".concat(state.tabsCursor + 1)
572
+ });
573
+ setTabvalue("c".concat(state.tabsCursor + 1));
574
+ setOptiosData(state.panes);
575
+ if (!type) {
576
+ _pathNodes = state.panes.map(function (item) {
577
+ return item.selectedNode;
578
+ });
579
+ _optionParams = _pathNodes.map(function (item) {
580
+ return item === null || item === void 0 ? void 0 : item.value;
581
+ });
582
+ onPathChange(_optionParams, _pathNodes);
583
+ }
584
+ return _context5.abrupt("return");
585
+ case 20:
586
+ state.currentProcessNode = node;
587
+ if (!node.loading) {
588
+ _context5.next = 23;
589
+ break;
590
+ }
591
+ return _context5.abrupt("return");
592
+ case 23:
593
+ _context5.next = 25;
594
+ return invokeLazyLoad(node);
595
+ case 25:
596
+ if (state.currentProcessNode === node) {
597
+ state.panes[state.tabsCursor].selectedNode = node;
598
+ _chooseItem(node, type);
599
+ }
600
+ setOptiosData(state.panes);
601
+ case 27:
602
+ case "end":
603
+ return _context5.stop();
614
604
  }
615
605
  }, _callee5);
616
606
  }));