@bk2k/ui 0.6.7 → 0.6.8

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 (226) hide show
  1. package/BUILDING.md +32 -0
  2. package/CHANGELOG.md +57 -0
  3. package/USAGE.md +14 -8
  4. package/custom-elements.json +1 -1
  5. package/dist/charts/frame.d.ts +2 -0
  6. package/dist/charts/frame.js +2 -1
  7. package/dist/components/bk-button.d.ts +18 -3
  8. package/dist/components/bk-button.js +19 -8
  9. package/dist/components/bk-chart-bar.d.ts +46 -9
  10. package/dist/components/bk-chart-bar.js +127 -37
  11. package/dist/components/bk-combobox.d.ts +29 -5
  12. package/dist/components/bk-combobox.js +61 -19
  13. package/dist/components/bk-dialog.d.ts +4 -1
  14. package/dist/components/bk-dialog.js +6 -2
  15. package/dist/components/bk-facts-item.js +8 -6
  16. package/dist/components/bk-facts.d.ts +6 -4
  17. package/dist/components/bk-facts.js +19 -8
  18. package/dist/components/bk-input-time-zone.d.ts +3 -0
  19. package/dist/components/bk-model-viewer.d.ts +12 -1
  20. package/dist/components/bk-model-viewer.js +15 -2
  21. package/dist/components/bk-period-nav.d.ts +102 -0
  22. package/dist/components/bk-period-nav.js +69 -0
  23. package/dist/components/bk-select.js +2 -1
  24. package/dist/components/bk-shell-app.d.ts +3 -2
  25. package/dist/components/bk-shell-app.js +16 -3
  26. package/dist/components/bk-sortable.d.ts +3 -0
  27. package/dist/components/bk-sortable.js +3 -0
  28. package/dist/components/bk-split.d.ts +3 -0
  29. package/dist/components/bk-split.js +3 -0
  30. package/dist/components/bk-table.d.ts +16 -12
  31. package/dist/components/bk-table.js +96 -14
  32. package/dist/i18n/de.js +7 -0
  33. package/dist/i18n.d.ts +7 -0
  34. package/dist/i18n.js +7 -0
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.js +1 -0
  37. package/dist/internal/cloak.d.ts +3 -0
  38. package/dist/internal/cloak.js +4 -0
  39. package/dist/internal/handle-menu.d.ts +2 -3
  40. package/dist/internal/handle-menu.js +14 -3
  41. package/dist/internal/late.d.ts +15 -0
  42. package/dist/internal/late.js +30 -0
  43. package/dist/jsx.d.ts +36 -5
  44. package/dist/standalone/all.js +119 -118
  45. package/dist/standalone/bk-action-bar.js +1 -1
  46. package/dist/standalone/bk-alert-offline.js +1 -1
  47. package/dist/standalone/bk-alert.js +1 -1
  48. package/dist/standalone/bk-attachment.js +1 -1
  49. package/dist/standalone/bk-avatar-group.js +1 -1
  50. package/dist/standalone/bk-avatar.js +1 -1
  51. package/dist/standalone/bk-breadcrumbs.js +1 -1
  52. package/dist/standalone/bk-button-copy.js +2 -2
  53. package/dist/standalone/bk-button-group.js +2 -2
  54. package/dist/standalone/bk-button-share.js +2 -2
  55. package/dist/standalone/bk-button-top.js +1 -1
  56. package/dist/standalone/bk-button.js +15 -7
  57. package/dist/standalone/bk-calendar-week.js +1 -1
  58. package/dist/standalone/bk-calendar.js +1 -1
  59. package/dist/standalone/bk-card.js +1 -1
  60. package/dist/standalone/bk-carousel-controls.js +2 -2
  61. package/dist/standalone/bk-carousel.js +1 -1
  62. package/dist/standalone/bk-chart-bar-list.js +3 -3
  63. package/dist/standalone/bk-chart-bar.js +164 -105
  64. package/dist/standalone/bk-chart-bridge.js +4 -4
  65. package/dist/standalone/bk-chart-bullet.js +3 -3
  66. package/dist/standalone/bk-chart-calendar.js +4 -4
  67. package/dist/standalone/bk-chart-heatmap.js +4 -4
  68. package/dist/standalone/bk-chart-histogram.js +2 -2
  69. package/dist/standalone/bk-chart-legend.js +3 -3
  70. package/dist/standalone/bk-chart-line.js +5 -5
  71. package/dist/standalone/bk-chart-scatter.js +3 -3
  72. package/dist/standalone/bk-chart-sparkline.js +3 -3
  73. package/dist/standalone/bk-chart-stacked-bar.js +4 -4
  74. package/dist/standalone/bk-chart-tracker.js +3 -3
  75. package/dist/standalone/bk-chart-waterfall.js +2 -2
  76. package/dist/standalone/bk-checkbox-group.js +2 -2
  77. package/dist/standalone/bk-checkbox.js +1 -1
  78. package/dist/standalone/bk-chip-group.js +2 -2
  79. package/dist/standalone/bk-chip.js +2 -2
  80. package/dist/standalone/bk-code-diff.js +1 -1
  81. package/dist/standalone/bk-code-stack.js +2 -2
  82. package/dist/standalone/bk-code.js +2 -2
  83. package/dist/standalone/bk-color-panel.js +2 -2
  84. package/dist/standalone/bk-columns.js +1 -1
  85. package/dist/standalone/bk-combobox.js +49 -30
  86. package/dist/standalone/bk-command-menu.js +2 -2
  87. package/dist/standalone/bk-command-palette.js +3 -3
  88. package/dist/standalone/bk-composer.js +2 -2
  89. package/dist/standalone/bk-delta.js +1 -1
  90. package/dist/standalone/bk-diagram.js +1 -1
  91. package/dist/standalone/bk-dialog.js +1 -1
  92. package/dist/standalone/bk-drawer.js +2 -2
  93. package/dist/standalone/bk-error-summary.js +1 -1
  94. package/dist/standalone/bk-facts-item.js +8 -6
  95. package/dist/standalone/bk-facts.js +19 -8
  96. package/dist/standalone/bk-fieldset.js +1 -1
  97. package/dist/standalone/bk-filter-bar.js +1 -1
  98. package/dist/standalone/bk-folder-browser.js +1 -1
  99. package/dist/standalone/bk-form-guard.js +1 -1
  100. package/dist/standalone/bk-form-steps.js +1 -1
  101. package/dist/standalone/bk-image-compare.js +1 -1
  102. package/dist/standalone/bk-image-crop.js +2 -2
  103. package/dist/standalone/bk-image-editor.js +2 -1
  104. package/dist/standalone/bk-image-viewer.js +1 -1
  105. package/dist/standalone/bk-input-code.js +2 -2
  106. package/dist/standalone/bk-input-color.js +1 -1
  107. package/dist/standalone/bk-input-date-range.js +2 -2
  108. package/dist/standalone/bk-input-date.js +1 -1
  109. package/dist/standalone/bk-input-file.js +2 -2
  110. package/dist/standalone/bk-input-group.js +2 -2
  111. package/dist/standalone/bk-input-inline.js +2 -2
  112. package/dist/standalone/bk-input-number.js +2 -2
  113. package/dist/standalone/bk-input-rating.js +2 -2
  114. package/dist/standalone/bk-input-rich.js +1 -1
  115. package/dist/standalone/bk-input-search.js +1 -1
  116. package/dist/standalone/bk-input-slider-range.js +2 -2
  117. package/dist/standalone/bk-input-slider.js +2 -2
  118. package/dist/standalone/bk-input-text.js +1 -1
  119. package/dist/standalone/bk-input-time.js +3 -3
  120. package/dist/standalone/bk-item.js +1 -1
  121. package/dist/standalone/bk-kbd-shortcuts.js +1 -1
  122. package/dist/standalone/bk-kbd.js +1 -1
  123. package/dist/standalone/bk-lightbox.js +2 -2
  124. package/dist/standalone/bk-listbox-columns.js +2 -2
  125. package/dist/standalone/bk-listbox-search.js +3 -3
  126. package/dist/standalone/bk-listbox-transfer.js +3 -3
  127. package/dist/standalone/bk-listbox.js +2 -2
  128. package/dist/standalone/bk-logo.js +1 -1
  129. package/dist/standalone/bk-menu-bar.js +1 -1
  130. package/dist/standalone/bk-menu-item.js +1 -1
  131. package/dist/standalone/bk-menu-list.js +1 -1
  132. package/dist/standalone/bk-menu.js +2 -2
  133. package/dist/standalone/bk-message-approval.js +1 -1
  134. package/dist/standalone/bk-message-branches.js +1 -1
  135. package/dist/standalone/bk-message-citation.js +1 -1
  136. package/dist/standalone/bk-message-feedback.js +1 -1
  137. package/dist/standalone/bk-message-list.js +1 -1
  138. package/dist/standalone/bk-message-reasoning.js +1 -1
  139. package/dist/standalone/bk-message-source.js +1 -1
  140. package/dist/standalone/bk-message-tool-group.js +1 -1
  141. package/dist/standalone/bk-message-tool.js +1 -1
  142. package/dist/standalone/bk-message.js +1 -1
  143. package/dist/standalone/bk-meter.js +1 -1
  144. package/dist/standalone/bk-model-viewer.js +1 -1
  145. package/dist/standalone/bk-nav-group.js +1 -1
  146. package/dist/standalone/bk-nav-item.js +1 -1
  147. package/dist/standalone/bk-nav-toc.js +1 -1
  148. package/dist/standalone/bk-nav.js +1 -1
  149. package/dist/standalone/bk-overflow.js +1 -1
  150. package/dist/standalone/bk-page-footer.js +1 -1
  151. package/dist/standalone/bk-page-pager.js +1 -1
  152. package/dist/standalone/bk-pagination.js +1 -1
  153. package/dist/standalone/bk-pane.js +1 -1
  154. package/dist/standalone/bk-panel.js +1 -1
  155. package/dist/standalone/bk-period-nav.js +69 -0
  156. package/dist/standalone/bk-picture.js +1 -1
  157. package/dist/standalone/bk-popover-help.js +1 -1
  158. package/dist/standalone/bk-popover.js +1 -1
  159. package/dist/standalone/bk-preview.js +1 -1
  160. package/dist/standalone/bk-progress.js +1 -1
  161. package/dist/standalone/bk-qr-code.js +1 -1
  162. package/dist/standalone/bk-radio-group.js +2 -2
  163. package/dist/standalone/bk-radio.js +1 -1
  164. package/dist/standalone/bk-rating.js +1 -1
  165. package/dist/standalone/bk-scroll.js +1 -1
  166. package/dist/standalone/bk-segmented.js +2 -2
  167. package/dist/standalone/bk-select-cascade.js +1 -1
  168. package/dist/standalone/bk-select-tree.js +1 -1
  169. package/dist/standalone/bk-select.js +3 -2
  170. package/dist/standalone/bk-shell-app.js +42 -38
  171. package/dist/standalone/bk-shell-sites.js +1 -1
  172. package/dist/standalone/bk-sortable.js +7 -4
  173. package/dist/standalone/bk-split-grid.js +1 -1
  174. package/dist/standalone/bk-split.js +7 -4
  175. package/dist/standalone/bk-stat.js +2 -2
  176. package/dist/standalone/bk-steps-item.js +1 -1
  177. package/dist/standalone/bk-swatch-group.js +2 -2
  178. package/dist/standalone/bk-switch.js +2 -2
  179. package/dist/standalone/bk-table.js +130 -80
  180. package/dist/standalone/bk-tabs-item.js +1 -1
  181. package/dist/standalone/bk-tabs.js +1 -1
  182. package/dist/standalone/bk-tasks-item.js +1 -1
  183. package/dist/standalone/bk-text.js +1 -1
  184. package/dist/standalone/bk-time-countdown.js +1 -1
  185. package/dist/standalone/bk-time-relative.js +1 -1
  186. package/dist/standalone/bk-timeline-item.js +1 -1
  187. package/dist/standalone/bk-toast-group.js +1 -1
  188. package/dist/standalone/bk-toast.js +1 -1
  189. package/dist/standalone/bk-tooltip.js +1 -1
  190. package/dist/standalone/bk-tree-item.js +2 -2
  191. package/dist/standalone/bk-video.js +1 -1
  192. package/dist/standalone/bk-zoom.js +3 -3
  193. package/dist/standalone/chunks/{bk-alert-offline-BoMEYxnE.js → bk-alert-offline-B1bQxOZp.js} +1 -1
  194. package/dist/standalone/chunks/{bk-carousel-B7-9OanA.js → bk-carousel-BCwIQhG5.js} +1 -1
  195. package/dist/standalone/chunks/{bk-diagram-CpOpicmo.js → bk-diagram-DWK8CvRZ.js} +2 -2
  196. package/dist/standalone/chunks/{bk-dialog-a2BtUBf2.js → bk-dialog-DX0cPJ1o.js} +7 -3
  197. package/dist/standalone/chunks/{bk-image-editor-z_Uj83fy.js → bk-image-editor-DXEj9gCu.js} +1 -1
  198. package/dist/standalone/chunks/{bk-input-date-range-BQkbPlSJ.js → bk-input-date-range-Cbx_lpf0.js} +1 -1
  199. package/dist/standalone/chunks/{bk-input-rich-Dte_b4Ev.js → bk-input-rich-ZB68vziu.js} +3 -3
  200. package/dist/standalone/chunks/{bk-input-text-CUNQG1ah.js → bk-input-text-DD32uWNO.js} +1 -1
  201. package/dist/standalone/chunks/{bk-kbd-B7bz8hmV.js → bk-kbd-B_TlKzWj.js} +1 -1
  202. package/dist/standalone/chunks/{bk-model-viewer-D1XJPgAG.js → bk-model-viewer-Dr81ahVv.js} +19 -5
  203. package/dist/standalone/chunks/{bk-qr-code-CbI9rdOK.js → bk-qr-code-QaYvZwOR.js} +1 -1
  204. package/dist/standalone/chunks/{bk-toast-group-Cix-Urgi.js → bk-toast-group-BSeO_rPs.js} +1 -1
  205. package/dist/standalone/chunks/{choice-field-BnuK9mp_.js → choice-field-CGvE4tyb.js} +1 -1
  206. package/dist/standalone/chunks/{clipboard-DBGdJ-1S.js → clipboard-BKlrP5rj.js} +1 -28
  207. package/dist/standalone/chunks/clipboard-Crzt1Sh9.js +29 -0
  208. package/dist/standalone/chunks/{date-field-BQ5k-DDL.js → date-field-BlI6grfT.js} +2 -2
  209. package/dist/standalone/chunks/{form-control-D7dqSP9M.js → form-control-CyXQIJ2x.js} +1 -1
  210. package/dist/standalone/chunks/{frame-BW1nKuoM.js → frame-abXBnl8a.js} +3 -1
  211. package/dist/standalone/chunks/handle-menu-ZVR_msk2.js +49 -0
  212. package/dist/standalone/chunks/{i18n-CNsBRNPu.js → i18n-B6Al9xCK.js} +7 -0
  213. package/dist/standalone/chunks/{i18n-CrZgrRu9.js → i18n-BI16HQmm.js} +1 -1
  214. package/dist/standalone/chunks/{marks-CdqbbJpM.js → marks-0kbeB4n8.js} +2 -2
  215. package/dist/standalone/chunks/{popover-base-oDhxsYMr.js → popover-base-ac49G87f.js} +1 -1
  216. package/dist/standalone/chunks/{ramp-EclrETaQ.js → ramp-ggoyjMvC.js} +1 -1
  217. package/dist/standalone/chunks/{summary-BwL-Gp8w.js → summary-BK-B4m5A.js} +1 -1
  218. package/dist/standalone/chunks/{text-field-CTp2b-Ai.js → text-field-4IUUpRHE.js} +2 -2
  219. package/dist/standalone/chunks/{toggle-control-DXkgmz7R.js → toggle-control-ioV2jhNY.js} +1 -1
  220. package/dist/standalone/confirm.js +3 -3
  221. package/dist/standalone/i18n-de.js +8 -1
  222. package/dist/standalone/toast.js +1 -1
  223. package/dist/standalone/tokens.css +4 -1
  224. package/dist/tokens.css +4 -1
  225. package/package.json +1 -1
  226. package/dist/standalone/chunks/handle-menu-DsxWvv4D.js +0 -22
@@ -61,6 +61,8 @@ export interface MarkSpecs {
61
61
  labelSize: number;
62
62
  /** Clearance of labels from lines, bars and each other (--bk-space-1). */
63
63
  clear: number;
64
+ /** Thickness of the mark of a chosen category (--bk-chart-indicator-width, default --bk-indicator-width). */
65
+ indicator: number;
64
66
  font: string;
65
67
  }
66
68
  /**
@@ -3,7 +3,7 @@ import { styleMap } from "../internal/style-map.js";
3
3
  import { srOnly, interactive, headingType } from "../internal/styles.js";
4
4
  import { chartT } from "./i18n.js";
5
5
  import { CHART_SLOTS, slotColor } from "./chart-tokens.js";
6
- const DEFAULT_SPECS = { barMax: 24, radius: 4, gap: 2, lineWidth: 2, marker: 8, ring: 2, hitMin: 24, bubbleMax: 40, labelSize: 12, clear: 4, font: "system-ui, sans-serif" };
6
+ const DEFAULT_SPECS = { barMax: 24, radius: 4, gap: 2, lineWidth: 2, marker: 8, ring: 2, hitMin: 24, bubbleMax: 40, labelSize: 12, clear: 4, indicator: 2, font: "system-ui, sans-serif" };
7
7
  function seriesColor(s, i, count = 2) {
8
8
  if (s.color)
9
9
  return s.color;
@@ -186,6 +186,7 @@ class ChartController {
186
186
  bubbleMax: px("--bk-chart-bubble-max", 40),
187
187
  labelSize: px("--bk-chart-label-size", 12) || parseFloat(cs.fontSize) * 0.85,
188
188
  clear: px("--bk-space-1", 4),
189
+ indicator: Math.max(1, px("--bk-chart-indicator-width", px("--bk-indicator-width", 2))),
189
190
  font: cs.fontFamily || DEFAULT_SPECS.font
190
191
  };
191
192
  probe.remove();
@@ -46,10 +46,13 @@ export type ButtonSize = "sm" | "md" | "lg";
46
46
  * - `collapse` shows only the icon when the nearest size container is narrow. Set
47
47
  * `container-type: inline-size` on a toolbar or header, and the button collapses below 640px of its width
48
48
  * (`collapse="sm"`: 480px, `collapse="lg"`: 960px). The label stays the accessible name and
49
- * becomes the tooltip. The button needs an icon, and `collapse` has no effect without a container ancestor.
49
+ * becomes the tooltip. The button needs an icon, and `collapse` has no effect without a container ancestor. The
50
+ * start icon stays. A button with only an end icon (`icon-end`) keeps the end icon.
50
51
  *
51
52
  * The element passes `aria-current` on the host (a page in a pager, the current step) to the inner control and
52
- * sets the `pressed` look on the button.
53
+ * sets the `pressed` look on the button. It also passes `aria-expanded` and `aria-controls` on the host (a
54
+ * disclosure button of the app) to the inner control. `pressed` sets `aria-pressed`. A popover, a menu or a tooltip
55
+ * that controls the button (setTriggerAria) replaces `aria-expanded` and `aria-controls` while it is attached.
53
56
  *
54
57
  * `disabled-reason` turns the button off and says why ("A group has at most 4 items"). Unlike
55
58
  * `disabled`, the button stays focusable (`aria-disabled`), so keyboard and screen reader users can
@@ -122,7 +125,7 @@ export type ButtonSize = "sm" | "md" | "lg";
122
125
  *
123
126
  * @keyboard Enter, Space - Activate the button (a link button: Enter follows the link).
124
127
  * @keyboard Tab - Move focus to the button, also when it is disabled with a `disabled-reason`.
125
- * @a11y A native `<button>` (or `<a>` with `href`) inside. An icon-only button uses `label` as its accessible name. A disabled button with `disabled-reason` stays focusable (`aria-disabled`) and has the reason as its description. `aria-*` on the host goes to the inner control.
128
+ * @a11y A native `<button>` (or `<a>` with `href`) inside. An icon-only button uses `label` as its accessible name. A disabled button with `disabled-reason` stays focusable (`aria-disabled`) and has the reason as its description. The inner control gets `aria-current`, `aria-expanded` and `aria-controls` of the host, and `aria-pressed` from `pressed`.
126
129
  * @fires {CustomEvent<NavigateDetail>} navigate - The user makes a plain click on the link (primary button, no modifier key, no other `target`, no `download`). `detail.href` is the resolved address. Bubbles, composed, cancelable: `preventDefault()` stops the browser, and the router of the app handles the navigation.
127
130
  * @tag bk-button
128
131
  */
@@ -202,6 +205,12 @@ export declare class BkButton extends LitElement implements AriaForwarding {
202
205
  current: {
203
206
  attribute: string;
204
207
  };
208
+ hostExpanded: {
209
+ attribute: string;
210
+ };
211
+ hostControls: {
212
+ attribute: string;
213
+ };
205
214
  count: {
206
215
  type: NumberConstructor;
207
216
  };
@@ -273,6 +282,10 @@ export declare class BkButton extends LitElement implements AriaForwarding {
273
282
  * pager or the current step; a toggle uses `pressed`.
274
283
  */
275
284
  current: string | undefined;
285
+ /** `aria-expanded` on the host (a disclosure button of the app). A popup that controls the button (setTriggerAria) wins. */
286
+ hostExpanded: string | undefined;
287
+ /** `aria-controls` on the host: the ids of elements in the same document or shadow root as the button. */
288
+ hostControls: string | undefined;
276
289
  /** Count badge on an icon-only button (unread items); `99+` above 99, none for 0 or unset. */
277
290
  count: number | undefined;
278
291
  /** A dot on an icon-only button: something new, without a number. */
@@ -295,6 +308,8 @@ export declare class BkButton extends LitElement implements AriaForwarding {
295
308
  get inactive(): boolean;
296
309
  /** Trigger ARIA set by popovers, menus and tooltips; rendered onto the inner control. */
297
310
  private forwarded;
311
+ /** The elements of the ids in `aria-controls` on the host, in the root of the button (the inner control cannot refer to them by id). */
312
+ private hostControlled;
298
313
  /** Used by `<bk-popover>`, `<bk-menu>` and `<bk-tooltip>` (see setTriggerAria). */
299
314
  forwardAria(aria: TriggerAria): void;
300
315
  static styles: import("lit").CSSResult[];
@@ -46,6 +46,8 @@ class BkButton extends LitElement {
46
46
  floating: { type: Boolean, reflect: true },
47
47
  collapse: { reflect: true },
48
48
  current: { attribute: "aria-current" },
49
+ hostExpanded: { attribute: "aria-expanded" },
50
+ hostControls: { attribute: "aria-controls" },
49
51
  count: { type: Number },
50
52
  dot: { type: Boolean, reflect: true }
51
53
  };
@@ -130,6 +132,14 @@ class BkButton extends LitElement {
130
132
  }
131
133
  /** Trigger ARIA set by popovers, menus and tooltips; rendered onto the inner control. */
132
134
  forwarded = { haspopup: null, expanded: null, controls: null, description: null, hideTitle: false };
135
+ /** The elements of the ids in `aria-controls` on the host, in the root of the button (the inner control cannot refer to them by id). */
136
+ hostControlled() {
137
+ if (!this.hostControls || !this.isConnected)
138
+ return null;
139
+ const root = this.getRootNode();
140
+ const found = this.hostControls.split(/\s+/).map((id) => root.getElementById?.(id)).filter((el) => !!el);
141
+ return found.length ? found : null;
142
+ }
133
143
  /** Used by `<bk-popover>`, `<bk-menu>` and `<bk-tooltip>` (see setTriggerAria). */
134
144
  forwardAria(aria) {
135
145
  const f = this.forwarded;
@@ -332,18 +342,19 @@ class BkButton extends LitElement {
332
342
  @media (forced-colors: active) { .count, .dot { border: var(--bk-border-width) solid CanvasText; } .dot { background: Highlight; } }
333
343
  :host(:state(round)) .control { border-radius: var(--bk-radius-full); }
334
344
 
335
- /* collapse: icon only when the nearest size container is narrow (thresholds can't be tokens) */
345
+ /* collapse: icon only when the nearest size container is narrow (thresholds can't be tokens). The start icon stays;
346
+ a button with only an end icon keeps the end icon. */
336
347
  @container (max-width: 480px) {
337
348
  :host([collapse="sm"]) .control { padding: 0; width: var(--_bk-button-h); }
338
- :host([collapse="sm"]) :is(.label, slot[name="end"]) { display: none; }
349
+ :host([collapse="sm"]) :is(.label, .has-start slot[name="end"]) { display: none; }
339
350
  }
340
351
  @container (max-width: 640px) {
341
352
  :host([collapse=""]) .control, :host([collapse="md"]) .control { padding: 0; width: var(--_bk-button-h); }
342
- :host([collapse=""]) :is(.label, slot[name="end"]), :host([collapse="md"]) :is(.label, slot[name="end"]) { display: none; }
353
+ :host([collapse=""]) :is(.label, .has-start slot[name="end"]), :host([collapse="md"]) :is(.label, .has-start slot[name="end"]) { display: none; }
343
354
  }
344
355
  @container (max-width: 960px) {
345
356
  :host([collapse="lg"]) .control { padding: 0; width: var(--_bk-button-h); }
346
- :host([collapse="lg"]) :is(.label, slot[name="end"]) { display: none; }
357
+ :host([collapse="lg"]) :is(.label, .has-start slot[name="end"]) { display: none; }
347
358
  }
348
359
  `];
349
360
  /** Whether `collapse` is set (a container query can hide the text). */
@@ -356,8 +367,8 @@ class BkButton extends LitElement {
356
367
  super.connectedCallback();
357
368
  const root = this.getRootNode();
358
369
  this.inOverlay = !!this.closest("dialog, bk-dialog, bk-drawer, [popover]") || root instanceof ShadowRoot && !!root.host.matches("bk-dialog, bk-drawer");
359
- if (this.collapsible && !this.icon && !this.querySelector(":scope > [slot=start]")) {
360
- console.warn("<bk-button collapse> needs an icon (icon attribute or start slot): it is all that stays visible.", this);
370
+ if (this.collapsible && !this.icon && !this.iconEnd && !this.querySelector(":scope > :is([slot=start], [slot=end])")) {
371
+ console.warn("<bk-button collapse> needs an icon (icon, icon-end, or the start or end slot): it is all that stays visible.", this);
361
372
  }
362
373
  }
363
374
  /**
@@ -429,10 +440,10 @@ class BkButton extends LitElement {
429
440
  const labelTip = !reason && !f.hideTitle && !this.hideTooltip && !this.inOverlay && this.iconOnly && name ? name : void 0;
430
441
  const title = f.hideTitle || this.hideTooltip || reason || labelTip ? void 0 : name;
431
442
  const popup = ifDefined(f.haspopup ?? void 0);
432
- const expanded = ifDefined(f.expanded === null ? void 0 : String(f.expanded));
443
+ const expanded = ifDefined(f.expanded === null ? this.hostExpanded ?? void 0 : String(f.expanded));
433
444
  const description = ifDefined(reason ? void 0 : [f.description, this.badgeDescription].filter(Boolean).join(". ") || void 0);
434
445
  const current = ifDefined(this.current ?? void 0);
435
- const controls = controlsList(f.controls);
446
+ const controls = controlsList(f.controls ?? this.hostControlled());
436
447
  if (this.href) {
437
448
  return this.withReason(reason, name, labelTip, html`<a part="control" class=${cls}
438
449
  href=${ifDefined(inactive ? void 0 : this.links.href(this.href))} @click=${this.links.click} target=${ifDefined(this.target)}
@@ -43,12 +43,20 @@ export interface ChartBarSelectDetail {
43
43
  * chart describes its data in one line for screen readers (`show-summary` shows it, `summary` replaces it).
44
44
  *
45
45
  * **Clickable categories.** With `href` (a template such as `?day={x}`), each category is a real `<a>` over its band
46
- * and its label. With `clickable`, each category is a button that fires a cancelable `select` with `{ category, index }`.
47
- * When no listener cancels the event, the category becomes `current`. `current` marks the chosen category. Its bars keep
48
- * their colour, and the bars of the other categories use `--bk-chart-bar-rest`.
46
+ * and its label. The link resolver of the app resolves each address. A template of one field (`href="{url}"`) takes
47
+ * the address of each row as it is. With `clickable`, each category is a button that fires a cancelable `select` with
48
+ * `{ category, index }`. When no listener cancels the event, the category becomes `current`. `current` marks the chosen
49
+ * category. Its bars keep their colour, its label is bold, and a mark (--bk-chart-bar-current-mark) stands under its
50
+ * label. The bars of the other categories use `--bk-chart-bar-rest`.
51
+ *
52
+ * **Missing values.** A value that is null or undefined draws no bar. A short outline at the baseline shows the place
53
+ * of the bar. A category without any value has no link or button, and its name says "no value".
54
+ *
55
+ * **Second label.** `detail` names a field of the row (a date, for example). The chart shows its value under the
56
+ * category label, and the data table shows it in a column.
49
57
  *
50
58
  * ```html
51
- * <bk-chart-bar aria-label="Views per day" x="day" href="?day={date}" current="2026-12-02" .data=${days}></bk-chart-bar>
59
+ * <bk-chart-bar aria-label="Views per day" x="day" detail="date" labels href="?day={date}" current="Wed" .data=${days}></bk-chart-bar>
52
60
  * ```
53
61
  *
54
62
  * This is content without a surface. Put it in a `<bk-surface>` or `<bk-card>`.
@@ -92,9 +100,13 @@ export interface ChartBarSelectDetail {
92
100
  * @cssprop --bk-chart-tooltip-max-width - Maximum tooltip width (default --bk-popup-width-md).
93
101
  * @cssprop --bk-chart-bar-rest - Colour of the bars of the categories that are not `current` (default --bk-chart-other).
94
102
  * @cssprop --bk-chart-bar-current-label - Colour of the label of the `current` category (default --bk-text).
103
+ * @cssprop --bk-chart-bar-current-mark - Colour of the mark under the label of the `current` category (default --bk-accent-solid).
104
+ * @cssprop --bk-chart-indicator-width - Thickness of the mark under the label of the `current` category (default --bk-indicator-width).
105
+ * @cssprop --bk-chart-bar-detail - Colour of the second label (`detail`) under a category (default --bk-chart-label).
106
+ * @cssprop --bk-chart-bar-stub - Colour of the outline that marks a bar without a value (default --bk-chart-axis).
95
107
  * @cssprop --bk-chart-category-hover - Background of the link or button of a category under the pointer (default --bk-hover).
96
108
  * @cssprop --bk-chart-category-radius - Radius of the link or button of a category (default --bk-radius-sm).
97
- * @keyboard ←, → - Move to the previous or next category (↑ and ↓ in a horizontal chart).
109
+ * @keyboard ←, → - Move to the previous or next category (↑ and ↓ in a horizontal chart). The chart draws from left to right in every writing direction, and the arrow keys follow the drawing. With `href` or `clickable`, the keys skip a category without a link or button.
98
110
  * @keyboard ↑, ↓ - Move between the series of a category (← and → in a horizontal chart).
99
111
  * @keyboard Home, End - Move to the first or last category.
100
112
  * @keyboard Shift + ←, Shift + → - With `selectable`: extend the range.
@@ -103,7 +115,7 @@ export interface ChartBarSelectDetail {
103
115
  * @keyboard Tab - With `href`: move to the link of the next category.
104
116
  * @keyboard Enter - With `href`: follow the link. With `clickable`: choose the category.
105
117
  * @keyboard Space - With `clickable`: choose the category.
106
- * @a11y A `figure` that its heading names. The bars are one tab stop of `img` marks. With `href`, the categories are links in the tab order. The category and its values name each link, and `aria-current="page"` marks `current`. With `clickable`, they are buttons in a `toolbar` (one tab stop, arrow keys) with `aria-current="true"`.
118
+ * @a11y A `figure` that its heading names. The bars are one tab stop of `img` marks. With `href`, the categories are links in the tab order. The category, its second label and its values name each link, and `aria-current="page"` marks `current`. With `clickable`, they are buttons in a `toolbar` (one tab stop, arrow keys) with `aria-current="true"`. A category without a value is an `img` that is not in the tab order; its name says "no value". The mark of `current` has a contrast of at least 3:1 and uses `Highlight` in forced colours.
107
119
  */
108
120
  export declare class BkChartBar extends LitElement {
109
121
  static properties: {
@@ -117,6 +129,10 @@ export declare class BkChartBar extends LitElement {
117
129
  xLabel: {
118
130
  attribute: string;
119
131
  };
132
+ detail: {};
133
+ detailLabel: {
134
+ attribute: string;
135
+ };
120
136
  orientation: {
121
137
  reflect: boolean;
122
138
  useDefault: boolean;
@@ -197,6 +213,10 @@ export declare class BkChartBar extends LitElement {
197
213
  x: string;
198
214
  /** Column header of the categories in the data table (default "Category"). */
199
215
  xLabel: string | undefined;
216
+ /** Field of a row that contains a second label. The chart shows it under the category label (a date, for example). */
217
+ detail: string | undefined;
218
+ /** Column header of the second label in the data table (default "Detail"). */
219
+ detailLabel: string | undefined;
200
220
  /** `vertical` columns (default) or `horizontal` bars (for long or many category names). */
201
221
  orientation: "vertical" | "horizontal";
202
222
  /** `grouped` side by side (default), `stacked`, or `percent` (stacked to 100 %). */
@@ -218,7 +238,9 @@ export declare class BkChartBar extends LitElement {
218
238
  selectable: boolean;
219
239
  /**
220
240
  * Makes each category a link. The template can contain `{x}` (the category) and `{<field>}` (a field of the row),
221
- * for example `?day={x}`. The values are URL-encoded. Not with `selectable`.
241
+ * for example `?day={x}`. The values are URL-encoded. A template of one field only (`{url}`) takes the value of the
242
+ * field as it is: each row brings its own address. A category without a value, or without a value for a field of the
243
+ * template, has no link. Not with `selectable`.
222
244
  */
223
245
  href: string | undefined;
224
246
  /** The `target` of the category links. */
@@ -271,8 +293,19 @@ export declare class BkChartBar extends LitElement {
271
293
  /** The value of a category in `current`, `select` and the `href` template (a date as its ISO string). */
272
294
  private rawKey;
273
295
  private isCurrent;
274
- /** The `href` of the link of a category: the template with the values of its row. */
296
+ /**
297
+ * The `href` of the link of a category: the template with the values of its row. A template of one field takes the
298
+ * value as it is. Null when a field of the template has no value in the row.
299
+ */
275
300
  private categoryHref;
301
+ /** True when no series of the row has a value: the category draws placeholders and has no link or button. */
302
+ private isEmpty;
303
+ /** The second label of a category (the `detail` field), or an empty string. */
304
+ private detailText;
305
+ /** The name of a category in tooltips and accessible names: the category and its second label. */
306
+ private categoryName;
307
+ /** True when the chart reserves room for the mark of a chosen category (links, buttons, or `current`). */
308
+ private get marksCurrent();
276
309
  /** Fires `select` for the category `i` of the view. When no listener cancels the event, the category becomes `current`. */
277
310
  private choose;
278
311
  /** The name of the link or button of a category: the category and its values. */
@@ -296,7 +329,11 @@ export declare class BkChartBar extends LitElement {
296
329
  private onMove;
297
330
  private onUp;
298
331
  private onKey;
299
- /** Keys on the links or buttons of the categories: arrow keys, Home and End move the focus; Escape hides the tooltip. */
332
+ /**
333
+ * Keys on the links or buttons of the categories: arrow keys, Home and End move the focus; Escape hides the tooltip.
334
+ * The keys skip a category without a link or button. The chart draws from left to right in every writing direction,
335
+ * and the arrow keys follow the drawing.
336
+ */
300
337
  private onCategoryKey;
301
338
  private toggleTable;
302
339
  private tableModel;
@@ -23,6 +23,8 @@ class BkChartBar extends LitElement {
23
23
  series: { attribute: false },
24
24
  x: {},
25
25
  xLabel: { attribute: "x-label" },
26
+ detail: {},
27
+ detailLabel: { attribute: "detail-label" },
26
28
  orientation: { reflect: true, useDefault: true },
27
29
  mode: { reflect: true, useDefault: true },
28
30
  labels: { type: Boolean, reflect: true },
@@ -110,15 +112,52 @@ class BkChartBar extends LitElement {
110
112
  const v = row?.[this.x];
111
113
  return this.rawKey(v) === c || v instanceof Date && this.rawKey(v).startsWith(c) || this.category(row) === c;
112
114
  }
113
- /** The `href` of the link of a category: the template with the values of its row. */
115
+ /**
116
+ * The `href` of the link of a category: the template with the values of its row. A template of one field takes the
117
+ * value as it is. Null when a field of the template has no value in the row.
118
+ */
114
119
  categoryHref(row) {
115
- return (this.href ?? "").replace(/\{([\w-]+)\}/g, (m, key) => {
116
- if (key in row)
117
- return encodeURIComponent(this.rawKey(row[key]));
118
- if (key === "x")
119
- return encodeURIComponent(this.rawKey(row[this.x]));
120
- return m;
120
+ const template = this.href ?? "";
121
+ const known = (key) => key in row || key === "x";
122
+ const field = (key) => key in row ? row[key] : row[this.x];
123
+ const blank = (v) => v === void 0 || v === null || v === "";
124
+ const whole = /^\{([\w-]+)\}$/.exec(template);
125
+ if (whole && known(whole[1])) {
126
+ const v = field(whole[1]);
127
+ return blank(v) ? null : this.rawKey(v);
128
+ }
129
+ let missing = false;
130
+ const href = template.replace(/\{([\w-]+)\}/g, (m, key) => {
131
+ if (!known(key))
132
+ return m;
133
+ const v = field(key);
134
+ if (blank(v))
135
+ missing = true;
136
+ return encodeURIComponent(this.rawKey(v));
121
137
  });
138
+ return missing ? null : href;
139
+ }
140
+ /** True when no series of the row has a value: the category draws placeholders and has no link or button. */
141
+ isEmpty(row) {
142
+ return this.effectiveSeries.every((se) => num(row?.[se.key]) === null);
143
+ }
144
+ /** The second label of a category (the `detail` field), or an empty string. */
145
+ detailText(row) {
146
+ if (!this.detail)
147
+ return "";
148
+ const v = row?.[this.detail];
149
+ if (v instanceof Date)
150
+ return formatTime(this.i18n.locale, v.getTime());
151
+ return v === void 0 || v === null ? "" : String(v);
152
+ }
153
+ /** The name of a category in tooltips and accessible names: the category and its second label. */
154
+ categoryName(row) {
155
+ const category = this.category(row), detail = this.detailText(row);
156
+ return detail ? chartT(this.i18n.locale, "chartCategoryDetail", { category, detail }) : category;
157
+ }
158
+ /** True when the chart reserves room for the mark of a chosen category (links, buttons, or `current`). */
159
+ get marksCurrent() {
160
+ return this.pickMode !== null || this.current !== void 0 && this.current !== null && this.current !== "";
122
161
  }
123
162
  /** Fires `select` for the category `i` of the view. When no listener cancels the event, the category becomes `current`. */
124
163
  choose(i) {
@@ -149,9 +188,14 @@ class BkChartBar extends LitElement {
149
188
  }
150
189
  .mark.rest { fill: var(--bk-chart-bar-rest, var(--bk-chart-other)); }
151
190
  text.current { fill: var(--bk-chart-bar-current-label, var(--bk-text)); font-weight: var(--bk-weight-medium); }
191
+ text.detail { fill: var(--bk-chart-bar-detail, var(--bk-chart-label)); }
192
+ .current-mark { fill: var(--bk-chart-bar-current-mark, var(--bk-accent-solid)); }
193
+ .stub { fill: none; stroke: var(--bk-chart-bar-stub, var(--bk-chart-axis)); stroke-width: 1; }
152
194
  @media (forced-colors: active) {
153
195
  .ghost { fill: none; stroke: CanvasText; } .selection { fill: Highlight; stroke: Highlight; }
154
196
  .mark.rest { fill: GrayText; }
197
+ .current-mark { fill: Highlight; }
198
+ .stub { stroke: GrayText; }
155
199
  .cat:hover { outline: var(--bk-border-width) solid Highlight; outline-offset: var(--bk-focus-offset-inset); }
156
200
  }
157
201
  `, markStyles];
@@ -227,7 +271,12 @@ class BkChartBar extends LitElement {
227
271
  }
228
272
  const fs = s.labelSize, font = s.font;
229
273
  const cats = rows.map((r) => this.category(r));
230
- const catW = Math.max(0, ...cats.map((c) => measureText(c, fs, font)));
274
+ const details = rows.map((r) => this.detailText(r));
275
+ const hasDetail = details.some(Boolean);
276
+ const catW = Math.max(0, ...cats.map((c) => measureText(c, fs, font)), ...details.map((d) => measureText(d, fs, font)));
277
+ const empty = rows.map((r) => this.isEmpty(r));
278
+ const lineStep = fs + s.clear;
279
+ const markSpace = this.marksCurrent ? s.clear + s.indicator : 0;
231
280
  const groupThick = (band) => {
232
281
  if (this.contiguous)
233
282
  return { t: Math.max(1, band - s.gap), groupW: Math.max(1, band - s.gap) };
@@ -242,7 +291,7 @@ class BkChartBar extends LitElement {
242
291
  if (!horizontal) {
243
292
  H = this.chart.height;
244
293
  y0 = Math.max(labelPad, fs / 2 + 2);
245
- y1 = H - (fs + 10 + s.clear);
294
+ y1 = H - (fs + 10 + s.clear + (hasDetail ? lineStep : 0) + markSpace);
246
295
  ticks = niceTicks(lo, hi, Math.max(2, Math.round((y1 - y0) / 48)));
247
296
  if (percent)
248
297
  ticks = niceTicks(0, 1, 4);
@@ -253,7 +302,8 @@ class BkChartBar extends LitElement {
253
302
  } else {
254
303
  const per = stacked ? 1 : Math.max(1, k);
255
304
  const groupW2 = this.contiguous ? s.barMax : per * (s.barMax * (1 + gh) + (gh ? s.gap : 0)) + (per - 1) * s.gap;
256
- const band = Math.max(groupW2 / 0.7, s.hitMin + 8);
305
+ const reach = (hasDetail ? lineStep / 2 + fs / 2 : fs / 2) + markSpace;
306
+ const band = Math.max(groupW2 / 0.7, s.hitMin + 8, Math.ceil(2 * reach + 2 * s.clear));
257
307
  x0 = Math.ceil(Math.min(catW, W * 0.35) + 8);
258
308
  y0 = 2;
259
309
  y1 = y0 + n * band;
@@ -325,14 +375,18 @@ class BkChartBar extends LitElement {
325
375
  const hw = stacked ? Math.max(t, Math.min(s.hitMin, bands.width)) : Math.max(t + s.gap, Math.min(s.hitMin, bands.width / Math.max(1, k)));
326
376
  const hx = off + t / 2 - hw / 2;
327
377
  const [hy, hh] = stacked ? [y - s.gap / 2, Math.max(h + s.gap, 4)] : [y0, y1 - y0];
328
- bar = { i, j, value: raw, share, path: v === null ? "" : barPath(off, y, t, h, s.radius, end), x: off, y, w: t, h, hx, hy, hw, hh, ax: off + t / 2, ay: negative ? y + h : y };
378
+ bar = { i, j, value: raw, share, path: v === null ? "" : barPath(off, y, t, h, s.radius, end), x: off, y, w: t, h, hx, hy, hw, hh, ax: off + t / 2, ay: negative ? y + h : y, stub: "" };
329
379
  } else {
330
380
  const x = Math.min(pa, pb), w = Math.abs(pb - pa);
331
381
  const end = !outer ? "none" : negative ? "left" : "right";
332
382
  const hh = stacked ? Math.max(t, Math.min(s.hitMin, bands.width)) : Math.max(t + s.gap, Math.min(s.hitMin, bands.width / Math.max(1, k)));
333
383
  const hy = off + t / 2 - hh / 2;
334
384
  const [hx, hw] = stacked ? [x - s.gap / 2, Math.max(w + s.gap, 4)] : [x0, x1 - x0];
335
- bar = { i, j, value: raw, share, path: v === null ? "" : barPath(x, off, w, t, s.radius, end), x, y: off, w, h: t, hx, hy, hw, hh, ax: negative ? x : x + w, ay: off + t / 2 };
385
+ bar = { i, j, value: raw, share, path: v === null ? "" : barPath(x, off, w, t, s.radius, end), x, y: off, w, h: t, hx, hy, hw, hh, ax: negative ? x : x + w, ay: off + t / 2, stub: "" };
386
+ }
387
+ if (raw === null && (!stacked || empty[i] && j === 0)) {
388
+ const len = Math.max(s.clear, Math.round(t / 2));
389
+ bar.stub = horizontal ? barPath(zero, off, len, t, s.radius, "right") : barPath(off, zero - len, t, len, s.radius, "top");
336
390
  }
337
391
  bars.push(bar);
338
392
  const g = ghostOf(i, j);
@@ -353,13 +407,13 @@ class BkChartBar extends LitElement {
353
407
  if (ys.some((y, idx) => idx && y - ys[idx - 1] < fs + 2))
354
408
  seriesLabels = [];
355
409
  }
356
- return { H, x0, x1, y0, y1, ticks, fmtTick, valueScale, bands, bars, ghosts, marks, cmp: !!cmpRows, t, zero, cats, values, totals, seriesLabels, horizontal, stacked, percent, series, n, k };
410
+ return { H, x0, x1, y0, y1, ticks, fmtTick, valueScale, bands, bars, ghosts, marks, cmp: !!cmpRows, t, zero, cats, details, hasDetail, empty, lineStep, values, totals, seriesLabels, horizontal, stacked, percent, series, n, k };
357
411
  }
358
412
  /* ---------------------------------------------------------------- interaction */
359
413
  markLabel(b) {
360
414
  const se = this.effectiveSeries[b.j];
361
- const cat = this.category(this.viewRows[b.i]);
362
- const value = this.mode === "percent" && b.value !== null ? `${formatPercent(this.i18n.locale, b.share, 1)} (${this.fmt(b.value)})` : this.fmt(b.value);
415
+ const cat = this.categoryName(this.viewRows[b.i]);
416
+ const value = b.value === null ? chartT(this.i18n.locale, "chartNoValue") : this.mode === "percent" ? `${formatPercent(this.i18n.locale, b.share, 1)} (${this.fmt(b.value)})` : this.fmt(b.value);
363
417
  return chartT(this.i18n.locale, "chartMark", { category: cat, series: se?.label ?? "", value });
364
418
  }
365
419
  tooltipFor(b) {
@@ -383,7 +437,7 @@ class BkChartBar extends LitElement {
383
437
  }
384
438
  if (this.mode !== "grouped" && series.length > 1)
385
439
  rows.push({ label: chartT(locale, "chartTotal"), value: this.fmt(total), color: "", marker: "rect", active: false });
386
- return { title: this.category(row), rows, x: b.ax, y: b.ay };
440
+ return { title: this.categoryName(row), rows, x: b.ax, y: b.ay };
387
441
  }
388
442
  enter(b) {
389
443
  this.hot = { i: b.i, j: b.j };
@@ -492,26 +546,31 @@ class BkChartBar extends LitElement {
492
546
  await this.updateComplete;
493
547
  this.renderRoot.querySelector(`.hit[data-i="${i}"][data-j="${j}"]`)?.focus();
494
548
  }
495
- /** Keys on the links or buttons of the categories: arrow keys, Home and End move the focus; Escape hides the tooltip. */
549
+ /**
550
+ * Keys on the links or buttons of the categories: arrow keys, Home and End move the focus; Escape hides the tooltip.
551
+ * The keys skip a category without a link or button. The chart draws from left to right in every writing direction,
552
+ * and the arrow keys follow the drawing.
553
+ */
496
554
  onCategoryKey = async (e) => {
497
- const n = this.viewRows.length;
498
- const from = e.target.closest(".cat");
499
- if (!n || !from)
555
+ const from = e.target.closest("a.cat, button.cat");
556
+ const items = [...this.renderRoot.querySelectorAll("a.cat, button.cat")];
557
+ const at = from ? items.indexOf(from) : -1;
558
+ if (at < 0)
500
559
  return;
501
560
  const h = this.orientation === "horizontal";
502
- let i = Number(from.dataset.i);
561
+ let to = at;
503
562
  switch (e.key) {
504
563
  case (h ? "ArrowDown" : "ArrowRight"):
505
- i = Math.min(n - 1, i + 1);
564
+ to = Math.min(items.length - 1, at + 1);
506
565
  break;
507
566
  case (h ? "ArrowUp" : "ArrowLeft"):
508
- i = Math.max(0, i - 1);
567
+ to = Math.max(0, at - 1);
509
568
  break;
510
569
  case "Home":
511
- i = 0;
570
+ to = 0;
512
571
  break;
513
572
  case "End":
514
- i = n - 1;
573
+ to = items.length - 1;
515
574
  break;
516
575
  case "Escape":
517
576
  this.chart.hideTooltip();
@@ -519,6 +578,7 @@ class BkChartBar extends LitElement {
519
578
  default:
520
579
  return;
521
580
  }
581
+ const i = Number(items[to].dataset.i);
522
582
  e.preventDefault();
523
583
  this.active = { i, j: this.active.j };
524
584
  this.requestUpdate();
@@ -537,6 +597,8 @@ class BkChartBar extends LitElement {
537
597
  const cmp = !!this.compare?.length && this.mode === "grouped" && !this.contiguous;
538
598
  const cmpLabel = this.compareLabel || chartT(locale, "chartPrevious");
539
599
  const columns = [this.xLabel || chartT(locale, "chartCategory")];
600
+ if (this.detail)
601
+ columns.push(this.detailLabel || chartT(locale, "chartDetail"));
540
602
  for (const se of series)
541
603
  columns.push(se.label, ...cmp ? [`${se.label} \xB7 ${cmpLabel}`, `${se.label} \xB7 ${chartT(locale, "chartChange")}`] : []);
542
604
  if (stacked)
@@ -544,6 +606,8 @@ class BkChartBar extends LitElement {
544
606
  const rows = (this.data ?? []).map((r, i) => {
545
607
  const vs = series.map((s) => num(r[s.key]));
546
608
  const cells = [this.category(r)];
609
+ if (this.detail)
610
+ cells.push(this.detailText(r));
547
611
  vs.forEach((v, j) => {
548
612
  cells.push(this.fmt(v));
549
613
  if (cmp) {
@@ -581,26 +645,47 @@ class BkChartBar extends LitElement {
581
645
  const cur = this.viewRows.map((r) => this.isCurrent(r));
582
646
  const anyCur = cur.some(Boolean);
583
647
  let catLabels;
648
+ const width = (text) => measureText(text, fs, font);
649
+ const currentMark = (cx, w, base2, anchor) => {
650
+ const mw = Math.max(Math.round(w), Math.round(L.t), s.hitMin);
651
+ const x = anchor === "middle" ? Math.round(cx - mw / 2) : Math.round(cx - mw);
652
+ const y = Math.round(base2 + fs * 0.25 + s.clear / 2);
653
+ return svg`<rect class="current-mark" x=${x} y=${y} width=${mw} height=${s.indicator} rx=${s.indicator / 2}></rect>`;
654
+ };
584
655
  if (!h) {
585
- const maxW = Math.max(...L.cats.map((c) => measureText(c, fs, font)));
586
- const place = (text, i) => {
587
- const half = measureText(text, fs, font) / 2;
588
- return Math.min(Math.max(L.bands.center(i), L.x0 + half), L.x1 - half);
589
- };
656
+ const base1 = L.y1 + fs + 4 + s.clear, base2 = base1 + L.lineStep;
657
+ const maxW = Math.max(...L.cats.map(width), ...L.details.map(width));
658
+ const place = (w, i) => Math.min(Math.max(L.bands.center(i), L.x0 + w / 2), L.x1 - w / 2);
590
659
  const pick = (every2) => L.cats.map((c, i) => {
591
660
  if (i % every2)
592
661
  return null;
593
662
  const text = fitText(c, L.bands.width * every2 - 4, fs, font);
594
- return { text, x: place(text, i), w: measureText(text, fs, font) };
663
+ const detail = L.details[i] ? fitText(L.details[i], L.bands.width * every2 - 4, fs, font) : "";
664
+ const w = Math.max(width(text), width(detail));
665
+ return { text, detail, x: place(w, i), w };
595
666
  });
596
667
  const clear = (shown2) => shown2.filter((p) => p !== null).every((p, j, all) => j === 0 || p.x - p.w / 2 >= all[j - 1].x + all[j - 1].w / 2 + 4);
597
668
  let every = Math.max(1, Math.ceil((maxW + 8) / Math.max(1, L.bands.width)));
598
669
  let shown = pick(every);
599
670
  while (every < L.cats.length && !clear(shown))
600
671
  shown = pick(++every);
601
- catLabels = shown.map((p, i) => p ? svg`<text class=${cur[i] ? "current" : ""} x=${p.x} y=${L.y1 + fs + 4 + s.clear} text-anchor="middle">${p.text}</text>` : svg``);
672
+ catLabels = shown.map((p, i) => {
673
+ const mark = cur[i] ? currentMark(p?.x ?? L.bands.center(i), Math.min(p?.w ?? 0, L.bands.width), L.hasDetail ? base2 : base1, "middle") : nothing;
674
+ if (!p)
675
+ return svg`${mark}`;
676
+ return svg`<text class=${cur[i] ? "current" : ""} x=${p.x} y=${base1} text-anchor="middle">${p.text}</text>
677
+ ${p.detail ? svg`<text class="detail" x=${p.x} y=${base2} text-anchor="middle">${p.detail}</text>` : nothing}${mark}`;
678
+ });
602
679
  } else {
603
- catLabels = L.cats.map((c, i) => svg`<text class=${cur[i] ? "current" : ""} x=${L.x0 - 8} y=${L.bands.center(i)} dy="0.32em" text-anchor="end">${fitText(c, L.x0 - 8, fs, font)}</text>`);
680
+ const room = L.x0 - 8;
681
+ catLabels = L.cats.map((c, i) => {
682
+ const centre = L.bands.center(i);
683
+ const text = fitText(c, room, fs, font), detail = L.details[i] ? fitText(L.details[i], room, fs, font) : "";
684
+ const y1 = L.hasDetail ? centre - L.lineStep / 2 : centre, y2 = centre + L.lineStep / 2;
685
+ const mark = cur[i] ? currentMark(room, Math.max(width(text), width(detail)), (L.hasDetail ? y2 : y1) + fs * 0.32, "end") : nothing;
686
+ return svg`<text class=${cur[i] ? "current" : ""} x=${room} y=${y1} dy="0.32em" text-anchor="end">${text}</text>
687
+ ${detail ? svg`<text class="detail" x=${room} y=${y2} dy="0.32em" text-anchor="end">${detail}</text>` : nothing}${mark}`;
688
+ });
604
689
  }
605
690
  const series = L.series;
606
691
  const hot = this.hot;
@@ -630,6 +715,7 @@ class BkChartBar extends LitElement {
630
715
  const selection = sel && this.selectable ? h ? svg`<rect class="selection" x=${L.x0} y=${L.bands.start(sel[0])} width=${L.x1 - L.x0} height=${(sel[1] - sel[0] + 1) * L.bands.width}></rect>` : svg`<rect class="selection" x=${L.bands.start(sel[0])} y=${L.y0} width=${(sel[1] - sel[0] + 1) * L.bands.width} height=${L.y1 - L.y0}></rect>` : nothing;
631
716
  const marks = L.bars.map((b) => b.path ? svg`<path class="mark ${hot && hot.i === b.i && hot.j === b.j ? "hot" : ""} ${anyCur && !cur[b.i] ? "rest" : ""}" data-slot=${seriesSlot(series[b.j], b.j)}
632
717
  style=${styleMap({ "--_bk-chart-c": seriesColor(series[b.j], b.j, series.length) })} d=${b.path}></path>` : svg``);
718
+ const stubs = L.bars.map((b) => b.stub ? svg`<path class="stub" d=${b.stub}></path>` : svg``);
633
719
  const valueLabels = [];
634
720
  if (this.labels && !L.percent) {
635
721
  const ends = L.stacked ? L.totals.map((tot, i) => {
@@ -670,16 +756,20 @@ class BkChartBar extends LitElement {
670
756
  this.enter(first(i));
671
757
  }
672
758
  };
673
- const cats = L.cats.map((_, i) => mode === "link" ? html`<a class="cat interactive" part="category" data-i=${i} href=${this.links.href(this.categoryHref(this.viewRows[i]))}
759
+ const hrefs = L.cats.map((_, i) => mode === "link" && !L.empty[i] ? this.categoryHref(this.viewRows[i]) : null);
760
+ const live = (i) => mode === "link" ? hrefs[i] !== null : !L.empty[i];
761
+ const tab = live(a.i) ? a.i : L.cats.findIndex((_, i) => live(i));
762
+ const cats = L.cats.map((_, i) => !live(i) ? html`<div class="cat" data-i=${i} role="img" aria-label=${this.categoryLabel(i)} aria-current=${cur[i] ? mode === "link" ? "page" : "true" : nothing}
763
+ style=${styleMap(box(i))} @pointerenter=${() => on.enter(i)}></div>` : mode === "link" ? html`<a class="cat interactive" part="category" data-i=${i} href=${this.links.href(hrefs[i])}
674
764
  target=${ifDefined(this.target)} rel=${ifDefined(this.rel)} aria-current=${cur[i] ? "page" : nothing} aria-label=${this.categoryLabel(i)}
675
- style=${styleMap(box(i))} @click=${this.links.click} @pointerenter=${() => on.enter(i)} @focus=${() => on.focus(i)} @blur=${this.onBlur}></a>` : html`<button type="button" class="cat interactive" part="category" data-i=${i} tabindex=${i === a.i ? 0 : -1}
765
+ style=${styleMap(box(i))} @click=${this.links.click} @pointerenter=${() => on.enter(i)} @focus=${() => on.focus(i)} @blur=${this.onBlur}></a>` : html`<button type="button" class="cat interactive" part="category" data-i=${i} tabindex=${i === tab ? 0 : -1}
676
766
  aria-current=${cur[i] ? "true" : nothing} aria-label=${this.categoryLabel(i)}
677
767
  style=${styleMap(box(i))} @click=${() => this.choose(i)} @pointerenter=${() => on.enter(i)} @focus=${() => on.focus(i)} @blur=${this.onBlur}></button>`);
678
768
  return html`<div class="plot" part="plot" style=${styleMap(h ? { height: `${L.H}px` } : {})}>
679
769
  <svg width=${W} height=${L.H} aria-hidden="true">
680
770
  ${textureDefs()}
681
771
  <g>${grid}${catLabels}</g>
682
- <g>${markGeo.back}${ghosts}${marks}${markGeo.front}</g>
772
+ <g>${markGeo.back}${ghosts}${marks}${stubs}${markGeo.front}</g>
683
773
  <g>${valueLabels}${seriesLabels}</g>
684
774
  </svg>
685
775
  <div class="cats" role=${mode === "button" ? "toolbar" : "group"} aria-orientation=${ifDefined(mode === "button" ? h ? "vertical" : "horizontal" : void 0)}
@@ -699,7 +789,7 @@ class BkChartBar extends LitElement {
699
789
  @keydown=${this.onKey} @pointerleave=${this.onLeave} @pointerdown=${this.onDown} @pointermove=${this.onMove} @pointerup=${this.onUp}>
700
790
  ${textureDefs()}
701
791
  <g aria-hidden="true">${grid}${catLabels}</g>
702
- <g aria-hidden="true">${markGeo.back}${selection}${ghosts}${marks}${markGeo.front}</g>
792
+ <g aria-hidden="true">${markGeo.back}${selection}${ghosts}${marks}${stubs}${markGeo.front}</g>
703
793
  <g aria-hidden="true">${valueLabels}${seriesLabels}</g>
704
794
  <g>${hits}</g>
705
795
  ${ring}