@aithe/aithe-ui 26.2.3 → 26.3.2

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 (620) hide show
  1. package/README.md +19 -11
  2. package/dist/apps/admin/app.js +12 -0
  3. package/dist/apps/admin/components/admin-app.js +83 -0
  4. package/dist/apps/admin/components/admin-layout.d.ts +0 -1
  5. package/dist/apps/admin/components/admin-layout.d.ts.map +1 -1
  6. package/dist/apps/admin/components/admin-layout.js +250 -0
  7. package/dist/apps/admin/datahub/auth.js +24 -0
  8. package/dist/apps/admin/datahub/dashboard.js +16 -0
  9. package/dist/apps/admin/datahub/index.js +42 -0
  10. package/dist/apps/admin/datahub/menu.js +16 -0
  11. package/dist/apps/admin/datahub/mock/auth.js +11 -0
  12. package/dist/apps/admin/datahub/mock/dashboard.js +10 -0
  13. package/dist/apps/admin/datahub/mock/menu.js +42 -0
  14. package/dist/apps/admin/i18n/de-DE.js +37 -0
  15. package/dist/apps/admin/i18n/en-US.js +37 -0
  16. package/dist/apps/admin/i18n/es-ES.js +38 -0
  17. package/dist/apps/admin/i18n/fr-FR.js +37 -0
  18. package/dist/apps/admin/i18n/index.js +27 -0
  19. package/dist/apps/admin/i18n/ja-JP.js +38 -0
  20. package/dist/apps/admin/i18n/ko-KR.js +37 -0
  21. package/dist/apps/admin/i18n/pt-BR.js +37 -0
  22. package/dist/apps/admin/i18n/zh-CN.js +37 -0
  23. package/dist/apps/admin/i18n/zh-HK.js +37 -0
  24. package/dist/apps/admin/i18n/zh-TW.js +37 -0
  25. package/dist/apps/admin/pages/dashboard-page.d.ts +1 -0
  26. package/dist/apps/admin/pages/dashboard-page.d.ts.map +1 -1
  27. package/dist/apps/admin/pages/dashboard-page.js +199 -0
  28. package/dist/apps/admin/pages/login-page.js +278 -0
  29. package/dist/apps/admin/pages/not-found-page.js +57 -0
  30. package/dist/apps/admin/pages/role-page.js +76 -0
  31. package/dist/apps/admin/pages/settings-page.js +95 -0
  32. package/dist/apps/admin/pages/user-page.js +76 -0
  33. package/dist/apps/admin/router/index.js +43 -0
  34. package/dist/apps/admin/standalone.js +1 -0
  35. package/dist/apps/admin/store/auth.js +42 -0
  36. package/dist/apps/api/app.js +82 -0
  37. package/dist/apps/api/demo-data.d.ts.map +1 -1
  38. package/dist/apps/api/demo-data.js +965 -0
  39. package/dist/apps/api/docs-viewer.js +684 -0
  40. package/dist/apps/api/i18n/de-DE.d.ts.map +1 -1
  41. package/dist/apps/api/i18n/de-DE.js +131 -0
  42. package/dist/apps/api/i18n/en-US.d.ts.map +1 -1
  43. package/dist/apps/api/i18n/en-US.js +141 -0
  44. package/dist/apps/api/i18n/es-ES.d.ts.map +1 -1
  45. package/dist/apps/api/i18n/es-ES.js +131 -0
  46. package/dist/apps/api/i18n/fr-FR.d.ts.map +1 -1
  47. package/dist/apps/api/i18n/fr-FR.js +131 -0
  48. package/dist/apps/api/i18n/index.js +27 -0
  49. package/dist/apps/api/i18n/ja-JP.d.ts.map +1 -1
  50. package/dist/apps/api/i18n/ja-JP.js +131 -0
  51. package/dist/apps/api/i18n/ko-KR.d.ts.map +1 -1
  52. package/dist/apps/api/i18n/ko-KR.js +131 -0
  53. package/dist/apps/api/i18n/pt-BR.d.ts.map +1 -1
  54. package/dist/apps/api/i18n/pt-BR.js +131 -0
  55. package/dist/apps/api/i18n/zh-CN.d.ts.map +1 -1
  56. package/dist/apps/api/i18n/zh-CN.js +141 -0
  57. package/dist/apps/api/i18n/zh-HK.d.ts.map +1 -1
  58. package/dist/apps/api/i18n/zh-HK.js +131 -0
  59. package/dist/apps/api/i18n/zh-TW.d.ts.map +1 -1
  60. package/dist/apps/api/i18n/zh-TW.js +131 -0
  61. package/dist/apps/api/pages/docs.d.ts.map +1 -1
  62. package/dist/apps/api/pages/docs.js +369 -0
  63. package/dist/apps/api/standalone.js +1 -0
  64. package/dist/apps/demo/app.d.ts.map +1 -1
  65. package/dist/apps/demo/app.js +275 -0
  66. package/dist/apps/demo/editor.d.ts.map +1 -1
  67. package/dist/apps/demo/editor.js +270 -0
  68. package/dist/apps/demo/helpers.js +7 -0
  69. package/dist/apps/demo/i18n/de-DE.d.ts.map +1 -1
  70. package/dist/apps/demo/i18n/de-DE.js +289 -0
  71. package/dist/apps/demo/i18n/en-US.d.ts.map +1 -1
  72. package/dist/apps/demo/i18n/en-US.js +301 -0
  73. package/dist/apps/demo/i18n/es-ES.d.ts.map +1 -1
  74. package/dist/apps/demo/i18n/es-ES.js +289 -0
  75. package/dist/apps/demo/i18n/fr-FR.d.ts.map +1 -1
  76. package/dist/apps/demo/i18n/fr-FR.js +289 -0
  77. package/dist/apps/demo/i18n/index.js +27 -0
  78. package/dist/apps/demo/i18n/ja-JP.d.ts.map +1 -1
  79. package/dist/apps/demo/i18n/ja-JP.js +289 -0
  80. package/dist/apps/demo/i18n/ko-KR.d.ts.map +1 -1
  81. package/dist/apps/demo/i18n/ko-KR.js +289 -0
  82. package/dist/apps/demo/i18n/pt-BR.d.ts.map +1 -1
  83. package/dist/apps/demo/i18n/pt-BR.js +289 -0
  84. package/dist/apps/demo/i18n/zh-CN.d.ts.map +1 -1
  85. package/dist/apps/demo/i18n/zh-CN.js +301 -0
  86. package/dist/apps/demo/i18n/zh-HK.d.ts.map +1 -1
  87. package/dist/apps/demo/i18n/zh-HK.js +289 -0
  88. package/dist/apps/demo/i18n/zh-TW.d.ts.map +1 -1
  89. package/dist/apps/demo/i18n/zh-TW.js +289 -0
  90. package/dist/apps/demo/pages/autoform.d.ts.map +1 -1
  91. package/dist/apps/demo/pages/autoform.js +422 -0
  92. package/dist/apps/demo/pages/autoview.d.ts +3 -0
  93. package/dist/apps/demo/pages/autoview.d.ts.map +1 -0
  94. package/dist/apps/demo/pages/autoview.js +310 -0
  95. package/dist/apps/demo/pages/basic.js +157 -0
  96. package/dist/apps/demo/pages/code.js +1088 -0
  97. package/dist/apps/demo/pages/container.js +42 -0
  98. package/dist/apps/demo/pages/dashboard.js +159 -0
  99. package/dist/apps/demo/pages/data.d.ts.map +1 -1
  100. package/dist/apps/demo/pages/data.js +327 -0
  101. package/dist/apps/demo/pages/display.d.ts.map +1 -1
  102. package/dist/apps/demo/pages/display.js +295 -0
  103. package/dist/apps/demo/pages/feedback.js +94 -0
  104. package/dist/apps/demo/pages/form.d.ts.map +1 -1
  105. package/dist/apps/demo/pages/form.js +119 -0
  106. package/dist/apps/demo/pages/layout.js +74 -0
  107. package/dist/apps/demo/pages/navigation.js +54 -0
  108. package/dist/apps/demo/pages/progress.js +42 -0
  109. package/dist/apps/demo/pages/theme.js +126 -0
  110. package/dist/apps/demo/standalone.js +1 -0
  111. package/dist/components/basic/AGENTS.md +1 -0
  112. package/dist/components/basic/avatar.js +168 -0
  113. package/dist/components/basic/badge.js +157 -0
  114. package/dist/components/basic/button-group.js +70 -0
  115. package/dist/components/basic/button.d.ts +2 -4
  116. package/dist/components/basic/button.d.ts.map +1 -1
  117. package/dist/components/basic/button.js +315 -0
  118. package/dist/components/basic/card.js +186 -0
  119. package/dist/components/basic/chip.js +103 -0
  120. package/dist/components/basic/divider.js +127 -0
  121. package/dist/components/basic/empty.js +72 -0
  122. package/dist/components/basic/icon.js +129 -0
  123. package/dist/components/basic/input.d.ts.map +1 -1
  124. package/dist/components/basic/input.js +314 -0
  125. package/dist/components/basic/tag.d.ts +7 -2
  126. package/dist/components/basic/tag.d.ts.map +1 -1
  127. package/dist/components/basic/tag.js +248 -0
  128. package/dist/components/basic/textarea.d.ts +0 -1
  129. package/dist/components/basic/textarea.d.ts.map +1 -1
  130. package/dist/components/basic/textarea.js +130 -0
  131. package/dist/components/container/callout.js +108 -0
  132. package/dist/components/container/details.js +117 -0
  133. package/dist/components/container/scroller.js +144 -0
  134. package/dist/components/container/split-panel.js +150 -0
  135. package/dist/components/data/AGENTS.md +1 -1
  136. package/dist/components/data/box-table.d.ts +53 -0
  137. package/dist/components/data/box-table.d.ts.map +1 -0
  138. package/dist/components/data/box-table.js +220 -0
  139. package/dist/components/data/dropdown.d.ts +8 -5
  140. package/dist/components/data/dropdown.d.ts.map +1 -1
  141. package/dist/components/data/dropdown.js +219 -0
  142. package/dist/components/data/metrics-group.js +180 -0
  143. package/dist/components/data/metrics.d.ts +11 -0
  144. package/dist/components/data/metrics.d.ts.map +1 -1
  145. package/dist/components/data/metrics.js +309 -0
  146. package/dist/components/data/pagination.js +119 -0
  147. package/dist/components/data/tab-pane.d.ts +58 -12
  148. package/dist/components/data/tab-pane.d.ts.map +1 -1
  149. package/dist/components/data/tab-pane.js +130 -0
  150. package/dist/components/data/table-column.d.ts +29 -5
  151. package/dist/components/data/table-column.d.ts.map +1 -1
  152. package/dist/components/data/table-column.js +123 -0
  153. package/dist/components/data/table.d.ts +134 -54
  154. package/dist/components/data/table.d.ts.map +1 -1
  155. package/dist/components/data/table.js +1210 -0
  156. package/dist/components/data/tabs.d.ts +60 -3
  157. package/dist/components/data/tabs.d.ts.map +1 -1
  158. package/dist/components/data/tabs.js +416 -0
  159. package/dist/components/data/timeline-item.js +127 -0
  160. package/dist/components/data/timeline.js +204 -0
  161. package/dist/components/data/tree-menu.d.ts +12 -2
  162. package/dist/components/data/tree-menu.d.ts.map +1 -1
  163. package/dist/components/data/tree-menu.js +482 -0
  164. package/dist/components/data/tree.js +269 -0
  165. package/dist/components/display/AGENTS.md +5 -2
  166. package/dist/components/display/animated-image.js +98 -0
  167. package/dist/components/display/autoview.d.ts +139 -0
  168. package/dist/components/display/autoview.d.ts.map +1 -0
  169. package/dist/components/display/autoview.js +460 -0
  170. package/dist/components/display/brief-box.d.ts +42 -0
  171. package/dist/components/display/brief-box.d.ts.map +1 -0
  172. package/dist/components/display/brief-box.js +117 -0
  173. package/dist/components/display/carousel.js +223 -0
  174. package/dist/components/display/code-editor.d.ts.map +1 -1
  175. package/dist/components/display/code-editor.js +976 -0
  176. package/dist/components/display/comparison.js +132 -0
  177. package/dist/components/display/desc-item.d.ts +48 -0
  178. package/dist/components/display/desc-item.d.ts.map +1 -0
  179. package/dist/components/display/desc-item.js +150 -0
  180. package/dist/components/display/desc.d.ts +68 -0
  181. package/dist/components/display/desc.d.ts.map +1 -0
  182. package/dist/components/display/desc.js +405 -0
  183. package/dist/components/display/detail-box.d.ts +51 -0
  184. package/dist/components/display/detail-box.d.ts.map +1 -0
  185. package/dist/components/display/detail-box.js +157 -0
  186. package/dist/components/display/label.js +166 -0
  187. package/dist/components/display/markdown-editor.js +319 -0
  188. package/dist/components/display/markdown.d.ts.map +1 -1
  189. package/dist/components/display/markdown.js +193 -0
  190. package/dist/components/display/mini-box.d.ts +31 -0
  191. package/dist/components/display/mini-box.d.ts.map +1 -0
  192. package/dist/components/display/mini-box.js +137 -0
  193. package/dist/components/display/profile.d.ts +18 -0
  194. package/dist/components/display/profile.d.ts.map +1 -0
  195. package/dist/components/display/profile.js +164 -0
  196. package/dist/components/feedback/AGENTS.md +1 -0
  197. package/dist/components/feedback/alert.js +150 -0
  198. package/dist/components/feedback/dialog.js +228 -0
  199. package/dist/components/feedback/drawer.d.ts.map +1 -1
  200. package/dist/components/feedback/drawer.js +338 -0
  201. package/dist/components/feedback/loading.js +130 -0
  202. package/dist/components/feedback/modal.d.ts.map +1 -1
  203. package/dist/components/feedback/modal.js +303 -0
  204. package/dist/components/feedback/notification.js +170 -0
  205. package/dist/components/feedback/popover.d.ts +1 -1
  206. package/dist/components/feedback/popover.js +124 -0
  207. package/dist/components/feedback/toast.js +142 -0
  208. package/dist/components/feedback/tooltip.d.ts +1 -1
  209. package/dist/components/feedback/tooltip.js +153 -0
  210. package/dist/components/form/AGENTS.md +4 -0
  211. package/dist/components/form/autoform-item.d.ts +6 -0
  212. package/dist/components/form/autoform-item.d.ts.map +1 -1
  213. package/dist/components/form/autoform-item.js +791 -0
  214. package/dist/components/form/autoform.d.ts +15 -5
  215. package/dist/components/form/autoform.d.ts.map +1 -1
  216. package/dist/components/form/autoform.js +303 -0
  217. package/dist/components/form/checkbox-group.js +118 -0
  218. package/dist/components/form/checkbox.js +123 -0
  219. package/dist/components/form/color-picker.js +148 -0
  220. package/dist/components/form/combobox.d.ts +4 -0
  221. package/dist/components/form/combobox.d.ts.map +1 -1
  222. package/dist/components/form/combobox.js +325 -0
  223. package/dist/components/form/date-picker.js +123 -0
  224. package/dist/components/form/form-item.d.ts.map +1 -1
  225. package/dist/components/form/form-item.js +141 -0
  226. package/dist/components/form/form.js +94 -0
  227. package/dist/components/form/radio-group.js +106 -0
  228. package/dist/components/form/radio.js +110 -0
  229. package/dist/components/form/rate.js +116 -0
  230. package/dist/components/form/select.d.ts +5 -1
  231. package/dist/components/form/select.d.ts.map +1 -1
  232. package/dist/components/form/select.js +539 -0
  233. package/dist/components/form/slider.js +134 -0
  234. package/dist/components/form/switch.js +146 -0
  235. package/dist/components/form/time-picker.js +92 -0
  236. package/dist/components/form/transfer.js +273 -0
  237. package/dist/components/form/upload.js +138 -0
  238. package/dist/components/framework/body.js +333 -0
  239. package/dist/components/framework/dashboard-panel.js +519 -0
  240. package/dist/components/framework/dashboard.d.ts.map +1 -1
  241. package/dist/components/framework/dashboard.js +1084 -0
  242. package/dist/components/framework/header.js +237 -0
  243. package/dist/components/framework/log-panel.js +637 -0
  244. package/dist/components/framework/page.js +151 -0
  245. package/dist/components/framework/sidebar.d.ts +4 -10
  246. package/dist/components/framework/sidebar.d.ts.map +1 -1
  247. package/dist/components/framework/sidebar.js +477 -0
  248. package/dist/components/layout/affix.js +137 -0
  249. package/dist/components/layout/col.js +103 -0
  250. package/dist/components/layout/collapse-item.js +165 -0
  251. package/dist/components/layout/collapse.js +108 -0
  252. package/dist/components/layout/container.js +92 -0
  253. package/dist/components/layout/flex.js +100 -0
  254. package/dist/components/layout/row.js +103 -0
  255. package/dist/components/layout/space.js +85 -0
  256. package/dist/components/navigation/back-top.js +127 -0
  257. package/dist/components/navigation/breadcrumb-item.js +108 -0
  258. package/dist/components/navigation/breadcrumb.js +70 -0
  259. package/dist/components/navigation/menu-item.js +181 -0
  260. package/dist/components/navigation/menu.js +126 -0
  261. package/dist/components/navigation/steps.js +183 -0
  262. package/dist/components/navigation/sub-menu.d.ts.map +1 -1
  263. package/dist/components/navigation/sub-menu.js +252 -0
  264. package/dist/components/progress/progress-bar.js +97 -0
  265. package/dist/components/progress/progress-ring.js +111 -0
  266. package/dist/components/progress/skeleton.js +108 -0
  267. package/dist/components/progress/spinner.js +129 -0
  268. package/dist/components/theme/locale-switch.js +241 -0
  269. package/dist/components/theme/shadow-picker.js +233 -0
  270. package/dist/components/theme/shape-picker.js +232 -0
  271. package/dist/components/theme/theme-picker.js +236 -0
  272. package/dist/components/theme/theme-preview.d.ts +1 -2
  273. package/dist/components/theme/theme-preview.d.ts.map +1 -1
  274. package/dist/components/theme/theme-preview.js +376 -0
  275. package/dist/components/theme/theme-switch.d.ts.map +1 -1
  276. package/dist/components/theme/theme-switch.js +318 -0
  277. package/dist/components/theme/typo-picker.js +219 -0
  278. package/dist/core/AGENTS.md +6 -1
  279. package/dist/core/aithe-element.d.ts +2 -2
  280. package/dist/core/aithe-element.js +135 -0
  281. package/dist/core/aithe-widget.js +30 -0
  282. package/dist/core/anchored-overlay.d.ts +3 -0
  283. package/dist/core/anchored-overlay.d.ts.map +1 -1
  284. package/dist/core/anchored-overlay.js +111 -0
  285. package/dist/core/autoform/autoform.js +79 -0
  286. package/dist/core/autoform/autoview.d.ts +86 -0
  287. package/dist/core/autoform/autoview.d.ts.map +1 -0
  288. package/dist/core/autoform/autoview.js +37 -0
  289. package/dist/core/autoform/condition.js +170 -0
  290. package/dist/core/autoform/index.d.ts +2 -0
  291. package/dist/core/autoform/index.d.ts.map +1 -1
  292. package/dist/core/autoform/index.js +9 -0
  293. package/dist/core/autoform/types.js +7 -0
  294. package/dist/core/datahub/__tests__/force-options.test.d.ts +8 -0
  295. package/dist/core/datahub/__tests__/force-options.test.d.ts.map +1 -0
  296. package/dist/core/datahub/__tests__/force-options.test.js +161 -0
  297. package/dist/core/datahub/config/strategy.d.ts +1 -1
  298. package/dist/core/datahub/config/strategy.d.ts.map +1 -1
  299. package/dist/core/datahub/config/strategy.js +50 -0
  300. package/dist/core/datahub/core/adapter/fetch-adapter.d.ts +1 -1
  301. package/dist/core/datahub/core/adapter/fetch-adapter.d.ts.map +1 -1
  302. package/dist/core/datahub/core/adapter/fetch-adapter.js +118 -0
  303. package/dist/core/datahub/core/adapter/index.js +7 -0
  304. package/dist/core/datahub/core/adapter/mock-adapter.d.ts +1 -1
  305. package/dist/core/datahub/core/adapter/mock-adapter.d.ts.map +1 -1
  306. package/dist/core/datahub/core/adapter/mock-adapter.js +58 -0
  307. package/dist/core/datahub/core/api-styles.d.ts +1 -1
  308. package/dist/core/datahub/core/api-styles.d.ts.map +1 -1
  309. package/dist/core/datahub/core/api-styles.js +136 -0
  310. package/dist/core/datahub/core/datahub-core.d.ts +53 -3
  311. package/dist/core/datahub/core/datahub-core.d.ts.map +1 -1
  312. package/dist/core/datahub/core/datahub-core.js +520 -0
  313. package/dist/core/datahub/core/index.js +7 -0
  314. package/dist/core/datahub/index.js +50 -0
  315. package/dist/core/datahub/types.d.ts +24 -0
  316. package/dist/core/datahub/types.d.ts.map +1 -1
  317. package/dist/core/datahub/types.js +31 -0
  318. package/dist/core/datahub/utils/cache.js +55 -0
  319. package/dist/core/datahub/utils/common.js +23 -0
  320. package/dist/core/datahub/utils/dedup.d.ts +1 -1
  321. package/dist/core/datahub/utils/dedup.d.ts.map +1 -1
  322. package/dist/core/datahub/utils/dedup.js +52 -0
  323. package/dist/core/datahub/utils/idempotent.js +61 -0
  324. package/dist/core/datahub/utils/is-query.js +53 -0
  325. package/dist/core/datahub/utils/loading.js +78 -0
  326. package/dist/core/filter/__tests__/index.test.d.ts +2 -0
  327. package/dist/core/filter/__tests__/index.test.d.ts.map +1 -0
  328. package/dist/core/filter/__tests__/index.test.js +230 -0
  329. package/dist/core/filter/builtins.d.ts +60 -0
  330. package/dist/core/filter/builtins.d.ts.map +1 -0
  331. package/dist/core/filter/builtins.js +172 -0
  332. package/dist/core/filter/factory.d.ts +54 -0
  333. package/dist/core/filter/factory.d.ts.map +1 -0
  334. package/dist/core/filter/factory.js +96 -0
  335. package/dist/core/filter/index.d.ts +11 -0
  336. package/dist/core/filter/index.d.ts.map +1 -0
  337. package/dist/core/filter/index.js +9 -0
  338. package/dist/core/filter/types.d.ts +12 -0
  339. package/dist/core/filter/types.d.ts.map +1 -0
  340. package/dist/core/filter/types.js +1 -0
  341. package/dist/core/floating.js +132 -0
  342. package/dist/core/highlight/index.js +43 -0
  343. package/dist/core/highlight/lang-bash.js +27 -0
  344. package/dist/core/highlight/lang-c.js +27 -0
  345. package/dist/core/highlight/lang-cmake.js +27 -0
  346. package/dist/core/highlight/lang-cpp.js +27 -0
  347. package/dist/core/highlight/lang-css.js +24 -0
  348. package/dist/core/highlight/lang-dart.js +27 -0
  349. package/dist/core/highlight/lang-dockerfile.js +16 -0
  350. package/dist/core/highlight/lang-fsharp.js +23 -0
  351. package/dist/core/highlight/lang-go.js +22 -0
  352. package/dist/core/highlight/lang-html.js +12 -0
  353. package/dist/core/highlight/lang-java.js +22 -0
  354. package/dist/core/highlight/lang-javascript.js +26 -0
  355. package/dist/core/highlight/lang-json.js +13 -0
  356. package/dist/core/highlight/lang-jsonline.js +13 -0
  357. package/dist/core/highlight/lang-jsx.js +30 -0
  358. package/dist/core/highlight/lang-kotlin.js +27 -0
  359. package/dist/core/highlight/lang-latex.js +22 -0
  360. package/dist/core/highlight/lang-lua.js +26 -0
  361. package/dist/core/highlight/lang-makefile.js +22 -0
  362. package/dist/core/highlight/lang-markdown.js +18 -0
  363. package/dist/core/highlight/lang-objectivec.js +24 -0
  364. package/dist/core/highlight/lang-perl.js +30 -0
  365. package/dist/core/highlight/lang-powershell.js +23 -0
  366. package/dist/core/highlight/lang-python.js +27 -0
  367. package/dist/core/highlight/lang-r.js +21 -0
  368. package/dist/core/highlight/lang-ruby.js +29 -0
  369. package/dist/core/highlight/lang-rust.js +24 -0
  370. package/dist/core/highlight/lang-scala.js +26 -0
  371. package/dist/core/highlight/lang-sql.js +21 -0
  372. package/dist/core/highlight/lang-svelte.js +27 -0
  373. package/dist/core/highlight/lang-swift.js +28 -0
  374. package/dist/core/highlight/lang-tsx.js +35 -0
  375. package/dist/core/highlight/lang-typescript.js +31 -0
  376. package/dist/core/highlight/lang-vue.js +29 -0
  377. package/dist/core/highlight/lang-wasm.js +22 -0
  378. package/dist/core/highlight/lang-xml.js +12 -0
  379. package/dist/core/highlight/lang-yaml.js +14 -0
  380. package/dist/core/highlight/registry.js +99 -0
  381. package/dist/core/logger/LoggerCore.js +626 -0
  382. package/dist/core/logger/index.js +10 -0
  383. package/dist/core/logger/types.js +29 -0
  384. package/dist/core/markdown/index.js +20 -0
  385. package/dist/core/markdown/parser.d.ts +2 -0
  386. package/dist/core/markdown/parser.d.ts.map +1 -1
  387. package/dist/core/markdown/parser.js +376 -0
  388. package/dist/core/markdown/plugins.d.ts +2 -1
  389. package/dist/core/markdown/plugins.d.ts.map +1 -1
  390. package/dist/core/markdown/plugins.js +755 -0
  391. package/dist/core/markdown/types.d.ts +5 -0
  392. package/dist/core/markdown/types.d.ts.map +1 -1
  393. package/dist/core/markdown/types.js +7 -0
  394. package/dist/core/router/index.js +244 -0
  395. package/dist/core/styles.js +44 -0
  396. package/dist/core/types.d.ts +52 -3
  397. package/dist/core/types.d.ts.map +1 -1
  398. package/dist/core/types.js +1 -0
  399. package/dist/index.d.ts +9 -0
  400. package/dist/index.d.ts.map +1 -1
  401. package/dist/index.js +3695 -1622
  402. package/dist/index.js.map +1 -1
  403. package/dist/index.umd.js +1844 -758
  404. package/dist/index.umd.js.map +1 -1
  405. package/dist/styles/aithe-ui.d.ts +23 -0
  406. package/dist/styles/aithe-ui.d.ts.map +1 -1
  407. package/dist/styles/aithe-ui.js +185 -0
  408. package/dist/styles/global.css.d.ts +1 -1
  409. package/dist/styles/global.css.d.ts.map +1 -1
  410. package/dist/styles/global.css.js +119 -0
  411. package/dist/styles/i18n/index.js +206 -0
  412. package/dist/styles/i18n/locales/de-DE.d.ts.map +1 -1
  413. package/dist/styles/i18n/locales/de-DE.js +151 -0
  414. package/dist/styles/i18n/locales/en-US.d.ts.map +1 -1
  415. package/dist/styles/i18n/locales/en-US.js +160 -0
  416. package/dist/styles/i18n/locales/es-ES.d.ts.map +1 -1
  417. package/dist/styles/i18n/locales/es-ES.js +151 -0
  418. package/dist/styles/i18n/locales/fr-FR.d.ts.map +1 -1
  419. package/dist/styles/i18n/locales/fr-FR.js +151 -0
  420. package/dist/styles/i18n/locales/index.js +14 -0
  421. package/dist/styles/i18n/locales/ja-JP.d.ts.map +1 -1
  422. package/dist/styles/i18n/locales/ja-JP.js +151 -0
  423. package/dist/styles/i18n/locales/ko-KR.d.ts.map +1 -1
  424. package/dist/styles/i18n/locales/ko-KR.js +151 -0
  425. package/dist/styles/i18n/locales/pt-BR.d.ts.map +1 -1
  426. package/dist/styles/i18n/locales/pt-BR.js +151 -0
  427. package/dist/styles/i18n/locales/zh-CN.d.ts.map +1 -1
  428. package/dist/styles/i18n/locales/zh-CN.js +160 -0
  429. package/dist/styles/i18n/locales/zh-HK.d.ts.map +1 -1
  430. package/dist/styles/i18n/locales/zh-HK.js +151 -0
  431. package/dist/styles/i18n/locales/zh-TW.d.ts.map +1 -1
  432. package/dist/styles/i18n/locales/zh-TW.js +151 -0
  433. package/dist/styles/layout/index.js +88 -0
  434. package/dist/styles/mixins.js +43 -0
  435. package/dist/styles/shadow/cyber.js +19 -0
  436. package/dist/styles/shadow/deep.js +19 -0
  437. package/dist/styles/shadow/diffuse.js +19 -0
  438. package/dist/styles/shadow/flat.js +19 -0
  439. package/dist/styles/shadow/glassmorphism.js +19 -0
  440. package/dist/styles/shadow/index.js +129 -0
  441. package/dist/styles/shadow/neumorphism.js +21 -0
  442. package/dist/styles/shadow/retro.js +19 -0
  443. package/dist/styles/shadow/sharp-business.js +19 -0
  444. package/dist/styles/shadow/skeuomorphic.js +21 -0
  445. package/dist/styles/shape/chamfer.js +19 -0
  446. package/dist/styles/shape/circle.js +19 -0
  447. package/dist/styles/shape/index.js +174 -0
  448. package/dist/styles/shape/organic.js +19 -0
  449. package/dist/styles/shape/pill.js +19 -0
  450. package/dist/styles/shape/rounded.js +21 -0
  451. package/dist/styles/shape/rounder.js +19 -0
  452. package/dist/styles/shape/sharp.js +19 -0
  453. package/dist/styles/shape/smooth.js +19 -0
  454. package/dist/styles/theme/aliyun.d.ts +1 -1
  455. package/dist/styles/theme/aliyun.d.ts.map +1 -1
  456. package/dist/styles/theme/aliyun.js +102 -0
  457. package/dist/styles/theme/amber.d.ts +1 -1
  458. package/dist/styles/theme/amber.d.ts.map +1 -1
  459. package/dist/styles/theme/amber.js +101 -0
  460. package/dist/styles/theme/blue.d.ts +1 -1
  461. package/dist/styles/theme/blue.d.ts.map +1 -1
  462. package/dist/styles/theme/blue.js +101 -0
  463. package/dist/styles/theme/charcoal.d.ts +1 -1
  464. package/dist/styles/theme/charcoal.d.ts.map +1 -1
  465. package/dist/styles/theme/charcoal.js +106 -0
  466. package/dist/styles/theme/cyan.d.ts +1 -1
  467. package/dist/styles/theme/cyan.d.ts.map +1 -1
  468. package/dist/styles/theme/cyan.js +96 -0
  469. package/dist/styles/theme/dark.d.ts +1 -1
  470. package/dist/styles/theme/dark.d.ts.map +1 -1
  471. package/dist/styles/theme/dark.js +106 -0
  472. package/dist/styles/theme/ebony.d.ts +1 -1
  473. package/dist/styles/theme/ebony.d.ts.map +1 -1
  474. package/dist/styles/theme/ebony.js +106 -0
  475. package/dist/styles/theme/festive.d.ts +1 -1
  476. package/dist/styles/theme/festive.d.ts.map +1 -1
  477. package/dist/styles/theme/festive.js +101 -0
  478. package/dist/styles/theme/graphite.d.ts +1 -1
  479. package/dist/styles/theme/graphite.d.ts.map +1 -1
  480. package/dist/styles/theme/graphite.js +106 -0
  481. package/dist/styles/theme/gray.d.ts +1 -1
  482. package/dist/styles/theme/gray.d.ts.map +1 -1
  483. package/dist/styles/theme/gray.js +101 -0
  484. package/dist/styles/theme/huawei.d.ts +1 -1
  485. package/dist/styles/theme/huawei.d.ts.map +1 -1
  486. package/dist/styles/theme/huawei.js +102 -0
  487. package/dist/styles/theme/index.d.ts +1 -1
  488. package/dist/styles/theme/index.d.ts.map +1 -1
  489. package/dist/styles/theme/index.js +276 -0
  490. package/dist/styles/theme/indigo.d.ts +1 -1
  491. package/dist/styles/theme/indigo.d.ts.map +1 -1
  492. package/dist/styles/theme/indigo.js +101 -0
  493. package/dist/styles/theme/ink.d.ts +1 -1
  494. package/dist/styles/theme/ink.d.ts.map +1 -1
  495. package/dist/styles/theme/ink.js +106 -0
  496. package/dist/styles/theme/light.d.ts +1 -1
  497. package/dist/styles/theme/light.d.ts.map +1 -1
  498. package/dist/styles/theme/light.js +102 -0
  499. package/dist/styles/theme/midnight.d.ts +1 -1
  500. package/dist/styles/theme/midnight.d.ts.map +1 -1
  501. package/dist/styles/theme/midnight.js +106 -0
  502. package/dist/styles/theme/navy.d.ts +1 -1
  503. package/dist/styles/theme/navy.d.ts.map +1 -1
  504. package/dist/styles/theme/navy.js +106 -0
  505. package/dist/styles/theme/obsidian.d.ts +1 -1
  506. package/dist/styles/theme/obsidian.d.ts.map +1 -1
  507. package/dist/styles/theme/obsidian.js +106 -0
  508. package/dist/styles/theme/onyx.d.ts +1 -1
  509. package/dist/styles/theme/onyx.d.ts.map +1 -1
  510. package/dist/styles/theme/onyx.js +106 -0
  511. package/dist/styles/theme/orange.d.ts +1 -1
  512. package/dist/styles/theme/orange.d.ts.map +1 -1
  513. package/dist/styles/theme/orange.js +101 -0
  514. package/dist/styles/theme/pink.d.ts +1 -1
  515. package/dist/styles/theme/pink.d.ts.map +1 -1
  516. package/dist/styles/theme/pink.js +101 -0
  517. package/dist/styles/theme/purple.d.ts +1 -1
  518. package/dist/styles/theme/purple.d.ts.map +1 -1
  519. package/dist/styles/theme/purple.js +101 -0
  520. package/dist/styles/theme/raisin.d.ts +1 -1
  521. package/dist/styles/theme/raisin.d.ts.map +1 -1
  522. package/dist/styles/theme/raisin.js +106 -0
  523. package/dist/styles/theme/slate.d.ts +1 -1
  524. package/dist/styles/theme/slate.d.ts.map +1 -1
  525. package/dist/styles/theme/slate.js +106 -0
  526. package/dist/styles/theme/teal.d.ts +1 -1
  527. package/dist/styles/theme/teal.d.ts.map +1 -1
  528. package/dist/styles/theme/teal.js +101 -0
  529. package/dist/styles/theme/tianyi.d.ts +1 -1
  530. package/dist/styles/theme/tianyi.d.ts.map +1 -1
  531. package/dist/styles/theme/tianyi.js +102 -0
  532. package/dist/styles/types.js +1 -0
  533. package/dist/styles/typo/business.js +34 -0
  534. package/dist/styles/typo/compact.js +34 -0
  535. package/dist/styles/typo/index.js +99 -0
  536. package/dist/styles/typo/luxury.js +34 -0
  537. package/dist/styles/typo/minimal.js +34 -0
  538. package/dist/types/index.js +2 -0
  539. package/dist/utils/dom.js +51 -0
  540. package/dist/utils/events.js +32 -0
  541. package/dist/utils/icon.js +176 -0
  542. package/dist/utils/index.js +4 -0
  543. package/dist/utils/utils.d.ts +5 -5
  544. package/dist/utils/utils.js +89 -0
  545. package/dist/utils/validation.js +52 -0
  546. package/docs/api/basic/button.md +9 -6
  547. package/docs/api/basic/tag.md +24 -17
  548. package/docs/api/data/box-table.md +73 -0
  549. package/docs/api/data/dropdown.md +3 -2
  550. package/docs/api/data/metrics.md +2 -0
  551. package/docs/api/data/table-column.md +37 -23
  552. package/docs/api/data/table.md +158 -44
  553. package/docs/api/data/tabs.md +46 -1
  554. package/docs/api/data/tree-menu.md +55 -2
  555. package/docs/api/display/autoview.md +277 -0
  556. package/docs/api/display/box.md +66 -0
  557. package/docs/api/display/brief-box.md +73 -0
  558. package/docs/api/display/desc-item.md +57 -0
  559. package/docs/api/display/desc.md +246 -0
  560. package/docs/api/display/detail-box.md +75 -0
  561. package/docs/api/display/mini-box.md +100 -0
  562. package/docs/api/display/profile.md +92 -0
  563. package/docs/api/feedback/popover.md +10 -10
  564. package/docs/api/feedback/tooltip.md +14 -14
  565. package/docs/api/form/autoform-item.md +115 -0
  566. package/docs/api/form/autoform.md +7 -3
  567. package/docs/api/form/combobox.md +27 -7
  568. package/docs/api/form/select.md +50 -28
  569. package/docs/api/framework/log-panel.md +46 -0
  570. package/docs/api/framework/sidebar.md +3 -2
  571. package/docs/api/summary.md +46 -35
  572. package/docs/api/theme/theme-switch.md +1 -1
  573. package/docs/autoform.md +14 -33
  574. package/docs/changelog/CHANGELOG.md +155 -0
  575. package/docs/changelog/VERSION_26.3.1.md +966 -0
  576. package/docs/changelog/VERSION_26.3.2.md +852 -0
  577. package/docs/datahub.md +4 -1
  578. package/docs/filter.md +332 -0
  579. package/docs/framework-integration.md +2 -2
  580. package/docs/guide.md +72 -6
  581. package/docs/i18n.md +2 -4
  582. package/docs/issue/26.3.1/issue_26.3.1.0.md +84 -0
  583. package/docs/issue/26.3.1/issue_26.3.1.1.md +72 -0
  584. package/docs/issue/26.3.1/issue_26.3.1.2.md +75 -0
  585. package/docs/issue/26.3.1/issue_26.3.1.3.md +78 -0
  586. package/docs/issue/26.3.1/issue_26.3.1.4.md +113 -0
  587. package/docs/issue/26.3.1/issue_26.3.1.5.md +142 -0
  588. package/docs/issue/26.3.1/issue_26.3.1.6.md +100 -0
  589. package/docs/issue/26.3.1/issue_26.3.1.7.md +78 -0
  590. package/docs/issue/26.3.2/issue_26.3.2.1.md +46 -0
  591. package/docs/issue/26.3.2/issue_26.3.2.2.md +82 -0
  592. package/docs/issue/26.3.2/issue_26.3.2.3.md +57 -0
  593. package/docs/issue/26.3.2/issue_26.3.2.4.md +43 -0
  594. package/docs/issue/AGENTS.md +24 -3
  595. package/docs/markdown.md +2 -2
  596. package/docs/quickstart.md +5 -5
  597. package/docs/theming.md +5 -4
  598. package/package.json +5 -2
  599. package/dist/components/navigation/dropdown.d.ts +0 -56
  600. package/dist/components/navigation/dropdown.d.ts.map +0 -1
  601. /package/docs/issue/{issue_26.2.2.1.md → 26.2.2/issue_26.2.2.1.md} +0 -0
  602. /package/docs/issue/{issue_26.2.2.2.md → 26.2.2/issue_26.2.2.2.md} +0 -0
  603. /package/docs/issue/{issue_26.2.2.3.md → 26.2.2/issue_26.2.2.3.md} +0 -0
  604. /package/docs/issue/{issue_26.2.2.4.md → 26.2.2/issue_26.2.2.4.md} +0 -0
  605. /package/docs/issue/{issue_26.2.3.1.md → 26.2.3/issue_26.2.3.1.md} +0 -0
  606. /package/docs/issue/{issue_26.2.3.10.md → 26.2.3/issue_26.2.3.10.md} +0 -0
  607. /package/docs/issue/{issue_26.2.3.11.md → 26.2.3/issue_26.2.3.11.md} +0 -0
  608. /package/docs/issue/{issue_26.2.3.12.md → 26.2.3/issue_26.2.3.12.md} +0 -0
  609. /package/docs/issue/{issue_26.2.3.13.md → 26.2.3/issue_26.2.3.13.md} +0 -0
  610. /package/docs/issue/{issue_26.2.3.14.md → 26.2.3/issue_26.2.3.14.md} +0 -0
  611. /package/docs/issue/{issue_26.2.3.15.md → 26.2.3/issue_26.2.3.15.md} +0 -0
  612. /package/docs/issue/{issue_26.2.3.16.md → 26.2.3/issue_26.2.3.16.md} +0 -0
  613. /package/docs/issue/{issue_26.2.3.2.md → 26.2.3/issue_26.2.3.2.md} +0 -0
  614. /package/docs/issue/{issue_26.2.3.3.md → 26.2.3/issue_26.2.3.3.md} +0 -0
  615. /package/docs/issue/{issue_26.2.3.4.md → 26.2.3/issue_26.2.3.4.md} +0 -0
  616. /package/docs/issue/{issue_26.2.3.5.md → 26.2.3/issue_26.2.3.5.md} +0 -0
  617. /package/docs/issue/{issue_26.2.3.6.md → 26.2.3/issue_26.2.3.6.md} +0 -0
  618. /package/docs/issue/{issue_26.2.3.7.md → 26.2.3/issue_26.2.3.7.md} +0 -0
  619. /package/docs/issue/{issue_26.2.3.8.md → 26.2.3/issue_26.2.3.8.md} +0 -0
  620. /package/docs/issue/{issue_26.2.3.9.md → 26.2.3/issue_26.2.3.9.md} +0 -0
@@ -0,0 +1,1210 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { css, html, nothing } from 'lit';
8
+ import { customElement, property, state } from 'lit/decorators.js';
9
+ import { classMap } from 'lit/directives/class-map.js';
10
+ import { styleMap } from 'lit/directives/style-map.js';
11
+ import { AitheElement } from '../../core/aithe-element';
12
+ import { aitheBaseStyles, aitheScrollbarStyles } from '../../core/styles';
13
+ import { getValueByPath, safeStringify } from '../../utils/utils';
14
+ import { t } from '../../styles/i18n';
15
+ import { filterFactory } from '../../core/filter';
16
+ import './table-column';
17
+ const SELECTION_COL_WIDTH = 52;
18
+ const MIN_COL_WIDTH = 40;
19
+ const DEFAULT_COL_WIDTH = 120;
20
+ const DRAG_THRESHOLD = 5;
21
+ const SHADOW_WIDTH = 15;
22
+ function toSortableString(val) {
23
+ if (val === null || val === undefined)
24
+ return '';
25
+ if (typeof val === 'object')
26
+ return '';
27
+ if (typeof val === 'string')
28
+ return val;
29
+ if (typeof val === 'number' || typeof val === 'boolean')
30
+ return String(val);
31
+ return '';
32
+ }
33
+ /**
34
+ * Data table with sorting, row selection, column fixed, column resizing,
35
+ * column drag-to-reorder, loading state, single-select mode, and keyboard navigation.
36
+ *
37
+ * @slot empty - Content shown when the table has no data.
38
+ * @slot loading - Custom loading indicator content.
39
+ * @slot - Default slot for `<aithe-table-column>` children.
40
+ *
41
+ * @fires aithe-sort-change - Emitted with `{ sortKey, sortOrder }`.
42
+ * @fires aithe-selection-change - Emitted with `{ selectionSet }`.
43
+ * @fires aithe-row-click - Emitted with `{ record, rowIndex }`.
44
+ * @fires aithe-column-resize - Emitted with `{ columnId, width }`.
45
+ * @fires aithe-column-reorder - Emitted with `{ columns }` (new column id order).
46
+ */
47
+ let AitheTable = class AitheTable extends AitheElement {
48
+ constructor() {
49
+ super(...arguments);
50
+ this.columnsJson = '';
51
+ this.columns = [];
52
+ this.dataJson = '';
53
+ this.data = [];
54
+ this.rowKey = 'id';
55
+ this.striped = false;
56
+ this.bordered = true;
57
+ this.hoverable = true;
58
+ this.selectable = 'none';
59
+ this.selectionSet = new Set();
60
+ this.sortKey = '';
61
+ this.sortOrder = '';
62
+ this.loading = false;
63
+ this.loadingText = '';
64
+ this.slotColumns = [];
65
+ this.columnOrder = [];
66
+ this.focusedRowIndex = -1;
67
+ this.resizeData = null;
68
+ this.dragData = null;
69
+ /**
70
+ * Keyboard navigation handler for ArrowDown/ArrowUp/Space/Enter.
71
+ * 键盘导航处理:ArrowDown/ArrowUp/空格/Enter。
72
+ */
73
+ this._onKeyDown = (e) => {
74
+ const rows = this.rowData;
75
+ if (rows.length === 0)
76
+ return;
77
+ const tag = e.target?.tagName;
78
+ if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || tag === 'BUTTON')
79
+ return;
80
+ let newIndex;
81
+ switch (e.key) {
82
+ case 'ArrowDown':
83
+ e.preventDefault();
84
+ newIndex = Math.min(this.focusedRowIndex + 1, rows.length - 1);
85
+ break;
86
+ case 'ArrowUp':
87
+ e.preventDefault();
88
+ newIndex = Math.max(this.focusedRowIndex - 1, 0);
89
+ break;
90
+ case ' ':
91
+ e.preventDefault();
92
+ if (this.selectable !== 'none' && this.focusedRowIndex >= 0) {
93
+ const record = rows[this.focusedRowIndex];
94
+ const key = this.getRecordKey(record, this.focusedRowIndex);
95
+ const checked = !this.selectionSet.has(key);
96
+ this.toggleRowSelection(record, this.focusedRowIndex, checked);
97
+ }
98
+ return;
99
+ case 'Enter':
100
+ e.preventDefault();
101
+ if (this.focusedRowIndex >= 0) {
102
+ this.emit('aithe-row-click', { record: rows[this.focusedRowIndex], rowIndex: this.focusedRowIndex });
103
+ }
104
+ return;
105
+ default:
106
+ return;
107
+ }
108
+ if (newIndex !== this.focusedRowIndex) {
109
+ this.focusedRowIndex = newIndex;
110
+ this.requestUpdate();
111
+ this._scrollRowIntoView(newIndex);
112
+ }
113
+ };
114
+ /**
115
+ * Handle mousemove during column resize, updating column width.
116
+ * 列宽调整时处理鼠标移动,更新列宽。
117
+ */
118
+ this._onResizeMove = (e) => {
119
+ if (!this.resizeData)
120
+ return;
121
+ const rd = this.resizeData;
122
+ const { startX, startWidth } = rd;
123
+ const diff = e.clientX - startX;
124
+ const newWidth = Math.max(MIN_COL_WIDTH, startWidth + diff);
125
+ const col = this.resolvedColumns.find((c) => c.id === rd.columnId);
126
+ const minW = col?.minWidth ? Number.parseInt(col.minWidth, 10) : MIN_COL_WIDTH;
127
+ const finalWidth = Math.max(minW, newWidth);
128
+ const ths = this.renderRoot?.querySelectorAll('th');
129
+ if (ths) {
130
+ for (const th of ths) {
131
+ const el = th;
132
+ const colId = el.dataset.columnId;
133
+ if (colId === rd.columnId) {
134
+ el.style.width = `${finalWidth}px`;
135
+ }
136
+ }
137
+ }
138
+ const tds = this.renderRoot?.querySelectorAll('td');
139
+ if (tds) {
140
+ for (const td of tds) {
141
+ const el = td;
142
+ const colId = el.dataset.columnId;
143
+ if (colId === rd.columnId) {
144
+ el.style.width = `${finalWidth}px`;
145
+ }
146
+ }
147
+ }
148
+ };
149
+ /**
150
+ * End column resize on mouseup, emit event with final width.
151
+ * 鼠标松开时结束列宽调整,发射最终宽度事件。
152
+ */
153
+ this._onResizeEnd = () => {
154
+ if (!this.resizeData)
155
+ return;
156
+ this._removeResizeListeners();
157
+ const ths = this.renderRoot?.querySelectorAll('th');
158
+ let finalWidth = '';
159
+ if (ths) {
160
+ for (const th of ths) {
161
+ const el = th;
162
+ const colId = el.dataset.columnId;
163
+ if (colId === this.resizeData.columnId) {
164
+ finalWidth = el.style.width;
165
+ }
166
+ }
167
+ }
168
+ this.emit('aithe-column-resize', {
169
+ columnId: this.resizeData.columnId,
170
+ width: finalWidth,
171
+ });
172
+ this.resizeData = null;
173
+ };
174
+ // --- Column drag-to-reorder logic ---
175
+ this.dragThreshold = DRAG_THRESHOLD;
176
+ this._onDragMove = (e) => {
177
+ if (!this.dragData)
178
+ return;
179
+ const ths = this.renderRoot?.querySelectorAll('th[data-column-id]');
180
+ if (!ths)
181
+ return;
182
+ for (const th of ths) {
183
+ th.classList.remove('drag-over-left', 'drag-over-right');
184
+ }
185
+ for (const th of ths) {
186
+ const el = th;
187
+ const rect = el.getBoundingClientRect();
188
+ const colId = el.dataset.columnId;
189
+ if (colId === this.dragData.columnId)
190
+ continue;
191
+ if (e.clientX >= rect.left && e.clientX <= rect.right) {
192
+ const mid = rect.left + rect.width / 2;
193
+ if (e.clientX < mid) {
194
+ el.classList.add('drag-over-left');
195
+ }
196
+ else {
197
+ el.classList.add('drag-over-right');
198
+ }
199
+ break;
200
+ }
201
+ }
202
+ };
203
+ /**
204
+ * End column drag-to-reorder. Removes ghost element and event listeners,
205
+ * updates column order, and emits event.
206
+ * 结束列拖拽排序。移除幽灵元素和事件监听,更新列顺序并发射事件。
207
+ */
208
+ this._onDragEnd = (e) => {
209
+ if (!this.dragData)
210
+ return;
211
+ document.removeEventListener('mousemove', this._onDragMove);
212
+ document.removeEventListener('mouseup', this._onDragEnd);
213
+ this._clearDragClasses();
214
+ const dragColId = this.dragData.columnId;
215
+ const target = this._findDropTarget(e, dragColId);
216
+ if (target) {
217
+ this._applyColumnReorder(dragColId, target.colId, target.insertBefore);
218
+ }
219
+ this.dragData = null;
220
+ };
221
+ }
222
+ /**
223
+ * Resolved column definitions with drag-to-reorder applied.
224
+ * 应用了拖拽排序后的列定义。
225
+ */
226
+ get resolvedColumns() {
227
+ const cols = this.slotColumns.length > 0 ? this.slotColumns : this.columns;
228
+ if (this.columnOrder.length === cols.length && this.columnOrder.length > 0) {
229
+ const ordered = [];
230
+ for (const id of this.columnOrder) {
231
+ const found = cols.find((c) => c.id === id);
232
+ if (found)
233
+ ordered.push(found);
234
+ }
235
+ if (ordered.length === cols.length)
236
+ return ordered;
237
+ }
238
+ return cols;
239
+ }
240
+ /** Ordered column IDs from resolved columns. 已解析列的 ID 顺序。 */
241
+ get orderedColumnIds() {
242
+ return this.resolvedColumns.map((c) => c.id);
243
+ }
244
+ connectedCallback() {
245
+ super.connectedCallback();
246
+ this.slotObserver = new MutationObserver(() => this.syncSlotColumns());
247
+ this.slotObserver.observe(this, { childList: true, subtree: true, attributes: true });
248
+ this.syncSlotColumns();
249
+ this.addEventListener('keydown', this._onKeyDown);
250
+ }
251
+ disconnectedCallback() {
252
+ super.disconnectedCallback();
253
+ this.slotObserver?.disconnect();
254
+ this.removeEventListener('keydown', this._onKeyDown);
255
+ }
256
+ updated(changed) {
257
+ if (changed.has('data') || changed.has('sortKey') || changed.has('sortOrder')) {
258
+ this.focusedRowIndex = -1;
259
+ }
260
+ }
261
+ /**
262
+ * Scroll the row at the given index into the visible area.
263
+ * 将指定索引的行滚动到可视区域。
264
+ */
265
+ _scrollRowIntoView(index) {
266
+ const tbody = this.renderRoot?.querySelector('tbody');
267
+ if (!tbody)
268
+ return;
269
+ const tr = tbody.children[index];
270
+ tr?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
271
+ }
272
+ /**
273
+ * Sync column definitions from `<aithe-table-column>` child elements.
274
+ * 从 `<aithe-table-column>` 子元素同步列定义。
275
+ */
276
+ syncSlotColumns() {
277
+ const colEls = this.querySelectorAll('aithe-table-column');
278
+ if (colEls.length === 0) {
279
+ if (this.slotColumns.length > 0) {
280
+ this.slotColumns = [];
281
+ }
282
+ return;
283
+ }
284
+ const cols = [];
285
+ for (const el of colEls) {
286
+ const col = el;
287
+ const def = {
288
+ id: col.id,
289
+ title: col.title,
290
+ dataIndex: col.dataIndex || col.id,
291
+ width: col.width || undefined,
292
+ minWidth: col.minWidth || undefined,
293
+ align: col.align,
294
+ sortable: col.sortable,
295
+ fixed: col.fixed || undefined,
296
+ resizable: col.resizable,
297
+ draggable: col.draggable,
298
+ icon: col.icon || undefined,
299
+ variant: col.variant || undefined,
300
+ filter: col.filter || undefined,
301
+ box: col.box || undefined,
302
+ };
303
+ if (typeof col.cellRenderer === 'function') {
304
+ def.render = col.cellRenderer;
305
+ }
306
+ cols.push(def);
307
+ }
308
+ this.slotColumns = cols;
309
+ }
310
+ /**
311
+ * Parse JSON string properties into their object counterparts.
312
+ * 将 JSON 字符串属性解析为对象。
313
+ */
314
+ willUpdate(changed) {
315
+ if (changed.has('columnsJson') && this.columnsJson) {
316
+ try {
317
+ this.columns = JSON.parse(this.columnsJson);
318
+ }
319
+ catch {
320
+ this.columns = [];
321
+ }
322
+ }
323
+ if (changed.has('dataJson') && this.dataJson) {
324
+ try {
325
+ this.data = JSON.parse(this.dataJson);
326
+ }
327
+ catch {
328
+ this.data = [];
329
+ }
330
+ }
331
+ }
332
+ static { this.styles = [
333
+ aitheBaseStyles,
334
+ aitheScrollbarStyles,
335
+ css `
336
+ :host {
337
+ display: block;
338
+ outline: none;
339
+ }
340
+
341
+ .table-wrap {
342
+ overflow: auto;
343
+ border-radius: var(--aithe-container-radius-xl);
344
+ background: var(--aithe-color-surface-elevated);
345
+ box-shadow: var(--aithe-shadow-1);
346
+ position: relative;
347
+ }
348
+
349
+ table {
350
+ width: 100%;
351
+ border-collapse: collapse;
352
+ table-layout: fixed;
353
+ }
354
+
355
+ :host([has-fixed]) table {
356
+ min-width: max-content;
357
+ }
358
+
359
+ th,
360
+ td {
361
+ padding: var(--aithe-space-4);
362
+ text-align: left;
363
+ border-bottom: 1px solid var(--aithe-color-border);
364
+ vertical-align: middle;
365
+ position: relative;
366
+ box-sizing: border-box;
367
+ }
368
+
369
+ .bordered th,
370
+ .bordered td {
371
+ border-inline-end: 1px solid var(--aithe-color-border);
372
+ }
373
+
374
+ .bordered th:last-child,
375
+ .bordered td:last-child {
376
+ border-inline-end: none;
377
+ }
378
+
379
+ thead th {
380
+ position: sticky;
381
+ top: 0;
382
+ background: color-mix(in srgb, var(--aithe-color-surface-elevated) 92%, transparent);
383
+ color: var(--aithe-color-text-muted);
384
+ font-size: var(--aithe-font-size-sm);
385
+ font-weight: var(--aithe-font-weight-semibold);
386
+ z-index: 2;
387
+ }
388
+
389
+ /* Fixed column styles */
390
+ th.fixed-left,
391
+ td.fixed-left {
392
+ position: sticky;
393
+ z-index: 3;
394
+ }
395
+
396
+ th.fixed-right,
397
+ td.fixed-right {
398
+ position: sticky;
399
+ z-index: 3;
400
+ }
401
+
402
+ th.fixed-left {
403
+ z-index: 4;
404
+ }
405
+
406
+ th.fixed-right {
407
+ z-index: 4;
408
+ }
409
+
410
+ td.fixed-left,
411
+ td.fixed-right {
412
+ background: var(--aithe-color-surface-elevated);
413
+ }
414
+
415
+ .fixed-left-shadow::after {
416
+ content: '';
417
+ position: absolute;
418
+ top: 0;
419
+ right: 0;
420
+ bottom: 0;
421
+ width: ${SHADOW_WIDTH}px;
422
+ pointer-events: none;
423
+ background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.06));
424
+ transform: translateX(100%);
425
+ }
426
+
427
+ .fixed-right-shadow::before {
428
+ content: '';
429
+ position: absolute;
430
+ top: 0;
431
+ left: 0;
432
+ bottom: 0;
433
+ width: ${SHADOW_WIDTH}px;
434
+ pointer-events: none;
435
+ background: linear-gradient(to left, transparent, rgba(0, 0, 0, 0.06));
436
+ transform: translateX(-100%);
437
+ }
438
+
439
+ tbody tr.hoverable:hover {
440
+ background: var(--aithe-color-surface-muted);
441
+ }
442
+
443
+ tbody tr.striped:nth-child(even) {
444
+ background: color-mix(in srgb, var(--aithe-color-surface-muted) 72%, transparent);
445
+ }
446
+
447
+ tbody tr.striped:nth-child(even) td.fixed-left,
448
+ tbody tr.striped:nth-child(even) td.fixed-right,
449
+ tbody tr.striped:nth-child(even) td.selection-cell {
450
+ background: color-mix(in srgb, var(--aithe-color-surface-muted) 72%, transparent);
451
+ }
452
+
453
+ tbody tr.focused {
454
+ outline: 2px solid var(--aithe-primary-5);
455
+ outline-offset: -2px;
456
+ }
457
+
458
+ .sorter {
459
+ display: inline-flex;
460
+ align-items: center;
461
+ gap: var(--aithe-space-2);
462
+ border: none;
463
+ padding: 0;
464
+ background: transparent;
465
+ color: inherit;
466
+ cursor: pointer;
467
+ }
468
+
469
+ .sort-icon {
470
+ color: var(--aithe-color-text-subtle);
471
+ }
472
+
473
+ .empty {
474
+ padding: var(--aithe-space-8);
475
+ text-align: center;
476
+ color: var(--aithe-color-text-muted);
477
+ }
478
+
479
+ .checkbox {
480
+ width: 16px;
481
+ height: 16px;
482
+ cursor: pointer;
483
+ }
484
+
485
+ .radio {
486
+ width: 16px;
487
+ height: 16px;
488
+ cursor: pointer;
489
+ accent-color: var(--aithe-primary-6);
490
+ }
491
+
492
+ .header-icon {
493
+ flex-shrink: 0;
494
+ color: var(--aithe-color-text-muted);
495
+ }
496
+
497
+ .cell.primary {
498
+ color: var(--aithe-primary-7);
499
+ }
500
+ .cell.success {
501
+ color: var(--aithe-success-7);
502
+ }
503
+ .cell.warning {
504
+ color: var(--aithe-warning-7);
505
+ }
506
+ .cell.danger {
507
+ color: var(--aithe-danger-7);
508
+ }
509
+
510
+ /* Column resize handle */
511
+ .resize-handle {
512
+ position: absolute;
513
+ top: 0;
514
+ right: 0;
515
+ width: 4px;
516
+ height: 100%;
517
+ cursor: col-resize;
518
+ z-index: 5;
519
+ user-select: none;
520
+ }
521
+
522
+ .resize-handle:hover,
523
+ .resize-handle.resizing {
524
+ background: var(--aithe-primary-5);
525
+ }
526
+
527
+ /* Column drag handle */
528
+ .drag-handle {
529
+ cursor: grab;
530
+ display: inline-flex;
531
+ align-items: center;
532
+ opacity: 0.4;
533
+ margin-right: var(--aithe-space-1);
534
+ user-select: none;
535
+ font-size: 12px;
536
+ }
537
+
538
+ .drag-handle:hover {
539
+ opacity: 0.8;
540
+ }
541
+
542
+ .drag-handle:active {
543
+ cursor: grabbing;
544
+ }
545
+
546
+ th.dragging {
547
+ opacity: 0.5;
548
+ }
549
+
550
+ th.drag-over-left {
551
+ border-left: 2px solid var(--aithe-primary-6);
552
+ }
553
+
554
+ th.drag-over-right {
555
+ border-right: 2px solid var(--aithe-primary-6);
556
+ }
557
+
558
+ /* Loading overlay */
559
+ .loading-overlay {
560
+ position: absolute;
561
+ inset: 0;
562
+ display: flex;
563
+ flex-direction: column;
564
+ align-items: center;
565
+ justify-content: center;
566
+ background: color-mix(in srgb, var(--aithe-color-surface-elevated) 70%, transparent);
567
+ z-index: 10;
568
+ border-radius: var(--aithe-container-radius-xl);
569
+ }
570
+
571
+ .loading-spinner {
572
+ width: 32px;
573
+ height: 32px;
574
+ border: 3px solid var(--aithe-color-border);
575
+ border-top-color: var(--aithe-primary-6);
576
+ border-radius: 50%;
577
+ animation: aithe-spin 0.8s linear infinite;
578
+ }
579
+
580
+ .loading-text {
581
+ margin-top: var(--aithe-space-2);
582
+ color: var(--aithe-color-text-muted);
583
+ font-size: var(--aithe-font-size-sm);
584
+ }
585
+
586
+ @keyframes aithe-spin {
587
+ to {
588
+ transform: rotate(360deg);
589
+ }
590
+ }
591
+
592
+ /* Loading placeholder rows */
593
+ .placeholder-cell {
594
+ height: 20px;
595
+ background: linear-gradient(
596
+ 90deg,
597
+ var(--aithe-color-surface-muted) 25%,
598
+ color-mix(in srgb, var(--aithe-color-surface-muted) 60%, transparent) 50%,
599
+ var(--aithe-color-surface-muted) 75%
600
+ );
601
+ background-size: 200% 100%;
602
+ animation: aithe-shimmer 1.5s ease-in-out infinite;
603
+ border-radius: var(--aithe-container-radius-sm);
604
+ }
605
+
606
+ @keyframes aithe-shimmer {
607
+ 0% {
608
+ background-position: 200% 0;
609
+ }
610
+ 100% {
611
+ background-position: -200% 0;
612
+ }
613
+ }
614
+
615
+ .selection-cell {
616
+ width: ${SELECTION_COL_WIDTH}px;
617
+ min-width: ${SELECTION_COL_WIDTH}px;
618
+ max-width: ${SELECTION_COL_WIDTH}px;
619
+ position: sticky;
620
+ left: 0;
621
+ z-index: 3;
622
+ }
623
+
624
+ thead .selection-cell {
625
+ z-index: 5;
626
+ }
627
+ `,
628
+ ]; }
629
+ /**
630
+ * Sorted row data. Returns original data when no sort key is set.
631
+ * 排序后的行数据。未设置排序键时返回原始数据。
632
+ */
633
+ get rowData() {
634
+ if (!this.sortKey || !this.sortOrder) {
635
+ return this.data;
636
+ }
637
+ const sorted = [...this.data];
638
+ sorted.sort((left, right) => {
639
+ const leftValue = getValueByPath(left, this.sortKey);
640
+ const rightValue = getValueByPath(right, this.sortKey);
641
+ if (typeof leftValue === 'number' && typeof rightValue === 'number') {
642
+ return this.sortOrder === 'asc' ? leftValue - rightValue : rightValue - leftValue;
643
+ }
644
+ const normalizedLeft = toSortableString(leftValue);
645
+ const normalizedRight = toSortableString(rightValue);
646
+ return this.sortOrder === 'asc'
647
+ ? normalizedLeft.localeCompare(normalizedRight)
648
+ : normalizedRight.localeCompare(normalizedLeft);
649
+ });
650
+ return sorted;
651
+ }
652
+ /** Whether all rows are selected. 是否所有行都被选中。 */
653
+ get allChecked() {
654
+ return this.rowData.length > 0 && this.selectionSet.size === this.rowData.length;
655
+ }
656
+ /** Whether some (but not all) rows are selected. 是否部分行被选中。 */
657
+ get partiallyChecked() {
658
+ return this.selectionSet.size > 0 && !this.allChecked;
659
+ }
660
+ /**
661
+ * Get the unique key for a record.
662
+ * 获取记录的唯一键。
663
+ */
664
+ getRecordKey(record, index) {
665
+ const value = getValueByPath(record, this.rowKey);
666
+ if (value == null)
667
+ return String(index);
668
+ return safeStringify(value);
669
+ }
670
+ /**
671
+ * Toggle sort state for a column (asc → desc → none → asc).
672
+ * 切换列的排序状态(升序 → 降序 → 无 → 升序)。
673
+ */
674
+ toggleSort(column) {
675
+ if (!column.sortable)
676
+ return;
677
+ if (this.sortKey !== column.id) {
678
+ this.sortKey = column.id;
679
+ this.sortOrder = 'asc';
680
+ }
681
+ else if (this.sortOrder === 'asc') {
682
+ this.sortOrder = 'desc';
683
+ }
684
+ else if (this.sortOrder === 'desc') {
685
+ this.sortOrder = '';
686
+ this.sortKey = '';
687
+ }
688
+ else {
689
+ this.sortOrder = 'asc';
690
+ }
691
+ this.emit('aithe-sort-change', {
692
+ sortKey: this.sortKey,
693
+ sortOrder: this.sortOrder,
694
+ });
695
+ }
696
+ /**
697
+ * Toggle selection state for a single row.
698
+ * 切换单行的选中状态。
699
+ */
700
+ toggleRowSelection(record, index, checked) {
701
+ const key = this.getRecordKey(record, index);
702
+ if (this.selectable === 'single') {
703
+ this.selectionSet.clear();
704
+ if (checked) {
705
+ this.selectionSet.add(key);
706
+ }
707
+ }
708
+ else if (checked) {
709
+ this.selectionSet.add(key);
710
+ }
711
+ else {
712
+ this.selectionSet.delete(key);
713
+ }
714
+ this.requestUpdate();
715
+ this.emit('aithe-selection-change', { selectionSet: this.selectionSet });
716
+ }
717
+ /**
718
+ * Toggle all rows selection state (multi-select mode only).
719
+ * 切换所有行的选中状态(仅多选模式)。
720
+ */
721
+ toggleAllRows(checked) {
722
+ if (this.selectable === 'single')
723
+ return;
724
+ this.selectionSet.clear();
725
+ if (checked) {
726
+ for (const [index, row] of this.rowData.entries()) {
727
+ this.selectionSet.add(this.getRecordKey(row, index));
728
+ }
729
+ }
730
+ this.requestUpdate();
731
+ this.emit('aithe-selection-change', { selectionSet: this.selectionSet });
732
+ }
733
+ // --- Column resize logic ---
734
+ /**
735
+ * Start column resize on mousedown of the resize handle.
736
+ * 在调整大小手柄上按下鼠标时开始列宽调整。
737
+ */
738
+ _onResizeStart(e, columnId) {
739
+ e.preventDefault();
740
+ const th = e.currentTarget.closest('th');
741
+ if (!th)
742
+ return;
743
+ const startWidth = th.getBoundingClientRect().width;
744
+ this.resizeData = { columnId, startX: e.clientX, startWidth };
745
+ this._addResizeListeners();
746
+ }
747
+ /** Attach document-level resize event listeners. 添加文档级调整大小事件监听。 */
748
+ _addResizeListeners() {
749
+ document.addEventListener('mousemove', this._onResizeMove);
750
+ document.addEventListener('mouseup', this._onResizeEnd);
751
+ }
752
+ /** Remove document-level resize event listeners. 移除文档级调整大小事件监听。 */
753
+ _removeResizeListeners() {
754
+ document.removeEventListener('mousemove', this._onResizeMove);
755
+ document.removeEventListener('mouseup', this._onResizeEnd);
756
+ }
757
+ /**
758
+ * Handle mousedown on a column header th. If the user moves the mouse beyond
759
+ * the drag threshold, starts column drag-to-reorder.
760
+ * 处理列头 th 上的鼠标按下。如果鼠标移动超过拖拽阈值,开始列拖拽排序。
761
+ */
762
+ _onThMouseDown(e, column) {
763
+ if (!column.draggable)
764
+ return;
765
+ const target = e.target;
766
+ if (target.closest('.resize-handle'))
767
+ return;
768
+ if (target.closest('.sorter') && !target.closest('.drag-handle'))
769
+ return;
770
+ if (target.closest('.checkbox'))
771
+ return;
772
+ if (target.tagName === 'INPUT' || target.tagName === 'SELECT' || target.tagName === 'TEXTAREA')
773
+ return;
774
+ const startX = e.clientX;
775
+ const startY = e.clientY;
776
+ const onMouseMove = (ev) => {
777
+ if (Math.abs(ev.clientX - startX) > this.dragThreshold || Math.abs(ev.clientY - startY) > this.dragThreshold) {
778
+ document.removeEventListener('mousemove', onMouseMove);
779
+ document.removeEventListener('mouseup', onMouseUp);
780
+ this._startDrag(ev, column.id);
781
+ }
782
+ };
783
+ const onMouseUp = () => {
784
+ document.removeEventListener('mousemove', onMouseMove);
785
+ document.removeEventListener('mouseup', onMouseUp);
786
+ };
787
+ document.addEventListener('mousemove', onMouseMove);
788
+ document.addEventListener('mouseup', onMouseUp);
789
+ }
790
+ /**
791
+ * Start column drag-to-reorder. Creates a drag ghost element and attaches
792
+ * document-level mousemove/mouseup listeners.
793
+ * 开始列拖拽排序。创建拖拽幽灵元素并添加文档级鼠标事件监听。
794
+ */
795
+ _startDrag(e, columnId) {
796
+ const th = this.renderRoot?.querySelector(`th[data-column-id="${columnId}"]`);
797
+ if (!th)
798
+ return;
799
+ const rect = th.getBoundingClientRect();
800
+ this.dragData = { columnId, startX: e.clientX, dragColWidth: rect.width };
801
+ th.classList.add('dragging');
802
+ document.addEventListener('mousemove', this._onDragMove);
803
+ document.addEventListener('mouseup', this._onDragEnd);
804
+ }
805
+ _clearDragClasses() {
806
+ const ths = this.renderRoot?.querySelectorAll('th[data-column-id]');
807
+ if (!ths)
808
+ return;
809
+ for (const th of ths) {
810
+ th.classList.remove('dragging', 'drag-over-left', 'drag-over-right');
811
+ }
812
+ }
813
+ _findDropTarget(e, dragColId) {
814
+ const ths = this.renderRoot?.querySelectorAll('th[data-column-id]');
815
+ if (!ths)
816
+ return null;
817
+ for (const th of ths) {
818
+ const el = th;
819
+ const colId = el.dataset.columnId;
820
+ if (colId === dragColId)
821
+ continue;
822
+ const rect = el.getBoundingClientRect();
823
+ if (e.clientX >= rect.left && e.clientX <= rect.right) {
824
+ const mid = rect.left + rect.width / 2;
825
+ return { colId: colId ?? '', insertBefore: e.clientX < mid };
826
+ }
827
+ }
828
+ return null;
829
+ }
830
+ _applyColumnReorder(dragColId, targetColId, insertBefore) {
831
+ if (targetColId === dragColId)
832
+ return;
833
+ const currentOrder = [...this.orderedColumnIds];
834
+ const dragIdx = currentOrder.indexOf(dragColId);
835
+ const targetIdx = currentOrder.indexOf(targetColId);
836
+ if (dragIdx === -1 || targetIdx === -1)
837
+ return;
838
+ currentOrder.splice(dragIdx, 1);
839
+ const newTargetIdx = currentOrder.indexOf(targetColId);
840
+ const insertIdx = insertBefore ? newTargetIdx : newTargetIdx + 1;
841
+ currentOrder.splice(insertIdx, 0, dragColId);
842
+ this.columnOrder = currentOrder;
843
+ this.emit('aithe-column-reorder', { columns: currentOrder });
844
+ }
845
+ // --- Rendering ---
846
+ renderCell(column, record) {
847
+ const value = getValueByPath(record, column.dataIndex ? String(column.dataIndex) : column.id);
848
+ if (column.render)
849
+ return column.render(column.id, value, record);
850
+ if (value == null)
851
+ return nothing;
852
+ if (typeof value === 'object')
853
+ return JSON.stringify(value);
854
+ if (column.filter)
855
+ return filterFactory.format(value, column.filter);
856
+ return value;
857
+ }
858
+ getSortIcon(column) {
859
+ if (this.sortKey !== column.id)
860
+ return '↕';
861
+ if (this.sortOrder === 'asc')
862
+ return '↑';
863
+ if (this.sortOrder === 'desc')
864
+ return '↓';
865
+ return '↕';
866
+ }
867
+ renderColumnHeader(column) {
868
+ const colIcon = column.icon
869
+ ? html `
870
+ <aithe-icon class="header-icon" name=${column.icon} size="16"></aithe-icon>
871
+ `
872
+ : nothing;
873
+ const dragHandle = column.draggable
874
+ ? html `<span class="drag-handle">⠿</span>`
875
+ : nothing;
876
+ const sortContent = column.sortable
877
+ ? html `
878
+ <button class="sorter" type="button" @click=${() => this.toggleSort(column)}>
879
+ ${colIcon}
880
+ <span>${column.title}</span>
881
+ <span class="sort-icon">${this.getSortIcon(column)}</span>
882
+ </button>
883
+ `
884
+ : html `
885
+ ${dragHandle}${colIcon}${column.title}
886
+ `;
887
+ const resizeHandle = column.resizable
888
+ ? html `<span
889
+ class="resize-handle"
890
+ @mousedown=${(e) => this._onResizeStart(e, column.id)}
891
+ ></span>`
892
+ : nothing;
893
+ return html `
894
+ <div style="display:flex;align-items:center;gap:4px;">
895
+ ${column.sortable ? dragHandle : nothing}
896
+ ${sortContent}
897
+ </div>
898
+ ${resizeHandle}
899
+ `;
900
+ }
901
+ /**
902
+ * Compute `left` or `right` offset for a fixed column.
903
+ * 计算固定列的 left 或 right 偏移值。
904
+ */
905
+ _getFixedStyle(column) {
906
+ if (!column.fixed)
907
+ return {};
908
+ if (column.fixed === 'left') {
909
+ return { left: `${this._calcLeftOffset(column)}px` };
910
+ }
911
+ if (column.fixed === 'right') {
912
+ return { right: `${this._calcRightOffset(column)}px` };
913
+ }
914
+ return {};
915
+ }
916
+ _calcLeftOffset(column) {
917
+ let offset = this.selectable === 'none' ? 0 : SELECTION_COL_WIDTH;
918
+ for (const c of this.resolvedColumns) {
919
+ if (c.id === column.id)
920
+ break;
921
+ if (c.fixed === 'left') {
922
+ offset += this._getColumnWidth(c);
923
+ }
924
+ }
925
+ return offset;
926
+ }
927
+ _calcRightOffset(column) {
928
+ let offset = 0;
929
+ const reversed = [...this.resolvedColumns].reverse();
930
+ for (const c of reversed) {
931
+ if (c.id === column.id)
932
+ break;
933
+ if (c.fixed === 'right') {
934
+ offset += this._getColumnWidth(c);
935
+ }
936
+ }
937
+ return offset;
938
+ }
939
+ /**
940
+ * Get the current width of a column from the DOM.
941
+ * 从 DOM 获取列当前实际宽度。
942
+ */
943
+ _getColumnWidth(column) {
944
+ if (column.width) {
945
+ const parsed = Number.parseInt(column.width, 10);
946
+ if (!Number.isNaN(parsed))
947
+ return parsed;
948
+ }
949
+ return DEFAULT_COL_WIDTH;
950
+ }
951
+ _hasFixedLeft() {
952
+ return this.resolvedColumns.some((c) => c.fixed === 'left');
953
+ }
954
+ _hasFixedRight() {
955
+ return this.resolvedColumns.some((c) => c.fixed === 'right');
956
+ }
957
+ _renderLoadingRows() {
958
+ const placeholderCount = Math.min(3, this.data.length || 3);
959
+ return html `
960
+ ${Array.from({ length: placeholderCount }, (_, _rowIdx) => html `
961
+ <tr>
962
+ ${this.selectable === 'none'
963
+ ? nothing
964
+ : html `
965
+ <td class="selection-cell"><div class="placeholder-cell"></div></td>
966
+ `}
967
+ ${this.resolvedColumns.map((col) => html `
968
+ <td>
969
+ <div
970
+ class="placeholder-cell"
971
+ style=${styleMap({ width: col.width || '60%' })}
972
+ ></div>
973
+ </td>
974
+ `)}
975
+ </tr>
976
+ `)}
977
+ `;
978
+ }
979
+ _renderSelectAllCheckbox() {
980
+ if (this.selectable === 'single')
981
+ return html ``;
982
+ return html `
983
+ <input
984
+ class="checkbox"
985
+ aria-label=${t('data.table.selectAllAriaLabel')}
986
+ .indeterminate=${this.partiallyChecked}
987
+ ?checked=${this.allChecked}
988
+ type="checkbox"
989
+ @change=${(event) => this.toggleAllRows(event.currentTarget.checked)}
990
+ />
991
+ `;
992
+ }
993
+ _renderSelectionCell(checked, record, rowIndex) {
994
+ if (this.selectable === 'none')
995
+ return html ``;
996
+ const isSingle = this.selectable === 'single';
997
+ return html `
998
+ <td class="selection-cell">
999
+ ${isSingle
1000
+ ? html `
1001
+ <input
1002
+ class="radio"
1003
+ type="radio"
1004
+ name=${`${this.tagName}-selection`}
1005
+ aria-label=${t('data.table.selectRowAriaLabel')}
1006
+ .checked=${checked}
1007
+ @click=${(event) => event.stopPropagation()}
1008
+ @change=${(event) => this.toggleRowSelection(record, rowIndex, event.currentTarget.checked)}
1009
+ />
1010
+ `
1011
+ : html `
1012
+ <input
1013
+ class="checkbox"
1014
+ aria-label=${t('data.table.selectRowAriaLabel')}
1015
+ .checked=${checked}
1016
+ type="checkbox"
1017
+ @click=${(event) => event.stopPropagation()}
1018
+ @change=${(event) => this.toggleRowSelection(record, rowIndex, event.currentTarget.checked)}
1019
+ />
1020
+ `}
1021
+ </td>
1022
+ `;
1023
+ }
1024
+ _renderTableBody(rows) {
1025
+ if (this.loading)
1026
+ return this._renderLoadingRows();
1027
+ const hasFixedLeft = this._hasFixedLeft();
1028
+ const hasFixedRight = this._hasFixedRight();
1029
+ return html `
1030
+ ${rows.map((record, rowIndex) => {
1031
+ const key = this.getRecordKey(record, rowIndex);
1032
+ const checked = this.selectionSet.has(key);
1033
+ const isFocused = rowIndex === this.focusedRowIndex;
1034
+ return html `
1035
+ <tr
1036
+ class=${classMap({
1037
+ hoverable: this.hoverable,
1038
+ striped: this.striped,
1039
+ focused: isFocused,
1040
+ })}
1041
+ @click=${() => {
1042
+ this.focusedRowIndex = rowIndex;
1043
+ this.emit('aithe-row-click', { record, rowIndex });
1044
+ }}
1045
+ >
1046
+ ${this._renderSelectionCell(checked, record, rowIndex)}
1047
+ ${this.resolvedColumns.map((column) => {
1048
+ const hasVariant = column.variant && column.variant !== 'default';
1049
+ return html `
1050
+ <td
1051
+ data-column-id=${column.id}
1052
+ class=${classMap({
1053
+ cell: !!hasVariant,
1054
+ [column.variant || '']: !!hasVariant,
1055
+ 'fixed-left': column.fixed === 'left',
1056
+ 'fixed-right': column.fixed === 'right',
1057
+ 'fixed-left-shadow': column.fixed === 'left' && hasFixedLeft,
1058
+ 'fixed-right-shadow': column.fixed === 'right' && hasFixedRight,
1059
+ })}
1060
+ style=${styleMap({
1061
+ textAlign: column.align ?? 'left',
1062
+ ...this._getFixedStyle(column),
1063
+ })}
1064
+ >
1065
+ ${this.renderCell(column, record)}
1066
+ </td>
1067
+ `;
1068
+ })}
1069
+ </tr>
1070
+ `;
1071
+ })}
1072
+ `;
1073
+ }
1074
+ render() {
1075
+ const rows = this.rowData;
1076
+ const hasFixedLeft = this._hasFixedLeft();
1077
+ const hasFixedRight = this._hasFixedRight();
1078
+ this.toggleAttribute('has-fixed', (hasFixedLeft || hasFixedRight || this.selectable !== 'none'));
1079
+ const selectAllTh = this.selectable === 'none'
1080
+ ? null
1081
+ : html `
1082
+ <th
1083
+ class="selection-cell"
1084
+ style=${styleMap({
1085
+ width: `${SELECTION_COL_WIDTH}px`,
1086
+ minWidth: `${SELECTION_COL_WIDTH}px`,
1087
+ maxWidth: `${SELECTION_COL_WIDTH}px`,
1088
+ left: '0',
1089
+ })}
1090
+ >
1091
+ ${this._renderSelectAllCheckbox()}
1092
+ </th>
1093
+ `;
1094
+ const loadingTextEl = this.loadingText
1095
+ ? html `<div class="loading-text">${this.loadingText}</div>`
1096
+ : nothing;
1097
+ return html `
1098
+ <div
1099
+ class=${classMap({ 'table-wrap': true, bordered: this.bordered })}
1100
+ tabindex="0"
1101
+ @keydown=${this._onKeyDown}
1102
+ >
1103
+ <slot @slotchange=${() => this.syncSlotColumns()}></slot>
1104
+ ${this.loading
1105
+ ? html `
1106
+ <div class="loading-overlay">
1107
+ <slot name="loading">
1108
+ <div class="loading-spinner"></div>
1109
+ ${loadingTextEl}
1110
+ </slot>
1111
+ </div>
1112
+ `
1113
+ : nothing}
1114
+ ${rows.length
1115
+ ? html `
1116
+ <table>
1117
+ <thead>
1118
+ <tr>
1119
+ ${selectAllTh}
1120
+ ${this.resolvedColumns.map((column) => html `
1121
+ <th
1122
+ data-column-id=${column.id}
1123
+ @mousedown=${(e) => this._onThMouseDown(e, column)}
1124
+ class=${classMap({
1125
+ 'fixed-left': column.fixed === 'left',
1126
+ 'fixed-right': column.fixed === 'right',
1127
+ 'fixed-left-shadow': column.fixed === 'left' && hasFixedLeft,
1128
+ 'fixed-right-shadow': column.fixed === 'right' && hasFixedRight,
1129
+ })}
1130
+ style=${styleMap({
1131
+ textAlign: column.align ?? 'left',
1132
+ width: column.width,
1133
+ minWidth: column.minWidth,
1134
+ ...this._getFixedStyle(column),
1135
+ })}
1136
+ >
1137
+ ${this.renderColumnHeader(column)}
1138
+ </th>
1139
+ `)}
1140
+ </tr>
1141
+ </thead>
1142
+ <tbody>
1143
+ ${this._renderTableBody(rows)}
1144
+ </tbody>
1145
+ </table>
1146
+ `
1147
+ : html `
1148
+ <div class="empty">
1149
+ <slot name="empty">${t('data.table.emptyText')}</slot>
1150
+ </div>
1151
+ `}
1152
+ </div>
1153
+ `;
1154
+ }
1155
+ };
1156
+ __decorate([
1157
+ property({ type: String, attribute: 'columns' })
1158
+ ], AitheTable.prototype, "columnsJson", void 0);
1159
+ __decorate([
1160
+ property({ attribute: false })
1161
+ ], AitheTable.prototype, "columns", void 0);
1162
+ __decorate([
1163
+ property({ type: String, attribute: 'data' })
1164
+ ], AitheTable.prototype, "dataJson", void 0);
1165
+ __decorate([
1166
+ property({ attribute: false })
1167
+ ], AitheTable.prototype, "data", void 0);
1168
+ __decorate([
1169
+ property({ type: String, attribute: 'row-key' })
1170
+ ], AitheTable.prototype, "rowKey", void 0);
1171
+ __decorate([
1172
+ property({ type: Boolean })
1173
+ ], AitheTable.prototype, "striped", void 0);
1174
+ __decorate([
1175
+ property({ type: Boolean })
1176
+ ], AitheTable.prototype, "bordered", void 0);
1177
+ __decorate([
1178
+ property({ type: Boolean, attribute: 'hoverable' })
1179
+ ], AitheTable.prototype, "hoverable", void 0);
1180
+ __decorate([
1181
+ property({ type: String })
1182
+ ], AitheTable.prototype, "selectable", void 0);
1183
+ __decorate([
1184
+ property({ attribute: false })
1185
+ ], AitheTable.prototype, "selectionSet", void 0);
1186
+ __decorate([
1187
+ property({ type: String, attribute: 'sort-key' })
1188
+ ], AitheTable.prototype, "sortKey", void 0);
1189
+ __decorate([
1190
+ property({ type: String, attribute: 'sort-order' })
1191
+ ], AitheTable.prototype, "sortOrder", void 0);
1192
+ __decorate([
1193
+ property({ type: Boolean })
1194
+ ], AitheTable.prototype, "loading", void 0);
1195
+ __decorate([
1196
+ property({ type: String })
1197
+ ], AitheTable.prototype, "loadingText", void 0);
1198
+ __decorate([
1199
+ state()
1200
+ ], AitheTable.prototype, "slotColumns", void 0);
1201
+ __decorate([
1202
+ state()
1203
+ ], AitheTable.prototype, "columnOrder", void 0);
1204
+ __decorate([
1205
+ state()
1206
+ ], AitheTable.prototype, "focusedRowIndex", void 0);
1207
+ AitheTable = __decorate([
1208
+ customElement('aithe-table')
1209
+ ], AitheTable);
1210
+ export { AitheTable };