@bk2k/ui 0.6.8 → 0.7.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 (471) hide show
  1. package/BUILDING.md +56 -2
  2. package/CHANGELOG.md +136 -0
  3. package/USAGE.md +89 -26
  4. package/custom-elements.json +1 -1
  5. package/dist/charts/chart-tokens.js +1 -1
  6. package/dist/charts/fields.d.ts +20 -0
  7. package/dist/charts/fields.js +27 -0
  8. package/dist/charts/frame.js +2 -1
  9. package/dist/clipboard.js +1 -0
  10. package/dist/components/bk-alert.js +2 -1
  11. package/dist/components/bk-avatar-group.js +4 -6
  12. package/dist/components/bk-avatar.d.ts +10 -0
  13. package/dist/components/bk-avatar.js +17 -0
  14. package/dist/components/bk-bar.js +2 -0
  15. package/dist/components/bk-button-group.js +1 -1
  16. package/dist/components/bk-button-top.js +2 -1
  17. package/dist/components/bk-button.d.ts +37 -14
  18. package/dist/components/bk-button.js +52 -16
  19. package/dist/components/bk-card.d.ts +4 -0
  20. package/dist/components/bk-card.js +15 -2
  21. package/dist/components/bk-carousel-controls.d.ts +2 -0
  22. package/dist/components/bk-carousel-controls.js +4 -2
  23. package/dist/components/bk-chart-area.d.ts +6 -0
  24. package/dist/components/bk-chart-bar.d.ts +17 -0
  25. package/dist/components/bk-chart-bar.js +25 -4
  26. package/dist/components/bk-chart-line.d.ts +13 -0
  27. package/dist/components/bk-chart-line.js +11 -1
  28. package/dist/components/bk-chip-group.d.ts +2 -2
  29. package/dist/components/bk-chip-group.js +4 -0
  30. package/dist/components/bk-chip.d.ts +53 -8
  31. package/dist/components/bk-chip.js +43 -7
  32. package/dist/components/bk-code.js +6 -2
  33. package/dist/components/bk-columns.d.ts +11 -0
  34. package/dist/components/bk-columns.js +8 -1
  35. package/dist/components/bk-combobox.d.ts +1 -1
  36. package/dist/components/bk-combobox.js +2 -1
  37. package/dist/components/bk-delta.d.ts +10 -0
  38. package/dist/components/bk-delta.js +8 -6
  39. package/dist/components/bk-dialog.d.ts +12 -5
  40. package/dist/components/bk-dialog.js +14 -6
  41. package/dist/components/bk-disclosure.js +4 -2
  42. package/dist/components/bk-drop-target.d.ts +7 -1
  43. package/dist/components/bk-drop-target.js +20 -4
  44. package/dist/components/bk-error-summary.d.ts +5 -0
  45. package/dist/components/bk-error-summary.js +13 -4
  46. package/dist/components/bk-facts.js +3 -2
  47. package/dist/components/bk-footnote.d.ts +73 -0
  48. package/dist/components/bk-footnote.js +97 -0
  49. package/dist/components/bk-footnotes-item.d.ts +92 -0
  50. package/dist/components/bk-footnotes-item.js +139 -0
  51. package/dist/components/bk-footnotes.d.ts +51 -0
  52. package/dist/components/bk-footnotes.js +43 -0
  53. package/dist/components/bk-icon.js +2 -2
  54. package/dist/components/bk-image-compare.d.ts +33 -5
  55. package/dist/components/bk-image-compare.js +72 -24
  56. package/dist/components/bk-image-crop.d.ts +3 -3
  57. package/dist/components/bk-image-editor.d.ts +1 -1
  58. package/dist/components/bk-image-viewer.d.ts +107 -11
  59. package/dist/components/bk-image-viewer.js +205 -34
  60. package/dist/components/bk-input-inline.d.ts +15 -6
  61. package/dist/components/bk-input-inline.js +22 -6
  62. package/dist/components/bk-input-number.js +2 -1
  63. package/dist/components/bk-input-search.d.ts +1 -1
  64. package/dist/components/bk-input-search.js +2 -1
  65. package/dist/components/bk-input-text.d.ts +11 -0
  66. package/dist/components/bk-input-text.js +17 -3
  67. package/dist/components/bk-input-time.js +2 -1
  68. package/dist/components/bk-item.js +2 -1
  69. package/dist/components/bk-lightbox.d.ts +12 -3
  70. package/dist/components/bk-lightbox.js +6 -3
  71. package/dist/components/bk-link.d.ts +9 -1
  72. package/dist/components/bk-link.js +14 -4
  73. package/dist/components/bk-menu-item.d.ts +40 -0
  74. package/dist/components/bk-menu-item.js +57 -9
  75. package/dist/components/bk-menu-label.js +2 -1
  76. package/dist/components/bk-menu-list.d.ts +1 -0
  77. package/dist/components/bk-menu-list.js +10 -0
  78. package/dist/components/bk-menu.d.ts +8 -1
  79. package/dist/components/bk-menu.js +16 -5
  80. package/dist/components/bk-message-feedback.d.ts +4 -3
  81. package/dist/components/bk-message-feedback.js +7 -5
  82. package/dist/components/bk-message-list.js +2 -1
  83. package/dist/components/bk-message-source.d.ts +1 -2
  84. package/dist/components/bk-message-source.js +3 -11
  85. package/dist/components/bk-message.js +2 -0
  86. package/dist/components/bk-nav-group.js +1 -1
  87. package/dist/components/bk-nav-item.d.ts +18 -0
  88. package/dist/components/bk-nav-item.js +18 -5
  89. package/dist/components/bk-nav.d.ts +1 -1
  90. package/dist/components/bk-page-cta.js +2 -0
  91. package/dist/components/bk-page-section.d.ts +1 -1
  92. package/dist/components/bk-page-section.js +3 -9
  93. package/dist/components/bk-pane.d.ts +1 -0
  94. package/dist/components/bk-pane.js +7 -5
  95. package/dist/components/bk-panel.d.ts +1 -1
  96. package/dist/components/bk-panel.js +6 -5
  97. package/dist/components/bk-picture.d.ts +17 -4
  98. package/dist/components/bk-picture.js +8 -1
  99. package/dist/components/bk-segmented-item.d.ts +24 -4
  100. package/dist/components/bk-segmented-item.js +37 -5
  101. package/dist/components/bk-segmented.js +2 -13
  102. package/dist/components/bk-select-cascade.d.ts +1 -1
  103. package/dist/components/bk-select-tree.d.ts +1 -1
  104. package/dist/components/bk-select.d.ts +1 -1
  105. package/dist/components/bk-shell-app.d.ts +10 -4
  106. package/dist/components/bk-shell-app.js +32 -9
  107. package/dist/components/bk-shell-sites.d.ts +2 -1
  108. package/dist/components/bk-shell-sites.js +3 -5
  109. package/dist/components/bk-sortable.js +7 -17
  110. package/dist/components/bk-split-grid.d.ts +104 -3
  111. package/dist/components/bk-split-grid.js +425 -2
  112. package/dist/components/bk-stat-group.js +2 -1
  113. package/dist/components/bk-stat.d.ts +17 -0
  114. package/dist/components/bk-stat.js +7 -3
  115. package/dist/components/bk-steps.js +2 -1
  116. package/dist/components/bk-surface.d.ts +2 -0
  117. package/dist/components/bk-surface.js +6 -3
  118. package/dist/components/bk-table.d.ts +1 -1
  119. package/dist/components/bk-table.js +9 -12
  120. package/dist/components/bk-tabs-item.d.ts +45 -7
  121. package/dist/components/bk-tabs-item.js +51 -20
  122. package/dist/components/bk-tabs-panel.d.ts +6 -3
  123. package/dist/components/bk-tabs-panel.js +6 -0
  124. package/dist/components/bk-tabs.d.ts +50 -7
  125. package/dist/components/bk-tabs.js +168 -96
  126. package/dist/components/bk-text.js +2 -1
  127. package/dist/components/bk-toast-group.d.ts +3 -1
  128. package/dist/components/bk-toast-group.js +11 -1
  129. package/dist/components/bk-tooltip.d.ts +3 -1
  130. package/dist/components/bk-tooltip.js +2 -1
  131. package/dist/components/bk-video.js +2 -2
  132. package/dist/components/bk-zoom.d.ts +3 -1
  133. package/dist/components/confirm.d.ts +15 -0
  134. package/dist/components/confirm.js +27 -4
  135. package/dist/i18n/de.js +12 -1
  136. package/dist/i18n/en.d.ts +2 -0
  137. package/dist/i18n/en.js +3 -0
  138. package/dist/i18n.d.ts +16 -2
  139. package/dist/i18n.js +28 -4
  140. package/dist/icons/brands-static.d.ts +3 -0
  141. package/dist/icons/brands-static.js +5 -0
  142. package/dist/icons/core.d.ts +1 -0
  143. package/dist/icons/core.js +2 -0
  144. package/dist/icons/load-static.d.ts +3 -0
  145. package/dist/icons/load-static.js +5 -0
  146. package/dist/icons/load.js +1 -0
  147. package/dist/icons/registry.js +1 -1
  148. package/dist/icons/set/save-as.d.ts +3 -0
  149. package/dist/icons/set/save-as.js +7 -0
  150. package/dist/index.d.ts +3 -0
  151. package/dist/index.js +3 -0
  152. package/dist/internal/announcer.d.ts +8 -1
  153. package/dist/internal/announcer.js +26 -10
  154. package/dist/internal/backdrop.d.ts +19 -0
  155. package/dist/internal/backdrop.js +29 -0
  156. package/dist/internal/busy.d.ts +3 -2
  157. package/dist/internal/busy.js +4 -5
  158. package/dist/internal/choice-field.js +1 -1
  159. package/dist/internal/choice-item.d.ts +17 -6
  160. package/dist/internal/choice-item.js +20 -9
  161. package/dist/internal/cloak.js +3 -0
  162. package/dist/internal/crop-frame.d.ts +1 -1
  163. package/dist/internal/crop-frame.js +2 -7
  164. package/dist/internal/date-field.js +2 -1
  165. package/dist/internal/drag.d.ts +11 -0
  166. package/dist/internal/drag.js +23 -0
  167. package/dist/internal/english-static.d.ts +3 -0
  168. package/dist/internal/english-static.js +5 -0
  169. package/dist/internal/english.d.ts +8 -0
  170. package/dist/internal/english.js +6 -0
  171. package/dist/internal/footnotes.d.ts +56 -0
  172. package/dist/internal/footnotes.js +143 -0
  173. package/dist/internal/handle-menu.js +2 -5
  174. package/dist/internal/late/bk-shell-app.d.ts +4 -0
  175. package/dist/internal/late/bk-shell-app.js +7 -0
  176. package/dist/internal/late/bk-table.d.ts +4 -0
  177. package/dist/internal/late/bk-table.js +17 -0
  178. package/dist/internal/late/handle-menu.d.ts +4 -0
  179. package/dist/internal/late/handle-menu.js +9 -0
  180. package/dist/internal/late/static.d.ts +7 -0
  181. package/dist/internal/late/static.js +5 -0
  182. package/dist/internal/late.d.ts +8 -3
  183. package/dist/internal/late.js +19 -4
  184. package/dist/internal/link.d.ts +2 -0
  185. package/dist/internal/link.js +11 -1
  186. package/dist/internal/own-text.d.ts +8 -0
  187. package/dist/internal/own-text.js +7 -0
  188. package/dist/internal/scope.js +1 -1
  189. package/dist/internal/scroll-lock.d.ts +4 -1
  190. package/dist/internal/scroll-lock.js +17 -4
  191. package/dist/internal/slider.js +2 -1
  192. package/dist/internal/styles.js +3 -0
  193. package/dist/internal/submit.d.ts +23 -0
  194. package/dist/internal/submit.js +57 -0
  195. package/dist/jsx.d.ts +141 -52
  196. package/dist/reset.css +10 -0
  197. package/dist/standalone/all.js +226 -222
  198. package/dist/standalone/appearance.js +1 -1
  199. package/dist/standalone/bk-accordion-item.js +4 -4
  200. package/dist/standalone/bk-accordion.js +2 -2
  201. package/dist/standalone/bk-action-bar.js +3 -3
  202. package/dist/standalone/bk-alert-offline.js +1 -2
  203. package/dist/standalone/bk-alert.js +13 -12
  204. package/dist/standalone/bk-app-state.js +1 -1
  205. package/dist/standalone/bk-attachment.js +4 -4
  206. package/dist/standalone/bk-avatar-group.js +12 -10
  207. package/dist/standalone/bk-avatar.js +14 -4
  208. package/dist/standalone/bk-badge.js +2 -2
  209. package/dist/standalone/bk-bar.js +3 -1
  210. package/dist/standalone/bk-brand.js +3 -3
  211. package/dist/standalone/bk-breadcrumbs.js +5 -5
  212. package/dist/standalone/bk-button-copy.js +5 -5
  213. package/dist/standalone/bk-button-group.js +5 -5
  214. package/dist/standalone/bk-button-share.js +5 -5
  215. package/dist/standalone/bk-button-top.js +9 -8
  216. package/dist/standalone/bk-button.js +62 -30
  217. package/dist/standalone/bk-calendar-event.js +1 -1
  218. package/dist/standalone/bk-calendar-week.js +3 -3
  219. package/dist/standalone/bk-calendar.js +4 -4
  220. package/dist/standalone/bk-card.js +20 -7
  221. package/dist/standalone/bk-carousel-controls.js +7 -6
  222. package/dist/standalone/bk-carousel-item.js +2 -2
  223. package/dist/standalone/bk-carousel.js +1 -1
  224. package/dist/standalone/bk-chart-area.js +1 -1
  225. package/dist/standalone/bk-chart-bar-list.js +8 -8
  226. package/dist/standalone/bk-chart-bar.js +145 -117
  227. package/dist/standalone/bk-chart-bridge.js +7 -7
  228. package/dist/standalone/bk-chart-bullet.js +6 -6
  229. package/dist/standalone/bk-chart-calendar.js +7 -7
  230. package/dist/standalone/bk-chart-heatmap.js +7 -7
  231. package/dist/standalone/bk-chart-histogram.js +5 -5
  232. package/dist/standalone/bk-chart-legend.js +6 -6
  233. package/dist/standalone/bk-chart-line.js +116 -103
  234. package/dist/standalone/bk-chart-mark.js +1 -1
  235. package/dist/standalone/bk-chart-scatter.js +6 -6
  236. package/dist/standalone/bk-chart-sparkline.js +6 -6
  237. package/dist/standalone/bk-chart-stacked-bar.js +7 -7
  238. package/dist/standalone/bk-chart-tracker.js +6 -6
  239. package/dist/standalone/bk-chart-waterfall.js +6 -6
  240. package/dist/standalone/bk-checkbox-group.js +4 -4
  241. package/dist/standalone/bk-checkbox.js +4 -4
  242. package/dist/standalone/bk-chip-group.js +9 -5
  243. package/dist/standalone/bk-chip.js +56 -17
  244. package/dist/standalone/bk-cluster.js +1 -1
  245. package/dist/standalone/bk-code-diff.js +4 -4
  246. package/dist/standalone/bk-code-stack.js +4 -4
  247. package/dist/standalone/bk-code.js +10 -6
  248. package/dist/standalone/bk-color-panel.js +5 -5
  249. package/dist/standalone/bk-columns.js +13 -5
  250. package/dist/standalone/bk-combobox.js +9 -8
  251. package/dist/standalone/bk-command-menu.js +6 -6
  252. package/dist/standalone/bk-command-palette.js +6 -5
  253. package/dist/standalone/bk-composer.js +6 -6
  254. package/dist/standalone/bk-delta.js +11 -10
  255. package/dist/standalone/bk-diagram.js +1 -1
  256. package/dist/standalone/bk-dialog.js +1 -1
  257. package/dist/standalone/bk-disclosure.js +7 -5
  258. package/dist/standalone/bk-divider.js +2 -2
  259. package/dist/standalone/bk-drawer.js +3 -3
  260. package/dist/standalone/bk-drop-target.js +12 -6
  261. package/dist/standalone/bk-empty-state.js +3 -3
  262. package/dist/standalone/bk-error-summary.js +9 -6
  263. package/dist/standalone/bk-facts-item.js +2 -2
  264. package/dist/standalone/bk-facts.js +9 -8
  265. package/dist/standalone/bk-feature.js +3 -3
  266. package/dist/standalone/bk-fieldset.js +3 -3
  267. package/dist/standalone/bk-filter-bar.js +4 -4
  268. package/dist/standalone/bk-folder-browser.js +4 -4
  269. package/dist/standalone/bk-footnote.js +82 -0
  270. package/dist/standalone/bk-footnotes-item.js +122 -0
  271. package/dist/standalone/bk-footnotes.js +37 -0
  272. package/dist/standalone/bk-form-guard.js +2 -2
  273. package/dist/standalone/bk-form-steps.js +3 -3
  274. package/dist/standalone/bk-grid.js +1 -1
  275. package/dist/standalone/bk-icon-tile.js +3 -3
  276. package/dist/standalone/bk-icon.js +1 -1
  277. package/dist/standalone/bk-image-compare.js +88 -47
  278. package/dist/standalone/bk-image-crop.js +6 -6
  279. package/dist/standalone/bk-image-editor.js +1 -1
  280. package/dist/standalone/bk-image-viewer.js +180 -59
  281. package/dist/standalone/bk-input-code.js +4 -4
  282. package/dist/standalone/bk-input-color.js +4 -4
  283. package/dist/standalone/bk-input-date-range.js +2 -2
  284. package/dist/standalone/bk-input-date.js +2 -2
  285. package/dist/standalone/bk-input-file.js +5 -5
  286. package/dist/standalone/bk-input-group.js +4 -4
  287. package/dist/standalone/bk-input-inline.js +17 -10
  288. package/dist/standalone/bk-input-number.js +9 -8
  289. package/dist/standalone/bk-input-rating.js +6 -6
  290. package/dist/standalone/bk-input-rich.js +1 -1
  291. package/dist/standalone/bk-input-search.js +23 -22
  292. package/dist/standalone/bk-input-slider-range.js +5 -5
  293. package/dist/standalone/bk-input-slider.js +5 -5
  294. package/dist/standalone/bk-input-text.js +1 -1
  295. package/dist/standalone/bk-input-time-zone.js +1 -1
  296. package/dist/standalone/bk-input-time.js +29 -28
  297. package/dist/standalone/bk-item-group.js +3 -3
  298. package/dist/standalone/bk-item.js +12 -11
  299. package/dist/standalone/bk-kbd-shortcuts.js +4 -3
  300. package/dist/standalone/bk-kbd.js +68 -1
  301. package/dist/standalone/bk-lightbox.js +11 -7
  302. package/dist/standalone/bk-lines.js +1 -1
  303. package/dist/standalone/bk-link.js +33 -19
  304. package/dist/standalone/bk-listbox-columns.js +6 -6
  305. package/dist/standalone/bk-listbox-item.js +1 -1
  306. package/dist/standalone/bk-listbox-search.js +7 -7
  307. package/dist/standalone/bk-listbox-transfer.js +6 -6
  308. package/dist/standalone/bk-listbox.js +7 -7
  309. package/dist/standalone/bk-logo-wall.js +2 -2
  310. package/dist/standalone/bk-logo.js +3 -3
  311. package/dist/standalone/bk-menu-bar.js +3 -3
  312. package/dist/standalone/bk-menu-context.js +1 -1
  313. package/dist/standalone/bk-menu-divider.js +2 -2
  314. package/dist/standalone/bk-menu-item.js +73 -29
  315. package/dist/standalone/bk-menu-label.js +7 -6
  316. package/dist/standalone/bk-menu-list.js +10 -4
  317. package/dist/standalone/bk-menu.js +19 -10
  318. package/dist/standalone/bk-message-approval.js +4 -4
  319. package/dist/standalone/bk-message-branches.js +3 -3
  320. package/dist/standalone/bk-message-citation.js +10 -10
  321. package/dist/standalone/bk-message-feedback.js +10 -6
  322. package/dist/standalone/bk-message-list.js +6 -5
  323. package/dist/standalone/bk-message-reasoning.js +5 -5
  324. package/dist/standalone/bk-message-source.js +13 -21
  325. package/dist/standalone/bk-message-tool-group.js +5 -5
  326. package/dist/standalone/bk-message-tool.js +5 -5
  327. package/dist/standalone/bk-message.js +6 -4
  328. package/dist/standalone/bk-meter.js +3 -3
  329. package/dist/standalone/bk-model-viewer.js +1 -1
  330. package/dist/standalone/bk-nav-divider.js +2 -2
  331. package/dist/standalone/bk-nav-group.js +6 -6
  332. package/dist/standalone/bk-nav-item.js +31 -23
  333. package/dist/standalone/bk-nav-toc.js +3 -3
  334. package/dist/standalone/bk-nav.js +3 -3
  335. package/dist/standalone/bk-overflow.js +3 -3
  336. package/dist/standalone/bk-page-cta.js +5 -3
  337. package/dist/standalone/bk-page-footer-column.js +2 -2
  338. package/dist/standalone/bk-page-footer.js +3 -3
  339. package/dist/standalone/bk-page-header.js +3 -3
  340. package/dist/standalone/bk-page-hero.js +3 -3
  341. package/dist/standalone/bk-page-pager.js +5 -5
  342. package/dist/standalone/bk-page-section.js +6 -6
  343. package/dist/standalone/bk-pagination.js +6 -6
  344. package/dist/standalone/bk-pane.js +10 -9
  345. package/dist/standalone/bk-panel.js +9 -10
  346. package/dist/standalone/bk-period-nav.js +4 -4
  347. package/dist/standalone/bk-picture.js +24 -15
  348. package/dist/standalone/bk-popover-help.js +3 -3
  349. package/dist/standalone/bk-popover.js +2 -2
  350. package/dist/standalone/bk-presence-cursor.js +2 -2
  351. package/dist/standalone/bk-preview.js +4 -4
  352. package/dist/standalone/bk-progress.js +3 -3
  353. package/dist/standalone/bk-prose.js +3 -3
  354. package/dist/standalone/bk-qr-code.js +1 -1
  355. package/dist/standalone/bk-radio-group.js +4 -4
  356. package/dist/standalone/bk-radio.js +3 -3
  357. package/dist/standalone/bk-rating.js +5 -5
  358. package/dist/standalone/bk-scroll.js +3 -3
  359. package/dist/standalone/bk-segmented-item.js +40 -16
  360. package/dist/standalone/bk-segmented.js +15 -13
  361. package/dist/standalone/bk-select-cascade.js +3 -3
  362. package/dist/standalone/bk-select-tree.js +4 -4
  363. package/dist/standalone/bk-select.js +5 -5
  364. package/dist/standalone/bk-shell-app.js +1 -1221
  365. package/dist/standalone/bk-shell-centered.js +2 -2
  366. package/dist/standalone/bk-shell-sites.js +5 -7
  367. package/dist/standalone/bk-skeleton.js +2 -2
  368. package/dist/standalone/bk-sortable.js +55 -60
  369. package/dist/standalone/bk-spinner.js +2 -2
  370. package/dist/standalone/bk-split-grid.js +318 -41
  371. package/dist/standalone/bk-split.js +4 -4
  372. package/dist/standalone/bk-stack.js +1 -1
  373. package/dist/standalone/bk-stat-group.js +8 -7
  374. package/dist/standalone/bk-stat.js +11 -8
  375. package/dist/standalone/bk-status-dot.js +3 -3
  376. package/dist/standalone/bk-steps-item.js +5 -5
  377. package/dist/standalone/bk-steps.js +8 -7
  378. package/dist/standalone/bk-surface.js +1 -1
  379. package/dist/standalone/bk-swatch-group.js +4 -4
  380. package/dist/standalone/bk-swatch-palette.js +1 -1
  381. package/dist/standalone/bk-swatch.js +2 -2
  382. package/dist/standalone/bk-switch.js +4 -4
  383. package/dist/standalone/bk-table.js +1 -1937
  384. package/dist/standalone/bk-tabs-item.js +58 -35
  385. package/dist/standalone/bk-tabs-panel.js +7 -3
  386. package/dist/standalone/bk-tabs.js +160 -98
  387. package/dist/standalone/bk-tasks-item.js +4 -4
  388. package/dist/standalone/bk-tasks.js +2 -2
  389. package/dist/standalone/bk-testimonial.js +3 -3
  390. package/dist/standalone/bk-text.js +19 -18
  391. package/dist/standalone/bk-time-countdown.js +4 -4
  392. package/dist/standalone/bk-time-relative.js +3 -3
  393. package/dist/standalone/bk-timeline-item.js +4 -4
  394. package/dist/standalone/bk-timeline.js +2 -2
  395. package/dist/standalone/bk-toast-group.js +1 -1
  396. package/dist/standalone/bk-toast.js +4 -4
  397. package/dist/standalone/bk-toolbar.js +2 -2
  398. package/dist/standalone/bk-tooltip.js +8 -7
  399. package/dist/standalone/bk-tree-item.js +6 -6
  400. package/dist/standalone/bk-tree.js +3 -3
  401. package/dist/standalone/bk-video.js +6 -6
  402. package/dist/standalone/bk-visually-hidden.js +2 -2
  403. package/dist/standalone/bk-zoom.js +5 -5
  404. package/dist/standalone/chunks/announcer-D1zrRWwO.js +36 -0
  405. package/dist/standalone/chunks/{appearance-waHnV0kk.js → appearance-CBOJXbmC.js} +1 -1
  406. package/dist/standalone/chunks/{bk-alert-offline-B1bQxOZp.js → bk-alert-offline-Clw0ZSsH.js} +3 -3
  407. package/dist/standalone/chunks/{bk-carousel-BCwIQhG5.js → bk-carousel-Biz7t8sL.js} +4 -4
  408. package/dist/standalone/chunks/{bk-diagram-DWK8CvRZ.js → bk-diagram-D_fQf6SF.js} +5 -5
  409. package/dist/standalone/chunks/{bk-dialog-DX0cPJ1o.js → bk-dialog-DwZyUUHh.js} +59 -25
  410. package/dist/standalone/chunks/{bk-icon-DssFsNuB.js → bk-icon-Bp_flKdv.js} +4 -3
  411. package/dist/standalone/chunks/{bk-image-editor-DXEj9gCu.js → bk-image-editor-BADsoLRL.js} +5 -5
  412. package/dist/standalone/chunks/{bk-input-date-range-Cbx_lpf0.js → bk-input-date-range-DHcJ8-5g.js} +2 -2
  413. package/dist/standalone/chunks/{bk-input-rich-ZB68vziu.js → bk-input-rich-CFhW6vRa.js} +6 -6
  414. package/dist/standalone/chunks/{bk-input-text-DD32uWNO.js → bk-input-text-DviyLBqj.js} +63 -54
  415. package/dist/standalone/chunks/{bk-model-viewer-Dr81ahVv.js → bk-model-viewer-w_Ah4Tvs.js} +4 -4
  416. package/dist/standalone/chunks/{bk-qr-code-QaYvZwOR.js → bk-qr-code-CYMovNVl.js} +3 -3
  417. package/dist/standalone/chunks/bk-shell-app-B2lxHit8.js +1235 -0
  418. package/dist/standalone/chunks/{bk-surface-DkIhrWMt.js → bk-surface-D7e0tErs.js} +9 -7
  419. package/dist/standalone/chunks/{bk-swatch-palette-BNNXTP3w.js → bk-swatch-palette-x13JgJQi.js} +6 -6
  420. package/dist/standalone/chunks/bk-table-CP8n_jy7.js +1944 -0
  421. package/dist/standalone/chunks/{bk-toast-group-BSeO_rPs.js → bk-toast-group-CoL6W7uk.js} +27 -24
  422. package/dist/standalone/chunks/{brush-Bn3lPdHN.js → brush-DALmXSru.js} +18 -2
  423. package/dist/standalone/chunks/{busy-B7Mxemwm.js → busy-BUB22mGY.js} +5 -4
  424. package/dist/standalone/chunks/{chart-tokens-D1Exf7BW.js → chart-tokens-DQ4hVSmn.js} +2 -2
  425. package/dist/standalone/chunks/{choice-field-CGvE4tyb.js → choice-field-poOTerh1.js} +6 -6
  426. package/dist/standalone/chunks/{choice-item-B6-9ZRlf.js → choice-item-Cx-nm1js.js} +17 -8
  427. package/dist/standalone/chunks/{clipboard-Crzt1Sh9.js → clipboard-RqIeP9Uz.js} +1 -1
  428. package/dist/standalone/chunks/{clipboard-BKlrP5rj.js → clipboard-UVLSkL4C.js} +1 -1
  429. package/dist/standalone/chunks/{crop-frame-poLCGrBG.js → crop-frame-Z9N0QML4.js} +1 -11
  430. package/dist/standalone/chunks/{date-field-BlI6grfT.js → date-field-B-fCXa2D.js} +48 -47
  431. package/dist/standalone/chunks/{define-CzVPD4Zi.js → define-DkVeu7e9.js} +1 -1
  432. package/dist/standalone/chunks/drag-DT4__0t9.js +12 -0
  433. package/dist/standalone/chunks/footnotes-BeisMxLk.js +94 -0
  434. package/dist/standalone/chunks/{form-control-CyXQIJ2x.js → form-control-CHpfKAKa.js} +2 -2
  435. package/dist/standalone/chunks/{frame-abXBnl8a.js → frame-xIMVEUCi.js} +5 -4
  436. package/dist/standalone/chunks/{handle-menu-ZVR_msk2.js → handle-menu-BgYUbGO2.js} +26 -19
  437. package/dist/standalone/chunks/{heading-text-CV5gBf7k.js → heading-text-CgnCa_q2.js} +1 -1
  438. package/dist/standalone/chunks/{i18n-B6Al9xCK.js → i18n-DFfGgd3d.js} +49 -34
  439. package/dist/standalone/chunks/{i18n-BI16HQmm.js → i18n-DQAcbHkY.js} +1 -1
  440. package/dist/standalone/chunks/link--YWr8exL.js +69 -0
  441. package/dist/standalone/chunks/{marks-0kbeB4n8.js → marks-pOUDNUf1.js} +2 -2
  442. package/dist/standalone/chunks/{options-DMEc8rQt.js → options-BdC8-KKM.js} +2 -2
  443. package/dist/standalone/chunks/own-text-mpZVnMyX.js +5 -0
  444. package/dist/standalone/chunks/{palettes-CKLHSIPx.js → palettes-J4bQ21ks.js} +2 -2
  445. package/dist/standalone/chunks/{popover-base-ac49G87f.js → popover-base-hxo-Vh6E.js} +2 -2
  446. package/dist/standalone/chunks/{prose-BG4oQH-i.js → prose-BiuJgiah.js} +1 -1
  447. package/dist/standalone/chunks/{ramp-ggoyjMvC.js → ramp-CGDOcqBZ.js} +1 -1
  448. package/dist/standalone/chunks/save-as-DBGZjczB.js +6 -0
  449. package/dist/standalone/chunks/shortcuts-DPxCSO4M.js +210 -0
  450. package/dist/standalone/chunks/{slider-BWT8Fmwz.js → slider-jp3d-Ld-.js} +15 -14
  451. package/dist/standalone/chunks/{stars-BN9M_9Q1.js → stars-BgKEjDQx.js} +1 -1
  452. package/dist/standalone/chunks/{styles-DwSR-9a3.js → styles-CaeyhYDA.js} +3 -0
  453. package/dist/standalone/chunks/submit-BjBGB8OW.js +42 -0
  454. package/dist/standalone/chunks/{summary-BK-B4m5A.js → summary-W5s0TFqV.js} +1 -1
  455. package/dist/standalone/chunks/{text-field-4IUUpRHE.js → text-field-CqhJSAwZ.js} +4 -4
  456. package/dist/standalone/chunks/{toggle-control-ioV2jhNY.js → toggle-control-lvZbQtGW.js} +2 -2
  457. package/dist/standalone/chunks/{tokens-BuahF1lF.js → tokens-C_ul7pL9.js} +4 -3
  458. package/dist/standalone/chunks/{virtual-B-1oN14Y.js → virtual-C_h6sHnm.js} +1 -1
  459. package/dist/standalone/confirm.js +27 -14
  460. package/dist/standalone/i18n-de.js +13 -2
  461. package/dist/standalone/icons.js +100 -98
  462. package/dist/standalone/links.js +1 -1
  463. package/dist/standalone/reset.css +10 -0
  464. package/dist/standalone/toast.js +1 -1
  465. package/dist/standalone/tokens.css +6 -5
  466. package/dist/tokens.css +6 -5
  467. package/dist/tokens.js +4 -3
  468. package/package.json +25 -2
  469. package/dist/standalone/chunks/announcer-haFcvqbe.js +0 -25
  470. package/dist/standalone/chunks/bk-kbd-B_TlKzWj.js +0 -275
  471. package/dist/standalone/chunks/link-CWSMsx04.js +0 -60
@@ -1,1937 +1 @@
1
- import { a as e, d as t, n, r, t as i, u as a } from "./chunks/lit-D8x-qXgH.js";
2
- import { t as o } from "./chunks/style-map-BMvn17E7.js";
3
- import { i as s, n as c, r as l, t as u } from "./chunks/define-CzVPD4Zi.js";
4
- import { t as d } from "./chunks/announcer-haFcvqbe.js";
5
- import { i as f, n as p, o as m, t as h } from "./chunks/link-CWSMsx04.js";
6
- import { i as g, n as _ } from "./chunks/events-DQ4e9cPN.js";
7
- import { t as v } from "./chunks/state-XYmTmnOw.js";
8
- import { t as ee } from "./chunks/light-styles-CFbyUU7I.js";
9
- import { t as y } from "./chunks/slots-BHTtBbPo.js";
10
- import { n as b, t as x } from "./chunks/busy-B7Mxemwm.js";
11
- import { n as S, t as C } from "./chunks/virtual-B-1oN14Y.js";
12
- import { a as w, i as T, n as E, o as D, t as O } from "./chunks/handle-menu-ZVR_msk2.js";
13
- import { c as k, i as A, n as j } from "./chunks/anchor-CNX3nt2F.js";
14
- import { t as te } from "./chunks/clipboard-BKlrP5rj.js";
15
- import { t as M } from "./chunks/i18n-B6Al9xCK.js";
16
- import { S as N, f as P, t as F } from "./chunks/styles-DwSR-9a3.js";
17
- import "./bk-button.js";
18
- import "./chunks/bk-icon-DssFsNuB.js";
19
- import "./chunks/add-CUFUzxGc.js";
20
- import "./chunks/arrow-back-DJBwVPZy.js";
21
- import "./chunks/arrow-down-yAm1AGV7.js";
22
- import "./chunks/arrow-forward-vijvTQ6r.js";
23
- import "./chunks/arrow-up-BfHTuP3c.js";
24
- import "./chunks/check-BkWcIJJJ.js";
25
- import "./chunks/chevron-right-CxqvZ6TS.js";
26
- import "./chunks/drag-indicator--UOafVoi.js";
27
- import "./chunks/filter-CCC4hLkS.js";
28
- import "./chunks/grid-BV0_DQ5v.js";
29
- import "./chunks/keyboard-Cq9klEyN.js";
30
- import "./chunks/more-vert-u8TDwpwH.js";
31
- import "./chunks/refresh-BeOCgDeL.js";
32
- import "./chunks/remove-3A4Fpn3J.js";
33
- import "./chunks/unfold-more-CcOFYpUE.js";
34
- import "./chunks/visibility-off-urFZQ4oB.js";
35
- // dist/components/bk-table.js
36
- var I = new w(() => import("./bk-checkbox.js")), L = new w(() => Promise.all([import("./bk-filter-bar.js"), import("./bk-popover.js")])), R = new w(() => Promise.all([
37
- import("./bk-menu-context.js"),
38
- import("./bk-menu-item.js"),
39
- import("./bk-menu-divider.js"),
40
- import("./bk-menu-label.js")
41
- ])), z = new w(() => Promise.all([import("./bk-input-number.js"), import("./bk-input-text.js")])), B = new w(() => import("./bk-skeleton.js")), V = 48, H = 16, U = 64, W = 3, G = 10, K = "[data-bk-select], [data-bk-handle]", q = "button, a[href], input, select, textarea, bk-checkbox, bk-button, bk-switch, bk-link, bk-select, .bk-table-resize, [tabindex]:not(td, th, tr)", J = "button, a[href], input, select, textarea, label, summary, [contenteditable], [role='button'], [tabindex]:not(td, th, tr), [data-row-action], bk-button, bk-button-copy, bk-button-share, bk-checkbox, bk-switch, bk-link, bk-select, bk-menu, bk-input-inline, bk-input-rating", Y = ":scope > table > :is(thead, tbody:not([data-bk-state]), tfoot) > tr:not([data-bk-spacer])", X = (e) => (e ?? "").replace(/\s+/g, " ").trim(), Z = /* @__PURE__ */ new Set(["true", "yes"]), ne = /* @__PURE__ */ new Set([
42
- "false",
43
- "no",
44
- ""
45
- ]), Q = (e) => e == null || e === "" || e === !1 || Array.isArray(e) && e.length === 0, re = (e, t) => e.includes(t) || /["\r\n]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e, ie = a`
46
- @layer bk.components {
47
- bk-table > table {
48
- inline-size: 100%; border-collapse: separate; border-spacing: 0;
49
- font-family: var(--bk-font); font-size: var(--bk-table-font-size, var(--bk-type-small));
50
- line-height: var(--bk-line-height-body); color: var(--bk-table-fg, var(--bk-text));
51
- }
52
- bk-table > table > caption {
53
- caption-side: top; text-align: start; padding-block-end: var(--bk-table-caption-gap, var(--bk-space-2));
54
- color: var(--bk-table-caption-fg, var(--bk-text-muted)); font-size: var(--bk-table-caption-size, var(--bk-type-small));
55
- }
56
- bk-table > table > * > tr > :is(th, td) {
57
- padding: var(--_bk-table-pad) var(--bk-table-cell-pad-inline, var(--bk-space-3));
58
- text-align: start; vertical-align: middle; box-sizing: border-box;
59
- border-block-end: var(--bk-border-width) solid var(--bk-table-border, var(--bk-line));
60
- }
61
- bk-table > table > * > tr > :is(th, td):first-child { padding-inline-start: var(--bk-table-edge, var(--bk-table-cell-pad-inline, var(--bk-space-3))); }
62
- bk-table > table > * > tr > :is(th, td):last-child { padding-inline-end: var(--bk-table-edge, var(--bk-table-cell-pad-inline, var(--bk-space-3))); }
63
- bk-table[flush] { --bk-table-edge: 0px; }
64
- bk-table > table > thead > tr > th {
65
- font-weight: var(--bk-table-head-weight, var(--bk-group-label-weight, var(--bk-label-weight, var(--bk-weight-medium)))); color: var(--bk-table-head-fg, var(--bk-group-label-color, var(--bk-text-muted)));
66
- font-size: var(--bk-table-head-size, var(--bk-group-label-size, 1em));
67
- line-height: var(--bk-table-head-leading, var(--bk-line-height-heading));
68
- text-transform: var(--bk-group-label-transform, var(--bk-label-transform, none)); letter-spacing: var(--bk-group-label-tracking, var(--bk-label-tracking, normal)); font-family: var(--bk-font-label, inherit);
69
- background: var(--bk-table-head-bg, transparent); white-space: nowrap;
70
- }
71
- bk-table > table > tbody > tr > th { font-weight: var(--bk-table-row-head-weight, var(--bk-weight-medium)); }
72
- bk-table > table > tbody:last-child > tr:last-child > :is(th, td) { border-block-end: 0; }
73
- bk-table > table > tfoot > tr > :is(th, td) {
74
- font-weight: var(--bk-table-foot-weight, var(--bk-weight-medium)); border-block-start: var(--bk-border-width) solid var(--bk-table-border-strong, var(--bk-line-strong)); border-block-end: 0;
75
- background: var(--bk-table-foot-bg, transparent);
76
- }
77
- bk-table > table > * > tr > [data-type="number"] { text-align: end; font-variant-numeric: tabular-nums; }
78
- /* Yes/no cells: a mark in place of the value, centred in the column. A text value of the column ("Unlimited") centres too. */
79
- bk-table > table > * > tr > :is([data-bk-check], [data-bk-check-column], th[data-type="check"]) { text-align: center; }
80
- bk-table > table > * > tr > [data-bk-check] > .bk-table-check {
81
- display: inline-flex; align-items: center; justify-content: center; vertical-align: top;
82
- block-size: var(--bk-line-height-body); color: var(--bk-table-check-yes-fg, var(--bk-success-text));
83
- }
84
- bk-table > table > * > tr > [data-bk-check="no"] > .bk-table-check { color: var(--bk-table-check-no-fg, var(--bk-text-faint)); }
85
- bk-table > table > * > tr > [data-bk-check] > .bk-table-check > bk-icon { --bk-icon-size: var(--bk-table-check-size, var(--bk-icon-sm)); }
86
- /* The highlighted column: a tint and a frame from the header to the last row. Inset shadows, so the layout stays. */
87
- bk-table > table > * > tr > [data-bk-highlight] {
88
- --_bk-table-hl-w: var(--bk-table-highlight-border-width, var(--bk-border-width));
89
- --_bk-table-hl-c: var(--bk-table-highlight-border, var(--bk-accent-solid));
90
- background-color: var(--bk-table-highlight-bg, var(--bk-accent-soft));
91
- box-shadow: inset var(--_bk-table-hl-w) 0 0 0 var(--_bk-table-hl-c), inset calc(-1 * var(--_bk-table-hl-w)) 0 0 0 var(--_bk-table-hl-c);
92
- }
93
- bk-table > table > * > tr > [data-bk-highlight="first"] {
94
- box-shadow: inset var(--_bk-table-hl-w) 0 0 0 var(--_bk-table-hl-c), inset calc(-1 * var(--_bk-table-hl-w)) 0 0 0 var(--_bk-table-hl-c), inset 0 var(--_bk-table-hl-w) 0 0 var(--_bk-table-hl-c);
95
- }
96
- bk-table > table > * > tr > [data-bk-highlight="last"] {
97
- box-shadow: inset var(--_bk-table-hl-w) 0 0 0 var(--_bk-table-hl-c), inset calc(-1 * var(--_bk-table-hl-w)) 0 0 0 var(--_bk-table-hl-c), inset 0 calc(-1 * var(--_bk-table-hl-w)) 0 0 var(--_bk-table-hl-c);
98
- }
99
- bk-table > table > thead > tr > th[data-bk-highlight] { color: var(--bk-table-highlight-head-fg, var(--bk-accent-text)); }
100
- bk-table[variant="striped"] > table > tbody > tr:nth-child(even) > :is(th, td) { background: var(--bk-table-stripe, var(--bk-hover)); }
101
- /* Stripes are the divider: no hairline runs into the edge of a tinted row. */
102
- bk-table[variant="striped"] > table > tbody > tr > :is(th, td) { border-block-end-color: transparent; }
103
- bk-table[variant="grid"] > table > * > tr > :is(th, td):not(:last-child) { border-inline-end: var(--bk-border-width) solid var(--bk-table-border, var(--bk-line)); }
104
- bk-table > table > tbody > tr:is([data-selected], [aria-selected="true"]) > :is(th, td) { background: var(--bk-table-selected, var(--bk-selected)); }
105
- /* A tinted row has a surface: no divider line runs into its edges (above, below). */
106
- bk-table:not([variant="striped"]) > table > tbody > tr:is([data-selected], [aria-selected="true"], [data-group]) > :is(th, td),
107
- bk-table:not([variant="striped"]) > table > tbody > tr:has(+ tr:is([data-selected], [aria-selected="true"], [data-group])) > :is(th, td) {
108
- border-block-end-color: transparent;
109
- }
110
- /* Row links: the hit area of the link covers the row; the controls of the row stay on top of it. The row is a
111
- stacking context, so its controls never paint over a sticky header. */
112
- bk-table > table > tbody > tr:has(a[data-row-link][href]) { position: relative; z-index: 0; cursor: pointer; }
113
- bk-table > table > tbody > tr > * a[data-row-link][href] { color: var(--bk-table-row-link-fg, inherit); font-weight: var(--bk-table-row-link-weight, inherit); text-decoration: none; }
114
- bk-table > table > tbody > tr > * a[data-row-link][href]::after { content: ""; position: absolute; inset: 0; }
115
- bk-table > table > tbody > tr:has(a[data-row-link][href]) :is(${t(J)}):not([data-row-link]) { position: relative; z-index: 1; }
116
- bk-table > table > tbody > tr > * a[data-row-link][href]:focus { outline: none; }
117
- bk-table > table > tbody > tr > * a[data-row-link][href]:focus-visible::after { outline: var(--bk-focus-ring); outline-offset: var(--bk-focus-offset-inset); }
118
- @media (hover: hover) {
119
- bk-table > table > tbody > tr:hover > * a[data-row-link][href] { text-decoration: underline; }
120
- /* An overlay, so the hover shows on stripes and selected rows too. */
121
- bk-table[hover-rows] > table > tbody > tr:hover > :is(th, td) {
122
- background-image: linear-gradient(var(--bk-table-row-hover, var(--bk-hover)), var(--bk-table-row-hover, var(--bk-hover)));
123
- }
124
- }
125
- /* The sort button fills the header cell beside its tools: a click anywhere in the cell sorts. */
126
- bk-table > table > thead > tr > th > .bk-table-sort {
127
- display: inline-flex; align-items: center; gap: var(--bk-table-sort-gap, var(--bk-space-1)); box-sizing: border-box;
128
- inline-size: calc(100% + 2 * var(--bk-table-sort-pad, var(--bk-space-1)) - var(--_bk-table-sort-tools, 0px));
129
- position: relative; min-block-size: var(--bk-space-6); margin: 0 calc(-1 * var(--bk-table-sort-pad, var(--bk-space-1)));
130
- padding: 0 var(--bk-table-sort-pad, var(--bk-space-1)); border: 0; border-radius: var(--bk-table-sort-radius, var(--bk-radius-xs));
131
- background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: inherit;
132
- cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color var(--bk-duration-fast), color var(--bk-duration-fast);
133
- }
134
- bk-table > table > thead > tr > th > .bk-table-sort::before { content: ""; position: absolute; inset-inline: 0; inset-block: min(0px, calc((100% - var(--bk-target-min)) / 2)); }
135
- @media (hover: hover) {
136
- bk-table > table > thead > tr > th > .bk-table-sort:hover { background: var(--bk-table-sort-hover, var(--bk-hover)); color: var(--bk-table-sort-active-fg, var(--bk-text)); }
137
- }
138
- bk-table > table > thead > tr > th > .bk-table-sort:active { background: var(--bk-pressed); }
139
- bk-table > table > thead > tr > th > .bk-table-sort:focus { outline: none; }
140
- bk-table > table > thead > tr > th > .bk-table-sort:focus-visible { outline: var(--bk-focus-ring); outline-offset: var(--bk-focus-offset-inset); }
141
- bk-table > table > thead > tr > th[aria-sort] > .bk-table-sort { color: var(--bk-table-sort-active-fg, var(--bk-text)); }
142
- bk-table > table > thead > tr > th:has(> .bk-table-tool) > .bk-table-sort {
143
- --_bk-table-sort-tools: calc(var(--bk-table-tool-size, var(--bk-space-6)) + var(--bk-table-tool-gap, var(--bk-space-1)));
144
- }
145
- bk-table > table > thead > tr > th:has(> .bk-table-tool ~ .bk-table-tool) > .bk-table-sort {
146
- --_bk-table-sort-tools: calc(2 * (var(--bk-table-tool-size, var(--bk-space-6)) + var(--bk-table-tool-gap, var(--bk-space-1))));
147
- }
148
- /* Numbers align to the end: the icon goes first, so the labels line up with the figures. In the reversed row the
149
- start of the content is the end of the cell. */
150
- bk-table > table > thead > tr > th[data-type="number"] > .bk-table-sort { flex-direction: row-reverse; }
151
- bk-table > table > thead > tr > th > .bk-table-sort > .bk-table-sort-icon {
152
- --bk-icon-size: var(--bk-table-sort-icon-size, var(--bk-icon-sm)); color: var(--bk-table-sort-icon-fg, var(--bk-text-faint));
153
- }
154
- bk-table > table > thead > tr > th[aria-sort] > .bk-table-sort > .bk-table-sort-icon { color: inherit; }
155
- bk-table[sticky-header] > table > thead > tr > th {
156
- position: sticky; inset-block-start: 0; z-index: 1;
157
- background: var(--bk-table-head-bg, var(--bk-layer-sticky-bg));
158
- }
159
- bk-table[sticky-footer] > table > tfoot > tr > :is(th, td) {
160
- position: sticky; inset-block-end: 0; z-index: 1;
161
- background: var(--bk-table-foot-bg, var(--bk-layer-sticky-bg));
162
- }
163
- bk-table > table > * > tr > * > .bk-table-sr, bk-table > table > * > tr > * > .bk-table-check > .bk-table-sr { ${N} }
164
- /* Header tools: the filter button and the column menu button, ghost icon buttons after the label. */
165
- bk-table > table > thead > tr > th > .bk-table-tool,
166
- bk-table > table > tbody > tr > [data-bk-handle] > .bk-table-handle {
167
- display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; position: relative;
168
- inline-size: var(--bk-table-tool-size, var(--bk-space-6)); block-size: var(--bk-table-tool-size, var(--bk-space-6));
169
- margin-block: calc(-1 * var(--bk-space-1)); padding: 0; border: 0;
170
- border-radius: var(--bk-table-tool-radius, var(--bk-radius-xs)); background: none;
171
- color: var(--bk-table-tool-fg, var(--bk-text-muted)); cursor: pointer; -webkit-tap-highlight-color: transparent;
172
- }
173
- bk-table > table > thead > tr > th > .bk-table-tool { margin-inline-start: var(--bk-table-tool-gap, var(--bk-space-1)); }
174
- bk-table > table > thead > tr > th > .bk-table-tool::before,
175
- bk-table > table > tbody > tr > [data-bk-handle] > .bk-table-handle::before { content: ""; position: absolute; inset: min(0px, calc((100% - var(--bk-target-min)) / 2)); }
176
- bk-table > table > thead > tr > th > .bk-table-tool > bk-icon,
177
- bk-table > table > tbody > tr > [data-bk-handle] > .bk-table-handle > bk-icon { --bk-icon-size: var(--bk-table-tool-icon-size, var(--bk-icon-sm)); }
178
- @media (hover: hover) {
179
- bk-table > table > thead > tr > th > .bk-table-tool:hover,
180
- bk-table > table > tbody > tr > [data-bk-handle] > .bk-table-handle:hover { background: var(--bk-table-tool-hover, var(--bk-hover)); color: var(--bk-text); }
181
- /* The menu button shows where the pointer or the focus is; on touch it always shows. */
182
- bk-table > table > thead > tr > th > .bk-table-menu { opacity: 0; }
183
- bk-table > table > thead > tr > th:is(:hover, :focus-within) > .bk-table-menu,
184
- bk-table > table > thead > tr > th > .bk-table-menu[aria-expanded="true"] { opacity: 1; }
185
- }
186
- bk-table > table > thead > tr > th > .bk-table-tool:active,
187
- bk-table > table > tbody > tr > [data-bk-handle] > .bk-table-handle:active { background: var(--bk-pressed); }
188
- bk-table > table > thead > tr > th > .bk-table-tool:focus,
189
- bk-table > table > tbody > tr > [data-bk-handle] > .bk-table-handle:focus { outline: none; }
190
- bk-table > table > thead > tr > th > .bk-table-tool:focus-visible,
191
- bk-table > table > tbody > tr > [data-bk-handle] > .bk-table-handle:focus-visible { outline: var(--bk-focus-ring); outline-offset: var(--bk-focus-offset-inset); }
192
- bk-table > table > thead > tr > th > .bk-table-filter[data-active] { color: var(--bk-table-filter-active-fg, var(--bk-accent-text)); }
193
- /* Selection and handle columns: narrow. */
194
- bk-table > table > * > tr > :is([data-bk-select], [data-bk-handle]) { inline-size: 1px; white-space: nowrap; }
195
- bk-table > table > * > tr > [data-bk-handle] { padding-inline-end: 0; }
196
- bk-table > table > tbody > tr > [data-bk-handle] > .bk-table-handle { cursor: grab; touch-action: none; }
197
- bk-table > table > tbody > tr[data-bk-lifted] > :is(th, td) { background: var(--bk-table-lifted-bg, var(--bk-layer-raised-bg)); }
198
- bk-table > table > tbody > tr[data-bk-lifted] > [data-bk-handle] > .bk-table-handle { cursor: grabbing; color: var(--bk-text); }
199
- bk-table > table > tbody > tr[data-bk-drop="before"] > :is(th, td) { box-shadow: inset 0 calc(var(--bk-border-width) * 2) 0 0 var(--bk-table-drop-line, var(--bk-accent-solid)); }
200
- bk-table > table > tbody > tr[data-bk-drop="after"] > :is(th, td) { box-shadow: inset 0 calc(var(--bk-border-width) * -2) 0 0 var(--bk-table-drop-line, var(--bk-accent-solid)); }
201
- /* Expandable rows: a disclosure button in the first cell. */
202
- bk-table > table > tbody > tr > * > .bk-table-disclosure {
203
- display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
204
- position: relative; inline-size: var(--bk-space-6); block-size: var(--bk-space-6); margin: calc(-1 * var(--bk-space-1)) var(--bk-space-1) calc(-1 * var(--bk-space-1)) calc(-1 * var(--bk-space-1));
205
- padding: 0; border: 0; border-radius: var(--bk-table-disclosure-radius, var(--bk-radius-xs));
206
- background: none; color: var(--bk-table-disclosure-fg, var(--bk-text-muted)); cursor: pointer; -webkit-tap-highlight-color: transparent;
207
- }
208
- bk-table > table > tbody > tr > * > .bk-table-disclosure::before { content: ""; position: absolute; inset-inline: 0; inset-block: min(0px, calc((100% - var(--bk-target-min)) / 2)); }
209
- bk-table > table > tbody > tr > * > .bk-table-disclosure > bk-icon {
210
- --bk-icon-size: var(--bk-table-disclosure-icon-size, var(--bk-icon-sm));
211
- transition: rotate var(--bk-duration-fast);
212
- }
213
- bk-table > table > tbody > tr > * > .bk-table-disclosure[aria-expanded="true"] > bk-icon,
214
- bk-table > table > tbody > tr[aria-expanded="true"] > * > .bk-table-disclosure > bk-icon { rotate: 90deg; }
215
- bk-table > table > tbody > tr > * > .bk-table-disclosure:dir(rtl) > bk-icon { scale: -1 1; }
216
- @media (hover: hover) {
217
- bk-table > table > tbody > tr > * > .bk-table-disclosure:hover { background: var(--bk-table-disclosure-hover, var(--bk-hover)); color: var(--bk-text); }
218
- }
219
- bk-table > table > tbody > tr > * > .bk-table-disclosure:active { background: var(--bk-pressed); }
220
- bk-table > table > tbody > tr > * > .bk-table-disclosure:focus { outline: none; }
221
- bk-table > table > tbody > tr > * > .bk-table-disclosure:focus-visible { outline: var(--bk-focus-ring); outline-offset: var(--bk-focus-offset-inset); }
222
- bk-table > table > tbody > tr[data-detail] > td { background: var(--bk-table-detail-bg, transparent); }
223
- /* Tree rows: the first cell moves in by the level; a leaf keeps the place of the disclosure button. */
224
- bk-table > table > tbody > tr[data-bk-tree] > [data-bk-indent] {
225
- padding-inline-start: calc(var(--bk-table-edge, var(--bk-table-cell-pad-inline, var(--bk-space-3))) + var(--_bk-table-level, 0) * var(--bk-table-indent, var(--bk-space-4)));
226
- }
227
- bk-table > table > tbody > tr[data-bk-tree]:not([data-bk-parent]) > [data-bk-indent] {
228
- padding-inline-start: calc(var(--bk-table-edge, var(--bk-table-cell-pad-inline, var(--bk-space-3))) + var(--_bk-table-level, 0) * var(--bk-table-indent, var(--bk-space-4)) + var(--bk-space-6));
229
- }
230
- bk-table > table > tbody > tr[data-group] > :is(th, td) {
231
- background: var(--bk-table-group-bg, var(--bk-layer-sunken-bg)); font-weight: var(--bk-table-group-weight, var(--bk-weight-medium));
232
- }
233
- bk-table > table > tbody > tr[data-bk-tree]:focus { outline: none; }
234
- bk-table > table > tbody > tr[data-bk-tree]:focus-visible { outline: var(--bk-focus-ring); outline-offset: var(--bk-focus-offset-inset); }
235
- /* Cell navigation: one cell (or the one control in it) has the focus. */
236
- bk-table[navigation="cell"] > table > * > tr > :is(th, td):focus { outline: none; }
237
- bk-table[navigation="cell"] > table > * > tr > :is(th, td):focus-visible { outline: var(--bk-focus-ring); outline-offset: var(--bk-focus-offset-inset); }
238
- bk-table > table > * > tr > td[data-bk-editing] { position: relative; }
239
- bk-table > table > * > tr > td > .bk-table-editor {
240
- position: absolute; inset: 0; z-index: 2; display: grid; align-content: center;
241
- padding-inline: var(--bk-table-edit-pad, var(--bk-space-1)); background: var(--bk-table-edit-bg, var(--bk-layer-base-bg));
242
- text-align: start; font-weight: var(--bk-weight-regular, normal);
243
- }
244
- /* Resizable columns: a separator handle on the end edge of the header cell. */
245
- :where(bk-table > table > thead > tr > th[data-resizable]) { position: relative; }
246
- bk-table > table > thead > tr > th > .bk-table-resize {
247
- position: absolute; inset-block: 0; inset-inline-end: calc(var(--bk-target-min) / -2); z-index: 3;
248
- inline-size: var(--bk-target-min); cursor: col-resize; touch-action: none; -webkit-tap-highlight-color: transparent;
249
- --_bk-grip-color: var(--bk-table-resize-active-fg, var(--bk-accent-solid));
250
- }
251
- ${P}
252
- bk-table > table > thead > tr > th > .bk-table-resize::after {
253
- content: ""; position: absolute; inset-block: var(--bk-space-1); inset-inline-start: calc(50% - var(--bk-border-width) / 2);
254
- inline-size: var(--bk-border-width); background: var(--bk-table-resize-fg, var(--bk-line-strong));
255
- }
256
- @media (hover: hover) {
257
- bk-table > table > thead > tr > th > .bk-table-resize:hover::after { background: var(--bk-table-resize-active-fg, var(--bk-accent-solid)); inline-size: var(--bk-table-resize-active-size, calc(var(--bk-border-width) * 2)); }
258
- }
259
- bk-table > table > thead > tr > th > .bk-table-resize:focus { outline: none; }
260
- bk-table > table > thead > tr > th > .bk-table-resize:focus-visible::after,
261
- bk-table > table > thead > tr > th > .bk-table-resize[data-dragging]::after { background: var(--bk-table-resize-active-fg, var(--bk-accent-solid)); }
262
- /* Pinned columns stay at the inline start or end; opaque, so the scrolled cells pass beneath. */
263
- bk-table > table > * > tr > :is(th, td)[data-pin] { white-space: nowrap; }
264
- bk-table > table > * > tr > :is(th, td)[data-pin="start"] {
265
- position: sticky; inset-inline-start: var(--_bk-table-pin, 0); z-index: 1;
266
- background: var(--bk-table-pin-bg, var(--bk-layer-base-bg));
267
- }
268
- bk-table > table > * > tr > :is(th, td)[data-pin="end"] {
269
- position: sticky; inset-inline-end: var(--_bk-table-pin, 0); z-index: 1;
270
- background: var(--bk-table-pin-bg, var(--bk-layer-base-bg));
271
- }
272
- bk-table > table > thead > tr > th[data-pin] { z-index: 2; background: var(--bk-table-pin-bg, var(--bk-layer-sticky-bg)); }
273
- bk-table[sticky-footer] > table > tfoot > tr > [data-pin] { z-index: 2; background: var(--bk-table-pin-bg, var(--bk-layer-sticky-bg)); }
274
- bk-table > table > tbody > tr:is([data-selected], [aria-selected="true"]) > :is(th, td)[data-pin] {
275
- background: linear-gradient(var(--bk-table-selected, var(--bk-selected)), var(--bk-table-selected, var(--bk-selected))), var(--bk-table-pin-bg, var(--bk-layer-base-bg));
276
- }
277
- bk-table > table > * > tr > :is(th, td)[data-pin="start"][data-pin-edge] { border-inline-end: var(--bk-border-width) solid var(--bk-table-pin-border, var(--bk-line-strong)); }
278
- bk-table > table > * > tr > :is(th, td)[data-pin="end"][data-pin-edge] { border-inline-start: var(--bk-border-width) solid var(--bk-table-pin-border, var(--bk-line-strong)); }
279
- /* Hidden columns (column menu). */
280
- bk-table > table > * > tr > [data-bk-hidden] { display: none; }
281
- /* Loading: the old rows fade under the veil; the first load shows skeleton rows. */
282
- bk-table[busy] > table > tbody:not([data-bk-state]) > tr > :is(th, td) { opacity: var(--bk-table-busy-opacity, 1); }
283
- bk-table > table > tbody[data-bk-state] > tr > td { border-block-end: var(--bk-border-width) solid var(--bk-table-border, var(--bk-line)); }
284
- bk-table > table > tbody[data-bk-state] > tr > td > bk-skeleton { --bk-skeleton-width: var(--bk-table-skeleton-width, 70%); }
285
- /* An error replaces the rows: they are out of date. */
286
- bk-table:has(> [slot="error"]) > table > tbody { display: none; }
287
- /* Virtual rows: one fixed height, so the table can compute the window. */
288
- bk-table[virtual] > table > tbody > tr:not([data-bk-spacer]) { block-size: var(--bk-table-row-height, var(--bk-control-lg)); }
289
- bk-table[virtual] > table > tbody > tr:not([data-bk-spacer]) > :is(th, td) { white-space: nowrap; padding-block: 0; }
290
- bk-table > table > tbody > tr[data-bk-spacer] > td { padding: 0; border: 0; }
291
- /* Cards on a narrow screen: every row is a card of label and value pairs; the header row keeps its controls. */
292
- bk-table:state(cards) > table,
293
- bk-table:state(cards) > table > :is(thead, tbody, tfoot),
294
- bk-table:state(cards) > table > * > tr { display: block; }
295
- bk-table:state(cards) > table > caption { display: block; }
296
- bk-table:state(cards) > table > thead > tr {
297
- display: flex; flex-wrap: wrap; align-items: center; gap: var(--bk-table-card-gap, var(--bk-space-2));
298
- padding-block-end: var(--bk-table-card-gap, var(--bk-space-2));
299
- }
300
- bk-table:state(cards) > table > thead > tr > th { display: block; position: static; padding: 0; border: 0; background: none; inline-size: auto; }
301
- bk-table:state(cards) > table > thead > tr > th:not(:has(> .bk-table-tool, > bk-checkbox)) { ${N} }
302
- /* The select above the table sorts the cards: the sort buttons of the header cells do not show. */
303
- bk-table:state(cards) > table > thead > tr > th > .bk-table-sort { ${N} }
304
- bk-table:state(cards) > table > thead > tr:not(:has(> th > :is(.bk-table-tool, bk-checkbox))) { padding-block-end: 0; }
305
- bk-table:state(cards) > table > thead > tr > th > .bk-table-resize { display: none; }
306
- /*
307
- * The card is the surface of the row: a selected row and the row under the pointer tint the whole card, not the
308
- * cells inside its padding. The cells have no background of their own in card mode (no stripes, no pin surface).
309
- */
310
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr:not([data-bk-spacer]) > :is(th, td):not([data-bk-handle]) { background: none; }
311
- bk-table:state(cards) > table > tbody > tr:is([data-selected], [aria-selected="true"]) {
312
- background-image: linear-gradient(var(--bk-table-selected, var(--bk-selected)), var(--bk-table-selected, var(--bk-selected)));
313
- }
314
- @media (hover: hover) {
315
- bk-table:state(cards)[hover-rows] > table > tbody > tr:hover {
316
- background-image: linear-gradient(var(--bk-table-row-hover, var(--bk-hover)), var(--bk-table-row-hover, var(--bk-hover)));
317
- }
318
- bk-table:state(cards)[hover-rows] > table > tbody > tr:is([data-selected], [aria-selected="true"]):hover {
319
- background-image: linear-gradient(var(--bk-table-row-hover, var(--bk-hover)), var(--bk-table-row-hover, var(--bk-hover))),
320
- linear-gradient(var(--bk-table-selected, var(--bk-selected)), var(--bk-table-selected, var(--bk-selected)));
321
- }
322
- }
323
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr {
324
- margin-block-end: var(--bk-table-card-gap, var(--bk-space-2)); padding: var(--bk-table-card-padding, var(--bk-space-3));
325
- border: var(--bk-border-width) solid var(--bk-table-card-border, var(--bk-layer-raised-border));
326
- border-radius: var(--bk-table-card-radius, var(--bk-radius-container, var(--bk-radius-md)));
327
- background: var(--bk-table-card-bg, var(--bk-layer-raised-bg));
328
- }
329
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > :is(th, td) {
330
- display: flex; justify-content: space-between; align-items: baseline; gap: var(--bk-table-card-label-gap, var(--bk-space-3));
331
- position: static; padding: var(--bk-table-card-row-pad, var(--bk-space-1)) 0; border: 0; text-align: end; inline-size: auto;
332
- }
333
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > [data-bk-label]::before {
334
- content: attr(data-bk-label) / ""; text-align: start; color: var(--bk-table-head-fg, var(--bk-text-muted));
335
- font-weight: var(--bk-table-head-weight, var(--bk-weight-medium));
336
- }
337
- /*
338
- * A text value stands at the end beside its label while it fits on the line. A longer value wraps as a whole under
339
- * the label: it starts at the start edge and takes the full width. A number stays at the end beside its label.
340
- */
341
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > [data-bk-label]:not([data-bk-number], [data-type="number"], [data-bk-check]) {
342
- flex-wrap: wrap; row-gap: var(--bk-table-card-block-gap, var(--bk-space-1)); text-align: start;
343
- }
344
- /* th[data-card="block"]: the value always stands under its label. */
345
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > [data-bk-card="block"] { display: block; text-align: start; }
346
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > [data-bk-card="block"][data-bk-label]::before {
347
- display: block; margin-block-end: var(--bk-table-card-block-gap, var(--bk-space-1));
348
- }
349
- /* A row header in the body is the title of the card, unless its column gives it another place (data-card). */
350
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > [data-bk-card="title"],
351
- bk-table:state(cards) > table > tbody > tr > th:not([data-bk-card], ${t(K)}) {
352
- justify-content: start; text-align: start; font-size: var(--bk-table-card-title-size, var(--bk-type-body, 1em));
353
- font-weight: var(--bk-table-card-title-weight, var(--bk-weight-semibold, var(--bk-weight-medium)));
354
- }
355
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > :is([data-bk-card="hidden"], [data-bk-handle]) { display: none; }
356
- /*
357
- * th[data-card="meta"]: a short value without its label (a position, a change) is in the head of the card,
358
- * in the order of the row, next to the title and the checkbox. The other cells follow in full rows.
359
- */
360
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr:has(> [data-bk-card="meta"]) {
361
- display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--bk-table-card-meta-gap, var(--bk-space-2));
362
- }
363
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr:has(> [data-bk-card="meta"]) > * { flex: 1 0 100%; order: 1; }
364
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr:has(> [data-bk-card="meta"]) > :is([data-bk-card="meta"], [data-bk-select]) {
365
- flex: none; order: 0;
366
- }
367
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr:has(> [data-bk-card="meta"]) > :is([data-bk-card="title"], th:not([data-bk-card], ${t(K)})) {
368
- /* The title keeps the width of its longest word (at most the card): a meta value that does not fit then wraps under it. */
369
- flex: 1 1 0; min-inline-size: min(min-content, 100%); order: 0;
370
- }
371
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > [data-bk-card="meta"] {
372
- justify-content: start; align-items: center; gap: var(--bk-table-card-meta-gap, var(--bk-space-2)); max-inline-size: 100%;
373
- text-align: start; color: var(--bk-table-card-meta-fg, var(--bk-text-muted));
374
- }
375
- /* An open row and its detail form one card. The text of the detail starts at the start edge. */
376
- bk-table:state(cards) > table > tbody > tr:has(+ tr[data-detail]:not([hidden])) {
377
- margin-block-end: 0; border-end-start-radius: 0; border-end-end-radius: 0;
378
- }
379
- bk-table:state(cards) > table > tbody > tr[data-detail] {
380
- border-block-start-style: dashed; border-start-start-radius: 0; border-start-end-radius: 0;
381
- }
382
- bk-table:state(cards) > table > tbody > tr[data-detail] > td { display: block; text-align: start; }
383
- /* A closed detail row and the hidden rows of a closed tree stay hidden in card mode too. */
384
- bk-table:state(cards) > table > :is(thead, tbody, tfoot) > tr[hidden] { display: none; }
385
- bk-table:state(cards) > table > :is(tbody, tfoot) > tr > [data-bk-select] { justify-content: start; }
386
- @media (forced-colors: active) {
387
- bk-table > table > * > tr > [data-bk-highlight] { --_bk-table-hl-c: Highlight; forced-color-adjust: none; background-color: Canvas; color: CanvasText; }
388
- bk-table > table > * > tr > [data-bk-check] > .bk-table-check { color: CanvasText; }
389
- bk-table > table > tbody > tr[data-bk-drop] { outline: calc(var(--bk-border-width) * 2) solid Highlight; }
390
- bk-table > table > thead > tr > th > .bk-table-filter[data-active] { color: Highlight; }
391
- }
392
- @media (prefers-reduced-motion: reduce) {
393
- bk-table > table > tbody > tr > * > .bk-table-disclosure > bk-icon { transition: none; }
394
- }
395
- }
396
- `, $ = class extends i {
397
- static properties = {
398
- variant: {
399
- reflect: !0,
400
- useDefault: !0
401
- },
402
- stickyHeader: {
403
- type: Boolean,
404
- reflect: !0,
405
- useDefault: !0,
406
- attribute: "sticky-header"
407
- },
408
- stickyFooter: {
409
- type: Boolean,
410
- reflect: !0,
411
- useDefault: !0,
412
- attribute: "sticky-footer"
413
- },
414
- hoverRows: {
415
- type: Boolean,
416
- reflect: !0,
417
- useDefault: !0,
418
- attribute: "hover-rows"
419
- },
420
- surface: {
421
- type: Boolean,
422
- reflect: !0,
423
- useDefault: !0
424
- },
425
- flush: {
426
- type: Boolean,
427
- reflect: !0,
428
- useDefault: !0
429
- },
430
- sortable: {
431
- type: Boolean,
432
- reflect: !0,
433
- useDefault: !0
434
- },
435
- sortKey: {
436
- reflect: !0,
437
- attribute: "sort-key"
438
- },
439
- sortDir: {
440
- reflect: !0,
441
- useDefault: !0,
442
- attribute: "sort-dir"
443
- },
444
- selection: { reflect: !0 },
445
- navigation: { reflect: !0 },
446
- columnMenu: {
447
- type: Boolean,
448
- reflect: !0,
449
- useDefault: !0,
450
- attribute: "column-menu"
451
- },
452
- reorderable: {
453
- type: Boolean,
454
- reflect: !0,
455
- useDefault: !0
456
- },
457
- responsive: { reflect: !0 },
458
- busy: {
459
- type: Boolean,
460
- reflect: !0,
461
- useDefault: !0
462
- },
463
- busyLabel: { attribute: "busy-label" },
464
- skeletonRows: {
465
- type: Number,
466
- attribute: "skeleton-rows"
467
- },
468
- virtual: {
469
- type: Boolean,
470
- reflect: !0,
471
- useDefault: !0
472
- },
473
- rows: { attribute: !1 },
474
- renderRow: { attribute: !1 },
475
- rowKey: { attribute: !1 },
476
- filters: { attribute: !1 },
477
- hiddenColumns: { attribute: !1 },
478
- persistKey: { attribute: "persist-key" },
479
- label: {},
480
- scrolling: { state: !0 },
481
- resizable: { state: !0 },
482
- empty: { state: !0 },
483
- filterKey: { state: !0 }
484
- };
485
- menuColumn = null;
486
- menuKind = "resize";
487
- i18n = new M(this);
488
- internals = this.attachInternals();
489
- slots = new y(this);
490
- busyState = new x(this, this.i18n);
491
- keys = /* @__PURE__ */ new Set();
492
- anchor;
493
- shift = !1;
494
- shiftDown = !1;
495
- widths = new v(this, () => this.persistKey && `table:${this.persistKey}:widths`);
496
- columnState = new v(this, () => this.persistKey && `table:${this.persistKey}:columns`);
497
- openRows = new v(this, () => this.persistKey && `table:${this.persistKey}:expanded`);
498
- sizes = s(() => this.measure());
499
- observedTable = null;
500
- heads = l(() => this.syncAll());
501
- rowLinks = l(() => this.resolveRowLinks());
502
- vc = new S(this, {
503
- scroller: () => this.scroller,
504
- track: () => this.virtual ? this.body : null,
505
- rowHeight: "var(--bk-table-row-height, var(--bk-control-lg))"
506
- });
507
- loadMore = new C(this, {
508
- sentinel: () => this.virtual ? this.renderRoot.querySelector(".sentinel") : null,
509
- root: () => this.scroller,
510
- loading: () => this.busy,
511
- count: () => this.rows?.length ?? 0
512
- });
513
- tree = !1;
514
- stop = null;
515
- lift = null;
516
- handleRow = null;
517
- editing = null;
518
- filterButton = null;
519
- filterable = !1;
520
- syncing = !1;
521
- constructor() {
522
- super(), new h(this), this.variant = "line", this.stickyHeader = !1, this.stickyFooter = !1, this.hoverRows = !1, this.surface = !1, this.flush = !1, this.sortable = !1, this.sortDir = "asc", this.columnMenu = !1, this.reorderable = !1, this.busy = !1, this.skeletonRows = 5, this.virtual = !1, this.filters = {}, this.hiddenColumns = [], this.scrolling = !1, this.resizable = !1, this.empty = !1, this.addEventListener("click", this.onClick), this.addEventListener("click", this.onRowLink), this.addEventListener("auxclick", this.onRowLink), this.addEventListener("click", this.onRowLinkNavigate), this.addEventListener("dblclick", this.onDoubleClick), this.addEventListener("click", (e) => {
523
- this.shift = e.shiftKey || this.shiftDown, setTimeout(() => this.shift = !1);
524
- }, !0), this.addEventListener("keydown", (e) => this.shiftDown = e.shiftKey, !0), this.addEventListener("keyup", (e) => this.shiftDown = e.shiftKey, !0), this.addEventListener("focusout", this.onFocusOut), this.addEventListener("focusin", this.onFocusIn), this.addEventListener("change", this.onChange), this.addEventListener("keydown", this.onKeydown), this.addEventListener("pointerdown", this.onPointerDown);
525
- }
526
- get selectedKeys() {
527
- return [...this.keys];
528
- }
529
- set selectedKeys(e) {
530
- this.keys = new Set(e ?? []), this.requestUpdate("selectedKeys");
531
- }
532
- get columnOrder() {
533
- let e = this.headRow, t = e ? this.appCells(e).map((e) => this.columnKey(e)) : [], n = this.columnState.value?.order;
534
- return n?.length ? [...n, ...t.filter((e) => !n.includes(e))] : t;
535
- }
536
- static styles = [
537
- F,
538
- b,
539
- E,
540
- a`
541
- :host {
542
- display: block; min-inline-size: 0;
543
- --_bk-table-pad: var(--bk-table-cell-pad-block, var(--bk-row-pad));
544
- }
545
- .frame { position: relative; max-block-size: inherit; block-size: inherit; display: flex; flex-direction: column; }
546
- :host([surface]:not(:state(cards))) .frame {
547
- background: var(--bk-table-surface-bg, var(--bk-layer-raised-bg));
548
- border: var(--bk-border-width) solid var(--bk-table-surface-border, var(--bk-layer-raised-border));
549
- border-radius: var(--bk-table-surface-radius, var(--bk-radius-container, var(--bk-radius-md)));
550
- box-shadow: var(--bk-table-surface-shadow, var(--bk-layer-raised-shadow));
551
- overflow: hidden;
552
- }
553
- .scroller { overflow: auto; flex: 1 1 auto; min-block-size: 0; max-block-size: inherit; overscroll-behavior-inline: contain; }
554
- .scroller:focus-visible { outline: var(--bk-focus-ring); outline-offset: var(--bk-focus-offset-inset); }
555
- .filter-bar { margin-block-end: var(--bk-table-filter-bar-gap, var(--bk-space-2)); }
556
- /* Card mode: the sort of the cards is one select and a button for the direction, above the table. */
557
- .card-sort { display: flex; align-items: end; gap: var(--bk-table-card-gap, var(--bk-space-2)); margin-block-end: var(--bk-table-card-gap, var(--bk-space-2)); }
558
- .card-sort bk-select { flex: 1 1 auto; min-inline-size: 0; --bk-field-label-width: max-content; }
559
- .state { padding: var(--bk-table-state-padding, var(--bk-space-4)); }
560
- .sentinel { block-size: var(--bk-border-width); }
561
- .probe { position: absolute; visibility: hidden; pointer-events: none; inline-size: 0; block-size: 0; margin-inline-start: var(--bk-table-cards-below, calc(var(--bk-width-panel) * 1.5)); }
562
- .filter-anchor { position: absolute; left: 0; top: 0; inline-size: 0; block-size: 0; }
563
- .filter-anchor > bk-popover { position: absolute; left: 0; top: 0; }
564
- .filter-body { display: flex; flex-direction: column; gap: var(--bk-table-filter-gap, var(--bk-space-3)); }
565
- .filter-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--bk-space-cluster); }
566
- `
567
- ];
568
- connectedCallback() {
569
- super.connectedCallback(), ee(this, ie), this.hasUpdated && this.observe();
570
- }
571
- disconnectedCallback() {
572
- super.disconnectedCallback(), this.sizes.disconnect(), this.heads.disconnect(), this.rowLinks.disconnect(), this.observedTable = null;
573
- }
574
- scheduleUpdate() {
575
- let e = this.lateParts();
576
- return e ? e.then(() => super.scheduleUpdate()) : super.scheduleUpdate();
577
- }
578
- lateParts() {
579
- this.busy && B.start(), this.navigation === "cell" && z.start();
580
- let e = L.loaded && R.loaded ? null : this.headRow, t = this.filterable || Object.keys(this.filters ?? {}).length > 0 || !!e?.querySelector(":scope > [data-filter]"), n = this.columnMenu || this.resizable || this.reorderable || !!e?.querySelector(":scope > [data-resizable]");
581
- return D(this.selection && I.start(), t && L.start(), n && R.start());
582
- }
583
- willUpdate(e) {
584
- if (super.willUpdate(e), this.virtual && this.renderRow ? this.vc.setCount(this.rows?.length ?? 0) : this.vc.count && this.vc.setCount(0), c(this)) {
585
- this.empty = this.isEmpty;
586
- let e = this.headRow;
587
- this.resizable = this.columnMenu || !!e && this.appCells(e).some((e) => e.hasAttribute("data-resizable"));
588
- }
589
- }
590
- get isEmpty() {
591
- return this.virtual && this.renderRow ? !this.rows?.length : this.dataRows.length === 0;
592
- }
593
- updated(e) {
594
- super.updated(e), this.virtual && this.renderRow ? this.renderWindow() : e.has("virtual") && e.get("virtual") && this.clearWindow(), this.isConnected && !this.observedTable && this.observe(), this.resolveRowLinks(), [
595
- "sortable",
596
- "sortKey",
597
- "sortDir",
598
- "selection",
599
- "selectedKeys",
600
- "persistKey",
601
- "navigation",
602
- "columnMenu",
603
- "reorderable",
604
- "responsive",
605
- "busy",
606
- "skeletonRows",
607
- "virtual",
608
- "rows",
609
- "renderRow",
610
- "filters",
611
- "hiddenColumns"
612
- ].some((t) => e.has(t)) ? this.syncAll() : (this.persistKey && this.syncColumns(), this.table && (this.syncMarks(), this.heads.takeRecords())), (e.has("stickyHeader") || e.has("stickyFooter") || e.has("responsive")) && this.measure();
613
- }
614
- resolveRowLinks() {
615
- if (!this.table) return;
616
- let e = [...this.table.querySelectorAll("a[data-row-link]")].filter((e) => e.closest("bk-table") === this);
617
- m(e), this.rowLinks.takeRecords();
618
- }
619
- observe() {
620
- let e = this.scroller, t = this.table;
621
- e && t !== this.observedTable && (this.sizes.disconnect(), this.heads.disconnect(), this.rowLinks.disconnect(), this.sizes.observe(e), t && (this.sizes.observe(t), this.heads.observe(t, {
622
- childList: !0,
623
- subtree: !0
624
- }), this.rowLinks.observe(t, {
625
- childList: !0,
626
- subtree: !0,
627
- attributes: !0,
628
- attributeFilter: ["href"]
629
- })), this.observedTable = t, this.syncAll());
630
- }
631
- syncAll() {
632
- if (!this.syncing && this.table) {
633
- this.syncing = !0;
634
- try {
635
- this.syncHandles(), this.syncSelection(), this.syncExpand(), this.syncTree(), this.syncSort(), this.syncTools(), this.syncColumns(), this.syncCards(), this.syncMarks(), this.syncRoles(), this.syncFocus(), this.syncState();
636
- } finally {
637
- this.syncing = !1, this.heads.takeRecords();
638
- }
639
- }
640
- }
641
- get scroller() {
642
- return this.renderRoot?.querySelector(".scroller") ?? null;
643
- }
644
- get table() {
645
- return c(this)?.querySelector(":scope > table") ?? null;
646
- }
647
- get body() {
648
- return c(this)?.querySelector(":scope > table > tbody:not([data-bk-state])") ?? null;
649
- }
650
- get headRow() {
651
- return c(this)?.querySelector(":scope > table > thead > tr") ?? null;
652
- }
653
- get headRows() {
654
- return [...c(this)?.querySelectorAll(":scope > table > thead > tr") ?? []];
655
- }
656
- get footRows() {
657
- return [...c(this)?.querySelectorAll(":scope > table > tfoot > tr") ?? []];
658
- }
659
- get bodyRows() {
660
- return [...this.querySelectorAll(":scope > table > tbody:not([data-bk-state]) > tr:not([data-bk-spacer])")];
661
- }
662
- get dataRows() {
663
- return this.bodyRows.filter((e) => !e.hasAttribute("data-detail"));
664
- }
665
- get keyedRows() {
666
- return this.dataRows.filter((e) => e.dataset.key !== void 0);
667
- }
668
- get columnRows() {
669
- return [...c(this)?.querySelectorAll(Y) ?? []].filter((e) => !e.hasAttribute("data-detail"));
670
- }
671
- appCells(e) {
672
- return [...e.cells].filter((e) => !e.matches(K));
673
- }
674
- get number() {
675
- return new Intl.NumberFormat(this.i18n.locale);
676
- }
677
- text(e) {
678
- let t = e.querySelector(":scope > .bk-table-check");
679
- if (t) return X(t.textContent);
680
- let n = e.querySelector(":scope > .bk-table-sort");
681
- if (n) return X(n.textContent);
682
- let r = e.querySelector(":scope > [data-bk-note]")?.textContent ?? "", i = e.textContent ?? "";
683
- return X(r && i.endsWith(r) ? i.slice(0, -r.length) : i);
684
- }
685
- rowName(e) {
686
- let t = this.appCells(e).find((e) => e.textContent?.trim());
687
- return t ? this.text(t) : e.dataset.key ?? "";
688
- }
689
- columnKey(e) {
690
- return e.dataset.key ?? e.dataset.sort ?? e.dataset.filter ?? String(this.appCells(e.parentElement).indexOf(e));
691
- }
692
- headOf(e) {
693
- return this.headRow?.cells[e.cellIndex] ?? null;
694
- }
695
- leadCell(e, t, n) {
696
- let r = e.querySelector(`:scope > [data-bk-${t}]`);
697
- if (r) return r;
698
- r = document.createElement(n), r.setAttribute(`data-bk-${t}`, ""), n === "th" && e.parentElement?.localName === "thead" && r.setAttribute("scope", "col");
699
- let i = t === "select" ? e.querySelector(":scope > [data-bk-handle]") : null;
700
- return i ? i.after(r) : e.prepend(r), r;
701
- }
702
- srText(e, t) {
703
- let n = e.querySelector(":scope > .bk-table-sr");
704
- return n || (n = document.createElement("span"), n.className = "bk-table-sr", e.append(n)), n.textContent !== t && (n.textContent = t), n;
705
- }
706
- get sortHeaders() {
707
- return [...c(this)?.querySelectorAll(":scope > table > thead > tr > th[data-sort]") ?? []];
708
- }
709
- syncSort() {
710
- for (let e of this.sortHeaders) {
711
- let t = e.querySelector(":scope > button:not(.bk-table-tool)");
712
- if (!this.sortable) {
713
- if (!t?.classList.contains("bk-table-sort")) continue;
714
- e.removeAttribute("aria-sort"), t.querySelector(":scope > .bk-table-sort-icon")?.remove(), t.classList.remove("bk-table-sort"), t.hasAttribute("data-bk-sort") && t.replaceWith(...t.childNodes);
715
- continue;
716
- }
717
- t || (t = document.createElement("button"), t.type = "button", t.setAttribute("data-bk-sort", ""), t.append(...[...e.childNodes].filter((e) => !(e instanceof Element && e.matches(".bk-table-tool, .bk-table-resize, .bk-table-sr")))), e.prepend(t)), t.classList.add("bk-table-sort");
718
- let n = t.querySelector(":scope > .bk-table-sort-icon");
719
- n || (n = document.createElement("bk-icon"), n.className = "bk-table-sort-icon", t.append(n)), this.cards ? t.getAttribute("tabindex") !== "-1" && t.setAttribute("tabindex", "-1") : t.getAttribute("tabindex") === "-1" && t.removeAttribute("tabindex");
720
- let r = e.dataset.sort === this.sortKey, i = r ? this.sortDir === "desc" ? "arrow-down" : "arrow-up" : "unfold-more";
721
- n.getAttribute("name") !== i && n.setAttribute("name", i);
722
- let a = r ? this.sortDir === "desc" ? "descending" : "ascending" : null;
723
- a === null ? e.removeAttribute("aria-sort") : e.getAttribute("aria-sort") !== a && e.setAttribute("aria-sort", a);
724
- }
725
- }
726
- onCardSort = (e) => {
727
- e.stopPropagation();
728
- let t = e.target.value, n = this.headRow && this.appCells(this.headRow).find((e) => e.dataset.sort === t);
729
- n && t !== this.sortKey && this.requestSort(n);
730
- };
731
- onCardSortDir = () => {
732
- let e = this.headRow && this.appCells(this.headRow).find((e) => e.dataset.sort === this.sortKey);
733
- e && this.requestSort(e, this.sortDir === "desc" ? "asc" : "desc");
734
- };
735
- requestSort(e, t) {
736
- let n = e.dataset.sort, r = t ?? (n === this.sortKey ? this.sortDir === "desc" ? "asc" : "desc" : e.dataset.sortDir === "desc" ? "desc" : "asc");
737
- _(this, "sort", {
738
- key: n,
739
- dir: r
740
- }, !0) && (this.sortKey = n, this.sortDir = r, d(this.i18n.t(r === "desc" ? "tableSortedDescending" : "tableSortedAscending", { column: this.text(e) || n })));
741
- }
742
- onRowLink = (e) => {
743
- if (e.defaultPrevented || e.type === "auxclick" && e.button !== 1) return;
744
- let t = e.composedPath(), n = t.find((e) => e instanceof HTMLTableRowElement);
745
- if (!n || n.parentElement?.localName !== "tbody" || n.closest("bk-table") !== this) return;
746
- let r = n.querySelector("a[data-row-link][href]");
747
- if (r && r.closest("tr") === n) {
748
- for (let e of t) {
749
- if (e === n) break;
750
- if (e === r || e instanceof Element && e.matches(J)) return;
751
- }
752
- getSelection()?.toString() || r.dispatchEvent(new MouseEvent(e.type, {
753
- bubbles: !0,
754
- cancelable: !0,
755
- composed: !0,
756
- view: window,
757
- detail: e.detail,
758
- button: e.button,
759
- buttons: e.buttons,
760
- clientX: e.clientX,
761
- clientY: e.clientY,
762
- ctrlKey: e.ctrlKey,
763
- metaKey: e.metaKey,
764
- shiftKey: e.shiftKey,
765
- altKey: e.altKey
766
- }));
767
- }
768
- };
769
- onRowLinkNavigate = (e) => {
770
- let t = p(e);
771
- t?.hasAttribute("data-row-link") && t.closest("bk-table") === this && f(t, e);
772
- };
773
- onClick = (e) => {
774
- let t = e.target;
775
- if (!t?.closest) return;
776
- let n = (e) => !!e && e.closest("bk-table") === this, r = t.closest(".bk-table-disclosure");
777
- if (r && n(r)) return this.onDisclosure(r);
778
- let i = t.closest("button.bk-table-tool");
779
- if (i && n(i)) {
780
- let e = i.parentElement;
781
- i.classList.contains("bk-table-filter") ? this.openFilter(e, i) : this.openColumnMenu(e, "column", i);
782
- return;
783
- }
784
- if (!this.sortable) return;
785
- let a = t.closest("button.bk-table-sort")?.parentElement;
786
- a && this.sortHeaders.includes(a) && this.requestSort(a);
787
- };
788
- box(e) {
789
- let t = e.querySelector(":scope > bk-checkbox");
790
- return t || (t = document.createElement("bk-checkbox"), t.setAttribute("data-bk-select", ""), e.append(t)), t;
791
- }
792
- get allKeys() {
793
- return this.virtual && this.rowKey && this.rows ? this.rows.map((e, t) => this.rowKey(e, t)) : this.keyedRows.map((e) => e.dataset.key);
794
- }
795
- syncSelection() {
796
- let e = this.selection === "single" || this.selection === "multiple", t = this.headRows, n = this.bodyRows, r = this.footRows;
797
- if (!e) {
798
- for (let e of [
799
- ...t,
800
- ...n,
801
- ...r
802
- ]) e.querySelector(":scope > [data-bk-select]")?.remove(), e.hasAttribute("data-bk-selectable") && (e.removeAttribute("data-selected"), e.removeAttribute("data-bk-selectable"));
803
- return;
804
- }
805
- let i = this.allKeys, a = i.filter((e) => this.keys.has(e)).length;
806
- t.forEach((e, t) => {
807
- let n = this.leadCell(e, "select", "th");
808
- if (t > 0 || this.selection !== "multiple") {
809
- n.querySelector("bk-checkbox")?.remove(), t === 0 && this.srText(n, this.i18n.t("tableSelection"));
810
- return;
811
- }
812
- n.querySelector(".bk-table-sr")?.remove();
813
- let r = this.box(n);
814
- r.setAttribute("aria-label", this.i18n.t("tableSelectAll")), r.setAttribute("data-bk-all", ""), r.checked = i.length > 0 && a === i.length, r.indeterminate = a > 0 && a < i.length;
815
- });
816
- for (let e of r) this.leadCell(e, "select", "td");
817
- for (let e of n) {
818
- if (e.hasAttribute("data-detail")) continue;
819
- let t = this.leadCell(e, "select", "td"), n = e.dataset.key;
820
- if (n === void 0) continue;
821
- let r = this.keys.has(n);
822
- e.setAttribute("data-bk-selectable", ""), e.toggleAttribute("data-selected", r);
823
- let i = this.box(t), a = this.i18n.t("tableSelectRow", { row: this.rowName(e) });
824
- i.getAttribute("aria-label") !== a && i.setAttribute("aria-label", a), i.checked !== r && (i.checked = r);
825
- }
826
- }
827
- choose(e) {
828
- let t = [...e];
829
- _(this, "select", { keys: t }, !0) ? (this.keys = e, this.syncSelection(), d(this.i18n.t("selectedCount", { count: this.number.format(this.keys.size) }))) : this.syncSelection();
830
- }
831
- toggleRow(e, t, n) {
832
- let r = new Set(this.selection === "single" ? [] : this.keys), i = this.allKeys, a = n && this.anchor !== void 0 && i.includes(this.anchor) && this.selection === "multiple" ? i.slice(Math.min(i.indexOf(this.anchor), i.indexOf(e)), Math.max(i.indexOf(this.anchor), i.indexOf(e)) + 1) : [e];
833
- for (let e of a) t ? r.add(e) : r.delete(e);
834
- this.anchor = e, this.choose(r);
835
- }
836
- onChange = (e) => {
837
- let t = e.target;
838
- if (!t?.hasAttribute?.("data-bk-select") || t.parentElement?.closest("bk-table") !== this) return;
839
- if (e.stopPropagation(), t.hasAttribute("data-bk-all")) {
840
- let e = new Set(this.keys);
841
- for (let n of this.allKeys) t.checked ? e.add(n) : e.delete(n);
842
- this.choose(e);
843
- return;
844
- }
845
- let n = t.closest("tr");
846
- n?.dataset.key !== void 0 && this.toggleRow(n.dataset.key, t.checked, this.shift);
847
- };
848
- serialize(e, t, n) {
849
- let r = this.headRow, i = /* @__PURE__ */ new Set(), a = r ? this.appCells(r) : [];
850
- a.forEach((e, t) => e.hasAttribute("data-bk-hidden") && i.add(t));
851
- let o = (e) => e.dataset.value ?? this.text(e), s = (e) => e.filter((e, t) => !i.has(t)).map((e) => re(o(e), t)).join(t), c = e.map((e) => s(this.appCells(e)));
852
- return n && a.length && c.unshift(s(a)), c.join("\r\n");
853
- }
854
- exportRows(t) {
855
- if (this.virtual && this.renderRow && this.rows) {
856
- let n = document.createElement("tbody"), i = this.rows.map((e, t) => ({
857
- r: e,
858
- i: t
859
- })).filter(({ r: e, i: n }) => !t || (this.rowKey ? this.keys.has(this.rowKey(e, n)) : !1));
860
- r(e`${i.map(({ r: e, i: t }) => this.renderRow(e, t))}`, n);
861
- let a = [...n.rows];
862
- return t && !this.rowKey ? a.filter((e) => e.dataset.key !== void 0 && this.keys.has(e.dataset.key)) : a;
863
- }
864
- let n = this.dataRows;
865
- return t ? n.filter((e) => e.dataset.key !== void 0 && this.keys.has(e.dataset.key)) : n;
866
- }
867
- toCSV(e = {}) {
868
- return this.serialize(this.exportRows(!!e.selectedOnly), e.delimiter ?? ",", e.header ?? !0);
869
- }
870
- async copySelection() {
871
- let e = this.selection ? this.exportRows(!0) : [], t = "", n = "";
872
- if (e.length) t = this.serialize(e, " ", !1), n = this.i18n.t("tableCopiedRows", { count: e.length });
873
- else {
874
- let e = A()?.closest?.("td, th");
875
- if (!e || e.closest("bk-table") !== this || this.navigation !== "cell") return !1;
876
- t = e.dataset.value ?? this.text(e), n = this.i18n.t("copied");
877
- }
878
- let r = await te(t);
879
- return r && d(n), r;
880
- }
881
- restoreOpen(e) {
882
- let t = this.openRows.value;
883
- t && e.dataset.key !== void 0 && e.toggleAttribute("data-expanded", t.includes(e.dataset.key));
884
- }
885
- saveOpen(e) {
886
- if (!this.persistKey || e.dataset.key === void 0) return;
887
- let t = new Set(this.openRows.value ?? []);
888
- e.hasAttribute("data-expanded") ? t.add(e.dataset.key) : t.delete(e.dataset.key), this.openRows.set([...t]);
889
- }
890
- syncExpand() {
891
- let e = 0;
892
- for (let t of this.querySelectorAll(":scope > table > tbody > tr[data-expandable]")) {
893
- let n = t.nextElementSibling instanceof HTMLTableRowElement && t.nextElementSibling.hasAttribute("data-detail") ? t.nextElementSibling : null, r = this.appCells(t)[0];
894
- if (!r || !n) continue;
895
- this.restoreOpen(t);
896
- let i = r.querySelector(":scope > button.bk-table-disclosure");
897
- if (!i) {
898
- i = document.createElement("button"), i.type = "button", i.className = "bk-table-disclosure";
899
- let e = document.createElement("bk-icon");
900
- e.setAttribute("name", "chevron-right"), i.append(e), r.prepend(i);
901
- }
902
- n.id ||= `bk-table-detail-${++e}-${Math.random().toString(36).slice(2, 7)}`;
903
- let a = t.hasAttribute("data-expanded");
904
- i.setAttribute("aria-controls", n.id), i.setAttribute("aria-expanded", String(a)), i.setAttribute("aria-label", this.i18n.t(a ? "tableCollapseRow" : "tableExpandRow")), n.hidden = !a;
905
- }
906
- }
907
- level(e) {
908
- return Math.max(0, Number(e.dataset.level) || 0);
909
- }
910
- syncTree() {
911
- let e = this.dataRows;
912
- if (!e.some((e) => e.hasAttribute("data-level") || e.hasAttribute("data-group"))) {
913
- if (this.tree) for (let e of this.querySelectorAll(":scope > table > tbody > tr[data-bk-tree]")) {
914
- for (let t of [
915
- "data-bk-tree",
916
- "data-bk-parent",
917
- "aria-level",
918
- "aria-setsize",
919
- "aria-posinset",
920
- "aria-expanded"
921
- ]) e.removeAttribute(t);
922
- e.hidden = !1, e.querySelector(":scope > * > span.bk-table-disclosure")?.remove(), e.querySelector(":scope > [data-bk-indent]")?.removeAttribute("data-bk-indent");
923
- }
924
- this.tree = !1;
925
- return;
926
- }
927
- this.tree = !0;
928
- let t = e.map((e) => this.level(e)), n = [], r = /* @__PURE__ */ new Map(), i = [];
929
- e.forEach((e, a) => {
930
- for (; n.length && t[n.at(-1)] >= t[a];) n.pop();
931
- let o = n.at(-1) ?? -1;
932
- i[a] = o, r.has(o) || r.set(o, []), r.get(o).push(a), n.push(a);
933
- });
934
- let a = 1e400;
935
- e.forEach((n, o) => {
936
- let s = t[o], c = o + 1 < e.length && t[o + 1] > s;
937
- s <= a && (a = 1e400), n.hidden = s > a, n.setAttribute("data-bk-tree", ""), n.toggleAttribute("data-bk-parent", c), n.setAttribute("aria-level", String(s + 1));
938
- let l = r.get(i[o]);
939
- n.setAttribute("aria-setsize", String(l.length)), n.setAttribute("aria-posinset", String(l.indexOf(o) + 1)), n.style.setProperty("--_bk-table-level", String(s));
940
- let u = this.appCells(n)[0];
941
- u && !u.hasAttribute("data-bk-indent") && u.setAttribute("data-bk-indent", "");
942
- let d = u?.querySelector(":scope > span.bk-table-disclosure") ?? null;
943
- if (c) {
944
- this.restoreOpen(n);
945
- let e = n.hasAttribute("data-expanded");
946
- if (n.setAttribute("aria-expanded", String(e)), !e && a === 1e400 && (a = s), !d && u) {
947
- d = document.createElement("span"), d.className = "bk-table-disclosure", d.setAttribute("aria-hidden", "true");
948
- let e = document.createElement("bk-icon");
949
- e.setAttribute("name", "chevron-right"), d.append(e), u.prepend(d);
950
- }
951
- } else n.removeAttribute("aria-expanded"), d?.remove();
952
- });
953
- }
954
- toggleOpen(e, t = !e.hasAttribute("data-expanded")) {
955
- t !== e.hasAttribute("data-expanded") && (e.toggleAttribute("data-expanded", t), this.saveOpen(e), this.syncAll(), g(e, t));
956
- }
957
- onDisclosure(e) {
958
- let t = e.closest("tr");
959
- t && this.toggleOpen(t);
960
- }
961
- tool(e, t, n) {
962
- let r = e.querySelector(`:scope > .bk-table-${t}`);
963
- if (!n) return r?.remove(), null;
964
- if (!r) {
965
- r = document.createElement("button"), r.type = "button", r.className = `bk-table-tool bk-table-${t}`;
966
- let n = document.createElement("bk-icon");
967
- n.setAttribute("name", t === "filter" ? "filter" : "more-vert"), r.append(n);
968
- let i = e.querySelector(t === "filter" ? ":scope > .bk-table-menu, :scope > .bk-table-resize" : ":scope > .bk-table-resize");
969
- i ? i.before(r) : e.append(r);
970
- }
971
- return r;
972
- }
973
- syncTools() {
974
- let e = this.headRow, t = !!e?.querySelector(":scope > th[data-filter]");
975
- if (t !== this.filterable && (this.filterable = t, this.requestUpdate()), e) for (let t of this.appCells(e)) {
976
- let e = this.text(t), n = this.tool(t, "filter", t.hasAttribute("data-filter"));
977
- if (n) {
978
- let r = !Q(this.filters?.[t.dataset.filter]);
979
- n.toggleAttribute("data-active", r);
980
- let i = this.i18n.t(r ? "tableFilterColumnActive" : "tableFilterColumn", { column: e });
981
- n.getAttribute("aria-label") !== i && n.setAttribute("aria-label", i), k(n, {
982
- haspopup: "dialog",
983
- expanded: this.filterKey === t.dataset.filter && n === this.filterButton
984
- });
985
- }
986
- let r = this.tool(t, "menu", this.columnMenu);
987
- if (r) {
988
- let t = this.i18n.t("tableColumnMenu", { column: e });
989
- r.getAttribute("aria-label") !== t && r.setAttribute("aria-label", t), r.hasAttribute("aria-haspopup") || k(r, {
990
- haspopup: "menu",
991
- expanded: !1
992
- });
993
- }
994
- }
995
- }
996
- filterField(e) {
997
- let t = [...this.children].find((t) => t.getAttribute("slot") === `filter-${e}`);
998
- if (!t) return null;
999
- let n = (e) => "value" in e && ("checkValidity" in e || e instanceof HTMLInputElement || e instanceof HTMLSelectElement);
1000
- return n(t) ? t : [...t.querySelectorAll("*")].find(n) ?? null;
1001
- }
1002
- readField(e) {
1003
- return Array.isArray(e.values) && (e.multiple || e.hasAttribute("multiple") || e.getAttribute("selection") === "multiple") ? [...e.values] : e.value;
1004
- }
1005
- clearField(e) {
1006
- let t = this.filterField(e);
1007
- t && (Array.isArray(t.values) && (t.values = []), t.value = "");
1008
- }
1009
- filterText(e, t) {
1010
- let n = this.filterField(e), r = (e) => {
1011
- let t = String(e);
1012
- return X(n?.querySelector(`[value="${CSS.escape(t)}"]`)?.textContent) || t;
1013
- };
1014
- return Array.isArray(t) ? t.map(r).join(", ") : r(t);
1015
- }
1016
- get filterItems() {
1017
- let e = this.headRow;
1018
- return e ? this.appCells(e).filter((e) => e.dataset.filter && !Q(this.filters?.[e.dataset.filter])).map((e) => ({
1019
- key: e.dataset.filter,
1020
- label: `${this.text(e)}: ${this.filterText(e.dataset.filter, this.filters[e.dataset.filter])}`
1021
- })) : [];
1022
- }
1023
- applyFilters(e) {
1024
- for (let [t, n] of Object.entries(e)) Q(n) && delete e[t];
1025
- return _(this, "filter", { filters: e }, !0) ? (this.filters = e, d(this.i18n.t("filtersActive", { count: Object.keys(e).length })), !0) : !1;
1026
- }
1027
- get filterPopover() {
1028
- return this.renderRoot.querySelector(".filter-popover");
1029
- }
1030
- async openFilter(e, t) {
1031
- let n = e.dataset.filter, r = this.filterPopover;
1032
- if (r?.open && this.filterKey === n) {
1033
- r.hide();
1034
- return;
1035
- }
1036
- this.filterKey = n, this.filterButton = t, await this.updateComplete;
1037
- let i = this.renderRoot.querySelector(".filter-anchor"), a = this.filterPopover;
1038
- if (!i || !a) return;
1039
- i.style.left = i.style.top = "0px";
1040
- let o = i.getBoundingClientRect(), s = e.getBoundingClientRect(), c = this.matches(":dir(rtl)");
1041
- i.style.left = `${(c ? s.right : s.left) - o.left}px`, i.style.top = `${s.bottom - o.top}px`, a.show(), k(t, {
1042
- haspopup: "dialog",
1043
- expanded: !0
1044
- });
1045
- }
1046
- onFilterClose = () => {
1047
- let e = this.filterButton;
1048
- e && k(e, {
1049
- haspopup: "dialog",
1050
- expanded: !1
1051
- });
1052
- let t = A(), n = [...this.children].find((e) => e.getAttribute("slot") === `filter-${this.filterKey}`);
1053
- e?.isConnected && (!t || t === document.body || j(n, t) || j(this.renderRoot, t)) && e.focus(), this.filterKey = void 0;
1054
- };
1055
- onFilterApply = (e) => {
1056
- let t = this.filterKey;
1057
- if (!t) return;
1058
- let n = this.filterField(t);
1059
- e && this.clearField(t);
1060
- let r = e || !n ? void 0 : this.readField(n);
1061
- this.applyFilters({
1062
- ...this.filters,
1063
- [t]: r
1064
- }) && this.filterPopover?.hide();
1065
- };
1066
- onFilterRemove = (e) => {
1067
- e.stopPropagation();
1068
- let t = { ...this.filters };
1069
- delete t[e.detail.key], this.applyFilters(t) ? this.clearField(e.detail.key) : e.preventDefault();
1070
- };
1071
- onFilterClear = (e) => {
1072
- e.stopPropagation();
1073
- let t = Object.keys(this.filters);
1074
- this.applyFilters({}) && (t.forEach((e) => this.clearField(e)), this.updateComplete.then(() => c(this)?.querySelector(":scope > table > thead > tr > th > .bk-table-filter")?.focus()));
1075
- };
1076
- get hiddenSet() {
1077
- return new Set(this.columnState.value?.hidden ?? this.hiddenColumns ?? []);
1078
- }
1079
- get pinned() {
1080
- let e = this.headRow, t = {};
1081
- if (e) for (let n of this.appCells(e)) {
1082
- let e = n.getAttribute("data-pin");
1083
- (e === "start" || e === "end") && (t[this.columnKey(n)] = e);
1084
- }
1085
- return t;
1086
- }
1087
- changeColumns(e, t, n) {
1088
- let r = this.headRow;
1089
- if (!r) return !1;
1090
- let i = this.pinned;
1091
- for (let [e, n] of Object.entries(t)) n === "none" ? delete i[e] : i[e] = n;
1092
- if (!_(this, "columns", {
1093
- hidden: e,
1094
- pinned: i,
1095
- widths: this.columnWidths()
1096
- }, !0)) return !1;
1097
- if (this.hiddenColumns = e, this.persistKey) {
1098
- let n = this.columnState.value ?? {};
1099
- this.columnState.set({
1100
- ...n,
1101
- hidden: e,
1102
- pinned: {
1103
- ...n.pinned,
1104
- ...t
1105
- }
1106
- });
1107
- }
1108
- for (let e of this.appCells(r)) {
1109
- let n = t[this.columnKey(e)];
1110
- n && this.setPin(e, n);
1111
- }
1112
- return this.syncColumns(), d(n), !0;
1113
- }
1114
- setPin(e, t) {
1115
- e.hasAttribute("data-bk-pin-default") || e.setAttribute("data-bk-pin-default", e.getAttribute("data-pin") ?? "none"), t === "none" ? e.removeAttribute("data-pin") : e.setAttribute("data-pin", t);
1116
- }
1117
- toggleColumn(e, t) {
1118
- let n = this.columnKey(e), r = new Set(this.hiddenSet);
1119
- return t ? r.delete(n) : r.add(n), this.changeColumns([...r], {}, this.i18n.t(t ? "tableColumnShown" : "tableColumnHidden", { column: this.text(e) }));
1120
- }
1121
- resetColumns() {
1122
- let e = this.headRow;
1123
- if (!e) return;
1124
- let t = {};
1125
- for (let n of this.appCells(e)) {
1126
- let e = n.getAttribute("data-bk-pin-default");
1127
- e && (t[this.columnKey(n)] = e);
1128
- }
1129
- if (this.changeColumns([], t, this.i18n.t("tableColumnsReset"))) {
1130
- this.persistKey && this.columnState.set(void 0);
1131
- for (let t of this.appCells(e)) t.removeAttribute("data-bk-pin-default");
1132
- }
1133
- }
1134
- moveColumn(e, t) {
1135
- let n = this.headRow;
1136
- if (!n) return;
1137
- let r = this.appCells(n), i = r.indexOf(e), a = i + t;
1138
- if (!this.canMove(r, i, a)) return;
1139
- let o = r.map((e) => this.columnKey(e)), [s] = o.splice(i, 1);
1140
- o.splice(a, 0, s), _(this, "reorder", {
1141
- type: "column",
1142
- key: s,
1143
- from: i,
1144
- to: a,
1145
- order: o
1146
- }, !0) && (this.persistKey && this.columnState.set({
1147
- ...this.columnState.value,
1148
- order: o
1149
- }), d(this.i18n.t("sortableMoved", {
1150
- item: this.text(e),
1151
- position: a + 1,
1152
- total: r.length
1153
- })));
1154
- }
1155
- canMove(e, t, n) {
1156
- if (n < 0 || n >= e.length || n === t) return !1;
1157
- let r = (e) => e.getAttribute("data-pin") ?? "";
1158
- return r(e[n]) === r(e[t]);
1159
- }
1160
- maxWidth() {
1161
- return Math.max(96, this.clientWidth);
1162
- }
1163
- clampWidth(e, t = this.maxWidth()) {
1164
- return Math.round(Math.min(t, Math.max(V, e)));
1165
- }
1166
- setValue(e, t, n = this.maxWidth()) {
1167
- let r = e.querySelector(":scope > .bk-table-resize");
1168
- if (!r) return;
1169
- let i = Math.round(t);
1170
- r.setAttribute("aria-valuenow", String(i)), r.setAttribute("aria-valuemin", String(V)), r.setAttribute("aria-valuemax", String(Math.max(i, Math.round(n)))), r.setAttribute("aria-valuetext", this.i18n.t("tableColumnWidth", { width: this.number.format(i) }));
1171
- }
1172
- setWidth(e, t, n) {
1173
- e.style.inlineSize = e.style.minInlineSize = `${t}px`, this.setValue(e, t, n);
1174
- }
1175
- columnWidths() {
1176
- let e = {}, t = this.headRow;
1177
- if (t) for (let n of this.appCells(t)) {
1178
- let t = n.style.inlineSize.endsWith("px") ? parseFloat(n.style.inlineSize) : NaN;
1179
- Number.isFinite(t) && (e[this.columnKey(n)] = Math.round(t));
1180
- }
1181
- return e;
1182
- }
1183
- emitColumns() {
1184
- _(this, "columns", {
1185
- hidden: [...this.hiddenSet],
1186
- pinned: this.pinned,
1187
- widths: this.columnWidths()
1188
- });
1189
- }
1190
- saveWidth(e, t) {
1191
- this.emitColumns(), this.persistKey && this.widths.set({
1192
- ...this.widths.value,
1193
- [this.columnKey(e)]: Math.round(t)
1194
- });
1195
- }
1196
- resizeTo(e, t) {
1197
- let n = this.clampWidth(t);
1198
- this.setWidth(e, n), this.saveWidth(e, n), this.syncPins(e.parentElement);
1199
- }
1200
- resetWidth(e) {
1201
- if (e.style.removeProperty("inline-size"), e.style.removeProperty("min-inline-size"), this.persistKey && this.widths.value && this.columnKey(e) in this.widths.value) {
1202
- let { [this.columnKey(e)]: t, ...n } = this.widths.value;
1203
- this.widths.set(n);
1204
- }
1205
- this.setValue(e, e.offsetWidth), this.syncPins(e.parentElement), this.emitColumns();
1206
- }
1207
- syncColumns() {
1208
- let e = this.headRow;
1209
- if (!e) return;
1210
- let t = this.widths.value, n = this.columnState.value?.pinned, r = this.hiddenSet, i = this.columnMenu, a = /* @__PURE__ */ new Set();
1211
- for (let o of this.appCells(e)) {
1212
- let e = this.columnKey(o);
1213
- n?.[e] && (o.hasAttribute("data-bk-pin-default") ? (o.getAttribute("data-pin") ?? "none") !== n[e] && this.setPin(o, n[e]) : this.setPin(o, n[e])), r.has(e) && a.add(o.cellIndex);
1214
- let s = o.querySelector(":scope > .bk-table-resize");
1215
- if (!o.hasAttribute("data-resizable")) {
1216
- s?.remove();
1217
- continue;
1218
- }
1219
- i = !0;
1220
- let c = t?.[e];
1221
- s || (s = document.createElement("span"), s.className = "bk-table-resize", s.setAttribute("role", "separator"), s.setAttribute("aria-orientation", "vertical"), s.tabIndex = 0, s.innerHTML = "<span class=\"bk-grip\" aria-hidden=\"true\"></span>", s.addEventListener("pointerdown", (e) => this.onHandleDown(e, o, s)), o.append(s), c || this.setValue(o, o.offsetWidth)), c && o.style.inlineSize !== `${c}px` && this.setWidth(o, c), o.id ||= `bk-table-col-${Math.random().toString(36).slice(2, 9)}`, s.setAttribute("aria-controls", o.id);
1222
- let l = this.i18n.t("tableResizeColumn", { column: this.text(o) });
1223
- s.getAttribute("aria-label") !== l && s.setAttribute("aria-label", l);
1224
- }
1225
- for (let e of this.columnRows) for (let t of e.cells) {
1226
- let e = a.has(t.cellIndex) && !t.matches(K);
1227
- t.hasAttribute("data-bk-hidden") !== e && t.toggleAttribute("data-bk-hidden", e);
1228
- }
1229
- i !== this.resizable && (this.resizable = i), this.syncPins(e);
1230
- }
1231
- syncPins(e) {
1232
- let t = [...e.cells], n = (e) => !e.hasAttribute("data-bk-hidden"), r = t.filter((e) => e.getAttribute("data-pin") === "start" && n(e)), i = t.filter((e) => e.getAttribute("data-pin") === "end" && n(e)).reverse(), a = this.columnRows;
1233
- for (let t of a) if (t !== e) for (let n of t.cells) {
1234
- let t = e.cells[n.cellIndex]?.getAttribute("data-pin");
1235
- n.hasAttribute("data-pin") && t !== n.getAttribute("data-pin") && (n.removeAttribute("data-pin"), n.removeAttribute("data-pin-edge"), n.style.removeProperty("--_bk-table-pin"));
1236
- }
1237
- for (let e of t) !e.hasAttribute("data-pin") && e.hasAttribute("data-pin-edge") && (e.removeAttribute("data-pin-edge"), e.style.removeProperty("--_bk-table-pin"));
1238
- for (let [e, t] of [[r, "start"], [i, "end"]]) {
1239
- let n = 0;
1240
- e.forEach((r, i) => {
1241
- let o = r.cellIndex;
1242
- for (let r of a) {
1243
- if (r.cells.length <= o) continue;
1244
- let a = r.cells[o];
1245
- a.getAttribute("data-pin") !== t && a.setAttribute("data-pin", t), a.toggleAttribute("data-pin-edge", i === e.length - 1), a.style.setProperty("--_bk-table-pin", `${n}px`);
1246
- }
1247
- n += r.offsetWidth;
1248
- });
1249
- }
1250
- }
1251
- onHandleDown(e, t, n) {
1252
- if (e.button !== 0) return;
1253
- e.preventDefault(), n.focus(), n.setPointerCapture(e.pointerId);
1254
- let r = t.offsetWidth, i = e.clientX, a = this.maxWidth(), o = this.matches(":dir(rtl)") ? -1 : 1, s = !1, c = (e) => {
1255
- !s && Math.abs(e.clientX - i) < W || (s || n.setAttribute("data-dragging", ""), s = !0, this.setWidth(t, this.clampWidth(r + o * (e.clientX - i), a), a), this.syncPins(t.parentElement));
1256
- }, l = (e) => {
1257
- n.removeEventListener("pointermove", c), n.removeEventListener("pointerup", l), n.removeEventListener("pointercancel", l), n.removeAttribute("data-dragging"), s ? this.saveWidth(t, t.offsetWidth) : e.type === "pointerup" && this.openColumnMenu(t, "resize", null, e.clientX, e.clientY);
1258
- };
1259
- n.addEventListener("pointermove", c), n.addEventListener("pointerup", l), n.addEventListener("pointercancel", l);
1260
- }
1261
- onHandleKey(e, t) {
1262
- let n = t.parentElement;
1263
- if (!n) return;
1264
- if (e.key === "Home") {
1265
- e.preventDefault(), this.resetWidth(n);
1266
- return;
1267
- }
1268
- if (!["ArrowLeft", "ArrowRight"].includes(e.key)) return;
1269
- e.preventDefault(), e.stopPropagation();
1270
- let r = e.key === "ArrowRight" !== this.matches(":dir(rtl)"), i = e.shiftKey ? U : H;
1271
- this.resizeTo(n, n.offsetWidth + (r ? i : -i));
1272
- }
1273
- get columnMenuEl() {
1274
- return this.renderRoot.querySelector(".column-menu");
1275
- }
1276
- async openColumnMenu(e, t, n, r, i) {
1277
- if (this.menuColumn = e, this.menuKind = t, this.requestUpdate(), await this.updateComplete, n) {
1278
- let e = n.getBoundingClientRect();
1279
- r = this.matches(":dir(rtl)") ? e.right : e.left, i = e.bottom, k(n, {
1280
- haspopup: "menu",
1281
- expanded: !0
1282
- });
1283
- }
1284
- setTimeout(() => this.columnMenuEl?.showAt(r ?? 0, i ?? 0, n ?? e));
1285
- }
1286
- onColumnMenuClose = () => {
1287
- let e = this.menuColumn?.querySelector(":scope > .bk-table-menu");
1288
- e && k(e, {
1289
- haspopup: "menu",
1290
- expanded: !1
1291
- });
1292
- };
1293
- onColumnMenu(e) {
1294
- e.stopPropagation();
1295
- let t = this.menuColumn;
1296
- if (!t?.isConnected) return;
1297
- let n = e.detail.value, r = this.headRow, i = this.matches(":dir(rtl)");
1298
- if (n === "reset") return this.resetWidth(t);
1299
- if (n === "wider" || n === "narrower") e.preventDefault(), this.resizeTo(t, t.offsetWidth + (n === "wider" ? H : -16));
1300
- else {
1301
- if (n === "sort-asc" || n === "sort-desc") return this.requestSort(t, n === "sort-asc" ? "asc" : "desc");
1302
- if (n === "pin-start" || n === "pin-end" || n === "unpin") {
1303
- let e = n === "unpin" ? "none" : n === "pin-start" ? "start" : "end";
1304
- this.changeColumns([...this.hiddenSet], { [this.columnKey(t)]: e }, this.i18n.t(e === "none" ? "tableColumnUnpinned" : "tableColumnPinned", { column: this.text(t) }));
1305
- } else {
1306
- if (n === "move-left" || n === "move-right") return this.moveColumn(t, n === "move-right" === i ? -1 : 1);
1307
- if (n === "hide") return void this.toggleColumn(t, !1);
1308
- if (n === "reset-columns") return this.resetColumns();
1309
- if (n.startsWith("col:")) {
1310
- e.preventDefault();
1311
- let t = this.appCells(r).find((e) => this.columnKey(e) === n.slice(4));
1312
- t && this.toggleColumn(t, t.hasAttribute("data-bk-hidden")), this.requestUpdate();
1313
- }
1314
- }
1315
- }
1316
- }
1317
- columnItems(t) {
1318
- let r = this.i18n.t.bind(this.i18n), i = this.headRow, a = this.appCells(i), o = a.indexOf(t), s = a.filter((e) => !e.hasAttribute("data-bk-hidden")), c = a.filter((e) => e.hasAttribute("data-hideable")), l = t.getAttribute("data-pin"), u = this.matches(":dir(rtl)"), d = [];
1319
- return this.sortable && t.dataset.sort && d.push([e`<bk-menu-item value="sort-asc" icon="arrow-up">${r("tableSortAscending")}</bk-menu-item>`, e`<bk-menu-item value="sort-desc" icon="arrow-down">${r("tableSortDescending")}</bk-menu-item>`]), d.push([
1320
- ...l === "start" ? [] : [e`<bk-menu-item value="pin-start">${r("tablePinStart")}</bk-menu-item>`],
1321
- ...l === "end" ? [] : [e`<bk-menu-item value="pin-end">${r("tablePinEnd")}</bk-menu-item>`],
1322
- ...l ? [e`<bk-menu-item value="unpin">${r("tableUnpin")}</bk-menu-item>`] : []
1323
- ]), t.hasAttribute("data-reorderable") && d.push([e`<bk-menu-item value="move-left" icon="arrow-back" ?disabled=${!this.canMove(a, o, o + (u ? 1 : -1))}>${r("tableMoveLeft")}</bk-menu-item>`, e`<bk-menu-item value="move-right" icon="arrow-forward" ?disabled=${!this.canMove(a, o, o + (u ? -1 : 1))}>${r("tableMoveRight")}</bk-menu-item>`]), t.hasAttribute("data-hideable") && d.push([e`<bk-menu-item value="hide" icon="visibility-off" ?disabled=${s.length <= 1}>${r("tableHideColumn")}</bk-menu-item>`]), c.length && d.push([
1324
- e`<bk-menu-label>${r("tableColumns")}</bk-menu-label>`,
1325
- ...c.map((t) => {
1326
- let n = !t.hasAttribute("data-bk-hidden");
1327
- return e`<bk-menu-item type="checkbox" value=${`col:${this.columnKey(t)}`} ?checked=${n} ?disabled=${n && s.length <= 1}>${this.text(t)}</bk-menu-item>`;
1328
- }),
1329
- e`<bk-menu-item value="reset-columns" icon="refresh">${r("tableResetColumns")}</bk-menu-item>`
1330
- ]), t.hasAttribute("data-resizable") && d.push(this.resizeItems()), d.filter((e) => e.length).map((t, r) => e`${r ? e`<bk-menu-divider></bk-menu-divider>` : n}${t}`);
1331
- }
1332
- resizeItems() {
1333
- return [
1334
- e`<bk-menu-item value="wider" icon="add">${this.i18n.t("tableColumnWider")}</bk-menu-item>`,
1335
- e`<bk-menu-item value="narrower" icon="remove">${this.i18n.t("tableColumnNarrower")}</bk-menu-item>`,
1336
- e`<bk-menu-item value="reset" icon="refresh">${this.i18n.t("tableColumnReset")}</bk-menu-item>`
1337
- ];
1338
- }
1339
- syncHandles() {
1340
- let e = [
1341
- ...this.headRows,
1342
- ...this.bodyRows,
1343
- ...this.footRows
1344
- ];
1345
- if (!this.reorderable) {
1346
- for (let t of e) t.querySelector(":scope > [data-bk-handle]")?.remove();
1347
- return;
1348
- }
1349
- this.headRows.forEach((e, t) => {
1350
- let n = this.leadCell(e, "handle", "th");
1351
- if (t === 0) {
1352
- let e = this.srText(n, this.i18n.t("tableOrder"));
1353
- e.id ||= `bk-table-order-${Math.random().toString(36).slice(2, 9)}`;
1354
- }
1355
- });
1356
- for (let e of this.footRows) this.leadCell(e, "handle", "td");
1357
- let t = this.instructions();
1358
- for (let e of this.bodyRows) {
1359
- if (e.hasAttribute("data-detail")) continue;
1360
- let n = this.leadCell(e, "handle", "td"), r = n.querySelector(":scope > .bk-table-handle");
1361
- if (!r) {
1362
- r = document.createElement("button"), r.type = "button", r.className = "bk-table-handle";
1363
- let e = document.createElement("bk-icon");
1364
- e.setAttribute("name", "drag-indicator"), r.append(e), n.append(r);
1365
- }
1366
- let i = this.i18n.t("sortableHandle", { item: this.rowName(e) });
1367
- r.getAttribute("aria-label") !== i && r.setAttribute("aria-label", i), t && r.getAttribute("aria-describedby") !== t.id && r.setAttribute("aria-describedby", t.id);
1368
- }
1369
- }
1370
- instructions() {
1371
- let e = this.headRow?.querySelector(":scope > [data-bk-handle]");
1372
- if (!e) return null;
1373
- let t = e.querySelector(":scope > .bk-table-help");
1374
- t || (t = document.createElement("span"), t.className = "bk-table-sr bk-table-help", t.hidden = !0, t.id = `bk-table-help-${Math.random().toString(36).slice(2, 9)}`, e.append(t));
1375
- let n = this.i18n.t("sortableInstructions");
1376
- return t.textContent !== n && (t.textContent = n), t;
1377
- }
1378
- get movableRows() {
1379
- return this.dataRows.filter((e) => !e.hidden);
1380
- }
1381
- startLift(e, t) {
1382
- let n = this.movableRows, r = n.indexOf(e);
1383
- return r < 0 ? null : (this.lift = {
1384
- row: e,
1385
- rows: n,
1386
- from: r,
1387
- to: r,
1388
- mode: t
1389
- }, e.setAttribute("data-bk-lifted", ""), t === "keyboard" && d(this.i18n.t("sortablePickedUp", {
1390
- item: this.rowName(e),
1391
- position: r + 1,
1392
- total: n.length
1393
- })), this.lift);
1394
- }
1395
- moveLift(e) {
1396
- let t = this.lift;
1397
- if (t) {
1398
- t.to = Math.max(0, Math.min(t.rows.length - 1, e));
1399
- for (let e of t.rows) e.removeAttribute("data-bk-drop");
1400
- t.to !== t.from && t.rows[t.to].setAttribute("data-bk-drop", t.to < t.from ? "before" : "after"), t.mode === "keyboard" && d(this.i18n.t("sortableMoved", {
1401
- item: this.rowName(t.row),
1402
- position: t.to + 1,
1403
- total: t.rows.length
1404
- }));
1405
- }
1406
- }
1407
- endLift(e) {
1408
- let t = this.lift;
1409
- if (!t) return;
1410
- this.lift = null, t.row.removeAttribute("data-bk-lifted");
1411
- for (let e of t.rows) e.removeAttribute("data-bk-drop");
1412
- let n = this.rowName(t.row);
1413
- !e || t.to === t.from ? t.mode === "keyboard" && d(this.i18n.t("sortableCancelled", {
1414
- item: n,
1415
- position: t.from + 1,
1416
- total: t.rows.length
1417
- })) : this.requestMove(t.row, t.from, t.to, t.rows.length);
1418
- }
1419
- requestMove(e, t, n, r) {
1420
- let i = e.dataset.key;
1421
- _(this, "reorder", {
1422
- type: "row",
1423
- key: i,
1424
- from: t,
1425
- to: n
1426
- }, !0) && (d(this.i18n.t("sortableDropped", {
1427
- item: this.rowName(e),
1428
- position: n + 1,
1429
- total: r
1430
- })), i !== void 0 && requestAnimationFrame(() => {
1431
- let e = this.keyedRows.find((e) => e.dataset.key === i)?.querySelector(":scope > [data-bk-handle] > .bk-table-handle");
1432
- e && !e.matches(":focus") && e.focus();
1433
- }));
1434
- }
1435
- onLiftKey(e, t) {
1436
- let n = this.lift;
1437
- if (!n) return e.key !== " " && e.key !== "Enter" ? !1 : (e.preventDefault(), this.startLift(t, "keyboard"), !0);
1438
- let r = {
1439
- ArrowUp: n.to - 1,
1440
- ArrowDown: n.to + 1,
1441
- Home: 0,
1442
- End: n.rows.length - 1
1443
- };
1444
- return e.key in r ? (e.preventDefault(), this.moveLift(r[e.key])) : e.key === " " || e.key === "Enter" ? (e.preventDefault(), this.endLift(!0)) : e.key === "Escape" ? (e.preventDefault(), e.stopPropagation(), this.endLift(!1)) : e.key !== "Tab" && e.key !== "Shift" && e.preventDefault(), !0;
1445
- }
1446
- onPointerDown = (e) => {
1447
- let t = e.target?.closest?.(".bk-table-handle");
1448
- if (!t || t.closest("bk-table") !== this || e.button !== 0 || this.lift) return;
1449
- let n = t.closest("tr");
1450
- e.preventDefault(), t.focus(), t.setPointerCapture(e.pointerId);
1451
- let r = e.clientY, i = !1, a = [], o = (e) => {
1452
- if (!i) {
1453
- if (Math.abs(e.clientY - r) < W) return;
1454
- let t = this.startLift(n, "pointer");
1455
- if (!t) return;
1456
- i = !0, a = t.rows.map((e) => {
1457
- let t = e.getBoundingClientRect();
1458
- return t.top + t.height / 2;
1459
- });
1460
- }
1461
- let t = this.lift, o = a.findIndex((t) => e.clientY < t);
1462
- o < 0 ? o = a.length - 1 : o > t.from && --o, this.moveLift(o);
1463
- }, s = (e) => {
1464
- t.removeEventListener("pointermove", o), t.removeEventListener("pointerup", s), t.removeEventListener("pointercancel", s), i ? this.endLift(e.type === "pointerup") : e.type === "pointerup" && this.openRowMenu(n, t);
1465
- };
1466
- t.addEventListener("pointermove", o), t.addEventListener("pointerup", s), t.addEventListener("pointercancel", s);
1467
- };
1468
- openRowMenu(e, t) {
1469
- this.handleRow = e, this.requestUpdate(), T(this, t);
1470
- }
1471
- get rowActions() {
1472
- let e = this.handleRow;
1473
- if (!e?.isConnected) return [];
1474
- let t = this.movableRows, n = t.indexOf(e), r = (r) => () => this.requestMove(e, n, r, t.length), i = this.i18n.t.bind(this.i18n);
1475
- return [
1476
- {
1477
- key: "up",
1478
- label: i("sortableMoveUp"),
1479
- disabled: n <= 0,
1480
- run: r(n - 1)
1481
- },
1482
- {
1483
- key: "down",
1484
- label: i("sortableMoveDown"),
1485
- disabled: n >= t.length - 1,
1486
- run: r(n + 1)
1487
- },
1488
- {
1489
- key: "top",
1490
- label: i("sortableMoveTop"),
1491
- disabled: n <= 0,
1492
- divider: !0,
1493
- run: r(0)
1494
- },
1495
- {
1496
- key: "bottom",
1497
- label: i("sortableMoveBottom"),
1498
- disabled: n >= t.length - 1,
1499
- run: r(t.length - 1)
1500
- }
1501
- ];
1502
- }
1503
- get cards() {
1504
- return this.internals.states.has("cards");
1505
- }
1506
- setRole(e, t) {
1507
- let n = e.hasAttribute("data-bk-role");
1508
- t ? (n || !e.hasAttribute("role")) && (e.getAttribute("role") !== t && e.setAttribute("role", t), n || e.setAttribute("data-bk-role", "")) : n && (e.removeAttribute("role"), e.removeAttribute("data-bk-role"));
1509
- }
1510
- syncRoles() {
1511
- let e = this.table, t = this.navigation === "cell", n = this.cards;
1512
- this.setRole(e, this.tree ? "treegrid" : t ? "grid" : n ? "table" : null);
1513
- for (let t of e.querySelectorAll(":scope > :is(thead, tbody, tfoot)")) this.setRole(t, n ? "rowgroup" : null);
1514
- for (let e of this.querySelectorAll(Y)) {
1515
- this.setRole(e, n ? "row" : null);
1516
- let r = e.parentElement?.localName === "thead";
1517
- for (let i of e.cells) i.localName === "td" ? this.setRole(i, t || this.tree ? "gridcell" : n ? "cell" : null) : this.setRole(i, n ? r || i.getAttribute("scope") === "col" ? "columnheader" : "rowheader" : null);
1518
- }
1519
- if (this.virtual && this.renderRow) {
1520
- let t = this.headRows.length;
1521
- e.setAttribute("aria-rowcount", String(t + (this.rows?.length ?? 0) + this.footRows.length)), this.headRows.forEach((e, t) => e.setAttribute("aria-rowindex", String(t + 1))), this.footRows.forEach((e, n) => e.setAttribute("aria-rowindex", String(t + (this.rows?.length ?? 0) + n + 1)));
1522
- } else e.hasAttribute("aria-rowcount") && e.removeAttribute("aria-rowcount");
1523
- }
1524
- setTab(e, t) {
1525
- if (t === null) {
1526
- if (!e.hasAttribute("data-bk-tabindex")) return;
1527
- let t = e.getAttribute("data-bk-tabindex");
1528
- t ? e.setAttribute("tabindex", t) : e.removeAttribute("tabindex"), e.removeAttribute("data-bk-tabindex");
1529
- } else e.hasAttribute("data-bk-tabindex") || e.setAttribute("data-bk-tabindex", e.getAttribute("tabindex") ?? ""), e.getAttribute("tabindex") !== String(t) && e.setAttribute("tabindex", String(t));
1530
- }
1531
- widgets(e) {
1532
- return [...e.querySelectorAll(q)].filter((t) => !t.closest(".bk-table-editor") && !t.closest(".bk-table-sr") && t.closest("td, th") === e);
1533
- }
1534
- target(e) {
1535
- let t = this.widgets(e);
1536
- return t.length === 1 ? t[0] : e;
1537
- }
1538
- get gridRows() {
1539
- return [
1540
- ...this.headRows,
1541
- ...this.bodyRows.filter((e) => !e.hidden),
1542
- ...this.footRows
1543
- ];
1544
- }
1545
- visibleCells(e) {
1546
- return [...e.cells].filter((e) => !e.hasAttribute("data-bk-hidden"));
1547
- }
1548
- syncFocus() {
1549
- let e = this.table, t = this.navigation === "cell", n = [...e.querySelectorAll("[data-bk-tabindex]")].filter((e) => e.closest("bk-table") === this);
1550
- if (!t && !this.tree) {
1551
- for (let e of n) this.setTab(e, null);
1552
- this.stop = null;
1553
- return;
1554
- }
1555
- let r = this.gridRows, i = [];
1556
- if (this.tree && i.push(...this.dataRows), t) for (let e of r) for (let t of e.cells) i.push(t, ...this.widgets(t));
1557
- let a = new Set(i);
1558
- for (let e of n) a.has(e) || this.setTab(e, null);
1559
- if (!((e) => !!e && e.isConnected && a.has(e) && !e.closest("[hidden], [data-bk-hidden]"))(this.stop)) {
1560
- let e = this.tree ? this.dataRows.find((e) => !e.hidden) : r[0] && this.visibleCells(r[0])[0];
1561
- this.stop = e ? this.tree ? e : this.target(e) : null;
1562
- }
1563
- for (let e of i) this.setTab(e, e === this.stop ? 0 : -1);
1564
- }
1565
- focusStop(e) {
1566
- e && (this.stop && this.stop !== e && this.stop.isConnected && this.setTab(this.stop, -1), this.stop = e, this.setTab(e, 0), e.focus());
1567
- }
1568
- onFocusIn = (e) => {
1569
- let t = e.target;
1570
- if (t.closest?.("bk-table") !== this || t.closest(".bk-table-editor") || this.navigation !== "cell" && !this.tree) return;
1571
- let n = t.closest("td, th"), r = this.navigation === "cell" && n ? t : this.tree ? t.closest("tr") : null;
1572
- r && r !== this.stop && r.hasAttribute("data-bk-tabindex") && (this.stop?.isConnected && this.setTab(this.stop, -1), this.stop = r, this.setTab(this.stop, 0));
1573
- };
1574
- onFocusOut = (e) => {
1575
- this.shiftDown = !1;
1576
- let t = e.target;
1577
- this.lift?.mode === "keyboard" && t.classList?.contains("bk-table-handle") && this.endLift(!1), this.editing && t.closest?.(".bk-table-editor") && !this.editing.field.contains(e.relatedTarget) && setTimeout(() => this.editing && !this.editing.field.matches(":focus-within") && this.commitEdit(!1, !1));
1578
- };
1579
- async rowAt(e) {
1580
- let t = this.headRows;
1581
- if (e < t.length) return t[e] ?? null;
1582
- if (this.virtual && this.renderRow) {
1583
- let n = this.rows?.length ?? 0;
1584
- if (e < t.length + n) {
1585
- let n = e - t.length;
1586
- return this.vc.reveal(n), this.requestUpdate(), await this.updateComplete, c(this)?.querySelector(`:scope > table > tbody > tr[data-bk-index="${n}"]`) ?? null;
1587
- }
1588
- return this.footRows[e - t.length - n] ?? null;
1589
- }
1590
- return this.gridRows[e] ?? null;
1591
- }
1592
- rowIndex(e) {
1593
- let t = this.headRows;
1594
- if (this.virtual && this.renderRow) {
1595
- let n = this.rows?.length ?? 0, r = t.length + n + this.footRows.length;
1596
- return t.includes(e) ? [t.indexOf(e), r] : e.dataset.bkIndex === void 0 ? [t.length + n + this.footRows.indexOf(e), r] : [t.length + Number(e.dataset.bkIndex), r];
1597
- }
1598
- let n = this.gridRows;
1599
- return [n.indexOf(e), n.length];
1600
- }
1601
- pageRows() {
1602
- let e = this.scroller, t = this.dataRows[0];
1603
- return !e || !t || e.scrollHeight <= e.clientHeight ? G : Math.max(1, Math.floor(e.clientHeight / Math.max(1, t.offsetHeight)) - 1);
1604
- }
1605
- async onGridKey(e, t) {
1606
- let n = t.parentElement, r = this.matches(":dir(rtl)"), i = e.ctrlKey || e.metaKey, a = this.visibleCells(n).indexOf(t), [o, s] = this.rowIndex(n), c = o, l = a;
1607
- switch (e.key) {
1608
- case "ArrowRight":
1609
- l = a + (r ? -1 : 1);
1610
- break;
1611
- case "ArrowLeft":
1612
- if (this.tree && a === 0 && n.hasAttribute("data-bk-tree")) {
1613
- e.preventDefault(), this.focusStop(n);
1614
- return;
1615
- }
1616
- l = a + (r ? 1 : -1);
1617
- break;
1618
- case "ArrowDown":
1619
- c = o + 1;
1620
- break;
1621
- case "ArrowUp":
1622
- c = o - 1;
1623
- break;
1624
- case "Home":
1625
- l = 0, i && (c = 0);
1626
- break;
1627
- case "End":
1628
- l = 1e400, i && (c = s - 1);
1629
- break;
1630
- case "PageDown":
1631
- c = o + this.pageRows();
1632
- break;
1633
- case "PageUp":
1634
- c = o - this.pageRows();
1635
- break;
1636
- default: return;
1637
- }
1638
- e.preventDefault(), c = Math.max(0, Math.min(s - 1, c));
1639
- let u = c === o ? n : await this.rowAt(c);
1640
- if (!u) return;
1641
- let d = this.visibleCells(u), f = d[Math.max(0, Math.min(d.length - 1, l))];
1642
- f && this.focusStop(this.target(f));
1643
- }
1644
- onTreeKey(e, t) {
1645
- let n = this.dataRows.filter((e) => !e.hidden), r = n.indexOf(t), i = t.hasAttribute("data-bk-parent"), a = t.hasAttribute("data-expanded"), o = this.matches(":dir(rtl)");
1646
- switch (o && e.key === "ArrowRight" ? "ArrowLeft" : o && e.key === "ArrowLeft" ? "ArrowRight" : e.key) {
1647
- case "ArrowDown":
1648
- this.focusStop(n[r + 1]);
1649
- break;
1650
- case "ArrowUp":
1651
- this.focusStop(n[r - 1]);
1652
- break;
1653
- case "Home":
1654
- this.focusStop(n[0]);
1655
- break;
1656
- case "End":
1657
- this.focusStop(n.at(-1));
1658
- break;
1659
- case "ArrowRight":
1660
- i && !a ? this.toggleOpen(t, !0) : this.navigation === "cell" && this.focusStop(this.target(this.visibleCells(t)[0]));
1661
- break;
1662
- case "ArrowLeft":
1663
- if (i && a) this.toggleOpen(t, !1);
1664
- else {
1665
- let e = this.level(t);
1666
- this.focusStop(n.slice(0, r).reverse().find((t) => this.level(t) < e));
1667
- }
1668
- break;
1669
- case "Enter":
1670
- if (!i) return;
1671
- this.toggleOpen(t);
1672
- break;
1673
- case " ": {
1674
- let e = t.querySelector(":scope > [data-bk-select] > bk-checkbox");
1675
- if (!e) return;
1676
- e.click();
1677
- break;
1678
- }
1679
- default: return;
1680
- }
1681
- e.preventDefault();
1682
- }
1683
- async startEdit(e) {
1684
- if (this.editing || !e.hasAttribute("data-editable") || this.navigation !== "cell") return;
1685
- let t = z.start();
1686
- if (t && (await t, this.editing)) return;
1687
- let n = this.headOf(e), r = e.dataset.value ?? this.text(e), i = document.createElement(e.dataset.field === "number" ? "bk-input-number" : "bk-input-text");
1688
- i.className = "bk-table-editor", i.setAttribute("size", "sm"), i.setAttribute("aria-label", n ? this.text(n) : ""), i.value = r, e.setAttribute("data-bk-editing", ""), e.append(i), this.editing = {
1689
- cell: e,
1690
- field: i,
1691
- old: r
1692
- }, await i.updateComplete, i.focus(), (i.shadowRoot?.querySelector("input"))?.select?.();
1693
- }
1694
- commitEdit(e, t = !0) {
1695
- let n = this.editing;
1696
- if (!n) return;
1697
- let { cell: r, field: i, old: a } = n, o = String(i.value ?? "");
1698
- if (!e && i.checkValidity && !i.checkValidity()) {
1699
- i.reportValidity?.();
1700
- return;
1701
- }
1702
- if (this.editing = null, i.remove(), r.removeAttribute("data-bk-editing"), t && this.focusStop(r), e || o === a) return;
1703
- let s = this.headOf(r), c = r.parentElement;
1704
- _(this, "edit", {
1705
- key: c.dataset.key,
1706
- column: s ? this.columnKey(s) : String(r.cellIndex),
1707
- value: o,
1708
- oldValue: a
1709
- }, !0) && d(this.i18n.t("tableCellChanged", {
1710
- column: s ? this.text(s) : "",
1711
- value: o
1712
- }));
1713
- }
1714
- onDoubleClick = (e) => {
1715
- let t = e.target?.closest?.("td[data-editable]");
1716
- t && t.closest("bk-table") === this && this.startEdit(t);
1717
- };
1718
- onKeydown = (e) => {
1719
- let t = e.target;
1720
- if (e.defaultPrevented || !t?.closest || t.closest("bk-table") !== this) return;
1721
- if (this.editing && t.closest(".bk-table-editor")) {
1722
- e.key === "Enter" ? (e.preventDefault(), this.commitEdit(!1)) : e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.commitEdit(!0));
1723
- return;
1724
- }
1725
- if (!this.table?.contains(t)) return;
1726
- if ((e.ctrlKey || e.metaKey) && !e.altKey && e.key.toLowerCase() === "c") {
1727
- if (t.closest("input, textarea, [contenteditable]") || !document.getSelection()?.isCollapsed) return;
1728
- (this.selection && this.keys.size || this.navigation === "cell") && (e.preventDefault(), this.copySelection());
1729
- return;
1730
- }
1731
- if (e.altKey) return;
1732
- let n = t.closest(".bk-table-resize");
1733
- if (n && !e.ctrlKey && !e.metaKey && [
1734
- "ArrowLeft",
1735
- "ArrowRight",
1736
- "Home"
1737
- ].includes(e.key)) return this.onHandleKey(e, n);
1738
- let r = t.closest(".bk-table-handle");
1739
- if (r && this.onLiftKey(e, r.closest("tr"))) return;
1740
- let i = t.closest("td, th");
1741
- if (this.tree && t.localName === "tr" && t.hasAttribute("data-bk-tree")) return this.onTreeKey(e, t);
1742
- if (this.navigation === "cell" && i) {
1743
- if (t === i && (e.key === "Enter" || e.key === "F2")) {
1744
- if (i.hasAttribute("data-editable")) {
1745
- e.preventDefault(), this.startEdit(i);
1746
- return;
1747
- }
1748
- let t = this.widgets(i);
1749
- if (t.length > 1) {
1750
- e.preventDefault(), t[0].focus();
1751
- return;
1752
- }
1753
- }
1754
- if (t !== i && e.key === "Escape" && this.widgets(i).length > 1) {
1755
- e.preventDefault(), this.focusStop(i);
1756
- return;
1757
- }
1758
- if ([
1759
- "ArrowRight",
1760
- "ArrowLeft",
1761
- "ArrowDown",
1762
- "ArrowUp",
1763
- "Home",
1764
- "End",
1765
- "PageDown",
1766
- "PageUp"
1767
- ].includes(e.key)) {
1768
- if (t !== i && t.closest("input, textarea, select, [contenteditable]")) return;
1769
- this.onGridKey(e, i);
1770
- }
1771
- return;
1772
- }
1773
- if (e.ctrlKey || e.metaKey || this.selection !== "single" && this.selection !== "multiple") return;
1774
- let a = t.closest("tr[data-bk-selectable]");
1775
- if (!a) return;
1776
- let o = a.querySelector(":scope > [data-bk-select] > bk-checkbox");
1777
- (e.key === "ArrowDown" || e.key === "ArrowUp") && t === o && (e.preventDefault(), this.moveSelectionFocus(a, e.key === "ArrowDown" ? 1 : -1));
1778
- };
1779
- async moveSelectionFocus(e, t) {
1780
- let n;
1781
- if (this.virtual && this.renderRow && e.dataset.bkIndex !== void 0) {
1782
- let r = Number(e.dataset.bkIndex) + t;
1783
- if (r < 0 || r >= (this.rows?.length ?? 0)) return;
1784
- n = await this.rowAt(this.headRows.length + r);
1785
- } else {
1786
- let r = this.keyedRows.filter((e) => !e.hidden);
1787
- n = r[r.indexOf(e) + t];
1788
- }
1789
- n?.querySelector(":scope > [data-bk-select] > bk-checkbox")?.focus();
1790
- }
1791
- syncCards() {
1792
- let e = this.headRow, t = this.cards;
1793
- for (let n of this.querySelectorAll(":scope > table > :is(tbody, tfoot) > tr")) if (!(n.hasAttribute("data-bk-spacer") || n.hasAttribute("data-detail"))) for (let r of this.appCells(n)) {
1794
- let i = t && e ? e.cells[r.cellIndex] : null, a = i?.dataset.card, o = a === "title" || !a && r.localName === "th" && n.parentElement?.localName === "tbody", s = i && !o && a !== "meta" ? this.text(i) : null;
1795
- s ? r.getAttribute("data-bk-label") !== s && r.setAttribute("data-bk-label", s) : r.removeAttribute("data-bk-label"), a ? r.getAttribute("data-bk-card") !== a && r.setAttribute("data-bk-card", a) : r.removeAttribute("data-bk-card");
1796
- let c = t && r.dataset.type !== "number" && i?.dataset.type === "number";
1797
- r.hasAttribute("data-bk-number") !== c && r.toggleAttribute("data-bk-number", c);
1798
- }
1799
- }
1800
- syncMarks() {
1801
- let e = this.headRow, t = this.columnRows.filter((e) => !e.hasAttribute("data-bk-spacer")), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
1802
- if (e) for (let t of this.appCells(e)) {
1803
- let e = t.hasAttribute("data-highlight");
1804
- e && n.add(t.cellIndex), t.dataset.type === "check" && r.add(t.cellIndex);
1805
- let i = t.querySelector(":scope > [data-bk-note]");
1806
- if (!e) {
1807
- i?.remove();
1808
- continue;
1809
- }
1810
- i || (i = document.createElement("span"), i.className = "bk-table-sr", i.setAttribute("data-bk-note", ""), t.append(i));
1811
- let a = ` ${t.getAttribute("data-highlight")?.trim() || this.i18n.t("tableRecommended")}`;
1812
- i.textContent !== a && (i.textContent = a);
1813
- }
1814
- t.forEach((e, i) => {
1815
- let a = e.parentElement?.localName === "thead";
1816
- for (let o of this.appCells(e)) {
1817
- let e = i === 0 ? "first" : i === t.length - 1 ? "last" : "";
1818
- n.has(o.cellIndex) ? o.getAttribute("data-bk-highlight") !== e && o.setAttribute("data-bk-highlight", e) : o.removeAttribute("data-bk-highlight");
1819
- let s = !a && (o.dataset.type ?? (r.has(o.cellIndex) ? "check" : "")) === "check";
1820
- o.hasAttribute("data-bk-check-column") !== s && o.toggleAttribute("data-bk-check-column", s), this.syncCheck(o, s);
1821
- }
1822
- });
1823
- }
1824
- syncCheck(e, t) {
1825
- let n = e.querySelector(":scope > .bk-table-check"), r = e.querySelector(":scope > [data-bk-check-value]"), i = (t ? e.dataset.value ?? [...e.childNodes].filter((e) => e !== n && e.nodeType !== Node.COMMENT_NODE).map((e) => e.textContent).join("") : "").trim().toLowerCase(), a = [this.i18n.t("tableYes"), this.i18n.t("tableNo")].map((e) => e.toLowerCase()), o = Z.has(i) || i === a[0];
1826
- if (!(t && (o || ne.has(i) || i === a[1]))) {
1827
- if (!n) return;
1828
- n.remove(), r?.replaceWith(...r.childNodes), e.removeAttribute("data-bk-check");
1829
- return;
1830
- }
1831
- r || (r = document.createElement("span"), r.setAttribute("data-bk-check-value", ""), r.hidden = !0, e.append(r));
1832
- let s = [...e.childNodes].filter((e) => e !== n && e !== r);
1833
- s.length && r.append(...s);
1834
- let c = o ? "yes" : "no";
1835
- n || (n = document.createElement("span"), n.className = "bk-table-check", n.append(document.createElement("bk-icon"), Object.assign(document.createElement("span"), { className: "bk-table-sr" })), e.prepend(n));
1836
- let l = n.querySelector("bk-icon"), u = o ? "check" : "remove";
1837
- l.getAttribute("name") !== u && l.setAttribute("name", u);
1838
- let d = this.i18n.t(o ? "tableYes" : "tableNo"), f = n.querySelector(".bk-table-sr");
1839
- f.textContent !== d && (f.textContent = d), e.getAttribute("data-bk-check") !== c && e.setAttribute("data-bk-check", c);
1840
- }
1841
- get columnCount() {
1842
- let e = this.headRow;
1843
- return e ? this.visibleCells(e).length : 1;
1844
- }
1845
- syncState() {
1846
- let e = this.table, t = this.isEmpty;
1847
- t !== this.empty && (this.empty = t);
1848
- let n = e.querySelector(":scope > tbody[data-bk-state]"), r = this.busy && t ? Math.max(1, this.skeletonRows || 0) : 0;
1849
- if (!r) {
1850
- n?.remove();
1851
- return;
1852
- }
1853
- n || (n = document.createElement("tbody"), n.setAttribute("data-bk-state", ""), n.setAttribute("aria-hidden", "true"), e.append(n));
1854
- let i = this.columnCount;
1855
- (n.rows.length !== r || n.rows[0]?.cells.length !== i) && n.replaceChildren(...Array.from({ length: r }, () => {
1856
- let e = document.createElement("tr");
1857
- e.setAttribute("data-bk-skeleton", "");
1858
- for (let t = 0; t < i; t++) e.append(Object.assign(document.createElement("td"), { innerHTML: "<bk-skeleton></bk-skeleton>" }));
1859
- return e;
1860
- }));
1861
- }
1862
- renderWindow() {
1863
- let t = this.body;
1864
- if (!t || !this.renderRow) return;
1865
- let i = this.rows ?? [], a = this.vc, s = a.count ? a.total / a.count : 0, c = a.offset, l = Math.max(0, a.total - a.offset - (a.end - a.start) * s), u = this.columnCount, d = (t) => e`<tr data-bk-spacer aria-hidden="true"><td colspan=${u} style=${o({ blockSize: `${t}px` })}></td></tr>`;
1866
- r(e`${c > 0 ? d(c) : n}${i.slice(a.start, a.end).map((e, t) => this.renderRow(e, a.start + t))}${l > 0 ? d(l) : n}`, t);
1867
- let f = this.headRows.length, p = a.start;
1868
- for (let e of t.rows) e.hasAttribute("data-bk-spacer") || (e.setAttribute("data-bk-index", String(p)), e.setAttribute("aria-rowindex", String(f + p + 1)), p++);
1869
- this.syncAll();
1870
- }
1871
- clearWindow() {
1872
- let e = this.body;
1873
- e && r(n, e);
1874
- }
1875
- measure() {
1876
- let e = this.scroller, t = !!e && (e.scrollWidth > e.clientWidth + 1 || e.scrollHeight > e.clientHeight + 1);
1877
- t !== this.scrolling && (this.scrolling = t);
1878
- let n = c(this)?.querySelector(":scope > table > thead"), r = c(this)?.querySelector(":scope > table > tfoot"), i = this.stickyHeader && n ? `${n.offsetHeight}px` : "", a = this.stickyFooter && r ? `${r.offsetHeight}px` : "";
1879
- e && e.style.scrollPaddingBlockStart !== i && (e.style.scrollPaddingBlockStart = i), e && e.style.scrollPaddingBlockEnd !== a && (e.style.scrollPaddingBlockEnd = a);
1880
- let o = this.renderRoot.querySelector(".probe"), s = this.responsive === "cards" && !!o && this.clientWidth > 0 && this.clientWidth < parseFloat(getComputedStyle(o).marginInlineStart);
1881
- s !== this.cards && (s ? this.internals.states.add("cards") : this.internals.states.delete("cards"), this.syncAll(), this.requestUpdate(), s && this.sortable && import("./bk-select.js"));
1882
- let l = this.headRow;
1883
- l && l.querySelector("[data-pin]") && this.syncPins(l);
1884
- }
1885
- get regionName() {
1886
- let e = c(this)?.querySelector(":scope > table > caption")?.textContent?.replace(/\s+/g, " ").trim();
1887
- return this.label || e || this.i18n.t("table");
1888
- }
1889
- render() {
1890
- let t = this.menuColumn ? this.text(this.menuColumn) : "", r = this.filterItems, i = this.slots.has("error"), a = this.empty && !this.busy && !i && this.slots.has("empty"), o = this.filterKey ? this.headRow && this.appCells(this.headRow).find((e) => e.dataset.filter === this.filterKey) : null, s = this.i18n.t("tableFilterColumn", { column: o ? this.text(o) : "" }), c = this.sortable && this.cards && this.headRow ? this.appCells(this.headRow).filter((e) => e.dataset.sort).map((e) => ({
1891
- key: e.dataset.sort,
1892
- text: this.text(e) || e.dataset.sort
1893
- })) : [], l = this.sortDir === "desc";
1894
- return e`${c.length ? e`<div class="card-sort" part="card-sort">
1895
- <bk-select size="sm" label-position="start" label=${this.i18n.t("tableSortBy")} placeholder=${this.sortKey ? n : this.i18n.t("tableSortBy")}
1896
- .value=${this.sortKey ?? ""} @input=${(e) => e.stopPropagation()} @change=${this.onCardSort}>
1897
- ${c.map((t) => e`<option value=${t.key}>${t.text}</option>`)}
1898
- </bk-select>
1899
- <bk-button size="sm" variant="outline" icon=${l ? "arrow-down" : "arrow-up"} ?disabled=${!this.sortKey}
1900
- label=${this.i18n.t(l ? "tableSortAscending" : "tableSortDescending")} @click=${this.onCardSortDir}></bk-button>
1901
- </div>` : n}
1902
- ${r.length ? e`<bk-filter-bar class="filter-bar" part="filter-bar" .items=${r}
1903
- @remove=${this.onFilterRemove} @clear=${this.onFilterClear}></bk-filter-bar>` : n}
1904
- <div class="frame">
1905
- <div class="scroller" part="scroller" tabindex=${this.scrolling ? "0" : n} ?inert=${this.busyState.inert && !this.empty}
1906
- role=${this.scrolling ? "region" : n} aria-label=${this.scrolling ? this.regionName : n}>
1907
- <slot @slotchange=${() => {
1908
- this.observedTable = null, this.observe();
1909
- }}></slot>
1910
- <div class="state" part="state" ?hidden=${!i && !a}>
1911
- <div role="alert" ?hidden=${!i}><slot name="error"></slot></div>
1912
- <div ?hidden=${!a}><slot name="empty"></slot></div>
1913
- </div>
1914
- ${this.virtual ? e`<div class="sentinel"></div>` : n}
1915
- </div>
1916
- ${this.empty ? n : this.busyState.veil()}
1917
- </div>
1918
- ${this.responsive === "cards" ? e`<div class="probe" aria-hidden="true"></div>` : n}
1919
- ${this.resizable ? e`<bk-menu-context class="column-menu" exportparts="menu: column-menu"
1920
- label=${this.i18n.t(this.menuKind === "resize" ? "tableResizeColumn" : "tableColumnMenu", { column: t })}
1921
- @select=${this.onColumnMenu} @close=${this.onColumnMenuClose}>
1922
- ${this.menuColumn ? this.menuKind === "resize" ? this.resizeItems() : this.columnItems(this.menuColumn) : this.resizeItems()}
1923
- </bk-menu-context>` : n}
1924
- ${this.filterable ? e`<div class="filter-anchor"><bk-popover class="filter-popover" part="filter-popover" label=${s} @close=${this.onFilterClose}>
1925
- <div class="filter-body">
1926
- ${this.filterKey ? e`<slot name=${`filter-${this.filterKey}`}></slot>` : n}
1927
- <div class="filter-actions">
1928
- <bk-button variant="ghost" size="sm" @click=${() => this.onFilterApply(!0)}>${this.i18n.t("tableFilterClear")}</bk-button>
1929
- <bk-button variant="solid" size="sm" @click=${() => this.onFilterApply(!1)}>${this.i18n.t("tableFilterApply")}</bk-button>
1930
- </div>
1931
- </div>
1932
- </bk-popover></div>` : n}
1933
- ${this.reorderable ? O(this.handleRow ? this.i18n.t("sortableHandle", { item: this.rowName(this.handleRow) }) : "", this.rowActions) : n}`;
1934
- }
1935
- };
1936
- u("bk-table", $);
1937
- export { $ as BkTable };
1
+ export { t as BkTable } from "./chunks/bk-table-CP8n_jy7.js";