@melodicdev/components 4.0.1 → 4.1.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 (210) hide show
  1. package/README.md +4 -4
  2. package/assets/fonts/phosphor/phosphor.css +5 -25
  3. package/assets/melodic-components.css +50 -25
  4. package/assets/melodic-components.js +5370 -4233
  5. package/assets/melodic-components.js.map +1 -1
  6. package/assets/melodic-components.min.css +1 -21
  7. package/assets/melodic-components.min.js +1808 -26662
  8. package/lib/components/data-display/calendar-view/calendar-view.styles.d.ts.map +1 -1
  9. package/lib/components/data-display/calendar-view/calendar-view.styles.js +14 -0
  10. package/lib/components/data-display/data-grid/data-grid.component.d.ts +43 -2
  11. package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
  12. package/lib/components/data-display/data-grid/data-grid.component.js +94 -8
  13. package/lib/components/data-display/data-grid/data-grid.styles.d.ts.map +1 -1
  14. package/lib/components/data-display/data-grid/data-grid.styles.js +17 -0
  15. package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
  16. package/lib/components/data-display/data-grid/data-grid.template.js +19 -10
  17. package/lib/components/data-display/data-grid/index.d.ts +1 -0
  18. package/lib/components/data-display/data-grid/index.d.ts.map +1 -1
  19. package/lib/components/data-display/list/list-item.styles.js +1 -1
  20. package/lib/components/data-display/table/index.d.ts +1 -0
  21. package/lib/components/data-display/table/index.d.ts.map +1 -1
  22. package/lib/components/data-display/table/table.component.d.ts +16 -0
  23. package/lib/components/data-display/table/table.component.d.ts.map +1 -1
  24. package/lib/components/data-display/table/table.component.js +28 -3
  25. package/lib/components/data-display/table/table.styles.d.ts.map +1 -1
  26. package/lib/components/data-display/table/table.styles.js +7 -1
  27. package/lib/components/data-display/table/table.template.d.ts.map +1 -1
  28. package/lib/components/data-display/table/table.template.js +8 -6
  29. package/lib/components/data-display/table-core/index.d.ts +2 -2
  30. package/lib/components/data-display/table-core/index.d.ts.map +1 -1
  31. package/lib/components/data-display/table-core/index.js +1 -1
  32. package/lib/components/data-display/table-core/table-core.d.ts +16 -2
  33. package/lib/components/data-display/table-core/table-core.d.ts.map +1 -1
  34. package/lib/components/data-display/table-core/table-core.js +32 -5
  35. package/lib/components/data-display/tag/tag.styles.d.ts.map +1 -1
  36. package/lib/components/data-display/tag/tag.styles.js +11 -4
  37. package/lib/components/feedback/alert/alert.styles.d.ts.map +1 -1
  38. package/lib/components/feedback/alert/alert.styles.js +11 -0
  39. package/lib/components/feedback/toast/index.d.ts +1 -0
  40. package/lib/components/feedback/toast/index.d.ts.map +1 -1
  41. package/lib/components/feedback/toast/toast-container.styles.d.ts.map +1 -1
  42. package/lib/components/feedback/toast/toast-container.styles.js +20 -0
  43. package/lib/components/feedback/toast/toast.component.d.ts +16 -0
  44. package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
  45. package/lib/components/feedback/toast/toast.component.js +63 -5
  46. package/lib/components/feedback/toast/toast.service.d.ts +14 -0
  47. package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
  48. package/lib/components/feedback/toast/toast.service.js +41 -0
  49. package/lib/components/feedback/toast/toast.styles.d.ts.map +1 -1
  50. package/lib/components/feedback/toast/toast.styles.js +6 -0
  51. package/lib/components/feedback/toast/toast.template.js +1 -1
  52. package/lib/components/forms/autocomplete/autocomplete.component.d.ts +14 -4
  53. package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
  54. package/lib/components/forms/autocomplete/autocomplete.component.js +40 -96
  55. package/lib/components/forms/autocomplete/autocomplete.styles.d.ts.map +1 -1
  56. package/lib/components/forms/autocomplete/autocomplete.styles.js +22 -6
  57. package/lib/components/forms/autocomplete/autocomplete.template.js +7 -1
  58. package/lib/components/forms/button/button.styles.d.ts.map +1 -1
  59. package/lib/components/forms/button/button.styles.js +11 -0
  60. package/lib/components/forms/button-group/button-group-item.styles.d.ts.map +1 -1
  61. package/lib/components/forms/button-group/button-group-item.styles.js +11 -0
  62. package/lib/components/forms/button-group/button-group.styles.js +2 -2
  63. package/lib/components/forms/checkbox/checkbox.styles.d.ts.map +1 -1
  64. package/lib/components/forms/checkbox/checkbox.styles.js +13 -2
  65. package/lib/components/forms/date-picker/calendar.component.d.ts +20 -7
  66. package/lib/components/forms/date-picker/calendar.component.d.ts.map +1 -1
  67. package/lib/components/forms/date-picker/calendar.component.js +88 -13
  68. package/lib/components/forms/date-picker/calendar.styles.d.ts.map +1 -1
  69. package/lib/components/forms/date-picker/calendar.styles.js +19 -0
  70. package/lib/components/forms/date-picker/date-picker.component.d.ts +2 -3
  71. package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
  72. package/lib/components/forms/date-picker/date-picker.component.js +70 -18
  73. package/lib/components/forms/date-picker/date-picker.styles.d.ts.map +1 -1
  74. package/lib/components/forms/date-picker/date-picker.styles.js +12 -1
  75. package/lib/components/forms/date-time-picker/date-time-picker.styles.d.ts.map +1 -1
  76. package/lib/components/forms/date-time-picker/date-time-picker.styles.js +12 -1
  77. package/lib/components/forms/date-time-picker/tz-utils.d.ts.map +1 -1
  78. package/lib/components/forms/date-time-picker/tz-utils.js +24 -3
  79. package/lib/components/forms/file-upload/file-upload-item.styles.d.ts.map +1 -1
  80. package/lib/components/forms/file-upload/file-upload-item.styles.js +13 -1
  81. package/lib/components/forms/file-upload/file-upload.styles.d.ts.map +1 -1
  82. package/lib/components/forms/file-upload/file-upload.styles.js +11 -0
  83. package/lib/components/forms/form-field/form-field.component.d.ts +18 -1
  84. package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
  85. package/lib/components/forms/form-field/form-field.component.js +55 -16
  86. package/lib/components/forms/form-field/form-field.styles.d.ts.map +1 -1
  87. package/lib/components/forms/form-field/form-field.styles.js +15 -2
  88. package/lib/components/forms/input/input.styles.d.ts.map +1 -1
  89. package/lib/components/forms/input/input.styles.js +12 -1
  90. package/lib/components/forms/listbox-core/index.d.ts +3 -0
  91. package/lib/components/forms/listbox-core/index.d.ts.map +1 -0
  92. package/lib/components/forms/listbox-core/index.js +2 -0
  93. package/lib/components/forms/listbox-core/listbox-core.d.ts +57 -0
  94. package/lib/components/forms/listbox-core/listbox-core.d.ts.map +1 -0
  95. package/lib/components/forms/listbox-core/listbox-core.js +168 -0
  96. package/lib/components/forms/radio/radio-group.styles.js +1 -1
  97. package/lib/components/forms/radio/radio.styles.d.ts.map +1 -1
  98. package/lib/components/forms/radio/radio.styles.js +12 -1
  99. package/lib/components/forms/radio-card-group/radio-card-group.styles.js +1 -1
  100. package/lib/components/forms/radio-card-group/radio-card.styles.d.ts.map +1 -1
  101. package/lib/components/forms/radio-card-group/radio-card.styles.js +11 -0
  102. package/lib/components/forms/select/select.component.d.ts +12 -4
  103. package/lib/components/forms/select/select.component.d.ts.map +1 -1
  104. package/lib/components/forms/select/select.component.js +41 -110
  105. package/lib/components/forms/select/select.styles.d.ts.map +1 -1
  106. package/lib/components/forms/select/select.styles.js +23 -6
  107. package/lib/components/forms/select/select.template.d.ts.map +1 -1
  108. package/lib/components/forms/select/select.template.js +25 -9
  109. package/lib/components/forms/slider/slider.component.js +1 -1
  110. package/lib/components/forms/slider/slider.styles.d.ts.map +1 -1
  111. package/lib/components/forms/slider/slider.styles.js +11 -0
  112. package/lib/components/forms/slider/slider.template.d.ts.map +1 -1
  113. package/lib/components/forms/slider/slider.template.js +5 -1
  114. package/lib/components/forms/textarea/textarea.styles.d.ts.map +1 -1
  115. package/lib/components/forms/textarea/textarea.styles.js +13 -2
  116. package/lib/components/forms/time-picker/time-picker.component.d.ts +1 -2
  117. package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
  118. package/lib/components/forms/time-picker/time-picker.component.js +8 -17
  119. package/lib/components/forms/time-picker/time-picker.styles.d.ts.map +1 -1
  120. package/lib/components/forms/time-picker/time-picker.styles.js +23 -3
  121. package/lib/components/forms/toggle/toggle.styles.d.ts.map +1 -1
  122. package/lib/components/forms/toggle/toggle.styles.js +13 -2
  123. package/lib/components/foundation/card/card.styles.d.ts.map +1 -1
  124. package/lib/components/foundation/card/card.styles.js +11 -0
  125. package/lib/components/foundation/container/container.styles.js +4 -4
  126. package/lib/components/navigation/breadcrumb/breadcrumb-item.template.d.ts.map +1 -1
  127. package/lib/components/navigation/breadcrumb/breadcrumb-item.template.js +5 -3
  128. package/lib/components/navigation/sidebar/sidebar-item.styles.js +4 -4
  129. package/lib/components/navigation/sidebar/sidebar-item.template.js +2 -2
  130. package/lib/components/navigation/sidebar/sidebar.styles.js +5 -5
  131. package/lib/components/navigation/sidebar/sidebar.template.js +2 -2
  132. package/lib/components/navigation/steps/step.styles.js +3 -3
  133. package/lib/components/navigation/steps/steps.styles.js +3 -3
  134. package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
  135. package/lib/components/navigation/tabs/tabs.component.js +4 -1
  136. package/lib/components/navigation/tabs/tabs.styles.js +8 -8
  137. package/lib/components/overlays/dialog/dialog.component.d.ts +15 -2
  138. package/lib/components/overlays/dialog/dialog.component.d.ts.map +1 -1
  139. package/lib/components/overlays/dialog/dialog.component.js +33 -1
  140. package/lib/components/overlays/dialog/dialog.service.d.ts +8 -2
  141. package/lib/components/overlays/dialog/dialog.service.d.ts.map +1 -1
  142. package/lib/components/overlays/dialog/dialog.service.js +1 -0
  143. package/lib/components/overlays/dialog/index.d.ts +1 -0
  144. package/lib/components/overlays/dialog/index.d.ts.map +1 -1
  145. package/lib/components/overlays/drawer/drawer.component.d.ts +18 -3
  146. package/lib/components/overlays/drawer/drawer.component.d.ts.map +1 -1
  147. package/lib/components/overlays/drawer/drawer.component.js +59 -16
  148. package/lib/components/overlays/dropdown/dropdown-item.styles.d.ts.map +1 -1
  149. package/lib/components/overlays/dropdown/dropdown-item.styles.js +12 -0
  150. package/lib/components/overlays/popover/popover.component.d.ts +12 -0
  151. package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
  152. package/lib/components/overlays/popover/popover.component.js +28 -1
  153. package/lib/components/overlays/popover/popover.template.d.ts.map +1 -1
  154. package/lib/components/overlays/popover/popover.template.js +2 -0
  155. package/lib/components/overlays/tooltip/tooltip.component.d.ts +8 -5
  156. package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
  157. package/lib/components/overlays/tooltip/tooltip.component.js +10 -3
  158. package/lib/components/sections/app-shell/app-shell.styles.js +1 -1
  159. package/lib/directives/tooltip.directive.d.ts.map +1 -1
  160. package/lib/directives/tooltip.directive.js +22 -3
  161. package/lib/theme/presets/base.preset.d.ts.map +1 -1
  162. package/lib/theme/presets/base.preset.js +17 -0
  163. package/lib/theme/presets/dark.preset.d.ts +8 -0
  164. package/lib/theme/presets/dark.preset.d.ts.map +1 -1
  165. package/lib/theme/presets/dark.preset.js +9 -0
  166. package/lib/theme/presets/light.preset.d.ts +6 -0
  167. package/lib/theme/presets/light.preset.d.ts.map +1 -1
  168. package/lib/theme/presets/light.preset.js +7 -0
  169. package/lib/theme/tokens/all-tokens.d.ts +10 -0
  170. package/lib/theme/tokens/all-tokens.d.ts.map +1 -1
  171. package/lib/theme/tokens/colors.tokens.d.ts +8 -0
  172. package/lib/theme/tokens/colors.tokens.d.ts.map +1 -1
  173. package/lib/theme/tokens/colors.tokens.js +11 -0
  174. package/lib/theme/tokens/transitions.tokens.d.ts +1 -0
  175. package/lib/theme/tokens/transitions.tokens.d.ts.map +1 -1
  176. package/lib/theme/tokens/transitions.tokens.js +3 -0
  177. package/lib/theme/tokens/typography.tokens.d.ts +1 -0
  178. package/lib/theme/tokens/typography.tokens.d.ts.map +1 -1
  179. package/lib/theme/tokens/typography.tokens.js +1 -0
  180. package/lib/utils/accessibility/cross-root-aria.d.ts +16 -8
  181. package/lib/utils/accessibility/cross-root-aria.d.ts.map +1 -1
  182. package/lib/utils/accessibility/cross-root-aria.js +58 -22
  183. package/lib/utils/accessibility/focus-trap.d.ts.map +1 -1
  184. package/lib/utils/accessibility/focus-trap.js +9 -19
  185. package/lib/utils/accessibility/focus-utils.d.ts +10 -1
  186. package/lib/utils/accessibility/focus-utils.d.ts.map +1 -1
  187. package/lib/utils/accessibility/focus-utils.js +48 -14
  188. package/lib/utils/accessibility/index.d.ts +2 -1
  189. package/lib/utils/accessibility/index.d.ts.map +1 -1
  190. package/lib/utils/accessibility/index.js +1 -1
  191. package/lib/utils/positioning/compute-position.d.ts +6 -1
  192. package/lib/utils/positioning/compute-position.d.ts.map +1 -1
  193. package/lib/utils/positioning/compute-position.js +3 -2
  194. package/lib/utils/positioning/middlewares/flip.middleware.js +2 -51
  195. package/package.json +8 -5
  196. package/assets/fonts/phosphor/Phosphor-Bold.svg +0 -3057
  197. package/assets/fonts/phosphor/Phosphor-Bold.ttf +0 -0
  198. package/assets/fonts/phosphor/Phosphor-Bold.woff +0 -0
  199. package/assets/fonts/phosphor/Phosphor-Fill.svg +0 -3057
  200. package/assets/fonts/phosphor/Phosphor-Fill.ttf +0 -0
  201. package/assets/fonts/phosphor/Phosphor-Fill.woff +0 -0
  202. package/assets/fonts/phosphor/Phosphor-Light.svg +0 -3057
  203. package/assets/fonts/phosphor/Phosphor-Light.ttf +0 -0
  204. package/assets/fonts/phosphor/Phosphor-Light.woff +0 -0
  205. package/assets/fonts/phosphor/Phosphor-Thin.svg +0 -3057
  206. package/assets/fonts/phosphor/Phosphor-Thin.ttf +0 -0
  207. package/assets/fonts/phosphor/Phosphor-Thin.woff +0 -0
  208. package/assets/fonts/phosphor/Phosphor.svg +0 -3056
  209. package/assets/fonts/phosphor/Phosphor.ttf +0 -0
  210. package/assets/fonts/phosphor/Phosphor.woff +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"calendar-view.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/calendar-view/calendar-view.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,iDAq0B9B,CAAC"}
1
+ {"version":3,"file":"calendar-view.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/calendar-view/calendar-view.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,iDAm1B9B,CAAC"}
@@ -836,4 +836,18 @@ export const calendarViewStyles = () => css `
836
836
  text-align: center;
837
837
  padding: var(--ml-space-6) 0;
838
838
  }
839
+
840
+ /*
841
+ * Forced colors (Windows High Contrast): box-shadow rings and background
842
+ * highlights are not painted there, so focus falls back to a real outline.
843
+ */
844
+ @media (forced-colors: active) {
845
+ .ml-cv__nav-btn:focus-visible,
846
+ .ml-cv__today-btn:focus-visible,
847
+ .ml-cv__view-trigger:focus-visible,
848
+ .ml-cv__add-btn:focus-visible {
849
+ outline: 2px solid Highlight;
850
+ outline-offset: 2px;
851
+ }
852
+ }
839
853
  `;
@@ -1,5 +1,15 @@
1
1
  import type { IElementRef, OnCreate, OnDestroy, OnRender, OnPropertyChange } from '@melodicdev/core';
2
2
  import type { DataGridColumn, SortDirection } from './data-grid.types.js';
3
+ import type { TableRowKey } from '../table-core/index.js';
4
+ /**
5
+ * Name of the custom property that carries a column's live width.
6
+ *
7
+ * The column key used to be interpolated as-is, so a key that is not a valid
8
+ * CSS identifier (`user.name`, `first name`, `a/b`) produced an invalid
9
+ * `var()` — which invalidates the whole `grid-template-columns` declaration
10
+ * and collapsed the grid. Keys that are already valid keep the same name.
11
+ */
12
+ export declare function columnWidthVar(key: string): string;
3
13
  /**
4
14
  * ml-data-grid — Full-featured data grid with virtual scrolling, sorting, filtering,
5
15
  * selection, column resizing, column reordering, pinned columns, and pagination.
@@ -52,10 +62,24 @@ export declare class DataGridComponent implements IElementRef, OnCreate, OnDestr
52
62
  virtual: boolean;
53
63
  /** Show per-column filter inputs below the header row */
54
64
  showFilterRow: boolean;
65
+ /**
66
+ * Make rows keyboard-operable: each row becomes a tab stop and Enter/Space
67
+ * fire `ml:row-click` (which a click always fires). Set this when you
68
+ * listen for `ml:row-click`. Mirrors ml-table's `clickable-rows`.
69
+ */
70
+ clickableRows: boolean;
55
71
  /** Column definitions */
56
72
  columns: DataGridColumn[];
57
73
  /** Row data */
58
74
  rows: Record<string, unknown>[];
75
+ /**
76
+ * Row identity: a property name (attribute `row-key="id"`) or a function
77
+ * `(row, index) => key`. Optional. When set, each rendered row's DOM
78
+ * follows its record across sorting, filtering and paging instead of being
79
+ * reused by position, so state held inside custom cells stays with the
80
+ * right row.
81
+ */
82
+ rowKey: TableRowKey | null;
59
83
  sortKey: string;
60
84
  sortDirection: SortDirection;
61
85
  filters: Record<string, string>;
@@ -112,20 +136,37 @@ export declare class DataGridComponent implements IElementRef, OnCreate, OnDestr
112
136
  get allSelected(): boolean;
113
137
  get someSelected(): boolean;
114
138
  isRowSelected: (index: number) => boolean;
139
+ /** 1-based position of a page row within the whole (filtered) dataset; the header is row 1. */
140
+ rowAriaIndex: (pageIndex: number) => number;
141
+ /** `repeat` key for a rendered row (see `rowKey`). */
142
+ getRowKey: (row: Record<string, unknown>, index: number) => unknown;
115
143
  handleSort: (col: DataGridColumn) => void;
116
144
  handleFilterInput: (key: string, e: Event) => void;
117
145
  handleSelectAll: () => void;
118
146
  handleSelectRow: (index: number, e: Event) => void;
119
147
  handleRowClick: (row: Record<string, unknown>, index: number) => void;
148
+ /** Enter/Space on a focused row fires `ml:row-click` (see `clickableRows`). */
149
+ handleRowKeyDown: (row: Record<string, unknown>, index: number, event: KeyboardEvent) => void;
120
150
  handleResizeStart: (key: string, e: PointerEvent) => void;
121
151
  handleResizeMove: (key: string, e: PointerEvent) => void;
122
152
  private _pendingResizeWidth;
123
153
  handleResizeEnd: () => void;
154
+ /**
155
+ * Abandon an in-flight column resize without committing it.
156
+ *
157
+ * A `pointercancel` (touch scroll takeover, the OS stealing the pointer)
158
+ * or losing pointer capture never produces a `pointerup`, which left the
159
+ * grid stuck in its "resizing" state with a stray live width applied.
160
+ */
161
+ handleResizeCancel: () => void;
162
+ /** Resize a column by `delta` px (keyboard path) and announce the new width. */
163
+ resizeColumnBy: (key: string, delta: number) => void;
124
164
  /**
125
165
  * Keyboard equivalents for the header's mouse-only interactions.
126
166
  *
127
- * Enter/Space sorts; Ctrl/Cmd + Arrow moves the column. Drag-and-drop
128
- * reordering and click-to-sort were otherwise unreachable without a mouse.
167
+ * Enter/Space sorts; Ctrl/Cmd + Arrow moves the column; Shift + Arrow
168
+ * resizes it. Drag-and-drop reordering, drag-to-resize and click-to-sort
169
+ * were otherwise unreachable without a mouse.
129
170
  */
130
171
  handleHeaderKeyDown: (col: DataGridColumn, event: KeyboardEvent) => void;
131
172
  /** Move a column `delta` positions and announce the new order. */
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid.component.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/data-grid.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAM1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAiBa,iBAAkB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB;IAC9F,UAAU,EAAG,WAAW,CAAC;IAIhC,0CAA0C;IACnC,UAAU,UAAS;IAE1B,kCAAkC;IAC3B,OAAO,UAAS;IAEvB,8BAA8B;IACvB,SAAS,UAAQ;IAExB,wBAAwB;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEhC,2CAA2C;IACpC,SAAS,SAAM;IAEtB,iDAAiD;IAC1C,WAAW,SAAM;IAExB,kFAAkF;IAC3E,UAAU,UAAS;IAE1B,8BAA8B;IACvB,QAAQ,SAAM;IAErB,2DAA2D;IACpD,OAAO,UAAQ;IAEtB,yDAAyD;IAClD,aAAa,UAAS;IAI7B,yBAAyB;IAClB,OAAO,EAAE,cAAc,EAAE,CAAM;IAEtC,eAAe;IACR,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAM;IAIrC,OAAO,SAAM;IACb,aAAa,EAAE,aAAa,CAAS;IAIr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AC,mBAAmB,CAAuB;IAE3C,eAAe,QAAO,IAAI,CAiB/B;IAEF;;;;;OAKG;IACI,mBAAmB,GAAI,KAAK,cAAc,EAAE,OAAO,aAAa,KAAG,IAAI,CAc5E;IAEF,kEAAkE;IAC3D,UAAU,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,IAAI,CAqBpD;IAEK,eAAe,GAAI,KAAK,MAAM,EAAE,GAAG,SAAS,KAAG,IAAI,CAGxD;IAEK,cAAc,GAAI,KAAK,MAAM,EAAE,GAAG,SAAS,KAAG,IAAI,CAGvD;IAEK,aAAa,QAAO,IAAI,CAG7B;IAEK,UAAU,GAAI,WAAW,MAAM,KAAG,IAAI,CAwB3C;IAEK,QAAQ,GAAI,MAAM,MAAM,KAAG,IAAI,CAgBpC;CACF"}
1
+ {"version":3,"file":"data-grid.component.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/data-grid.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK1D;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGlD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAmBa,iBAAkB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB;IAC9F,UAAU,EAAG,WAAW,CAAC;IAIhC,0CAA0C;IACnC,UAAU,UAAS;IAE1B,kCAAkC;IAC3B,OAAO,UAAS;IAEvB,8BAA8B;IACvB,SAAS,UAAQ;IAExB,wBAAwB;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ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,GAAI,KAAK,MAAM,EAAE,GAAG,SAAS,KAAG,IAAI,CAGvD;IAEK,aAAa,QAAO,IAAI,CAG7B;IAEK,UAAU,GAAI,WAAW,MAAM,KAAG,IAAI,CAwB3C;IAEK,QAAQ,GAAI,MAAM,MAAM,KAAG,IAAI,CAgBpC;CACF"}
@@ -7,8 +7,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { MelodicComponent } from '@melodicdev/core';
8
8
  import { dataGridTemplate } from './data-grid.template.js';
9
9
  import { dataGridStyles } from './data-grid.styles.js';
10
- import { TableCore } from '../table-core/index.js';
11
- import { memoOn } from '../table-core/index.js';
10
+ import { TableCore, memoOn, resolveRowKey } from '../table-core/index.js';
11
+ /** Step, in px, for keyboard column resizing (Shift + Arrow). */
12
+ const KEYBOARD_RESIZE_STEP = 16;
13
+ /**
14
+ * Name of the custom property that carries a column's live width.
15
+ *
16
+ * The column key used to be interpolated as-is, so a key that is not a valid
17
+ * CSS identifier (`user.name`, `first name`, `a/b`) produced an invalid
18
+ * `var()` — which invalidates the whole `grid-template-columns` declaration
19
+ * and collapsed the grid. Keys that are already valid keep the same name.
20
+ */
21
+ export function columnWidthVar(key) {
22
+ const safe = /^[a-zA-Z0-9_-]+$/.test(key) ? key : key.replace(/[^a-zA-Z0-9_-]/g, (char) => `_${char.codePointAt(0).toString(16)}_`);
23
+ return `--ml-grid-col-${safe}`;
24
+ }
12
25
  /**
13
26
  * ml-data-grid — Full-featured data grid with virtual scrolling, sorting, filtering,
14
27
  * selection, column resizing, column reordering, pinned columns, and pagination.
@@ -62,11 +75,25 @@ let DataGridComponent = class DataGridComponent {
62
75
  this.virtual = true;
63
76
  /** Show per-column filter inputs below the header row */
64
77
  this.showFilterRow = false;
78
+ /**
79
+ * Make rows keyboard-operable: each row becomes a tab stop and Enter/Space
80
+ * fire `ml:row-click` (which a click always fires). Set this when you
81
+ * listen for `ml:row-click`. Mirrors ml-table's `clickable-rows`.
82
+ */
83
+ this.clickableRows = false;
65
84
  // ── Properties ───────────────────────────────────────────────────────────────
66
85
  /** Column definitions */
67
86
  this.columns = [];
68
87
  /** Row data */
69
88
  this.rows = [];
89
+ /**
90
+ * Row identity: a property name (attribute `row-key="id"`) or a function
91
+ * `(row, index) => key`. Optional. When set, each rendered row's DOM
92
+ * follows its record across sorting, filtering and paging instead of being
93
+ * reused by position, so state held inside custom cells stays with the
94
+ * right row.
95
+ */
96
+ this.rowKey = null;
70
97
  // ── Sort state ───────────────────────────────────────────────────────────────
71
98
  this.sortKey = '';
72
99
  this.sortDirection = 'asc';
@@ -110,6 +137,13 @@ let DataGridComponent = class DataGridComponent {
110
137
  this._sortedRowsMemo = memoOn();
111
138
  this._pagedRowsMemo = memoOn();
112
139
  this.isRowSelected = (index) => this._core.isRowSelected(index);
140
+ /** 1-based position of a page row within the whole (filtered) dataset; the header is row 1. */
141
+ this.rowAriaIndex = (pageIndex) => {
142
+ const pageOffset = this.serverSide ? 0 : (this.currentPage - 1) * this.pageSize;
143
+ return pageOffset + pageIndex + 2;
144
+ };
145
+ /** `repeat` key for a rendered row (see `rowKey`). */
146
+ this.getRowKey = (row, index) => resolveRowKey(this.rowKey, row, index);
113
147
  // ── Event handlers ────────────────────────────────────────────────────────────
114
148
  this.handleSort = (col) => {
115
149
  // Sorting restarts pagination from the first page before events fire.
@@ -141,6 +175,17 @@ let DataGridComponent = class DataGridComponent {
141
175
  this.handleRowClick = (row, index) => {
142
176
  this._core.emitRowClick(row, index);
143
177
  };
178
+ /** Enter/Space on a focused row fires `ml:row-click` (see `clickableRows`). */
179
+ this.handleRowKeyDown = (row, index, event) => {
180
+ if (!this.clickableRows || event.target !== event.currentTarget) {
181
+ return;
182
+ }
183
+ if (event.key !== 'Enter' && event.key !== ' ') {
184
+ return;
185
+ }
186
+ event.preventDefault();
187
+ this._core.emitRowClick(row, index);
188
+ };
144
189
  this.handleResizeStart = (key, e) => {
145
190
  this.resizingKey = key;
146
191
  this._resizeStartX = e.clientX;
@@ -160,7 +205,7 @@ let DataGridComponent = class DataGridComponent {
160
205
  // cell — on each pointermove. Drive the live drag through a CSS custom
161
206
  // property instead and commit the value once, on pointerup.
162
207
  this._pendingResizeWidth = width;
163
- this.elementRef.style.setProperty(`--ml-grid-col-${key}`, `${width}px`);
208
+ this.elementRef.style.setProperty(columnWidthVar(key), `${width}px`);
164
209
  };
165
210
  this._pendingResizeWidth = null;
166
211
  this.handleResizeEnd = () => {
@@ -168,7 +213,7 @@ let DataGridComponent = class DataGridComponent {
168
213
  return;
169
214
  if (this._pendingResizeWidth !== null) {
170
215
  this.colWidths = { ...this.colWidths, [this.resizingKey]: this._pendingResizeWidth };
171
- this.elementRef.style.removeProperty(`--ml-grid-col-${this.resizingKey}`);
216
+ this.elementRef.style.removeProperty(columnWidthVar(this.resizingKey));
172
217
  this._pendingResizeWidth = null;
173
218
  }
174
219
  this.elementRef.dispatchEvent(new CustomEvent('ml:column-resize', {
@@ -178,13 +223,52 @@ let DataGridComponent = class DataGridComponent {
178
223
  }));
179
224
  this.resizingKey = null;
180
225
  };
226
+ /**
227
+ * Abandon an in-flight column resize without committing it.
228
+ *
229
+ * A `pointercancel` (touch scroll takeover, the OS stealing the pointer)
230
+ * or losing pointer capture never produces a `pointerup`, which left the
231
+ * grid stuck in its "resizing" state with a stray live width applied.
232
+ */
233
+ this.handleResizeCancel = () => {
234
+ if (!this.resizingKey)
235
+ return;
236
+ this.elementRef.style.removeProperty(columnWidthVar(this.resizingKey));
237
+ this._pendingResizeWidth = null;
238
+ this.resizingKey = null;
239
+ };
240
+ /** Resize a column by `delta` px (keyboard path) and announce the new width. */
241
+ this.resizeColumnBy = (key, delta) => {
242
+ const col = this.columns.find((c) => c.key === key);
243
+ if (!col || col.resizable === false)
244
+ return;
245
+ const minW = col.minWidth ?? 80;
246
+ const width = Math.max(minW, (this.columnWidths[key] ?? 150) + delta);
247
+ if (width === this.columnWidths[key])
248
+ return;
249
+ this.colWidths = { ...this.colWidths, [key]: width };
250
+ this.elementRef.dispatchEvent(new CustomEvent('ml:column-resize', {
251
+ bubbles: true,
252
+ composed: true,
253
+ detail: { key, width }
254
+ }));
255
+ };
181
256
  /**
182
257
  * Keyboard equivalents for the header's mouse-only interactions.
183
258
  *
184
- * Enter/Space sorts; Ctrl/Cmd + Arrow moves the column. Drag-and-drop
185
- * reordering and click-to-sort were otherwise unreachable without a mouse.
259
+ * Enter/Space sorts; Ctrl/Cmd + Arrow moves the column; Shift + Arrow
260
+ * resizes it. Drag-and-drop reordering, drag-to-resize and click-to-sort
261
+ * were otherwise unreachable without a mouse.
186
262
  */
187
263
  this.handleHeaderKeyDown = (col, event) => {
264
+ if (event.shiftKey && !event.ctrlKey && !event.metaKey && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
265
+ if (col.resizable === false) {
266
+ return;
267
+ }
268
+ event.preventDefault();
269
+ this.resizeColumnBy(col.key, event.key === 'ArrowLeft' ? -KEYBOARD_RESIZE_STEP : KEYBOARD_RESIZE_STEP);
270
+ return;
271
+ }
188
272
  if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
189
273
  if (col.reorderable === false) {
190
274
  return;
@@ -392,7 +476,7 @@ let DataGridComponent = class DataGridComponent {
392
476
  get gridTemplateColumns() {
393
477
  // `var(--ml-grid-col-<key>, <committed>px)` lets a live column drag
394
478
  // update the layout by writing one custom property, without a render.
395
- const cols = this.orderedColumns.map((col) => `var(--ml-grid-col-${col.key}, ${this.columnWidths[col.key] ?? 150}px)`).join(' ');
479
+ const cols = this.orderedColumns.map((col) => `var(${columnWidthVar(col.key)}, ${this.columnWidths[col.key] ?? 150}px)`).join(' ');
396
480
  return this.selectable ? `44px ${cols}` : cols;
397
481
  }
398
482
  getPinnedLeftOffset(key) {
@@ -462,7 +546,9 @@ DataGridComponent = __decorate([
462
546
  'server-side',
463
547
  'page-size',
464
548
  'virtual',
465
- 'show-filter-row'
549
+ 'show-filter-row',
550
+ 'clickable-rows',
551
+ 'row-key'
466
552
  ]
467
553
  })
468
554
  ], DataGridComponent);
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/data-grid.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDAuiB1B,CAAC"}
1
+ {"version":3,"file":"data-grid.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/data-grid.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDAwjB1B,CAAC"}
@@ -25,6 +25,7 @@ export const dataGridStyles = () => css `
25
25
  * --ml-data-grid-row-selected-hover-bg: var(--ml-color-primary-subtle, rgba(99, 102, 241, 0.07))
26
26
  * --ml-data-grid-row-striped-bg: var(--ml-color-surface-sunken)
27
27
  * --ml-data-grid-row-striped-hover-bg: var(--ml-color-surface-raised)
28
+ * --ml-data-grid-row-focus-outline-color: var(--ml-color-primary)
28
29
  *
29
30
  * Data Grid: cells
30
31
  * --ml-data-grid-cell-color: var(--ml-color-text)
@@ -311,6 +312,11 @@ export const dataGridStyles = () => css `
311
312
  border-bottom: none;
312
313
  }
313
314
 
315
+ .ml-data-grid__row:focus-visible {
316
+ outline: 2px solid var(--ml-data-grid-row-focus-outline-color, var(--ml-color-primary));
317
+ outline-offset: -2px;
318
+ }
319
+
314
320
  .ml-data-grid--hoverable .ml-data-grid__row:hover {
315
321
  background-color: var(--ml-data-grid-row-hover-bg, var(--ml-color-surface-sunken));
316
322
  }
@@ -550,4 +556,15 @@ export const dataGridStyles = () => css `
550
556
  opacity: 0.4;
551
557
  cursor: not-allowed;
552
558
  }
559
+
560
+ /*
561
+ * Forced colors (Windows High Contrast): box-shadow rings and background
562
+ * highlights are not painted there, so focus falls back to a real outline.
563
+ */
564
+ @media (forced-colors: active) {
565
+ .ml-data-grid__filter-input:focus {
566
+ outline: 2px solid Highlight;
567
+ outline-offset: -2px;
568
+ }
569
+ }
553
570
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid.template.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/data-grid.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAUlE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,iBAAiB,6CAmOpD"}
1
+ {"version":3,"file":"data-grid.template.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/data-grid.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAUlE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,iBAAiB,6CA4OpD"}
@@ -31,12 +31,12 @@ export function dataGridTemplate(c) {
31
31
  `)}
32
32
 
33
33
  <div class="ml-data-grid__viewport">
34
- <div class="ml-data-grid__inner" style="min-width: ${totalW}px">
34
+ <div class="ml-data-grid__inner" style="min-width: ${totalW}px" role="table" aria-rowcount=${c.totalRows + 1}>
35
35
 
36
36
  <!-- Header row -->
37
- <div class="ml-data-grid__header-row" style="grid-template-columns: ${gtc}">
37
+ <div class="ml-data-grid__header-row" style="grid-template-columns: ${gtc}" role="row" aria-rowindex="1">
38
38
  ${when(c.selectable, () => html `
39
- <div class="ml-data-grid__th ml-data-grid__check-cell">
39
+ <div class="ml-data-grid__th ml-data-grid__check-cell" role="columnheader">
40
40
  <input
41
41
  type="checkbox"
42
42
  class="ml-data-grid__checkbox"
@@ -70,7 +70,7 @@ export function dataGridTemplate(c) {
70
70
  @drop=${() => c.handleDrop(col.key)}
71
71
  @click=${() => c.handleSort(col)}
72
72
  @keydown=${(e) => c.handleHeaderKeyDown(col, e)}
73
- tabindex=${col.sortable || col.reorderable !== false ? '0' : ''}
73
+ tabindex=${col.sortable || col.reorderable !== false || col.resizable !== false ? '0' : ''}
74
74
  role="columnheader"
75
75
  aria-sort=${c.sortKey === col.key
76
76
  ? (c.sortDirection === 'asc' ? 'ascending' : 'descending')
@@ -94,6 +94,8 @@ export function dataGridTemplate(c) {
94
94
  @pointerdown=${(e) => c.handleResizeStart(col.key, e)}
95
95
  @pointermove=${(e) => c.handleResizeMove(col.key, e)}
96
96
  @pointerup=${c.handleResizeEnd}
97
+ @pointercancel=${c.handleResizeCancel}
98
+ @lostpointercapture=${c.handleResizeCancel}
97
99
  @click=${(e) => e.stopPropagation()}
98
100
  ></div>
99
101
  `)}
@@ -103,9 +105,9 @@ export function dataGridTemplate(c) {
103
105
 
104
106
  <!-- Filter row -->
105
107
  ${when(c.showFilterRow, () => html `
106
- <div class="ml-data-grid__filter-row" style="grid-template-columns: ${gtc}">
108
+ <div class="ml-data-grid__filter-row" style="grid-template-columns: ${gtc}" role="row">
107
109
  ${when(c.selectable, () => html `
108
- <div class="ml-data-grid__filter-cell ml-data-grid__check-cell"></div>
110
+ <div class="ml-data-grid__filter-cell ml-data-grid__check-cell" role="cell"></div>
109
111
  `)}
110
112
  ${repeat(c.orderedColumns, (col) => col.key, (col) => html `
111
113
  <div
@@ -115,12 +117,14 @@ export function dataGridTemplate(c) {
115
117
  'ml-data-grid__filter-cell--pinned-right': col.pinned === 'right'
116
118
  })}
117
119
  style=${pinStyle(c, col)}
120
+ role="cell"
118
121
  >
119
122
  ${when(!!col.filterable, () => html `
120
123
  <input
121
124
  type="text"
122
125
  class="ml-data-grid__filter-input"
123
126
  placeholder="Filter..."
127
+ aria-label=${`Filter ${col.label}`}
124
128
  .value=${c.filters[col.key] ?? ''}
125
129
  @input=${(e) => c.handleFilterInput(col.key, e)}
126
130
  />
@@ -132,11 +136,11 @@ export function dataGridTemplate(c) {
132
136
 
133
137
  <!-- Virtual top spacer -->
134
138
  ${when(c.virtual && c.topSpacerHeight > 0, () => html `
135
- <div class="ml-data-grid__top-spacer" style="height: ${c.topSpacerHeight}px"></div>
139
+ <div class="ml-data-grid__top-spacer" style="height: ${c.topSpacerHeight}px" aria-hidden="true"></div>
136
140
  `)}
137
141
 
138
142
  <!-- Data rows -->
139
- ${repeat(c.visibleRows, (_, i) => c.startIndex + i, (row, i) => html `
143
+ ${repeat(c.visibleRows, (row, i) => c.getRowKey(row, c.startIndex + i), (row, i) => html `
140
144
  <div
141
145
  class=${classMap({
142
146
  'ml-data-grid__row': true,
@@ -144,10 +148,14 @@ export function dataGridTemplate(c) {
144
148
  'ml-data-grid__row--even': (c.startIndex + i) % 2 === 1
145
149
  })}
146
150
  style="grid-template-columns: ${gtc}"
151
+ role="row"
152
+ aria-rowindex=${c.rowAriaIndex(c.startIndex + i)}
153
+ tabindex=${c.clickableRows ? '0' : undefined}
147
154
  @click=${() => c.handleRowClick(row, c.startIndex + i)}
155
+ @keydown=${(e) => c.handleRowKeyDown(row, c.startIndex + i, e)}
148
156
  >
149
157
  ${when(c.selectable, () => html `
150
- <div class="ml-data-grid__td ml-data-grid__check-cell">
158
+ <div class="ml-data-grid__td ml-data-grid__check-cell" role="cell">
151
159
  <input
152
160
  type="checkbox"
153
161
  class="ml-data-grid__checkbox"
@@ -169,6 +177,7 @@ export function dataGridTemplate(c) {
169
177
  'ml-data-grid__td--pinned-right-edge': col.key === c.firstRightPinnedKey
170
178
  })}
171
179
  style=${pinStyle(c, col)}
180
+ role="cell"
172
181
  >
173
182
  ${renderCell(col, row, c.startIndex + i)}
174
183
  </div>
@@ -178,7 +187,7 @@ export function dataGridTemplate(c) {
178
187
 
179
188
  <!-- Virtual bottom spacer -->
180
189
  ${when(c.virtual && c.bottomSpacerHeight > 0, () => html `
181
- <div class="ml-data-grid__bottom-spacer" style="height: ${c.bottomSpacerHeight}px"></div>
190
+ <div class="ml-data-grid__bottom-spacer" style="height: ${c.bottomSpacerHeight}px" aria-hidden="true"></div>
182
191
  `)}
183
192
 
184
193
  </div>
@@ -2,4 +2,5 @@ export { DataGridComponent } from './data-grid.component.js';
2
2
  export { dataGridTemplate } from './data-grid.template.js';
3
3
  export { dataGridStyles } from './data-grid.styles.js';
4
4
  export type { DataGridColumn, SortDirection, DataGridState } from './data-grid.types.js';
5
+ export type { TableRowKey } from '../table-core/table-core.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/data-grid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzF,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC"}
@@ -99,6 +99,6 @@ export const listItemStyles = () => css `
99
99
  display: flex;
100
100
  align-items: center;
101
101
  flex-shrink: 0;
102
- margin-left: auto;
102
+ margin-inline-start: auto;
103
103
  }
104
104
  `;
@@ -2,4 +2,5 @@ export { TableComponent } from './table.component.js';
2
2
  export { tableTemplate } from './table.template.js';
3
3
  export { tableStyles } from './table.styles.js';
4
4
  export type { TableColumn, SortDirection } from './table.types.js';
5
+ export type { TableRowKey } from '../table-core/table-core.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { IElementRef, OnCreate, OnDestroy, OnRender, OnPropertyChange } from '@melodicdev/core';
2
2
  import type { TableColumn, SortDirection } from './table.types.js';
3
+ import type { TableRowKey } from '../table-core/index.js';
3
4
  /**
4
5
  * ml-table - Data table with sorting, selection, and custom cell rendering
5
6
  *
@@ -66,6 +67,13 @@ export declare class TableComponent implements IElementRef, OnCreate, OnDestroy,
66
67
  manualSort: boolean;
67
68
  /** Column definitions */
68
69
  columns: TableColumn[];
70
+ /**
71
+ * Row identity: a property name (attribute `row-key="id"`) or a function
72
+ * `(row, index) => key`. Optional. When set, each rendered row's DOM
73
+ * follows its record across sorting instead of being reused by position,
74
+ * so state held inside custom cells stays with the right row.
75
+ */
76
+ rowKey: TableRowKey | null;
69
77
  /** Row data */
70
78
  rows: Record<string, unknown>[];
71
79
  /** Currently sorted column key */
@@ -93,6 +101,8 @@ export declare class TableComponent implements IElementRef, OnCreate, OnDestroy,
93
101
  get allSelected(): boolean;
94
102
  get someSelected(): boolean;
95
103
  isRowSelected: (index: number) => boolean;
104
+ /** `repeat` key for a rendered row (see `rowKey`). */
105
+ getRowKey: (row: Record<string, unknown>, index: number) => unknown;
96
106
  /**
97
107
  * Sort headers were mouse-only: a `<th>` with a click handler is not
98
108
  * focusable and does not respond to Enter/Space, so a keyboard user could
@@ -103,5 +113,11 @@ export declare class TableComponent implements IElementRef, OnCreate, OnDestroy,
103
113
  handleSelectAll: () => void;
104
114
  handleSelectRow: (index: number, event: Event) => void;
105
115
  handleRowClick: (row: Record<string, unknown>, index: number) => void;
116
+ /**
117
+ * Keyboard activation for clickable rows. With `clickable-rows` a row is a
118
+ * tab stop and Enter/Space fire `ml:row-click`, which used to be reachable
119
+ * with a mouse only. Keys pressed inside a cell's own controls are theirs.
120
+ */
121
+ handleRowKeyDown: (row: Record<string, unknown>, index: number, event: KeyboardEvent) => void;
106
122
  }
107
123
  //# sourceMappingURL=table.component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.component.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAMa,cAAe,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB;IAC3F,UAAU,EAAG,WAAW,CAAC;IAEhC;;;;OAIG;IACI,aAAa,UAAS;IAE7B,0CAA0C;IACnC,SAAS,UAAS;IAEzB,kDAAkD;IAC3C,gBAAgB,UAAS;IAEhC,0CAA0C;IACnC,UAAU,UAAS;IAE1B,kCAAkC;IAC3B,OAAO,UAAS;IAEvB,8BAA8B;IACvB,SAAS,UAAQ;IAExB,0BAA0B;IACnB,YAAY,UAAS;IAE5B,iBAAiB;IACV,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEhC,yBAAyB;IAClB,UAAU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AAI,CAE7C;IAEK,eAAe,QAAO,IAAI,CAE/B;IAEK,eAAe,GAAI,OAAO,MAAM,EAAE,OAAO,KAAK,KAAG,IAAI,CAE1D;IAEK,cAAc,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,MAAM,KAAG,IAAI,CAEzE;CACF"}
1
+ {"version":3,"file":"table.component.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAMa,cAAe,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB;IAC3F,UAAU,EAAG,WAAW,CAAC;IAEhC;;;;OAIG;IACI,aAAa,UAAS;IAE7B,0CAA0C;IACnC,SAAS,UAAS;IAEzB,kDAAkD;IAC3C,gBAAgB,UAAS;IAEhC,0CAA0C;IACnC,UAAU,UAAS;IAE1B,kCAAkC;IAC3B,OAAO,UAAS;IAEvB,8BAA8B;IACvB,SAAS,UAAQ;IAExB,0BAA0B;IACnB,YAAY,UAAS;IAE5B,iBAAiB;IACV,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEhC,yBAAyB;IAClB,UAAU,SAAM;IAEvB,+BAA+B;IACxB,WAAW,SAAM;IAExB,2DAA2D;IACpD,OAAO,UAAS;IAEvB;;;;;OAKG;IACI,UAAU,UAAS;IAE1B,yBAAyB;IAClB,OAAO,EAAE,WAAW,EAAE,CAAM;IAEnC;;;;;OAKG;IACI,MAAM,EAAE,WAAW,GAAG,IAAI,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/B;IAEK,eAAe,GAAI,OAAO,MAAM,EAAE,OAAO,KAAK,KAAG,IAAI,CAE1D;IAEK,cAAc,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,MAAM,KAAG,IAAI,CAEzE;IAEF;;;;OAIG;IACI,gBAAgB,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,OAAO,aAAa,KAAG,IAAI,CAUjG;CACF"}
@@ -8,8 +8,7 @@ import { MelodicComponent } from '@melodicdev/core';
8
8
  import { watchSlotPresence } from '../../../functions/index.js';
9
9
  import { tableTemplate } from './table.template.js';
10
10
  import { tableStyles } from './table.styles.js';
11
- import { TableCore } from '../table-core/index.js';
12
- import { memoOn } from '../table-core/index.js';
11
+ import { TableCore, memoOn, resolveRowKey } from '../table-core/index.js';
13
12
  /**
14
13
  * ml-table - Data table with sorting, selection, and custom cell rendering
15
14
  *
@@ -76,6 +75,13 @@ let TableComponent = class TableComponent {
76
75
  this.manualSort = false;
77
76
  /** Column definitions */
78
77
  this.columns = [];
78
+ /**
79
+ * Row identity: a property name (attribute `row-key="id"`) or a function
80
+ * `(row, index) => key`. Optional. When set, each rendered row's DOM
81
+ * follows its record across sorting instead of being reused by position,
82
+ * so state held inside custom cells stays with the right row.
83
+ */
84
+ this.rowKey = null;
79
85
  /** Row data */
80
86
  this.rows = [];
81
87
  /** Currently sorted column key */
@@ -99,6 +105,10 @@ let TableComponent = class TableComponent {
99
105
  this.isRowSelected = (index) => {
100
106
  return this._core.isRowSelected(index);
101
107
  };
108
+ /** `repeat` key for a rendered row (see `rowKey`). */
109
+ this.getRowKey = (row, index) => {
110
+ return resolveRowKey(this.rowKey, row, index);
111
+ };
102
112
  // ── Event handlers ────────────────────────────────────────────────────────────
103
113
  /**
104
114
  * Sort headers were mouse-only: a `<th>` with a click handler is not
@@ -124,6 +134,21 @@ let TableComponent = class TableComponent {
124
134
  this.handleRowClick = (row, index) => {
125
135
  this._core.emitRowClick(row, index);
126
136
  };
137
+ /**
138
+ * Keyboard activation for clickable rows. With `clickable-rows` a row is a
139
+ * tab stop and Enter/Space fire `ml:row-click`, which used to be reachable
140
+ * with a mouse only. Keys pressed inside a cell's own controls are theirs.
141
+ */
142
+ this.handleRowKeyDown = (row, index, event) => {
143
+ if (!this.clickableRows || event.target !== event.currentTarget) {
144
+ return;
145
+ }
146
+ if (event.key !== 'Enter' && event.key !== ' ') {
147
+ return;
148
+ }
149
+ event.preventDefault();
150
+ this._core.emitRowClick(row, index);
151
+ };
127
152
  }
128
153
  // ── Row height by size ────────────────────────────────────────────────────────
129
154
  get rowHeight() {
@@ -189,7 +214,7 @@ TableComponent = __decorate([
189
214
  selector: 'ml-table',
190
215
  template: tableTemplate,
191
216
  styles: tableStyles,
192
- attributes: ['selectable', 'striped', 'hoverable', 'size', 'table-title', 'description', 'sticky-header', 'virtual', 'manual-sort', 'clickable-rows']
217
+ attributes: ['selectable', 'striped', 'hoverable', 'size', 'table-title', 'description', 'sticky-header', 'virtual', 'manual-sort', 'clickable-rows', 'row-key']
193
218
  })
194
219
  ], TableComponent);
195
220
  export { TableComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"table.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,iDAyTvB,CAAC"}
1
+ {"version":3,"file":"table.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,iDA+TvB,CAAC"}
@@ -42,6 +42,7 @@ export const tableStyles = () => css `
42
42
  * --ml-table-row-hover-border-left-width: 0
43
43
  * --ml-table-row-hover-border-left-color: transparent
44
44
  * --ml-table-row-selected-bg: var(--ml-color-primary-subtle, rgba(99, 102, 241, 0.04))
45
+ * --ml-table-row-focus-outline-color: var(--ml-color-primary)
45
46
  * --ml-table-row-selected-hover-bg: var(--ml-color-primary-subtle, rgba(99, 102, 241, 0.06))
46
47
  * --ml-table-row-striped-bg: var(--ml-color-surface-sunken)
47
48
  * --ml-table-row-striped-hover-bg: var(--ml-color-surface-raised)
@@ -139,7 +140,7 @@ export const tableStyles = () => css `
139
140
  color: var(--ml-table-header-color, var(--ml-color-text-muted));
140
141
  text-transform: uppercase;
141
142
  letter-spacing: 0.05em;
142
- text-align: left;
143
+ text-align: start;
143
144
  white-space: nowrap;
144
145
  user-select: none;
145
146
  }
@@ -207,6 +208,11 @@ export const tableStyles = () => css `
207
208
  cursor: pointer;
208
209
  }
209
210
 
211
+ .ml-table--row-clickable .ml-table__row:focus-visible {
212
+ outline: 2px solid var(--ml-table-row-focus-outline-color, var(--ml-color-primary));
213
+ outline-offset: -2px;
214
+ }
215
+
210
216
  .ml-table__row--selected {
211
217
  background-color: var(--ml-table-row-selected-bg, var(--ml-color-primary-subtle, rgba(99, 102, 241, 0.04)));
212
218
  }
@@ -1 +1 @@
1
- {"version":3,"file":"table.template.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,6CAkI9C"}
1
+ {"version":3,"file":"table.template.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/table/table.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,6CAoI9C"}