@mintplayer/web-components 2.18.0 → 2.19.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.
@@ -1,4 +1,4 @@
1
- import { D as s, M as e, c as o, d as A, s as L } from "../chunks/mp-datatable-CEpSxlkd.mjs";
1
+ import { D as s, M as e, c as o, d as A, s as L } from "../chunks/mp-datatable-BeKunRfd.mjs";
2
2
  export {
3
3
  s as DEFAULT_DATATABLE_LABELS,
4
4
  e as MpDatatable,
@@ -9,3 +9,25 @@ export declare const KEYBOARD_RESIZE_STEP = 10;
9
9
  * floor.
10
10
  */
11
11
  export declare function resizedColumnWidth(startWidth: number, delta: number): number;
12
+ /**
13
+ * The furthest measured columns are scaled down to keep fitting a narrowing
14
+ * scroller. Past it they keep this share and the table scrolls: crushing them
15
+ * to the floor would overflow anyway (measured: a desktop table narrowed to
16
+ * 254px clamps to 40px columns and still overflows), with every cell an
17
+ * ellipsis on the way there.
18
+ */
19
+ export declare const MIN_REFIT_SCALE = 0.75;
20
+ /**
21
+ * Movement, in px, below which a press on a resize handle is a TAP: it opens
22
+ * the resize options instead of resizing. Without it a finger, which never
23
+ * lands perfectly still, would nudge the column on every tap.
24
+ */
25
+ export declare const RESIZE_TAP_SLOP = 4;
26
+ /**
27
+ * The width that shows the widest of `contentWidths` (each already including
28
+ * its cell's padding) without an ellipsis. Rounded UP, unlike the initial
29
+ * measurement: here a sub-pixel short would clip the very content the user
30
+ * asked to see, and the column was explicitly sized, so overflowing the
31
+ * scroller is the requested outcome rather than a phantom scrollbar.
32
+ */
33
+ export declare function fittedColumnWidth(contentWidths: readonly number[]): number | null;
@@ -66,7 +66,10 @@ export interface SelectionChangeEventDetail<T = unknown> {
66
66
  * - Row events: `mp-datatable-row-click`, `mp-datatable-row-dblclick`,
67
67
  * `mp-datatable-row-contextmenu` — all carry `RowEventDetail`.
68
68
  * - Pagination footer when `pagination` enabled.
69
- * - Column resize via a 6px handle at the right edge of each header.
69
+ * - Column resize via a handle at the right edge of each header (24px hit
70
+ * area, 40px on coarse pointers): drag, Left/Right arrows, or tap / Enter
71
+ * for an options dialog (narrower, wider, fit, reset). Per column via
72
+ * `DatatableColumnDef.resizable`, table-wide via `resizable-columns`.
70
73
  */
71
74
  export declare class MpDatatable extends LitElement {
72
75
  /**
@@ -153,8 +156,22 @@ export declare class MpDatatable extends LitElement {
153
156
  */
154
157
  private warnPositionalKeyOnce;
155
158
  private _columnWidths;
159
+ /** Widths the measure pass chose, kept so Reset can return to them. */
160
+ private _measuredWidths;
161
+ /** Columns the user sized (drag, keys, the options dialog): never re-fitted. */
162
+ private _userWidths;
163
+ /**
164
+ * Text each column's header actually renders, read from a Node a
165
+ * headerRenderer returned. It names the column in generated strings when the
166
+ * consumer set no label, so a header template that says Artist is not
167
+ * announced by its internal key. See columnLabel().
168
+ */
169
+ private _derivedLabels;
156
170
  /** Becomes `true` after the first measure-once pass locks column widths. Drives the `.measured` class on the table (→ `table-layout: fixed`). */
157
171
  private _hasMeasuredInitial;
172
+ /** Whether the natural column widths fitted the scroller at measurement; see refitMeasuredWidths. */
173
+ private _measuredFit;
174
+ private _refitFrame;
158
175
  private _loading;
159
176
  private _emptyMessage;
160
177
  private _pagination;
@@ -171,6 +188,15 @@ export declare class MpDatatable extends LitElement {
171
188
  private _virtualRange;
172
189
  private _scrollElement;
173
190
  private _resizeObserver;
191
+ /**
192
+ * Re-renders when a header's TEXT changes in place. A wrapper's header view
193
+ * (Angular's EmbeddedViewRef) updates its own nodes — a language switch, say
194
+ * — without any property of this element changing, so without this the
195
+ * names derived from header text would go stale until some unrelated render.
196
+ * A render that changes nothing mutates nothing, so it cannot loop.
197
+ */
198
+ private _headerObserver;
199
+ private _observedThead;
174
200
  private _scrollListener;
175
201
  private _viewportHeight;
176
202
  /** Name of the column whose filter panel is open, or null. Only ever one. */
@@ -448,6 +474,24 @@ export declare class MpDatatable extends LitElement {
448
474
  * authoritative and overflowing content clips with ellipsis.
449
475
  */
450
476
  private maybeMeasureInitialColumnWidths;
477
+ private scheduleRefit;
478
+ /**
479
+ * Keeps columns that fitted fitting when the scroller narrows: when it is
480
+ * resized, or when a classic vertical scrollbar appears after the
481
+ * measurement (13-15px, measured on Windows Chromium and Firefox), which
482
+ * otherwise brings back the very horizontal scrollbar #426 removed.
483
+ *
484
+ * Only MEASURED widths move. A user-set width, an explicit `col.width` and
485
+ * the fixed checkbox/chevron cells keep theirs, and their total is taken off
486
+ * the room first. Scaling is always from the measured base, never from the
487
+ * previous result, which would ratchet down a pixel per pass through the
488
+ * floor; that also restores the exact widths when the scroller widens again.
489
+ *
490
+ * It only ever shrinks (fixed layout spreads any surplus by itself), and
491
+ * never below MIN_REFIT_SCALE: past that the columns would crush into
492
+ * ellipses, and content that no longer fits is meant to scroll instead.
493
+ */
494
+ private refitMeasuredWidths;
451
495
  private measureColumnWidth;
452
496
  disconnectedCallback(): void;
453
497
  private refreshVirtualRange;
@@ -626,6 +670,32 @@ export declare class MpDatatable extends LitElement {
626
670
  */
627
671
  private renderFilterRow;
628
672
  private renderFilterCell;
673
+ /**
674
+ * The column's name in every generated string: the consumer's label, else the
675
+ * text its header renders, else its key. The header-text step is what makes a
676
+ * wrapper that only passes a header template (Angular) correct with no extra
677
+ * input, and that text is already localized because the consumer rendered it.
678
+ */
679
+ private columnLabel;
680
+ /**
681
+ * Caches the text of a Node header. Read during render, before lit moves a
682
+ * fragment's children into the cell, and only a non-empty text replaces the
683
+ * cache: a renderer that hands back the same, already-emptied fragment on a
684
+ * later render must not erase the name it had.
685
+ */
686
+ private deriveHeaderLabel;
687
+ /** Idempotent; re-attaches if the thead was replaced or the element reconnected. */
688
+ private observeHeaderText;
689
+ /**
690
+ * Whether a header now shows different text than the name derived from it.
691
+ * The gate that keeps the observer from looping: a renderer that returns
692
+ * fresh nodes on every call (a new fragment each time, the React/Vue
693
+ * render-prop shape) mutates the header on EVERY render, but its text stays
694
+ * the same, so only a real change re-renders.
695
+ */
696
+ private headerTextChanged;
697
+ /** The column's own flag wins in either direction; absent, the table-wide one. */
698
+ private isColumnResizable;
629
699
  private renderHeader;
630
700
  private renderRow;
631
701
  /**
@@ -816,13 +886,83 @@ export declare class MpDatatable extends LitElement {
816
886
  private resolveRows;
817
887
  private gotoPage;
818
888
  private resizeState;
889
+ /** The column whose resize options dialog is open, or null. */
890
+ private _openResizeColumn;
891
+ private _resizeHintAnnounced;
892
+ /**
893
+ * Every resize path ends here. A user-set width is never re-fitted when the
894
+ * scroller resizes (see `refitMeasuredWidths`): the user chose it.
895
+ */
896
+ private setUserColumnWidth;
897
+ private currentColumnWidth;
898
+ /**
899
+ * Width of the cells no column owns (selection checkbox, tree chevron) while
900
+ * the widths are frozen; null while the table fills its container.
901
+ */
902
+ private _frozenExtraWidth;
903
+ /**
904
+ * Before the first user resize, pins every column at the width it RENDERS
905
+ * and gives the table that total as an explicit width.
906
+ *
907
+ * Without this the resized edge does not follow the pointer. The table is
908
+ * 100% wide with fixed layout, so whenever the pins add up to less than the
909
+ * container the slack is shared out over every column, the one being
910
+ * resized included: widening it shrinks its share (it grows slower than the
911
+ * pointer), narrowing it grows its share (it hardly moves). With an explicit
912
+ * width equal to the sum there is no slack to share, so a column is exactly
913
+ * as wide as its pin and the edge tracks the pointer 1:1. Narrowing then
914
+ * leaves room on the right, as in a spreadsheet, instead of refusing to move.
915
+ *
916
+ * Idempotent. Unfrozen again when the last user width is reset.
917
+ */
918
+ private freezeColumnWidths;
919
+ /** Widths at the moment of freezing: what Reset returns a column to while frozen. */
920
+ private _frozenWidths;
921
+ private frozenTableWidth;
922
+ private headerCell;
923
+ private resizeHandle;
819
924
  /**
820
925
  * Keyboard column resize — the same ±px model as the pointer path, same 40px
821
- * floor. The handle is a focusable role="separator"; without this it was the
822
- * audit's pointer-only finding for the datatable.
926
+ * floor. Enter opens the same options dialog a tap does, so every pointer
927
+ * path has a keyboard twin and the other way round.
823
928
  */
824
929
  private onResizeHandleKeydown;
930
+ private stepColumnWidth;
931
+ /** The keymap, spoken once per element: a separator gives no hint of Enter on its own. */
932
+ private onResizeHandleFocus;
933
+ /**
934
+ * A press on a handle is a drag only once it moves past `RESIZE_TAP_SLOP`;
935
+ * released before that it is a tap, and a tap opens the options dialog. That
936
+ * dialog is the single-pointer alternative WCAG 2.5.7 requires for the drag,
937
+ * and the arrow keys do not count as one.
938
+ *
939
+ * The gesture itself is protected by `touch-action: none` on the handle, not
940
+ * by anything here: `preventDefault()` on pointerdown does not stop a touch
941
+ * pan, and a pan the browser claims ends in `pointercancel`.
942
+ */
825
943
  private startColumnResize;
826
944
  private onColumnResizeMove;
827
945
  private onColumnResizeEnd;
946
+ private readonly resizeOverlay;
947
+ private openResizePanel;
948
+ /**
949
+ * The resize options dialog: step narrower, step wider, fit, reset. Rendered
950
+ * into the overlay pane with a render() of its own, like the filter panel,
951
+ * and for the same reasons — including being a NON-modal dialog in ARIA
952
+ * terms (#416): it is anchored, dismissible and does not own the page.
953
+ *
954
+ * The readout is an `output`, whose implicit status role announces each new
955
+ * width: the only feedback a screen reader gets for a step, because the
956
+ * buttons keep focus and the separator's valuenow is not where focus is.
957
+ */
958
+ private renderResizePanel;
959
+ /**
960
+ * Sizes the column to its widest RENDERED content: header plus the body rows
961
+ * currently in the DOM (one window, in virtual mode). Read with a Range,
962
+ * because a clipped cell's own box reports the column width, not its
963
+ * content's, while a range over its contents measures the text itself.
964
+ */
965
+ private fitColumnWidth;
966
+ /** Back to the width the table chose: the measured one, else the column's own. */
967
+ private resetColumnWidth;
828
968
  }
@@ -41,10 +41,22 @@ export type FilterRenderer<T = unknown> = (column: DatatableColumnDef<T>, contex
41
41
  export interface DatatableColumnDef<T = unknown> {
42
42
  /** Data property name + sort key. */
43
43
  name: string;
44
- /** Header label (rendered when no `headerRenderer` is provided). */
44
+ /**
45
+ * Header label (rendered when no `headerRenderer` is provided) and the
46
+ * column's name in every generated accessible string: resize handle, filter
47
+ * trigger and panel, sort and filter announcements. When absent, those
48
+ * strings use the text a `headerRenderer` node renders, and only then
49
+ * `name`. Set it when the header is icon-only or should be spoken differently.
50
+ */
45
51
  label?: string;
46
52
  /** Whether the header is clickable to toggle sort. Default `true`. */
47
53
  sortable?: boolean;
54
+ /**
55
+ * Whether this column offers a resize handle. Absent follows the table-wide
56
+ * `resizableColumns`; a set value wins over it in either direction, so one
57
+ * column can be resizable in a table that is not, and vice versa.
58
+ */
59
+ resizable?: boolean;
48
60
  /** Initial pinned width in px. Resizable columns can override at runtime. */
49
61
  width?: number;
50
62
  /** Cell renderer; defaults to `String(row[column.name])`. */
@@ -21,6 +21,23 @@ export interface DatatableLabels {
21
21
  loading: string;
22
22
  rowsPerPage: string;
23
23
  resizeColumn: (column: string) => string;
24
+ /**
25
+ * Announced once, the first time a resize handle takes focus: how to resize
26
+ * without dragging.
27
+ */
28
+ resizeColumnHint: string;
29
+ /** Name of the resize options dialog a tap (or Enter) on a handle opens. */
30
+ resizeColumnOptions: (column: string) => string;
31
+ /** The dialog's step-down button; its visible glyph is a minus sign. */
32
+ narrowerColumn: (column: string) => string;
33
+ /** The dialog's step-up button; its visible glyph is a plus sign. */
34
+ widerColumn: (column: string) => string;
35
+ /** The dialog's current-width readout. */
36
+ columnWidth: (px: number) => string;
37
+ /** The dialog's button that sizes the column to its widest rendered content. */
38
+ fitColumn: string;
39
+ /** The dialog's button that drops a resized width again. */
40
+ resetColumn: string;
24
41
  /** A row checkbox's name when the row yields no text (see `selectRowNamed`). */
25
42
  selectRow: (rowNumber: number) => string;
26
43
  /**
@@ -9,7 +9,7 @@ import { createRef as C, ref as k } from "lit/directives/ref.js";
9
9
  import { styleMap as E } from "lit/directives/style-map.js";
10
10
  import "../chunks/mp-splitter-DLehrw3Y.mjs";
11
11
  import "../chunks/mp-treeview-CaMTDrvY.mjs";
12
- import "../chunks/mp-datatable-CEpSxlkd.mjs";
12
+ import "../chunks/mp-datatable-BeKunRfd.mjs";
13
13
  const M = _(`:host {
14
14
  display: flex;
15
15
  flex-direction: column;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/web-components",
3
- "version": "2.18.0",
3
+ "version": "2.19.0",
4
4
  "description": "Framework-agnostic Lit web components for the @mintplayer/bootstrap design system. Consumed by @mintplayer/ng-bootstrap, @mintplayer/react-bootstrap, and @mintplayer/vue-bootstrap.",
5
5
  "license": "MIT",
6
6
  "repository": {