@hjmds/design-contracts 1.19.0 → 1.21.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 (144) hide show
  1. package/dist/authoring-tools.d.ts +38 -0
  2. package/dist/authoring-tools.d.ts.map +1 -0
  3. package/dist/authoring-tools.js +35 -0
  4. package/dist/authoring-tools.js.map +1 -0
  5. package/dist/behaviors.d.ts +34 -3
  6. package/dist/behaviors.d.ts.map +1 -1
  7. package/dist/behaviors.js +2 -0
  8. package/dist/behaviors.js.map +1 -1
  9. package/dist/bottom-navigation.d.ts +10 -0
  10. package/dist/bottom-navigation.d.ts.map +1 -1
  11. package/dist/bottom-navigation.js +10 -0
  12. package/dist/bottom-navigation.js.map +1 -1
  13. package/dist/calendar.d.ts +9 -1
  14. package/dist/calendar.d.ts.map +1 -1
  15. package/dist/calendar.js +4 -2
  16. package/dist/calendar.js.map +1 -1
  17. package/dist/catalog.d.ts +148 -2
  18. package/dist/catalog.d.ts.map +1 -1
  19. package/dist/catalog.js +6 -2
  20. package/dist/catalog.js.map +1 -1
  21. package/dist/chart.d.ts +398 -0
  22. package/dist/chart.d.ts.map +1 -0
  23. package/dist/chart.js +414 -0
  24. package/dist/chart.js.map +1 -0
  25. package/dist/collection-editing.d.ts +38 -0
  26. package/dist/collection-editing.d.ts.map +1 -0
  27. package/dist/collection-editing.js +53 -0
  28. package/dist/collection-editing.js.map +1 -0
  29. package/dist/communication.d.ts +29 -0
  30. package/dist/communication.d.ts.map +1 -0
  31. package/dist/communication.js +11 -0
  32. package/dist/communication.js.map +1 -0
  33. package/dist/component-definitions.d.ts +1 -0
  34. package/dist/component-definitions.d.ts.map +1 -1
  35. package/dist/component-definitions.js +1 -0
  36. package/dist/component-definitions.js.map +1 -1
  37. package/dist/component-recipes.d.ts +25 -0
  38. package/dist/component-recipes.d.ts.map +1 -1
  39. package/dist/component-recipes.js +13 -0
  40. package/dist/component-recipes.js.map +1 -1
  41. package/dist/data-table.d.ts +229 -5
  42. package/dist/data-table.d.ts.map +1 -1
  43. package/dist/data-table.js +242 -6
  44. package/dist/data-table.js.map +1 -1
  45. package/dist/data-workflows.d.ts +70 -0
  46. package/dist/data-workflows.d.ts.map +1 -0
  47. package/dist/data-workflows.js +109 -0
  48. package/dist/data-workflows.js.map +1 -0
  49. package/dist/dataviz.d.ts +7 -6
  50. package/dist/dataviz.d.ts.map +1 -1
  51. package/dist/dataviz.js +7 -6
  52. package/dist/dataviz.js.map +1 -1
  53. package/dist/gooey-navigation.d.ts +7 -0
  54. package/dist/gooey-navigation.d.ts.map +1 -1
  55. package/dist/gooey-navigation.js +10 -0
  56. package/dist/gooey-navigation.js.map +1 -1
  57. package/dist/index.d.ts +2 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +1 -0
  60. package/dist/index.js.map +1 -1
  61. package/dist/media-transport.d.ts +16 -0
  62. package/dist/media-transport.d.ts.map +1 -0
  63. package/dist/media-transport.js +17 -0
  64. package/dist/media-transport.js.map +1 -0
  65. package/dist/recipes.d.ts +1 -0
  66. package/dist/recipes.d.ts.map +1 -1
  67. package/dist/recipes.js +1 -0
  68. package/dist/recipes.js.map +1 -1
  69. package/dist/semantic-colors.d.ts +9 -0
  70. package/dist/semantic-colors.d.ts.map +1 -1
  71. package/dist/semantic-colors.js +5 -0
  72. package/dist/semantic-colors.js.map +1 -1
  73. package/dist/showcase.d.ts.map +1 -1
  74. package/dist/showcase.js +3 -1
  75. package/dist/showcase.js.map +1 -1
  76. package/dist/social-compositions.d.ts +19 -0
  77. package/dist/social-compositions.d.ts.map +1 -0
  78. package/dist/social-compositions.js +33 -0
  79. package/dist/social-compositions.js.map +1 -0
  80. package/dist/streaming-answer.d.ts +18 -0
  81. package/dist/streaming-answer.d.ts.map +1 -0
  82. package/dist/streaming-answer.js +61 -0
  83. package/dist/streaming-answer.js.map +1 -0
  84. package/dist/task-controls.d.ts +31 -0
  85. package/dist/task-controls.d.ts.map +1 -0
  86. package/dist/task-controls.js +25 -0
  87. package/dist/task-controls.js.map +1 -0
  88. package/dist/toggle-feedback.d.ts +22 -0
  89. package/dist/toggle-feedback.d.ts.map +1 -0
  90. package/dist/toggle-feedback.js +32 -0
  91. package/dist/toggle-feedback.js.map +1 -0
  92. package/dist/transfer-task.d.ts +13 -0
  93. package/dist/transfer-task.d.ts.map +1 -0
  94. package/dist/transfer-task.js +13 -0
  95. package/dist/transfer-task.js.map +1 -0
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +1 -1
  98. package/dist/version.js.map +1 -1
  99. package/docs/authoring-tools.md +31 -0
  100. package/docs/bottom-navigation.md +11 -0
  101. package/docs/calendar.md +3 -1
  102. package/docs/catalog-freeze.json +5 -0
  103. package/docs/chart.md +206 -0
  104. package/docs/collection-editing.md +83 -0
  105. package/docs/communication.md +35 -0
  106. package/docs/data-table.md +56 -6
  107. package/docs/data-workflows.md +26 -0
  108. package/docs/generated/component-maturity.md +6 -5
  109. package/docs/generated/renderer-evidence.json +95 -5
  110. package/docs/generated/renderer-evidence.md +6 -3
  111. package/docs/generated/showcase-manifest.json +66 -3
  112. package/docs/gooey-navigation.md +20 -0
  113. package/docs/library-gap-analysis.md +4 -2
  114. package/docs/media-transport.md +37 -0
  115. package/docs/social-compositions.md +51 -0
  116. package/docs/streaming-answer.md +57 -0
  117. package/docs/task-controls.md +38 -0
  118. package/docs/toggle-feedback.md +56 -0
  119. package/docs/transfer-task.md +33 -0
  120. package/docs/usage/README.md +15 -4
  121. package/docs/usage/components/activity-chip.md +2 -2
  122. package/docs/usage/components/bottom-navigation.md +14 -1
  123. package/docs/usage/components/button.md +39 -0
  124. package/docs/usage/components/calendar.md +4 -2
  125. package/docs/usage/components/chart.md +277 -0
  126. package/docs/usage/components/data-table.md +92 -18
  127. package/docs/usage/components/screen-layout.md +3 -1
  128. package/docs/usage/components/tabs.md +25 -0
  129. package/docs/usage/components/toast.md +1 -1
  130. package/docs/usage/compositions/action-feedback.md +18 -2
  131. package/docs/usage/compositions/activity-status.md +2 -2
  132. package/docs/usage/compositions/authoring-tools.md +90 -0
  133. package/docs/usage/compositions/collection-editing.md +110 -0
  134. package/docs/usage/compositions/communication.md +100 -0
  135. package/docs/usage/compositions/data-workflows.md +91 -0
  136. package/docs/usage/compositions/media-transport.md +87 -0
  137. package/docs/usage/compositions/social-compositions.md +91 -0
  138. package/docs/usage/compositions/streaming-answer.md +97 -0
  139. package/docs/usage/compositions/task-controls.md +93 -0
  140. package/docs/usage/compositions/toggle-feedback.md +84 -0
  141. package/docs/usage/compositions/transfer-task.md +86 -0
  142. package/docs/usage/compositions/web-additions.md +2 -2
  143. package/docs/usage/screens/common-shell.md +4 -0
  144. package/package.json +67 -1
@@ -1,4 +1,5 @@
1
1
  import type { AsyncCollectionState, CheckboxState, CollectionKey, CollectionSelectionModel } from "./behaviors.js";
2
+ import { type TextVariant } from "./foundations.js";
2
3
  export type DataTableAlign = "start" | "center" | "end";
3
4
  export type DataTableColumnDescriptor<Key extends CollectionKey = CollectionKey> = Readonly<{
4
5
  id: Key;
@@ -8,6 +9,16 @@ export type DataTableColumnDescriptor<Key extends CollectionKey = CollectionKey>
8
9
  sortable?: boolean;
9
10
  /** Layout hint only (px or flex-basis); renderers may ignore or clamp it. */
10
11
  width?: number;
12
+ /**
13
+ * First press sorts descending (TanStack Table `sortDescFirst`). Stat tables read "highest first";
14
+ * lower-is-better columns (ERA, rank) leave it false. Added 2026-10-14 with the Native renderer.
15
+ */
16
+ sortDescFirst?: boolean;
17
+ /**
18
+ * Keeps the column visible while the others scroll horizontally (AG Grid / TanStack column
19
+ * pinning, start edge only). Only a leading run of pinned columns is honored.
20
+ */
21
+ pinned?: "start";
11
22
  }>;
12
23
  export declare const dataTableColumnDefaults: {
13
24
  readonly align: "start";
@@ -24,6 +35,8 @@ export declare function validateDataTableColumns<Key extends CollectionKey>(colu
24
35
  export type DataTableRowDescriptor<Key extends CollectionKey = CollectionKey> = Readonly<{
25
36
  id: Key;
26
37
  disabled?: boolean;
38
+ /** Sub-row nesting (TanStack `depth`): 1 indents a substitute under a starter. 0–3. */
39
+ depth?: number;
27
40
  }>;
28
41
  export declare function validateDataTableRows<Key extends CollectionKey>(rows: readonly DataTableRowDescriptor<Key>[]): void;
29
42
  /** Row selection is the unmodified Collection base contract — no DataTable-only selection shape. */
@@ -56,7 +69,34 @@ export declare function validateDataTableSortState<Key extends CollectionKey>(st
56
69
  * actually re-sorting rows (Combobox's local/external filtering split is the
57
70
  * same boundary — HJM judges intent, never executes the data operation).
58
71
  */
59
- export declare function getNextDataTableSortState<Key extends CollectionKey>(current: DataTableSortState<Key>, columnId: Key, cycle?: DataTableSortCycle): DataTableSortState<Key>;
72
+ export declare function getNextDataTableSortState<Key extends CollectionKey>(current: DataTableSortState<Key>, columnId: Key, cycle?: DataTableSortCycle, firstDirection?: DataTableSortDirection): DataTableSortState<Key>;
73
+ /** The first direction a column's header applies, from `sortDescFirst`. */
74
+ export declare function dataTableFirstSortDirection(column: Pick<DataTableColumnDescriptor, "sortDescFirst">): DataTableSortDirection;
75
+ export type DataTableSortValue = number | string | null | undefined;
76
+ /**
77
+ * Sort key for a displayed cell string: "0.340", ".340", "36 ⅓", "13.5억", "61.0%" → numbers;
78
+ * text such as "7승0무3패" or names stay strings; "—", "-" and "" are missing.
79
+ */
80
+ export declare function toDataTableSortValue(value: unknown): DataTableSortValue;
81
+ /**
82
+ * Pure comparison: numbers numerically, strings with `localeCompare`, numbers before strings.
83
+ * Missing values are not compared here; `sortDataTableRows` always sinks them.
84
+ */
85
+ export declare function compareDataTableValues(a: Exclude<DataTableSortValue, null | undefined>, b: Exclude<DataTableSortValue, null | undefined>, locale?: string): number;
86
+ /**
87
+ * Optional row-model helper (TanStack `getSortedRowModel` with `sortUndefined: "last"`): stable,
88
+ * missing values always last in both directions. 1.20 left all sorting to products; Yajalal and
89
+ * other stat tables reimplemented the same rules, so the shared helper exists now. Products with
90
+ * server-side sorting keep calling `getNextDataTableSortState` only.
91
+ */
92
+ export declare function sortDataTableRows<Row, Key extends CollectionKey>(rows: readonly Row[], sort: DataTableSortState<Key>, getValue: (row: Row, columnId: Key) => DataTableSortValue, options?: Readonly<{
93
+ locale?: string;
94
+ }>): Row[];
95
+ /** Leading pinned columns (only an unbroken run from the start is pinned). */
96
+ export declare function splitPinnedDataTableColumns<Column extends Pick<DataTableColumnDescriptor, "pinned">>(columns: readonly Column[]): Readonly<{
97
+ pinned: readonly Column[];
98
+ scrolling: readonly Column[];
99
+ }>;
60
100
  /** The whole table's row-loading status — the unmodified Collection base async contract. */
61
101
  export type DataTableAsyncState = AsyncCollectionState;
62
102
  export type DataTableDensity = "compact" | "regular";
@@ -168,6 +208,7 @@ export declare const dataTableRecipe: {
168
208
  };
169
209
  };
170
210
  };
211
+ export declare const dataTableFamilyScenarios: readonly ["header-groups-span-contiguous-leaf-columns-and-pad-ungrouped-columns", "row-groups-insert-a-section-label-before-their-rows", "cell-tone-and-heat-are-product-decided-semantic-emphasis", "percentile-rank-flips-for-lower-is-better-stats-and-ties-take-the-midpoint", "bounded-height-tables-keep-the-header-fixed-while-the-body-scrolls", "line-score-pads-to-nine-periods-and-extends-for-extra-periods", "matrix-diagonal-is-a-blank-self-cell", "comparison-bars-favor-the-better-side-even-when-lower-is-better"];
171
212
  /**
172
213
  * No roving-tabindex grid keyboard navigation (arrow keys between cells):
173
214
  * no product using this contract has measured demand for full ARIA-grid
@@ -194,10 +235,193 @@ export declare const dataTableBehavior: {
194
235
  readonly focus: "native";
195
236
  };
196
237
  readonly native: {
197
- readonly roles: readonly [];
198
- readonly states: readonly [];
199
- readonly actions: readonly [];
238
+ readonly roles: readonly ["button", "header"];
239
+ readonly states: readonly ["selected"];
240
+ readonly actions: readonly ["activate"];
200
241
  };
201
- readonly scenarios: readonly ["row-selection-reuses-the-shared-collection-selection-model-unchanged", "select-all-reuses-the-shared-tri-state-checkbox-value", "async-state-reuses-the-shared-collection-async-state-unchanged", "sortable-header-is-a-button-inside-the-columnheader-not-the-header-itself", "sort-direction-values-pass-through-to-aria-sort-without-translation", "disabled-rows-are-excluded-from-select-all-accounting", "pagination-or-load-more-is-composed-beneath-the-table-not-owned-by-it", "row-expansion-is-not-owned-here-compose-the-disclosure-group-contract-per-row", "a-data-cell-exposes-at-most-one-focusable-control", "no-roving-tabindex-grid-navigation-is-implied"];
242
+ readonly scenarios: readonly ["sort-desc-first-columns-start-descending-and-cycle-back", "missing-values-sink-to-the-bottom-in-both-directions", "pinned-start-columns-stay-visible-while-the-rest-scrolls", "row-selection-reuses-the-shared-collection-selection-model-unchanged", "select-all-reuses-the-shared-tri-state-checkbox-value", "async-state-reuses-the-shared-collection-async-state-unchanged", "sortable-header-is-a-button-inside-the-columnheader-not-the-header-itself", "sort-direction-values-pass-through-to-aria-sort-without-translation", "disabled-rows-are-excluded-from-select-all-accounting", "pagination-or-load-more-is-composed-beneath-the-table-not-owned-by-it", "row-expansion-is-not-owned-here-compose-the-disclosure-group-contract-per-row", "a-data-cell-exposes-at-most-one-focusable-control", "no-roving-tabindex-grid-navigation-is-implied", "header-groups-span-contiguous-leaf-columns-and-pad-ungrouped-columns", "row-groups-insert-a-section-label-before-their-rows", "cell-tone-and-heat-are-product-decided-semantic-emphasis", "percentile-rank-flips-for-lower-is-better-stats-and-ties-take-the-midpoint", "bounded-height-tables-keep-the-header-fixed-while-the-body-scrolls", "line-score-pads-to-nine-periods-and-extends-for-extra-periods", "matrix-diagonal-is-a-blank-self-cell", "comparison-bars-favor-the-better-side-even-when-lower-is-better"];
202
243
  };
244
+ /** One header band above leaf columns. Columns not listed in any group get an empty placeholder cell. */
245
+ export type DataTableColumnGroup<Key extends CollectionKey = CollectionKey> = Readonly<{
246
+ id: string;
247
+ header: string;
248
+ columns: readonly Key[];
249
+ }>;
250
+ export type DataTableHeaderBand = Readonly<{
251
+ id: string;
252
+ header: string | null;
253
+ span: number;
254
+ columnIds: readonly string[];
255
+ }>;
256
+ /**
257
+ * Resolves group bands over the given (already pinned-split) column order. A group must cover a
258
+ * contiguous run; columns outside every group become placeholder bands so leaf widths still line up.
259
+ */
260
+ export declare function resolveDataTableHeaderBands<Key extends CollectionKey>(columns: readonly Pick<DataTableColumnDescriptor<Key>, "id">[], groups: readonly DataTableColumnGroup<Key>[]): DataTableHeaderBand[];
261
+ /** Labeled row section (e.g. 선발 / 교체, 동부 / 서부). Rows not in any group render first, ungrouped. */
262
+ export type DataTableRowGroup<Key extends CollectionKey = CollectionKey> = Readonly<{
263
+ id: string;
264
+ label: string;
265
+ rows: readonly Key[];
266
+ }>;
267
+ export type DataTableBodyItem<Key extends CollectionKey = CollectionKey> = Readonly<{
268
+ kind: "group";
269
+ id: string;
270
+ label: string;
271
+ }> | Readonly<{
272
+ kind: "row";
273
+ id: Key;
274
+ }>;
275
+ /** Flattens rows + groups into the body order renderers draw. Unknown or duplicated ids throw. */
276
+ export declare function resolveDataTableBody<Key extends CollectionKey>(rows: readonly DataTableRowDescriptor<Key>[], groups?: readonly DataTableRowGroup<Key>[]): DataTableBodyItem<Key>[];
277
+ /**
278
+ * Semantic cell emphasis, decided by the product per cell (AG Grid cellClassRules):
279
+ * `leader` marks a league/table best, `positive`/`negative` a direction, `muted` a non-qualifying value.
280
+ */
281
+ export type DataTableCellTone = "leader" | "positive" | "negative" | "muted";
282
+ /** Percentile heat (Savant): `high` side toward the best values, `low` toward the worst; strength 1–3. */
283
+ export type DataTableCellHeat = Readonly<{
284
+ side: "high" | "low";
285
+ strength: 1 | 2 | 3;
286
+ }>;
287
+ /**
288
+ * Percentile rank (0–100, best = 100) of `value` among `sample`. `lowerIsBetter` flips ERA-style stats.
289
+ * Ties take the midpoint rank, missing values return null. A one-value sample is the 50th percentile.
290
+ */
291
+ export declare function percentileRank(value: number | null | undefined, sample: readonly (number | null | undefined)[], options?: Readonly<{
292
+ lowerIsBetter?: boolean;
293
+ }>): number | null;
294
+ /** Maps a percentile to heat: ≥90/≥75/≥60 high, ≤10/≤25/≤40 low, the middle stays neutral (null). */
295
+ export declare function percentileHeat(percentile: number | null): DataTableCellHeat | null;
296
+ export declare const dataTableFamilyRecipe: {
297
+ /** Heat background alpha per strength, over the high/low base colors. */
298
+ readonly heatAlpha: {
299
+ readonly 1: 0.14;
300
+ readonly 2: 0.26;
301
+ readonly 3: 0.42;
302
+ };
303
+ readonly heat: {
304
+ readonly high: Readonly<{
305
+ source: "theme";
306
+ key: "danger";
307
+ alpha?: number;
308
+ }>;
309
+ readonly low: Readonly<{
310
+ source: "accent";
311
+ key: "info";
312
+ alpha?: number;
313
+ }>;
314
+ };
315
+ readonly tone: {
316
+ readonly leader: {
317
+ readonly color: Readonly<{
318
+ source: "theme";
319
+ key: "text";
320
+ alpha?: number;
321
+ }>;
322
+ readonly fontWeight: "700";
323
+ };
324
+ readonly positive: {
325
+ readonly color: Readonly<{
326
+ source: "theme";
327
+ key: "danger";
328
+ alpha?: number;
329
+ }>;
330
+ readonly fontWeight: "700";
331
+ };
332
+ readonly negative: {
333
+ readonly color: Readonly<{
334
+ source: "accent";
335
+ key: "info";
336
+ alpha?: number;
337
+ }>;
338
+ readonly fontWeight: "700";
339
+ };
340
+ readonly muted: {
341
+ readonly color: Readonly<{
342
+ source: "theme";
343
+ key: "textSub";
344
+ alpha?: number;
345
+ }>;
346
+ readonly fontWeight: "400";
347
+ };
348
+ };
349
+ readonly groupRow: {
350
+ readonly background: Readonly<{
351
+ source: "theme";
352
+ key: "surfaceAlt";
353
+ alpha?: number;
354
+ }>;
355
+ readonly color: Readonly<{
356
+ source: "theme";
357
+ key: "textMuted";
358
+ alpha?: number;
359
+ }>;
360
+ readonly textVariant: TextVariant;
361
+ };
362
+ /** Indent per sub-row depth level (substitutes under a starter, players under a team). */
363
+ readonly depthIndent: 16;
364
+ readonly headerBand: {
365
+ readonly color: Readonly<{
366
+ source: "theme";
367
+ key: "textMuted";
368
+ alpha?: number;
369
+ }>;
370
+ readonly borderBottom: Readonly<{
371
+ source: "theme";
372
+ key: "border";
373
+ alpha?: number;
374
+ }>;
375
+ };
376
+ };
377
+ export type LineScoreTeam = Readonly<{
378
+ id: string;
379
+ name: string;
380
+ /** Runs per period; null = not played yet, "X" = home team did not bat in the last inning. */
381
+ periods: readonly (number | "X" | null)[];
382
+ /** Totals in display order, e.g. { R: 5, H: 9, E: 0, B: 4 }. */
383
+ totals: Readonly<Record<string, number | null>>;
384
+ }>;
385
+ export type LineScoreColumn = Readonly<{
386
+ id: string;
387
+ header: string;
388
+ kind: "period" | "total";
389
+ }>;
390
+ /**
391
+ * Period columns are padded to `minPeriods` (9 innings) and extend for extra innings; totals follow.
392
+ * The current period (live game) is reported so renderers can highlight it.
393
+ */
394
+ export declare function resolveLineScore(teams: readonly LineScoreTeam[], options: Readonly<{
395
+ minPeriods?: number;
396
+ totals: readonly string[];
397
+ currentPeriod?: number | null;
398
+ }>): Readonly<{
399
+ columns: LineScoreColumn[];
400
+ currentPeriod: number | null;
401
+ leaderId: string | null;
402
+ }>;
403
+ export declare function formatLineScoreCell(value: number | "X" | null | undefined): string;
404
+ export type MatrixCell = Readonly<{
405
+ label: string;
406
+ tone?: DataTableCellTone | null;
407
+ heat?: DataTableCellHeat | null;
408
+ }>;
409
+ /**
410
+ * Square cross table (team × team head-to-head). Rows and columns share one id list; the diagonal is
411
+ * a self cell and renders blank. `getCell(row, column)` returns null for no record.
412
+ */
413
+ export declare function resolveMatrix<Key extends string>(ids: readonly Key[], getCell: (row: Key, column: Key) => MatrixCell | null): readonly (readonly (MatrixCell | "self" | null)[])[];
414
+ export type ComparisonRow = Readonly<{
415
+ id: string;
416
+ label: string;
417
+ values: readonly [number | null, number | null];
418
+ /** Display strings; defaults to String(value). */
419
+ display?: readonly [string, string];
420
+ lowerIsBetter?: boolean;
421
+ }>;
422
+ /** Which side wins a row (null on ties/missing), and each side's bar share of the pair (0–1). */
423
+ export declare function resolveComparisonRow(row: ComparisonRow): Readonly<{
424
+ winner: 0 | 1 | null;
425
+ shares: readonly [number, number];
426
+ }>;
203
427
  //# sourceMappingURL=data-table.d.ts.map
@@ -1 +1 @@
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AM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAChD,kDAAkD;IAClD,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC,CAAC;AAEH,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,QAAQ,CAAC;IAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CAO9H"}
@@ -1,3 +1,4 @@
1
+ import { accentColor, themeColor } from "./color-references.js";
1
2
  import { collectionItemContract, focusIndicatorContract } from "./component-contracts.js";
2
3
  import { control, fontWeight, spacing } from "./foundations.js";
3
4
  import { semanticColors } from "./semantic-colors.js";
@@ -35,6 +36,9 @@ export function validateDataTableRows(rows) {
35
36
  throw new TypeError(`Duplicate DataTable row id: ${row.id}`);
36
37
  }
37
38
  ids.add(row.id);
39
+ if (row.depth !== undefined && (!Number.isInteger(row.depth) || row.depth < 0 || row.depth > 3)) {
40
+ throw new RangeError(`DataTable row "${String(row.id)}" depth must be an integer from 0 to 3`);
41
+ }
38
42
  }
39
43
  }
40
44
  /**
@@ -76,14 +80,76 @@ export function validateDataTableSortState(state, columns) {
76
80
  * actually re-sorting rows (Combobox's local/external filtering split is the
77
81
  * same boundary — HJM judges intent, never executes the data operation).
78
82
  */
79
- export function getNextDataTableSortState(current, columnId, cycle = dataTableDefaults.sortCycle) {
83
+ export function getNextDataTableSortState(current, columnId, cycle = dataTableDefaults.sortCycle, firstDirection = "ascending") {
84
+ const second = firstDirection === "ascending" ? "descending" : "ascending";
80
85
  if (current === null || current.columnId !== columnId) {
81
- return { columnId, direction: "ascending" };
86
+ return { columnId, direction: firstDirection };
82
87
  }
83
- if (current.direction === "ascending") {
84
- return { columnId, direction: "descending" };
88
+ if (current.direction === firstDirection) {
89
+ return { columnId, direction: second };
85
90
  }
86
- return cycle === "three-state" ? null : { columnId, direction: "ascending" };
91
+ return cycle === "three-state" ? null : { columnId, direction: firstDirection };
92
+ }
93
+ /** The first direction a column's header applies, from `sortDescFirst`. */
94
+ export function dataTableFirstSortDirection(column) {
95
+ return column.sortDescFirst ? "descending" : "ascending";
96
+ }
97
+ /**
98
+ * Sort key for a displayed cell string: "0.340", ".340", "36 ⅓", "13.5억", "61.0%" → numbers;
99
+ * text such as "7승0무3패" or names stay strings; "—", "-" and "" are missing.
100
+ */
101
+ export function toDataTableSortValue(value) {
102
+ if (value === null || value === undefined)
103
+ return null;
104
+ if (typeof value === "number")
105
+ return Number.isFinite(value) ? value : null;
106
+ const text = String(value).trim();
107
+ if (!text || text === "—" || text === "-" || text === "–")
108
+ return null;
109
+ // Two or more letters (any script) mean a label, not a number with a unit.
110
+ if (/\p{L}.*\p{L}/u.test(text.replace(/[⅓⅔]/g, "")))
111
+ return text;
112
+ const number = Number.parseFloat(text.replace(/[^0-9.+-]/g, ""));
113
+ return Number.isFinite(number) ? number : text;
114
+ }
115
+ /**
116
+ * Pure comparison: numbers numerically, strings with `localeCompare`, numbers before strings.
117
+ * Missing values are not compared here; `sortDataTableRows` always sinks them.
118
+ */
119
+ export function compareDataTableValues(a, b, locale) {
120
+ if (typeof a === "number" && typeof b === "number")
121
+ return a - b;
122
+ if (typeof a === "number")
123
+ return -1;
124
+ if (typeof b === "number")
125
+ return 1;
126
+ return a.localeCompare(b, locale);
127
+ }
128
+ /**
129
+ * Optional row-model helper (TanStack `getSortedRowModel` with `sortUndefined: "last"`): stable,
130
+ * missing values always last in both directions. 1.20 left all sorting to products; Yajalal and
131
+ * other stat tables reimplemented the same rules, so the shared helper exists now. Products with
132
+ * server-side sorting keep calling `getNextDataTableSortState` only.
133
+ */
134
+ export function sortDataTableRows(rows, sort, getValue, options = {}) {
135
+ const indexed = rows.map((row, index) => ({ row, index }));
136
+ if (!sort)
137
+ return indexed.map(item => item.row);
138
+ const sign = sort.direction === "ascending" ? 1 : -1;
139
+ return indexed.sort((x, y) => {
140
+ const a = getValue(x.row, sort.columnId), b = getValue(y.row, sort.columnId);
141
+ const missingA = a === null || a === undefined, missingB = b === null || b === undefined;
142
+ if (missingA || missingB)
143
+ return missingA === missingB ? x.index - y.index : missingA ? 1 : -1;
144
+ return sign * compareDataTableValues(a, b, options.locale) || x.index - y.index;
145
+ }).map(item => item.row);
146
+ }
147
+ /** Leading pinned columns (only an unbroken run from the start is pinned). */
148
+ export function splitPinnedDataTableColumns(columns) {
149
+ let count = 0;
150
+ while (count < columns.length && columns[count].pinned === "start")
151
+ count++;
152
+ return { pinned: columns.slice(0, count), scrolling: columns.slice(count) };
87
153
  }
88
154
  /**
89
155
  * Reuses `collectionItemContract`'s hover/selected/focus tokens instead of a
@@ -144,6 +210,16 @@ export const dataTableRecipe = {
144
210
  focus: focusIndicatorContract,
145
211
  },
146
212
  };
213
+ export const dataTableFamilyScenarios = [
214
+ "header-groups-span-contiguous-leaf-columns-and-pad-ungrouped-columns",
215
+ "row-groups-insert-a-section-label-before-their-rows",
216
+ "cell-tone-and-heat-are-product-decided-semantic-emphasis",
217
+ "percentile-rank-flips-for-lower-is-better-stats-and-ties-take-the-midpoint",
218
+ "bounded-height-tables-keep-the-header-fixed-while-the-body-scrolls",
219
+ "line-score-pads-to-nine-periods-and-extends-for-extra-periods",
220
+ "matrix-diagonal-is-a-blank-self-cell",
221
+ "comparison-bars-favor-the-better-side-even-when-lower-is-better",
222
+ ];
147
223
  /**
148
224
  * No roving-tabindex grid keyboard navigation (arrow keys between cells):
149
225
  * no product using this contract has measured demand for full ARIA-grid
@@ -165,8 +241,11 @@ export const dataTableBehavior = {
165
241
  keyboard: ["Tab", "Enter", "Space"],
166
242
  focus: "native",
167
243
  },
168
- native: { roles: [], states: [], actions: [] },
244
+ native: { roles: ["button", "header"], states: ["selected"], actions: ["activate"] },
169
245
  scenarios: [
246
+ "sort-desc-first-columns-start-descending-and-cycle-back",
247
+ "missing-values-sink-to-the-bottom-in-both-directions",
248
+ "pinned-start-columns-stay-visible-while-the-rest-scrolls",
170
249
  "row-selection-reuses-the-shared-collection-selection-model-unchanged",
171
250
  "select-all-reuses-the-shared-tri-state-checkbox-value",
172
251
  "async-state-reuses-the-shared-collection-async-state-unchanged",
@@ -177,6 +256,163 @@ export const dataTableBehavior = {
177
256
  "row-expansion-is-not-owned-here-compose-the-disclosure-group-contract-per-row",
178
257
  "a-data-cell-exposes-at-most-one-focusable-control",
179
258
  "no-roving-tabindex-grid-navigation-is-implied",
259
+ ...dataTableFamilyScenarios,
180
260
  ],
181
261
  };
262
+ /**
263
+ * Resolves group bands over the given (already pinned-split) column order. A group must cover a
264
+ * contiguous run; columns outside every group become placeholder bands so leaf widths still line up.
265
+ */
266
+ export function resolveDataTableHeaderBands(columns, groups) {
267
+ const owner = new Map();
268
+ for (const group of groups) {
269
+ assertNonEmpty(group.id, "column group id");
270
+ assertNonEmpty(group.header, `column group "${group.id}" header`);
271
+ for (const id of group.columns) {
272
+ if (owner.has(id))
273
+ throw new TypeError(`DataTable column "${String(id)}" belongs to two groups`);
274
+ owner.set(id, group);
275
+ }
276
+ }
277
+ const bands = [];
278
+ for (const column of columns) {
279
+ const group = owner.get(column.id) ?? null;
280
+ const last = bands.at(-1);
281
+ if (group && last && last.id === group.id) {
282
+ last.columnIds.push(column.id);
283
+ continue;
284
+ }
285
+ if (group && bands.some((band) => band.id === group.id))
286
+ throw new TypeError(`DataTable column group "${group.id}" must be contiguous`);
287
+ bands.push({ id: group ? group.id : `placeholder-${column.id}`, header: group ? group.header : null, columnIds: [column.id] });
288
+ }
289
+ return bands.map((band) => ({ ...band, span: band.columnIds.length }));
290
+ }
291
+ /** Flattens rows + groups into the body order renderers draw. Unknown or duplicated ids throw. */
292
+ export function resolveDataTableBody(rows, groups = []) {
293
+ if (groups.length === 0)
294
+ return rows.map((row) => ({ kind: "row", id: row.id }));
295
+ const known = new Set(rows.map((row) => row.id)), placed = new Set();
296
+ const grouped = [];
297
+ for (const group of groups) {
298
+ assertNonEmpty(group.id, "row group id");
299
+ assertNonEmpty(group.label, `row group "${group.id}" label`);
300
+ grouped.push({ kind: "group", id: group.id, label: group.label });
301
+ for (const id of group.rows) {
302
+ if (!known.has(id))
303
+ throw new TypeError(`DataTable row group "${group.id}" references unknown row id: ${String(id)}`);
304
+ if (placed.has(id))
305
+ throw new TypeError(`DataTable row "${String(id)}" belongs to two row groups`);
306
+ placed.add(id);
307
+ grouped.push({ kind: "row", id });
308
+ }
309
+ }
310
+ const loose = rows.filter((row) => !placed.has(row.id)).map((row) => ({ kind: "row", id: row.id }));
311
+ return [...loose, ...grouped];
312
+ }
313
+ /**
314
+ * Percentile rank (0–100, best = 100) of `value` among `sample`. `lowerIsBetter` flips ERA-style stats.
315
+ * Ties take the midpoint rank, missing values return null. A one-value sample is the 50th percentile.
316
+ */
317
+ export function percentileRank(value, sample, options = {}) {
318
+ if (value === null || value === undefined || !Number.isFinite(value))
319
+ return null;
320
+ const values = sample.filter((item) => item !== null && item !== undefined && Number.isFinite(item));
321
+ if (values.length <= 1)
322
+ return 50;
323
+ let below = 0, equal = 0;
324
+ for (const item of values) {
325
+ const better = options.lowerIsBetter ? item > value : item < value;
326
+ if (item === value)
327
+ equal++;
328
+ else if (better)
329
+ below++;
330
+ }
331
+ return Math.round(((below + (equal - 1) / 2) / (values.length - 1)) * 100);
332
+ }
333
+ /** Maps a percentile to heat: ≥90/≥75/≥60 high, ≤10/≤25/≤40 low, the middle stays neutral (null). */
334
+ export function percentileHeat(percentile) {
335
+ if (percentile === null)
336
+ return null;
337
+ if (percentile >= 90)
338
+ return { side: "high", strength: 3 };
339
+ if (percentile >= 75)
340
+ return { side: "high", strength: 2 };
341
+ if (percentile >= 60)
342
+ return { side: "high", strength: 1 };
343
+ if (percentile <= 10)
344
+ return { side: "low", strength: 3 };
345
+ if (percentile <= 25)
346
+ return { side: "low", strength: 2 };
347
+ if (percentile <= 40)
348
+ return { side: "low", strength: 1 };
349
+ return null;
350
+ }
351
+ export const dataTableFamilyRecipe = {
352
+ /** Heat background alpha per strength, over the high/low base colors. */
353
+ heatAlpha: { 1: 0.14, 2: 0.26, 3: 0.42 },
354
+ heat: { high: themeColor("danger"), low: accentColor("info") },
355
+ tone: {
356
+ leader: { color: semanticColors.content.primary, fontWeight: fontWeight.bold },
357
+ positive: { color: themeColor("danger"), fontWeight: fontWeight.bold },
358
+ negative: { color: accentColor("info"), fontWeight: fontWeight.bold },
359
+ muted: { color: semanticColors.content.tertiary, fontWeight: fontWeight.regular },
360
+ },
361
+ groupRow: { background: semanticColors.surface.sunken, color: semanticColors.content.secondary, textVariant: "label" },
362
+ /** Indent per sub-row depth level (substitutes under a starter, players under a team). */
363
+ depthIndent: spacing.md,
364
+ headerBand: { color: semanticColors.content.secondary, borderBottom: semanticColors.border.subtle },
365
+ };
366
+ /**
367
+ * Period columns are padded to `minPeriods` (9 innings) and extend for extra innings; totals follow.
368
+ * The current period (live game) is reported so renderers can highlight it.
369
+ */
370
+ export function resolveLineScore(teams, options) {
371
+ if (teams.length < 2)
372
+ throw new TypeError("LineScore needs at least two teams");
373
+ const ids = new Set();
374
+ for (const team of teams) {
375
+ assertNonEmpty(team.id, "line score team id");
376
+ if (ids.has(team.id))
377
+ throw new TypeError(`Duplicate LineScore team id: ${team.id}`);
378
+ ids.add(team.id);
379
+ }
380
+ const played = Math.max(...teams.map((team) => team.periods.length));
381
+ const count = Math.max(options.minPeriods ?? 9, played);
382
+ const columns = Array.from({ length: count }, (_, i) => ({ id: `p${i + 1}`, header: String(i + 1), kind: "period" }));
383
+ for (const total of options.totals)
384
+ columns.push({ id: `t-${total}`, header: total, kind: "total" });
385
+ const runs = options.totals[0];
386
+ let leaderId = null;
387
+ if (runs) {
388
+ const scores = teams.map((team) => ({ id: team.id, value: team.totals[runs] ?? null }));
389
+ const best = Math.max(...scores.map((score) => score.value ?? -Infinity));
390
+ const leaders = scores.filter((score) => score.value === best && Number.isFinite(best));
391
+ leaderId = leaders.length === 1 ? leaders[0].id : null;
392
+ }
393
+ const current = options.currentPeriod ?? null;
394
+ return { columns, currentPeriod: current !== null && current >= 1 && current <= count ? current : null, leaderId };
395
+ }
396
+ export function formatLineScoreCell(value) {
397
+ return value === null || value === undefined ? "" : String(value);
398
+ }
399
+ /**
400
+ * Square cross table (team × team head-to-head). Rows and columns share one id list; the diagonal is
401
+ * a self cell and renders blank. `getCell(row, column)` returns null for no record.
402
+ */
403
+ export function resolveMatrix(ids, getCell) {
404
+ if (new Set(ids).size !== ids.length)
405
+ throw new TypeError("Matrix ids must be unique");
406
+ return ids.map((row) => ids.map((column) => (row === column ? "self" : getCell(row, column))));
407
+ }
408
+ /** Which side wins a row (null on ties/missing), and each side's bar share of the pair (0–1). */
409
+ export function resolveComparisonRow(row) {
410
+ const [a, b] = row.values;
411
+ if (a === null || b === null || !Number.isFinite(a) || !Number.isFinite(b))
412
+ return { winner: null, shares: [a === null ? 0 : 0.5, b === null ? 0 : 0.5] };
413
+ const winner = a === b ? null : (row.lowerIsBetter ? a < b : a > b) ? 0 : 1;
414
+ // Lower-is-better rows invert the magnitudes so the better side still draws the longer bar.
415
+ const left = Math.abs(row.lowerIsBetter ? b : a), right = Math.abs(row.lowerIsBetter ? a : b), sum = left + right;
416
+ return { winner, shares: sum === 0 ? [0.5, 0.5] : [left / sum, right / sum] };
417
+ }
182
418
  //# sourceMappingURL=data-table.js.map