@sheinx/hooks 3.0.0-rc.2 → 3.0.0-rc.4

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 (595) hide show
  1. package/cjs/common/type.d.ts +15 -15
  2. package/cjs/common/type.d.ts.map +1 -1
  3. package/cjs/common/use-click-away/index.d.ts +2 -2
  4. package/cjs/common/use-click-away/index.d.ts.map +1 -1
  5. package/cjs/common/use-click-away/index.js +2 -3
  6. package/cjs/common/use-default-value/index.js +2 -2
  7. package/cjs/common/use-default-value/use-default-value.js +9 -5
  8. package/cjs/common/use-drag-mock/index.js +2 -2
  9. package/cjs/common/use-drag-mock/use-drag-mock.js +11 -8
  10. package/cjs/common/use-drag-mock/use-drag-move.js +15 -11
  11. package/cjs/common/use-drag-mock/use-drag-resize.js +9 -5
  12. package/cjs/common/use-filter/index.js +2 -2
  13. package/cjs/common/use-filter/use-filter.js +17 -13
  14. package/cjs/common/use-fork-ref/index.js +5 -10
  15. package/cjs/common/use-func-change/index.js +2 -2
  16. package/cjs/common/use-func-change/use-func-change.d.ts +1 -1
  17. package/cjs/common/use-func-change/use-func-change.js +2 -3
  18. package/cjs/common/use-input-able/index.js +2 -2
  19. package/cjs/common/use-input-able/use-Input-able.js +8 -4
  20. package/cjs/common/use-input-able/use-Input-able.type.d.ts +1 -1
  21. package/cjs/common/use-input-able/use-Input-able.type.d.ts.map +1 -1
  22. package/cjs/common/use-key-event/index.js +6 -8
  23. package/cjs/common/use-latest-obj/index.js +1 -3
  24. package/cjs/common/use-list-select/index.js +2 -2
  25. package/cjs/common/use-list-select/use-list-select-multiple.js +20 -29
  26. package/cjs/common/use-list-select/use-list-select-single.js +9 -11
  27. package/cjs/common/use-list-select/use-list-select.js +10 -12
  28. package/cjs/common/use-pagination-list/index.js +17 -15
  29. package/cjs/common/use-persist-fn/index.js +1 -2
  30. package/cjs/common/use-position-style/get-position-style.js +10 -7
  31. package/cjs/common/use-position-style/index.d.ts +3 -3
  32. package/cjs/common/use-position-style/index.d.ts.map +1 -1
  33. package/cjs/common/use-position-style/index.js +16 -22
  34. package/cjs/common/use-previous/index.js +1 -2
  35. package/cjs/common/use-render/index.js +8 -5
  36. package/cjs/common/use-resize/index.js +11 -9
  37. package/cjs/common/use-safe-state/index.js +8 -5
  38. package/cjs/common/use-style/index.js +0 -2
  39. package/cjs/common/use-toggle/index.d.ts +1 -1
  40. package/cjs/common/use-toggle/index.d.ts.map +1 -1
  41. package/cjs/common/use-toggle/index.js +7 -3
  42. package/cjs/common/use-transform/index.js +2 -2
  43. package/cjs/common/use-transform/use-transform.js +13 -11
  44. package/cjs/common/use-unmounted-ref/index.js +1 -2
  45. package/cjs/components/use-button/index.js +2 -2
  46. package/cjs/components/use-button/use-button.d.ts +3 -3
  47. package/cjs/components/use-button/use-button.js +12 -13
  48. package/cjs/components/use-button/use-button.type.d.ts +3 -3
  49. package/cjs/components/use-button/use-button.type.d.ts.map +1 -1
  50. package/cjs/components/use-carousel/index.js +2 -2
  51. package/cjs/components/use-carousel/use-carousel.d.ts +1 -1
  52. package/cjs/components/use-carousel/use-carousel.d.ts.map +1 -1
  53. package/cjs/components/use-carousel/use-carousel.js +9 -5
  54. package/cjs/components/use-cascader/index.js +2 -2
  55. package/cjs/components/use-cascader/use-cascader.js +2 -3
  56. package/cjs/components/use-check/index.js +2 -2
  57. package/cjs/components/use-check/use-check.d.ts +3 -3
  58. package/cjs/components/use-check/use-check.js +24 -17
  59. package/cjs/components/use-collapse/index.js +2 -2
  60. package/cjs/components/use-collapse/use-collapse-item.d.ts +4 -4
  61. package/cjs/components/use-collapse/use-collapse-item.js +7 -10
  62. package/cjs/components/use-collapse/use-collapse-item.type.d.ts +1 -1
  63. package/cjs/components/use-collapse/use-collapse-item.type.d.ts.map +1 -1
  64. package/cjs/components/use-collapse/use-collapse.js +14 -13
  65. package/cjs/components/use-datepicker/index.js +2 -2
  66. package/cjs/components/use-datepicker/use-date.js +13 -11
  67. package/cjs/components/use-datepicker/use-datepicker-format.js +26 -21
  68. package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts +4 -4
  69. package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
  70. package/cjs/components/use-datepicker/use-datepicker-range.js +10 -7
  71. package/cjs/components/use-datepicker/use-datepicker-range.type.d.ts +1 -1
  72. package/cjs/components/use-datepicker/use-datepicker-range.type.d.ts.map +1 -1
  73. package/cjs/components/use-datepicker/use-month.js +13 -11
  74. package/cjs/components/use-datepicker/use-quarter.js +13 -12
  75. package/cjs/components/use-datepicker/use-time.js +3 -8
  76. package/cjs/components/use-datepicker/use-year.js +13 -11
  77. package/cjs/components/use-datepicker/util.d.ts +3 -3
  78. package/cjs/components/use-datepicker/util.d.ts.map +1 -1
  79. package/cjs/components/use-datepicker/util.js +13 -20
  80. package/cjs/components/use-descriptions/index.js +2 -2
  81. package/cjs/components/use-descriptions/use-descriptions.js +14 -11
  82. package/cjs/components/use-form/Provider.js +6 -10
  83. package/cjs/components/use-form/form-bind-context.js +6 -11
  84. package/cjs/components/use-form/form-config-context.js +6 -11
  85. package/cjs/components/use-form/form-func-context.js +6 -11
  86. package/cjs/components/use-form/index.js +2 -3
  87. package/cjs/components/use-form/use-form-control/index.js +2 -2
  88. package/cjs/components/use-form/use-form-control/use-form-control.js +23 -23
  89. package/cjs/components/use-form/use-form-fieldset/fieldset-context.js +10 -19
  90. package/cjs/components/use-form/use-form-fieldset/index.js +2 -2
  91. package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.js +3 -5
  92. package/cjs/components/use-form/use-form-flow/index.js +2 -2
  93. package/cjs/components/use-form/use-form-flow/use-form-datum.js +1 -2
  94. package/cjs/components/use-form/use-form-flow/use-form-flow.js +2 -3
  95. package/cjs/components/use-form/use-form-item/form-item-context.js +5 -9
  96. package/cjs/components/use-form/use-form-item/index.js +2 -2
  97. package/cjs/components/use-form/use-form-item/use-form-item.js +12 -13
  98. package/cjs/components/use-form/use-form.d.ts +2 -2
  99. package/cjs/components/use-form/use-form.js +28 -37
  100. package/cjs/components/use-form/use-form.type.d.ts +4 -4
  101. package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
  102. package/cjs/components/use-image/index.js +2 -2
  103. package/cjs/components/use-image/use-image-gallery.d.ts +4 -4
  104. package/cjs/components/use-image/use-image-gallery.d.ts.map +1 -1
  105. package/cjs/components/use-image/use-image-gallery.js +18 -15
  106. package/cjs/components/use-image/use-image-gallery.type.d.ts +1 -1
  107. package/cjs/components/use-image/use-image-gallery.type.d.ts.map +1 -1
  108. package/cjs/components/use-image/use-image-group.d.ts +2 -2
  109. package/cjs/components/use-image/use-image-group.d.ts.map +1 -1
  110. package/cjs/components/use-image/use-image-group.js +9 -12
  111. package/cjs/components/use-image/use-image-magnify.js +13 -13
  112. package/cjs/components/use-image/use-image.d.ts +4 -4
  113. package/cjs/components/use-image/use-image.d.ts.map +1 -1
  114. package/cjs/components/use-image/use-image.js +17 -23
  115. package/cjs/components/use-image/use-image.type.d.ts +4 -4
  116. package/cjs/components/use-image/use-image.type.d.ts.map +1 -1
  117. package/cjs/components/use-input/index.js +2 -2
  118. package/cjs/components/use-input/use-input-format.d.ts +1 -1
  119. package/cjs/components/use-input/use-input-format.js +13 -15
  120. package/cjs/components/use-input/use-input-format.type.d.ts +1 -1
  121. package/cjs/components/use-input/use-input-format.type.d.ts.map +1 -1
  122. package/cjs/components/use-input/use-input-number.d.ts +1 -1
  123. package/cjs/components/use-input/use-input-number.js +15 -16
  124. package/cjs/components/use-input/use-input-number.type.d.ts +1 -1
  125. package/cjs/components/use-input/use-input-number.type.d.ts.map +1 -1
  126. package/cjs/components/use-input/use-input-password.js +11 -9
  127. package/cjs/components/use-input/use-input-password.type.d.ts +1 -1
  128. package/cjs/components/use-input/use-input-password.type.d.ts.map +1 -1
  129. package/cjs/components/use-input/use-input.d.ts +3 -3
  130. package/cjs/components/use-input/use-input.js +30 -29
  131. package/cjs/components/use-input/use-input.type.d.ts +5 -5
  132. package/cjs/components/use-input/use-input.type.d.ts.map +1 -1
  133. package/cjs/components/use-menu/index.js +2 -2
  134. package/cjs/components/use-menu/use-menu-item.d.ts +1 -1
  135. package/cjs/components/use-menu/use-menu-item.d.ts.map +1 -1
  136. package/cjs/components/use-menu/use-menu-item.js +11 -12
  137. package/cjs/components/use-menu/use-menu.js +2 -8
  138. package/cjs/components/use-menu/use-menu.type.d.ts +1 -1
  139. package/cjs/components/use-menu/use-menu.type.d.ts.map +1 -1
  140. package/cjs/components/use-pagination/index.js +2 -2
  141. package/cjs/components/use-pagination/use-pagination.d.ts +1 -1
  142. package/cjs/components/use-pagination/use-pagination.js +16 -13
  143. package/cjs/components/use-popup/index.js +2 -2
  144. package/cjs/components/use-popup/popup-context.js +1 -2
  145. package/cjs/components/use-popup/use-popup.js +14 -11
  146. package/cjs/components/use-popup/use-popup.type.d.ts +1 -1
  147. package/cjs/components/use-popup/use-popup.type.d.ts.map +1 -1
  148. package/cjs/components/use-select/index.js +2 -2
  149. package/cjs/components/use-select/use-select-group.js +13 -10
  150. package/cjs/components/use-select/use-select.js +1 -2
  151. package/cjs/components/use-select/use-select.type.d.ts +1 -1
  152. package/cjs/components/use-select/use-select.type.d.ts.map +1 -1
  153. package/cjs/components/use-slider/index.js +2 -2
  154. package/cjs/components/use-slider/use-slider.js +15 -10
  155. package/cjs/components/use-table/index.js +2 -2
  156. package/cjs/components/use-table/use-table-columns.d.ts +1 -1
  157. package/cjs/components/use-table/use-table-columns.d.ts.map +1 -1
  158. package/cjs/components/use-table/use-table-columns.js +4 -8
  159. package/cjs/components/use-table/use-table-expand.js +19 -20
  160. package/cjs/components/use-table/use-table-group.js +1 -7
  161. package/cjs/components/use-table/use-table-layout.js +34 -34
  162. package/cjs/components/use-table/use-table-row.js +8 -9
  163. package/cjs/components/use-table/use-table-sort.d.ts +1 -1
  164. package/cjs/components/use-table/use-table-sort.d.ts.map +1 -1
  165. package/cjs/components/use-table/use-table-sort.js +21 -22
  166. package/cjs/components/use-table/use-table-tree.js +19 -26
  167. package/cjs/components/use-table/use-table-virtual.js +17 -13
  168. package/cjs/components/use-table/use-table.type.d.ts +4 -4
  169. package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
  170. package/cjs/components/use-tabs/context.js +7 -13
  171. package/cjs/components/use-tabs/index.js +2 -2
  172. package/cjs/components/use-tabs/use-tabs.js +9 -6
  173. package/cjs/components/use-tabs/use-tabs.type.d.ts +1 -1
  174. package/cjs/components/use-tabs/use-tabs.type.d.ts.map +1 -1
  175. package/cjs/components/use-textarea/index.js +2 -2
  176. package/cjs/components/use-textarea/use-textarea-format.js +5 -7
  177. package/cjs/components/use-textarea/use-textarea-format.type.d.ts +1 -1
  178. package/cjs/components/use-textarea/use-textarea-format.type.d.ts.map +1 -1
  179. package/cjs/components/use-textarea/use-textarea.d.ts +2 -2
  180. package/cjs/components/use-textarea/use-textarea.js +23 -18
  181. package/cjs/components/use-textarea/use-textarea.type.d.ts +3 -3
  182. package/cjs/components/use-textarea/use-textarea.type.d.ts.map +1 -1
  183. package/cjs/components/use-transfer/index.js +2 -2
  184. package/cjs/components/use-transfer/use-transfer.js +20 -19
  185. package/cjs/components/use-transfer/use-transfer.type.d.ts +1 -1
  186. package/cjs/components/use-transfer/use-transfer.type.d.ts.map +1 -1
  187. package/cjs/components/use-tree/index.js +2 -2
  188. package/cjs/components/use-tree/use-tree-node.js +11 -7
  189. package/cjs/components/use-tree/use-tree-node.type.d.ts +2 -2
  190. package/cjs/components/use-tree/use-tree-node.type.d.ts.map +1 -1
  191. package/cjs/components/use-tree/use-tree.js +11 -16
  192. package/cjs/components/use-tree/use-tree.type.d.ts +3 -3
  193. package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
  194. package/cjs/components/use-treeselect/index.js +2 -2
  195. package/cjs/components/use-treeselect/use-tiled.js +13 -9
  196. package/cjs/components/use-treeselect/use-tiled.type.d.ts +1 -1
  197. package/cjs/components/use-treeselect/use-tiled.type.d.ts.map +1 -1
  198. package/cjs/components/use-treeselect/use-treeselect.js +1 -2
  199. package/cjs/components/use-upload/index.js +2 -2
  200. package/cjs/components/use-upload/use-upload.js +36 -34
  201. package/cjs/components/use-upload/xhr.js +0 -1
  202. package/cjs/components/use-validate/index.js +2 -2
  203. package/cjs/components/use-validate/use-validate.js +9 -5
  204. package/cjs/index.js +4 -9
  205. package/cjs/utils/accept.d.ts +1 -1
  206. package/cjs/utils/accept.d.ts.map +1 -1
  207. package/cjs/utils/accept.js +0 -4
  208. package/cjs/utils/array.js +2 -4
  209. package/cjs/utils/attribute.js +3 -5
  210. package/cjs/utils/clone.js +11 -20
  211. package/cjs/utils/document.js +2 -4
  212. package/cjs/utils/dom/element.js +11 -11
  213. package/cjs/utils/dom/index.js +2 -3
  214. package/cjs/utils/dom/responsiveObserve.js +10 -15
  215. package/cjs/utils/dom/responsiveObserve.type.d.ts +4 -4
  216. package/cjs/utils/dom/responsiveObserve.type.d.ts.map +1 -1
  217. package/cjs/utils/dom/scroll-behavior.js +2 -3
  218. package/cjs/utils/extract-event-handlers.js +0 -6
  219. package/cjs/utils/func.js +3 -5
  220. package/cjs/utils/immer.d.ts +1 -8
  221. package/cjs/utils/immer.d.ts.map +1 -1
  222. package/cjs/utils/immer.js +11 -8
  223. package/cjs/utils/index.js +2 -3
  224. package/cjs/utils/is.d.ts +1 -1
  225. package/cjs/utils/is.d.ts.map +1 -1
  226. package/cjs/utils/is.js +30 -55
  227. package/cjs/utils/lazyload.d.ts +1 -1
  228. package/cjs/utils/lazyload.d.ts.map +1 -1
  229. package/cjs/utils/lazyload.js +0 -1
  230. package/cjs/utils/number.js +0 -7
  231. package/cjs/utils/object.d.ts +4 -4
  232. package/cjs/utils/object.d.ts.map +1 -1
  233. package/cjs/utils/object.js +18 -37
  234. package/cjs/utils/position.js +4 -3
  235. package/cjs/utils/react-render.d.ts +1 -1
  236. package/cjs/utils/react-render.d.ts.map +1 -1
  237. package/cjs/utils/react-render.js +17 -24
  238. package/cjs/utils/render.d.ts +1 -1
  239. package/cjs/utils/render.d.ts.map +1 -1
  240. package/cjs/utils/render.js +3 -5
  241. package/cjs/utils/rule/index.js +2 -2
  242. package/cjs/utils/rule/length.d.ts +1 -1
  243. package/cjs/utils/rule/length.js +9 -11
  244. package/cjs/utils/rule/regexp.d.ts +1 -1
  245. package/cjs/utils/rule/regexp.js +4 -9
  246. package/cjs/utils/rule/required.d.ts +1 -1
  247. package/cjs/utils/rule/required.js +3 -5
  248. package/cjs/utils/rule/rule.js +4 -9
  249. package/cjs/utils/rule/rule.type.d.ts +8 -8
  250. package/cjs/utils/rule/rule.type.d.ts.map +1 -1
  251. package/cjs/utils/rule/type.d.ts +1 -1
  252. package/cjs/utils/rule/type.js +3 -5
  253. package/cjs/utils/shallow-equal.js +4 -9
  254. package/cjs/utils/string.js +0 -7
  255. package/cjs/utils/style-unit.js +0 -2
  256. package/cjs/utils/tree.d.ts +1 -1
  257. package/cjs/utils/tree.d.ts.map +1 -1
  258. package/cjs/utils/tree.js +19 -21
  259. package/cjs/utils/uid.js +0 -11
  260. package/cjs/utils/validate/error.js +22 -18
  261. package/cjs/utils/validate/get-rule.js +1 -4
  262. package/cjs/utils/validate/index.d.ts +1 -1
  263. package/cjs/utils/validate/index.d.ts.map +1 -1
  264. package/cjs/utils/validate/index.js +13 -13
  265. package/cjs/utils/validate/isJson.js +2 -5
  266. package/cjs/utils/validate/nullable.js +2 -3
  267. package/cjs/utils/validate/type.d.ts +1 -1
  268. package/cjs/utils/validate/type.d.ts.map +1 -1
  269. package/cjs/utils/validate/type.js +4 -9
  270. package/esm/common/type.d.ts +15 -15
  271. package/esm/common/type.d.ts.map +1 -1
  272. package/esm/common/type.js +1 -5
  273. package/esm/common/use-click-away/index.d.ts +2 -2
  274. package/esm/common/use-click-away/index.d.ts.map +1 -1
  275. package/esm/common/use-click-away/index.js +8 -17
  276. package/esm/common/use-default-value/index.js +2 -26
  277. package/esm/common/use-default-value/use-default-value.js +16 -19
  278. package/esm/common/use-default-value/use-previous.js +4 -10
  279. package/esm/common/use-drag-mock/index.js +3 -33
  280. package/esm/common/use-drag-mock/use-drag-mock.js +17 -20
  281. package/esm/common/use-drag-mock/use-drag-move.js +25 -28
  282. package/esm/common/use-drag-mock/use-drag-resize.js +19 -22
  283. package/esm/common/use-filter/index.js +1 -19
  284. package/esm/common/use-filter/use-filter.js +34 -36
  285. package/esm/common/use-filter/use-filter.type.js +1 -5
  286. package/esm/common/use-fork-ref/index.js +5 -20
  287. package/esm/common/use-fork-ref/setRef.js +1 -7
  288. package/esm/common/use-func-change/index.js +1 -19
  289. package/esm/common/use-func-change/use-func-change.d.ts +1 -1
  290. package/esm/common/use-func-change/use-func-change.js +8 -16
  291. package/esm/common/use-input-able/index.js +1 -19
  292. package/esm/common/use-input-able/use-Input-able.js +25 -28
  293. package/esm/common/use-input-able/use-Input-able.type.d.ts +1 -1
  294. package/esm/common/use-input-able/use-Input-able.type.d.ts.map +1 -1
  295. package/esm/common/use-input-able/use-Input-able.type.js +1 -5
  296. package/esm/common/use-key-event/index.js +7 -15
  297. package/esm/common/use-latest-obj/index.js +4 -12
  298. package/esm/common/use-list-select/index.js +3 -33
  299. package/esm/common/use-list-select/use-list-select-multiple.js +35 -54
  300. package/esm/common/use-list-select/use-list-select-single.js +17 -26
  301. package/esm/common/use-list-select/use-list-select.js +16 -25
  302. package/esm/common/use-list-select/use-list.type.js +1 -5
  303. package/esm/common/use-pagination-list/index.js +22 -26
  304. package/esm/common/use-persist-fn/index.js +5 -11
  305. package/esm/common/use-position-style/get-position-style.js +10 -13
  306. package/esm/common/use-position-style/index.d.ts +3 -3
  307. package/esm/common/use-position-style/index.d.ts.map +1 -1
  308. package/esm/common/use-position-style/index.js +25 -41
  309. package/esm/common/use-previous/index.js +5 -13
  310. package/esm/common/use-render/index.js +15 -19
  311. package/esm/common/use-resize/index.js +17 -21
  312. package/esm/common/use-safe-state/index.js +15 -19
  313. package/esm/common/use-style/index.js +3 -11
  314. package/esm/common/use-toggle/index.d.ts +1 -1
  315. package/esm/common/use-toggle/index.d.ts.map +1 -1
  316. package/esm/common/use-toggle/index.js +12 -14
  317. package/esm/common/use-transform/index.js +1 -19
  318. package/esm/common/use-transform/use-transform.js +23 -27
  319. package/esm/common/use-transform/use-transform.type.js +1 -5
  320. package/esm/common/use-unmounted-ref/index.js +5 -13
  321. package/esm/components/use-button/index.js +1 -19
  322. package/esm/components/use-button/use-button-group.type.js +1 -5
  323. package/esm/components/use-button/use-button.d.ts +3 -3
  324. package/esm/components/use-button/use-button.js +17 -24
  325. package/esm/components/use-button/use-button.type.d.ts +3 -3
  326. package/esm/components/use-button/use-button.type.d.ts.map +1 -1
  327. package/esm/components/use-button/use-button.type.js +1 -5
  328. package/esm/components/use-carousel/index.js +1 -19
  329. package/esm/components/use-carousel/use-carousel.d.ts +1 -1
  330. package/esm/components/use-carousel/use-carousel.d.ts.map +1 -1
  331. package/esm/components/use-carousel/use-carousel.js +21 -24
  332. package/esm/components/use-cascader/index.js +1 -19
  333. package/esm/components/use-cascader/use-cascader.js +5 -13
  334. package/esm/components/use-cascader/use-cascader.type.js +1 -5
  335. package/esm/components/use-check/index.js +1 -19
  336. package/esm/components/use-check/use-check.d.ts +3 -3
  337. package/esm/components/use-check/use-check.js +32 -31
  338. package/esm/components/use-check/use-check.type.js +1 -5
  339. package/esm/components/use-collapse/index.js +2 -26
  340. package/esm/components/use-collapse/use-collapse-item.d.ts +4 -4
  341. package/esm/components/use-collapse/use-collapse-item.js +9 -18
  342. package/esm/components/use-collapse/use-collapse-item.type.d.ts +1 -1
  343. package/esm/components/use-collapse/use-collapse-item.type.d.ts.map +1 -1
  344. package/esm/components/use-collapse/use-collapse-item.type.js +1 -5
  345. package/esm/components/use-collapse/use-collapse.js +17 -22
  346. package/esm/components/use-collapse/use-collapse.type.js +1 -5
  347. package/esm/components/use-datepicker/index.js +8 -62
  348. package/esm/components/use-datepicker/use-date.js +53 -57
  349. package/esm/components/use-datepicker/use-date.type.js +1 -5
  350. package/esm/components/use-datepicker/use-datepicker-format.js +54 -56
  351. package/esm/components/use-datepicker/use-datepicker-format.type.d.ts +4 -4
  352. package/esm/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
  353. package/esm/components/use-datepicker/use-datepicker-format.type.js +1 -5
  354. package/esm/components/use-datepicker/use-datepicker-range.js +43 -47
  355. package/esm/components/use-datepicker/use-datepicker-range.type.d.ts +1 -1
  356. package/esm/components/use-datepicker/use-datepicker-range.type.d.ts.map +1 -1
  357. package/esm/components/use-datepicker/use-datepicker-range.type.js +1 -5
  358. package/esm/components/use-datepicker/use-month.js +37 -41
  359. package/esm/components/use-datepicker/use-month.type.js +1 -5
  360. package/esm/components/use-datepicker/use-quarter.js +36 -41
  361. package/esm/components/use-datepicker/use-quarter.type.js +1 -5
  362. package/esm/components/use-datepicker/use-time.js +23 -35
  363. package/esm/components/use-datepicker/use-time.type.js +1 -5
  364. package/esm/components/use-datepicker/use-year.js +37 -41
  365. package/esm/components/use-datepicker/use-year.type.js +1 -5
  366. package/esm/components/use-datepicker/util.d.ts +3 -3
  367. package/esm/components/use-datepicker/util.d.ts.map +1 -1
  368. package/esm/components/use-datepicker/util.js +67 -80
  369. package/esm/components/use-descriptions/index.js +1 -19
  370. package/esm/components/use-descriptions/use-descriptions.js +24 -27
  371. package/esm/components/use-descriptions/use-descriptions.type.js +1 -5
  372. package/esm/components/use-form/Provider.js +12 -26
  373. package/esm/components/use-form/form-bind-context.js +4 -17
  374. package/esm/components/use-form/form-config-context.js +4 -17
  375. package/esm/components/use-form/form-func-context.js +4 -17
  376. package/esm/components/use-form/index.js +7 -87
  377. package/esm/components/use-form/use-form-control/index.js +1 -19
  378. package/esm/components/use-form/use-form-control/use-form-control.js +57 -66
  379. package/esm/components/use-form/use-form-control/use-form-control.type.js +1 -5
  380. package/esm/components/use-form/use-form-fieldset/fieldset-context.js +13 -29
  381. package/esm/components/use-form/use-form-fieldset/index.js +2 -26
  382. package/esm/components/use-form/use-form-fieldset/use-form-fieldset.js +6 -15
  383. package/esm/components/use-form/use-form-fieldset/use-form-fieldset.type.js +1 -5
  384. package/esm/components/use-form/use-form-flow/index.js +2 -26
  385. package/esm/components/use-form/use-form-flow/use-form-datum.js +4 -11
  386. package/esm/components/use-form/use-form-flow/use-form-flow.js +9 -17
  387. package/esm/components/use-form/use-form-flow/use-form-flow.type.js +1 -5
  388. package/esm/components/use-form/use-form-item/form-item-context.js +3 -15
  389. package/esm/components/use-form/use-form-item/index.js +1 -19
  390. package/esm/components/use-form/use-form-item/use-form-item.js +21 -32
  391. package/esm/components/use-form/use-form.d.ts +2 -2
  392. package/esm/components/use-form/use-form.js +65 -83
  393. package/esm/components/use-form/use-form.type.d.ts +4 -4
  394. package/esm/components/use-form/use-form.type.d.ts.map +1 -1
  395. package/esm/components/use-form/use-form.type.js +1 -5
  396. package/esm/components/use-image/index.js +4 -40
  397. package/esm/components/use-image/use-image-gallery.d.ts +4 -4
  398. package/esm/components/use-image/use-image-gallery.d.ts.map +1 -1
  399. package/esm/components/use-image/use-image-gallery.js +34 -37
  400. package/esm/components/use-image/use-image-gallery.type.d.ts +1 -1
  401. package/esm/components/use-image/use-image-gallery.type.d.ts.map +1 -1
  402. package/esm/components/use-image/use-image-gallery.type.js +1 -5
  403. package/esm/components/use-image/use-image-group.d.ts +2 -2
  404. package/esm/components/use-image/use-image-group.d.ts.map +1 -1
  405. package/esm/components/use-image/use-image-group.js +15 -24
  406. package/esm/components/use-image/use-image-group.type.js +1 -5
  407. package/esm/components/use-image/use-image-magnify.js +17 -26
  408. package/esm/components/use-image/use-image-magnify.type.js +1 -5
  409. package/esm/components/use-image/use-image.d.ts +4 -4
  410. package/esm/components/use-image/use-image.d.ts.map +1 -1
  411. package/esm/components/use-image/use-image.js +28 -41
  412. package/esm/components/use-image/use-image.type.d.ts +4 -4
  413. package/esm/components/use-image/use-image.type.d.ts.map +1 -1
  414. package/esm/components/use-image/use-image.type.js +1 -5
  415. package/esm/components/use-input/index.js +4 -40
  416. package/esm/components/use-input/use-input-format.d.ts +1 -1
  417. package/esm/components/use-input/use-input-format.js +18 -27
  418. package/esm/components/use-input/use-input-format.type.d.ts +1 -1
  419. package/esm/components/use-input/use-input-format.type.d.ts.map +1 -1
  420. package/esm/components/use-input/use-input-format.type.js +1 -5
  421. package/esm/components/use-input/use-input-number.d.ts +1 -1
  422. package/esm/components/use-input/use-input-number.js +23 -31
  423. package/esm/components/use-input/use-input-number.type.d.ts +1 -1
  424. package/esm/components/use-input/use-input-number.type.d.ts.map +1 -1
  425. package/esm/components/use-input/use-input-number.type.js +1 -5
  426. package/esm/components/use-input/use-input-password.js +16 -21
  427. package/esm/components/use-input/use-input-password.type.d.ts +1 -1
  428. package/esm/components/use-input/use-input-password.type.d.ts.map +1 -1
  429. package/esm/components/use-input/use-input-password.type.js +1 -5
  430. package/esm/components/use-input/use-input.d.ts +3 -3
  431. package/esm/components/use-input/use-input.js +34 -42
  432. package/esm/components/use-input/use-input.type.d.ts +5 -5
  433. package/esm/components/use-input/use-input.type.d.ts.map +1 -1
  434. package/esm/components/use-input/use-input.type.js +1 -5
  435. package/esm/components/use-menu/index.js +2 -20
  436. package/esm/components/use-menu/use-menu-item.d.ts +1 -1
  437. package/esm/components/use-menu/use-menu-item.d.ts.map +1 -1
  438. package/esm/components/use-menu/use-menu-item.js +23 -31
  439. package/esm/components/use-menu/use-menu.js +15 -28
  440. package/esm/components/use-menu/use-menu.type.d.ts +1 -1
  441. package/esm/components/use-menu/use-menu.type.d.ts.map +1 -1
  442. package/esm/components/use-menu/use-menu.type.js +1 -5
  443. package/esm/components/use-pagination/index.js +1 -19
  444. package/esm/components/use-pagination/use-pagination.d.ts +1 -1
  445. package/esm/components/use-pagination/use-pagination.js +22 -25
  446. package/esm/components/use-pagination/use-pagination.type.js +1 -5
  447. package/esm/components/use-popup/index.js +1 -19
  448. package/esm/components/use-popup/popup-context.js +3 -9
  449. package/esm/components/use-popup/use-popup.js +35 -39
  450. package/esm/components/use-popup/use-popup.type.d.ts +1 -1
  451. package/esm/components/use-popup/use-popup.type.d.ts.map +1 -1
  452. package/esm/components/use-popup/use-popup.type.js +1 -5
  453. package/esm/components/use-select/index.js +2 -26
  454. package/esm/components/use-select/use-select-group.js +19 -22
  455. package/esm/components/use-select/use-select-group.type.js +1 -5
  456. package/esm/components/use-select/use-select.js +5 -12
  457. package/esm/components/use-select/use-select.type.d.ts +1 -1
  458. package/esm/components/use-select/use-select.type.d.ts.map +1 -1
  459. package/esm/components/use-select/use-select.type.js +1 -5
  460. package/esm/components/use-slider/index.js +1 -19
  461. package/esm/components/use-slider/use-slider.js +30 -32
  462. package/esm/components/use-slider/use-slider.type.js +1 -5
  463. package/esm/components/use-table/index.js +8 -68
  464. package/esm/components/use-table/use-table-columns.d.ts +1 -1
  465. package/esm/components/use-table/use-table-columns.d.ts.map +1 -1
  466. package/esm/components/use-table/use-table-columns.js +9 -20
  467. package/esm/components/use-table/use-table-expand.js +24 -35
  468. package/esm/components/use-table/use-table-group.js +5 -17
  469. package/esm/components/use-table/use-table-layout.js +66 -75
  470. package/esm/components/use-table/use-table-row.js +18 -25
  471. package/esm/components/use-table/use-table-sort.d.ts +1 -1
  472. package/esm/components/use-table/use-table-sort.d.ts.map +1 -1
  473. package/esm/components/use-table/use-table-sort.js +34 -41
  474. package/esm/components/use-table/use-table-tree.js +36 -49
  475. package/esm/components/use-table/use-table-virtual.js +34 -36
  476. package/esm/components/use-table/use-table.type.d.ts +4 -4
  477. package/esm/components/use-table/use-table.type.d.ts.map +1 -1
  478. package/esm/components/use-table/use-table.type.js +1 -5
  479. package/esm/components/use-tabs/context.js +7 -21
  480. package/esm/components/use-tabs/context.type.js +1 -5
  481. package/esm/components/use-tabs/index.js +2 -26
  482. package/esm/components/use-tabs/use-tabs.js +13 -16
  483. package/esm/components/use-tabs/use-tabs.type.d.ts +1 -1
  484. package/esm/components/use-tabs/use-tabs.type.d.ts.map +1 -1
  485. package/esm/components/use-tabs/use-tabs.type.js +1 -5
  486. package/esm/components/use-textarea/index.js +2 -26
  487. package/esm/components/use-textarea/use-textarea-format.js +6 -15
  488. package/esm/components/use-textarea/use-textarea-format.type.d.ts +1 -1
  489. package/esm/components/use-textarea/use-textarea-format.type.d.ts.map +1 -1
  490. package/esm/components/use-textarea/use-textarea-format.type.js +1 -5
  491. package/esm/components/use-textarea/use-textarea.d.ts +2 -2
  492. package/esm/components/use-textarea/use-textarea.js +31 -32
  493. package/esm/components/use-textarea/use-textarea.type.d.ts +3 -3
  494. package/esm/components/use-textarea/use-textarea.type.d.ts.map +1 -1
  495. package/esm/components/use-textarea/use-textarea.type.js +1 -5
  496. package/esm/components/use-transfer/index.js +1 -19
  497. package/esm/components/use-transfer/use-transfer.js +33 -38
  498. package/esm/components/use-transfer/use-transfer.type.d.ts +1 -1
  499. package/esm/components/use-transfer/use-transfer.type.d.ts.map +1 -1
  500. package/esm/components/use-transfer/use-transfer.type.js +1 -5
  501. package/esm/components/use-tree/index.js +2 -26
  502. package/esm/components/use-tree/use-tree-node.js +17 -20
  503. package/esm/components/use-tree/use-tree-node.type.d.ts +2 -2
  504. package/esm/components/use-tree/use-tree-node.type.d.ts.map +1 -1
  505. package/esm/components/use-tree/use-tree-node.type.js +1 -5
  506. package/esm/components/use-tree/use-tree.js +25 -37
  507. package/esm/components/use-tree/use-tree.type.d.ts +3 -3
  508. package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
  509. package/esm/components/use-tree/use-tree.type.js +1 -5
  510. package/esm/components/use-treeselect/index.js +2 -26
  511. package/esm/components/use-treeselect/use-tiled.js +22 -24
  512. package/esm/components/use-treeselect/use-tiled.type.d.ts +1 -1
  513. package/esm/components/use-treeselect/use-tiled.type.d.ts.map +1 -1
  514. package/esm/components/use-treeselect/use-tiled.type.js +1 -5
  515. package/esm/components/use-treeselect/use-treeselect.js +3 -10
  516. package/esm/components/use-treeselect/use-treeselect.type.js +1 -5
  517. package/esm/components/use-upload/index.js +1 -19
  518. package/esm/components/use-upload/use-upload.js +57 -62
  519. package/esm/components/use-upload/use-upload.type.js +1 -5
  520. package/esm/components/use-upload/xhr.js +1 -8
  521. package/esm/components/use-validate/index.js +1 -19
  522. package/esm/components/use-validate/use-validate.js +16 -19
  523. package/esm/components/use-validate/use-validate.type.js +1 -5
  524. package/esm/index.js +48 -547
  525. package/esm/utils/accept.d.ts +1 -1
  526. package/esm/utils/accept.d.ts.map +1 -1
  527. package/esm/utils/accept.js +1 -11
  528. package/esm/utils/array.js +2 -10
  529. package/esm/utils/attribute.js +3 -11
  530. package/esm/utils/clone.js +19 -34
  531. package/esm/utils/document.js +11 -20
  532. package/esm/utils/dom/element.js +23 -33
  533. package/esm/utils/dom/index.js +5 -69
  534. package/esm/utils/dom/normalize-wheel.js +1 -7
  535. package/esm/utils/dom/normalize-wheel.type.js +1 -5
  536. package/esm/utils/dom/ready.js +3 -9
  537. package/esm/utils/dom/responsiveObserve.js +10 -21
  538. package/esm/utils/dom/responsiveObserve.type.d.ts +4 -4
  539. package/esm/utils/dom/responsiveObserve.type.d.ts.map +1 -1
  540. package/esm/utils/dom/responsiveObserve.type.js +1 -5
  541. package/esm/utils/dom/scroll-behavior.js +2 -9
  542. package/esm/utils/extract-event-handlers.js +1 -13
  543. package/esm/utils/func.js +3 -11
  544. package/esm/utils/immer.d.ts +1 -8
  545. package/esm/utils/immer.d.ts.map +1 -1
  546. package/esm/utils/immer.js +12 -20
  547. package/esm/utils/index.js +22 -269
  548. package/esm/utils/is.d.ts +1 -1
  549. package/esm/utils/is.d.ts.map +1 -1
  550. package/esm/utils/is.js +33 -69
  551. package/esm/utils/lazyload.d.ts +1 -1
  552. package/esm/utils/lazyload.d.ts.map +1 -1
  553. package/esm/utils/lazyload.js +6 -15
  554. package/esm/utils/number.js +6 -24
  555. package/esm/utils/object.d.ts +4 -4
  556. package/esm/utils/object.d.ts.map +1 -1
  557. package/esm/utils/object.js +30 -59
  558. package/esm/utils/position.js +8 -13
  559. package/esm/utils/react-render.d.ts +1 -1
  560. package/esm/utils/react-render.d.ts.map +1 -1
  561. package/esm/utils/react-render.js +16 -31
  562. package/esm/utils/render.d.ts +1 -1
  563. package/esm/utils/render.d.ts.map +1 -1
  564. package/esm/utils/render.js +4 -13
  565. package/esm/utils/rule/index.js +1 -19
  566. package/esm/utils/rule/length.d.ts +1 -1
  567. package/esm/utils/rule/length.js +11 -19
  568. package/esm/utils/rule/regexp.d.ts +1 -1
  569. package/esm/utils/rule/regexp.js +7 -18
  570. package/esm/utils/rule/required.d.ts +1 -1
  571. package/esm/utils/rule/required.js +6 -14
  572. package/esm/utils/rule/rule.js +20 -33
  573. package/esm/utils/rule/rule.type.d.ts +8 -8
  574. package/esm/utils/rule/rule.type.d.ts.map +1 -1
  575. package/esm/utils/rule/rule.type.js +1 -5
  576. package/esm/utils/rule/type.d.ts +1 -1
  577. package/esm/utils/rule/type.js +6 -14
  578. package/esm/utils/shallow-equal.js +7 -21
  579. package/esm/utils/string.js +2 -16
  580. package/esm/utils/style-unit.js +3 -11
  581. package/esm/utils/tree.d.ts +1 -1
  582. package/esm/utils/tree.d.ts.map +1 -1
  583. package/esm/utils/tree.js +24 -32
  584. package/esm/utils/uid.js +2 -20
  585. package/esm/utils/validate/error.js +23 -26
  586. package/esm/utils/validate/get-rule.js +16 -26
  587. package/esm/utils/validate/index.d.ts +1 -1
  588. package/esm/utils/validate/index.d.ts.map +1 -1
  589. package/esm/utils/validate/index.js +20 -40
  590. package/esm/utils/validate/isJson.js +3 -12
  591. package/esm/utils/validate/nullable.js +2 -9
  592. package/esm/utils/validate/type.d.ts +1 -1
  593. package/esm/utils/validate/type.d.ts.map +1 -1
  594. package/esm/utils/validate/type.js +8 -19
  595. package/package.json +3 -2
@@ -1,33 +1,25 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.array.filter.js");
4
- require("core-js/modules/es.object.get-own-property-descriptors.js");
5
- require("core-js/modules/es.weak-map.js");
6
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
7
- var _typeof = require("@babel/runtime/helpers/typeof");
8
- Object.defineProperty(exports, "__esModule", {
9
- value: true
10
- });
11
- exports.default = void 0;
12
- require("core-js/modules/es.array.map.js");
13
- require("core-js/modules/es.array.concat.js");
14
- require("core-js/modules/web.dom-collections.for-each.js");
15
- require("core-js/modules/es.array.iterator.js");
16
- require("core-js/modules/es.map.js");
17
- require("core-js/modules/web.dom-collections.iterator.js");
18
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
20
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
21
- var _react = _interopRequireWildcard(require("react"));
22
- var _useLatestObj = _interopRequireDefault(require("../../common/use-latest-obj"));
23
- var _usePersistFn = _interopRequireDefault(require("../../common/use-persist-fn"));
24
- var _usePrevious = _interopRequireDefault(require("../../common/use-previous"));
25
- var _element = require("../../utils/dom/element");
26
- var _is = require("../../utils/is");
27
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
30
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1
+ 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); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ import React, { useEffect, useRef, useLayoutEffect } from 'react';
18
+ import useLatestObj from "../../common/use-latest-obj";
19
+ import usePersistFn from "../../common/use-persist-fn";
20
+ import usePrevious from "../../common/use-previous";
21
+ import { addResizeObserver } from "../../utils/dom/element";
22
+ import { isFunc, isNumber } from "../../utils/is";
31
23
  var MIN_RESIZABLE_WIDTH = 20;
32
24
  function compareColumnWidth(curCols, preCols) {
33
25
  if (curCols.length !== preCols.length) return false;
@@ -40,60 +32,60 @@ var useTableLayout = function useTableLayout(props) {
40
32
  var theadRef = props.theadRef,
41
33
  tbodyRef = props.tbodyRef,
42
34
  scrollRef = props.scrollRef;
43
- var preColumns = (0, _usePrevious.default)(props.columns);
44
- var preData = (0, _usePrevious.default)(props.data);
45
- var _useRef = (0, _react.useRef)({
35
+ var preColumns = usePrevious(props.columns);
36
+ var preData = usePrevious(props.data);
37
+ var _useRef = useRef({
46
38
  checkNum: 0,
47
39
  cachedWidth: null,
48
40
  dragWidth: 0,
49
41
  clientWidth: 0
50
42
  }),
51
43
  context = _useRef.current;
52
- var _React$useState = _react.default.useState(false),
53
- _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
44
+ var _React$useState = React.useState(false),
45
+ _React$useState2 = _slicedToArray(_React$useState, 2),
54
46
  isScrollX = _React$useState2[0],
55
47
  setIsScrollX = _React$useState2[1];
56
- var _React$useState3 = _react.default.useState(0),
57
- _React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
48
+ var _React$useState3 = React.useState(0),
49
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
58
50
  deltaXSum = _React$useState4[0],
59
51
  setDeltaXSum = _React$useState4[1];
60
- var _React$useState5 = _react.default.useState(false),
61
- _React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
52
+ var _React$useState5 = React.useState(false),
53
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
62
54
  isScrollY = _React$useState6[0],
63
55
  setIsScrollY = _React$useState6[1];
64
- var _React$useState7 = _react.default.useState(false),
65
- _React$useState8 = (0, _slicedToArray2.default)(_React$useState7, 2),
56
+ var _React$useState7 = React.useState(false),
57
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
66
58
  floatLeft = _React$useState8[0],
67
59
  setFloatLeft = _React$useState8[1];
68
- var _React$useState9 = _react.default.useState(false),
69
- _React$useState10 = (0, _slicedToArray2.default)(_React$useState9, 2),
60
+ var _React$useState9 = React.useState(false),
61
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
70
62
  floatRight = _React$useState10[0],
71
63
  setFloatRight = _React$useState10[1];
72
- var _React$useState11 = _react.default.useState(0),
73
- _React$useState12 = (0, _slicedToArray2.default)(_React$useState11, 2),
64
+ var _React$useState11 = React.useState(0),
65
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
74
66
  resizeFlag = _React$useState12[0],
75
67
  setResizeFlag = _React$useState12[1];
76
- var _React$useState13 = _react.default.useState(0),
77
- _React$useState14 = (0, _slicedToArray2.default)(_React$useState13, 2),
68
+ var _React$useState13 = React.useState(0),
69
+ _React$useState14 = _slicedToArray(_React$useState13, 2),
78
70
  scrollBarWidth = _React$useState14[0],
79
71
  setScrollBarWidth = _React$useState14[1];
80
- var _React$useState15 = _react.default.useState(0),
81
- _React$useState16 = (0, _slicedToArray2.default)(_React$useState15, 2),
72
+ var _React$useState15 = React.useState(0),
73
+ _React$useState16 = _slicedToArray(_React$useState15, 2),
82
74
  scrollWidth = _React$useState16[0],
83
75
  setScrollWidth = _React$useState16[1];
84
- var _React$useState17 = _react.default.useState(props.columns.map(function (v) {
76
+ var _React$useState17 = React.useState(props.columns.map(function (v) {
85
77
  return v.width;
86
78
  })),
87
- _React$useState18 = (0, _slicedToArray2.default)(_React$useState17, 2),
79
+ _React$useState18 = _slicedToArray(_React$useState17, 2),
88
80
  colgroup = _React$useState18[0],
89
81
  setColgroup = _React$useState18[1];
90
- var _React$useState19 = _react.default.useState(true),
91
- _React$useState20 = (0, _slicedToArray2.default)(_React$useState19, 2),
82
+ var _React$useState19 = React.useState(true),
83
+ _React$useState20 = _slicedToArray(_React$useState19, 2),
92
84
  adjust = _React$useState20[0],
93
85
  setAdjust = _React$useState20[1];
94
86
 
95
87
  // 检查滚动状态
96
- var checkScroll = (0, _usePersistFn.default)(function () {
88
+ var checkScroll = usePersistFn(function () {
97
89
  var scrollEl = scrollRef.current;
98
90
  if (!scrollEl) return;
99
91
  if (context.checkNum > 10) {
@@ -115,7 +107,7 @@ var useTableLayout = function useTableLayout(props) {
115
107
  });
116
108
 
117
109
  // 拖拽列
118
- var dragCol = (0, _usePersistFn.default)(function (index, deltaX) {
110
+ var dragCol = usePersistFn(function (index, deltaX) {
119
111
  var col = props.columns[index];
120
112
  if (!colgroup) return;
121
113
  var table = theadRef.current || tbodyRef.current;
@@ -127,12 +119,12 @@ var useTableLayout = function useTableLayout(props) {
127
119
  oWidth = colEl.getBoundingClientRect().width;
128
120
  }
129
121
  var w = oWidth + deltaX;
130
- if ((0, _is.isNumber)(col.minWidth)) {
122
+ if (isNumber(col.minWidth)) {
131
123
  w = Math.max(w, col.minWidth);
132
124
  } else {
133
125
  w = Math.max(w, MIN_RESIZABLE_WIDTH);
134
126
  }
135
- if ((0, _is.isNumber)(col.maxWidth)) {
127
+ if (isNumber(col.maxWidth)) {
136
128
  w = Math.min(w, col.maxWidth);
137
129
  }
138
130
  colEl.style.width = "".concat(w, "px");
@@ -152,13 +144,13 @@ var useTableLayout = function useTableLayout(props) {
152
144
  };
153
145
 
154
146
  // 完成拖拽
155
- var resizeCol = (0, _usePersistFn.default)(function (index) {
147
+ var resizeCol = usePersistFn(function (index) {
156
148
  if (!props.columnResizable) return;
157
149
  if (!colgroup) return;
158
150
  var deltaX = context.dragWidth - colgroup[index];
159
- var newColgroup = (0, _toConsumableArray2.default)(colgroup);
151
+ var newColgroup = _toConsumableArray(colgroup);
160
152
  newColgroup[index] = context.dragWidth;
161
- if ((0, _is.isFunc)(props.onColumnResize)) {
153
+ if (isFunc(props.onColumnResize)) {
162
154
  var newColumns = props.columns.map(function (item) {
163
155
  return _objectSpread(_objectSpread({}, item), {}, {
164
156
  width: newColgroup[index]
@@ -174,7 +166,7 @@ var useTableLayout = function useTableLayout(props) {
174
166
  });
175
167
 
176
168
  // 根据column的宽度计算colgroup
177
- var resetColGroup = (0, _usePersistFn.default)(function () {
169
+ var resetColGroup = usePersistFn(function () {
178
170
  var columnLengthChange = preColumns && preColumns.length !== props.columns.length;
179
171
  // 当支持拖拽列 并且有缓存 并且 column 的数量没有发生变化的时候, 从缓存中获取宽度
180
172
  var useCache = props.columnResizable && context.cachedWidth && !columnLengthChange;
@@ -188,7 +180,7 @@ var useTableLayout = function useTableLayout(props) {
188
180
  });
189
181
 
190
182
  // 根据渲染内容计算colgroup
191
- var getColgroup = (0, _usePersistFn.default)(function (fromDrag) {
183
+ var getColgroup = usePersistFn(function (fromDrag) {
192
184
  var _props$data, _target$current;
193
185
  var target = props !== null && props !== void 0 && (_props$data = props.data) !== null && _props$data !== void 0 && _props$data.length ? tbodyRef : theadRef;
194
186
  var group = (_target$current = target.current) === null || _target$current === void 0 ? void 0 : _target$current.querySelector('colgroup');
@@ -219,13 +211,13 @@ var useTableLayout = function useTableLayout(props) {
219
211
  });
220
212
  }
221
213
  context.cachedWidth = new Map();
222
- for (var _i2 = 0; _i2 < props.columns.length; _i2++) {
223
- context.cachedWidth.set(props.columns[_i2].key, widthArr[_i2] || 0);
214
+ for (var _i = 0; _i < props.columns.length; _i++) {
215
+ context.cachedWidth.set(props.columns[_i].key, widthArr[_i] || 0);
224
216
  }
225
217
  }
226
218
  changeColGroup(newCols, false);
227
219
  });
228
- var checkFloat = (0, _usePersistFn.default)(function () {
220
+ var checkFloat = usePersistFn(function () {
229
221
  var scrollEl = scrollRef.current;
230
222
  var max = scrollEl.scrollWidth - scrollEl.clientWidth;
231
223
  var min = 0;
@@ -235,7 +227,7 @@ var useTableLayout = function useTableLayout(props) {
235
227
  if (l !== floatLeft) setFloatLeft(l);
236
228
  if (r !== floatRight) setFloatRight(r);
237
229
  });
238
- var syncScrollWidth = (0, _usePersistFn.default)(function () {
230
+ var syncScrollWidth = usePersistFn(function () {
239
231
  if (!scrollRef.current) return;
240
232
  var scrollEl = scrollRef.current;
241
233
  var w = scrollEl.scrollWidth;
@@ -243,7 +235,7 @@ var useTableLayout = function useTableLayout(props) {
243
235
  });
244
236
 
245
237
  // 页面resize
246
- var handleResize = (0, _usePersistFn.default)(function (_, dir) {
238
+ var handleResize = usePersistFn(function (_, dir) {
247
239
  checkScroll();
248
240
  syncScrollWidth();
249
241
  if (dir.x) {
@@ -251,14 +243,14 @@ var useTableLayout = function useTableLayout(props) {
251
243
  resetColGroup();
252
244
  }
253
245
  });
254
- var func = (0, _useLatestObj.default)({
246
+ var func = useLatestObj({
255
247
  scrollCheck: checkScroll,
256
248
  resetColGroup: resetColGroup,
257
249
  resizeCol: resizeCol,
258
250
  dragCol: dragCol,
259
251
  checkFloat: checkFloat
260
252
  });
261
- (0, _react.useEffect)(function () {
253
+ useEffect(function () {
262
254
  if (!colgroup) return;
263
255
  // columns 增加或者减少列, 或者宽度发生变化且和colgroup的宽度不一致时
264
256
  if (preColumns && !compareColumnWidth(props.columns, preColumns)) {
@@ -272,20 +264,20 @@ var useTableLayout = function useTableLayout(props) {
272
264
  if (preData.length === 0 || props.dataChangeResize) resetColGroup();
273
265
  }
274
266
  }, [props.columns, props.data, props.dataChangeResize]);
275
- (0, _react.useEffect)(function () {
267
+ useEffect(function () {
276
268
  var cancelFunc;
277
269
  syncScrollWidth();
278
270
  if (scrollRef.current) {
279
- cancelFunc = (0, _element.addResizeObserver)(scrollRef.current, handleResize, {
271
+ cancelFunc = addResizeObserver(scrollRef.current, handleResize, {
280
272
  direction: true
281
273
  });
282
274
  }
283
275
  return function () {
284
276
  var _cancelFunc;
285
- (_cancelFunc = cancelFunc) === null || _cancelFunc === void 0 ? void 0 : _cancelFunc();
277
+ (_cancelFunc = cancelFunc) === null || _cancelFunc === void 0 || _cancelFunc();
286
278
  };
287
279
  }, [scrollRef.current]);
288
- (0, _react.useLayoutEffect)(function () {
280
+ useLayoutEffect(function () {
289
281
  if (adjust) {
290
282
  getColgroup(adjust === 'drag');
291
283
  setAdjust(false);
@@ -311,5 +303,4 @@ var useTableLayout = function useTableLayout(props) {
311
303
  resizeFlag: resizeFlag
312
304
  };
313
305
  };
314
- var _default = useTableLayout;
315
- exports.default = _default;
306
+ export default useTableLayout;
@@ -1,18 +1,12 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- require("core-js/modules/es.array.map.js");
10
- require("core-js/modules/es.array.iterator.js");
11
- require("core-js/modules/es.set.js");
12
- require("core-js/modules/web.dom-collections.iterator.js");
13
- var _is = require("../../utils/is");
14
- var _react = require("react");
15
- var _usePersistFn = require("../../common/use-persist-fn");
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { isObject, isFunc } from "../../utils/is";
8
+ import { useMemo, useState, useRef } from 'react';
9
+ import { usePersistFn } from "../../common/use-persist-fn";
16
10
  // handle rowSpan colSpan
17
11
  function format(columns, data, nextRow, index) {
18
12
  var row = columns.map(function (col, i) {
@@ -25,9 +19,9 @@ function format(columns, data, nextRow, index) {
25
19
  var rowSpan = col.rowSpan;
26
20
  if (rowSpan && nextRow && nextRow[i]) {
27
21
  if (col.type !== 'checkbox') {
28
- if (typeof col.render === 'string' && (0, _is.isObject)(data)) {
22
+ if (typeof col.render === 'string' && isObject(data)) {
29
23
  cell.content = data[col.render];
30
- } else if ((0, _is.isFunc)(col.render)) {
24
+ } else if (isFunc(col.render)) {
31
25
  cell.content = col.render(data, index);
32
26
  }
33
27
  }
@@ -54,15 +48,15 @@ function format(columns, data, nextRow, index) {
54
48
  */
55
49
  var useTableRow = function useTableRow(props) {
56
50
  var currentIndex = props.currentIndex;
57
- var _useRef = (0, _react.useRef)({
51
+ var _useRef = useRef({
58
52
  rowSelectMergeStartData: []
59
53
  }),
60
54
  context = _useRef.current;
61
- var _useState = (0, _react.useState)(new Set()),
62
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
55
+ var _useState = useState(new Set()),
56
+ _useState2 = _slicedToArray(_useState, 2),
63
57
  hoverIndex = _useState2[0],
64
58
  setHoverIndex = _useState2[1];
65
- var handleCellHover = (0, _usePersistFn.usePersistFn)(function (rowIndex) {
59
+ var handleCellHover = usePersistFn(function (rowIndex) {
66
60
  var colSpan = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
67
61
  if (!props.hover) return;
68
62
  var hoverIndex = new Set();
@@ -71,7 +65,7 @@ var useTableRow = function useTableRow(props) {
71
65
  }
72
66
  setHoverIndex(hoverIndex);
73
67
  });
74
- var isCellHover = (0, _usePersistFn.usePersistFn)(function (rowIndex) {
68
+ var isCellHover = usePersistFn(function (rowIndex) {
75
69
  var colSpan = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
76
70
  if (!props.hover) return false;
77
71
  var isHover = false;
@@ -81,7 +75,7 @@ var useTableRow = function useTableRow(props) {
81
75
  }
82
76
  return isHover;
83
77
  });
84
- var rowData = (0, _react.useMemo)(function () {
78
+ var rowData = useMemo(function () {
85
79
  var rows = [];
86
80
  context.rowSelectMergeStartData = [];
87
81
  var data = props.data || [];
@@ -113,5 +107,4 @@ var useTableRow = function useTableRow(props) {
113
107
  rowSelectMergeStartData: context.rowSelectMergeStartData
114
108
  };
115
109
  };
116
- var _default = useTableRow;
117
- exports.default = _default;
110
+ export default useTableRow;
@@ -10,7 +10,7 @@ export interface SortInfo {
10
10
  manual: boolean;
11
11
  multiple?: boolean;
12
12
  }
13
- export declare type SortMap = Map<string | number, SortInfo>;
13
+ export type SortMap = Map<string | number, SortInfo>;
14
14
  declare const useTableSort: <Item = any>(props: UseTableSorterProps<Item>) => {
15
15
  sortInfo: SortMap;
16
16
  onSorterChange: (columnKey: KeygenResult, direction: 'desc' | 'asc' | null, manual: boolean | undefined, columnSorter: string | import("./use-table.type").TableColumnSorter | ((order: import("./use-table.type").TableColumnOrder) => void | ((prevRowData: Item, nextRowData: Item) => number)) | undefined) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-sort.d.ts","sourceRoot":"","sources":["use-table-sort.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,mBAAmB,CAAC,IAAI,GAAG,GAAG,CAC7C,SAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtE,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;CACpC;AACD,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IACvD,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,oBAAY,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC;AACrD,QAAA,MAAM,YAAY;;gCAoCD,YAAY,aAIZ,MAAM,GAAG,KAAK,GAAG,IAAI;;CAoGrC,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"use-table-sort.d.ts","sourceRoot":"","sources":["use-table-sort.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,mBAAmB,CAAC,IAAI,GAAG,GAAG,CAC7C,SAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtE,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;CACpC;AACD,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IACvD,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC;AACrD,QAAA,MAAM,YAAY;;gCAoCD,YAAY,aAIZ,MAAM,GAAG,KAAK,GAAG,IAAI;;CAoGrC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,36 +1,30 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.object.get-own-property-descriptors.js");
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- require("core-js/modules/es.array.iterator.js");
10
- require("core-js/modules/es.map.js");
11
- require("core-js/modules/web.dom-collections.iterator.js");
12
- require("core-js/modules/es.array.map.js");
13
- require("core-js/modules/es.array.sort.js");
14
- require("core-js/modules/es.array.filter.js");
15
- require("core-js/modules/es.array.from.js");
16
- require("core-js/modules/web.dom-collections.for-each.js");
17
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
18
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
19
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
20
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
21
- var _react = require("react");
22
- var _ = require("../..");
23
- var _is = require("../../utils/is");
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1
+ 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); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ import { useState, useMemo, useEffect, useRef } from 'react';
18
+ import { usePersistFn } from "../..";
19
+ import { isObject, isFunc } from "../../utils/is";
26
20
  var useTableSort = function useTableSort(props) {
27
21
  var sorter = props.sorter,
28
22
  data = props.data;
29
- var _useState = (0, _react.useState)(new Map()),
30
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
23
+ var _useState = useState(new Map()),
24
+ _useState2 = _slicedToArray(_useState, 2),
31
25
  sortInfo = _useState2[0],
32
26
  setSortInfo = _useState2[1];
33
- var _useRef = (0, _react.useRef)({
27
+ var _useRef = useRef({
34
28
  mounted: false,
35
29
  sortInfo: new Map()
36
30
  }),
@@ -38,7 +32,7 @@ var useTableSort = function useTableSort(props) {
38
32
  if (!context.sortInfo) {
39
33
  context.sortInfo = sortInfo;
40
34
  }
41
- var getSortList = (0, _.usePersistFn)(function (info) {
35
+ var getSortList = usePersistFn(function (info) {
42
36
  return Array.from(info.keys()).filter(function (name) {
43
37
  var _info$get;
44
38
  return (_info$get = info.get(name)) === null || _info$get === void 0 ? void 0 : _info$get.order;
@@ -54,21 +48,21 @@ var useTableSort = function useTableSort(props) {
54
48
  });
55
49
  });
56
50
  });
57
- var sortedData = (0, _react.useMemo)(function () {
58
- var newData = (0, _toConsumableArray2.default)(data || []);
51
+ var sortedData = useMemo(function () {
52
+ var newData = _toConsumableArray(data || []);
59
53
  var sortList = getSortList(sortInfo);
60
54
  sortList.forEach(function (sort) {
61
55
  if (sort.sort) newData.sort(sort.sort);
62
56
  });
63
57
  return newData;
64
58
  }, [sortInfo, data]);
65
- var onSorterChange = (0, _.usePersistFn)(function (columnKey, direction) {
59
+ var onSorterChange = usePersistFn(function (columnKey, direction) {
66
60
  var manual = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
67
61
  var columnSorter = arguments.length > 3 ? arguments[3] : undefined;
68
62
  var sortName = undefined;
69
63
  if (typeof columnSorter === 'string') {
70
64
  sortName = columnSorter;
71
- } else if ((0, _is.isObject)(columnSorter) && !(0, _is.isFunc)(columnSorter)) {
65
+ } else if (isObject(columnSorter) && !isFunc(columnSorter)) {
72
66
  if (typeof columnSorter.rule === 'string') {
73
67
  sortName = columnSorter.rule;
74
68
  }
@@ -85,14 +79,14 @@ var useTableSort = function useTableSort(props) {
85
79
  };
86
80
  var newInfo = multiple ? new Map(_sortInfo) : new Map();
87
81
  newInfo.set(columnKey, sortObj);
88
- if ((0, _is.isFunc)(columnSorter)) {
82
+ if (isFunc(columnSorter)) {
89
83
  sortObj.sort = columnSorter(direction);
90
84
  sortObj.multiple = false;
91
- } else if ((0, _is.isObject)(columnSorter)) {
85
+ } else if (isObject(columnSorter)) {
92
86
  sortObj.weight = columnSorter.weight || 0;
93
87
  sortObj.multiple = true;
94
88
  var rule = columnSorter.rule;
95
- if (typeof rule === 'string') {} else if ((0, _is.isFunc)(rule)) {
89
+ if (typeof rule === 'string') {} else if (isFunc(rule)) {
96
90
  var infoList = getSortList(newInfo).map(function (item) {
97
91
  return {
98
92
  key: item.key,
@@ -137,17 +131,17 @@ var useTableSort = function useTableSort(props) {
137
131
  });
138
132
  if (sortName) {
139
133
  var _props$onSortCancel;
140
- (_props$onSortCancel = props.onSortCancel) === null || _props$onSortCancel === void 0 ? void 0 : _props$onSortCancel.call(props, beforeSortOrder, columnKey, _infoList2, sortName);
134
+ (_props$onSortCancel = props.onSortCancel) === null || _props$onSortCancel === void 0 || _props$onSortCancel.call(props, beforeSortOrder, columnKey, _infoList2, sortName);
141
135
  }
142
136
  }
143
137
  });
144
- (0, _react.useEffect)(function () {
138
+ useEffect(function () {
145
139
  if (context.mounted) return;
146
140
  var hasSingleDefaultOrder = false;
147
141
  for (var i = 0; i < props.columns.length; i++) {
148
142
  var col = props.columns[i];
149
143
  if (col.defaultOrder && col.sorter) {
150
- if ((0, _typeof2.default)(col.sorter) !== 'object') {
144
+ if (_typeof(col.sorter) !== 'object') {
151
145
  if (hasSingleDefaultOrder) {
152
146
  break;
153
147
  } else {
@@ -165,5 +159,4 @@ var useTableSort = function useTableSort(props) {
165
159
  sortedData: sortedData
166
160
  };
167
161
  };
168
- var _default = useTableSort;
169
- exports.default = _default;
162
+ export default useTableSort;