tntd 2.8.0-beta.8 → 2.8.1

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 (314) hide show
  1. package/es/array-input/index.js +57 -42
  2. package/es/array-input/index.js.map +1 -1
  3. package/es/array-input/index.less +4 -1
  4. package/es/button/button.js +3 -7
  5. package/es/button/button.js.map +1 -1
  6. package/es/button/button.less +7 -0
  7. package/es/button/index.js +1 -0
  8. package/es/button/index.js.map +1 -1
  9. package/es/collapse/collapse.less +3 -3
  10. package/es/descriptions/descriptions.js +85 -24
  11. package/es/descriptions/descriptions.js.map +1 -1
  12. package/es/descriptions/descriptions.less +63 -62
  13. package/es/descriptions/style/index.less +1 -0
  14. package/es/drawer/drawer.js +118 -13
  15. package/es/drawer/drawer.js.map +1 -1
  16. package/es/drawer/index.js +1 -1
  17. package/es/drawer/index.js.map +1 -1
  18. package/es/drawer/index.less +153 -0
  19. package/es/drawer/style/drawer.less +2 -4
  20. package/es/form/form.js +8 -3
  21. package/es/form/form.js.map +1 -1
  22. package/es/form/form.less +42 -0
  23. package/es/form/style/index.less +6 -6
  24. package/es/handle-icon/index.js +201 -0
  25. package/es/handle-icon/index.js.map +1 -0
  26. package/es/handle-icon/index.less +53 -0
  27. package/es/icon/style/style.less +1 -1
  28. package/es/index.js +1 -0
  29. package/es/index.js.map +1 -1
  30. package/es/input/input.js +10 -6
  31. package/es/input/input.js.map +1 -1
  32. package/es/input/style/mixin.less +1 -1
  33. package/es/locale/en_US.js +8 -1
  34. package/es/locale/en_US.js.map +1 -1
  35. package/es/locale/zh_CN.js +8 -1
  36. package/es/locale/zh_CN.js.map +1 -1
  37. package/es/mentions/style/index.less +1 -0
  38. package/es/modal/style/confirm.less +6 -10
  39. package/es/modal/style/modal.less +4 -2
  40. package/es/notification/assets/index.js +2 -0
  41. package/es/notification/assets/index.js.map +1 -0
  42. package/es/notification/assets/svg-error-tip.js +145 -0
  43. package/es/notification/assets/svg-error-tip.js.map +1 -0
  44. package/es/notification/assets/svg-success-tip.js +162 -0
  45. package/es/notification/assets/svg-success-tip.js.map +1 -0
  46. package/es/notification/index.js +1 -1
  47. package/es/notification/index.js.map +1 -1
  48. package/es/notification/notification.js +80 -0
  49. package/es/notification/notification.js.map +1 -0
  50. package/es/notification/notification.less +34 -0
  51. package/es/notification/style/index.less +1 -0
  52. package/es/page-container/index.js +1 -1
  53. package/es/page-container/index.js.map +1 -1
  54. package/es/page-loading/index.js +1 -1
  55. package/es/page-loading/index.js.map +1 -1
  56. package/es/select/select.js +5 -3
  57. package/es/select/select.js.map +1 -1
  58. package/es/select/style/index.less +7 -6
  59. package/es/spin/index.js +3 -2
  60. package/es/spin/index.js.map +1 -1
  61. package/es/spin/spin.js +36 -0
  62. package/es/spin/spin.js.map +1 -0
  63. package/es/spin/spin.less +9 -0
  64. package/es/style/themes/default.less +1 -1
  65. package/es/table/expand.less +49 -0
  66. package/es/table/hooks/index.js +2 -1
  67. package/es/table/hooks/index.js.map +1 -1
  68. package/es/table/hooks/use-expand-fixed.js +80 -0
  69. package/es/table/hooks/use-expand-fixed.js.map +1 -0
  70. package/es/table/index.js +1 -0
  71. package/es/table/index.js.map +1 -1
  72. package/es/table/style/index.less +77 -39
  73. package/es/table/style/size.less +1 -0
  74. package/es/table/table.js +43 -8
  75. package/es/table/table.js.map +1 -1
  76. package/es/table/table.less +5 -5
  77. package/es/table/table.stories.js +413 -2
  78. package/es/table/table.stories.js.map +1 -1
  79. package/es/table/utils.js +11 -0
  80. package/es/table/utils.js.map +1 -1
  81. package/es/table-container/index.js +1 -1
  82. package/es/table-container/index.js.map +1 -1
  83. package/es/table-container/index.less +10 -10
  84. package/es/tabs-container/index.js +1 -1
  85. package/es/tabs-container/index.js.map +1 -1
  86. package/es/tag/color.less +53 -0
  87. package/es/tag/index.js +11 -2
  88. package/es/tag/index.js.map +1 -1
  89. package/es/tag/tag.js +171 -0
  90. package/es/tag/tag.js.map +1 -0
  91. package/es/tag/tag.less +228 -0
  92. package/es/title/index.js +4 -3
  93. package/es/title/index.js.map +1 -1
  94. package/es/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js +5 -11
  95. package/es/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js.map +1 -1
  96. package/es/tntd-cascader/AntdCascader/index.less +12 -2
  97. package/es/tntd-cascader/rc-cascader/OptionList/Column.js +3 -2
  98. package/es/tntd-cascader/rc-cascader/OptionList/Column.js.map +1 -1
  99. package/es/tntd-cascader/rc-cascader/OptionList/index.js +1 -0
  100. package/es/tntd-cascader/rc-cascader/OptionList/index.js.map +1 -1
  101. package/es/tntd-form/FormItem/ItemHolder.js +1 -6
  102. package/es/tntd-form/FormItem/ItemHolder.js.map +1 -1
  103. package/es/tntd-form/FormItemLabel.js +2 -0
  104. package/es/tntd-form/FormItemLabel.js.map +1 -1
  105. package/es/tntd-select/index.js +9 -4
  106. package/es/tntd-select/index.js.map +1 -1
  107. package/es/tooltip/index.js +3 -2
  108. package/es/tooltip/index.js.map +1 -1
  109. package/es/tooltip/index.less +29 -0
  110. package/es/tooltip/tooltip.js +33 -0
  111. package/es/tooltip/tooltip.js.map +1 -0
  112. package/lib/array-input/index.d.ts +1 -12
  113. package/lib/array-input/index.d.ts.map +1 -1
  114. package/lib/array-input/index.js +62 -55
  115. package/lib/array-input/index.js.map +1 -1
  116. package/lib/array-input/index.less +4 -1
  117. package/lib/button/button.d.ts.map +1 -1
  118. package/lib/button/button.js +2 -14
  119. package/lib/button/button.js.map +1 -1
  120. package/lib/button/button.less +7 -0
  121. package/lib/button/index.d.ts +1 -0
  122. package/lib/button/index.d.ts.map +1 -1
  123. package/lib/button/index.js +6 -5
  124. package/lib/button/index.js.map +1 -1
  125. package/lib/collapse/collapse.less +3 -3
  126. package/lib/descriptions/descriptions.d.ts +11 -6
  127. package/lib/descriptions/descriptions.d.ts.map +1 -1
  128. package/lib/descriptions/descriptions.js +92 -30
  129. package/lib/descriptions/descriptions.js.map +1 -1
  130. package/lib/descriptions/descriptions.less +63 -62
  131. package/lib/descriptions/style/index.less +1 -0
  132. package/lib/drawer/drawer.d.ts +28 -2
  133. package/lib/drawer/drawer.d.ts.map +1 -1
  134. package/lib/drawer/drawer.js +125 -13
  135. package/lib/drawer/drawer.js.map +1 -1
  136. package/lib/drawer/index.d.ts +1 -1
  137. package/lib/drawer/index.d.ts.map +1 -1
  138. package/lib/drawer/index.js +5 -5
  139. package/lib/drawer/index.js.map +1 -1
  140. package/lib/drawer/index.less +153 -0
  141. package/lib/drawer/style/drawer.less +2 -4
  142. package/lib/form/form.d.ts +1 -0
  143. package/lib/form/form.d.ts.map +1 -1
  144. package/lib/form/form.js +9 -3
  145. package/lib/form/form.js.map +1 -1
  146. package/lib/form/form.less +42 -0
  147. package/lib/form/style/index.less +6 -6
  148. package/lib/handle-icon/index.d.ts +7 -0
  149. package/lib/handle-icon/index.d.ts.map +1 -0
  150. package/lib/handle-icon/index.js +221 -0
  151. package/lib/handle-icon/index.js.map +1 -0
  152. package/lib/handle-icon/index.less +53 -0
  153. package/lib/icon/style/style.less +1 -1
  154. package/lib/index.d.ts +1 -0
  155. package/lib/index.d.ts.map +1 -1
  156. package/lib/index.js +7 -0
  157. package/lib/index.js.map +1 -1
  158. package/lib/input/input.js +8 -4
  159. package/lib/input/input.js.map +1 -1
  160. package/lib/input/style/mixin.less +1 -1
  161. package/lib/locale/default.d.ts +7 -0
  162. package/lib/locale/default.d.ts.map +1 -1
  163. package/lib/locale/en_US.d.ts +7 -0
  164. package/lib/locale/en_US.d.ts.map +1 -1
  165. package/lib/locale/en_US.js +8 -1
  166. package/lib/locale/en_US.js.map +1 -1
  167. package/lib/locale/zh_CN.d.ts +7 -0
  168. package/lib/locale/zh_CN.d.ts.map +1 -1
  169. package/lib/locale/zh_CN.js +8 -1
  170. package/lib/locale/zh_CN.js.map +1 -1
  171. package/lib/mentions/style/index.less +1 -0
  172. package/lib/modal/style/confirm.less +6 -10
  173. package/lib/modal/style/modal.less +4 -2
  174. package/lib/notification/assets/index.d.ts +3 -0
  175. package/lib/notification/assets/index.d.ts.map +1 -0
  176. package/lib/notification/assets/index.js +20 -0
  177. package/lib/notification/assets/index.js.map +1 -0
  178. package/lib/notification/assets/svg-error-tip.d.ts +4 -0
  179. package/lib/notification/assets/svg-error-tip.d.ts.map +1 -0
  180. package/lib/notification/assets/svg-error-tip.js +154 -0
  181. package/lib/notification/assets/svg-error-tip.js.map +1 -0
  182. package/lib/notification/assets/svg-success-tip.d.ts +4 -0
  183. package/lib/notification/assets/svg-success-tip.d.ts.map +1 -0
  184. package/lib/notification/assets/svg-success-tip.js +171 -0
  185. package/lib/notification/assets/svg-success-tip.js.map +1 -0
  186. package/lib/notification/index.d.ts +1 -1
  187. package/lib/notification/index.d.ts.map +1 -1
  188. package/lib/notification/index.js +7 -8
  189. package/lib/notification/index.js.map +1 -1
  190. package/lib/notification/notification.d.ts +9 -0
  191. package/lib/notification/notification.d.ts.map +1 -0
  192. package/lib/notification/notification.js +105 -0
  193. package/lib/notification/notification.js.map +1 -0
  194. package/lib/notification/notification.less +34 -0
  195. package/lib/notification/style/index.less +1 -0
  196. package/lib/page-container/index.js +1 -1
  197. package/lib/page-container/index.js.map +1 -1
  198. package/lib/page-loading/index.js +1 -1
  199. package/lib/page-loading/index.js.map +1 -1
  200. package/lib/segmented/index.d.ts +1 -1
  201. package/lib/select/select.d.ts.map +1 -1
  202. package/lib/select/select.js +4 -2
  203. package/lib/select/select.js.map +1 -1
  204. package/lib/select/style/index.less +7 -6
  205. package/lib/spin/index.d.ts +3 -2
  206. package/lib/spin/index.d.ts.map +1 -1
  207. package/lib/spin/index.js +4 -6
  208. package/lib/spin/index.js.map +1 -1
  209. package/lib/spin/spin.d.ts +9 -0
  210. package/lib/spin/spin.d.ts.map +1 -0
  211. package/lib/spin/spin.js +44 -0
  212. package/lib/spin/spin.js.map +1 -0
  213. package/lib/spin/spin.less +9 -0
  214. package/lib/style/themes/default.less +1 -1
  215. package/lib/svg-components/illustration-403.d.ts +1 -1
  216. package/lib/svg-components/illustration-404.d.ts +1 -1
  217. package/lib/svg-components/illustration-500.d.ts +1 -1
  218. package/lib/svg-components/illustration-empty.d.ts +1 -1
  219. package/lib/svg-components/illustration-failure.d.ts +1 -1
  220. package/lib/svg-components/illustration-no-access.d.ts +1 -1
  221. package/lib/svg-components/illustration-no-chart.d.ts +1 -1
  222. package/lib/svg-components/illustration-no-result.d.ts +1 -1
  223. package/lib/svg-components/illustration-offline.d.ts +1 -1
  224. package/lib/svg-components/illustration-success.d.ts +1 -1
  225. package/lib/table/assets/image-loading-background.d.ts +1 -1
  226. package/lib/table/assets/image-loading.d.ts +1 -1
  227. package/lib/table/expand.less +49 -0
  228. package/lib/table/hooks/index.d.ts +1 -0
  229. package/lib/table/hooks/index.d.ts.map +1 -1
  230. package/lib/table/hooks/index.js +11 -0
  231. package/lib/table/hooks/index.js.map +1 -1
  232. package/lib/table/hooks/use-expand-fixed.d.ts +4 -0
  233. package/lib/table/hooks/use-expand-fixed.d.ts.map +1 -0
  234. package/lib/table/hooks/use-expand-fixed.js +110 -0
  235. package/lib/table/hooks/use-expand-fixed.js.map +1 -0
  236. package/lib/table/index.d.ts +1 -0
  237. package/lib/table/index.d.ts.map +1 -1
  238. package/lib/table/index.js +1 -0
  239. package/lib/table/index.js.map +1 -1
  240. package/lib/table/style/index.less +77 -39
  241. package/lib/table/style/size.less +1 -0
  242. package/lib/table/table.d.ts +3 -1
  243. package/lib/table/table.d.ts.map +1 -1
  244. package/lib/table/table.js +43 -4
  245. package/lib/table/table.js.map +1 -1
  246. package/lib/table/table.less +5 -5
  247. package/lib/table/table.stories.d.ts +106 -29
  248. package/lib/table/table.stories.d.ts.map +1 -1
  249. package/lib/table/table.stories.js +426 -3
  250. package/lib/table/table.stories.js.map +1 -1
  251. package/lib/table/utils.d.ts +1 -0
  252. package/lib/table/utils.d.ts.map +1 -1
  253. package/lib/table/utils.js +13 -0
  254. package/lib/table/utils.js.map +1 -1
  255. package/lib/table-container/index.js +1 -1
  256. package/lib/table-container/index.js.map +1 -1
  257. package/lib/table-container/index.less +10 -10
  258. package/lib/tabs-container/index.js +1 -1
  259. package/lib/tabs-container/index.js.map +1 -1
  260. package/lib/tag/color.less +53 -0
  261. package/lib/tag/index.d.ts +3 -2
  262. package/lib/tag/index.d.ts.map +1 -1
  263. package/lib/tag/index.js +15 -9
  264. package/lib/tag/index.js.map +1 -1
  265. package/lib/tag/tag.d.ts +41 -0
  266. package/lib/tag/tag.d.ts.map +1 -0
  267. package/lib/tag/tag.js +183 -0
  268. package/lib/tag/tag.js.map +1 -0
  269. package/lib/tag/tag.less +228 -0
  270. package/lib/title/index.d.ts +1 -0
  271. package/lib/title/index.d.ts.map +1 -1
  272. package/lib/title/index.js +3 -2
  273. package/lib/title/index.js.map +1 -1
  274. package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.d.ts.map +1 -1
  275. package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js +5 -11
  276. package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js.map +1 -1
  277. package/lib/tntd-cascader/AntdCascader/config/utils.d.ts +1 -1
  278. package/lib/tntd-cascader/AntdCascader/index.less +12 -2
  279. package/lib/tntd-cascader/rc-cascader/OptionList/Column.d.ts +1 -1
  280. package/lib/tntd-cascader/rc-cascader/OptionList/Column.d.ts.map +1 -1
  281. package/lib/tntd-cascader/rc-cascader/OptionList/Column.js +3 -2
  282. package/lib/tntd-cascader/rc-cascader/OptionList/Column.js.map +1 -1
  283. package/lib/tntd-cascader/rc-cascader/OptionList/index.d.ts.map +1 -1
  284. package/lib/tntd-cascader/rc-cascader/OptionList/index.js +1 -0
  285. package/lib/tntd-cascader/rc-cascader/OptionList/index.js.map +1 -1
  286. package/lib/tntd-form/FormItem/ItemHolder.js +1 -6
  287. package/lib/tntd-form/FormItem/ItemHolder.js.map +1 -1
  288. package/lib/tntd-form/FormItemLabel.d.ts.map +1 -1
  289. package/lib/tntd-form/FormItemLabel.js +2 -0
  290. package/lib/tntd-form/FormItemLabel.js.map +1 -1
  291. package/lib/tntd-rc-select/_util/PurePanel.d.ts +1 -1
  292. package/lib/tntd-select/index.d.ts.map +1 -1
  293. package/lib/tntd-select/index.js +8 -3
  294. package/lib/tntd-select/index.js.map +1 -1
  295. package/lib/tooltip/index.d.ts +3 -2
  296. package/lib/tooltip/index.d.ts.map +1 -1
  297. package/lib/tooltip/index.js +3 -2
  298. package/lib/tooltip/index.js.map +1 -1
  299. package/lib/tooltip/index.less +29 -0
  300. package/lib/tooltip/tooltip.d.ts +9 -0
  301. package/lib/tooltip/tooltip.d.ts.map +1 -0
  302. package/lib/tooltip/tooltip.js +53 -0
  303. package/lib/tooltip/tooltip.js.map +1 -0
  304. package/package.json +4 -3
  305. package/themes/default/variables.less +2 -2
  306. package/themes/default/variablesVar.less +2 -2
  307. package/es/array-input/icon.js +0 -25
  308. package/es/array-input/icon.js.map +0 -1
  309. package/es/drawer/drawer.less +0 -20
  310. package/lib/array-input/icon.d.ts +0 -4
  311. package/lib/array-input/icon.d.ts.map +0 -1
  312. package/lib/array-input/icon.js +0 -32
  313. package/lib/array-input/icon.js.map +0 -1
  314. package/lib/drawer/drawer.less +0 -20
@@ -0,0 +1,153 @@
1
+ @drawer-prefix-cls: ~'@{ant-prefix}-drawer';
2
+
3
+
4
+ .tnt-drawer.@{drawer-prefix-cls} {
5
+ &-top {
6
+ .@{drawer-prefix-cls}-wrapper-body {
7
+ margin-top: 48px;
8
+ }
9
+
10
+ .@{drawer-prefix-cls}-content-wrapper {
11
+ height: 480px !important;
12
+ }
13
+ }
14
+
15
+ &-bottom {
16
+ .@{drawer-prefix-cls}-content-wrapper {
17
+ height: 480px !important;
18
+ }
19
+ }
20
+
21
+ .@{drawer-prefix-cls}-wrapper-body {
22
+ margin-top: 48px;
23
+ max-height: ~'calc(100vh - 48px)';
24
+ }
25
+
26
+ &-footer {
27
+ .@{drawer-prefix-cls}-header {
28
+ // border-bottom: none;
29
+ position: absolute;
30
+ right: 0;
31
+ top: 0;
32
+ background: #fff;
33
+ width: 100%;
34
+ }
35
+
36
+ .@{drawer-prefix-cls}-wrapper-body {
37
+ max-height: ~'calc(100vh - 96px)' !important;
38
+ margin-top: 48px !important;
39
+ margin-bottom: 48px !important;
40
+ }
41
+
42
+ }
43
+
44
+ .@{drawer-prefix-cls}-title {
45
+ font-size: 16px !important;
46
+ font-weight: 500 !important;
47
+ }
48
+
49
+ .@{drawer-prefix-cls}-close {
50
+ position: absolute;
51
+ top: -2px;
52
+ right: 0;
53
+ z-index: 10;
54
+ display: block;
55
+ width: 48px;
56
+ height: 48px;
57
+ padding: 0;
58
+ color: rgba(23, 35, 61, 0.8);
59
+ font-weight: 700;
60
+ font-size: 20px;
61
+ font-style: normal;
62
+ line-height: 56px;
63
+ text-align: center;
64
+ text-transform: none;
65
+ text-decoration: none;
66
+ background: transparent;
67
+ border: 0;
68
+ outline: 0;
69
+ cursor: pointer;
70
+ transition: color 0.3s;
71
+ text-rendering: auto;
72
+ }
73
+
74
+
75
+ .@{drawer-prefix-cls}-contain-closable {
76
+ .@{drawer-prefix-cls}-header {
77
+ padding: 12px 36px 12px 20px;
78
+ }
79
+ }
80
+
81
+ &-right {
82
+ .@{drawer-prefix-cls}-content {
83
+ border-radius: @border-radius-base 0px 0px @border-radius-base;
84
+ background: #F8F9FB;
85
+ }
86
+ }
87
+
88
+ &-left {
89
+ .@{drawer-prefix-cls}-content {
90
+ border-radius: 0px @border-radius-base @border-radius-base 0px;
91
+ background: #F8F9FB;
92
+ }
93
+ }
94
+
95
+ &-top {
96
+ .@{drawer-prefix-cls}-content {
97
+ border-radius: 0px 0px @border-radius-base @border-radius-base;
98
+ background: #F8F9FB;
99
+ padding-top: 48px;
100
+ }
101
+
102
+ .@{drawer-prefix-cls}-wrapper-body {
103
+ margin-top: 0px !important;
104
+ }
105
+ }
106
+
107
+ &-bottom {
108
+ .@{drawer-prefix-cls}-content {
109
+ border-radius: @border-radius-base @border-radius-base 0px 0px;
110
+ background: #F8F9FB;
111
+ padding-top: 48px;
112
+ }
113
+
114
+ .@{drawer-prefix-cls}-wrapper-body {
115
+ margin-top: 0px !important;
116
+ }
117
+ }
118
+
119
+
120
+ .@{drawer-prefix-cls}-header {
121
+ padding: 13px 24px;
122
+ position: absolute;
123
+ right: 0;
124
+ top: 0;
125
+ width: 100%;
126
+ background: #fff;
127
+ border-bottom: 1px solid #E9EDF3;
128
+
129
+ }
130
+
131
+ .@{drawer-prefix-cls}-body {
132
+ padding: 24px !important;
133
+ }
134
+
135
+ .@{drawer-prefix-cls}-wrapper-body {
136
+
137
+ .@{drawer-prefix-cls}-footer-style {
138
+ position: absolute;
139
+ right: 0;
140
+ bottom: 0;
141
+ width: 100%;
142
+ padding: 8px 24px;
143
+ background: #fff;
144
+ text-align: right;
145
+ border-top: 1px solid #E9EDF3;
146
+
147
+ .@{ant-prefix}-btn {
148
+ margin-left: 15px;
149
+ }
150
+ }
151
+
152
+ }
153
+ }
@@ -157,7 +157,7 @@
157
157
  padding: 0;
158
158
  color: @text-color-secondary;
159
159
  font-weight: 700;
160
- font-size: 20px;
160
+ font-size: @font-size-lg;
161
161
  font-style: normal;
162
162
  line-height: 56px;
163
163
  text-align: center;
@@ -169,9 +169,7 @@
169
169
  cursor: pointer;
170
170
  transition: color @animation-duration-slow;
171
171
  text-rendering: auto;
172
- .tntd-anticon {
173
- font-size: 20px;
174
- }
172
+
175
173
  &:focus,
176
174
  &:hover {
177
175
  color: @icon-color-hover;
@@ -2,6 +2,7 @@ import type { FormItemProps as AntdFormItemProps, FormProps as AntdFormProps } f
2
2
  import React from 'react';
3
3
  import { default as AntdForm } from 'antd/lib/form';
4
4
  import type AntdFormItem from 'antd/lib/form/FormItem';
5
+ import './form.less';
5
6
  export * from 'antd/lib/form';
6
7
  interface FormItemComponent extends React.ForwardRefExoticComponent<AntdFormItemProps & React.RefAttributes<AntdFormItem>> {
7
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../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,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtF,IAAI,EAAE,iBAAiB,CAAA;IACvB,MAAM,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAA;IAC9B,eAAe,EAAE,OAAO,QAAQ,CAAC,eAAe,CAAA;CACjD;AAED,eAAO,MAAM,IAAI,eAQE,CAAA"}
package/lib/form/form.js CHANGED
@@ -22,6 +22,9 @@ Object.keys(_form).forEach(function (key) {
22
22
  });
23
23
  });
24
24
  var _utils = require("../utils");
25
+ require("./form.less");
26
+ var _classnames = _interopRequireDefault(require("classnames"));
27
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
28
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
26
29
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
27
30
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
@@ -41,6 +44,7 @@ var Form = exports.Form = (0, _react.forwardRef)(function (_a, ref) {
41
44
  return _react["default"].createElement(_configProvider.ConfigConsumer, null, function (_ref) {
42
45
  var getPrefixCls = _ref.getPrefixCls;
43
46
  return _react["default"].createElement(_form["default"], Object.assign({}, rest, {
47
+ className: (0, _classnames["default"])(rest.className, 'tnt-form'),
44
48
  ref: ref
45
49
  }));
46
50
  });
@@ -59,7 +63,7 @@ Form.Item = (0, _react.forwardRef)(function (_a, ref) {
59
63
  var Create = function Create(options) {
60
64
  return function (WrappedComponent) {
61
65
  var validateSubmitMap = {};
62
- var CustomFormWrapper = function CustomFormWrapper(props) {
66
+ var CustomFormWrapper = function CustomFormWrapper(props, ref) {
63
67
  var getFieldDecorator = props.form.getFieldDecorator;
64
68
  props.form.getFieldDecorator = function (name, options) {
65
69
  var opt = options || {};
@@ -71,7 +75,9 @@ var Create = function Create(options) {
71
75
  }
72
76
  return getFieldDecorator(name, opt);
73
77
  };
74
- return _react["default"].createElement(WrappedComponent, Object.assign({}, props));
78
+ return _react["default"].createElement(WrappedComponent, Object.assign({}, props, {
79
+ ref: ref
80
+ }));
75
81
  };
76
82
  return _form["default"].create(Object.assign(Object.assign({}, options), {
77
83
  onValuesChange: function onValuesChange(props, changedValues, allValues) {
@@ -89,7 +95,7 @@ var Create = function Create(options) {
89
95
  options.onValuesChange(props, changedValues, allValues);
90
96
  }
91
97
  }
92
- }))(CustomFormWrapper);
98
+ }))((0, _react.forwardRef)(CustomFormWrapper));
93
99
  };
94
100
  };
95
101
  Form.createFormField = _form["default"].createFormField;
@@ -1 +1 @@
1
- {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/form/form.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,+CAAyC;AAEzC,6DAAwD;AAExD,wDAAkD;AAGlD,oCAAuC;AAEvC,+CAA4B;AAWf,QAAA,IAAI,GAAG,IAAA,kBAAU,EAA0B,CAAC,EAAW,EAAE,GAAG,EAAE,EAAE;QAAf,IAAI,cAAT,EAAW,CAAF;IAChE,OAAO,CACL,8BAAC,gCAAc,QACZ,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;QACpB,OAAO,8BAAC,cAAQ,oBAAK,IAAI,IAAE,GAAG,E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kB,EAAE,SAAc,EAAE,EAAE;YACjE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;YACvC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;gBACrB,IAAI,CAAC,OAAO,CAAC,CAAC,IAAS,EAAE,EAAE;oBACzB,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;wBAC3B,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;4BACnB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;yBAC9B,CAAC,CAAA;qBACH;gBACH,CAAC,CAAC,CAAA;aACH;YACD,IAAI,OAAO,IAAI,OAAO,CAAC,cAAc,EAAE;gBACrC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,CAAC,CAAA;aACxD;QACH,CAAC,IACD,CAAC,iBAAiB,CAAC,CAAA;AACvB,CAAC,CAAA;AAED,YAAI,CAAC,eAAe,GAAG,cAAQ,CAAC,eAAe,CAAA;AAC/C,YAAI,CAAC,MAAM,GAAG,MAAM,CAAA","sourcesContent":["import type {\n FormItemProps as AntdFormItemProps,\n FormProps as AntdFormProps,\n FormComponentProps,\n FormCreateOption,\n} from 'antd/lib/form'\nimport React, { forwardRef } from 'react'\n\nimport { ConfigConsumer } from 'antd/lib/config-provider'\n\nimport { default as AntdForm } from 'antd/lib/form'\nimport type AntdFormItem from 'antd/lib/form/FormItem'\n\nimport { doUpperTitle } from '../utils'\n\nexport * from 'antd/lib/form'\n\ninterface FormItemComponent\n extends React.ForwardRefExoticComponent<AntdFormItemProps & React.RefAttributes<AntdFormItem>> {}\ninterface FormComponent\n extends React.ForwardRefExoticComponent<AntdFormProps & React.RefAttributes<AntdForm>> {\n Item: FormItemComponent\n create: typeof AntdForm.create\n createFormField: typeof AntdForm.createFormField\n}\n\nexport const Form = forwardRef<AntdForm, AntdFormProps>(({ ...rest }, ref) => {\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n return <AntdForm {...rest} ref={ref} />\n }}\n </ConfigConsumer>\n )\n}) as FormComponent\n\nForm.Item = forwardRef<AntdFormItem, AntdFormItemProps>(({ label, ...rest }, ref) => {\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n return <AntdForm.Item {...rest} label={doUpperTitle(label)} ref={ref} />\n }}\n </ConfigConsumer>\n )\n})\n\n// 定义 create 函数的类型\ntype CreateFunction = <TOwnProps extends FormComponentProps<any>>(\n options?: FormCreateOption<TOwnProps>\n) => any\n\nconst Create: CreateFunction = (options: any) => (WrappedComponent: any) => {\n const validateSubmitMap: any = {}\n const CustomFormWrapper = (props: any) => {\n const getFieldDecorator = props.form.getFieldDecorator\n props.form.getFieldDecorator = (name: any, options: any) => {\n let opt = options || {}\n if (opt.validateSubmit) {\n opt = {\n ...options,\n validateTrigger: 'noEvent',\n }\n validateSubmitMap[name] = true\n }\n return getFieldDecorator(name, opt)\n }\n return <WrappedComponent {...props} />\n }\n\n return AntdForm.create({\n ...options,\n onValuesChange: (props: any, changedValues: any, allValues: any) => {\n const keys = Object.keys(changedValues)\n if (keys.length === 1) {\n keys.forEach((name: any) => {\n if (validateSubmitMap[name]) {\n props.form.setFields({\n [name]: { errors: undefined },\n })\n }\n })\n }\n if (options && options.onValuesChange) {\n options.onValuesChange(props, changedValues, allValues)\n }\n },\n })(CustomFormWrapper)\n}\n\nForm.createFormField = AntdForm.createFormField\nForm.create = Create\n"]}
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/form/form.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,+CAAyC;AAEzC,6DAAwD;AAExD,wDAAkD;AAGlD,oCAAuC;AACvC,uBAAoB;AACpB,4DAAmC;AACnC,+CAA4B;AAWf,QAAA,IAAI,GAAG,IAAA,kBAAU,EAA0B,CAAC,EAAW,EAAE,GAAG,EAAE,EAAE;QAAf,IAAI,cAAT,EAAW,CA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AO,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACrC,CAAC,CAAA;QACD,OAAO,8BAAC,gBAAgB,oBAAK,KAAK,IAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAClD,CAAC,CAAA;IAED,OAAO,cAAQ,CAAC,MAAM,iCACjB,OAAO,KACV,cAAc,EAAE,CAAC,KAAU,EAAE,aAAkB,EAAE,SAAc,EAAE,EAAE;YACjE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;YACvC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;gBACrB,IAAI,CAAC,OAAO,CAAC,CAAC,IAAS,EAAE,EAAE;oBACzB,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;wBAC3B,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;4BACnB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;yBAC9B,CAAC,CAAA;qBACH;gBACH,CAAC,CAAC,CAAA;aACH;YACD,IAAI,OAAO,IAAI,OAAO,CAAC,cAAc,EAAE;gBACrC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,CAAC,CAAA;aACxD;QACH,CAAC,IACD,CAAC,IAAA,kBAAU,EAAC,iBAAiB,CAAC,CAAC,CAAA;AACnC,CAAC,CAAA;AAED,YAAI,CAAC,eAAe,GAAG,cAAQ,CAAC,eAAe,CAAA;AAC/C,YAAI,CAAC,MAAM,GAAG,MAAM,CAAA","sourcesContent":["import type {\n FormItemProps as AntdFormItemProps,\n FormProps as AntdFormProps,\n FormComponentProps,\n FormCreateOption,\n} from 'antd/lib/form'\nimport React, { forwardRef } from 'react'\n\nimport { ConfigConsumer } from 'antd/lib/config-provider'\n\nimport { default as AntdForm } from 'antd/lib/form'\nimport type AntdFormItem from 'antd/lib/form/FormItem'\n\nimport { doUpperTitle } from '../utils'\nimport './form.less'\nimport classNames from 'classnames'\nexport * from 'antd/lib/form'\n\ninterface FormItemComponent\n extends React.ForwardRefExoticComponent<AntdFormItemProps & React.RefAttributes<AntdFormItem>> {}\ninterface FormComponent\n extends React.ForwardRefExoticComponent<AntdFormProps & React.RefAttributes<AntdForm>> {\n Item: FormItemComponent\n create: typeof AntdForm.create\n createFormField: typeof AntdForm.createFormField\n}\n\nexport const Form = forwardRef<AntdForm, AntdFormProps>(({ ...rest }, ref) => {\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n return <AntdForm {...rest} className={classNames(rest.className, 'tnt-form')} ref={ref} />\n }}\n </ConfigConsumer>\n )\n}) as FormComponent\n\nForm.Item = forwardRef<AntdFormItem, AntdFormItemProps>(({ label, ...rest }, ref) => {\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n return <AntdForm.Item {...rest} label={doUpperTitle(label)} ref={ref} />\n }}\n </ConfigConsumer>\n )\n})\n\n// 定义 create 函数的类型\ntype CreateFunction = <TOwnProps extends FormComponentProps<any>>(\n options?: FormCreateOption<TOwnProps>\n) => any\n\nconst Create: CreateFunction = (options: any) => (WrappedComponent: any) => {\n const validateSubmitMap: any = {}\n const CustomFormWrapper = (props: any, ref: any) => {\n const getFieldDecorator = props.form.getFieldDecorator\n props.form.getFieldDecorator = (name: any, options: any) => {\n let opt = options || {}\n if (opt.validateSubmit) {\n opt = {\n ...options,\n validateTrigger: 'noEvent',\n }\n validateSubmitMap[name] = true\n }\n return getFieldDecorator(name, opt)\n }\n return <WrappedComponent {...props} ref={ref} />\n }\n\n return AntdForm.create({\n ...options,\n onValuesChange: (props: any, changedValues: any, allValues: any) => {\n const keys = Object.keys(changedValues)\n if (keys.length === 1) {\n keys.forEach((name: any) => {\n if (validateSubmitMap[name]) {\n props.form.setFields({\n [name]: { errors: undefined },\n })\n }\n })\n }\n if (options && options.onValuesChange) {\n options.onValuesChange(props, changedValues, allValues)\n }\n },\n })(forwardRef(CustomFormWrapper))\n}\n\nForm.createFormField = AntdForm.createFormField\nForm.create = Create\n"]}
@@ -0,0 +1,42 @@
1
+ @form-prefix-cls: ~'@{ant-prefix}-form';
2
+
3
+ .tnt-form {
4
+ .@{form-prefix-cls}-item {
5
+ // min-height: @input-height-base;
6
+
7
+ .@{form-prefix-cls}-item-required::before {
8
+ top: 2px;
9
+ position: relative;
10
+ }
11
+
12
+ &-with-help {
13
+ margin-bottom: @form-item-margin-bottom;
14
+ }
15
+
16
+ &-control {
17
+ line-height: 1;
18
+ min-height: @input-height-base;
19
+ }
20
+
21
+ &-label {
22
+ line-height: @input-height-base;
23
+ }
24
+
25
+ &-children {
26
+ line-height: calc(@input-height-base - 2px);
27
+ }
28
+ }
29
+
30
+ .@{form-prefix-cls}-explain,
31
+ .@{form-prefix-cls}-extra {
32
+ margin-top: 4px;
33
+ }
34
+
35
+ &.@{form-prefix-cls}-vertical{
36
+ .@{form-prefix-cls}-item {
37
+ &-label {
38
+ line-height: @line-height-base;
39
+ }
40
+ }
41
+ }
42
+ }
@@ -83,9 +83,9 @@
83
83
  position: relative;
84
84
  }
85
85
 
86
- &-with-help {
87
- margin-bottom: max(0, @form-item-margin-bottom - @form-explain-height - @form-help-margin-top);
88
- }
86
+ // &-with-help {
87
+ // margin-bottom: max(0, @form-item-margin-bottom - @form-explain-height - @form-help-margin-top);
88
+ // }
89
89
 
90
90
  &-label {
91
91
  display: inline-block;
@@ -310,9 +310,9 @@ form {
310
310
  }
311
311
 
312
312
  .@{form-prefix-cls}-vertical {
313
- .@{form-prefix-cls}-item {
314
- padding-bottom: 8px;
315
- }
313
+ // .@{form-prefix-cls}-item {
314
+ // padding-bottom: 8px;
315
+ // }
316
316
  .@{form-prefix-cls}-item-control {
317
317
  line-height: @line-height-base;
318
318
  }
@@ -0,0 +1,7 @@
1
+ export default HandleIcon;
2
+ declare function HandleIcon(props: any): React.JSX.Element;
3
+ declare namespace HandleIcon {
4
+ function Item(props: any): any;
5
+ }
6
+ import React from "react";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handle-icon/index.js"],"names":[],"mappings":";AAYA,2DAiJC;;IAED,+BAiEC"}
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _LocaleReceiver = _interopRequireDefault(require("antd/lib/locale-provider/LocaleReceiver"));
9
+ var _toArray = _interopRequireDefault(require("rc-util/es/Children/toArray"));
10
+ var _icon = _interopRequireDefault(require("../icon"));
11
+ var _popconfirm = _interopRequireDefault(require("../popconfirm"));
12
+ var _divider = _interopRequireDefault(require("../divider"));
13
+ var _dropdown = _interopRequireDefault(require("../dropdown"));
14
+ var _tooltip = _interopRequireDefault(require("../tooltip"));
15
+ var _utils = require("../utils");
16
+ var _menu = _interopRequireDefault(require("../menu"));
17
+ require("./index.less");
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
20
+ var t = {};
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
22
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+ var HandleIcon = function HandleIcon(props) {
28
+ return _react["default"].createElement(_LocaleReceiver["default"], {
29
+ componentName: "HandleIcon"
30
+ }, function () {
31
+ var _a = props || {},
32
+ _a$children = _a.children,
33
+ children = _a$children === void 0 ? [] : _a$children,
34
+ _a$num = _a.num,
35
+ num = _a$num === void 0 ? 5 : _a$num,
36
+ _a$divider = _a.divider,
37
+ divider = _a$divider === void 0 ? false : _a$divider,
38
+ _a$stopPropagation = _a.stopPropagation,
39
+ stopPropagation = _a$stopPropagation === void 0 ? true : _a$stopPropagation,
40
+ _a$size = _a.size,
41
+ size = _a$size === void 0 ? 'large' : _a$size,
42
+ rest = __rest(_a, ["children", "num", "divider", "stopPropagation", "size"]);
43
+ var newChildren = [];
44
+ if (Array.isArray(children)) {
45
+ newChildren = (children === null || children === void 0 ? void 0 : children.filter(function (item) {
46
+ return !!item;
47
+ })) || [];
48
+ } else if (children) {
49
+ newChildren.push(children);
50
+ }
51
+ var flattenChildren = function flattenChildren(children) {
52
+ if (!children) {
53
+ return [];
54
+ }
55
+ return (0, _toArray["default"])(children).reduce(function (flatChildren, child) {
56
+ if (child && child.type === _react["default"].Fragment) {
57
+ return flatChildren.concat(flattenChildren(child.props.children));
58
+ }
59
+ flatChildren.push(child);
60
+ return flatChildren;
61
+ }, []);
62
+ };
63
+ // 解决需要Fragment包的场景
64
+ newChildren = flattenChildren(newChildren);
65
+ var preChildPart = newChildren,
66
+ lastChildPart = null;
67
+ // 只有1个时不适配
68
+ if (newChildren.length - num === 1) {
69
+ preChildPart = newChildren;
70
+ } else if (newChildren && num && !isNaN(num) && newChildren.length > num) {
71
+ preChildPart = newChildren.slice(0, num);
72
+ lastChildPart = newChildren.slice(num);
73
+ }
74
+ if (divider && preChildPart) {
75
+ preChildPart = preChildPart === null || preChildPart === void 0 ? void 0 : preChildPart.map(function (dom, i) {
76
+ return _react["default"].createElement(_react["default"].Fragment, null, dom, !(i === (preChildPart === null || preChildPart === void 0 ? void 0 : preChildPart.length) - 1 && !(lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.length) // 没有更多 且 是最后一个时 不显示 Divider
77
+ ) && _react["default"].createElement(_divider["default"], {
78
+ type: "vertical"
79
+ }));
80
+ });
81
+ }
82
+ var decoratePopconfirm = function decoratePopconfirm(element, parentElement) {
83
+ if (_react["default"].isValidElement(element)) {
84
+ var type = element.type,
85
+ _props = element.props;
86
+ if (type === _popconfirm["default"]) {
87
+ var placement = {
88
+ placement: 'left'
89
+ };
90
+ var _ref = (parentElement === null || parentElement === void 0 ? void 0 : parentElement.props) || {},
91
+ disabled = _ref.disabled;
92
+ var disableProps = {};
93
+ if (disabled) {
94
+ disableProps = {
95
+ disabled: disabled,
96
+ onConfirm: function onConfirm() {}
97
+ };
98
+ }
99
+ return _react["default"].cloneElement(element, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
100
+ overlayStyle: {
101
+ width: 180
102
+ }
103
+ }, _props || {}), {
104
+ onClick: function onClick(e) {
105
+ return e.stopPropagation();
106
+ }
107
+ }), placement), {
108
+ trigger: 'hover',
109
+ getPopupContainer: function getPopupContainer(trigger) {
110
+ return trigger.parentNode;
111
+ }
112
+ }), disableProps || {}));
113
+ }
114
+ if (_props && _props.children) {
115
+ var modifiedChildren = _react["default"].Children.map(_props.children, function (child) {
116
+ return decoratePopconfirm(child, element);
117
+ });
118
+ return _react["default"].cloneElement(element, _props, modifiedChildren);
119
+ }
120
+ }
121
+ return element;
122
+ };
123
+ // 对更多的popConfirm
124
+ if (lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.length) {
125
+ lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.forEach(function (v, i) {
126
+ v = decoratePopconfirm(v);
127
+ lastChildPart[i] = _react["default"].cloneElement(v, Object.assign(Object.assign({}, (v === null || v === void 0 ? void 0 : v.props) || {}), {
128
+ inMore: true
129
+ }));
130
+ });
131
+ }
132
+ var menu = function menu(childArr) {
133
+ return _react["default"].createElement(_menu["default"], {
134
+ className: "menu-handle-icon-more tnt-handle-icon-".concat(size)
135
+ }, childArr === null || childArr === void 0 ? void 0 : childArr.map(function (child, i) {
136
+ return _react["default"].createElement(_menu["default"].Item, {
137
+ key: i
138
+ }, child);
139
+ }));
140
+ };
141
+ return _react["default"].createElement("div", Object.assign({
142
+ onClick: function onClick(e) {
143
+ if (stopPropagation) {
144
+ e.stopPropagation();
145
+ }
146
+ }
147
+ }, rest, {
148
+ className: "tnt-handle-icon-wrap tnt-handle-icon-".concat(size, " ").concat((rest === null || rest === void 0 ? void 0 : rest.className) || '')
149
+ }), preChildPart, !!(lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.length) && _react["default"].createElement(_dropdown["default"], {
150
+ overlay: menu(lastChildPart || []),
151
+ arrow: true,
152
+ onClick: function onClick(e) {
153
+ stopPropagation && e.stopPropagation();
154
+ }
155
+ }, _react["default"].createElement(_icon["default"], {
156
+ type: "more",
157
+ className: 'tnt-handle-icon-more'
158
+ })));
159
+ });
160
+ };
161
+ HandleIcon.Item = function (props) {
162
+ var children = props.children,
163
+ title = props.title,
164
+ desc = props.desc,
165
+ _props$tooltip = props.tooltip,
166
+ tooltip = _props$tooltip === void 0 ? true : _props$tooltip,
167
+ inMore = props.inMore,
168
+ disabled = props.disabled,
169
+ _props$upperCaseIgnor = props.upperCaseIgnore,
170
+ upperCaseIgnore = _props$upperCaseIgnor === void 0 ? [] : _props$upperCaseIgnor,
171
+ rest = __rest(props, ["children", "title", "desc", "tooltip", "inMore", "disabled", "upperCaseIgnore"]);
172
+ var upTitle = (0, _utils.doUpperTitle)(title, upperCaseIgnore);
173
+ ;
174
+ var replaceIconWithText = function replaceIconWithText(element) {
175
+ if (_react["default"].isValidElement(element)) {
176
+ var type = element.type,
177
+ eleProps = element.props;
178
+ var disabledProps = {};
179
+ if (disabled) {
180
+ disabledProps = {
181
+ disabled: disabled,
182
+ onClick: function onClick(e) {
183
+ e.stopPropagation();
184
+ },
185
+ className: ((eleProps === null || eleProps === void 0 ? void 0 : eleProps.className) || "") + (disabled ? ' disabled' : "")
186
+ };
187
+ }
188
+ // 如果是更多需要替换文字
189
+ if (type === _icon["default"] || type === 'img') {
190
+ if (inMore) {
191
+ return _react["default"].createElement("a", Object.assign({}, eleProps, disabledProps), upTitle);
192
+ }
193
+ }
194
+ if (disabled && (type === _icon["default"] || ['img', 'a'].includes(type))) {
195
+ return _react["default"].cloneElement(element, Object.assign(Object.assign({}, (element === null || element === void 0 ? void 0 : element.props) || {}), disabledProps || {}));
196
+ }
197
+ if (eleProps && eleProps.children) {
198
+ var modifiedChildren = _react["default"].Children.map(eleProps.children, function (child) {
199
+ return replaceIconWithText(child);
200
+ });
201
+ return _react["default"].cloneElement(element, eleProps, modifiedChildren);
202
+ }
203
+ }
204
+ return element;
205
+ };
206
+ var newChildren = children;
207
+ if (Array.isArray(newChildren)) {
208
+ newChildren = children === null || children === void 0 ? void 0 : children.map(function (child) {
209
+ return replaceIconWithText(child);
210
+ });
211
+ } else {
212
+ newChildren = replaceIconWithText(children);
213
+ }
214
+ if ((inMore && desc || !inMore) && tooltip) {
215
+ return _react["default"].createElement(_tooltip["default"], Object.assign({
216
+ title: disabled ? desc || upTitle : upTitle
217
+ }, rest || {}), newChildren);
218
+ }
219
+ return newChildren;
220
+ };
221
+ var _default = exports["default"] = HandleIcon;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handle-icon/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,4FAAmE;AACnE,0EAAkD;AAClD,mDAA0B;AAC1B,+DAAsC;AACtC,yDAAgC;AAChC,2DAAkC;AAClC,yDAAgC;AAChC,oCAAuC;AACvC,mDAA0B;AAC1B,wBAAqB;AAErB,MAAM,UAAU,GAAI,CAAC,KAAK,EAAE,EAAE;IAC5B,OAAO,CACL,8BAAC,wBAAc,IAAC,aAAa,EAAC,YAAY,IACvC,GAAG,EAAE;QACJ,MAAM,KAOF,KAAK,IAAI,EAAE,EAPT,EACF,QAAQ,GAAG,EAAE,EACb,GAAG,GAAG,CAAC,EACP,OAAO,GAAG,KAAK,EACf,eAAe,GAAC,IAAI,EACpB,IAAI,GAAE,OAAO,OAEF,EADR,IAAI,cANL,yDAOL,CAAc,CAAA;QAGf,IAAI,WAAW,GAAG,EAAE,CAAA;QACpB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,WAAW,GAA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,CAAC,EAAC;QAC1B,WAAW,GAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC,KAAK,CAAA,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAA;KACjE;SAAI;QACD,WAAW,GAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAA;KAC7C;IAGD,IAAG,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,OAAO,EAAC;QACxC,OAAO,CACH,8BAAC,iBAAO,kBAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,IAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,IAAM,CAAC,IAAI,IAAE,EAAE,CAAC,GAC/D,WAAW,CACN,CACb,CAAA;KACJ;IAED,OAAO,WAAW,CAAA;AAEtB,CAAC,CAAA;AACD,kBAAe,UAAU,CAAA","sourcesContent":["import React from 'react'\nimport LocaleReceiver from 'antd/lib/locale-provider/LocaleReceiver'\nimport toArray from \"rc-util/es/Children/toArray\";\nimport Icon from '../icon'\nimport PopConfirm from \"../popconfirm\"\nimport Divider from '../divider'\nimport Dropdown from '../dropdown'\nimport Tooltip from '../tooltip'\nimport { doUpperTitle } from '../utils'\nimport Menu from '../menu'\nimport './index.less'\n\nconst HandleIcon = (props) => {\n return (\n <LocaleReceiver componentName=\"HandleIcon\">\n {() => {\n const {\n children = [],\n num = 5,\n divider = false,\n stopPropagation=true,\n size= 'large',\n ...rest\n } = props || {}\n\n \n let newChildren = []\n if (Array.isArray(children)) {\n newChildren = children?.filter((item) => !!item) || []\n } else if (children) {\n newChildren.push(children)\n }\n\n const flattenChildren = (children) => {\n if (!children) {\n return [];\n }\n return toArray(children).reduce(function (flatChildren, child) {\n if (child && child.type === React.Fragment) {\n return flatChildren.concat(flattenChildren(child.props.children));\n }\n \n flatChildren.push(child);\n return flatChildren;\n }, []);\n }\n\n // 解决需要Fragment包的场景\n newChildren = flattenChildren(newChildren);\n\n let [preChildPart, lastChildPart] = [newChildren, null];\n \n // 只有1个时不适配\n if (newChildren.length - num === 1) {\n preChildPart = newChildren\n } else if (newChildren && num && !isNaN(num) && newChildren.length > num) {\n preChildPart = newChildren.slice(0, num)\n lastChildPart = newChildren.slice(num)\n }\n \n if (divider && preChildPart) {\n preChildPart = preChildPart?.map((dom, i) => (\n <>\n {dom}\n {!(\n (i === preChildPart?.length - 1 && !lastChildPart?.length) // 没有更多 且 是最后一个时 不显示 Divider\n ) && <Divider type=\"vertical\" />}\n </>\n ))\n }\n\n const decoratePopconfirm = (element, parentElement) => {\n if (React.isValidElement(element)) {\n const { type, props } = element;\n if (type === PopConfirm ) {\n const placement = { placement: 'left' }\n const {disabled} = parentElement?.props||{}\n let disableProps={};\n if(disabled){\n disableProps={\n disabled,\n onConfirm:()=>{}\n };\n }\n return React.cloneElement(element, {\n overlayStyle: { width: 180 },\n ...(props || {}),\n onClick: (e) => e.stopPropagation(),\n ...placement,\n trigger: 'hover',\n getPopupContainer: (trigger) => trigger.parentNode,\n ...disableProps||{}\n })\n }\n if (props && props.children) {\n const modifiedChildren = React.Children.map(props.children, (child) => {\n return decoratePopconfirm(child,element);\n });\n return React.cloneElement(element, props, modifiedChildren);\n }\n }\n return element;\n };\n \n\n // 对更多的popConfirm\n if(lastChildPart?.length){\n lastChildPart?.forEach((v, i) => {\n v = decoratePopconfirm(v);\n lastChildPart[i] = React.cloneElement(v, {\n ...(v?.props || {}),\n inMore:true,\n })\n }) \n }\n \n const menu = (childArr)=>(\n <Menu className={`menu-handle-icon-more tnt-handle-icon-${size}`}>\n {\n childArr?.map(\n (child,i) => (\n <Menu.Item key={i}>\n {child}\n </Menu.Item>\n )\n )\n }\n </Menu>\n );\n\n return (\n <div\n onClick={(e) => {\n if(stopPropagation){\n e.stopPropagation()\n }\n }}\n {...rest}\n className={`tnt-handle-icon-wrap tnt-handle-icon-${size} ${rest?.className||''}`}\n >\n {preChildPart}\n {!!lastChildPart?.length && (\n <Dropdown \n overlay={menu(lastChildPart || [])} \n arrow \n onClick={(e)=>{\n stopPropagation && e.stopPropagation()\n }}\n >\n <Icon type=\"more\" className='tnt-handle-icon-more'/>\n </Dropdown>\n )}\n </div>\n )\n }}\n </LocaleReceiver>\n )\n}\n\nHandleIcon.Item = (props) => {\n const {children, title, desc, tooltip=true, inMore, disabled,upperCaseIgnore=[],...rest} = props\n const upTitle = doUpperTitle(title,upperCaseIgnore);;\n\n const replaceIconWithText = (element) => {\n if (React.isValidElement(element)) {\n const { type, props:eleProps } = element;\n let disabledProps = {}\n if(disabled){\n disabledProps = {\n disabled,\n onClick:(e)=>{\n e.stopPropagation()\n },\n className:(eleProps?.className || \"\")+ (disabled?' disabled':\"\")\n }\n }\n // 如果是更多需要替换文字\n if (type === Icon || type ==='img') {\n if(inMore){\n return (\n <a \n {...eleProps}\n {...disabledProps}\n \n >{upTitle}</a>\n );\n }\n }\n\n if(disabled && (type===Icon || ['img','a'].includes(type))){\n return React.cloneElement(element, {\n ...element?.props || {} ,\n ...disabledProps||{}\n })\n }\n\n if (eleProps && eleProps.children) {\n const modifiedChildren = React.Children.map(eleProps.children, (child) => {\n return replaceIconWithText(child);\n });\n return React.cloneElement(element, eleProps, modifiedChildren);\n }\n }\n return element;\n };\n\n let newChildren = children;\n if(Array.isArray(newChildren)){\n newChildren= children?.map(child=> replaceIconWithText(child))\n }else{\n newChildren= replaceIconWithText(children)\n }\n\n\n if(((inMore && desc) || !inMore) && tooltip){\n return (\n <Tooltip title={disabled ? (desc||upTitle) : upTitle} {...(rest||{})}>\n {newChildren}\n </Tooltip>\n )\n }\n\n return newChildren\n \n}\nexport default HandleIcon"]}
@@ -0,0 +1,53 @@
1
+ @small-size: 16px;
2
+ @middle-size: 18px;
3
+ @large-size: 20px;
4
+ .tnt-handle-icon-wrap{
5
+ >*:not(:last-child){
6
+ margin-right: 8px;
7
+ }
8
+ }
9
+
10
+ .menu-handle-icon-more{
11
+ min-width: 100px;
12
+ max-width: 300px;
13
+ }
14
+
15
+ [class*=tnt-handle-icon]{
16
+ a{
17
+ display: block;
18
+ overflow: hidden;
19
+ white-space: nowrap;
20
+ text-overflow: ellipsis;
21
+ color:@text-color;
22
+ }
23
+ .icon-disabled,.disabled{
24
+ cursor: not-allowed;
25
+ pointer-events: auto;
26
+ color: @disabled-color;
27
+ }
28
+
29
+ }
30
+ .tnt-handle-icon-small{
31
+ .tntd-anticon{
32
+ font-size: @small-size;
33
+ cursor: pointer;
34
+ }
35
+ font-size: @small-size;
36
+ line-height: 22px;
37
+ }
38
+ .tnt-handle-icon-middle{
39
+ .tntd-anticon{
40
+ font-size: @middle-size;
41
+ cursor: pointer;
42
+ }
43
+ font-size: @middle-size;
44
+ line-height: 22px;
45
+ }
46
+ .tnt-handle-icon-large{
47
+ .tntd-anticon{
48
+ font-size: @large-size;
49
+ cursor: pointer;
50
+ }
51
+ font-size: @large-size;
52
+ line-height: 22px;
53
+ }
@@ -2,5 +2,5 @@
2
2
 
3
3
  .tntd-anticon {
4
4
  font-size: @font-size-lg;
5
- vertical-align: -0.25em;
5
+ vertical-align: -0.1875em;
6
6
  }
package/lib/index.d.ts CHANGED
@@ -84,6 +84,7 @@ export { default as Columns } from './columns';
84
84
  export { default as DevelopmentLogin } from './development-login';
85
85
  export { default as LoadingButton } from './loading-button';
86
86
  export { default as Handle } from './handle';
87
+ export { default as HandleIcon } from './handle-icon';
87
88
  export { default as Page } from './page';
88
89
  export { default as TntdSelect } from './tntd-select';
89
90
  export { default as TntdRcSelect } from './tntd-rc-select';