react-kui 3.1.1 → 3.2.0

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 (396) hide show
  1. package/README.zh-CN.md +3 -1
  2. package/ai/kui-components.json +912 -318
  3. package/es/_virtual/_rolldown/runtime.js +1 -1
  4. package/es/affix/index.js +1 -1
  5. package/es/alert/index.js +11 -4
  6. package/es/anchor/anchor-context.js +1 -1
  7. package/es/anchor/anchor-link.js +1 -1
  8. package/es/anchor/anchor.js +1 -1
  9. package/es/auto-complete/index.js +371 -347
  10. package/es/avatar/avatar-group-context.js +1 -1
  11. package/es/avatar/avatar-group.js +1 -1
  12. package/es/avatar/avatar.js +1 -1
  13. package/es/back-top/index.js +1 -1
  14. package/es/badge/index.js +10 -8
  15. package/es/base/teleport.js +1 -1
  16. package/es/base/transition-props.js +1 -1
  17. package/es/base/transition.js +1 -1
  18. package/es/breadcrumb/breadcrumb-context.js +1 -1
  19. package/es/breadcrumb/breadcrumb-item.js +1 -1
  20. package/es/breadcrumb/breadcrumb.js +1 -1
  21. package/es/button/button-group-context.js +1 -1
  22. package/es/button/button-group.js +1 -1
  23. package/es/button/button.js +13 -6
  24. package/es/calendar/index.js +20 -6
  25. package/es/card/index.js +11 -4
  26. package/es/carousel/carousel-context.js +1 -1
  27. package/es/carousel/carousel-item.js +1 -1
  28. package/es/carousel/carousel.js +1 -1
  29. package/es/carousel/drag.js +1 -1
  30. package/es/cascader/index.js +13 -10
  31. package/es/check-card/check-card-group.js +3 -3
  32. package/es/check-card/check-card.js +155 -141
  33. package/es/check-card/context.js +1 -1
  34. package/es/checkbox/checkbox-group-context.js +1 -1
  35. package/es/checkbox/checkbox-group.js +3 -3
  36. package/es/checkbox/checkbox.js +64 -244
  37. package/es/checkbox/index.js +1 -1
  38. package/es/collapse/collapse-panel.js +1 -1
  39. package/es/collapse/collapse.js +96 -82
  40. package/es/color-picker/alpha.js +1 -1
  41. package/es/color-picker/hue.js +1 -1
  42. package/es/color-picker/index.js +7 -7
  43. package/es/color-picker/mode.js +2 -2
  44. package/es/color-picker/paint.js +1 -1
  45. package/es/color-picker/presets.js +1 -1
  46. package/es/components.js +4 -4
  47. package/es/config/config-context.js +16 -3
  48. package/es/config/context.js +29 -2
  49. package/es/config/index.js +31 -12
  50. package/es/config/popup-host.js +106 -0
  51. package/es/config/size-context.js +1 -1
  52. package/es/config/use-config-appearance.js +62 -2
  53. package/es/const/var.js +6 -2
  54. package/es/date-picker/index.js +404 -885
  55. package/es/descriptions/descriptions-item.js +1 -1
  56. package/es/descriptions/descriptions.js +1 -1
  57. package/es/divider/index.js +1 -1
  58. package/es/drawer/index.js +328 -240
  59. package/es/dropdown/dropdown-button.js +69 -51
  60. package/es/dropdown/dropdown-context.js +1 -1
  61. package/es/dropdown/dropdown.js +137 -93
  62. package/es/dropdown/trigger.js +85 -33
  63. package/es/empty/index.js +3 -4
  64. package/es/feature-card/index.js +15 -4
  65. package/es/feedback-panel/index.js +95 -81
  66. package/es/flame-wrap/index.js +116 -109
  67. package/es/flame-wrap/types.js +54 -6
  68. package/es/flex/index.js +1 -1
  69. package/es/form/field-context.js +16 -2
  70. package/es/form/form-context.js +1 -1
  71. package/es/form/form-item.js +7 -6
  72. package/es/form/form.js +1 -1
  73. package/es/form/utils.js +1 -1
  74. package/es/grid/grid-item.js +1 -1
  75. package/es/grid/grid.js +1 -1
  76. package/es/grid/useBreakpoint.js +1 -1
  77. package/es/icon/index.js +1 -1
  78. package/es/image/group.js +1 -1
  79. package/es/image/image-group-context.js +1 -1
  80. package/es/image/image.js +137 -123
  81. package/es/image/instance.js +1 -1
  82. package/es/image/preview.js +1 -1
  83. package/es/image/utils.js +1 -1
  84. package/es/index.js +3 -3
  85. package/es/input/index.js +3 -3
  86. package/es/input/input-base.js +7 -7
  87. package/es/input/input-box.js +2 -2
  88. package/es/input/input-group.js +43 -127
  89. package/es/input/input.js +1 -1
  90. package/es/input/textarea.js +28 -114
  91. package/es/input-number/index.js +7 -5
  92. package/es/input-otp/index.js +5 -5
  93. package/es/input-tag/index.js +5 -5
  94. package/es/kanban/index.js +79 -63
  95. package/es/layout/index.js +1 -1
  96. package/es/layout/layout-context.js +1 -1
  97. package/es/list-panel/index.js +96 -83
  98. package/es/loading/index.js +1 -1
  99. package/es/loading/loading-bar.js +1 -1
  100. package/es/locale/de.js +10 -2
  101. package/es/locale/el.js +10 -2
  102. package/es/locale/en.js +10 -2
  103. package/es/locale/fr.js +10 -2
  104. package/es/locale/it.js +10 -2
  105. package/es/locale/ja.js +10 -2
  106. package/es/locale/ko.js +10 -2
  107. package/es/locale/ru.js +10 -2
  108. package/es/locale/th.js +10 -2
  109. package/es/locale/uk.js +10 -2
  110. package/es/locale/vi.js +10 -2
  111. package/es/locale/zh-CN.js +10 -2
  112. package/es/locale/zh-TW.js +10 -2
  113. package/es/mentions/index.js +291 -286
  114. package/es/menu/menu-context.js +1 -1
  115. package/es/menu/menu-divider.js +1 -1
  116. package/es/menu/menu-group.js +1 -1
  117. package/es/menu/menu-item.js +1 -1
  118. package/es/menu/menu-keyboard.js +41 -2
  119. package/es/menu/menu.js +268 -222
  120. package/es/menu/recursive-menu.js +1 -1
  121. package/es/menu/sub-menu.js +81 -23
  122. package/es/message/index.js +1 -1
  123. package/es/modal/api.js +46 -12
  124. package/es/modal/modal.js +441 -345
  125. package/es/modal/toast.js +177 -64
  126. package/es/node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js +1 -1
  127. package/es/notice/container.js +1 -1
  128. package/es/notice/content.js +1 -1
  129. package/es/notice/index.js +1 -1
  130. package/es/notice/instance.js +1 -1
  131. package/es/page/index.js +13 -8
  132. package/es/page/responsive.js +1 -1
  133. package/es/page-header/index.js +1 -1
  134. package/es/popconfirm/index.js +36 -35
  135. package/es/poptip/index.js +47 -45
  136. package/es/popup/index.js +5 -2
  137. package/es/popup/layers.js +11 -2
  138. package/es/progress/index.js +1 -1
  139. package/es/qrcode/index.js +13 -7
  140. package/es/radio/radio-button.js +51 -44
  141. package/es/radio/radio-group-context.js +1 -1
  142. package/es/radio/radio-group.js +49 -52
  143. package/es/radio/radio.js +46 -197
  144. package/es/rate/index.js +1 -1
  145. package/es/rate/star.js +1 -1
  146. package/es/result/index.js +1 -1
  147. package/es/ripple/index.js +104 -97
  148. package/es/ripple/types.js +71 -18
  149. package/es/row-col/col.js +1 -1
  150. package/es/row-col/row.js +1 -1
  151. package/es/segmented/index.js +3 -3
  152. package/es/select/option.js +1 -1
  153. package/es/select/select.js +33 -36
  154. package/es/skeleton/skeleton-avatar.js +1 -1
  155. package/es/skeleton/skeleton-button.js +1 -1
  156. package/es/skeleton/skeleton-image.js +1 -1
  157. package/es/skeleton/skeleton-text.js +1 -1
  158. package/es/skeleton/skeleton.js +1 -1
  159. package/es/skeleton/use-skeleton-loading.js +1 -1
  160. package/es/slider/index.js +1 -1
  161. package/es/slider/thumb.js +1 -1
  162. package/es/space/index.js +1 -1
  163. package/es/spin/index.js +1 -1
  164. package/es/splitter/splitter-panel.js +1 -1
  165. package/es/splitter/splitter.js +1 -1
  166. package/es/stat-card/countup.js +2 -2
  167. package/es/stat-card/rollup.js +1 -1
  168. package/es/stat-card/stat-card.js +16 -7
  169. package/es/stat-card/stat-number.js +4 -3
  170. package/es/stat-card/utils/countup.js +1 -1
  171. package/es/stat-card/utils/odometer.js +1 -1
  172. package/es/stat-card/utils/stat-item-key.js +22 -0
  173. package/es/steps/index.js +1 -1
  174. package/es/switch/index.js +3 -3
  175. package/es/table/column-setting.js +104 -115
  176. package/es/table/index.js +544 -206
  177. package/es/table/utils.js +141 -3
  178. package/es/tabs/tab-panel.js +1 -1
  179. package/es/tabs/tabs.js +1 -1
  180. package/es/tag/index.js +12 -5
  181. package/es/time-line/timeline-item.js +1 -1
  182. package/es/time-line/timeline.js +1 -1
  183. package/es/tooltip/index.js +114 -94
  184. package/es/tour/index.js +1 -1
  185. package/es/transfer/index.js +190 -172
  186. package/es/tree/index.js +55 -44
  187. package/es/tree/utils.js +1 -1
  188. package/es/tree-select/index.js +259 -781
  189. package/es/typography/index.js +1 -1
  190. package/es/upload/file-list.js +1 -1
  191. package/es/upload/index.js +5 -6
  192. package/es/upload/picture-sort.js +1 -1
  193. package/es/upload/selector.js +1 -1
  194. package/es/utils/checked.js +1 -1
  195. package/es/utils/color.js +25 -2
  196. package/es/utils/css.js +19 -0
  197. package/es/utils/focus.js +63 -0
  198. package/es/utils/number.js +1 -1
  199. package/es/utils/overlay-order.js +18 -0
  200. package/es/utils/overlay-stack.js +33 -0
  201. package/es/utils/placement.js +1 -1
  202. package/es/utils/popup.js +1 -1
  203. package/es/utils/promise.js +18 -0
  204. package/es/utils/react-node.js +55 -30
  205. package/es/utils/selection-tags.js +6 -4
  206. package/es/utils/share.js +5 -2
  207. package/es/utils/theme.js +1 -1
  208. package/es/utils/transition.js +1 -1
  209. package/es/utils/use-value.js +1 -1
  210. package/es/virtual-list/index.js +1 -1
  211. package/es/virtual-list/range.js +3 -2
  212. package/es/watermark/index.js +1 -1
  213. package/lib/index.cjs +2 -2
  214. package/lib/locale/de.cjs +2 -2
  215. package/lib/locale/el.cjs +2 -2
  216. package/lib/locale/en.cjs +2 -2
  217. package/lib/locale/fr.cjs +2 -2
  218. package/lib/locale/it.cjs +2 -2
  219. package/lib/locale/ja.cjs +2 -2
  220. package/lib/locale/ko.cjs +2 -2
  221. package/lib/locale/ru.cjs +2 -2
  222. package/lib/locale/th.cjs +2 -2
  223. package/lib/locale/uk.cjs +2 -2
  224. package/lib/locale/vi.cjs +2 -2
  225. package/lib/locale/zh-CN.cjs +2 -2
  226. package/lib/locale/zh-TW.cjs +2 -2
  227. package/package.json +4 -3
  228. package/readme.md +3 -1
  229. package/style/base.css +2 -2
  230. package/style/components.css +2 -2
  231. package/style/index.css +2 -2
  232. package/style/theme.css +2 -2
  233. package/types/alert/index.d.cts +2 -2
  234. package/types/alert/index.d.ts +2 -2
  235. package/types/auto-complete/index.d.cts +7 -1
  236. package/types/auto-complete/index.d.ts +7 -1
  237. package/types/badge/index.d.cts +2 -1
  238. package/types/badge/index.d.ts +2 -1
  239. package/types/button/button.d.cts +2 -2
  240. package/types/button/button.d.ts +2 -2
  241. package/types/card/index.d.cts +3 -3
  242. package/types/card/index.d.ts +3 -3
  243. package/types/cascader/index.d.cts +1 -1
  244. package/types/cascader/index.d.ts +1 -1
  245. package/types/cascader/types.d.cts +2 -0
  246. package/types/cascader/types.d.ts +2 -0
  247. package/types/check-card/context.d.cts +4 -3
  248. package/types/check-card/context.d.ts +4 -3
  249. package/types/check-card/index.d.cts +1 -1
  250. package/types/check-card/index.d.ts +1 -1
  251. package/types/check-card/types.d.cts +3 -4
  252. package/types/check-card/types.d.ts +3 -4
  253. package/types/checkbox/checkbox-group.d.cts +2 -2
  254. package/types/checkbox/checkbox-group.d.ts +2 -2
  255. package/types/checkbox/checkbox.d.cts +2 -2
  256. package/types/checkbox/checkbox.d.ts +2 -2
  257. package/types/collapse/collapse.d.cts +3 -3
  258. package/types/collapse/collapse.d.ts +3 -3
  259. package/types/color-picker/index.d.cts +3 -1
  260. package/types/color-picker/index.d.ts +3 -1
  261. package/types/components.d.cts +2 -2
  262. package/types/components.d.ts +2 -2
  263. package/types/config/config-context.d.cts +15 -2
  264. package/types/config/config-context.d.ts +15 -2
  265. package/types/config/context.d.cts +6 -0
  266. package/types/config/context.d.ts +6 -0
  267. package/types/config/popup-host.d.cts +16 -0
  268. package/types/config/popup-host.d.ts +16 -0
  269. package/types/config/use-config-appearance.d.cts +41 -2
  270. package/types/config/use-config-appearance.d.ts +41 -2
  271. package/types/const/types.d.cts +30 -1
  272. package/types/const/types.d.ts +30 -1
  273. package/types/const/var.d.cts +6 -1
  274. package/types/const/var.d.ts +6 -1
  275. package/types/date-picker/index.d.cts +3 -1
  276. package/types/date-picker/index.d.ts +3 -1
  277. package/types/descriptions/descriptions.d.cts +2 -2
  278. package/types/descriptions/descriptions.d.ts +2 -2
  279. package/types/drawer/index.d.cts +1 -0
  280. package/types/drawer/index.d.ts +1 -0
  281. package/types/dropdown/dropdown-button.d.cts +5 -2
  282. package/types/dropdown/dropdown-button.d.ts +5 -2
  283. package/types/dropdown/dropdown-context.d.cts +6 -0
  284. package/types/dropdown/dropdown-context.d.ts +6 -0
  285. package/types/dropdown/dropdown.d.cts +2 -0
  286. package/types/dropdown/dropdown.d.ts +2 -0
  287. package/types/feature-card/index.d.cts +3 -3
  288. package/types/feature-card/index.d.ts +3 -3
  289. package/types/feedback-panel/index.d.cts +3 -3
  290. package/types/feedback-panel/index.d.ts +3 -3
  291. package/types/flame-wrap/types.d.cts +18 -0
  292. package/types/flame-wrap/types.d.ts +18 -0
  293. package/types/form/field-context.d.cts +2 -0
  294. package/types/form/field-context.d.ts +2 -0
  295. package/types/image/image.d.cts +2 -2
  296. package/types/image/image.d.ts +2 -2
  297. package/types/input/input-group.d.cts +2 -2
  298. package/types/input/input-group.d.ts +2 -2
  299. package/types/input-number/index.d.cts +2 -0
  300. package/types/input-number/index.d.ts +2 -0
  301. package/types/kanban/index.d.cts +3 -2
  302. package/types/kanban/index.d.ts +3 -2
  303. package/types/list-panel/index.d.cts +3 -3
  304. package/types/list-panel/index.d.ts +3 -3
  305. package/types/locale/de.d.cts +6 -0
  306. package/types/locale/de.d.ts +6 -0
  307. package/types/locale/el.d.cts +6 -0
  308. package/types/locale/el.d.ts +6 -0
  309. package/types/locale/en.d.cts +6 -0
  310. package/types/locale/en.d.ts +6 -0
  311. package/types/locale/fr.d.cts +6 -0
  312. package/types/locale/fr.d.ts +6 -0
  313. package/types/locale/it.d.cts +6 -0
  314. package/types/locale/it.d.ts +6 -0
  315. package/types/locale/ja.d.cts +6 -0
  316. package/types/locale/ja.d.ts +6 -0
  317. package/types/locale/ko.d.cts +6 -0
  318. package/types/locale/ko.d.ts +6 -0
  319. package/types/locale/ru.d.cts +6 -0
  320. package/types/locale/ru.d.ts +6 -0
  321. package/types/locale/th.d.cts +6 -0
  322. package/types/locale/th.d.ts +6 -0
  323. package/types/locale/uk.d.cts +6 -0
  324. package/types/locale/uk.d.ts +6 -0
  325. package/types/locale/vi.d.cts +6 -0
  326. package/types/locale/vi.d.ts +6 -0
  327. package/types/locale/zh-CN.d.cts +6 -0
  328. package/types/locale/zh-CN.d.ts +6 -0
  329. package/types/locale/zh-TW.d.cts +6 -0
  330. package/types/locale/zh-TW.d.ts +6 -0
  331. package/types/mentions/index.d.cts +2 -0
  332. package/types/mentions/index.d.ts +2 -0
  333. package/types/menu/menu-keyboard.d.cts +23 -0
  334. package/types/menu/menu-keyboard.d.ts +23 -0
  335. package/types/modal/api.d.cts +6 -1
  336. package/types/modal/api.d.ts +6 -1
  337. package/types/modal/modal.d.cts +1 -0
  338. package/types/modal/modal.d.ts +1 -0
  339. package/types/modal/toast.d.cts +8 -2
  340. package/types/modal/toast.d.ts +8 -2
  341. package/types/page/index.d.cts +2 -2
  342. package/types/page/index.d.ts +2 -2
  343. package/types/popconfirm/index.d.cts +2 -0
  344. package/types/popconfirm/index.d.ts +2 -0
  345. package/types/poptip/index.d.cts +2 -0
  346. package/types/poptip/index.d.ts +2 -0
  347. package/types/popup/layers.d.cts +2 -0
  348. package/types/popup/layers.d.ts +2 -0
  349. package/types/qrcode/index.d.cts +2 -2
  350. package/types/qrcode/index.d.ts +2 -2
  351. package/types/radio/radio-button.d.cts +2 -2
  352. package/types/radio/radio-button.d.ts +2 -2
  353. package/types/radio/radio-group.d.cts +2 -2
  354. package/types/radio/radio-group.d.ts +2 -2
  355. package/types/radio/radio.d.cts +2 -2
  356. package/types/radio/radio.d.ts +2 -2
  357. package/types/ripple/types.d.cts +18 -0
  358. package/types/ripple/types.d.ts +18 -0
  359. package/types/select/select.d.cts +2 -0
  360. package/types/select/select.d.ts +2 -0
  361. package/types/stat-card/stat-card.d.cts +3 -3
  362. package/types/stat-card/stat-card.d.ts +3 -3
  363. package/types/stat-card/utils/stat-item-key.d.cts +11 -0
  364. package/types/stat-card/utils/stat-item-key.d.ts +11 -0
  365. package/types/table/column-setting.d.cts +4 -4
  366. package/types/table/column-setting.d.ts +4 -4
  367. package/types/table/index.d.cts +2 -2
  368. package/types/table/index.d.ts +2 -2
  369. package/types/table/types.d.cts +21 -2
  370. package/types/table/types.d.ts +21 -2
  371. package/types/table/utils.d.cts +75 -0
  372. package/types/table/utils.d.ts +75 -0
  373. package/types/tag/index.d.cts +2 -2
  374. package/types/tag/index.d.ts +2 -2
  375. package/types/tooltip/index.d.cts +2 -0
  376. package/types/tooltip/index.d.ts +2 -0
  377. package/types/transfer/index.d.cts +3 -2
  378. package/types/transfer/index.d.ts +3 -2
  379. package/types/tree-select/index.d.cts +3 -1
  380. package/types/tree-select/index.d.ts +3 -1
  381. package/types/utils/checked.d.cts +1 -1
  382. package/types/utils/checked.d.ts +1 -1
  383. package/types/utils/color.d.cts +13 -0
  384. package/types/utils/color.d.ts +13 -0
  385. package/types/utils/css.d.cts +2 -0
  386. package/types/utils/css.d.ts +2 -0
  387. package/types/utils/focus.d.cts +5 -0
  388. package/types/utils/focus.d.ts +5 -0
  389. package/types/utils/overlay-order.d.cts +6 -0
  390. package/types/utils/overlay-order.d.ts +6 -0
  391. package/types/utils/overlay-stack.d.cts +13 -0
  392. package/types/utils/overlay-stack.d.ts +13 -0
  393. package/types/utils/promise.d.cts +5 -0
  394. package/types/utils/promise.d.ts +5 -0
  395. package/types/utils/react-node.d.cts +10 -0
  396. package/types/utils/react-node.d.ts +10 -0
package/es/table/index.js CHANGED
@@ -1,47 +1,263 @@
1
1
  /*!
2
- * react-kui v3.1.1
2
+ * react-kui v3.2.0
3
3
  * Copyright 2017-present, kui-react.
4
4
  * All rights reserved.
5
5
  * Homepage: https://react.k-ui.cn
6
6
  * Author: Qiu / https://chuchur.com
7
7
  */
8
8
 
9
+ import { ConfigContext, DEFAULT_LOCALE } from "../config/config-context.js";
9
10
  import { normalizeSurfaceShape, useConfigAppearance } from "../config/use-config-appearance.js";
10
11
  import { ChevronDown, ChevronRight, Triangle } from "../node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js";
11
12
  import Icon from "../icon/index.js";
12
13
  import { useValue } from "../utils/use-value.js";
13
14
  import Empty from "../empty/index.js";
14
15
  import checkbox_default from "../checkbox/checkbox.js";
16
+ import Tooltip from "../tooltip/index.js";
15
17
  import { getVirtualRange } from "../virtual-list/range.js";
16
18
  import Spin from "../spin/index.js";
17
- import { countColumnLeaves, flattenColumns, flattenTreeData, getRecordValue } from "./utils.js";
19
+ import { compareSortValues, countColumnLeaves, flattenColumns, flattenTreeData, getRecordValue, inheritColumnFixed, mergeExpandAllRows, resolveCellEllipsis, resolveRowKey } from "./utils.js";
18
20
  import { TableColumnSetting } from "./column-setting.js";
21
+ import { c } from "react/compiler-runtime";
19
22
  import clsx from "clsx";
20
- import { useEffect, useMemo, useRef, useState } from "react";
23
+ import { useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
21
24
  import { jsx, jsxs } from "react/jsx-runtime";
22
25
  import { flushSync } from "react-dom";
23
26
  //#region components/table/index.tsx
24
- function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKey = "key", childrenColumnName = "children", expandedKeys, expandAllRows = false, expandRowByClick = false, indentSize = 20, scroll = {}, size: sizeProp, striped, bordered = false, shape: shapeProp, checkable, loading, emptyText, header, footer, virtual = false, itemHeight = 44, overscan = 5, hiddenColumnKeys = [], onSort, onRowClick, onSelect, onSelectAll, onSelectedKeysChange, onExpand, onExpandedKeysChange, className, ...rest }) {
27
+ /**
28
+ * 默认值必须是稳定引用。每次渲染都新建的 `[]` / `{}` 会让
29
+ * `visibleColumns → leaves → sortRecords → rows → matrix` 这条 memo 链整段失效,
30
+ * 等于每次无关重渲染都重新扁平化、重新排序、重新铺合并矩阵。
31
+ */
32
+ var EMPTY_DATA = [];
33
+ var EMPTY_COLUMNS = [];
34
+ var EMPTY_KEYS = [];
35
+ var EMPTY_SCROLL = {};
36
+ /**
37
+ * 列宽基准,与 kui-vue `components/table/index.tsx` 的同名常量保持一致。
38
+ *
39
+ * 规矩只有一条:**`<col>` 落地的宽度、算 sticky 偏移的宽度、表格内容的最小宽度,三处都从同一个
40
+ * `width ?? 150` 出发**。写了 `width` 的列(固定与否都一样)照原值写进 colgroup,偏移也按原值累加;
41
+ * 没写 `width` 的固定列按 150 落地;没写 `width` 的普通列在 colgroup 上留 `auto` 去吸收容器撑出来的
42
+ * 多余宽度,但在最小宽度里按 150 计——容器比这份下限还窄时先出横向滚动条,而不是把 `auto` 列一路压到
43
+ * 表头一个字一行。反过来把带宽度的普通列也写成 `auto` 是不行的——`table-layout: fixed`
44
+ * 下它们会被固定列的确切宽度挤到 0 宽,横向能滚的距离也一并消失,固定列就"看着没生效"。
45
+ */
46
+ var DEFAULT_COLUMN_WIDTH = 150;
47
+ /** 勾选列宽度:colgroup、行内单元格样式和固定列的左偏移三处共用 */
48
+ var SELECTION_COLUMN_WIDTH = 50;
49
+ /** 一列的宽度基准:写了 `width` 照原值,没写按 150。sticky 偏移和表格最小宽度都走它。 */
50
+ var widthBasisOf = (column) => column.width ?? DEFAULT_COLUMN_WIDTH;
51
+ /** colgroup 落地的宽度:有 `width` 照写,缺宽度的固定列按 150,缺宽度的普通列交给 `auto`。 */
52
+ var colgroupWidthOf = (column) => column.width ?? (column.fixed ? DEFAULT_COLUMN_WIDTH : "auto");
53
+ /**
54
+ * 分栏表头要按真实滚动条宽度给表头容器让出一条槽位(见 `styles/index.less` 的 `k-table-split-header`),
55
+ * 这个值只能量、不能写死:新内核走 `.k-scroll` 的 `::-webkit-scrollbar { width }` 拿到 8px,
56
+ * Firefox 走 `scrollbar-width`(不认长度值的旧版退回 `thin` 的约 11px),更老的 Safari/Windows 是 15/17px。
57
+ * 探针必须带 `k-scroll` 类——量裸 `div` 得到的是浏览器默认滚动条宽度,不是库自己那套。
58
+ * 顺带一提 `overflow: scroll` 让两条轴都出滚动条,`offsetWidth - clientWidth` 才是纵向那一条的宽度。
59
+ *
60
+ * kui-react 与 kui-vue 的 `components/table/index.tsx` 里是逐字节相同的副本,改一边必须同步另一边。
61
+ */
62
+ var measureScrollbarWidth = () => {
63
+ if (typeof document === "undefined") return 0;
64
+ const probe = document.createElement("div");
65
+ probe.className = "k-scroll";
66
+ probe.style.cssText = "position:absolute;top:-9999px;left:-9999px;width:100px;height:100px;overflow:scroll";
67
+ document.body.appendChild(probe);
68
+ const width = probe.offsetWidth - probe.clientWidth;
69
+ probe.remove();
70
+ return width;
71
+ };
72
+ /**
73
+ * 单元格省略号。`rows` 是截断行数,`tooltip` 决定悬停提示:省略或 `true` 用被截断的那段文本,
74
+ * 传内容则换成指定的提示,`false` 关掉。
75
+ *
76
+ * 提示只在**真的被截断**时才弹——判定放在 hover 那一刻量 `scrollWidth` / `scrollHeight`,
77
+ * 于是既不用给每格挂观察器,也不会给没截断的格子凭空多出一个气泡。
78
+ * `Tooltip` 在关闭时不产出任何 DOM,所以整表开启时每格挂一份也不吃亏。
79
+ */
80
+ var EllipsisCell = (t0) => {
81
+ const $ = c(19);
82
+ const { rows, tooltip, className, children } = t0;
83
+ const innerRef = useRef(null);
84
+ const [tip, setTip] = useState(null);
85
+ const multiRows = rows > 1;
86
+ let t1;
87
+ if ($[0] !== multiRows || $[1] !== tooltip) {
88
+ t1 = () => {
89
+ const element = innerRef.current;
90
+ if (!element || tooltip === false) return;
91
+ if (!(multiRows ? element.scrollHeight > element.clientHeight + 1 : element.scrollWidth > element.clientWidth + 1)) return;
92
+ if (tooltip === void 0 || tooltip === true) {
93
+ setTip(element.textContent?.replace(/\s+/g, " ").trim() || null);
94
+ return;
95
+ }
96
+ setTip(tooltip);
97
+ };
98
+ $[0] = multiRows;
99
+ $[1] = tooltip;
100
+ $[2] = t1;
101
+ } else t1 = $[2];
102
+ const enter = t1;
103
+ const t2 = multiRows && "k-table-cell-ellipsis-rows";
104
+ let t3;
105
+ if ($[3] !== className || $[4] !== t2) {
106
+ t3 = clsx("k-table-cell-ellipsis", t2, className);
107
+ $[3] = className;
108
+ $[4] = t2;
109
+ $[5] = t3;
110
+ } else t3 = $[5];
111
+ let t4;
112
+ if ($[6] !== multiRows || $[7] !== rows) {
113
+ t4 = multiRows ? { WebkitLineClamp: rows } : void 0;
114
+ $[6] = multiRows;
115
+ $[7] = rows;
116
+ $[8] = t4;
117
+ } else t4 = $[8];
118
+ let t5;
119
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
120
+ t5 = () => setTip(null);
121
+ $[9] = t5;
122
+ } else t5 = $[9];
123
+ let t6;
124
+ if ($[10] !== children || $[11] !== enter || $[12] !== t3 || $[13] !== t4) {
125
+ t6 = /* @__PURE__ */ jsx("span", {
126
+ ref: innerRef,
127
+ className: t3,
128
+ style: t4,
129
+ onMouseEnter: enter,
130
+ onMouseLeave: t5,
131
+ children
132
+ });
133
+ $[10] = children;
134
+ $[11] = enter;
135
+ $[12] = t3;
136
+ $[13] = t4;
137
+ $[14] = t6;
138
+ } else t6 = $[14];
139
+ const node = t6;
140
+ if (tooltip === false) return node;
141
+ const t7 = Boolean(tip);
142
+ let t8;
143
+ if ($[15] !== node || $[16] !== t7 || $[17] !== tip) {
144
+ t8 = /* @__PURE__ */ jsx(Tooltip, {
145
+ trigger: "manual",
146
+ open: t7,
147
+ title: tip,
148
+ children: node
149
+ });
150
+ $[15] = node;
151
+ $[16] = t7;
152
+ $[17] = tip;
153
+ $[18] = t8;
154
+ } else t8 = $[18];
155
+ return t8;
156
+ };
157
+ /**
158
+ * 行展开状态。`expandedKeys` 提供时完全受控;否则 `expandAllRows` 决定初始是否全部展开,
159
+ * 并且此后 `data` 变化只补“新出现的父行”(见 `mergeExpandAllRows`),
160
+ * 用户手动展开或折叠过的行不会被异步到达的数据覆盖。
161
+ * “新出现”以本次数据里的父行为准,所以从数据里消失又回来的父行算新行、会重新展开,
162
+ * 组件不记住它曾被折叠(kui-vue 同口径)。
163
+ */
164
+ function useRowExpansion(t0) {
165
+ const $ = c(21);
166
+ const { parentKeys, expandedKeys, expandAllRows } = t0;
167
+ let t1;
168
+ if ($[0] !== expandAllRows || $[1] !== expandedKeys) {
169
+ t1 = {
170
+ expandedKeys,
171
+ expandAllRows
172
+ };
173
+ $[0] = expandAllRows;
174
+ $[1] = expandedKeys;
175
+ $[2] = t1;
176
+ } else t1 = $[2];
177
+ const controlSource = t1;
178
+ let t2;
179
+ if ($[3] !== controlSource || $[4] !== expandAllRows || $[5] !== expandedKeys || $[6] !== parentKeys) {
180
+ t2 = () => ({
181
+ controlSource,
182
+ parentKeys,
183
+ keys: new Set(expandedKeys ?? (expandAllRows ? parentKeys : []))
184
+ });
185
+ $[3] = controlSource;
186
+ $[4] = expandAllRows;
187
+ $[5] = expandedKeys;
188
+ $[6] = parentKeys;
189
+ $[7] = t2;
190
+ } else t2 = $[7];
191
+ const [state, setState] = useState(t2);
192
+ let keys = state.keys;
193
+ if (!Object.is(state.controlSource, controlSource)) {
194
+ let t3;
195
+ if ($[8] !== expandAllRows || $[9] !== expandedKeys || $[10] !== parentKeys) {
196
+ t3 = expandedKeys ?? (expandAllRows ? parentKeys : []);
197
+ $[8] = expandAllRows;
198
+ $[9] = expandedKeys;
199
+ $[10] = parentKeys;
200
+ $[11] = t3;
201
+ } else t3 = $[11];
202
+ let t4;
203
+ if ($[12] !== t3) {
204
+ t4 = new Set(t3);
205
+ $[12] = t3;
206
+ $[13] = t4;
207
+ } else t4 = $[13];
208
+ keys = t4;
209
+ setState({
210
+ controlSource,
211
+ parentKeys,
212
+ keys
213
+ });
214
+ } else if (expandedKeys === void 0 && expandAllRows) {
215
+ let t3;
216
+ if ($[14] !== parentKeys || $[15] !== state.keys || $[16] !== state.parentKeys) {
217
+ t3 = mergeExpandAllRows(state.parentKeys, parentKeys, state.keys);
218
+ $[14] = parentKeys;
219
+ $[15] = state.keys;
220
+ $[16] = state.parentKeys;
221
+ $[17] = t3;
222
+ } else t3 = $[17];
223
+ const merged = t3;
224
+ if (state.parentKeys !== parentKeys || merged.changed) {
225
+ keys = merged.changed ? merged.keys : state.keys;
226
+ setState({
227
+ controlSource,
228
+ parentKeys,
229
+ keys
230
+ });
231
+ }
232
+ }
233
+ let t3;
234
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
235
+ t3 = (next) => setState((previous) => ({
236
+ ...previous,
237
+ keys: next
238
+ }));
239
+ $[18] = t3;
240
+ } else t3 = $[18];
241
+ let t4;
242
+ if ($[19] !== keys) {
243
+ t4 = [keys, t3];
244
+ $[19] = keys;
245
+ $[20] = t4;
246
+ } else t4 = $[20];
247
+ return t4;
248
+ }
249
+ function Table({ data = EMPTY_DATA, columns = EMPTY_COLUMNS, ellipsis: tableEllipsis, selectedKeys, disabledKeys = EMPTY_KEYS, rowKey = "key", childrenColumnName = "children", expandedKeys, expandAllRows = false, expandRowByClick = false, indentSize = 20, scroll = EMPTY_SCROLL, size: sizeProp, striped, bordered = false, shape: shapeProp, checkable, loading, emptyText, header, footer, virtual = false, itemHeight = 44, overscan = 5, hiddenColumnKeys = EMPTY_KEYS, onSort, onRowClick, onSelect, onSelectAll, onSelectedKeysChange, onExpand, onExpandedKeysChange, className, ...rest }) {
25
250
  const inheritedAppearance = useConfigAppearance();
251
+ const tableLocale = (useContext(ConfigContext)?.locale || DEFAULT_LOCALE)?.k?.table;
26
252
  const size = sizeProp ?? inheritedAppearance.size;
27
253
  const shape = normalizeSurfaceShape(shapeProp ?? inheritedAppearance.shape ?? "round");
28
- const headerRef = useRef(null);
254
+ const rootRef = useRef(null);
29
255
  const bodyRef = useRef(null);
256
+ const headerWrapperRef = useRef(null);
257
+ /** 分栏表头里真正承担裁剪与横向同步的是内层(见 `styles/index.less` 的 `.k-table-thead-inner`)。 */
258
+ const headerScrollRef = useRef(null);
30
259
  const scrollFrameRef = useRef(0);
31
260
  const [innerSelected, setInnerSelected] = useValue(selectedKeys, (next) => new Set(next ?? []));
32
- const expansionSource = useMemo(() => ({
33
- expandedKeys,
34
- expandAllRows
35
- }), [expandedKeys, expandAllRows]);
36
- const [innerExpanded, setInnerExpanded] = useValue(expansionSource, (source) => new Set(source.expandedKeys ?? (source.expandAllRows ? flattenTreeData({
37
- data,
38
- childrenColumnName,
39
- getKey: (record) => {
40
- if (typeof rowKey === "function") return rowKey(record);
41
- const key = getRecordValue(record, rowKey);
42
- return typeof key === "string" || typeof key === "number" ? key : "";
43
- }
44
- }).filter((row) => row.hasChildren).map((row_0) => typeof rowKey === "function" ? rowKey(row_0.record) : getRecordValue(row_0.record, rowKey) ?? "") : [])));
45
261
  const [sort, setSort] = useState({
46
262
  key: "",
47
263
  order: null
@@ -50,11 +266,9 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
50
266
  left: false,
51
267
  right: false
52
268
  });
53
- const [scrollbarWidth, setScrollbarWidth] = useState(0);
54
269
  const [scrollTop, setScrollTop] = useState(0);
55
270
  const [viewportHeight, setViewportHeight] = useState(0);
56
271
  const selected = innerSelected;
57
- const currentExpanded = innerExpanded;
58
272
  const visibleColumns = useMemo(() => {
59
273
  const filter = (items) => items.flatMap((column) => {
60
274
  if (hiddenColumnKeys.includes(column.key)) return [];
@@ -67,65 +281,127 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
67
281
  });
68
282
  return filter(columns);
69
283
  }, [columns, hiddenColumnKeys]);
70
- const leaves = useMemo(() => flattenColumns(visibleColumns), [visibleColumns]);
71
- const split = scroll.y != null;
72
- const virtualEnabled = virtual && split;
73
- const keyOf = (record_0) => {
74
- if (typeof rowKey === "function") return rowKey(record_0);
75
- const key_0 = getRecordValue(record_0, rowKey);
76
- return typeof key_0 === "string" || typeof key_0 === "number" ? key_0 : "";
77
- };
78
- const isDisabled = (key_1) => disabledKeys.includes(key_1);
284
+ const inheritedColumns = useMemo(() => inheritColumnFixed(visibleColumns), [visibleColumns]);
285
+ const leaves = useMemo(() => flattenColumns(inheritedColumns), [inheritedColumns]);
286
+ /**
287
+ * 表格内容的最小宽度:每列的宽度基准之和(没写 `width` 的普通列按 150 计),再加勾选列的 50。
288
+ * `<col>` 上它们仍是 `auto`,宽容器里照旧平摊多余空间;这一份只是下限,容器比它还窄就出横向
289
+ * 滚动条。`scroll.x` 显式给了则照旧以 `scroll.x` 为准。
290
+ */
291
+ const contentMinWidth = useMemo(() => leaves.reduce((sum, column_0) => sum + widthBasisOf(column_0), 0) + (checkable ? SELECTION_COLUMN_WIDTH : 0), [leaves, checkable]);
292
+ const cellEllipsis = useMemo(() => {
293
+ const map = /* @__PURE__ */ new Map();
294
+ leaves.forEach((column_1) => map.set(column_1.key, resolveCellEllipsis(column_1.ellipsis, tableEllipsis)));
295
+ return map;
296
+ }, [leaves, tableEllipsis]);
297
+ const splitHeader = scroll.y != null;
298
+ const virtualEnabled = virtual && splitHeader;
299
+ const rawId = useId();
300
+ const headCellIds = useMemo(() => {
301
+ const ids = /* @__PURE__ */ new Map();
302
+ if (!splitHeader) return ids;
303
+ const prefix = `k-table-${rawId.replace(/[^a-zA-Z0-9_-]/g, "")}-`;
304
+ const visit = (items_0) => items_0.forEach((item) => {
305
+ ids.set(item.key, `${prefix}${ids.size}`);
306
+ if (item.children?.length) visit(item.children);
307
+ });
308
+ visit(inheritedColumns);
309
+ return ids;
310
+ }, [
311
+ splitHeader,
312
+ rawId,
313
+ inheritedColumns
314
+ ]);
315
+ const keyOf = useCallback((record) => resolveRowKey(record, rowKey), [rowKey]);
316
+ const isDisabled = (key) => disabledKeys.includes(key);
317
+ const allRows = useMemo(() => flattenTreeData({
318
+ data,
319
+ childrenColumnName,
320
+ getKey: keyOf
321
+ }), [
322
+ data,
323
+ childrenColumnName,
324
+ keyOf
325
+ ]);
326
+ const [currentExpanded, setInnerExpanded] = useRowExpansion({
327
+ parentKeys: useMemo(() => new Set(allRows.filter((row) => row.hasChildren).map((row_0) => resolveRowKey(row_0.record, rowKey))), [allRows, rowKey]),
328
+ expandedKeys,
329
+ expandAllRows
330
+ });
79
331
  const headerInfo = useMemo(() => {
80
332
  let maxDepth = 1;
81
- const depth = (items_0, level = 1) => items_0.forEach((item) => item.children?.length ? depth(item.children, level + 1) : maxDepth = Math.max(maxDepth, level));
82
- depth(visibleColumns);
333
+ const depth = (items_1, level = 1) => items_1.forEach((item_0) => item_0.children?.length ? depth(item_0.children, level + 1) : maxDepth = Math.max(maxDepth, level));
334
+ depth(inheritedColumns);
335
+ const fixedDirectionOf = (leafStart, leafCount) => {
336
+ const direction = leaves[leafStart]?.fixed;
337
+ if (!direction) return void 0;
338
+ for (let index = leafStart + 1; index < leafStart + leafCount; index += 1) if (leaves[index]?.fixed !== direction) return void 0;
339
+ return direction;
340
+ };
83
341
  const headerRows = [];
84
- const visit = (items_1, level_0) => {
342
+ const visit_0 = (items_2, level_0, startAt) => {
85
343
  headerRows[level_0] ??= [];
86
- items_1.forEach((item_0) => {
344
+ let cursor = startAt;
345
+ items_2.forEach((item_1) => {
346
+ const leafStart_0 = cursor;
347
+ const headerColSpan = countColumnLeaves(item_1);
87
348
  headerRows[level_0].push({
88
- ...item_0,
89
- headerColSpan: countColumnLeaves(item_0),
90
- headerRowSpan: item_0.children?.length ? 1 : maxDepth - level_0
349
+ ...item_1,
350
+ headerColSpan,
351
+ headerRowSpan: item_1.children?.length ? 1 : maxDepth - level_0,
352
+ leafStart: leafStart_0,
353
+ headerFixed: fixedDirectionOf(leafStart_0, headerColSpan)
91
354
  });
92
- if (item_0.children?.length) visit(item_0.children, level_0 + 1);
355
+ cursor += headerColSpan;
356
+ if (item_1.children?.length) visit_0(item_1.children, level_0 + 1, leafStart_0);
93
357
  });
94
358
  };
95
- visit(visibleColumns, 0);
359
+ visit_0(inheritedColumns, 0, 0);
96
360
  return {
97
361
  rows: headerRows,
98
362
  maxDepth
99
363
  };
100
- }, [visibleColumns]);
364
+ }, [inheritedColumns, leaves]);
101
365
  const fixed = useMemo(() => {
102
366
  const header_0 = {};
103
367
  const body = {};
104
- let left = checkable ? 50 : 0;
105
- leaves.forEach((column_0) => {
106
- if (column_0.fixed === "left") {
107
- const style = {
368
+ const leftBefore = [];
369
+ const rightAfter = [];
370
+ let left = checkable ? SELECTION_COLUMN_WIDTH : 0;
371
+ leaves.forEach((column_2, index_0) => {
372
+ leftBefore[index_0] = left;
373
+ if (column_2.fixed === "left") {
374
+ body[column_2.key] = {
108
375
  position: "sticky",
109
376
  left
110
377
  };
111
- header_0[column_0.key] = style;
112
- body[column_0.key] = style;
113
- left += column_0.width ?? 150;
378
+ left += widthBasisOf(column_2);
114
379
  }
115
380
  });
116
381
  let right = 0;
117
- [...leaves].reverse().forEach((column_1) => {
118
- if (column_1.fixed === "right") {
119
- body[column_1.key] = {
382
+ for (let index_1 = leaves.length - 1; index_1 >= 0; index_1 -= 1) {
383
+ rightAfter[index_1] = right;
384
+ const column_3 = leaves[index_1];
385
+ if (column_3.fixed === "right") {
386
+ body[column_3.key] = {
120
387
  position: "sticky",
121
388
  right
122
389
  };
123
- header_0[column_1.key] = {
390
+ right += widthBasisOf(column_3);
391
+ }
392
+ }
393
+ headerInfo.rows.forEach((row_1) => {
394
+ row_1.forEach((cell) => {
395
+ const lastLeaf = cell.leafStart + cell.headerColSpan - 1;
396
+ if (cell.headerFixed === "left") header_0[cell.key] = {
397
+ position: "sticky",
398
+ left: leftBefore[cell.leafStart] ?? 0
399
+ };
400
+ else if (cell.headerFixed === "right") header_0[cell.key] = {
124
401
  position: "sticky",
125
- right: split ? right + scrollbarWidth : right
402
+ right: rightAfter[lastLeaf] ?? 0
126
403
  };
127
- right += column_1.width ?? 150;
128
- }
404
+ });
129
405
  });
130
406
  return {
131
407
  header: header_0,
@@ -134,39 +410,52 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
134
410
  }, [
135
411
  checkable,
136
412
  leaves,
137
- scrollbarWidth,
138
- split
413
+ headerInfo
139
414
  ]);
140
- const fixedClass = (column_2, index) => clsx({
141
- "k-table-cell-fix-left": column_2.fixed === "left",
142
- "k-table-cell-fix-left-last": column_2.fixed === "left" && leaves[index + 1]?.fixed !== "left",
143
- "k-table-cell-fix-right": column_2.fixed === "right",
144
- "k-table-cell-fix-right-first": column_2.fixed === "right" && leaves[index - 1]?.fixed !== "right",
145
- "k-table-cell-sorter": column_2.sorter
415
+ const fixedClass = (column_4, index_2, colSpan = 1) => clsx({
416
+ "k-table-cell-fix-left": column_4.fixed === "left",
417
+ "k-table-cell-fix-left-last": column_4.fixed === "left" && leaves[index_2 + 1]?.fixed !== "left",
418
+ "k-table-cell-fix-right": column_4.fixed === "right",
419
+ "k-table-cell-fix-right-first": column_4.fixed === "right" && leaves[index_2 - 1]?.fixed !== "right",
420
+ "k-table-cell-sorter": column_4.sorter,
421
+ "k-table-cell-last-column": index_2 + colSpan === leaves.length
422
+ });
423
+ /**
424
+ * 表头格的固定类按它覆盖的叶子区间判断。`*-last`/`*-first` 决定横向滚动时 ping 阴影画在哪一格的
425
+ * 边沿上,分组表头若改用叶子下标去查会拿到 `-1`,把不该画阴影的父格标成最后一列固定格。
426
+ *
427
+ * `k-table-cell-last-column` 同理必须按区间末尾算:bordered 时只有真的盖到最后一列的格子才让出
428
+ * 右边框。表头每一行的格数不一样(分组格占 `colSpan`),行末那一格往往并不是最后一列。
429
+ */
430
+ const headerFixedClass = (cell_0) => clsx({
431
+ "k-table-cell-fix-left": cell_0.headerFixed === "left",
432
+ "k-table-cell-fix-left-last": cell_0.headerFixed === "left" && leaves[cell_0.leafStart + cell_0.headerColSpan]?.fixed !== "left",
433
+ "k-table-cell-fix-right": cell_0.headerFixed === "right",
434
+ "k-table-cell-fix-right-first": cell_0.headerFixed === "right" && leaves[cell_0.leafStart - 1]?.fixed !== "right",
435
+ "k-table-cell-sorter": cell_0.sorter,
436
+ "k-table-cell-last-column": cell_0.leafStart + cell_0.headerColSpan === leaves.length
146
437
  });
147
- const leafIndexOf = (column_3) => leaves.findIndex((item_1) => item_1.key === column_3.key);
148
- const sortRecords = (records) => {
438
+ const sortRecords = useCallback((records) => {
149
439
  const result = [...records];
150
- if (sort.key && sort.order && leaves.find((column_4) => column_4.key === sort.key)?.sorter === true) result.sort((a, b) => {
151
- const first = getRecordValue(a, sort.key), second = getRecordValue(b, sort.key);
152
- if (first === second) return 0;
153
- const comparison = typeof first === "number" && typeof second === "number" || typeof first === "string" && typeof second === "string" ? first > second ? 1 : -1 : 0;
440
+ if (sort.key && sort.order && leaves.find((column_5) => column_5.key === sort.key)?.sorter === true) result.sort((a, b) => {
441
+ const comparison = compareSortValues(getRecordValue(a, sort.key), getRecordValue(b, sort.key));
154
442
  return sort.order === "asc" ? comparison : -comparison;
155
443
  });
156
444
  return result;
157
- };
158
- const allRows = flattenTreeData({
159
- data,
160
- childrenColumnName,
161
- getKey: keyOf
162
- });
163
- const rows = flattenTreeData({
445
+ }, [leaves, sort]);
446
+ const rows = useMemo(() => flattenTreeData({
164
447
  data,
165
448
  childrenColumnName,
166
449
  expandedKeys: currentExpanded,
167
450
  getKey: keyOf,
168
451
  sortRecords
169
- });
452
+ }), [
453
+ data,
454
+ childrenColumnName,
455
+ currentExpanded,
456
+ keyOf,
457
+ sortRecords
458
+ ]);
170
459
  const virtualRange = useMemo(() => {
171
460
  if (!virtualEnabled) return {
172
461
  start: 0,
@@ -189,38 +478,46 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
189
478
  itemHeight,
190
479
  overscan
191
480
  ]);
192
- const treeEnabled = allRows.some((row_1) => row_1.hasChildren);
481
+ const treeEnabled = useMemo(() => allRows.some((row_2) => row_2.hasChildren), [allRows]);
193
482
  const matrix = useMemo(() => {
194
- if (!leaves.some((column_5) => column_5.rowSpan !== void 0 || column_5.colSpan !== void 0)) return [];
483
+ if (!leaves.some((column_6) => column_6.rowSpan !== void 0 || column_6.colSpan !== void 0)) return [];
195
484
  const result_0 = rows.map(() => leaves.map(() => ({
196
485
  rowSpan: 1,
197
486
  colSpan: 1,
198
487
  show: true
199
488
  })));
200
- rows.forEach(({ record: record_1 }, row_2) => leaves.forEach((column_6, col) => {
201
- if (!result_0[row_2][col].show) return;
202
- const rowSpan = typeof column_6.rowSpan === "function" ? column_6.rowSpan(record_1, row_2) : column_6.rowSpan ?? 1;
203
- const colSpan = typeof column_6.colSpan === "function" ? column_6.colSpan(record_1, row_2) : column_6.colSpan ?? 1;
489
+ rows.forEach(({ record: record_0 }, row_3) => leaves.forEach((column_7, col) => {
490
+ if (!result_0[row_3][col].show) return;
491
+ const rowSpan = typeof column_7.rowSpan === "function" ? column_7.rowSpan(record_0, row_3) : column_7.rowSpan ?? 1;
492
+ const colSpan_0 = typeof column_7.colSpan === "function" ? column_7.colSpan(record_0, row_3) : column_7.colSpan ?? 1;
204
493
  const normalizedRowSpan = Number.isFinite(rowSpan) ? Math.max(0, Math.floor(rowSpan)) : 1;
205
- const normalizedColSpan = Number.isFinite(colSpan) ? Math.max(0, Math.floor(colSpan)) : 1;
494
+ const normalizedColSpan = Number.isFinite(colSpan_0) ? Math.max(0, Math.floor(colSpan_0)) : 1;
206
495
  if (normalizedRowSpan === 0 || normalizedColSpan === 0) {
207
- result_0[row_2][col].show = false;
496
+ result_0[row_3][col].show = false;
208
497
  return;
209
498
  }
210
- result_0[row_2][col] = {
499
+ result_0[row_3][col] = {
211
500
  rowSpan: normalizedRowSpan,
212
501
  colSpan: normalizedColSpan,
213
502
  show: true
214
503
  };
215
504
  for (let r = 0; r < normalizedRowSpan; r++) for (let c = 0; c < normalizedColSpan; c++) if (r || c) {
216
- const cell = result_0[row_2 + r]?.[col + c];
217
- if (cell) cell.show = false;
505
+ const cell_1 = result_0[row_3 + r]?.[col + c];
506
+ if (cell_1) cell_1.show = false;
218
507
  }
219
508
  }));
220
509
  return result_0;
221
510
  }, [leaves, rows]);
222
- const enabled = allRows.map((row_3) => row_3.record).filter((record_2) => !isDisabled(keyOf(record_2)));
223
- const checkedCount = enabled.filter((record_3) => selected.has(keyOf(record_3))).length;
511
+ const enabled = useMemo(() => allRows.map((row_4) => row_4.record).filter((record_1) => !disabledKeys.includes(keyOf(record_1))), [
512
+ allRows,
513
+ disabledKeys,
514
+ keyOf
515
+ ]);
516
+ const checkedCount = useMemo(() => enabled.filter((record_2) => selected.has(keyOf(record_2))).length, [
517
+ enabled,
518
+ selected,
519
+ keyOf
520
+ ]);
224
521
  const allChecked = enabled.length > 0 && checkedCount === enabled.length;
225
522
  const indeterminate = checkedCount > 0 && checkedCount < enabled.length;
226
523
  const commitSelection = (next_0) => {
@@ -231,52 +528,51 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
231
528
  };
232
529
  const toggleAll = ({ checked }) => {
233
530
  const next_1 = new Set(selected);
234
- allRows.forEach(({ record: record_4 }) => {
235
- const key_2 = keyOf(record_4);
236
- if (!isDisabled(key_2)) {
237
- if (checked) next_1.add(key_2);
238
- else next_1.delete(key_2);
531
+ allRows.forEach(({ record: record_3 }) => {
532
+ const key_0 = keyOf(record_3);
533
+ if (!isDisabled(key_0)) {
534
+ if (checked) next_1.add(key_0);
535
+ else next_1.delete(key_0);
239
536
  }
240
537
  });
241
538
  const keys_0 = commitSelection(next_1);
242
539
  onSelectAll?.(checked, keys_0);
243
540
  };
244
- const toggleOne = (event, record_5) => {
245
- const key_3 = keyOf(record_5);
246
- if (isDisabled(key_3)) return;
541
+ const toggleOne = (event, record_4) => {
542
+ const key_1 = keyOf(record_4);
543
+ if (isDisabled(key_1)) return;
247
544
  const next_2 = new Set(selected);
248
- if (event.checked) next_2.add(key_3);
249
- else next_2.delete(key_3);
545
+ if (event.checked) next_2.add(key_1);
546
+ else next_2.delete(key_1);
250
547
  const keys_1 = commitSelection(next_2);
251
- onSelect?.(record_5, event.checked, keys_1);
548
+ onSelect?.(record_4, event.checked, keys_1);
252
549
  };
253
- const toggleExpand = (record_6) => {
254
- const key_4 = keyOf(record_6);
550
+ const toggleExpand = (record_5) => {
551
+ const key_2 = keyOf(record_5);
255
552
  const next_3 = new Set(currentExpanded);
256
- const nextExpanded = !next_3.has(key_4);
257
- if (nextExpanded) next_3.add(key_4);
258
- else next_3.delete(key_4);
553
+ const nextExpanded = !next_3.has(key_2);
554
+ if (nextExpanded) next_3.add(key_2);
555
+ else next_3.delete(key_2);
259
556
  setInnerExpanded(next_3);
260
557
  onExpandedKeysChange?.([...next_3]);
261
- onExpand?.(nextExpanded, record_6);
558
+ onExpand?.(nextExpanded, record_5);
262
559
  };
263
- const changeSort = (column_7) => {
264
- if (!column_7.sorter) return;
560
+ const changeSort = (column_8) => {
561
+ if (!column_8.sorter) return;
265
562
  const next_4 = {
266
- key: column_7.key,
267
- order: sort.key !== column_7.key ? "asc" : sort.order === "asc" ? "desc" : sort.order === "desc" ? null : "asc"
563
+ key: column_8.key,
564
+ order: sort.key !== column_8.key ? "asc" : sort.order === "asc" ? "desc" : sort.order === "desc" ? null : "asc"
268
565
  };
269
566
  setSort(next_4);
270
- if (typeof column_7.sorter === "function") column_7.sorter(next_4);
567
+ if (typeof column_8.sorter === "function") column_8.sorter(next_4);
271
568
  onSort?.(next_4);
272
569
  };
273
570
  const handleScroll = (event_0) => {
274
- const target = event_0.currentTarget;
571
+ const body_0 = bodyRef.current ?? event_0.currentTarget;
572
+ if (splitHeader && headerScrollRef.current) headerScrollRef.current.scrollLeft = body_0.scrollLeft;
275
573
  if (scrollFrameRef.current) return;
276
574
  scrollFrameRef.current = requestAnimationFrame(() => {
277
575
  scrollFrameRef.current = 0;
278
- const body_0 = bodyRef.current ?? target;
279
- if (split && headerRef.current) headerRef.current.scrollLeft = body_0.scrollLeft;
280
576
  const max = Math.max(0, body_0.scrollWidth - body_0.clientWidth);
281
577
  const update = () => {
282
578
  if (virtualEnabled) setScrollTop(body_0.scrollTop);
@@ -294,7 +590,6 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
294
590
  const body_1 = bodyRef.current;
295
591
  if (!body_1) return;
296
592
  const measure = () => {
297
- setScrollbarWidth(split ? Math.max(0, body_1.offsetWidth - body_1.clientWidth - (bordered ? 1 : 0)) : 0);
298
593
  setViewportHeight(body_1.clientHeight);
299
594
  const max_0 = Math.max(0, body_1.scrollWidth - body_1.clientWidth);
300
595
  const nextPing_0 = {
@@ -313,63 +608,82 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
313
608
  };
314
609
  }
315
610
  return () => cancelAnimationFrame(scrollFrameRef.current);
316
- }, [bordered, split]);
317
- const colgroup = (headerTable = false) => /* @__PURE__ */ jsxs("colgroup", { children: [
318
- checkable && /* @__PURE__ */ jsx("col", { style: { width: 50 } }),
319
- leaves.map((column_8) => /* @__PURE__ */ jsx("col", { style: {
320
- width: column_8.width ?? 150,
321
- minWidth: column_8.width ?? 150
322
- } }, column_8.key)),
323
- headerTable && split && /* @__PURE__ */ jsx("col", { style: { width: scrollbarWidth } })
324
- ] });
325
- const thead = /* @__PURE__ */ jsx("thead", { children: headerInfo.rows.map((row_4, rowIndex) => /* @__PURE__ */ jsxs("tr", { children: [
326
- checkable && rowIndex === 0 && /* @__PURE__ */ jsx("th", {
327
- rowSpan: headerInfo.maxDepth,
328
- className: clsx("k-table-cell-fix-left", { "k-table-cell-fix-left-last": ping.left }),
329
- style: {
330
- left: 0,
331
- zIndex: 3
332
- },
333
- children: /* @__PURE__ */ jsx(checkbox_default, {
334
- checked: allChecked,
335
- indeterminate,
336
- onChange: toggleAll,
337
- disabled: !enabled.length
338
- })
611
+ }, []);
612
+ useLayoutEffect(() => {
613
+ const root = rootRef.current;
614
+ if (!root) return;
615
+ root.style.setProperty("--k-table-scrollbar-width", splitHeader ? `${measureScrollbarWidth()}px` : "");
616
+ }, [splitHeader]);
617
+ useEffect(() => {
618
+ const wrapper = headerWrapperRef.current;
619
+ const body_2 = bodyRef.current;
620
+ if (!splitHeader || !wrapper || !body_2) return;
621
+ const onWheel = (event_1) => {
622
+ const unit = event_1.deltaMode === 1 ? 16 : event_1.deltaMode === 2 ? body_2.clientHeight : 1;
623
+ const maxTop = Math.max(0, body_2.scrollHeight - body_2.clientHeight);
624
+ const maxLeft = Math.max(0, body_2.scrollWidth - body_2.clientWidth);
625
+ const nextTop = Math.min(maxTop, Math.max(0, body_2.scrollTop + event_1.deltaY * unit));
626
+ const nextLeft = Math.min(maxLeft, Math.max(0, body_2.scrollLeft + event_1.deltaX * unit));
627
+ if (nextTop === body_2.scrollTop && nextLeft === body_2.scrollLeft) return;
628
+ event_1.preventDefault();
629
+ body_2.scrollTo({
630
+ top: nextTop,
631
+ left: nextLeft
632
+ });
633
+ };
634
+ wrapper.addEventListener("wheel", onWheel, { passive: false });
635
+ return () => wrapper.removeEventListener("wheel", onWheel);
636
+ }, [splitHeader]);
637
+ const colgroup = /* @__PURE__ */ jsxs("colgroup", { children: [checkable && /* @__PURE__ */ jsx("col", { style: { width: SELECTION_COLUMN_WIDTH } }), leaves.map((column_9) => /* @__PURE__ */ jsx("col", { style: { width: colgroupWidthOf(column_9) } }, column_9.key))] });
638
+ const thead = /* @__PURE__ */ jsx("thead", { children: headerInfo.rows.map((row_5, rowIndex) => /* @__PURE__ */ jsxs("tr", { children: [checkable && rowIndex === 0 && /* @__PURE__ */ jsx("th", {
639
+ rowSpan: headerInfo.maxDepth,
640
+ className: clsx("k-table-cell-fix-left", {
641
+ "k-table-cell-fix-left-last": ping.left,
642
+ "k-table-cell-last-column": !leaves.length
339
643
  }),
340
- row_4.map((column_9, index_0) => /* @__PURE__ */ jsx("th", {
341
- colSpan: column_9.headerColSpan,
342
- rowSpan: column_9.headerRowSpan,
343
- className: fixedClass(column_9, leafIndexOf(column_9)),
344
- style: fixed.header[column_9.key],
345
- onClick: () => changeSort(column_9),
346
- children: /* @__PURE__ */ jsxs("div", {
347
- className: "k-table-header-col",
348
- children: [column_9.renderHeader?.(column_9, index_0) ?? column_9.title, column_9.sorter && /* @__PURE__ */ jsxs("span", {
349
- className: "k-table-sorter",
350
- children: [/* @__PURE__ */ jsx(Icon, {
351
- type: Triangle,
352
- reverseFill: true,
353
- className: clsx("k-table-sorter-up", { "k-table-sorter-active": sort.key === column_9.key && sort.order === "asc" })
354
- }), /* @__PURE__ */ jsx(Icon, {
355
- type: Triangle,
356
- reverseFill: true,
357
- className: clsx("k-table-sorter-down", { "k-table-sorter-active": sort.key === column_9.key && sort.order === "desc" })
358
- })]
644
+ style: { left: 0 },
645
+ children: /* @__PURE__ */ jsx(checkbox_default, {
646
+ checked: allChecked,
647
+ indeterminate,
648
+ onChange: toggleAll,
649
+ disabled: !enabled.length,
650
+ "aria-label": tableLocale?.selectAllRows || "Select all"
651
+ })
652
+ }), row_5.map((column_10, index_3) => /* @__PURE__ */ jsx("th", {
653
+ id: splitHeader ? headCellIds.get(column_10.key) : void 0,
654
+ colSpan: column_10.headerColSpan,
655
+ rowSpan: column_10.headerRowSpan,
656
+ className: headerFixedClass(column_10),
657
+ style: fixed.header[column_10.key],
658
+ tabIndex: column_10.sorter ? 0 : void 0,
659
+ "aria-sort": !column_10.sorter ? void 0 : sort.key !== column_10.key || !sort.order ? "none" : sort.order === "asc" ? "ascending" : "descending",
660
+ onClick: () => changeSort(column_10),
661
+ onKeyDown: (event_2) => {
662
+ if (!column_10.sorter || event_2.key !== "Enter" && event_2.key !== " ") return;
663
+ event_2.preventDefault();
664
+ changeSort(column_10);
665
+ },
666
+ children: /* @__PURE__ */ jsxs("div", {
667
+ className: "k-table-header-col",
668
+ children: [column_10.renderHeader?.(column_10, index_3) ?? column_10.title, column_10.sorter && /* @__PURE__ */ jsxs("span", {
669
+ className: "k-table-sorter",
670
+ children: [/* @__PURE__ */ jsx(Icon, {
671
+ type: Triangle,
672
+ reverseFill: true,
673
+ className: clsx("k-table-sorter-up", { "k-table-sorter-active": sort.key === column_10.key && sort.order === "asc" })
674
+ }), /* @__PURE__ */ jsx(Icon, {
675
+ type: Triangle,
676
+ reverseFill: true,
677
+ className: clsx("k-table-sorter-down", { "k-table-sorter-active": sort.key === column_10.key && sort.order === "desc" })
359
678
  })]
360
- })
361
- }, column_9.key)),
362
- split && rowIndex === 0 && /* @__PURE__ */ jsx("th", {
363
- rowSpan: headerInfo.maxDepth,
364
- className: "k-table-scrollbar-patch",
365
- style: { width: scrollbarWidth }
679
+ })]
366
680
  })
367
- ] }, rowIndex)) });
681
+ }, column_10.key))] }, rowIndex)) });
368
682
  const renderedRows = useMemo(() => {
369
683
  const start = virtualRange.start;
370
684
  const end = virtualRange.end;
371
- return rows.slice(start, end).map((row_5, idx) => ({
372
- ...row_5,
685
+ return rows.slice(start, end).map((row_6, idx) => ({
686
+ ...row_6,
373
687
  rowIndex: start + idx
374
688
  }));
375
689
  }, [rows, virtualRange]);
@@ -378,65 +692,82 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
378
692
  className: "k-table-virtual-spacer k-table-virtual-spacer-top",
379
693
  "aria-hidden": "true",
380
694
  children: /* @__PURE__ */ jsx("td", {
695
+ className: "k-table-cell-last-column",
381
696
  colSpan: leaves.length + (checkable ? 1 : 0),
382
697
  style: { height: virtualRange.offset }
383
698
  })
384
699
  }),
385
- renderedRows.map(({ record: record_7, depth: depth_0, hasChildren, rowIndex: rowIndex_0 }) => /* @__PURE__ */ jsxs("tr", {
700
+ renderedRows.map(({ record: record_6, depth: depth_0, hasChildren, rowIndex: rowIndex_0 }) => /* @__PURE__ */ jsxs("tr", {
386
701
  className: virtualEnabled && rowIndex_0 % 2 === 1 ? "k-table-row-even" : void 0,
387
702
  style: virtualEnabled ? { height: itemHeight } : void 0,
388
- onClick: (event_1) => {
389
- if (event_1.target.closest(".k-checkbox, .k-table-tree-toggle")) return;
390
- if (expandRowByClick && hasChildren) toggleExpand(record_7);
391
- onRowClick?.(record_7, rowIndex_0);
703
+ onClick: (event_3) => {
704
+ if (event_3.target.closest(".k-checkbox, .k-table-tree-toggle")) return;
705
+ if (expandRowByClick && hasChildren) toggleExpand(record_6);
706
+ onRowClick?.(record_6, rowIndex_0);
392
707
  },
393
708
  children: [checkable && /* @__PURE__ */ jsx("td", {
394
- className: clsx("k-table-cell-fix-left", { "k-table-cell-fix-left-last": ping.left }),
709
+ className: clsx("k-table-cell-fix-left", {
710
+ "k-table-cell-fix-left-last": ping.left,
711
+ "k-table-cell-last-column": !leaves.length
712
+ }),
395
713
  style: {
396
- width: 50,
714
+ width: SELECTION_COLUMN_WIDTH,
397
715
  left: 0
398
716
  },
399
717
  children: /* @__PURE__ */ jsx(checkbox_default, {
400
- checked: selected.has(keyOf(record_7)),
401
- disabled: isDisabled(keyOf(record_7)),
402
- onChange: (event_2) => toggleOne(event_2, record_7)
718
+ checked: selected.has(keyOf(record_6)),
719
+ disabled: isDisabled(keyOf(record_6)),
720
+ onChange: (event_4) => toggleOne(event_4, record_6),
721
+ "aria-label": tableLocale?.selectRow || "Select row"
403
722
  })
404
- }), leaves.map((column_10, colIndex) => {
405
- const cell_0 = matrix[rowIndex_0]?.[colIndex] ?? {
723
+ }), leaves.map((column_11, colIndex) => {
724
+ const cell_2 = matrix[rowIndex_0]?.[colIndex] ?? {
406
725
  rowSpan: 1,
407
726
  colSpan: 1,
408
727
  show: true
409
728
  };
410
- if (!cell_0.show) return null;
411
- const value = getRecordValue(record_7, column_10.key);
412
- const content = column_10.render?.(value, record_7, rowIndex_0, column_10) ?? value;
729
+ if (!cell_2.show) return null;
730
+ const value = getRecordValue(record_6, column_11.key);
731
+ const content = column_11.render?.(value, record_6, rowIndex_0, column_11) ?? value;
732
+ const ellipsis = cellEllipsis.get(column_11.key);
413
733
  return /* @__PURE__ */ jsx("td", {
414
- rowSpan: cell_0.rowSpan > 1 ? cell_0.rowSpan : void 0,
415
- colSpan: cell_0.colSpan > 1 ? cell_0.colSpan : void 0,
416
- className: fixedClass(column_10, colIndex),
417
- style: fixed.body[column_10.key],
734
+ "aria-labelledby": splitHeader ? headCellIds.get(column_11.key) : void 0,
735
+ rowSpan: cell_2.rowSpan > 1 ? cell_2.rowSpan : void 0,
736
+ colSpan: cell_2.colSpan > 1 ? cell_2.colSpan : void 0,
737
+ className: fixedClass(column_11, colIndex, cell_2.colSpan),
738
+ style: fixed.body[column_11.key],
418
739
  children: treeEnabled && colIndex === 0 ? /* @__PURE__ */ jsxs("div", {
419
740
  className: "k-table-tree-cell",
420
741
  style: { paddingLeft: depth_0 * indentSize },
421
742
  children: [hasChildren ? /* @__PURE__ */ jsx("button", {
422
743
  type: "button",
423
744
  className: "k-table-tree-toggle",
424
- "aria-label": currentExpanded.has(keyOf(record_7)) ? "Collapse row" : "Expand row",
425
- "aria-expanded": currentExpanded.has(keyOf(record_7)),
426
- onClick: () => toggleExpand(record_7),
427
- children: /* @__PURE__ */ jsx(Icon, { type: currentExpanded.has(keyOf(record_7)) ? ChevronDown : ChevronRight })
428
- }) : /* @__PURE__ */ jsx("span", { className: "k-table-tree-indent" }), /* @__PURE__ */ jsx("span", {
745
+ "aria-label": currentExpanded.has(keyOf(record_6)) ? tableLocale?.collapseRow || "Collapse row" : tableLocale?.expandRow || "Expand row",
746
+ "aria-expanded": currentExpanded.has(keyOf(record_6)),
747
+ onClick: () => toggleExpand(record_6),
748
+ children: /* @__PURE__ */ jsx(Icon, { type: currentExpanded.has(keyOf(record_6)) ? ChevronDown : ChevronRight })
749
+ }) : /* @__PURE__ */ jsx("span", { className: "k-table-tree-indent" }), ellipsis ? /* @__PURE__ */ jsx(EllipsisCell, {
750
+ rows: ellipsis.rows,
751
+ tooltip: ellipsis.tooltip,
752
+ className: "k-table-tree-content",
753
+ children: content
754
+ }) : /* @__PURE__ */ jsx("span", {
429
755
  className: "k-table-tree-content",
430
756
  children: content
431
757
  })]
758
+ }) : ellipsis ? /* @__PURE__ */ jsx(EllipsisCell, {
759
+ rows: ellipsis.rows,
760
+ tooltip: ellipsis.tooltip,
761
+ children: content
432
762
  }) : content
433
- }, column_10.key);
763
+ }, column_11.key);
434
764
  })]
435
- }, keyOf(record_7))),
765
+ }, keyOf(record_6))),
436
766
  virtualEnabled && virtualRange.offset + (virtualRange.end - virtualRange.start) * itemHeight < virtualRange.total && /* @__PURE__ */ jsx("tr", {
437
767
  className: "k-table-virtual-spacer k-table-virtual-spacer-bottom",
438
768
  "aria-hidden": "true",
439
769
  children: /* @__PURE__ */ jsx("td", {
770
+ className: "k-table-cell-last-column",
440
771
  colSpan: leaves.length + (checkable ? 1 : 0),
441
772
  style: { height: virtualRange.total - virtualRange.offset - (virtualRange.end - virtualRange.start) * itemHeight }
442
773
  })
@@ -444,26 +775,20 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
444
775
  ] });
445
776
  const tableStyle = {
446
777
  width: "100%",
447
- minWidth: typeof scroll.x === "number" ? scroll.x : scroll.x || "100%",
778
+ minWidth: scroll.x || (contentMinWidth ? `${contentMinWidth}px` : "100%"),
448
779
  tableLayout: "fixed"
449
780
  };
450
- const renderTable = (showHeader, showBody, headerTable_0 = false) => /* @__PURE__ */ jsxs("table", {
451
- style: tableStyle,
452
- children: [
453
- colgroup(headerTable_0),
454
- showHeader && thead,
455
- showBody && tbody
456
- ]
457
- });
458
781
  const empty = !rows.length || !visibleColumns.length;
459
782
  return /* @__PURE__ */ jsxs("div", {
460
783
  ...rest,
784
+ ref: rootRef,
461
785
  className: clsx("k-table", {
462
786
  "k-table-striped": striped,
463
787
  "k-table-sm": size === "small",
464
788
  "k-table-lg": size === "large",
465
789
  "k-table-bordered": bordered,
466
790
  "k-table-has-footer": !!footer,
791
+ "k-table-split-header": splitHeader,
467
792
  [`k-table-${shape}`]: shape,
468
793
  "k-table-ping-left": ping.left,
469
794
  "k-table-ping-right": ping.right,
@@ -474,11 +799,17 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
474
799
  className: "k-table-header",
475
800
  children: header
476
801
  }),
477
- split && /* @__PURE__ */ jsx("div", {
802
+ splitHeader && /* @__PURE__ */ jsx("div", {
478
803
  className: "k-table-thead",
479
- ref: headerRef,
480
- style: { overflow: "hidden" },
481
- children: renderTable(true, false, true)
804
+ ref: headerWrapperRef,
805
+ children: /* @__PURE__ */ jsx("div", {
806
+ className: "k-table-thead-inner",
807
+ ref: headerScrollRef,
808
+ children: /* @__PURE__ */ jsxs("table", {
809
+ style: tableStyle,
810
+ children: [colgroup, thead]
811
+ })
812
+ })
482
813
  }),
483
814
  /* @__PURE__ */ jsxs("div", {
484
815
  className: "k-table-body k-scroll",
@@ -490,12 +821,19 @@ function Table({ data = [], columns = [], selectedKeys, disabledKeys = [], rowKe
490
821
  },
491
822
  onScroll: handleScroll,
492
823
  children: [
493
- renderTable(!split, true),
824
+ /* @__PURE__ */ jsxs("table", {
825
+ style: tableStyle,
826
+ children: [
827
+ colgroup,
828
+ !splitHeader && thead,
829
+ tbody
830
+ ]
831
+ }),
494
832
  empty && loading && /* @__PURE__ */ jsx("div", {
495
833
  className: "k-table-loading-placeholder",
496
834
  "aria-hidden": "true"
497
835
  }),
498
- empty && !loading && /* @__PURE__ */ jsx(Empty, { description: emptyText })
836
+ empty && !loading && /* @__PURE__ */ jsx(Empty, { description: emptyText || tableLocale?.emptyText })
499
837
  ]
500
838
  }),
501
839
  footer && /* @__PURE__ */ jsx("div", {