tntd 2.6.17 → 2.6.19

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 (797) hide show
  1. package/es/actions/index.js +8 -22
  2. package/es/affix/index.js +2 -1
  3. package/es/alert/index.js +2 -1
  4. package/es/anchor/index.js +2 -1
  5. package/es/array-input/icon.js +6 -24
  6. package/es/array-input/index.js +119 -203
  7. package/es/auth-context/index.js +2 -1
  8. package/es/auto-complete/index.js +2 -1
  9. package/es/avatar/index.js +2 -1
  10. package/es/back-top/index.js +2 -1
  11. package/es/badge/index.js +2 -1
  12. package/es/breadcrumb/index.js +2 -1
  13. package/es/button/button.js +46 -0
  14. package/es/button/button.js.map +1 -0
  15. package/es/button/index.js +4 -3
  16. package/es/button/index.js.map +1 -1
  17. package/es/calendar/index.js +2 -1
  18. package/es/card/card.js +25 -0
  19. package/es/card/card.js.map +1 -0
  20. package/es/card/index.js +4 -3
  21. package/es/card/index.js.map +1 -1
  22. package/es/carousel/index.js +2 -1
  23. package/es/cascader/index.js +2 -1
  24. package/es/check-card/group.js +138 -186
  25. package/es/check-card/index.js +107 -150
  26. package/es/checkbox/checkbox-group.js +2 -1
  27. package/es/checkbox/index.js +2 -1
  28. package/es/col/index.js +2 -1
  29. package/es/collapse/index.js +2 -1
  30. package/es/color-picker/ColorPicker.js +80 -126
  31. package/es/color-picker/index.js +5 -8
  32. package/es/columns/index.js +30 -66
  33. package/es/columns/style/index.js +2 -1
  34. package/es/comment/index.js +2 -1
  35. package/es/config-provider/DisabledContext.js +5 -9
  36. package/es/config-provider/SizeContext.js +3 -7
  37. package/es/config-provider/config-provider.js +2 -1
  38. package/es/config-provider/index.js +2 -1
  39. package/es/connect/index.js +20 -23
  40. package/es/date-picker/index.js +6 -9
  41. package/es/descriptions/descriptions.js +30 -38
  42. package/es/descriptions/index.js +2 -1
  43. package/es/development-login/LoginModal.js +46 -81
  44. package/es/development-login/index.js +8 -17
  45. package/es/divider/index.js +2 -1
  46. package/es/drawer/drawer.js +20 -27
  47. package/es/drawer/index.js +2 -1
  48. package/es/dropdown/index.js +2 -1
  49. package/es/ellipsis/Svg/CopySVG.js +16 -63
  50. package/es/ellipsis/Svg/TickSVG.js +11 -41
  51. package/es/ellipsis/index.js +93 -125
  52. package/es/ellipsis/index.js.map +1 -1
  53. package/es/empty/empty.js +48 -58
  54. package/es/empty/empty.stories.js +6 -5
  55. package/es/empty/index.js +2 -1
  56. package/es/exception/exception.js +19 -32
  57. package/es/exception/index.js +2 -1
  58. package/es/form/form.js +68 -0
  59. package/es/form/form.js.map +1 -0
  60. package/es/form/index.js +4 -3
  61. package/es/form/index.js.map +1 -1
  62. package/es/handle/handle.js +102 -0
  63. package/es/handle/handle.js.map +1 -0
  64. package/es/handle/index.js +116 -120
  65. package/es/handle/index.js.map +1 -1
  66. package/es/icon/index.js +2 -1
  67. package/es/icon-list/index.js +120 -1
  68. package/es/img/Contain.js +39 -60
  69. package/es/img/Cover.js +72 -98
  70. package/es/img/index.js +32 -48
  71. package/es/index.js +3 -2
  72. package/es/index.js.map +1 -1
  73. package/es/input/index.js +2 -1
  74. package/es/input/input.js +47 -89
  75. package/es/input/input.js.map +1 -1
  76. package/es/input-number/index.js +2 -1
  77. package/es/label/index.js +98 -115
  78. package/es/layout/index.js +2 -1
  79. package/es/list/index.js +2 -1
  80. package/es/loading-button/index.js +28 -33
  81. package/es/locale/default.js +4 -3
  82. package/es/locale/en_US.js +32 -31
  83. package/es/locale/index.js +2 -1
  84. package/es/locale/zh_CN.js +32 -31
  85. package/es/locale-provider/index.js +3 -2
  86. package/es/mentions/index.js +2 -1
  87. package/es/menu/index.js +2 -1
  88. package/es/message/index.js +2 -1
  89. package/es/modal/index.js +2 -1
  90. package/es/modal/modal.js +20 -23
  91. package/es/modal/modal.js.map +1 -1
  92. package/es/notification/index.js +2 -1
  93. package/es/page/Box.js +33 -49
  94. package/es/page/index.js +84 -120
  95. package/es/page/utils.js +14 -12
  96. package/es/page-header/index.js +2 -1
  97. package/es/pagination/index.js +2 -1
  98. package/es/popconfirm/index.js +2 -1
  99. package/es/popover/index.js +2 -1
  100. package/es/prev-locale.js +47 -49
  101. package/es/preview-text/index.js +177 -247
  102. package/es/progress/index.js +2 -1
  103. package/es/query-form/Field/Checkbox.js +17 -20
  104. package/es/query-form/Field/Select.js +39 -54
  105. package/es/query-form/Field/SelectInput.js +45 -65
  106. package/es/query-form/Field/fieldsMap.js +20 -19
  107. package/es/query-form/Field/index.js +67 -108
  108. package/es/query-form/createActions.js +46 -46
  109. package/es/query-form/index.js +247 -327
  110. package/es/query-form/useForm.js +4 -3
  111. package/es/query-list-scene/List.js +255 -321
  112. package/es/query-list-scene/QueryForm.js +94 -132
  113. package/es/query-list-scene/QueryListScene.js +21 -29
  114. package/es/query-list-scene/Title.js +4 -6
  115. package/es/query-list-scene/Toolbar.js +15 -21
  116. package/es/query-list-scene/createActions.js +60 -60
  117. package/es/query-list-scene/index.js +2 -1
  118. package/es/query-list-scene/useActions.js +4 -3
  119. package/es/radio/index.js +2 -1
  120. package/es/radio/radio-group.js +2 -1
  121. package/es/rate/index.js +2 -1
  122. package/es/render-empty/index.js +2 -1
  123. package/es/render-empty/render-empty.js +16 -19
  124. package/es/result/index.js +2 -1
  125. package/es/row/index.js +2 -1
  126. package/es/segmented/index.js +38 -55
  127. package/es/select/index.js +2 -1
  128. package/es/select/select.js +28 -42
  129. package/es/select/select.js.map +1 -1
  130. package/es/skeleton/index.js +2 -1
  131. package/es/slider/index.js +2 -1
  132. package/es/spin/index.js +2 -1
  133. package/es/statistic/index.js +2 -1
  134. package/es/steps/index.js +2 -1
  135. package/es/steps/steps.js +35 -51
  136. package/es/steps/style/nav.less +1 -1
  137. package/es/svg-components/illustration-403.js +58 -206
  138. package/es/svg-components/illustration-404.js +75 -290
  139. package/es/svg-components/illustration-500.js +83 -321
  140. package/es/svg-components/illustration-empty.js +15 -54
  141. package/es/svg-components/illustration-failure.js +36 -112
  142. package/es/svg-components/illustration-no-access.js +35 -114
  143. package/es/svg-components/illustration-no-chart.js +37 -134
  144. package/es/svg-components/illustration-no-result.js +32 -92
  145. package/es/svg-components/illustration-offline.js +43 -131
  146. package/es/svg-components/illustration-success.js +43 -137
  147. package/es/svg-components/index.js +2 -1
  148. package/es/switch/index.js +2 -1
  149. package/es/switch/switch.js +3 -4
  150. package/es/switch/switch.js.map +1 -1
  151. package/es/table/assets/image-loading-background.js +17 -45
  152. package/es/table/assets/image-loading.js +5 -26
  153. package/es/table/constants.js +54 -2
  154. package/es/table/context.js +2 -1
  155. package/es/table/hooks/index.js +2 -1
  156. package/es/table/hooks/use-column-setting.js +16 -13
  157. package/es/table/index.js +2 -1
  158. package/es/table/table.js +174 -158
  159. package/es/table/table.js.map +1 -1
  160. package/es/table/table.less +3 -1
  161. package/es/table/table.stories.js +139 -148
  162. package/es/table/total-shower.js +4 -8
  163. package/es/table/utils.js +18 -17
  164. package/es/tabs/index.js +4 -3
  165. package/es/tabs/index.js.map +1 -1
  166. package/es/tabs/tabPane.js +2 -0
  167. package/es/tabs/tabPane.js.map +1 -0
  168. package/es/tabs/tabs.js +45 -0
  169. package/es/tabs/tabs.js.map +1 -0
  170. package/es/tag/index.js +2 -1
  171. package/es/time-picker/index.js +2 -1
  172. package/es/timeline/index.js +2 -1
  173. package/es/title/index.js +21 -32
  174. package/es/title/index.js.map +1 -1
  175. package/es/tntd-cascader/AntdCascader/component/DisabledContext.js +5 -9
  176. package/es/tntd-cascader/AntdCascader/component/FormItemInputContext.js +2 -1
  177. package/es/tntd-cascader/AntdCascader/component/SizeContext.js +2 -1
  178. package/es/tntd-cascader/AntdCascader/component/context.js +7 -5
  179. package/es/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js +10 -22
  180. package/es/tntd-cascader/AntdCascader/component/getIcons.js +50 -72
  181. package/es/tntd-cascader/AntdCascader/component/useCompactItemContext.js +20 -22
  182. package/es/tntd-cascader/AntdCascader/config/utils.js +18 -17
  183. package/es/tntd-cascader/AntdCascader/config/warning.js +10 -9
  184. package/es/tntd-cascader/AntdCascader/index.js +118 -189
  185. package/es/tntd-cascader/AntdCascader/index.less +1 -1
  186. package/es/tntd-cascader/AntdCascader/interface.js +2 -1
  187. package/es/tntd-cascader/index.js +2 -1
  188. package/es/tntd-cascader/rc-cascader/Cascader.js +239 -256
  189. package/es/tntd-cascader/rc-cascader/OptionList/Checkbox.js +11 -21
  190. package/es/tntd-cascader/rc-cascader/OptionList/Column.js +116 -175
  191. package/es/tntd-cascader/rc-cascader/OptionList/index.js +128 -180
  192. package/es/tntd-cascader/rc-cascader/OptionList/useActive.js +19 -22
  193. package/es/tntd-cascader/rc-cascader/OptionList/useKeyboard.js +137 -144
  194. package/es/tntd-cascader/rc-cascader/context.js +2 -1
  195. package/es/tntd-cascader/rc-cascader/hooks/useDisplayValues.js +37 -44
  196. package/es/tntd-cascader/rc-cascader/hooks/useEntities.js +24 -25
  197. package/es/tntd-cascader/rc-cascader/hooks/useMissingValues.js +17 -15
  198. package/es/tntd-cascader/rc-cascader/hooks/useRefFunc.js +8 -7
  199. package/es/tntd-cascader/rc-cascader/hooks/useSearchConfig.js +21 -20
  200. package/es/tntd-cascader/rc-cascader/hooks/useSearchOptions.js +41 -51
  201. package/es/tntd-cascader/rc-cascader/index.js +2 -1
  202. package/es/tntd-cascader/rc-cascader/utils/commonUtil.js +27 -33
  203. package/es/tntd-cascader/rc-cascader/utils/treeUtil.js +32 -29
  204. package/es/tntd-cascader/rc-cascader/utils/warningPropsUtil.js +23 -26
  205. package/es/tntd-form/ErrorList.js +41 -75
  206. package/es/tntd-form/Form.js +98 -107
  207. package/es/tntd-form/Form.js.map +1 -1
  208. package/es/tntd-form/FormItem/ItemHolder.js +117 -126
  209. package/es/tntd-form/FormItem/index.js +206 -232
  210. package/es/tntd-form/FormItemInput.js +31 -72
  211. package/es/tntd-form/FormItemLabel.js +62 -87
  212. package/es/tntd-form/FormList.js +27 -33
  213. package/es/tntd-form/_util/motion.js +27 -36
  214. package/es/tntd-form/_util/reactNode.js +9 -10
  215. package/es/tntd-form/_util/scrollTo.js +2 -2
  216. package/es/tntd-form/_util/type.js +2 -1
  217. package/es/tntd-form/_util/warning.js +4 -3
  218. package/es/tntd-form/_util/wave.js +2 -2
  219. package/es/tntd-form/context.js +24 -29
  220. package/es/tntd-form/hooks/useDebounce.js +12 -11
  221. package/es/tntd-form/hooks/useForm.js +28 -33
  222. package/es/tntd-form/hooks/useFormInstance.js +4 -5
  223. package/es/tntd-form/hooks/useFormItemStatus.js +5 -8
  224. package/es/tntd-form/hooks/useFrameState.js +33 -32
  225. package/es/tntd-form/hooks/useItemRef.js +14 -15
  226. package/es/tntd-form/index.js +2 -1
  227. package/es/tntd-form/interface.js +2 -1
  228. package/es/tntd-form/style/index.js +2 -1
  229. package/es/tntd-form/tntd-form.stories.js +383 -731
  230. package/es/tntd-form/tntd-form.stories.js.map +1 -1
  231. package/es/tntd-form/util.js +13 -10
  232. package/es/tntd-form/validateMessagesContext.js +2 -1
  233. package/es/tntd-icon/fonts/iconfont.js +53 -36
  234. package/es/tntd-icon/index.js +17 -23
  235. package/es/tntd-layout/ActionsContext.js +2 -1
  236. package/es/tntd-layout/AppList.js +77 -135
  237. package/es/tntd-layout/Application.js +29 -42
  238. package/es/tntd-layout/Avatar.js +42 -80
  239. package/es/tntd-layout/CompatibleLanguage.js +56 -93
  240. package/es/tntd-layout/EnterpriseLayout/Avatar.js +47 -93
  241. package/es/tntd-layout/EnterpriseLayout/Language.js +34 -56
  242. package/es/tntd-layout/EnterpriseLayout/Theme.js +24 -45
  243. package/es/tntd-layout/EnterpriseLayout/index.js +9 -17
  244. package/es/tntd-layout/GlobalNavigation/NavigationPopup.js +153 -212
  245. package/es/tntd-layout/GlobalNavigation/index.js +50 -84
  246. package/es/tntd-layout/Header.js +26 -59
  247. package/es/tntd-layout/HeaderActions.js +34 -84
  248. package/es/tntd-layout/HeaderNavs.js +35 -46
  249. package/es/tntd-layout/HeaderTabs.js +140 -176
  250. package/es/tntd-layout/Iconfont.js +2 -1
  251. package/es/tntd-layout/Language.js +33 -55
  252. package/es/tntd-layout/Layout.js +78 -176
  253. package/es/tntd-layout/Logo.js +40 -52
  254. package/es/tntd-layout/OrgAppList.js +139 -208
  255. package/es/tntd-layout/SideMenu.js +160 -230
  256. package/es/tntd-layout/Theme.js +29 -47
  257. package/es/tntd-layout/createActions.js +29 -28
  258. package/es/tntd-layout/images/index.js +32 -31
  259. package/es/tntd-layout/index.js +60 -92
  260. package/es/tntd-layout/paaslayout/CompactSideMenu.js +65 -109
  261. package/es/tntd-layout/paaslayout/Header.js +14 -37
  262. package/es/tntd-layout/paaslayout/Logo.js +3 -2
  263. package/es/tntd-layout/paaslayout/SideMenu.js +63 -109
  264. package/es/tntd-layout/paaslayout/index.js +79 -159
  265. package/es/tntd-layout/storage.js +11 -18
  266. package/es/tntd-modal/index.js +34 -90
  267. package/es/tntd-modal/index.js.map +1 -1
  268. package/es/tntd-modal/index.less +66 -82
  269. package/es/tntd-second-page/index.js +24 -47
  270. package/es/tntd-select/DropDownWrap.js +52 -73
  271. package/es/tntd-select/index.js +500 -586
  272. package/es/tntd-select/index.js.map +1 -1
  273. package/es/tooltip/index.js +2 -1
  274. package/es/transfer/index.js +2 -1
  275. package/es/tree/index.js +2 -1
  276. package/es/tree-select/index.js +2 -1
  277. package/es/typography/index.js +2 -1
  278. package/es/upload/index.js +3 -4
  279. package/es/utils/checkAuth.js +21 -24
  280. package/es/utils/findMenuInfoByPath.js +30 -33
  281. package/es/utils/index.js +73 -65
  282. package/es/utils/index.js.map +1 -1
  283. package/es/utils/lang.js +119 -0
  284. package/es/utils/lang.js.map +1 -0
  285. package/es/utils/simple-template.js +3 -2
  286. package/es/version/index.js +2 -1
  287. package/es/water-mark/index.js +87 -98
  288. package/lib/actions/index.js +14 -31
  289. package/lib/affix/index.d.ts +3 -3
  290. package/lib/affix/index.js +22 -23
  291. package/lib/affix/index.js.map +1 -1
  292. package/lib/alert/index.d.ts +3 -3
  293. package/lib/alert/index.js +22 -23
  294. package/lib/alert/index.js.map +1 -1
  295. package/lib/anchor/index.d.ts +3 -3
  296. package/lib/anchor/index.js +22 -23
  297. package/lib/anchor/index.js.map +1 -1
  298. package/lib/array-input/icon.js +12 -33
  299. package/lib/array-input/index.js +150 -254
  300. package/lib/auth-context/index.js +4 -10
  301. package/lib/auto-complete/index.d.ts +3 -3
  302. package/lib/auto-complete/index.js +22 -23
  303. package/lib/auto-complete/index.js.map +1 -1
  304. package/lib/avatar/index.d.ts +3 -3
  305. package/lib/avatar/index.js +22 -23
  306. package/lib/avatar/index.js.map +1 -1
  307. package/lib/back-top/index.d.ts +3 -3
  308. package/lib/back-top/index.js +22 -23
  309. package/lib/back-top/index.js.map +1 -1
  310. package/lib/badge/index.d.ts +3 -3
  311. package/lib/badge/index.js +22 -23
  312. package/lib/badge/index.js.map +1 -1
  313. package/lib/breadcrumb/index.d.ts +3 -3
  314. package/lib/breadcrumb/index.js +22 -23
  315. package/lib/breadcrumb/index.js.map +1 -1
  316. package/lib/button/button.d.ts +10 -0
  317. package/lib/button/button.d.ts.map +1 -0
  318. package/lib/button/button.js +78 -0
  319. package/lib/button/button.js.map +1 -0
  320. package/lib/button/index.d.ts +3 -3
  321. package/lib/button/index.d.ts.map +1 -1
  322. package/lib/button/index.js +19 -23
  323. package/lib/button/index.js.map +1 -1
  324. package/lib/calendar/index.d.ts +3 -3
  325. package/lib/calendar/index.js +22 -23
  326. package/lib/calendar/index.js.map +1 -1
  327. package/lib/card/card.d.ts +10 -0
  328. package/lib/card/card.d.ts.map +1 -0
  329. package/lib/card/card.js +57 -0
  330. package/lib/card/card.js.map +1 -0
  331. package/lib/card/index.d.ts +3 -3
  332. package/lib/card/index.d.ts.map +1 -1
  333. package/lib/card/index.js +19 -23
  334. package/lib/card/index.js.map +1 -1
  335. package/lib/carousel/index.d.ts +3 -3
  336. package/lib/carousel/index.js +22 -23
  337. package/lib/carousel/index.js.map +1 -1
  338. package/lib/cascader/index.d.ts +3 -3
  339. package/lib/cascader/index.js +26 -29
  340. package/lib/cascader/index.js.map +1 -1
  341. package/lib/check-card/group.js +171 -228
  342. package/lib/check-card/index.js +141 -171
  343. package/lib/checkbox/checkbox-group.d.ts +1 -1
  344. package/lib/checkbox/checkbox-group.js +9 -11
  345. package/lib/checkbox/checkbox-group.js.map +1 -1
  346. package/lib/checkbox/index.d.ts +3 -3
  347. package/lib/checkbox/index.js +25 -37
  348. package/lib/checkbox/index.js.map +1 -1
  349. package/lib/col/index.d.ts +3 -3
  350. package/lib/col/index.js +22 -23
  351. package/lib/col/index.js.map +1 -1
  352. package/lib/collapse/index.d.ts +3 -3
  353. package/lib/collapse/index.js +23 -24
  354. package/lib/collapse/index.js.map +1 -1
  355. package/lib/color-picker/ColorPicker.js +113 -156
  356. package/lib/color-picker/index.js +14 -18
  357. package/lib/color-picker/index.js.map +1 -1
  358. package/lib/columns/index.js +41 -81
  359. package/lib/columns/style/index.js +2 -1
  360. package/lib/comment/index.d.ts +3 -3
  361. package/lib/comment/index.js +22 -23
  362. package/lib/comment/index.js.map +1 -1
  363. package/lib/config-provider/DisabledContext.js +31 -18
  364. package/lib/config-provider/SizeContext.js +28 -19
  365. package/lib/config-provider/config-provider.d.ts +1 -1
  366. package/lib/config-provider/config-provider.js +8 -12
  367. package/lib/config-provider/config-provider.js.map +1 -1
  368. package/lib/config-provider/index.d.ts +4 -4
  369. package/lib/config-provider/index.js +23 -35
  370. package/lib/config-provider/index.js.map +1 -1
  371. package/lib/connect/index.js +26 -44
  372. package/lib/date-picker/index.d.ts +4 -4
  373. package/lib/date-picker/index.js +32 -48
  374. package/lib/date-picker/index.js.map +1 -1
  375. package/lib/descriptions/descriptions.d.ts +3 -3
  376. package/lib/descriptions/descriptions.js +55 -64
  377. package/lib/descriptions/descriptions.js.map +1 -1
  378. package/lib/descriptions/index.d.ts +1 -1
  379. package/lib/descriptions/index.js +22 -23
  380. package/lib/descriptions/index.js.map +1 -1
  381. package/lib/development-login/LoginModal.js +79 -110
  382. package/lib/development-login/index.js +35 -42
  383. package/lib/divider/index.d.ts +3 -3
  384. package/lib/divider/index.js +22 -23
  385. package/lib/divider/index.js.map +1 -1
  386. package/lib/drawer/drawer.d.ts +1 -1
  387. package/lib/drawer/drawer.js +30 -41
  388. package/lib/drawer/drawer.js.map +1 -1
  389. package/lib/drawer/index.d.ts +2 -2
  390. package/lib/drawer/index.js +20 -22
  391. package/lib/drawer/index.js.map +1 -1
  392. package/lib/dropdown/index.d.ts +3 -3
  393. package/lib/dropdown/index.js +22 -23
  394. package/lib/dropdown/index.js.map +1 -1
  395. package/lib/ellipsis/Svg/CopySVG.js +20 -70
  396. package/lib/ellipsis/Svg/TickSVG.js +15 -48
  397. package/lib/ellipsis/index.d.ts.map +1 -1
  398. package/lib/ellipsis/index.js +129 -155
  399. package/lib/ellipsis/index.js.map +1 -1
  400. package/lib/empty/empty.d.ts +2 -2
  401. package/lib/empty/empty.js +75 -90
  402. package/lib/empty/empty.js.map +1 -1
  403. package/lib/empty/empty.stories.js +18 -19
  404. package/lib/empty/index.d.ts +1 -1
  405. package/lib/empty/index.js +19 -20
  406. package/lib/empty/index.js.map +1 -1
  407. package/lib/exception/exception.js +31 -46
  408. package/lib/exception/exception.js.map +1 -1
  409. package/lib/exception/index.js +18 -19
  410. package/lib/form/form.d.ts +15 -0
  411. package/lib/form/form.d.ts.map +1 -0
  412. package/lib/form/form.js +100 -0
  413. package/lib/form/form.js.map +1 -0
  414. package/lib/form/index.d.ts +3 -3
  415. package/lib/form/index.d.ts.map +1 -1
  416. package/lib/form/index.js +19 -23
  417. package/lib/form/index.js.map +1 -1
  418. package/lib/handle/handle.d.ts +3 -0
  419. package/lib/handle/handle.d.ts.map +1 -0
  420. package/lib/handle/handle.js +130 -0
  421. package/lib/handle/handle.js.map +1 -0
  422. package/lib/handle/index.d.ts.map +1 -1
  423. package/lib/handle/index.js +149 -152
  424. package/lib/handle/index.js.map +1 -1
  425. package/lib/icon/index.d.ts +3 -3
  426. package/lib/icon/index.js +22 -23
  427. package/lib/icon/index.js.map +1 -1
  428. package/lib/icon-list/index.js +121 -7
  429. package/lib/img/Contain.js +44 -69
  430. package/lib/img/Cover.js +78 -117
  431. package/lib/img/index.js +60 -74
  432. package/lib/index.d.ts +1 -1
  433. package/lib/index.js +195 -642
  434. package/lib/index.js.map +1 -1
  435. package/lib/input/index.d.ts +1 -1
  436. package/lib/input/index.js +20 -21
  437. package/lib/input/index.js.map +1 -1
  438. package/lib/input/input.d.ts +14 -8
  439. package/lib/input/input.d.ts.map +1 -1
  440. package/lib/input/input.js +90 -95
  441. package/lib/input/input.js.map +1 -1
  442. package/lib/input-number/index.d.ts +3 -3
  443. package/lib/input-number/index.js +24 -26
  444. package/lib/input-number/index.js.map +1 -1
  445. package/lib/label/index.d.ts +2 -2
  446. package/lib/label/index.js +137 -134
  447. package/lib/label/index.js.map +1 -1
  448. package/lib/layout/index.d.ts +3 -3
  449. package/lib/layout/index.js +22 -23
  450. package/lib/layout/index.js.map +1 -1
  451. package/lib/list/index.d.ts +3 -3
  452. package/lib/list/index.js +22 -23
  453. package/lib/list/index.js.map +1 -1
  454. package/lib/loading-button/index.js +55 -58
  455. package/lib/locale/default.js +10 -12
  456. package/lib/locale/default.js.map +1 -1
  457. package/lib/locale/en_US.js +37 -39
  458. package/lib/locale/en_US.js.map +1 -1
  459. package/lib/locale/index.js +18 -36
  460. package/lib/locale/zh_CN.js +37 -39
  461. package/lib/locale/zh_CN.js.map +1 -1
  462. package/lib/locale-provider/index.d.ts +3 -3
  463. package/lib/locale-provider/index.js +25 -26
  464. package/lib/locale-provider/index.js.map +1 -1
  465. package/lib/mentions/index.d.ts +3 -3
  466. package/lib/mentions/index.js +22 -23
  467. package/lib/mentions/index.js.map +1 -1
  468. package/lib/menu/index.d.ts +3 -3
  469. package/lib/menu/index.js +22 -23
  470. package/lib/menu/index.js.map +1 -1
  471. package/lib/message/index.d.ts +3 -3
  472. package/lib/message/index.js +22 -23
  473. package/lib/message/index.js.map +1 -1
  474. package/lib/modal/index.d.ts +1 -1
  475. package/lib/modal/index.js +21 -22
  476. package/lib/modal/index.js.map +1 -1
  477. package/lib/modal/modal.d.ts +14 -13
  478. package/lib/modal/modal.d.ts.map +1 -1
  479. package/lib/modal/modal.js +61 -54
  480. package/lib/modal/modal.js.map +1 -1
  481. package/lib/notification/index.d.ts +3 -3
  482. package/lib/notification/index.js +22 -23
  483. package/lib/notification/index.js.map +1 -1
  484. package/lib/page/Box.js +40 -66
  485. package/lib/page/index.js +95 -148
  486. package/lib/page/utils.js +16 -22
  487. package/lib/page-header/index.d.ts +3 -3
  488. package/lib/page-header/index.js +22 -23
  489. package/lib/page-header/index.js.map +1 -1
  490. package/lib/pagination/index.d.ts +3 -3
  491. package/lib/pagination/index.js +22 -23
  492. package/lib/pagination/index.js.map +1 -1
  493. package/lib/popconfirm/index.d.ts +3 -3
  494. package/lib/popconfirm/index.js +22 -23
  495. package/lib/popconfirm/index.js.map +1 -1
  496. package/lib/popover/index.d.ts +3 -3
  497. package/lib/popover/index.js +22 -23
  498. package/lib/popover/index.js.map +1 -1
  499. package/lib/prev-locale.js +54 -68
  500. package/lib/preview-text/index.d.ts +4 -4
  501. package/lib/preview-text/index.js +209 -263
  502. package/lib/preview-text/index.js.map +1 -1
  503. package/lib/progress/index.d.ts +3 -3
  504. package/lib/progress/index.js +22 -23
  505. package/lib/progress/index.js.map +1 -1
  506. package/lib/query-form/Field/Checkbox.js +22 -28
  507. package/lib/query-form/Field/Select.js +68 -79
  508. package/lib/query-form/Field/SelectInput.js +73 -87
  509. package/lib/query-form/Field/fieldsMap.d.ts +4 -2
  510. package/lib/query-form/Field/fieldsMap.js +32 -34
  511. package/lib/query-form/Field/index.js +96 -143
  512. package/lib/query-form/createActions.js +50 -53
  513. package/lib/query-form/index.js +286 -377
  514. package/lib/query-form/useForm.js +11 -11
  515. package/lib/query-list-scene/List.js +289 -360
  516. package/lib/query-list-scene/QueryForm.js +103 -161
  517. package/lib/query-list-scene/QueryListScene.js +31 -66
  518. package/lib/query-list-scene/Title.js +9 -15
  519. package/lib/query-list-scene/Toolbar.js +20 -31
  520. package/lib/query-list-scene/createActions.js +64 -79
  521. package/lib/query-list-scene/index.js +24 -28
  522. package/lib/query-list-scene/useActions.js +11 -11
  523. package/lib/radio/index.d.ts +3 -3
  524. package/lib/radio/index.js +24 -26
  525. package/lib/radio/index.js.map +1 -1
  526. package/lib/radio/radio-group.d.ts +1 -1
  527. package/lib/radio/radio-group.js +9 -11
  528. package/lib/radio/radio-group.js.map +1 -1
  529. package/lib/rate/index.d.ts +3 -3
  530. package/lib/rate/index.js +22 -23
  531. package/lib/rate/index.js.map +1 -1
  532. package/lib/render-empty/index.js +4 -8
  533. package/lib/render-empty/render-empty.js +22 -28
  534. package/lib/render-empty/render-empty.js.map +1 -1
  535. package/lib/result/index.d.ts +3 -3
  536. package/lib/result/index.js +22 -23
  537. package/lib/result/index.js.map +1 -1
  538. package/lib/row/index.d.ts +3 -3
  539. package/lib/row/index.js +22 -23
  540. package/lib/row/index.js.map +1 -1
  541. package/lib/segmented/index.d.ts +1 -1
  542. package/lib/segmented/index.js +69 -71
  543. package/lib/select/index.d.ts +2 -2
  544. package/lib/select/index.js +20 -22
  545. package/lib/select/index.js.map +1 -1
  546. package/lib/select/select.d.ts +2 -2
  547. package/lib/select/select.d.ts.map +1 -1
  548. package/lib/select/select.js +64 -59
  549. package/lib/select/select.js.map +1 -1
  550. package/lib/skeleton/index.d.ts +3 -3
  551. package/lib/skeleton/index.js +22 -23
  552. package/lib/skeleton/index.js.map +1 -1
  553. package/lib/slider/index.d.ts +3 -3
  554. package/lib/slider/index.js +22 -23
  555. package/lib/slider/index.js.map +1 -1
  556. package/lib/spin/index.d.ts +3 -3
  557. package/lib/spin/index.js +22 -23
  558. package/lib/spin/index.js.map +1 -1
  559. package/lib/statistic/index.d.ts +3 -3
  560. package/lib/statistic/index.js +22 -23
  561. package/lib/statistic/index.js.map +1 -1
  562. package/lib/steps/index.d.ts +1 -1
  563. package/lib/steps/index.js +19 -20
  564. package/lib/steps/index.js.map +1 -1
  565. package/lib/steps/steps.d.ts +3 -3
  566. package/lib/steps/steps.js +59 -72
  567. package/lib/steps/steps.js.map +1 -1
  568. package/lib/steps/style/nav.less +1 -1
  569. package/lib/svg-components/illustration-403.d.ts +1 -1
  570. package/lib/svg-components/illustration-403.js +84 -217
  571. package/lib/svg-components/illustration-404.d.ts +1 -1
  572. package/lib/svg-components/illustration-404.js +101 -301
  573. package/lib/svg-components/illustration-500.d.ts +1 -1
  574. package/lib/svg-components/illustration-500.js +109 -332
  575. package/lib/svg-components/illustration-empty.d.ts +1 -1
  576. package/lib/svg-components/illustration-empty.js +41 -65
  577. package/lib/svg-components/illustration-failure.d.ts +1 -1
  578. package/lib/svg-components/illustration-failure.js +62 -123
  579. package/lib/svg-components/illustration-no-access.d.ts +1 -1
  580. package/lib/svg-components/illustration-no-access.js +61 -125
  581. package/lib/svg-components/illustration-no-chart.d.ts +1 -1
  582. package/lib/svg-components/illustration-no-chart.js +63 -145
  583. package/lib/svg-components/illustration-no-result.d.ts +1 -1
  584. package/lib/svg-components/illustration-no-result.js +58 -103
  585. package/lib/svg-components/illustration-offline.d.ts +1 -1
  586. package/lib/svg-components/illustration-offline.js +69 -142
  587. package/lib/svg-components/illustration-success.d.ts +1 -1
  588. package/lib/svg-components/illustration-success.js +69 -148
  589. package/lib/svg-components/index.js +26 -75
  590. package/lib/switch/index.js +21 -22
  591. package/lib/switch/switch.d.ts +4 -4
  592. package/lib/switch/switch.d.ts.map +1 -1
  593. package/lib/switch/switch.js +27 -35
  594. package/lib/switch/switch.js.map +1 -1
  595. package/lib/table/assets/image-loading-background.d.ts +1 -1
  596. package/lib/table/assets/image-loading-background.js +43 -56
  597. package/lib/table/assets/image-loading.d.ts +1 -1
  598. package/lib/table/assets/image-loading.js +31 -37
  599. package/lib/table/constants.js +57 -11
  600. package/lib/table/context.js +4 -7
  601. package/lib/table/hooks/index.js +16 -14
  602. package/lib/table/hooks/use-column-setting.d.ts +1 -1
  603. package/lib/table/hooks/use-column-setting.js +20 -37
  604. package/lib/table/hooks/use-column-setting.js.map +1 -1
  605. package/lib/table/index.d.ts +1 -1
  606. package/lib/table/index.js +19 -20
  607. package/lib/table/index.js.map +1 -1
  608. package/lib/table/table.d.ts +4 -3
  609. package/lib/table/table.d.ts.map +1 -1
  610. package/lib/table/table.js +218 -197
  611. package/lib/table/table.js.map +1 -1
  612. package/lib/table/table.less +3 -1
  613. package/lib/table/table.stories.js +154 -182
  614. package/lib/table/total-shower.d.ts +2 -2
  615. package/lib/table/total-shower.js +10 -14
  616. package/lib/table/total-shower.js.map +1 -1
  617. package/lib/table/utils.d.ts +1 -1
  618. package/lib/table/utils.js +25 -24
  619. package/lib/table/utils.js.map +1 -1
  620. package/lib/tabs/index.d.ts +3 -3
  621. package/lib/tabs/index.d.ts.map +1 -1
  622. package/lib/tabs/index.js +19 -23
  623. package/lib/tabs/index.js.map +1 -1
  624. package/lib/tabs/tabPane.d.ts +1 -0
  625. package/lib/tabs/tabPane.d.ts.map +1 -0
  626. package/lib/tabs/tabPane.js +2 -0
  627. package/lib/tabs/tabPane.js.map +1 -0
  628. package/lib/tabs/tabs.d.ts +12 -0
  629. package/lib/tabs/tabs.d.ts.map +1 -0
  630. package/lib/tabs/tabs.js +77 -0
  631. package/lib/tabs/tabs.js.map +1 -0
  632. package/lib/tag/index.d.ts +3 -3
  633. package/lib/tag/index.js +22 -23
  634. package/lib/tag/index.js.map +1 -1
  635. package/lib/time-picker/index.d.ts +3 -3
  636. package/lib/time-picker/index.js +24 -25
  637. package/lib/time-picker/index.js.map +1 -1
  638. package/lib/timeline/index.d.ts +3 -3
  639. package/lib/timeline/index.js +22 -23
  640. package/lib/timeline/index.js.map +1 -1
  641. package/lib/title/index.d.ts.map +1 -1
  642. package/lib/title/index.js +27 -43
  643. package/lib/title/index.js.map +1 -1
  644. package/lib/tntd-cascader/AntdCascader/component/DisabledContext.js +31 -18
  645. package/lib/tntd-cascader/AntdCascader/component/FormItemInputContext.js +26 -9
  646. package/lib/tntd-cascader/AntdCascader/component/SizeContext.js +26 -9
  647. package/lib/tntd-cascader/AntdCascader/component/context.js +16 -18
  648. package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js +39 -36
  649. package/lib/tntd-cascader/AntdCascader/component/defaultRenderEmpty.js.map +1 -1
  650. package/lib/tntd-cascader/AntdCascader/component/getIcons.js +75 -81
  651. package/lib/tntd-cascader/AntdCascader/component/useCompactItemContext.js +50 -31
  652. package/lib/tntd-cascader/AntdCascader/config/utils.js +27 -29
  653. package/lib/tntd-cascader/AntdCascader/config/warning.js +35 -19
  654. package/lib/tntd-cascader/AntdCascader/index.js +162 -216
  655. package/lib/tntd-cascader/AntdCascader/index.less +1 -1
  656. package/lib/tntd-cascader/AntdCascader/interface.js +6 -13
  657. package/lib/tntd-cascader/img/no-data-s.png +0 -0
  658. package/lib/tntd-cascader/index.js +8 -12
  659. package/lib/tntd-cascader/rc-cascader/Cascader.js +284 -325
  660. package/lib/tntd-cascader/rc-cascader/OptionList/Checkbox.js +41 -30
  661. package/lib/tntd-cascader/rc-cascader/OptionList/Column.js +152 -198
  662. package/lib/tntd-cascader/rc-cascader/OptionList/index.js +163 -223
  663. package/lib/tntd-cascader/rc-cascader/OptionList/useActive.js +48 -40
  664. package/lib/tntd-cascader/rc-cascader/OptionList/useKeyboard.js +166 -179
  665. package/lib/tntd-cascader/rc-cascader/context.js +27 -11
  666. package/lib/tntd-cascader/rc-cascader/hooks/useDisplayValues.js +63 -62
  667. package/lib/tntd-cascader/rc-cascader/hooks/useEntities.js +49 -39
  668. package/lib/tntd-cascader/rc-cascader/hooks/useMissingValues.js +41 -26
  669. package/lib/tntd-cascader/rc-cascader/hooks/useRefFunc.js +33 -16
  670. package/lib/tntd-cascader/rc-cascader/hooks/useSearchConfig.js +51 -30
  671. package/lib/tntd-cascader/rc-cascader/hooks/useSearchOptions.js +65 -75
  672. package/lib/tntd-cascader/rc-cascader/index.js +7 -9
  673. package/lib/tntd-cascader/rc-cascader/utils/commonUtil.js +38 -49
  674. package/lib/tntd-cascader/rc-cascader/utils/treeUtil.js +39 -42
  675. package/lib/tntd-cascader/rc-cascader/utils/warningPropsUtil.js +30 -34
  676. package/lib/tntd-form/ErrorList.js +77 -99
  677. package/lib/tntd-form/Form.d.ts.map +1 -1
  678. package/lib/tntd-form/Form.js +139 -155
  679. package/lib/tntd-form/Form.js.map +1 -1
  680. package/lib/tntd-form/FormItem/ItemHolder.js +155 -154
  681. package/lib/tntd-form/FormItem/index.js +252 -287
  682. package/lib/tntd-form/FormItemInput.js +62 -88
  683. package/lib/tntd-form/FormItemLabel.js +94 -99
  684. package/lib/tntd-form/FormList.js +58 -52
  685. package/lib/tntd-form/_util/motion.js +34 -51
  686. package/lib/tntd-form/_util/reactNode.js +37 -20
  687. package/lib/tntd-form/_util/scrollTo.js +2 -2
  688. package/lib/tntd-form/_util/type.js +5 -17
  689. package/lib/tntd-form/_util/warning.js +29 -17
  690. package/lib/tntd-form/_util/wave.js +2 -2
  691. package/lib/tntd-form/context.js +59 -47
  692. package/lib/tntd-form/hooks/useDebounce.js +37 -28
  693. package/lib/tntd-form/hooks/useForm.js +57 -56
  694. package/lib/tntd-form/hooks/useFormInstance.js +8 -11
  695. package/lib/tntd-form/hooks/useFormItemStatus.js +13 -18
  696. package/lib/tntd-form/hooks/useFrameState.js +63 -51
  697. package/lib/tntd-form/hooks/useItemRef.js +41 -24
  698. package/lib/tntd-form/index.js +43 -26
  699. package/lib/tntd-form/interface.js +4 -6
  700. package/lib/tntd-form/style/index.js +4 -2
  701. package/lib/tntd-form/tntd-form.stories.d.ts.map +1 -1
  702. package/lib/tntd-form/tntd-form.stories.js +437 -858
  703. package/lib/tntd-form/tntd-form.stories.js.map +1 -1
  704. package/lib/tntd-form/util.js +19 -18
  705. package/lib/tntd-form/validateMessagesContext.js +4 -8
  706. package/lib/tntd-icon/fonts/iconfont.js +53 -36
  707. package/lib/tntd-icon/index.js +25 -40
  708. package/lib/tntd-layout/ActionsContext.js +4 -8
  709. package/lib/tntd-layout/AppList.js +224 -173
  710. package/lib/tntd-layout/Application.js +111 -75
  711. package/lib/tntd-layout/Avatar.js +135 -100
  712. package/lib/tntd-layout/CompatibleLanguage.js +180 -128
  713. package/lib/tntd-layout/EnterpriseLayout/Avatar.js +146 -117
  714. package/lib/tntd-layout/EnterpriseLayout/Language.js +90 -73
  715. package/lib/tntd-layout/EnterpriseLayout/Theme.js +102 -69
  716. package/lib/tntd-layout/EnterpriseLayout/index.js +17 -28
  717. package/lib/tntd-layout/GlobalNavigation/NavigationPopup.js +276 -283
  718. package/lib/tntd-layout/GlobalNavigation/index.js +115 -108
  719. package/lib/tntd-layout/Header.js +136 -77
  720. package/lib/tntd-layout/HeaderActions.js +106 -106
  721. package/lib/tntd-layout/HeaderNavs.js +107 -78
  722. package/lib/tntd-layout/HeaderTabs.js +316 -224
  723. package/lib/tntd-layout/Iconfont.js +7 -11
  724. package/lib/tntd-layout/Language.js +76 -69
  725. package/lib/tntd-layout/Layout.js +171 -214
  726. package/lib/tntd-layout/Logo.js +144 -69
  727. package/lib/tntd-layout/OrgAppList.js +388 -238
  728. package/lib/tntd-layout/SideMenu.js +408 -269
  729. package/lib/tntd-layout/Theme.js +93 -75
  730. package/lib/tntd-layout/createActions.js +34 -45
  731. package/lib/tntd-layout/images/avatar/empty.png +0 -0
  732. package/lib/tntd-layout/images/avatar/female1.png +0 -0
  733. package/lib/tntd-layout/images/avatar/female2.png +0 -0
  734. package/lib/tntd-layout/images/avatar/female3.png +0 -0
  735. package/lib/tntd-layout/images/avatar/female4.png +0 -0
  736. package/lib/tntd-layout/images/avatar/female5.png +0 -0
  737. package/lib/tntd-layout/images/avatar/female6.png +0 -0
  738. package/lib/tntd-layout/images/avatar/male1.png +0 -0
  739. package/lib/tntd-layout/images/avatar/male2.png +0 -0
  740. package/lib/tntd-layout/images/avatar/male3.png +0 -0
  741. package/lib/tntd-layout/images/avatar/male4.png +0 -0
  742. package/lib/tntd-layout/images/avatar/male5.png +0 -0
  743. package/lib/tntd-layout/images/avatar/male6.png +0 -0
  744. package/lib/tntd-layout/images/index.js +66 -68
  745. package/lib/tntd-layout/index.js +95 -137
  746. package/lib/tntd-layout/paaslayout/CompactSideMenu.js +182 -131
  747. package/lib/tntd-layout/paaslayout/Header.js +79 -51
  748. package/lib/tntd-layout/paaslayout/Logo.js +30 -15
  749. package/lib/tntd-layout/paaslayout/SideMenu.js +147 -131
  750. package/lib/tntd-layout/paaslayout/index.js +141 -205
  751. package/lib/tntd-layout/storage.js +30 -58
  752. package/lib/tntd-modal/index.d.ts +2 -15
  753. package/lib/tntd-modal/index.d.ts.map +1 -1
  754. package/lib/tntd-modal/index.js +62 -113
  755. package/lib/tntd-modal/index.js.map +1 -1
  756. package/lib/tntd-modal/index.less +66 -82
  757. package/lib/tntd-second-page/index.js +33 -60
  758. package/lib/tntd-second-page/index.js.map +1 -1
  759. package/lib/tntd-select/DropDownWrap.js +78 -102
  760. package/lib/tntd-select/index.d.ts +2 -2
  761. package/lib/tntd-select/index.d.ts.map +1 -1
  762. package/lib/tntd-select/index.js +538 -631
  763. package/lib/tntd-select/index.js.map +1 -1
  764. package/lib/tooltip/index.d.ts +3 -3
  765. package/lib/tooltip/index.js +22 -23
  766. package/lib/tooltip/index.js.map +1 -1
  767. package/lib/transfer/index.d.ts +3 -3
  768. package/lib/transfer/index.js +22 -23
  769. package/lib/transfer/index.js.map +1 -1
  770. package/lib/tree/index.d.ts +3 -3
  771. package/lib/tree/index.js +22 -23
  772. package/lib/tree/index.js.map +1 -1
  773. package/lib/tree-select/index.d.ts +5 -5
  774. package/lib/tree-select/index.js +27 -30
  775. package/lib/tree-select/index.js.map +1 -1
  776. package/lib/typography/index.d.ts +3 -3
  777. package/lib/typography/index.js +22 -23
  778. package/lib/typography/index.js.map +1 -1
  779. package/lib/upload/index.d.ts +2 -2
  780. package/lib/upload/index.js +26 -32
  781. package/lib/upload/index.js.map +1 -1
  782. package/lib/utils/checkAuth.js +23 -34
  783. package/lib/utils/findMenuInfoByPath.js +34 -41
  784. package/lib/utils/index.d.ts +2 -0
  785. package/lib/utils/index.d.ts.map +1 -1
  786. package/lib/utils/index.js +95 -128
  787. package/lib/utils/index.js.map +1 -1
  788. package/lib/utils/lang.d.ts +2 -0
  789. package/lib/utils/lang.d.ts.map +1 -0
  790. package/lib/utils/lang.js +126 -0
  791. package/lib/utils/lang.js.map +1 -0
  792. package/lib/utils/simple-template.js +7 -11
  793. package/lib/version/index.d.ts +3 -3
  794. package/lib/version/index.js +22 -23
  795. package/lib/version/index.js.map +1 -1
  796. package/lib/water-mark/index.js +117 -130
  797. package/package.json +1 -1
@@ -1,616 +1,530 @@
1
- var __rest = this && this.__rest || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
4
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
6
- }
7
- return t;
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
8
11
  };
9
12
  import React, { PureComponent } from 'react';
10
13
  import Select from '../select';
11
14
  import Empty from '../empty';
12
15
  import Spin from '../spin';
13
16
  import DropDownWrap from './DropDownWrap';
17
+ import { capitalizeFirstLetter } from '../utils';
14
18
  // 页面实际渲染的下拉菜单数量,实际为 2 * ITEM_ELEMENT_NUMBER
15
19
  const ITEM_ELEMENT_NUMBER = 30;
16
20
  // Select size 配置
17
21
  const ITEM_HEIGHT_CFG = {
18
- small: 24,
19
- large: 40,
20
- default: 32
22
+ small: 24,
23
+ large: 40,
24
+ default: 32,
21
25
  };
22
26
  const ARROW_CODE = {
23
- 40: 'down',
24
- 38: 'up'
27
+ 40: 'down',
28
+ 38: 'up',
25
29
  };
26
30
  const DROPDOWN_HEIGHT = 224;
27
31
  const Option = Select.Option;
28
32
  class SuperSelect extends PureComponent {
29
- constructor(props) {
30
- super(props);
31
- Object.defineProperty(this, "turnChildren", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: children => {
36
- if (!children) return [];
37
- let arr = [];
38
- if (children && children.props) {
39
- arr.push(children);
40
- } else {
41
- children.forEach(item => {
42
- if (item) {
43
- if (item instanceof Array) {
44
- arr = arr.concat(item);
45
- } else {
46
- arr.push(item);
47
- }
33
+ constructor(props) {
34
+ super(props);
35
+ Object.defineProperty(this, "turnChildren", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: (children) => {
40
+ if (!children)
41
+ return [];
42
+ let arr = [];
43
+ if (children && children.props) {
44
+ arr.push(children);
45
+ }
46
+ else {
47
+ children.forEach((item) => {
48
+ if (item) {
49
+ if (item instanceof Array) {
50
+ arr = arr.concat(item);
51
+ }
52
+ else {
53
+ arr.push(item);
54
+ }
55
+ }
56
+ });
57
+ }
58
+ return arr;
48
59
  }
49
- });
50
- }
51
- return arr;
52
- }
53
- });
54
- Object.defineProperty(this, "formulaWidth", {
55
- enumerable: true,
56
- configurable: true,
57
- writable: true,
58
- value: () => {
59
- // 获取dom设置宽度
60
- const {
61
- children: arr2,
62
- dropdownMatchSelectWidth = true,
63
- maxWidth
64
- } = this.props;
65
- const selectDom = document.getElementById(this.id);
66
- const selectWidth = selectDom.clientWidth || selectDom.offsetWidth;
67
- let arr = [];
68
- let formulaMaxWidth = 10;
69
- if (!dropdownMatchSelectWidth) {
70
- formulaMaxWidth = maxWidth || 10;
71
- }
72
- if (!dropdownMatchSelectWidth && !maxWidth) {
73
- const children = this.turnChildren(arr2);
74
- for (let i = 0; i < children.length; i++) {
75
- const val = children[i].props.children;
76
- const textWidth = this.getTextPixelWith(val);
77
- arr.push(textWidth.toFixed(2));
78
- }
79
- if (arr.length > 0) {
80
- formulaMaxWidth = Math.max(...arr);
81
- }
82
- }
83
- this.setState({
84
- selectWidth,
85
- maxWidth: formulaMaxWidth
86
60
  });
87
- }
88
- });
89
- // 获取单行文本的像素宽度
90
- Object.defineProperty(this, "getTextPixelWith", {
91
- enumerable: true,
92
- configurable: true,
93
- writable: true,
94
- value: (text, fontStyle = '14px') => {
95
- let canvas = document.createElement('canvas'); // 创建 canvas 画布
96
- let context = canvas.getContext('2d'); // 获取 canvas 绘图上下文环境
97
- context.font = fontStyle; // 设置字体样式,使用前设置好对应的 font 样式才能准确获取文字的像素长度
98
- let dimension = context.measureText(text); // 测量文字
99
- return dimension.width;
100
- }
101
- });
102
- Object.defineProperty(this, "getItemStyle", {
103
- enumerable: true,
104
- configurable: true,
105
- writable: true,
106
- value: i => ({
107
- position: 'absolute',
108
- top: this.ITEM_HEIGHT * i,
109
- width: '100%',
110
- height: this.ITEM_HEIGHT
111
- })
112
- });
113
- Object.defineProperty(this, "preventEvent", {
114
- enumerable: true,
115
- configurable: true,
116
- writable: true,
117
- value: e => {
118
- e.preventDefault();
119
- }
120
- });
121
- Object.defineProperty(this, "addEvent", {
122
- enumerable: true,
123
- configurable: true,
124
- writable: true,
125
- value: () => {
126
- this.scrollEle = document.querySelector(`.${this.dropdownClassName}`);
127
- // 下拉菜单未展开时元素不存在
128
- if (!this.scrollEle) return;
129
- this.scrollEle.addEventListener('mousedown', this.preventEvent, false);
130
- this.scrollEle.addEventListener('scroll', this.onScroll, false);
131
- this.inputEle = document.querySelector(`#${this.id}`);
132
- if (!this.inputEle) return;
133
- this.inputEle.addEventListener('keydown', this.onKeyDown, false);
134
- }
135
- });
136
- // 模拟 antd select 按下 上下箭头 键时滚动列表
137
- Object.defineProperty(this, "onKeyDown", {
138
- enumerable: true,
139
- configurable: true,
140
- writable: true,
141
- value: e => {
142
- const {
143
- keyCode
144
- } = e || {};
145
- setTimeout(() => {
146
- const activeItem = document.querySelector(`.${this.dropdownClassName} .ant-select-dropdown-menu-item-active`);
147
- if (!activeItem) return;
148
- const {
149
- offsetTop
150
- } = activeItem;
151
- const isUp = ARROW_CODE[keyCode] === 'up';
152
- const isDown = ARROW_CODE[keyCode] === 'down';
153
- // 在所有列表第一行按上键
154
- if (offsetTop - this.prevTop > DROPDOWN_HEIGHT && isUp && this.scrollEle) {
155
- this.scrollEle.scrollTo(0, this.allHeight - DROPDOWN_HEIGHT);
156
- this.prevTop = this.allHeight;
157
- return;
158
- }
159
- // 在所有列表中最后一行按下键
160
- if (this.prevTop > offsetTop + DROPDOWN_HEIGHT && isDown && this.scrollEle) {
161
- this.scrollEle.scrollTo(0, 0);
162
- this.prevTop = 0;
163
- return;
164
- }
165
- this.prevTop = offsetTop;
166
- // 向下滚动到下拉框最后一行时,向下滚动一行的高度
167
- if (offsetTop > this.scrollEle.scrollTop + DROPDOWN_HEIGHT - this.ITEM_HEIGHT + 10 && isDown) {
168
- this.scrollEle.scrollTo(0, this.scrollTop + this.ITEM_HEIGHT);
169
- return;
170
- }
171
- // 向上滚动到下拉框第一一行时,向上滚动一行的高度
172
- if (offsetTop < this.scrollEle.scrollTop && isUp) {
173
- this.scrollEle.scrollTo(0, this.scrollTop - this.ITEM_HEIGHT);
174
- }
175
- }, 100);
176
- }
177
- });
178
- Object.defineProperty(this, "onScroll", {
179
- enumerable: true,
180
- configurable: true,
181
- writable: true,
182
- value: () => this.throttleByHeight(this.onScrollReal)
183
- });
184
- Object.defineProperty(this, "onScrollReal", {
185
- enumerable: true,
186
- configurable: true,
187
- writable: true,
188
- value: () => {
189
- this.allList = this.getUseChildrenList();
190
- const {
191
- startIndex,
192
- endIndex
193
- } = this.getStartAndEndIndex();
194
- this.prevScrollTop = this.scrollTop;
195
- // 重新渲染列表组件 Wrap
196
- const allHeight = this.allList.length * this.ITEM_HEIGHT || 100;
197
- this.wrap.reactList(allHeight, startIndex, endIndex);
198
- }
199
- });
200
- Object.defineProperty(this, "throttleByHeight", {
201
- enumerable: true,
202
- configurable: true,
203
- writable: true,
204
- value: () => {
205
- this.scrollTop = this.scrollEle.scrollTop;
206
- // 滚动的高度
207
- let delta = this.prevScrollTop - this.scrollTop;
208
- delta = delta < 0 ? 0 - delta : delta;
209
- delta > this.reactDelta && this.onScrollReal();
210
- }
211
- });
212
- // 列表可展示所有 children
213
- Object.defineProperty(this, "getUseChildrenList", {
214
- enumerable: true,
215
- configurable: true,
216
- writable: true,
217
- value: () => this.state.filterChildren || this.state.children
218
- });
219
- Object.defineProperty(this, "getStartAndEndIndex", {
220
- enumerable: true,
221
- configurable: true,
222
- writable: true,
223
- value: () => {
224
- // 滚动后显示在列表可视区中的第一个 item 的 index
225
- const showIndex = Number((this.scrollTop / this.ITEM_HEIGHT).toFixed(0));
226
- const startIndex = showIndex - ITEM_ELEMENT_NUMBER < 0 ? 0 : showIndex - ITEM_ELEMENT_NUMBER / 2;
227
- const endIndex = showIndex + ITEM_ELEMENT_NUMBER;
228
- return {
229
- startIndex,
230
- endIndex
61
+ Object.defineProperty(this, "formulaWidth", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: () => {
66
+ // 获取dom设置宽度
67
+ const { children: arr2, dropdownMatchSelectWidth = true, maxWidth } = this.props;
68
+ const selectDom = document.getElementById(this.id);
69
+ const selectWidth = selectDom.clientWidth || selectDom.offsetWidth;
70
+ let arr = [];
71
+ let formulaMaxWidth = 10;
72
+ if (!dropdownMatchSelectWidth) {
73
+ formulaMaxWidth = maxWidth || 10;
74
+ }
75
+ if (!dropdownMatchSelectWidth && !maxWidth) {
76
+ const children = this.turnChildren(arr2);
77
+ for (let i = 0; i < children.length; i++) {
78
+ const val = children[i].props.children;
79
+ const textWidth = this.getTextPixelWith(val);
80
+ arr.push(textWidth.toFixed(2));
81
+ }
82
+ if (arr.length > 0) {
83
+ formulaMaxWidth = Math.max(...arr);
84
+ }
85
+ }
86
+ this.setState({
87
+ selectWidth,
88
+ maxWidth: formulaMaxWidth,
89
+ });
90
+ }
91
+ });
92
+ // 获取单行文本的像素宽度
93
+ Object.defineProperty(this, "getTextPixelWith", {
94
+ enumerable: true,
95
+ configurable: true,
96
+ writable: true,
97
+ value: (text, fontStyle = '14px') => {
98
+ let canvas = document.createElement('canvas'); // 创建 canvas 画布
99
+ let context = canvas.getContext('2d'); // 获取 canvas 绘图上下文环境
100
+ context.font = fontStyle; // 设置字体样式,使用前设置好对应的 font 样式才能准确获取文字的像素长度
101
+ let dimension = context.measureText(text); // 测量文字
102
+ return dimension.width;
103
+ }
104
+ });
105
+ Object.defineProperty(this, "getItemStyle", {
106
+ enumerable: true,
107
+ configurable: true,
108
+ writable: true,
109
+ value: (i) => ({
110
+ position: 'absolute',
111
+ top: this.ITEM_HEIGHT * i,
112
+ width: '100%',
113
+ height: this.ITEM_HEIGHT,
114
+ })
115
+ });
116
+ Object.defineProperty(this, "preventEvent", {
117
+ enumerable: true,
118
+ configurable: true,
119
+ writable: true,
120
+ value: (e) => {
121
+ e.preventDefault();
122
+ }
123
+ });
124
+ Object.defineProperty(this, "addEvent", {
125
+ enumerable: true,
126
+ configurable: true,
127
+ writable: true,
128
+ value: () => {
129
+ this.scrollEle = document.querySelector(`.${this.dropdownClassName}`);
130
+ // 下拉菜单未展开时元素不存在
131
+ if (!this.scrollEle)
132
+ return;
133
+ this.scrollEle.addEventListener('mousedown', this.preventEvent, false);
134
+ this.scrollEle.addEventListener('scroll', this.onScroll, false);
135
+ this.inputEle = document.querySelector(`#${this.id}`);
136
+ if (!this.inputEle)
137
+ return;
138
+ this.inputEle.addEventListener('keydown', this.onKeyDown, false);
139
+ }
140
+ });
141
+ // 模拟 antd select 按下 上下箭头 键时滚动列表
142
+ Object.defineProperty(this, "onKeyDown", {
143
+ enumerable: true,
144
+ configurable: true,
145
+ writable: true,
146
+ value: (e) => {
147
+ const { keyCode } = e || {};
148
+ setTimeout(() => {
149
+ const activeItem = document.querySelector(`.${this.dropdownClassName} .ant-select-dropdown-menu-item-active`);
150
+ if (!activeItem)
151
+ return;
152
+ const { offsetTop } = activeItem;
153
+ const isUp = ARROW_CODE[keyCode] === 'up';
154
+ const isDown = ARROW_CODE[keyCode] === 'down';
155
+ // 在所有列表第一行按上键
156
+ if (offsetTop - this.prevTop > DROPDOWN_HEIGHT && isUp && this.scrollEle) {
157
+ this.scrollEle.scrollTo(0, this.allHeight - DROPDOWN_HEIGHT);
158
+ this.prevTop = this.allHeight;
159
+ return;
160
+ }
161
+ // 在所有列表中最后一行按下键
162
+ if (this.prevTop > offsetTop + DROPDOWN_HEIGHT && isDown && this.scrollEle) {
163
+ this.scrollEle.scrollTo(0, 0);
164
+ this.prevTop = 0;
165
+ return;
166
+ }
167
+ this.prevTop = offsetTop;
168
+ // 向下滚动到下拉框最后一行时,向下滚动一行的高度
169
+ if (offsetTop > this.scrollEle.scrollTop + DROPDOWN_HEIGHT - this.ITEM_HEIGHT + 10 &&
170
+ isDown) {
171
+ this.scrollEle.scrollTo(0, this.scrollTop + this.ITEM_HEIGHT);
172
+ return;
173
+ }
174
+ // 向上滚动到下拉框第一一行时,向上滚动一行的高度
175
+ if (offsetTop < this.scrollEle.scrollTop && isUp) {
176
+ this.scrollEle.scrollTo(0, this.scrollTop - this.ITEM_HEIGHT);
177
+ }
178
+ }, 100);
179
+ }
180
+ });
181
+ Object.defineProperty(this, "onScroll", {
182
+ enumerable: true,
183
+ configurable: true,
184
+ writable: true,
185
+ value: () => this.throttleByHeight(this.onScrollReal)
186
+ });
187
+ Object.defineProperty(this, "onScrollReal", {
188
+ enumerable: true,
189
+ configurable: true,
190
+ writable: true,
191
+ value: () => {
192
+ this.allList = this.getUseChildrenList();
193
+ const { startIndex, endIndex } = this.getStartAndEndIndex();
194
+ this.prevScrollTop = this.scrollTop;
195
+ // 重新渲染列表组件 Wrap
196
+ const allHeight = this.allList.length * this.ITEM_HEIGHT || 100;
197
+ this.wrap.reactList(allHeight, startIndex, endIndex);
198
+ }
199
+ });
200
+ Object.defineProperty(this, "throttleByHeight", {
201
+ enumerable: true,
202
+ configurable: true,
203
+ writable: true,
204
+ value: () => {
205
+ this.scrollTop = this.scrollEle.scrollTop;
206
+ // 滚动的高度
207
+ let delta = this.prevScrollTop - this.scrollTop;
208
+ delta = delta < 0 ? 0 - delta : delta;
209
+ delta > this.reactDelta && this.onScrollReal();
210
+ }
211
+ });
212
+ // 列表可展示所有 children
213
+ Object.defineProperty(this, "getUseChildrenList", {
214
+ enumerable: true,
215
+ configurable: true,
216
+ writable: true,
217
+ value: () => this.state.filterChildren || this.state.children
218
+ });
219
+ Object.defineProperty(this, "getStartAndEndIndex", {
220
+ enumerable: true,
221
+ configurable: true,
222
+ writable: true,
223
+ value: () => {
224
+ // 滚动后显示在列表可视区中的第一个 item 的 index
225
+ const showIndex = Number((this.scrollTop / this.ITEM_HEIGHT).toFixed(0));
226
+ const startIndex = showIndex - ITEM_ELEMENT_NUMBER < 0 ? 0 : showIndex - ITEM_ELEMENT_NUMBER / 2;
227
+ const endIndex = showIndex + ITEM_ELEMENT_NUMBER;
228
+ return { startIndex, endIndex };
229
+ }
230
+ });
231
+ // 须使用 setTimeout 确保在 dom 加载完成之后添加事件
232
+ Object.defineProperty(this, "setSuperDrowDownMenu", {
233
+ enumerable: true,
234
+ configurable: true,
235
+ writable: true,
236
+ value: (visible) => {
237
+ if (!visible)
238
+ return;
239
+ this.allList = this.getUseChildrenList();
240
+ if (!this.eventTimer || !this.scrollEle) {
241
+ this.eventTimer = setTimeout(() => this.addEvent(), 0);
242
+ }
243
+ else {
244
+ const allHeight = this.allList.length * this.ITEM_HEIGHT || 100;
245
+ // 下拉列表单独重新渲染
246
+ const { startIndex, endIndex } = this.getStartAndEndIndex();
247
+ setTimeout(() => {
248
+ this.wrap && this.wrap.reactList(allHeight, startIndex, endIndex);
249
+ }, 0);
250
+ }
251
+ }
252
+ });
253
+ Object.defineProperty(this, "onDropdownVisibleChange", {
254
+ enumerable: true,
255
+ configurable: true,
256
+ writable: true,
257
+ value: (visible) => {
258
+ const { onDropdownVisibleChange } = this.props;
259
+ onDropdownVisibleChange && onDropdownVisibleChange(visible);
260
+ const { value, children } = this.state;
261
+ // 关闭下拉框前清空筛选条件,防止下次打开任然显示筛选后的 options
262
+ if (!visible) {
263
+ // 定时器确保关闭后再设置 filterChildren,防止列表刷新闪烁
264
+ setTimeout(() => {
265
+ this.setState({ filterChildren: null });
266
+ this.setDefaultScrollTop(value);
267
+ }, 100);
268
+ // this.removeEvent();
269
+ }
270
+ else {
271
+ // this.addEvent();
272
+ if (value) {
273
+ // 如果已有 value, 设置默认滚动位置
274
+ this.setDefaultScrollTop();
275
+ // 设置下拉列表显示数据
276
+ this.setSuperDrowDownMenu(visible);
277
+ }
278
+ else if (!value && value !== 0 && children && children.length > 0) {
279
+ // 无数据时,下拉回归至第一个
280
+ const val = children[0].props.value;
281
+ this.setDefaultScrollTop(val);
282
+ }
283
+ }
284
+ }
285
+ });
286
+ Object.defineProperty(this, "onDeselect", {
287
+ enumerable: true,
288
+ configurable: true,
289
+ writable: true,
290
+ value: (value) => {
291
+ const { onDeselect } = this.props;
292
+ onDeselect && onDeselect(value);
293
+ }
294
+ });
295
+ // 在搜索重新计算下拉滚动条高度
296
+ Object.defineProperty(this, "onChange", {
297
+ enumerable: true,
298
+ configurable: true,
299
+ writable: true,
300
+ value: (value, opt) => {
301
+ const { showSearch, onChange, autoClearSearchValue, maxCount, mode } = this.props;
302
+ if (showSearch || this.isMultiple) {
303
+ // 搜索模式下选择后是否需要重置搜索状态
304
+ if (autoClearSearchValue !== false) {
305
+ this.setState({ filterChildren: null }, () => {
306
+ // 搜索成功后重新设置列表的总高度
307
+ this.setSuperDrowDownMenu(true);
308
+ });
309
+ }
310
+ }
311
+ if (mode === 'multiple') {
312
+ if (value.length <= maxCount) {
313
+ this.setState({ value });
314
+ }
315
+ }
316
+ else {
317
+ this.setState({ value });
318
+ }
319
+ onChange && onChange(value, opt);
320
+ if (mode !== 'multiple') {
321
+ this.select && this.select.blur();
322
+ }
323
+ }
324
+ });
325
+ Object.defineProperty(this, "onSearch", {
326
+ enumerable: true,
327
+ configurable: true,
328
+ writable: true,
329
+ value: (v) => {
330
+ const { showSearch, onSearch, filterOption, children: arr } = this.props;
331
+ let children = this.turnChildren(arr);
332
+ if (showSearch && filterOption !== false) {
333
+ // 须根据 filterOption(如有该自定义函数)手动 filter 搜索匹配的列表
334
+ let filterChildren = null;
335
+ if (typeof filterOption === 'function') {
336
+ filterChildren = children.filter((item) => filterOption(v, item));
337
+ }
338
+ else if (filterOption === undefined) {
339
+ filterChildren = children.filter((item) => this.filterOption(v, item));
340
+ }
341
+ // 搜索框有值,去除disabled=true的children
342
+ let newFilterChild = [];
343
+ filterChildren &&
344
+ filterChildren.forEach((item, index) => {
345
+ if (!item.props.disabled) {
346
+ newFilterChild.push(item);
347
+ }
348
+ });
349
+ filterChildren = newFilterChild;
350
+ // 设置下拉列表显示数据
351
+ this.setState({ filterChildren: v === '' ? null : filterChildren }, () => {
352
+ setTimeout(() => {
353
+ // 搜索后需要重置滚动位置到0,防止上次 scrollTop 位置无数据
354
+ if (filterChildren && this.scrollEle) {
355
+ this.scrollTop = 0;
356
+ this.scrollEle.scrollTo(0, 0);
357
+ }
358
+ // 搜索成功后需要重新设置列表的总高度
359
+ this.setSuperDrowDownMenu(true);
360
+ }, 0);
361
+ });
362
+ }
363
+ onSearch && onSearch(v);
364
+ }
365
+ });
366
+ Object.defineProperty(this, "filterOption", {
367
+ enumerable: true,
368
+ configurable: true,
369
+ writable: true,
370
+ value: (v, option) => {
371
+ // 自定义过滤对应的 option 属性配置
372
+ const filterProps = this.props.optionFilterProp || 'value';
373
+ return `${option.props[filterProps]}`.indexOf(v) >= 0;
374
+ }
375
+ });
376
+ Object.defineProperty(this, "setDefaultScrollTop", {
377
+ enumerable: true,
378
+ configurable: true,
379
+ writable: true,
380
+ value: (data) => {
381
+ const { value } = this.state;
382
+ const { children: arr } = this.props;
383
+ const children = this.turnChildren(arr);
384
+ let val = data || data === 0 ? data : value;
385
+ for (let i = 0; i < children.length; i++) {
386
+ const item = children[i];
387
+ const itemValue = item.props.value;
388
+ if (itemValue === val || (Array.isArray(val) && val.includes(itemValue))) {
389
+ const targetScrollTop = i * this.ITEM_HEIGHT;
390
+ setTimeout(() => {
391
+ if (!this.scrollEle) {
392
+ this.addEvent();
393
+ }
394
+ this.scrollEle && this.scrollEle.scrollTo(0, targetScrollTop);
395
+ }, 100);
396
+ return;
397
+ }
398
+ }
399
+ }
400
+ });
401
+ Object.defineProperty(this, "removeEvent", {
402
+ enumerable: true,
403
+ configurable: true,
404
+ writable: true,
405
+ value: () => {
406
+ if (!this.scrollEle)
407
+ return;
408
+ this.scrollEle.removeEventListener('mousedown', this.preventEvent, false);
409
+ this.scrollEle.removeEventListener('scroll', this.onScroll, false);
410
+ if (!this.inputEle)
411
+ return;
412
+ this.inputEle.removeEventListener('keydown', this.onKeyDown, false);
413
+ }
414
+ });
415
+ const { mode, defaultValue, value, optionHeight, children: arr } = props;
416
+ this.isMultiple = ['tags', 'multiple'].includes(mode);
417
+ const children = this.turnChildren(arr);
418
+ // 设置默认 value
419
+ let defaultV = this.isMultiple ? [] : '';
420
+ defaultV = value || defaultValue || defaultV;
421
+ this.state = {
422
+ children: children || [],
423
+ filterChildren: null,
424
+ value: defaultV,
425
+ maxWidth: null,
426
+ selectWidth: null,
231
427
  };
232
- }
233
- });
234
- // 须使用 setTimeout 确保在 dom 加载完成之后添加事件
235
- Object.defineProperty(this, "setSuperDrowDownMenu", {
236
- enumerable: true,
237
- configurable: true,
238
- writable: true,
239
- value: visible => {
240
- if (!visible) return;
241
- this.allList = this.getUseChildrenList();
242
- if (!this.eventTimer || !this.scrollEle) {
243
- this.eventTimer = setTimeout(() => this.addEvent(), 0);
244
- } else {
245
- const allHeight = this.allList.length * this.ITEM_HEIGHT || 100;
246
- // 下拉列表单独重新渲染
247
- const {
248
- startIndex,
249
- endIndex
250
- } = this.getStartAndEndIndex();
251
- setTimeout(() => {
252
- this.wrap && this.wrap.reactList(allHeight, startIndex, endIndex);
253
- }, 0);
254
- }
255
- }
256
- });
257
- Object.defineProperty(this, "onDropdownVisibleChange", {
258
- enumerable: true,
259
- configurable: true,
260
- writable: true,
261
- value: visible => {
262
- const {
263
- onDropdownVisibleChange
264
- } = this.props;
265
- onDropdownVisibleChange && onDropdownVisibleChange(visible);
266
- const {
267
- value,
268
- children
269
- } = this.state;
270
- // 关闭下拉框前清空筛选条件,防止下次打开任然显示筛选后的 options
271
- if (!visible) {
272
- // 定时器确保关闭后再设置 filterChildren,防止列表刷新闪烁
273
- setTimeout(() => {
274
- this.setState({
275
- filterChildren: null
276
- });
277
- this.setDefaultScrollTop(value);
278
- }, 100);
279
- // this.removeEvent();
280
- } else {
281
- // this.addEvent();
282
- if (value) {
283
- // 如果已有 value, 设置默认滚动位置
284
- this.setDefaultScrollTop();
285
- // 设置下拉列表显示数据
286
- this.setSuperDrowDownMenu(visible);
287
- } else if (!value && value !== 0 && children && children.length > 0) {
288
- // 无数据时,下拉回归至第一个
289
- const val = children[0].props.value;
290
- this.setDefaultScrollTop(val);
291
- }
292
- }
293
- }
294
- });
295
- Object.defineProperty(this, "onDeselect", {
296
- enumerable: true,
297
- configurable: true,
298
- writable: true,
299
- value: value => {
300
- const {
301
- onDeselect
302
- } = this.props;
303
- onDeselect && onDeselect(value);
304
- }
305
- });
306
- // 在搜索重新计算下拉滚动条高度
307
- Object.defineProperty(this, "onChange", {
308
- enumerable: true,
309
- configurable: true,
310
- writable: true,
311
- value: (value, opt) => {
312
- const {
313
- showSearch,
314
- onChange,
315
- autoClearSearchValue,
316
- maxCount,
317
- mode
318
- } = this.props;
319
- if (showSearch || this.isMultiple) {
320
- // 搜索模式下选择后是否需要重置搜索状态
321
- if (autoClearSearchValue !== false) {
428
+ // 下拉菜单项行高
429
+ this.ITEM_HEIGHT = optionHeight || ITEM_HEIGHT_CFG[props.size || 'default'];
430
+ // 可视区 dom 高度
431
+ this.visibleDomHeight = this.ITEM_HEIGHT * ITEM_ELEMENT_NUMBER;
432
+ // 滚动时重新渲染的 scrollTop 判断值,大于 reactDelta 则刷新下拉列表
433
+ this.reactDelta = this.visibleDomHeight / 3;
434
+ // 是否拖动滚动条快速滚动状态
435
+ this.isStopReact = false;
436
+ // 上一次滚动的 scrollTop 值
437
+ this.prevScrollTop = 0;
438
+ // 上一次按下方向键时 scrollTop
439
+ this.prevTop = 0;
440
+ this.scrollTop = 0;
441
+ // className
442
+ this.dropdownClassName = `dc${+new Date()}`;
443
+ this.id = `sid${+new Date()}`;
444
+ }
445
+ componentDidMount() {
446
+ // defaultOpens=true 时添加滚动事件
447
+ setTimeout(() => {
448
+ this.addEvent();
449
+ }, 500);
450
+ const { children: arr } = this.props;
451
+ const children = this.turnChildren(arr);
452
+ // if (children && children.length > 0) {
453
+ this.formulaWidth();
454
+ // }
455
+ }
456
+ componentDidUpdate(prevProps) {
457
+ const { mode, defaultValue, value, children } = this.props;
458
+ let arr = this.turnChildren(children);
459
+ if (prevProps.children !== children) {
460
+ this.isMultiple = ['tags', 'multiple'].includes(mode);
322
461
  this.setState({
323
- filterChildren: null
462
+ children: arr || [],
463
+ filterChildren: null,
324
464
  }, () => {
325
- // 搜索成功后重新设置列表的总高度
326
- this.setSuperDrowDownMenu(true);
465
+ if (arr && arr.length > 0) {
466
+ this.formulaWidth();
467
+ if (!this.inputEle) {
468
+ this.removeEvent();
469
+ this.addEvent();
470
+ }
471
+ }
327
472
  });
328
- }
329
473
  }
330
- if (mode === 'multiple') {
331
- if (value.length <= maxCount) {
332
- this.setState({
333
- value
334
- });
335
- }
336
- } else {
337
- this.setState({
338
- value
339
- });
474
+ if (prevProps.value !== value) {
475
+ // 更新时设置默认 value
476
+ let defaultV = this.isMultiple ? [] : '';
477
+ defaultV = value || defaultValue || defaultV;
478
+ this.setState({ value: defaultV });
340
479
  }
341
- onChange && onChange(value, opt);
342
- if (mode !== 'multiple') {
343
- this.select && this.select.blur();
344
- }
345
- }
346
- });
347
- Object.defineProperty(this, "onSearch", {
348
- enumerable: true,
349
- configurable: true,
350
- writable: true,
351
- value: v => {
352
- const {
353
- showSearch,
354
- onSearch,
355
- filterOption,
356
- children: arr
357
- } = this.props;
358
- let children = this.turnChildren(arr);
359
- if (showSearch && filterOption !== false) {
360
- // 须根据 filterOption(如有该自定义函数)手动 filter 搜索匹配的列表
361
- let filterChildren = null;
362
- if (typeof filterOption === 'function') {
363
- filterChildren = children.filter(item => filterOption(v, item));
364
- } else if (filterOption === undefined) {
365
- filterChildren = children.filter(item => this.filterOption(v, item));
366
- }
367
- // 搜索框有值,去除disabled=true的children
368
- let newFilterChild = [];
369
- filterChildren && filterChildren.forEach((item, index) => {
370
- if (!item.props.disabled) {
371
- newFilterChild.push(item);
372
- }
373
- });
374
- filterChildren = newFilterChild;
375
- // 设置下拉列表显示数据
376
- this.setState({
377
- filterChildren: v === '' ? null : filterChildren
378
- }, () => {
379
- setTimeout(() => {
380
- // 搜索后需要重置滚动位置到0,防止上次 scrollTop 位置无数据
381
- if (filterChildren && this.scrollEle) {
382
- this.scrollTop = 0;
383
- this.scrollEle.scrollTo(0, 0);
384
- }
385
- // 搜索成功后需要重新设置列表的总高度
386
- this.setSuperDrowDownMenu(true);
387
- }, 0);
388
- });
389
- }
390
- onSearch && onSearch(v);
391
- }
392
- });
393
- Object.defineProperty(this, "filterOption", {
394
- enumerable: true,
395
- configurable: true,
396
- writable: true,
397
- value: (v, option) => {
398
- // 自定义过滤对应的 option 属性配置
399
- const filterProps = this.props.optionFilterProp || 'value';
400
- return `${option.props[filterProps]}`.indexOf(v) >= 0;
401
- }
402
- });
403
- Object.defineProperty(this, "setDefaultScrollTop", {
404
- enumerable: true,
405
- configurable: true,
406
- writable: true,
407
- value: data => {
408
- const {
409
- value
410
- } = this.state;
411
- const {
412
- children: arr
413
- } = this.props;
414
- const children = this.turnChildren(arr);
415
- let val = data || data === 0 ? data : value;
416
- for (let i = 0; i < children.length; i++) {
417
- const item = children[i];
418
- const itemValue = item.props.value;
419
- if (itemValue === val || Array.isArray(val) && val.includes(itemValue)) {
420
- const targetScrollTop = i * this.ITEM_HEIGHT;
421
- setTimeout(() => {
422
- if (!this.scrollEle) {
423
- this.addEvent();
424
- }
425
- this.scrollEle && this.scrollEle.scrollTo(0, targetScrollTop);
426
- }, 100);
427
- return;
428
- }
429
- }
430
- }
431
- });
432
- Object.defineProperty(this, "removeEvent", {
433
- enumerable: true,
434
- configurable: true,
435
- writable: true,
436
- value: () => {
437
- if (!this.scrollEle) return;
438
- this.scrollEle.removeEventListener('mousedown', this.preventEvent, false);
439
- this.scrollEle.removeEventListener('scroll', this.onScroll, false);
440
- if (!this.inputEle) return;
441
- this.inputEle.removeEventListener('keydown', this.onKeyDown, false);
442
- }
443
- });
444
- const {
445
- mode,
446
- defaultValue,
447
- value,
448
- optionHeight,
449
- children: arr
450
- } = props;
451
- this.isMultiple = ['tags', 'multiple'].includes(mode);
452
- const children = this.turnChildren(arr);
453
- // 设置默认 value
454
- let defaultV = this.isMultiple ? [] : '';
455
- defaultV = value || defaultValue || defaultV;
456
- this.state = {
457
- children: children || [],
458
- filterChildren: null,
459
- value: defaultV,
460
- maxWidth: null,
461
- selectWidth: null
462
- };
463
- // 下拉菜单项行高
464
- this.ITEM_HEIGHT = optionHeight || ITEM_HEIGHT_CFG[props.size || 'default'];
465
- // 可视区 dom 高度
466
- this.visibleDomHeight = this.ITEM_HEIGHT * ITEM_ELEMENT_NUMBER;
467
- // 滚动时重新渲染的 scrollTop 判断值,大于 reactDelta 则刷新下拉列表
468
- this.reactDelta = this.visibleDomHeight / 3;
469
- // 是否拖动滚动条快速滚动状态
470
- this.isStopReact = false;
471
- // 上一次滚动的 scrollTop 值
472
- this.prevScrollTop = 0;
473
- // 上一次按下方向键时 scrollTop 值
474
- this.prevTop = 0;
475
- this.scrollTop = 0;
476
- // className
477
- this.dropdownClassName = `dc${+new Date()}`;
478
- this.id = `sid${+new Date()}`;
479
- }
480
- componentDidMount() {
481
- // defaultOpens=true 时添加滚动事件
482
- setTimeout(() => {
483
- this.addEvent();
484
- }, 500);
485
- const {
486
- children: arr
487
- } = this.props;
488
- const children = this.turnChildren(arr);
489
- // if (children && children.length > 0) {
490
- this.formulaWidth();
491
- // }
492
- }
493
-
494
- componentDidUpdate(prevProps) {
495
- const {
496
- mode,
497
- defaultValue,
498
- value,
499
- children
500
- } = this.props;
501
- let arr = this.turnChildren(children);
502
- if (prevProps.children !== children) {
503
- this.isMultiple = ['tags', 'multiple'].includes(mode);
504
- this.setState({
505
- children: arr || [],
506
- filterChildren: null
507
- }, () => {
508
- if (arr && arr.length > 0) {
509
- this.formulaWidth();
510
- if (!this.inputEle) {
511
- this.removeEvent();
512
- this.addEvent();
513
- }
514
- }
515
- });
516
- }
517
- if (prevProps.value !== value) {
518
- // 更新时设置默认 value
519
- let defaultV = this.isMultiple ? [] : '';
520
- defaultV = value || defaultValue || defaultV;
521
- this.setState({
522
- value: defaultV
523
- });
524
480
  }
525
- }
526
- componentWillUnmount() {
527
- this.removeEvent();
528
- }
529
- render() {
530
- const {
531
- maxWidth,
532
- selectWidth
533
- } = this.state;
534
- let _a = this.props,
535
- {
536
- dropdownStyle,
537
- optionLabelProp,
538
- dropdownClassName
539
- } = _a,
540
- props = __rest(_a, ["dropdownStyle", "optionLabelProp", "dropdownClassName"]);
541
- this.allList = this.getUseChildrenList();
542
- this.allHeight = this.allList.length * this.ITEM_HEIGHT || 100;
543
- const {
544
- startIndex,
545
- endIndex
546
- } = this.getStartAndEndIndex();
547
- let dynamicWidth = maxWidth;
548
- if (this.allList.length === 0 || maxWidth < selectWidth) {
549
- dynamicWidth = selectWidth;
481
+ componentWillUnmount() {
482
+ this.removeEvent();
550
483
  }
551
- dropdownStyle = Object.assign(Object.assign({
552
- maxHeight: `${DROPDOWN_HEIGHT}px`
553
- }, dropdownStyle), {
554
- overflow: 'auto',
555
- position: 'relative',
556
- maxWidth: dynamicWidth
557
- });
558
- const {
559
- value
560
- } = this.state;
561
- // 判断处于 antd Form 中时不自动设置 value
562
- const _props = Object.assign({}, props);
563
- // 先删除 value,再手动赋值,防止空 value 影响 placeholder
564
- delete _props.value;
565
- // value 为空字符会隐藏 placeholder,改为 undefined
566
- if (typeof value === 'string' && !value) {
567
- _props.value = undefined;
568
- } else {
569
- _props.value = value;
570
- }
571
- optionLabelProp = optionLabelProp || 'children';
572
- return React.createElement(Select, Object.assign({}, _props, {
573
- id: this.id,
574
- onSearch: this.onSearch,
575
- onChange: this.onChange,
576
- dropdownClassName: `${this.dropdownClassName} ${dropdownClassName || ''}`,
577
- optionLabelProp: optionLabelProp,
578
- dropdownStyle: dropdownStyle,
579
- onDropdownVisibleChange: this.onDropdownVisibleChange,
580
- onDeselect: this.onDeselect,
581
- ref: ele => this.select = ele,
582
- dropdownRender: (menu, props) => {
583
- if (_props.loading) {
584
- return React.createElement(Spin, {
585
- size: "small",
586
- style: {
587
- marginLeft: 8
588
- }
589
- });
484
+ render() {
485
+ const { maxWidth, selectWidth } = this.state;
486
+ let _a = this.props, { dropdownStyle, optionLabelProp, dropdownClassName } = _a, props = __rest(_a, ["dropdownStyle", "optionLabelProp", "dropdownClassName"]);
487
+ this.allList = this.getUseChildrenList();
488
+ this.allHeight = this.allList.length * this.ITEM_HEIGHT || 100;
489
+ const { startIndex, endIndex } = this.getStartAndEndIndex();
490
+ let dynamicWidth = maxWidth;
491
+ if (this.allList.length === 0 || maxWidth < selectWidth) {
492
+ dynamicWidth = selectWidth;
590
493
  }
591
- if (this.allList.length === 0) {
592
- return React.createElement("div", {
593
- style: {
594
- padding: '5px 12px'
595
- }
596
- }, React.createElement(Empty, {
597
- image: Empty.PRESENTED_IMAGE_SIMPLE
598
- }));
494
+ dropdownStyle = Object.assign(Object.assign({ maxHeight: `${DROPDOWN_HEIGHT}px` }, dropdownStyle), { overflow: 'auto', position: 'relative', maxWidth: dynamicWidth });
495
+ const { value } = this.state;
496
+ // 判断处于 antd Form 中时不自动设置 value
497
+ const _props = Object.assign({}, props);
498
+ // 先删除 value,再手动赋值,防止空 value 影响 placeholder
499
+ delete _props.value;
500
+ // value 为空字符会隐藏 placeholder,改为 undefined
501
+ if (typeof value === 'string' && !value) {
502
+ _props.value = undefined;
599
503
  }
600
- return React.createElement(DropDownWrap, Object.assign({}, {
601
- startIndex,
602
- endIndex,
603
- allHeight: this.allHeight,
604
- menu,
605
- itemHeight: this.ITEM_HEIGHT
606
- }, {
607
- ref: ele => {
608
- this.wrap = ele;
609
- }
610
- }));
611
- }
612
- }), this.allList);
613
- }
504
+ else {
505
+ _props.value = value;
506
+ }
507
+ optionLabelProp = optionLabelProp || 'children';
508
+ return (React.createElement(Select, Object.assign({}, _props, { id: this.id, placeholder: capitalizeFirstLetter(props === null || props === void 0 ? void 0 : props.placeholder, props === null || props === void 0 ? void 0 : props.capitalize), onSearch: this.onSearch, onChange: this.onChange, dropdownClassName: `${this.dropdownClassName} ${dropdownClassName || ''}`, optionLabelProp: optionLabelProp, dropdownStyle: dropdownStyle, onDropdownVisibleChange: this.onDropdownVisibleChange, onDeselect: this.onDeselect, ref: (ele) => (this.select = ele), dropdownRender: (menu, props) => {
509
+ if (_props.loading) {
510
+ return (React.createElement(Spin, { size: "small", style: { marginLeft: 8 } }));
511
+ }
512
+ if (this.allList.length === 0) {
513
+ return (React.createElement("div", { style: { padding: '5px 12px' } },
514
+ React.createElement(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE })));
515
+ }
516
+ return (React.createElement(DropDownWrap, Object.assign({}, {
517
+ startIndex,
518
+ endIndex,
519
+ allHeight: this.allHeight,
520
+ menu,
521
+ itemHeight: this.ITEM_HEIGHT,
522
+ }, { ref: (ele) => {
523
+ this.wrap = ele;
524
+ } })));
525
+ } }), this.allList));
526
+ }
614
527
  }
615
528
  SuperSelect.Option = Option;
616
- export default SuperSelect;
529
+ export default SuperSelect;
530
+ //# sourceMappingURL=index.js.map