@nutui/nutui-react-taro 3.0.0-beta.6 → 3.0.0-beta.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.
Files changed (94) hide show
  1. package/README.md +39 -9
  2. package/dist/cjs/packages/address/style/style.css +56 -89
  3. package/dist/cjs/packages/animate/style/animate.scss +0 -3
  4. package/dist/cjs/packages/animate/style/style.css +0 -3
  5. package/dist/cjs/packages/animatingnumbers/style/style.css +1 -1
  6. package/dist/cjs/packages/backtop/backtop.d.ts +3 -4
  7. package/dist/cjs/packages/backtop/backtop.js +16 -34
  8. package/dist/cjs/packages/backtop/style/backtop.scss +8 -17
  9. package/dist/cjs/packages/backtop/style/style.css +8 -14
  10. package/dist/cjs/packages/badge/badge.d.ts +2 -12
  11. package/dist/cjs/packages/badge/badge.js +16 -54
  12. package/dist/cjs/packages/badge/index.d.ts +1 -1
  13. package/dist/cjs/packages/badge/style/badge.scss +61 -34
  14. package/dist/cjs/packages/badge/style/style.css +63 -40
  15. package/dist/cjs/packages/badge/types.d.ts +12 -0
  16. package/dist/cjs/packages/badge/types.js +4 -0
  17. package/dist/cjs/packages/cascader/style/style.css +49 -85
  18. package/dist/cjs/packages/configprovider/types.d.ts +1 -1
  19. package/dist/cjs/packages/countdown/countdown.js +1 -1
  20. package/dist/cjs/packages/countdown/style/countdown.scss +21 -2
  21. package/dist/cjs/packages/countdown/style/style.css +20 -2
  22. package/dist/cjs/packages/countup/style/countup.scss +1 -1
  23. package/dist/cjs/packages/countup/style/style.css +1 -1
  24. package/dist/cjs/packages/elevator/elevator.js +23 -16
  25. package/dist/cjs/packages/elevator/style/elevator.scss +7 -4
  26. package/dist/cjs/packages/elevator/style/style.css +7 -4
  27. package/dist/cjs/packages/hoverbutton/style/style.css +3 -3
  28. package/dist/cjs/packages/hoverbuttonitem/style/hoverbuttonitem.scss +3 -3
  29. package/dist/cjs/packages/hoverbuttonitem/style/style.css +3 -3
  30. package/dist/cjs/packages/inputnumber/inputnumber.js +0 -1
  31. package/dist/cjs/packages/inputnumber/style/inputnumber.scss +19 -16
  32. package/dist/cjs/packages/inputnumber/style/style.css +21 -19
  33. package/dist/cjs/packages/numberkeyboard/numberkeyboard.js +6 -5
  34. package/dist/cjs/packages/numberkeyboard/style/numberkeyboard.scss +10 -1
  35. package/dist/cjs/packages/numberkeyboard/style/style.css +12 -0
  36. package/dist/cjs/packages/popover/style/popover.scss +16 -11
  37. package/dist/cjs/packages/popover/style/style.css +14 -2
  38. package/dist/cjs/packages/tabbar/style/style.css +63 -40
  39. package/dist/cjs/packages/tabbaritem/style/style.css +63 -40
  40. package/dist/cjs/packages/tabs/style/style.css +49 -85
  41. package/dist/cjs/packages/tabs/style/tabs.scss +68 -106
  42. package/dist/cjs/packages/tabs/tabs.js +2 -4
  43. package/dist/cjs/packages/tour/style/style.css +14 -2
  44. package/dist/es/packages/address/style/style.css +56 -89
  45. package/dist/es/packages/animate/style/animate.scss +0 -3
  46. package/dist/es/packages/animate/style/style.css +0 -3
  47. package/dist/es/packages/animatingnumbers/style/style.css +1 -1
  48. package/dist/es/packages/backtop/backtop.d.ts +3 -4
  49. package/dist/es/packages/backtop/backtop.js +18 -36
  50. package/dist/es/packages/backtop/style/backtop.scss +8 -17
  51. package/dist/es/packages/backtop/style/style.css +8 -14
  52. package/dist/es/packages/badge/badge.d.ts +2 -12
  53. package/dist/es/packages/badge/badge.js +17 -55
  54. package/dist/es/packages/badge/index.d.ts +1 -1
  55. package/dist/es/packages/badge/style/badge.scss +61 -34
  56. package/dist/es/packages/badge/style/style.css +63 -40
  57. package/dist/es/packages/badge/types.d.ts +12 -0
  58. package/dist/es/packages/badge/types.js +1 -0
  59. package/dist/es/packages/cascader/style/style.css +49 -85
  60. package/dist/es/packages/configprovider/types.d.ts +1 -1
  61. package/dist/es/packages/countdown/countdown.js +1 -1
  62. package/dist/es/packages/countdown/style/countdown.scss +21 -2
  63. package/dist/es/packages/countdown/style/style.css +20 -2
  64. package/dist/es/packages/countup/style/countup.scss +1 -1
  65. package/dist/es/packages/countup/style/style.css +1 -1
  66. package/dist/es/packages/elevator/elevator.js +26 -19
  67. package/dist/es/packages/elevator/style/elevator.scss +7 -4
  68. package/dist/es/packages/elevator/style/style.css +7 -4
  69. package/dist/es/packages/hoverbutton/style/style.css +3 -3
  70. package/dist/es/packages/hoverbuttonitem/style/hoverbuttonitem.scss +3 -3
  71. package/dist/es/packages/hoverbuttonitem/style/style.css +3 -3
  72. package/dist/es/packages/inputnumber/inputnumber.js +1 -2
  73. package/dist/es/packages/inputnumber/style/inputnumber.scss +19 -16
  74. package/dist/es/packages/inputnumber/style/style.css +21 -19
  75. package/dist/es/packages/numberkeyboard/numberkeyboard.d.ts +10 -50
  76. package/dist/es/packages/numberkeyboard/numberkeyboard.js +6 -5
  77. package/dist/es/packages/numberkeyboard/style/numberkeyboard.scss +10 -1
  78. package/dist/es/packages/numberkeyboard/style/style.css +12 -0
  79. package/dist/es/packages/popover/style/popover.scss +16 -11
  80. package/dist/es/packages/popover/style/style.css +14 -2
  81. package/dist/es/packages/tabbar/style/style.css +63 -40
  82. package/dist/es/packages/tabbaritem/style/style.css +63 -40
  83. package/dist/es/packages/tabpane/tabpane.d.ts +3 -15
  84. package/dist/es/packages/tabs/style/style.css +49 -85
  85. package/dist/es/packages/tabs/style/tabs.scss +68 -106
  86. package/dist/es/packages/tabs/tabs.d.ts +12 -60
  87. package/dist/es/packages/tabs/tabs.js +2 -4
  88. package/dist/es/packages/tour/style/style.css +14 -2
  89. package/dist/nutui.react.umd.js +188 -253
  90. package/dist/style.css +1 -1
  91. package/dist/styles/theme-dark.scss +2 -0
  92. package/dist/styles/theme-default.scss +2 -0
  93. package/dist/styles/variables.scss +36 -29
  94. package/package.json +1 -1
@@ -51,6 +51,8 @@
51
51
  color: var(--nutui-color-primary, #ff0f23);
52
52
  }
53
53
  .nut-elevator-list-fixed {
54
+ display: flex;
55
+ align-items: center;
54
56
  width: 100%;
55
57
  position: absolute;
56
58
  top: 0;
@@ -58,14 +60,15 @@
58
60
  z-index: 1;
59
61
  padding: var(--nutui-elevator-list-item-padding, 0 20px);
60
62
  height: var(--nutui-elevator-list-item-code-height, 35px);
61
- line-height: var(--nutui-elevator-list-item-code-line-height, 35px);
62
- font-size: var(--nutui-elevator-list-item-code-font-size, var(--nutui-font-size-base, 14px));
63
- color: var(--nutui-elevator-list-fixed-color, var(--nutui-color-primary, #ff0f23));
64
- font-weight: var(--nutui-elevator-list-item-code-font-weight, var(--nutui-font-weight-bold, 600));
65
63
  background-color: var(--nutui-elevator-list-fixed-bg-color, #ffffff);
66
64
  box-sizing: border-box;
67
65
  box-shadow: var(--nutui-elevator-list-fixed-box-shadow, 0 0 10px #eee);
68
66
  }
67
+ .nut-elevator-list-fixed-title {
68
+ font-size: var(--nutui-elevator-list-item-code-font-size, var(--nutui-font-size-base, 14px));
69
+ color: var(--nutui-elevator-list-fixed-color, var(--nutui-color-primary, #ff0f23));
70
+ font-weight: var(--nutui-elevator-list-item-code-font-weight, var(--nutui-font-weight-bold, 600));
71
+ }
69
72
  .nut-elevator-code-current {
70
73
  position: absolute;
71
74
  right: var(--nutui-elevator-list-item-code-current-right, 60px);
@@ -544,12 +547,17 @@
544
547
  display: flex;
545
548
  }
546
549
 
550
+ .nut-tabs-horizontal {
551
+ flex-direction: column;
552
+ }
553
+
547
554
  .nut-tabs-titles {
548
555
  display: flex;
549
556
  box-sizing: border-box;
550
557
  height: var(--nutui-tabs-titles-height, 44px);
551
558
  user-select: none;
552
- overflow: hidden;
559
+ overflow-x: auto;
560
+ overflow-y: hidden;
553
561
  background: var(--nutui-tabs-titles-background-color, var(--nutui-color-background, #f5f6fa));
554
562
  scrollbar-width: none;
555
563
  }
@@ -560,7 +568,6 @@
560
568
  }
561
569
  .nut-tabs-titles .nut-tabs-list {
562
570
  width: 100%;
563
- height: auto;
564
571
  display: flex;
565
572
  flex-shrink: 0;
566
573
  }
@@ -576,10 +583,6 @@
576
583
  .nut-tabs-titles-right .nut-tabs-titles-item {
577
584
  padding: 0 22px;
578
585
  }
579
- .nut-tabs-titles-scrollable {
580
- overflow-x: auto;
581
- overflow-y: hidden;
582
- }
583
586
  .nut-tabs-titles-item {
584
587
  position: relative;
585
588
  display: flex;
@@ -595,11 +598,14 @@
595
598
  text-overflow: ellipsis;
596
599
  white-space: nowrap;
597
600
  }
601
+ .nut-tabs-titles-item .nut-icon {
602
+ color: var(--nutui-tabs-titles-item-color, var(--nutui-color-title, #1a1a1a));
603
+ }
598
604
  .nut-tabs-titles-item-left, .nut-tabs-titles-item-right {
599
605
  flex: none;
600
606
  }
601
607
  .nut-tabs-titles-item-text {
602
- text-align: center;
608
+ color: var(--nutui-tabs-titles-item-color, var(--nutui-color-title, #1a1a1a));
603
609
  }
604
610
  .nut-tabs-titles-item-smile, .nut-tabs-titles-item-line {
605
611
  position: absolute;
@@ -607,9 +613,9 @@
607
613
  width: 0;
608
614
  height: 0;
609
615
  content: " ";
610
- bottom: var(--nutui-tabs-line-bottom, 15%);
611
616
  left: 50%;
612
617
  transform: translate(-50%, 0);
618
+ bottom: var(--nutui-tabs-line-bottom, 15%);
613
619
  border-radius: var(--nutui-tabs-line-border-radius, 2px);
614
620
  opacity: var(--nutui-tabs-tab-line-opacity, 1);
615
621
  overflow: hidden;
@@ -622,9 +628,11 @@
622
628
  font-size: 20px;
623
629
  width: 100%;
624
630
  height: 100%;
625
- color: var(--nutui-color-primary, #ff0f23);
626
631
  }
627
- .nut-tabs-titles-item-active {
632
+ .nut-tabs-titles-item-active .nut-icon {
633
+ color: var(--nutui-tabs-titles-item-active-color, var(--nutui-color-primary, #ff0f23));
634
+ }
635
+ .nut-tabs-titles-item-active .nut-tabs-titles-item-text {
628
636
  color: var(--nutui-tabs-titles-item-active-color, var(--nutui-color-primary, #ff0f23));
629
637
  font-weight: var(--nutui-tabs-titles-item-active-font-weight, var(--nutui-font-weight-bold, 600));
630
638
  }
@@ -640,10 +648,20 @@
640
648
  width: 40px;
641
649
  height: 20px;
642
650
  }
651
+ .nut-tabs-titles-item-active .nut-tabs-titles-item-smile .nut-icon {
652
+ color: var(--nutui-tabs-titles-item-active-color, var(--nutui-color-primary, #ff0f23));
653
+ }
643
654
  .nut-tabs-titles-item-disabled {
644
655
  color: var(--nutui-color-text-disabled, #c2c4cc);
645
656
  }
646
- .nut-tabs-titles-simple .nut-tabs-titles-item-active {
657
+ .nut-tabs-titles-item-disabled .nut-icon {
658
+ color: var(--nutui-color-text-disabled, #c2c4cc);
659
+ }
660
+ .nut-tabs-titles-item-disabled .nut-tabs-titles-item-text {
661
+ color: var(--nutui-color-text-disabled, #c2c4cc);
662
+ }
663
+ .nut-tabs-titles-simple .nut-tabs-titles-item-active .nut-tabs-titles-item-text,
664
+ .nut-tabs-titles-simple .nut-tabs-titles-item-active .nut-icon {
647
665
  color: var(--nutui-color-title, #1a1a1a);
648
666
  font-size: var(--nutui-tabs-titles-item-active-font-size, var(--nutui-font-size-l, 16px));
649
667
  }
@@ -672,11 +690,10 @@
672
690
  }
673
691
  .nut-tabs-titles-button .nut-tabs-titles-item-active .nut-tabs-titles-item-text {
674
692
  background: var(--nutui-color-default-light);
675
- color: var(--nutui-color-text, #505259);
693
+ color: var(--nutui-tabs-titles-item-active-color, var(--nutui-color-primary, #ff0f23));
676
694
  border-radius: var(--nutui-tabs-button-border-radius, 50px);
677
695
  font-weight: var(--nutui-font-weight-bold, 600);
678
696
  background-color: var(--nutui-tabs-button-active-background-color, var(--nutui-color-primary-light-pressed, #ffebf1));
679
- color: var(--nutui-color-primary, #ff0f23);
680
697
  border: var(--nutui-tabs-button-active-border, 1px solid var(--nutui-color-primary, #ff0f23));
681
698
  }
682
699
  .nut-tabs-titles-divider {
@@ -701,68 +718,29 @@
701
718
  display: none;
702
719
  }
703
720
 
704
- [dir=rtl] .nut-tabs-titles-item-smile, [dir=rtl] .nut-tabs-titles-item-line,
705
- .nut-rtl .nut-tabs-titles-item-smile,
706
- .nut-rtl .nut-tabs-titles-item-line {
707
- left: auto;
708
- right: 50%;
709
- transform: translate(50%, 0);
710
- }
711
- [dir=rtl] .nut-tabs-titles-divider .nut-tabs-titles-item::after,
712
- .nut-rtl .nut-tabs-titles-divider .nut-tabs-titles-item::after {
713
- right: auto;
714
- left: 0;
715
- }
716
-
717
- .nut-tabs-horizontal {
718
- flex-direction: column;
719
- position: relative;
720
- }
721
-
722
- .nut-tabs-vertical {
723
- flex-direction: row;
724
- width: 100%;
725
- }
726
721
  .nut-tabs-vertical .nut-tabs-ellipsis {
727
722
  text-overflow: ellipsis;
728
723
  white-space: nowrap;
729
724
  overflow: hidden;
730
725
  }
731
726
  .nut-tabs-vertical .nut-tabs-titles {
732
- box-sizing: border-box;
733
727
  flex-direction: column;
734
728
  height: 100%;
735
- padding: 0;
736
729
  width: var(--nutui-tabs-vertical-titles-width, 100px);
737
730
  flex-shrink: 0;
738
731
  }
739
732
  .nut-tabs-vertical .nut-tabs-titles .nut-tabs-list {
740
- width: 100%;
741
- display: flex;
742
733
  flex-direction: column;
743
- flex-shrink: 0;
744
- }
745
- .nut-tabs-vertical .nut-tabs-titles-line .nut-tabs-titles-item {
746
- padding-left: 14px;
747
- }
748
- .nut-tabs-vertical .nut-tabs-titles-scrollable {
749
- overflow-x: hidden;
750
- overflow-y: auto;
751
734
  }
752
735
  .nut-tabs-vertical .nut-tabs-titles-item {
753
736
  height: var(--nutui-tabs-vertical-titles-item-height, 40px);
754
- margin: 0;
755
737
  flex: none;
756
738
  }
757
739
  .nut-tabs-vertical .nut-tabs-titles-item-smile {
758
- width: 0;
759
- height: 0;
760
740
  overflow: hidden;
761
741
  transition: width 0.3s ease;
762
742
  }
763
743
  .nut-tabs-vertical .nut-tabs-titles-item-line {
764
- width: 0;
765
- height: 0;
766
744
  transform: translate(0, -50%);
767
745
  transition: height 0.3s ease;
768
746
  }
@@ -782,21 +760,17 @@
782
760
  right: -12px;
783
761
  bottom: -2%;
784
762
  left: auto;
785
- width: 40px;
786
- height: 20px;
787
763
  transform: rotate(320deg);
788
764
  }
789
765
  .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-titles {
790
766
  flex-direction: row;
791
- overflow-x: auto;
792
- overflow-y: hidden;
793
767
  height: var(--nutui-tabs-titles-height, 44px);
768
+ width: 100%;
769
+ padding: 0 !important;
794
770
  }
795
771
  .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-titles .nut-tabs-list {
796
- width: 100%;
797
- display: flex;
798
772
  flex-direction: row;
799
- flex-shrink: 0;
773
+ height: auto;
800
774
  }
801
775
  .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-content {
802
776
  flex-direction: row;
@@ -807,6 +781,9 @@
807
781
  .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-titles-item-active .nut-tabs-titles-item-line {
808
782
  left: 50%;
809
783
  transform: translate(-50%, 0);
784
+ width: var(--nutui-tabs-tab-line-width, 12px);
785
+ height: var(--nutui-tabs-tab-line-height, 2px);
786
+ background: var(--nutui-tabs-tab-line-color, var(--nutui-color-primary, #ff0f23));
810
787
  }
811
788
  .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-titles-item-active .nut-tabs-titles-item-smile {
812
789
  left: 50%;
@@ -824,28 +801,26 @@
824
801
  .nut-tabs-vertical .nut-tabs-content .nut-tabpane {
825
802
  height: 100%;
826
803
  }
827
- .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-titles {
804
+
805
+ .nut-tabs-content {
828
806
  display: flex;
829
- flex-direction: row;
830
- padding: 0 !important;
831
- width: 100%;
807
+ box-sizing: border-box;
832
808
  }
833
- .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-titles .nut-tabs-titles-item {
834
- display: flex;
835
- align-items: center;
836
- justify-content: center;
837
- flex: 1 0 auto;
809
+ .nut-tabs-content-wrap {
810
+ overflow: hidden;
838
811
  }
839
- .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-titles .nut-tabs-titles-item-active {
840
- color: var(--nutui-color-primary, #ff0f23);
841
- font-weight: var(--nutui-tabs-titles-item-active-font-weight, var(--nutui-font-weight-bold, 600));
842
- font-size: var(--nutui-tabs-titles-item-active-font-size, var(--nutui-font-size-l, 16px));
812
+
813
+ [dir=rtl] .nut-tabs-titles-item-smile, [dir=rtl] .nut-tabs-titles-item-line,
814
+ .nut-rtl .nut-tabs-titles-item-smile,
815
+ .nut-rtl .nut-tabs-titles-item-line {
816
+ left: auto;
817
+ right: 50%;
818
+ transform: translate(50%, 0);
843
819
  }
844
- .nut-tabs-vertical .nut-tabs-horizontal .nut-tabs-titles .nut-tabs-titles-item-active .nut-tabs-titles-item-line {
845
- content: " ";
846
- width: var(--nutui-tabs-tab-line-width, 12px);
847
- height: var(--nutui-tabs-tab-line-height, 2px);
848
- background: var(--nutui-tabs-tab-line-color, var(--nutui-color-primary, #ff0f23));
820
+ [dir=rtl] .nut-tabs-titles-divider .nut-tabs-titles-item::after,
821
+ .nut-rtl .nut-tabs-titles-divider .nut-tabs-titles-item::after {
822
+ right: auto;
823
+ left: 0;
849
824
  }
850
825
 
851
826
  [dir=rtl] .nut-tabs-vertical .nut-tabs-titles-line .nut-tabs-titles-item,
@@ -877,14 +852,6 @@
877
852
  transform: translate(50%, 0) rotate(0deg);
878
853
  }
879
854
 
880
- .nut-tabs-content {
881
- display: flex;
882
- box-sizing: border-box;
883
- }
884
- .nut-tabs-content-wrap {
885
- overflow: hidden;
886
- }
887
-
888
855
  .nut-cascader {
889
856
  width: 100%;
890
857
  font-size: var(--nutui-cascader-font-size, var(--nutui-font-size-base, 14px));
@@ -1,7 +1,4 @@
1
1
  .nut-animate {
2
- .nut-ani-container {
3
- display: inline-block;
4
- }
5
2
  /* Animation css */
6
3
  [class*='nut-animate-'] {
7
4
  animation-duration: 0.5s;
@@ -5,9 +5,6 @@
5
5
  .nut-animate {
6
6
  /* Animation css */
7
7
  }
8
- .nut-animate .nut-ani-container {
9
- display: inline-block;
10
- }
11
8
  .nut-animate [class*=nut-animate-] {
12
9
  animation-duration: 0.5s;
13
10
  animation-timing-function: ease-out;
@@ -24,7 +24,7 @@
24
24
  display: flex;
25
25
  height: 80%;
26
26
  align-items: flex-end;
27
- color: var(--nutui-countup-bg-color, inherit);
27
+ color: var(--nutui-countup-separator-color, var(--nutui-color-title, #1a1a1a));
28
28
  font-size: var(--nutui-countup-base-size, 18px);
29
29
  font-weight: var(--nutui-font-weight-bold, 600);
30
30
  }
@@ -1,9 +1,8 @@
1
1
  import React, { FunctionComponent } from 'react';
2
- import type { MouseEvent } from 'react';
3
2
  import { PageScrollObject } from '@tarojs/taro';
4
3
  import { ITouchEvent } from '@tarojs/components';
5
- import { BasicComponent } from "../../utils/typings";
6
- export interface BackTopProps extends BasicComponent {
4
+ import { HoverButtonProps } from "../hoverbutton/index";
5
+ export interface BackTopProps extends HoverButtonProps {
7
6
  threshold: number;
8
7
  zIndex: number;
9
8
  duration: number;
@@ -11,6 +10,6 @@ export interface BackTopProps extends BasicComponent {
11
10
  * 容器滚动时的回调参数,主要用于 rn、鸿蒙端
12
11
  */
13
12
  scrollRes?: PageScrollObject;
14
- onClick?: (event: React.MouseEvent<Element, MouseEvent> | ITouchEvent) => void;
13
+ onClick?: (event: React.MouseEvent<HTMLDivElement> | ITouchEvent) => void;
15
14
  }
16
15
  export declare const BackTop: FunctionComponent<Partial<BackTopProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'>>;
@@ -2,41 +2,31 @@ import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
2
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
3
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
4
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
5
- import React, { useCallback, useState, useMemo, useEffect, useRef } from "react";
5
+ import React, { useCallback, useState, useEffect, useRef } from "react";
6
6
  import { usePageScroll, pageScrollTo, getSystemInfo } from "@tarojs/taro";
7
7
  import { View } from "@tarojs/components";
8
- import { Top } from "@nutui/icons-react-taro";
9
8
  import classNames from "classnames";
9
+ import { Top } from "@nutui/icons-react-taro";
10
10
  import { ComponentDefaults } from "../../utils/typings";
11
- import { useRtl } from "../configprovider/index";
12
- import { harmonyAndRn, rn } from "../../utils/platform-taro";
13
- import pxTransform from "../../utils/px-transform";
11
+ import HoverButton from "../hoverbutton/index";
12
+ import { rn } from "../../utils/platform-taro";
14
13
  var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
15
14
  threshold: 200,
16
15
  zIndex: 900,
17
16
  duration: 1000
18
17
  });
19
- var isNative = harmonyAndRn();
20
18
  export var BackTop = function(props) {
21
- var rtl = useRtl();
22
- var _$_object_spread = _object_spread({}, defaultProps, props), children = _$_object_spread.children, threshold = _$_object_spread.threshold, zIndex = _$_object_spread.zIndex, className = _$_object_spread.className, duration = _$_object_spread.duration, style = _$_object_spread.style, scrollRes = _$_object_spread.scrollRes, onClick = _$_object_spread.onClick;
19
+ var _$_object_spread = _object_spread({}, defaultProps, props), children = _$_object_spread.children, threshold = _$_object_spread.threshold, zIndex = _$_object_spread.zIndex, className = _$_object_spread.className, duration = _$_object_spread.duration, icon = _$_object_spread.icon, style = _$_object_spread.style, scrollRes = _$_object_spread.scrollRes, onClick = _$_object_spread.onClick;
23
20
  var classPrefix = 'nut-backtop';
24
21
  var _useState = _sliced_to_array(useState(false), 2), backTop = _useState[0], setBackTop = _useState[1];
25
- var _useState1 = _sliced_to_array(useState(false), 2), isTouchStart = _useState1[0], setTouchStart = _useState1[1];
26
22
  var _obj;
27
- var cls = classNames(classPrefix, (_obj = {}, _define_property(_obj, "".concat(classPrefix, "-show"), backTop), _define_property(_obj, "".concat(classPrefix, "-show-active"), isNative && isTouchStart), _define_property(_obj, "".concat(classPrefix, "-rn"), rn()), _obj), className);
23
+ var cls = classNames(classPrefix, (_obj = {}, _define_property(_obj, "".concat(classPrefix, "-show"), backTop), _define_property(_obj, "".concat(classPrefix, "-rn"), rn()), _obj), className);
28
24
  var systemInfo = useRef({});
29
25
  useEffect(function() {
30
26
  getSystemInfo().then(function(res) {
31
27
  systemInfo.current = res;
32
28
  });
33
29
  }, []);
34
- var handleActiveStart = useCallback(function() {
35
- isNative && setTouchStart(true);
36
- }, []);
37
- var handleActiveEnd = useCallback(function() {
38
- isNative && setTouchStart(false);
39
- }, []);
40
30
  var onScroll = useCallback(function(res) {
41
31
  var scrollTop = res.scrollTop;
42
32
  setBackTop(scrollTop >= threshold);
@@ -63,28 +53,20 @@ export var BackTop = function(props) {
63
53
  duration,
64
54
  onClick
65
55
  ]);
66
- var styles = useMemo(function() {
67
- var _obj;
68
- return Object.keys(style || {}).length !== 0 ? _object_spread({
69
- zIndex: zIndex
70
- }, style) : (_obj = {}, _define_property(_obj, rtl ? 'left' : 'right', pxTransform(10)), _define_property(_obj, "bottom", pxTransform(20)), _define_property(_obj, "zIndex", zIndex), _obj);
71
- }, [
72
- rtl,
73
- style,
74
- zIndex
75
- ]);
76
- return /*#__PURE__*/ React.createElement(View, {
56
+ return /*#__PURE__*/ React.createElement(HoverButton, {
77
57
  className: cls,
78
- style: styles,
58
+ style: _object_spread({
59
+ zIndex: zIndex
60
+ }, style),
61
+ icon: !children && (icon || /*#__PURE__*/ React.createElement(Top, null)),
62
+ onClick: function(e) {
63
+ goTop(e);
64
+ }
65
+ }, children && /*#__PURE__*/ React.createElement(View, {
66
+ className: "nut-hoverbutton-item-container",
79
67
  onClick: function(e) {
80
68
  goTop(e);
81
- },
82
- onTouchStart: handleActiveStart,
83
- onTouchEnd: handleActiveEnd,
84
- onTouchCancel: handleActiveEnd
85
- }, children || /*#__PURE__*/ React.createElement(Top, {
86
- size: 19,
87
- className: "nut-backtop-main"
88
- }));
69
+ }
70
+ }, children));
89
71
  };
90
72
  BackTop.displayName = 'NutBackTop';
@@ -1,31 +1,22 @@
1
1
  .nut-backtop {
2
2
  display: none;
3
- position: fixed;
4
3
 
5
4
  &-rn {
6
5
  position: absolute;
7
6
  }
8
7
 
9
8
  &-show {
10
- width: 40px;
11
- height: 40px;
12
9
  display: flex;
13
10
  align-items: center;
14
11
  justify-content: center;
15
- background: $color-background-overlay;
16
- color: $color-title;
17
- border: 1px solid $backtop-border-color;
18
- border-radius: 21px;
19
- z-index: 100;
20
-
21
- &:active,
22
- &-active {
23
- background: $color-background;
24
- }
25
- }
26
-
27
- &-main {
12
+ width: $hoverbutton-item-size;
13
+ height: $hoverbutton-item-size;
28
14
  transition: all 0.2s ease-in-out;
29
- color: $color-title;
15
+ .nut-hoverbutton-item-container {
16
+ display: flex;
17
+ flex-direction: column;
18
+ justify-content: center;
19
+ align-items: center;
20
+ }
30
21
  }
31
22
  }
@@ -4,27 +4,21 @@
4
4
  /* #endif */
5
5
  .nut-backtop {
6
6
  display: none;
7
- position: fixed;
8
7
  }
9
8
  .nut-backtop-rn {
10
9
  position: absolute;
11
10
  }
12
11
  .nut-backtop-show {
13
- width: 40px;
14
- height: 40px;
15
12
  display: flex;
16
13
  align-items: center;
17
14
  justify-content: center;
18
- background: var(--nutui-color-background-overlay, #ffffff);
19
- color: var(--nutui-color-title, #1a1a1a);
20
- border: 1px solid var(--nutui-backtop-border-color, var(--nutui-color-border, rgba(0, 0, 0, 0.06)));
21
- border-radius: 21px;
22
- z-index: 100;
23
- }
24
- .nut-backtop-show:active, .nut-backtop-show-active {
25
- background: var(--nutui-color-background, #f5f6fa);
26
- }
27
- .nut-backtop-main {
15
+ width: var(--nutui-hoverbutton-item-size, 40px);
16
+ height: var(--nutui-hoverbutton-item-size, 40px);
28
17
  transition: all 0.2s ease-in-out;
29
- color: var(--nutui-color-title, #1a1a1a);
18
+ }
19
+ .nut-backtop-show .nut-hoverbutton-item-container {
20
+ display: flex;
21
+ flex-direction: column;
22
+ justify-content: center;
23
+ align-items: center;
30
24
  }
@@ -1,13 +1,3 @@
1
- import { FunctionComponent, ReactNode } from 'react';
2
- import { BasicComponent } from "../../utils/typings";
3
- export type BadgeFill = 'solid' | 'outline';
4
- export interface BadgeProps extends BasicComponent {
5
- value: ReactNode;
6
- dot: boolean;
7
- max: number;
8
- top: string | number;
9
- right: string | number;
10
- color: string;
11
- fill: BadgeFill;
12
- }
1
+ import { FunctionComponent } from 'react';
2
+ import { BadgeProps } from './types';
13
3
  export declare const Badge: FunctionComponent<Partial<BadgeProps>>;
@@ -11,16 +11,15 @@ import { View } from "@tarojs/components";
11
11
  import { ComponentDefaults } from "../../utils/typings";
12
12
  import { useRtl } from "../configprovider/index";
13
13
  import pxTransform from "../../utils/px-transform";
14
- import { getRectByTaro } from "../../utils/get-rect-by-taro";
15
- import { harmony, rn } from "../../utils/platform-taro";
14
+ import { harmony } from "../../utils/platform-taro";
16
15
  var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
17
16
  value: '',
18
17
  dot: false,
19
18
  max: 99,
20
- top: '4',
21
- right: '8',
22
- color: '',
23
- fill: 'solid'
19
+ top: 0,
20
+ right: 0,
21
+ fill: 'solid',
22
+ size: 'large'
24
23
  });
25
24
  export var Badge = function(props) {
26
25
  var content = function content() {
@@ -41,14 +40,14 @@ export var Badge = function(props) {
41
40
  };
42
41
  var _this;
43
42
  var rtl = useRtl();
44
- var _$_object_spread = _object_spread({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, value = _$_object_spread.value, max = _$_object_spread.max, children = _$_object_spread.children, dot = _$_object_spread.dot, top = _$_object_spread.top, right = _$_object_spread.right, color = _$_object_spread.color, fill = _$_object_spread.fill;
43
+ var _$_object_spread = _object_spread({}, defaultProps, props), className = _$_object_spread.className, style = _$_object_spread.style, value = _$_object_spread.value, max = _$_object_spread.max, children = _$_object_spread.children, dot = _$_object_spread.dot, top = _$_object_spread.top, right = _$_object_spread.right, fill = _$_object_spread.fill, size = _$_object_spread.size;
45
44
  var classPrefix = 'nut-badge';
46
45
  var isHarmony = harmony();
47
46
  var classes = classNames(classPrefix, className);
48
47
  var badgeRef = useRef(null);
49
48
  var _useState = _sliced_to_array(useState({}), 2), contentStyle = _useState[0], setContentStyle = _useState[1];
50
49
  var _obj;
51
- var contentClasses = classNames("".concat(classPrefix, "-content"), (_obj = {}, _define_property(_obj, "".concat(classPrefix, "-sup"), isNumber() || isString() || dot), _define_property(_obj, "".concat(classPrefix, "-one"), typeof content() === 'string' && ((_this = "".concat(content())) === null || _this === void 0 ? void 0 : _this.length) === 1), _define_property(_obj, "".concat(classPrefix, "-dot"), dot), _define_property(_obj, "".concat(classPrefix, "-").concat(fill), fill === 'outline'), _obj));
50
+ var contentClasses = classNames((_obj = {}, _define_property(_obj, "".concat(classPrefix, "-sup"), isNumber() || isString() || dot), _define_property(_obj, "".concat(classPrefix, "-number"), isNumber()), _define_property(_obj, "".concat(classPrefix, "-one"), typeof content() === 'string' && ((_this = "".concat(content())) === null || _this === void 0 ? void 0 : _this.length) === 1), _define_property(_obj, "".concat(classPrefix, "-dot"), dot), _define_property(_obj, "".concat(classPrefix, "-dot-").concat(size), dot), _define_property(_obj, "".concat(classPrefix, "-").concat(fill), fill === 'outline'), _define_property(_obj, "".concat(classPrefix, "-content"), children), _obj));
52
51
  useEffect(function() {
53
52
  if (badgeRef.current) {
54
53
  getPositionStyle();
@@ -56,59 +55,22 @@ export var Badge = function(props) {
56
55
  }, []);
57
56
  var getPositionStyle = /*#__PURE__*/ function() {
58
57
  var _ref = _async_to_generator(function() {
59
- var style, reacts, dir;
58
+ var style, dir;
60
59
  return _ts_generator(this, function(_state) {
61
- switch(_state.label){
62
- case 0:
63
- style = {};
64
- style.top = pxTransform(-Number(top) || 0);
65
- if (!rn()) return [
66
- 3,
67
- 2
68
- ];
69
- return [
70
- 4,
71
- getRectByTaro(badgeRef.current)
72
- ];
73
- case 1:
74
- reacts = _state.sent();
75
- style.left = (reacts === null || reacts === void 0 ? void 0 : reacts.width) && (reacts === null || reacts === void 0 ? void 0 : reacts.width) > Number(right) ? pxTransform(reacts.width - Number(right)) : 0;
76
- return [
77
- 3,
78
- 3
79
- ];
80
- case 2:
81
- dir = rtl ? 'left' : 'right';
82
- style[dir] = isHarmony ? pxTransform(Number(right)) : "".concat(Number(right) || parseFloat(String(right)) || 0, "px");
83
- _state.label = 3;
84
- case 3:
85
- setContentStyle(style);
86
- return [
87
- 2
88
- ];
89
- }
60
+ style = {};
61
+ style.top = pxTransform(Number(top) || 0);
62
+ dir = rtl ? 'left' : 'right';
63
+ style[dir] = isHarmony ? pxTransform(Number(right)) : "".concat(Number(right) || 0, "px");
64
+ setContentStyle(style);
65
+ return [
66
+ 2
67
+ ];
90
68
  });
91
69
  });
92
70
  return function getPositionStyle() {
93
71
  return _ref.apply(this, arguments);
94
72
  };
95
73
  }();
96
- var getStyle = function() {
97
- var style = {};
98
- if (color) {
99
- if (fill === 'outline') {
100
- style.color = color;
101
- isHarmony ? style.backgroundColor = '#fff' : style.background = '#fff';
102
- if (!(color === null || color === void 0 ? void 0 : color.includes('gradient'))) {
103
- style.borderColor = color;
104
- }
105
- } else {
106
- style.color = '#fff';
107
- isHarmony ? style.backgroundColor = color : style.background = color;
108
- }
109
- }
110
- return style;
111
- };
112
74
  var _obj1;
113
75
  return /*#__PURE__*/ React.createElement(View, {
114
76
  className: classes,
@@ -119,7 +81,7 @@ export var Badge = function(props) {
119
81
  style: contentStyle
120
82
  }, value), children, !isIcon() && /*#__PURE__*/ React.createElement(View, {
121
83
  className: contentClasses,
122
- style: _object_spread({}, contentStyle, getStyle())
84
+ style: contentStyle
123
85
  }, content()));
124
86
  };
125
87
  Badge.displayName = 'NutBadge';
@@ -1,3 +1,3 @@
1
1
  import { Badge } from "./badge";
2
- export type { BadgeFill, BadgeProps } from "./badge";
2
+ export type { BadgeFill, BadgeDotSize, BadgeProps } from './types';
3
3
  export default Badge;