@autobest-ui/components 1.1.2 → 1.1.9

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 (126) hide show
  1. package/README.md +10 -10
  2. package/esm/accordion/__stories__/style.scss +58 -58
  3. package/esm/affix/__stories__/style.scss +13 -13
  4. package/esm/affix/style/index.scss +34 -34
  5. package/esm/base.scss +42 -42
  6. package/esm/carousel/__stories__/style.scss +41 -41
  7. package/esm/carousel/style/index.scss +37 -37
  8. package/esm/checkbox/style/index.scss +117 -117
  9. package/esm/collapse/__stories__/style.scss +18 -18
  10. package/esm/collapse/style/index.scss +42 -42
  11. package/esm/confirm/style/index.scss +44 -44
  12. package/esm/date-picker/calendar/grid/index.scss +85 -85
  13. package/esm/date-picker/calendar/index.scss +57 -57
  14. package/esm/date-picker/index.d.ts +1 -0
  15. package/esm/date-picker/index.js +17 -7
  16. package/esm/date-picker/style/index.css +1 -1
  17. package/esm/date-picker/style/index.scss +23 -19
  18. package/esm/drawer/style/index.scss +44 -44
  19. package/esm/ellipsis/style/index.scss +35 -35
  20. package/esm/guide/__stories__/style.scss +13 -13
  21. package/esm/guide/style/index.scss +17 -17
  22. package/esm/icon/__stories__/style.scss +39 -39
  23. package/esm/icon/style/index.scss +6 -6
  24. package/esm/index.d.ts +2 -1
  25. package/esm/input-number/index.d.ts +30 -17
  26. package/esm/input-number/index.js +116 -36
  27. package/esm/input-number/style/index.scss +86 -86
  28. package/esm/lazy-image/__stories__/style.scss +9 -9
  29. package/esm/lazy-image/style/index.scss +24 -24
  30. package/esm/link-list/style/index.scss +125 -125
  31. package/esm/loading/style/index.scss +30 -30
  32. package/esm/loading-bar/style/index.scss +62 -62
  33. package/esm/loading-container/__stories__/style.scss +5 -5
  34. package/esm/loading-container/style/index.scss +27 -27
  35. package/esm/loading-icon/style/index.scss +23 -23
  36. package/esm/mask/style/index.scss +34 -34
  37. package/esm/message/style/index.scss +70 -70
  38. package/esm/modal/style/index.scss +112 -112
  39. package/esm/move/__stories__/style.scss +6 -6
  40. package/esm/move/style/index.scss +7 -7
  41. package/esm/popover/__stories__/style.scss +15 -15
  42. package/esm/popover/style/index.scss +59 -59
  43. package/esm/select/__stories__/style.scss +8 -8
  44. package/esm/select/style/index.scss +126 -126
  45. package/esm/show-more/style/index.scss +22 -22
  46. package/esm/skeleton/__stories__/style.scss +2 -2
  47. package/esm/skeleton/style/index.scss +26 -26
  48. package/esm/style.css +16 -16
  49. package/esm/table/__stories__/style.scss +33 -33
  50. package/esm/table/body/BodyRow.d.ts +9 -3
  51. package/esm/table/body/BodyRow.js +6 -2
  52. package/esm/table/body/index.d.ts +2 -2
  53. package/esm/table/body/index.js +8 -7
  54. package/esm/table/header/HeaderCell.d.ts +2 -2
  55. package/esm/table/header/HeaderRow.d.ts +2 -2
  56. package/esm/table/index.d.ts +4 -4
  57. package/esm/table/index.js +3 -3
  58. package/esm/table/interface.d.ts +9 -3
  59. package/esm/table/style/index.scss +51 -51
  60. package/esm/tabs/__stories__/style.scss +8 -8
  61. package/esm/tabs/style/index.scss +62 -62
  62. package/esm/tooltip/style/index.scss +61 -61
  63. package/esm/trigger/style/index.scss +79 -79
  64. package/lib/accordion/__stories__/style.scss +58 -58
  65. package/lib/affix/__stories__/style.scss +13 -13
  66. package/lib/affix/style/index.scss +34 -34
  67. package/lib/base.scss +42 -42
  68. package/lib/carousel/__stories__/style.scss +41 -41
  69. package/lib/carousel/style/index.scss +37 -37
  70. package/lib/checkbox/style/index.scss +117 -117
  71. package/lib/collapse/__stories__/style.scss +18 -18
  72. package/lib/collapse/style/index.scss +42 -42
  73. package/lib/confirm/style/index.scss +44 -44
  74. package/lib/date-picker/calendar/grid/index.scss +85 -85
  75. package/lib/date-picker/calendar/index.scss +57 -57
  76. package/lib/date-picker/index.d.ts +1 -0
  77. package/lib/date-picker/index.js +17 -7
  78. package/lib/date-picker/style/index.css +1 -1
  79. package/lib/date-picker/style/index.scss +23 -19
  80. package/lib/drawer/style/index.scss +44 -44
  81. package/lib/ellipsis/style/index.scss +35 -35
  82. package/lib/guide/__stories__/style.scss +13 -13
  83. package/lib/guide/style/index.scss +17 -17
  84. package/lib/icon/__stories__/style.scss +39 -39
  85. package/lib/icon/style/index.scss +6 -6
  86. package/lib/index.d.ts +2 -1
  87. package/lib/input-number/index.d.ts +30 -17
  88. package/lib/input-number/index.js +116 -36
  89. package/lib/input-number/style/index.scss +86 -86
  90. package/lib/lazy-image/__stories__/style.scss +9 -9
  91. package/lib/lazy-image/style/index.scss +24 -24
  92. package/lib/link-list/style/index.scss +125 -125
  93. package/lib/loading/style/index.scss +30 -30
  94. package/lib/loading-bar/style/index.scss +62 -62
  95. package/lib/loading-container/__stories__/style.scss +5 -5
  96. package/lib/loading-container/style/index.scss +27 -27
  97. package/lib/loading-icon/style/index.scss +23 -23
  98. package/lib/mask/style/index.scss +34 -34
  99. package/lib/message/style/index.scss +70 -70
  100. package/lib/modal/style/index.scss +112 -112
  101. package/lib/move/__stories__/style.scss +6 -6
  102. package/lib/move/style/index.scss +7 -7
  103. package/lib/popover/__stories__/style.scss +15 -15
  104. package/lib/popover/style/index.scss +59 -59
  105. package/lib/select/__stories__/style.scss +8 -8
  106. package/lib/select/style/index.scss +126 -126
  107. package/lib/show-more/style/index.scss +22 -22
  108. package/lib/skeleton/__stories__/style.scss +2 -2
  109. package/lib/skeleton/style/index.scss +26 -26
  110. package/lib/style.css +16 -16
  111. package/lib/table/__stories__/style.scss +33 -33
  112. package/lib/table/body/BodyRow.d.ts +9 -3
  113. package/lib/table/body/BodyRow.js +6 -2
  114. package/lib/table/body/index.d.ts +2 -2
  115. package/lib/table/body/index.js +8 -7
  116. package/lib/table/header/HeaderCell.d.ts +2 -2
  117. package/lib/table/header/HeaderRow.d.ts +2 -2
  118. package/lib/table/index.d.ts +4 -4
  119. package/lib/table/index.js +3 -3
  120. package/lib/table/interface.d.ts +9 -3
  121. package/lib/table/style/index.scss +51 -51
  122. package/lib/tabs/__stories__/style.scss +8 -8
  123. package/lib/tabs/style/index.scss +62 -62
  124. package/lib/tooltip/style/index.scss +61 -61
  125. package/lib/trigger/style/index.scss +79 -79
  126. package/package.json +2 -2
@@ -43,7 +43,7 @@ var __assign = this && this.__assign || function () {
43
43
  import React from 'react';
44
44
  import classNames from 'classnames';
45
45
  import { isBlank, debounce, getOffsetAndSize, addEventListener } from '@autobest-ui/utils';
46
- var cls = 'ab-input-number';
46
+ var cls = 'ab-input-number'; // TODO: 重构组件
47
47
 
48
48
  var InputNumber =
49
49
  /** @class */
@@ -305,6 +305,19 @@ function (_super) {
305
305
  return ceilNumber;
306
306
  };
307
307
 
308
+ _this.getPadDigitalValue = function (value) {
309
+ var _a = _this.props,
310
+ digital = _a.digital,
311
+ padDigital = _a.padDigital;
312
+
313
+ if (!padDigital || isBlank(value) || !digital) {
314
+ return value;
315
+ }
316
+
317
+ var resultArr = value.split('.');
318
+ return resultArr[0] + "." + (resultArr[1] || '').padEnd(digital, '0');
319
+ };
320
+
308
321
  _this.onChangePackMultipleValue = function (value) {
309
322
  var currentValue = _this.getCurrentValue(value).toString();
310
323
 
@@ -319,60 +332,97 @@ function (_super) {
319
332
  }
320
333
  };
321
334
 
322
- _this.getDebounce = function () {
323
- if (_this.debounce) {
324
- return _this.debounce;
335
+ _this.onPadDigital = function (value) {
336
+ var currentValue = _this.getPadDigitalValue(value);
337
+
338
+ var _a = _this.props,
339
+ onChange = _a.onChange,
340
+ name = _a.name;
341
+
342
+ if (value !== currentValue) {
343
+ onChange(currentValue, name);
325
344
  }
345
+ };
346
+
347
+ _this.getPadDigitalDebounce = function () {
348
+ if (_this.padDigitalDebounce) {
349
+ return _this.padDigitalDebounce;
350
+ }
351
+
352
+ _this.padDigitalDebounce = debounce(_this.onPadDigital, _this.props.delay);
353
+ return _this.padDigitalDebounce;
354
+ };
326
355
 
327
- _this.debounce = debounce(_this.onChangePackMultipleValue, _this.props.delay);
328
- return _this.debounce;
356
+ _this.getChangePackMultipleValueDebounce = function () {
357
+ if (_this.changePackMultipleValueDebounce) {
358
+ return _this.changePackMultipleValueDebounce;
359
+ }
360
+
361
+ _this.changePackMultipleValueDebounce = debounce(_this.onChangePackMultipleValue, _this.props.delay);
362
+ return _this.changePackMultipleValueDebounce;
329
363
  };
330
364
 
331
- _this.callback = function (value) {
365
+ _this.callback = function (value, ignoreDelay) {
332
366
  var _a = _this.props,
333
367
  name = _a.name,
334
368
  onChange = _a.onChange,
335
- onChangePackMultipleBefore = _a.onChangePackMultipleBefore;
336
- var packMultiple = _this.props.packMultiple || 1;
369
+ onChangePackMultipleBefore = _a.onChangePackMultipleBefore,
370
+ packMultiple = _a.packMultiple,
371
+ padDigital = _a.padDigital;
337
372
 
338
- if (onChange) {
373
+ if (onChange && value !== _this.props.value) {
339
374
  onChange(value, name);
340
375
  }
341
376
 
342
- var valueNumber = parseFloat(value);
343
-
344
- if (!isBlank(packMultiple) && !isBlank(value) && valueNumber % packMultiple !== 0) {
377
+ if (packMultiple && !isBlank(value) && parseFloat(value) % packMultiple !== 0) {
345
378
  if (onChangePackMultipleBefore) {
346
379
  onChangePackMultipleBefore(value, name);
347
380
  }
348
381
 
349
- _this.getDebounce()(value);
382
+ if (ignoreDelay) {
383
+ _this.onChangePackMultipleValue(value);
384
+ } else {
385
+ _this.getChangePackMultipleValueDebounce()(value);
386
+ }
387
+
388
+ return;
389
+ }
390
+
391
+ if (padDigital) {
392
+ if (ignoreDelay) {
393
+ _this.onPadDigital(value);
394
+
395
+ return;
396
+ }
397
+
398
+ _this.getPadDigitalDebounce()(value);
350
399
  }
351
400
  };
352
401
 
353
- _this.onValueChange = function (ev) {
354
- if (_this.debounce) {
355
- _this.debounce.cancel();
402
+ _this.onValueChange = function (ev, ignoreDelay) {
403
+ if (_this.changePackMultipleValueDebounce) {
404
+ _this.changePackMultipleValueDebounce.cancel();
356
405
  }
357
406
 
358
407
  var _a = _this.props,
359
408
  min = _a.min,
360
409
  max = _a.max,
361
- isPositive = _a.isPositive,
410
+ digital = _a.digital,
362
411
  value = _a.value;
363
- var currentValue = ev.target.value.toString();
412
+ var currentValue = ev.target.value.toString(); // 输入为空
364
413
 
365
414
  if (isBlank(currentValue)) {
366
- _this.callback('');
415
+ _this.callback('', ignoreDelay);
367
416
 
368
417
  return;
369
418
  }
370
419
 
371
- var preValue = value.toString();
420
+ var preValue = value.toString(); // 输入的不是数字格式
421
+
372
422
  var reg = /^-$|(^(-?\d+)(\.\d*)?)$/;
373
423
 
374
424
  if (!reg.test(currentValue)) {
375
- _this.callback(preValue);
425
+ _this.callback(preValue, ignoreDelay);
376
426
 
377
427
  return;
378
428
  } // 0开头后面直接是数字,没有点如:011, 这是不合法的
@@ -381,41 +431,59 @@ function (_super) {
381
431
  var zeroReg = /^0\d+$/;
382
432
 
383
433
  if (zeroReg.test(currentValue)) {
384
- _this.callback(preValue);
434
+ _this.callback(preValue, ignoreDelay);
385
435
 
386
436
  return;
437
+ } // 小数位数限制
438
+
439
+
440
+ if (digital) {
441
+ currentValue = new RegExp("[^.]+([.](\\d{0," + digital + "}))?").exec(currentValue)[0].toString();
387
442
  }
388
443
 
389
444
  var valueNumber = parseFloat(currentValue);
390
445
 
391
446
  if (!isBlank(min)) {
392
447
  if (min > valueNumber) {
393
- _this.callback(preValue);
448
+ _this.callback(preValue, ignoreDelay);
394
449
 
395
450
  return;
396
451
  } // 如果min>= 0, 将阻止输入-
397
452
 
398
453
 
399
454
  if (min >= 0 && currentValue.indexOf('-') > -1) {
400
- _this.callback('');
455
+ _this.callback('', ignoreDelay);
401
456
 
402
457
  return;
403
458
  }
404
459
  }
405
460
 
406
461
  if (!isBlank(max) && max < valueNumber) {
407
- _this.callback(preValue);
462
+ _this.callback(preValue, ignoreDelay);
408
463
 
409
464
  return;
410
465
  }
411
466
 
412
- if (isPositive && currentValue.indexOf('.') > -1) {
413
- _this.callback(preValue);
467
+ if (!digital && currentValue.indexOf('.') > -1) {
468
+ _this.callback(preValue, ignoreDelay);
414
469
 
415
470
  return;
416
471
  }
417
472
 
418
- _this.callback(currentValue);
473
+ _this.callback(currentValue, ignoreDelay);
474
+ };
475
+
476
+ _this.getValueCalculate = function (value, offset) {
477
+ var valueStr = value.toString();
478
+ var offsetStr = offset.toString();
479
+
480
+ if (valueStr.indexOf('.') < 0 && offsetStr.indexOf('.') < 0) {
481
+ return value + offset;
482
+ }
483
+
484
+ var digital = _this.props.digital;
485
+ var powValue = Math.pow(10, digital);
486
+ return Math.round((value + offset) * powValue) / powValue;
419
487
  };
420
488
 
421
489
  _this.onAdd = function () {
@@ -426,7 +494,7 @@ function (_super) {
426
494
 
427
495
  var ev = {
428
496
  target: {
429
- value: (parseFloat(value.toString()) || 0) + step
497
+ value: _this.getPadDigitalValue(_this.getValueCalculate(Number(value), step).toString())
430
498
  }
431
499
  };
432
500
 
@@ -440,7 +508,7 @@ function (_super) {
440
508
  var step = packMultiple || 1;
441
509
  var ev = {
442
510
  target: {
443
- value: (parseFloat(value.toString()) || 0) - step
511
+ value: _this.getPadDigitalValue(_this.getValueCalculate(Number(value), step * -1).toString())
444
512
  }
445
513
  };
446
514
 
@@ -473,6 +541,11 @@ function (_super) {
473
541
 
474
542
  InputNumber.prototype.componentDidMount = function () {
475
543
  this.addMouseMoveListener();
544
+ this.onValueChange({
545
+ target: {
546
+ value: this.props.value
547
+ }
548
+ }, true);
476
549
  };
477
550
 
478
551
  InputNumber.prototype.componentWillUnmount = function () {
@@ -486,9 +559,14 @@ function (_super) {
486
559
  this.mouseMoveHandler = null;
487
560
  }
488
561
 
489
- if (this.debounce) {
490
- this.debounce.cancel();
491
- this.debounce = null;
562
+ if (this.padDigitalDebounce) {
563
+ this.padDigitalDebounce.cancel();
564
+ this.padDigitalDebounce = null;
565
+ }
566
+
567
+ if (this.changePackMultipleValueDebounce) {
568
+ this.changePackMultipleValueDebounce.cancel();
569
+ this.changePackMultipleValueDebounce = null;
492
570
  }
493
571
  };
494
572
 
@@ -497,7 +575,8 @@ function (_super) {
497
575
 
498
576
  delete copyProps.onChangePackMultipleBefore;
499
577
  delete copyProps.onChangePackMultipleAfter;
500
- delete copyProps.isPositive;
578
+ delete copyProps.digital;
579
+ delete copyProps.padDigital;
501
580
  delete copyProps.packMultiple;
502
581
  delete copyProps.visibleButton;
503
582
  delete copyProps.onChange;
@@ -539,7 +618,8 @@ function (_super) {
539
618
  name: '',
540
619
  size: 3,
541
620
  disabled: false,
542
- isPositive: true,
621
+ digital: 0,
622
+ padDigital: false,
543
623
  delay: 1000,
544
624
  visibleButton: false
545
625
  };
@@ -1,87 +1,87 @@
1
- $namespace: ab-input-number;
2
-
3
- .#{$namespace} {
4
- padding: .06rem .07rem;
5
- -webkit-appearance: none;
6
- outline: none;
7
- width: 100%;
8
- border: 1px solid #ccc;
9
- border-radius: 2px;
10
- resize: none;
11
- font-size: .12rem;
12
- transition: all .3s;
13
- position: relative;
14
- background-color: transparent;
15
- z-index: 2;
16
-
17
- &:focus {
18
- box-shadow: 0 0 4px rgba(#348FEE, 0.8);
19
- border-color: rgba(#348FEE, 0.8);
20
- }
21
-
22
- &-wrap {
23
- position: relative;
24
- background-color: #fff;
25
- display: inline-block;
26
- }
27
-
28
- &-button-wrap {
29
- position: absolute;
30
- user-select: none;
31
- top: 50%;
32
- transform: translateY(-50%);
33
- right: .02rem;
34
- }
35
-
36
- &-button {
37
- position: relative;
38
- width: .16rem;
39
- height: .1rem;
40
- overflow: hidden;
41
- background-color: #f1f1f1;
42
- &.#{$namespace}-hover {
43
- background-color: #d0d0d0;
44
- }
45
- &.#{$namespace}-active {
46
- background-color: #787878;
47
- .#{$namespace}-add {
48
- border-bottom-color: #fff;
49
- }
50
- .#{$namespace}-sub {
51
- border-top-color: #fff;
52
- }
53
- }
54
-
55
- &:first-child {
56
- margin-bottom: .02rem;
57
- }
58
- }
59
-
60
- &-add {
61
- position: absolute;
62
- top: -.01rem;
63
- left: .04rem;
64
- display: block;
65
- border-top-color: transparent;
66
- border-right-color: transparent;
67
- border-bottom-color: #505050;
68
- border-left-color: transparent;
69
- border-width: .04rem;
70
- border-style: solid;
71
- width: 0;
72
- height: 0;
73
- }
74
-
75
- &-sub {
76
- display: block;
77
- margin: .03rem 0 0 .04rem;
78
- border-top-color: #505050;
79
- border-right-color: transparent;
80
- border-bottom-color: transparent;
81
- border-left-color: transparent;
82
- border-width: .04rem;
83
- border-style: solid;
84
- width: 0;
85
- height: 0;
86
- }
1
+ $namespace: ab-input-number;
2
+
3
+ .#{$namespace} {
4
+ padding: .06rem .07rem;
5
+ -webkit-appearance: none;
6
+ outline: none;
7
+ width: 100%;
8
+ border: 1px solid #ccc;
9
+ border-radius: 2px;
10
+ resize: none;
11
+ font-size: .12rem;
12
+ transition: all .3s;
13
+ position: relative;
14
+ background-color: transparent;
15
+ z-index: 2;
16
+
17
+ &:focus {
18
+ box-shadow: 0 0 4px rgba(#348FEE, 0.8);
19
+ border-color: rgba(#348FEE, 0.8);
20
+ }
21
+
22
+ &-wrap {
23
+ position: relative;
24
+ background-color: #fff;
25
+ display: inline-block;
26
+ }
27
+
28
+ &-button-wrap {
29
+ position: absolute;
30
+ user-select: none;
31
+ top: 50%;
32
+ transform: translateY(-50%);
33
+ right: .02rem;
34
+ }
35
+
36
+ &-button {
37
+ position: relative;
38
+ width: .16rem;
39
+ height: .1rem;
40
+ overflow: hidden;
41
+ background-color: #f1f1f1;
42
+ &.#{$namespace}-hover {
43
+ background-color: #d0d0d0;
44
+ }
45
+ &.#{$namespace}-active {
46
+ background-color: #787878;
47
+ .#{$namespace}-add {
48
+ border-bottom-color: #fff;
49
+ }
50
+ .#{$namespace}-sub {
51
+ border-top-color: #fff;
52
+ }
53
+ }
54
+
55
+ &:first-child {
56
+ margin-bottom: .02rem;
57
+ }
58
+ }
59
+
60
+ &-add {
61
+ position: absolute;
62
+ top: -.01rem;
63
+ left: .04rem;
64
+ display: block;
65
+ border-top-color: transparent;
66
+ border-right-color: transparent;
67
+ border-bottom-color: #505050;
68
+ border-left-color: transparent;
69
+ border-width: .04rem;
70
+ border-style: solid;
71
+ width: 0;
72
+ height: 0;
73
+ }
74
+
75
+ &-sub {
76
+ display: block;
77
+ margin: .03rem 0 0 .04rem;
78
+ border-top-color: #505050;
79
+ border-right-color: transparent;
80
+ border-bottom-color: transparent;
81
+ border-left-color: transparent;
82
+ border-width: .04rem;
83
+ border-style: solid;
84
+ width: 0;
85
+ height: 0;
86
+ }
87
87
  }
@@ -1,9 +1,9 @@
1
- .lazy-image-demo {
2
- margin-top: 200vh;
3
-
4
- img {
5
- display: block;
6
- width: 400px;
7
- margin: .2rem;
8
- }
9
- }
1
+ .lazy-image-demo {
2
+ margin-top: 200vh;
3
+
4
+ img {
5
+ display: block;
6
+ width: 400px;
7
+ margin: .2rem;
8
+ }
9
+ }
@@ -1,25 +1,25 @@
1
- $namespace: ab-lazy-image;
2
-
3
- .#{$namespace} {
4
- transition: opacity 500ms;
5
-
6
- &-loading {
7
- background: #f2f2f2;
8
- overflow: hidden;
9
- }
10
-
11
- &-loading.#{$namespace}-active {
12
- background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
13
- background-size: 400% 100%;
14
- animation: ab-skeleton-loading 1.4s ease infinite;
15
- }
16
-
17
- @keyframes ab-skeleton-loading {
18
- 0% {
19
- background-position: 100% 50%;
20
- }
21
- 100% {
22
- background-position: 0 50%;
23
- }
24
- }
1
+ $namespace: ab-lazy-image;
2
+
3
+ .#{$namespace} {
4
+ transition: opacity 500ms;
5
+
6
+ &-loading {
7
+ background: #f2f2f2;
8
+ overflow: hidden;
9
+ }
10
+
11
+ &-loading.#{$namespace}-active {
12
+ background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
13
+ background-size: 400% 100%;
14
+ animation: ab-skeleton-loading 1.4s ease infinite;
15
+ }
16
+
17
+ @keyframes ab-skeleton-loading {
18
+ 0% {
19
+ background-position: 100% 50%;
20
+ }
21
+ 100% {
22
+ background-position: 0 50%;
23
+ }
24
+ }
25
25
  }