@lit-material/data-table 0.0.1 → 0.0.2
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.
- package/README.md +86 -8
- package/dist/data-table-cell-styles.d.ts.map +1 -1
- package/dist/data-table-cell-styles.js +46 -0
- package/dist/data-table-cell-styles.js.map +1 -1
- package/dist/data-table-cell.d.ts +25 -0
- package/dist/data-table-cell.d.ts.map +1 -1
- package/dist/data-table-cell.js +79 -1
- package/dist/data-table-cell.js.map +1 -1
- package/dist/data-table-pagination-styles.d.ts +2 -0
- package/dist/data-table-pagination-styles.d.ts.map +1 -0
- package/dist/data-table-pagination-styles.js +83 -0
- package/dist/data-table-pagination-styles.js.map +1 -0
- package/dist/data-table-pagination.d.ts +42 -0
- package/dist/data-table-pagination.d.ts.map +1 -0
- package/dist/data-table-pagination.js +106 -0
- package/dist/data-table-pagination.js.map +1 -0
- package/dist/data-table-row-styles.d.ts.map +1 -1
- package/dist/data-table-row-styles.js +6 -0
- package/dist/data-table-row-styles.js.map +1 -1
- package/dist/data-table-row.d.ts +10 -0
- package/dist/data-table-row.d.ts.map +1 -1
- package/dist/data-table-row.js +13 -0
- package/dist/data-table-row.js.map +1 -1
- package/dist/data-table-styles.d.ts.map +1 -1
- package/dist/data-table-styles.js +19 -0
- package/dist/data-table-styles.js.map +1 -1
- package/dist/data-table.d.ts +45 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +139 -12
- package/dist/data-table.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -63,12 +63,18 @@ column alignment.
|
|
|
63
63
|
|
|
64
64
|
### `lit-material-data-table`
|
|
65
65
|
|
|
66
|
-
| Property | Attribute
|
|
66
|
+
| Property | Attribute | Type | Default |
|
|
67
67
|
| ---------------- | ------------------ | ----------------------------------------- | -------------- |
|
|
68
|
-
| `sortKey` | `sort-key` | `string \| undefined` | `undefined`
|
|
69
|
-
| `sortDirection` | `sort-direction` | `"none" \| "ascending" \| "descending"` | `"ascending"`
|
|
68
|
+
| `sortKey` | `sort-key` | `string \| undefined` | `undefined` |
|
|
69
|
+
| `sortDirection` | `sort-direction` | `"none" \| "ascending" \| "descending"` | `"ascending"` |
|
|
70
|
+
| `items` | — | `readonly unknown[]` | `[]` |
|
|
71
|
+
| `rowRenderer` | — | `(item, index) => unknown` \| `undefined` | `undefined` |
|
|
72
|
+
| `rowKey` | — | `(item, index) => string \| number` \| `undefined` | `undefined` |
|
|
73
|
+
| `rowHeight` | `row-height` | `number` | `44` |
|
|
74
|
+
| `viewportHeight` | `viewport-height` | `number` | `400` |
|
|
75
|
+
| `overscan` | `overscan` | `number` | `4` |
|
|
70
76
|
|
|
71
|
-
Slot: default (`lit-material-data-table-row` elements).
|
|
77
|
+
Slot: default (`lit-material-data-table-row` elements — in virtualized mode, the header row only).
|
|
72
78
|
|
|
73
79
|
This component owns UI *state* (which column is sorted which way, which rows are checked) and
|
|
74
80
|
*notifies* you of it via events — it never reorders rows or owns your data. Activating a sortable
|
|
@@ -89,16 +95,51 @@ values.
|
|
|
89
95
|
Fires `sort-change` (`detail: { sortKey, sortDirection }`) and `selection-change`
|
|
90
96
|
(`detail: { selected: string[] }`).
|
|
91
97
|
|
|
98
|
+
#### Row virtualization
|
|
99
|
+
|
|
100
|
+
Set `.items` (your full dataset) and `.rowRenderer` (a function returning one body row per item)
|
|
101
|
+
to switch on fixed-height virtualization — only the rows within (or near) the visible scroll window
|
|
102
|
+
are ever mounted, however large `items` is:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
table.items = people; // e.g. 50,000 rows
|
|
106
|
+
table.rowRenderer = (person, index) => html`
|
|
107
|
+
<lit-material-data-table-row flex data-row-id=${person.id}>
|
|
108
|
+
<lit-material-data-table-cell flex width="200px">${person.name}</lit-material-data-table-cell>
|
|
109
|
+
<lit-material-data-table-cell flex width="80px" numeric>${person.age}</lit-material-data-table-cell>
|
|
110
|
+
</lit-material-data-table-row>
|
|
111
|
+
`;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
This is the one thing here that isn't purely headless — true virtualization requires knowing the
|
|
115
|
+
full item count up front, which "you slot real rows" (the table's normal mode) can't provide.
|
|
116
|
+
Notes:
|
|
117
|
+
|
|
118
|
+
- **Slot only the header row.** Body rows come from `rowRenderer`; anything else slotted alongside
|
|
119
|
+
it is ignored by the virtualized viewport (though still slotted, so don't put extra body rows
|
|
120
|
+
there).
|
|
121
|
+
- **Both the header row and every `rowRenderer` row need `flex`** (see
|
|
122
|
+
`lit-material-data-table-row`'s own docs) — virtualized rows are positioned with `transform`,
|
|
123
|
+
which the table's normal `display: table` column-alignment trick can't do, so virtualized mode
|
|
124
|
+
uses explicit flexbox widths (`lit-material-data-table-cell`'s `width` property) instead. Keep
|
|
125
|
+
the header's cell widths and the body rows' cell widths in sync yourself.
|
|
126
|
+
- **Row height is fixed** — set `row-height` to whatever your actual row content needs; there's no
|
|
127
|
+
per-row measurement.
|
|
128
|
+
- Sorting and row-selection delegation both keep working on virtualized rows exactly as they do on
|
|
129
|
+
slotted ones.
|
|
130
|
+
|
|
92
131
|
### `lit-material-data-table-row`
|
|
93
132
|
|
|
94
133
|
| Property | Attribute | Type | Default |
|
|
95
134
|
| ---------- | ---------- | --------- | ------- |
|
|
96
135
|
| `header` | `header` | `boolean` | `false` |
|
|
97
136
|
| `selected` | `selected` | `boolean` | `false` |
|
|
137
|
+
| `flex` | `flex` | `boolean` | `false` |
|
|
98
138
|
|
|
99
139
|
Slot: default (`lit-material-data-table-cell` elements). Set `header` on the row made up of
|
|
100
140
|
header cells (typically the first). `selected` is normally managed by the parent table from a
|
|
101
|
-
`data-row-select` checkbox's checked state, not set directly.
|
|
141
|
+
`data-row-select` checkbox's checked state, not set directly. Set `flex` to switch the row from
|
|
142
|
+
`display: table-row` to `display: flex` — only needed for virtualized rows (see above).
|
|
102
143
|
|
|
103
144
|
### `lit-material-data-table-cell`
|
|
104
145
|
|
|
@@ -108,6 +149,10 @@ header cells (typically the first). `selected` is normally managed by the parent
|
|
|
108
149
|
| `numeric` | `numeric` | `boolean` | `false` |
|
|
109
150
|
| `sortKey` | `sort-key` | `string \| undefined` | `undefined` |
|
|
110
151
|
| `sortDirection` | `sort-direction` | `"none" \| "ascending" \| "descending"` | `"none"` |
|
|
152
|
+
| `resizable` | `resizable` | `boolean` | `false` |
|
|
153
|
+
| `minWidth` | `min-width` | `number` | `60` |
|
|
154
|
+
| `flex` | `flex` | `boolean` | `false` |
|
|
155
|
+
| `width` | `width` | `string \| undefined` | `undefined` |
|
|
111
156
|
|
|
112
157
|
Slot: default (the cell's content). `numeric` right-aligns content (and applies tabular figures)
|
|
113
158
|
— use it for numeric columns per the MD3 spec. Set `sort-key` on a `header` cell to make it
|
|
@@ -115,6 +160,14 @@ sortable: that wraps its content in a real `<button>` (the ARIA APG pattern for
|
|
|
115
160
|
headers is an interactive element *inside* the columnheader cell, not the cell itself carrying the
|
|
116
161
|
interaction). `sortDirection` is kept in sync by the parent table, not set directly.
|
|
117
162
|
|
|
163
|
+
Set `resizable` on a `header` cell to add a drag handle at its trailing edge; dragging it fires
|
|
164
|
+
`column-resize` (`detail: { width }`, pixels) on the cell, which `lit-material-data-table` listens
|
|
165
|
+
for and applies to every cell in that column (not just the header one — see the table's own docs
|
|
166
|
+
for why). `min-width` floors how narrow a drag can make it. `flex`/`width` are for virtualized mode
|
|
167
|
+
— see the table's docs above.
|
|
168
|
+
|
|
169
|
+
Fires `column-resize` (`detail: { width: number }`) while dragging a `resizable` cell's handle.
|
|
170
|
+
|
|
118
171
|
## Accessibility
|
|
119
172
|
|
|
120
173
|
Built entirely on ARIA `table`/`row`/`columnheader`/`cell` roles (set automatically — the
|
|
@@ -122,11 +175,36 @@ underlying elements aren't real `<table>`/`<tr>`/`<th>`/`<td>`, see above for wh
|
|
|
122
175
|
requiring you to wire them up. Row-select and select-all checkboxes need their own `aria-label` (a
|
|
123
176
|
bare checkbox has no accessible name of its own) — see the usage example above.
|
|
124
177
|
|
|
178
|
+
## Pagination
|
|
179
|
+
|
|
180
|
+
`lit-material-data-table-pagination` is a standalone footer control, not something the table
|
|
181
|
+
renders itself — pagination is exactly as data-shaped a concern as sorting/selection, and the
|
|
182
|
+
table never owns your data (see above). Feed it a total row count and it works out page count,
|
|
183
|
+
range, and button disabled-state itself:
|
|
184
|
+
|
|
185
|
+
```html
|
|
186
|
+
<lit-material-data-table-pagination id="pager" total="97" page-size="10"></lit-material-data-table-pagination>
|
|
187
|
+
<script type="module">
|
|
188
|
+
document.querySelector("#pager").addEventListener("page-change", (e) => {
|
|
189
|
+
console.log(e.detail); // { page, pageSize } — re-slice or re-fetch your rows in response
|
|
190
|
+
});
|
|
191
|
+
</script>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
| Property | Attribute | Type | Default |
|
|
195
|
+
| ------------------ | ------------ | ----------------------- | -------------- |
|
|
196
|
+
| `page` | `page` | `number` | `0` (0-based) |
|
|
197
|
+
| `pageSize` | `page-size` | `number` | `10` |
|
|
198
|
+
| `total` | `total` | `number` | `0` |
|
|
199
|
+
| `pageSizeOptions` | — | `readonly number[]` | `[10, 25, 50]` |
|
|
200
|
+
|
|
201
|
+
Fires `page-change` (`detail: { page, pageSize }`) when a nav button is clicked or the page-size
|
|
202
|
+
select changes (which also resets `page` back to `0`).
|
|
203
|
+
|
|
125
204
|
## Scope
|
|
126
205
|
|
|
127
|
-
Deliberately out of scope
|
|
128
|
-
|
|
129
|
-
silently missing pieces.
|
|
206
|
+
Deliberately out of scope: column reordering and multi-column sort. Both reasonable follow-ups,
|
|
207
|
+
not silently missing pieces.
|
|
130
208
|
|
|
131
209
|
## License
|
|
132
210
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-cell-styles.d.ts","sourceRoot":"","sources":["../src/data-table-cell-styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"data-table-cell-styles.d.ts","sourceRoot":"","sources":["../src/data-table-cell-styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAoHlB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { css } from "lit";
|
|
|
2
2
|
export const styles = css `
|
|
3
3
|
:host {
|
|
4
4
|
display: table-cell;
|
|
5
|
+
position: relative;
|
|
5
6
|
box-sizing: border-box;
|
|
6
7
|
padding: 12px 16px;
|
|
7
8
|
vertical-align: middle;
|
|
@@ -16,6 +17,12 @@ export const styles = css `
|
|
|
16
17
|
font-variant-numeric: tabular-nums;
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
:host([flex]) {
|
|
21
|
+
display: block;
|
|
22
|
+
flex: 0 0 auto;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
:host([header]) {
|
|
20
27
|
color: var(--md-sys-color-on-surface-variant, #49454f);
|
|
21
28
|
font-family: var(--md-sys-typescale-label-large-font, Roboto, system-ui, sans-serif);
|
|
@@ -28,6 +35,11 @@ export const styles = css `
|
|
|
28
35
|
display: inline-flex;
|
|
29
36
|
align-items: center;
|
|
30
37
|
gap: 4px;
|
|
38
|
+
max-width: 100%;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
text-overflow: ellipsis;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
vertical-align: middle;
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
:host([numeric]) .content {
|
|
@@ -69,5 +81,39 @@ export const styles = css `
|
|
|
69
81
|
:host([sort-direction="descending"]) .sort-icon {
|
|
70
82
|
opacity: 1;
|
|
71
83
|
}
|
|
84
|
+
|
|
85
|
+
.resize-handle {
|
|
86
|
+
position: absolute;
|
|
87
|
+
top: 0;
|
|
88
|
+
bottom: 0;
|
|
89
|
+
inset-inline-end: -4px;
|
|
90
|
+
width: 8px;
|
|
91
|
+
cursor: col-resize;
|
|
92
|
+
touch-action: none;
|
|
93
|
+
z-index: 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.resize-handle::after {
|
|
97
|
+
content: "";
|
|
98
|
+
position: absolute;
|
|
99
|
+
top: 0;
|
|
100
|
+
bottom: 0;
|
|
101
|
+
inset-inline-start: 3px;
|
|
102
|
+
width: 2px;
|
|
103
|
+
background-color: var(--md-sys-color-outline-variant, #cac4d0);
|
|
104
|
+
opacity: 0;
|
|
105
|
+
transition: opacity 100ms var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.resize-handle:hover::after {
|
|
109
|
+
opacity: 1;
|
|
110
|
+
background-color: var(--md-sys-color-primary, #6750a4);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@media (prefers-reduced-motion: reduce) {
|
|
114
|
+
.resize-handle::after {
|
|
115
|
+
transition: none;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
72
118
|
`;
|
|
73
119
|
//# sourceMappingURL=data-table-cell-styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-cell-styles.js","sourceRoot":"","sources":["../src/data-table-cell-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"data-table-cell-styles.js","sourceRoot":"","sources":["../src/data-table-cell-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoHxB,CAAC"}
|
|
@@ -12,6 +12,14 @@ export type SortDirection = "none" | "ascending" | "descending";
|
|
|
12
12
|
* table on click; `sort-direction` is then kept in sync by the table, not
|
|
13
13
|
* set directly.
|
|
14
14
|
*
|
|
15
|
+
* Set `resizable` on a header cell to add a drag handle at its trailing
|
|
16
|
+
* edge. Dragging it dispatches a bubbling, composed `column-resize` event
|
|
17
|
+
* (`detail: { width }`, in pixels) — the cell only reports the drag, it
|
|
18
|
+
* never resizes itself or its column-mates; `lit-material-data-table`
|
|
19
|
+
* listens for that event and applies the resulting width to every cell in
|
|
20
|
+
* the same column (see its own class docs for why that has to happen
|
|
21
|
+
* one level up).
|
|
22
|
+
*
|
|
15
23
|
* `:host` uses `display: table-cell` (not a real `<td>`) so cells still
|
|
16
24
|
* align into columns via the browser's native table layout algorithm
|
|
17
25
|
* without needing an actual `<table>` element — see `lit-material-data-table`
|
|
@@ -26,6 +34,9 @@ export type SortDirection = "none" | "ascending" | "descending";
|
|
|
26
34
|
*
|
|
27
35
|
* @csspart sort-button - The button wrapping content, for sortable header cells.
|
|
28
36
|
* @csspart sort-icon - The ascending/descending indicator.
|
|
37
|
+
* @csspart resize-handle - The drag handle for a `resizable` header cell.
|
|
38
|
+
*
|
|
39
|
+
* @fires column-resize - `detail: { width }` (pixels), while dragging a `resizable` cell's handle.
|
|
29
40
|
*/
|
|
30
41
|
export declare class LitMaterialDataTableCell extends LitElement {
|
|
31
42
|
static styles: import("lit").CSSResult;
|
|
@@ -34,10 +45,24 @@ export declare class LitMaterialDataTableCell extends LitElement {
|
|
|
34
45
|
sortKey?: string;
|
|
35
46
|
/** Kept in sync by the parent table — see the class docs. Not meant to be set directly. */
|
|
36
47
|
sortDirection: SortDirection;
|
|
48
|
+
/** Adds a drag handle at the trailing edge. Only meaningful on a `header` cell. */
|
|
49
|
+
resizable: boolean;
|
|
50
|
+
/** Floor for the width this cell's handle will report while dragging. */
|
|
51
|
+
minWidth: number;
|
|
52
|
+
/** Lays the cell out with flexbox instead of `display: table-cell` — see `lit-material-data-table-row`. */
|
|
53
|
+
flex: boolean;
|
|
54
|
+
/** This cell's width in `flex` mode (any CSS `flex-basis` value, e.g. `"96px"`). Ignored otherwise. */
|
|
55
|
+
width?: string;
|
|
56
|
+
private resizeStartX;
|
|
57
|
+
private resizeStartWidth;
|
|
37
58
|
protected willUpdate(changed: Map<string, unknown>): void;
|
|
38
59
|
private get isSortable();
|
|
39
60
|
render(): import("lit").TemplateResult<1>;
|
|
40
61
|
private readonly handleSortClick;
|
|
62
|
+
private readonly handleResizePointerDown;
|
|
63
|
+
private readonly handleResizePointerMove;
|
|
64
|
+
private readonly handleResizePointerUp;
|
|
65
|
+
private dispatchResize;
|
|
41
66
|
}
|
|
42
67
|
declare global {
|
|
43
68
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-cell.d.ts","sourceRoot":"","sources":["../src/data-table-cell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;AAEhE
|
|
1
|
+
{"version":3,"file":"data-table-cell.d.ts","sourceRoot":"","sources":["../src/data-table-cell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBACa,wBAAyB,SAAQ,UAAU;IACtD,OAAgB,MAAM,0BAAU;IAEY,MAAM,UAAS;IACf,OAAO,UAAS;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACtD,2FAA2F;IACjC,aAAa,EAAE,aAAa,CAAU;IAChG,mFAAmF;IACvC,SAAS,UAAS;IAC9D,yEAAyE;IACrB,QAAQ,SAAM;IAClE,2GAA2G;IAC/D,IAAI,UAAS;IACzD,uGAAuG;IAC3F,KAAK,CAAC,EAAE,MAAM,CAAC;IAE3B,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,gBAAgB,CAAK;cAEV,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAWlE,OAAO,KAAK,UAAU,GAErB;IAEQ,MAAM;IAqBf,OAAO,CAAC,QAAQ,CAAC,eAAe,CAQ9B;IAEF,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAgBtC;IAEF,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAEtC;IAEF,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAMpC;IAEF,OAAO,CAAC,cAAc;CAQvB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,8BAA8B,EAAE,wBAAwB,CAAC;KAC1D;CACF"}
|
package/dist/data-table-cell.js
CHANGED
|
@@ -19,6 +19,14 @@ import { styles } from "./data-table-cell-styles.js";
|
|
|
19
19
|
* table on click; `sort-direction` is then kept in sync by the table, not
|
|
20
20
|
* set directly.
|
|
21
21
|
*
|
|
22
|
+
* Set `resizable` on a header cell to add a drag handle at its trailing
|
|
23
|
+
* edge. Dragging it dispatches a bubbling, composed `column-resize` event
|
|
24
|
+
* (`detail: { width }`, in pixels) — the cell only reports the drag, it
|
|
25
|
+
* never resizes itself or its column-mates; `lit-material-data-table`
|
|
26
|
+
* listens for that event and applies the resulting width to every cell in
|
|
27
|
+
* the same column (see its own class docs for why that has to happen
|
|
28
|
+
* one level up).
|
|
29
|
+
*
|
|
22
30
|
* `:host` uses `display: table-cell` (not a real `<td>`) so cells still
|
|
23
31
|
* align into columns via the browser's native table layout algorithm
|
|
24
32
|
* without needing an actual `<table>` element — see `lit-material-data-table`
|
|
@@ -33,6 +41,9 @@ import { styles } from "./data-table-cell-styles.js";
|
|
|
33
41
|
*
|
|
34
42
|
* @csspart sort-button - The button wrapping content, for sortable header cells.
|
|
35
43
|
* @csspart sort-icon - The ascending/descending indicator.
|
|
44
|
+
* @csspart resize-handle - The drag handle for a `resizable` header cell.
|
|
45
|
+
*
|
|
46
|
+
* @fires column-resize - `detail: { width }` (pixels), while dragging a `resizable` cell's handle.
|
|
36
47
|
*/
|
|
37
48
|
let LitMaterialDataTableCell = class LitMaterialDataTableCell extends LitElement {
|
|
38
49
|
constructor() {
|
|
@@ -41,6 +52,14 @@ let LitMaterialDataTableCell = class LitMaterialDataTableCell extends LitElement
|
|
|
41
52
|
this.numeric = false;
|
|
42
53
|
/** Kept in sync by the parent table — see the class docs. Not meant to be set directly. */
|
|
43
54
|
this.sortDirection = "none";
|
|
55
|
+
/** Adds a drag handle at the trailing edge. Only meaningful on a `header` cell. */
|
|
56
|
+
this.resizable = false;
|
|
57
|
+
/** Floor for the width this cell's handle will report while dragging. */
|
|
58
|
+
this.minWidth = 60;
|
|
59
|
+
/** Lays the cell out with flexbox instead of `display: table-cell` — see `lit-material-data-table-row`. */
|
|
60
|
+
this.flex = false;
|
|
61
|
+
this.resizeStartX = 0;
|
|
62
|
+
this.resizeStartWidth = 0;
|
|
44
63
|
this.handleSortClick = () => {
|
|
45
64
|
this.dispatchEvent(new CustomEvent("sort-request", {
|
|
46
65
|
bubbles: true,
|
|
@@ -48,17 +67,57 @@ let LitMaterialDataTableCell = class LitMaterialDataTableCell extends LitElement
|
|
|
48
67
|
detail: { sortKey: this.sortKey },
|
|
49
68
|
}));
|
|
50
69
|
};
|
|
70
|
+
this.handleResizePointerDown = (event) => {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
const handle = event.currentTarget;
|
|
73
|
+
// Pointer capture keeps drag events flowing to the handle even once the cursor leaves its
|
|
74
|
+
// small hit area mid-drag; synthetic pointer events (as in tests) don't register as an
|
|
75
|
+
// "active" pointer the platform will accept, so degrade to plain bubbling instead of throwing.
|
|
76
|
+
try {
|
|
77
|
+
handle.setPointerCapture(event.pointerId);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// no-op — see comment above.
|
|
81
|
+
}
|
|
82
|
+
this.resizeStartX = event.clientX;
|
|
83
|
+
this.resizeStartWidth = this.getBoundingClientRect().width;
|
|
84
|
+
handle.addEventListener("pointermove", this.handleResizePointerMove);
|
|
85
|
+
handle.addEventListener("pointerup", this.handleResizePointerUp);
|
|
86
|
+
handle.addEventListener("pointercancel", this.handleResizePointerUp);
|
|
87
|
+
};
|
|
88
|
+
this.handleResizePointerMove = (event) => {
|
|
89
|
+
this.dispatchResize(event.clientX);
|
|
90
|
+
};
|
|
91
|
+
this.handleResizePointerUp = (event) => {
|
|
92
|
+
this.dispatchResize(event.clientX);
|
|
93
|
+
const handle = event.currentTarget;
|
|
94
|
+
handle.removeEventListener("pointermove", this.handleResizePointerMove);
|
|
95
|
+
handle.removeEventListener("pointerup", this.handleResizePointerUp);
|
|
96
|
+
handle.removeEventListener("pointercancel", this.handleResizePointerUp);
|
|
97
|
+
};
|
|
51
98
|
}
|
|
52
99
|
static { this.styles = styles; }
|
|
53
100
|
willUpdate(changed) {
|
|
54
101
|
if (changed.has("header")) {
|
|
55
102
|
this.setAttribute("role", this.header ? "columnheader" : "cell");
|
|
56
103
|
}
|
|
104
|
+
// @lit-labs/ssr's light-DOM shim doesn't implement `style` on the host — skip rather than
|
|
105
|
+
// throw, there's no layout to compute server-side anyway.
|
|
106
|
+
if ((changed.has("flex") || changed.has("width")) && this.style) {
|
|
107
|
+
this.style.flex = this.flex ? `0 0 ${this.width ?? "auto"}` : "";
|
|
108
|
+
}
|
|
57
109
|
}
|
|
58
110
|
get isSortable() {
|
|
59
111
|
return this.header && !!this.sortKey;
|
|
60
112
|
}
|
|
61
113
|
render() {
|
|
114
|
+
const handle = this.resizable
|
|
115
|
+
? html `<span
|
|
116
|
+
class="resize-handle"
|
|
117
|
+
part="resize-handle"
|
|
118
|
+
@pointerdown=${this.handleResizePointerDown}
|
|
119
|
+
></span>`
|
|
120
|
+
: "";
|
|
62
121
|
if (this.isSortable) {
|
|
63
122
|
const icon = this.sortDirection === "descending" ? "▼" : "▲";
|
|
64
123
|
return html `
|
|
@@ -66,9 +125,16 @@ let LitMaterialDataTableCell = class LitMaterialDataTableCell extends LitElement
|
|
|
66
125
|
<span class="content"><slot></slot></span>
|
|
67
126
|
<span class="sort-icon" part="sort-icon" aria-hidden="true">${icon}</span>
|
|
68
127
|
</button>
|
|
128
|
+
${handle}
|
|
69
129
|
`;
|
|
70
130
|
}
|
|
71
|
-
return html `<span class="content"><slot></slot></span
|
|
131
|
+
return html `<span class="content"><slot></slot></span>${handle}`;
|
|
132
|
+
}
|
|
133
|
+
dispatchResize(clientX) {
|
|
134
|
+
const isRtl = getComputedStyle(this).direction === "rtl";
|
|
135
|
+
const delta = isRtl ? this.resizeStartX - clientX : clientX - this.resizeStartX;
|
|
136
|
+
const width = Math.max(this.minWidth, Math.round(this.resizeStartWidth + delta));
|
|
137
|
+
this.dispatchEvent(new CustomEvent("column-resize", { bubbles: true, composed: true, detail: { width } }));
|
|
72
138
|
}
|
|
73
139
|
};
|
|
74
140
|
__decorate([
|
|
@@ -83,6 +149,18 @@ __decorate([
|
|
|
83
149
|
__decorate([
|
|
84
150
|
property({ attribute: "sort-direction", reflect: true })
|
|
85
151
|
], LitMaterialDataTableCell.prototype, "sortDirection", void 0);
|
|
152
|
+
__decorate([
|
|
153
|
+
property({ type: Boolean, reflect: true })
|
|
154
|
+
], LitMaterialDataTableCell.prototype, "resizable", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
property({ attribute: "min-width", type: Number })
|
|
157
|
+
], LitMaterialDataTableCell.prototype, "minWidth", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
property({ type: Boolean, reflect: true })
|
|
160
|
+
], LitMaterialDataTableCell.prototype, "flex", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
property()
|
|
163
|
+
], LitMaterialDataTableCell.prototype, "width", void 0);
|
|
86
164
|
LitMaterialDataTableCell = __decorate([
|
|
87
165
|
customElement("lit-material-data-table-cell")
|
|
88
166
|
], LitMaterialDataTableCell);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-cell.js","sourceRoot":"","sources":["../src/data-table-cell.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAIrD
|
|
1
|
+
{"version":3,"file":"data-table-cell.js","sourceRoot":"","sources":["../src/data-table-cell.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,UAAU;IAAjD;;QAGuC,WAAM,GAAG,KAAK,CAAC;QACf,YAAO,GAAG,KAAK,CAAC;QAE5D,2FAA2F;QACjC,kBAAa,GAAkB,MAAM,CAAC;QAChG,mFAAmF;QACvC,cAAS,GAAG,KAAK,CAAC;QAC9D,yEAAyE;QACrB,aAAQ,GAAG,EAAE,CAAC;QAClE,2GAA2G;QAC/D,SAAI,GAAG,KAAK,CAAC;QAIjD,iBAAY,GAAG,CAAC,CAAC;QACjB,qBAAgB,GAAG,CAAC,CAAC;QAsCZ,oBAAe,GAAG,GAAS,EAAE;YAC5C,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,cAAc,EAAE;gBAC9B,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,E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DAAgB;AAfhB,wBAAwB;IADpC,aAAa,CAAC,8BAA8B,CAAC;GACjC,wBAAwB,CAwGpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-pagination-styles.d.ts","sourceRoot":"","sources":["../src/data-table-pagination-styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAgFlB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: flex-end;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
gap: 24px;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
padding: 0 16px;
|
|
11
|
+
min-height: 52px;
|
|
12
|
+
color: var(--md-sys-color-on-surface-variant, #49454f);
|
|
13
|
+
font-family: var(--md-sys-typescale-body-medium-font, Roboto, system-ui, sans-serif);
|
|
14
|
+
font-size: var(--md-sys-typescale-body-medium-size, 0.875rem);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.page-size {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.page-size select {
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
border: none;
|
|
26
|
+
background: transparent;
|
|
27
|
+
color: inherit;
|
|
28
|
+
font: inherit;
|
|
29
|
+
padding: 4px 24px 4px 4px;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.range {
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
font-variant-numeric: tabular-nums;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.controls {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 4px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
button {
|
|
45
|
+
display: inline-flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
width: 40px;
|
|
50
|
+
height: 40px;
|
|
51
|
+
border: none;
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
background: transparent;
|
|
54
|
+
color: var(--md-sys-color-on-surface-variant, #49454f);
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
font-size: 1.1rem;
|
|
57
|
+
-webkit-appearance: none;
|
|
58
|
+
appearance: none;
|
|
59
|
+
transition: background-color 150ms var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
button:hover:not(:disabled) {
|
|
63
|
+
background-color: color-mix(in srgb, var(--md-sys-color-on-surface, #1c1b1f) 8%, transparent);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
button:focus-visible {
|
|
67
|
+
outline: 2px solid var(--md-sys-color-secondary, #625b71);
|
|
68
|
+
outline-offset: 2px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
button:disabled {
|
|
72
|
+
color: var(--md-sys-color-on-surface, #1c1b1f);
|
|
73
|
+
opacity: 0.38;
|
|
74
|
+
cursor: default;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@media (prefers-reduced-motion: reduce) {
|
|
78
|
+
button {
|
|
79
|
+
transition: none;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
//# sourceMappingURL=data-table-pagination-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-pagination-styles.js","sourceRoot":"","sources":["../src/data-table-pagination-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgFxB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* A pagination footer for `lit-material-data-table` — a standalone,
|
|
4
|
+
* headless control rather than something the table renders itself, since
|
|
5
|
+
* the table never owns your data (see its own class docs) and paging is
|
|
6
|
+
* exactly as data-shaped a concern as sorting/selection. Place one below a
|
|
7
|
+
* table, feed it `total`/`page`/`page-size`, and re-render (or re-fetch) the
|
|
8
|
+
* table's rows in response to `page-change` — this component never touches
|
|
9
|
+
* the table directly.
|
|
10
|
+
*
|
|
11
|
+
* @element lit-material-data-table-pagination
|
|
12
|
+
*
|
|
13
|
+
* @fires page-change - `detail: { page, pageSize }`, when a nav button is activated or the page-size
|
|
14
|
+
* select changes (which also resets `page` to `0`).
|
|
15
|
+
*/
|
|
16
|
+
export declare class LitMaterialDataTablePagination extends LitElement {
|
|
17
|
+
static styles: import("lit").CSSResult;
|
|
18
|
+
/** 0-based current page index. */
|
|
19
|
+
page: number;
|
|
20
|
+
pageSize: number;
|
|
21
|
+
/** Total row count across every page — this control has no idea what a "row" is beyond this number. */
|
|
22
|
+
total: number;
|
|
23
|
+
pageSizeOptions: readonly number[];
|
|
24
|
+
protected willUpdate(): void;
|
|
25
|
+
private get pageCount();
|
|
26
|
+
private get clampedPage();
|
|
27
|
+
private get rangeStart();
|
|
28
|
+
private get rangeEnd();
|
|
29
|
+
private emitChange;
|
|
30
|
+
private readonly handleFirst;
|
|
31
|
+
private readonly handlePrevious;
|
|
32
|
+
private readonly handleNext;
|
|
33
|
+
private readonly handleLast;
|
|
34
|
+
private readonly handlePageSizeChange;
|
|
35
|
+
render(): import("lit").TemplateResult<1>;
|
|
36
|
+
}
|
|
37
|
+
declare global {
|
|
38
|
+
interface HTMLElementTagNameMap {
|
|
39
|
+
"lit-material-data-table-pagination": LitMaterialDataTablePagination;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=data-table-pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-pagination.d.ts","sourceRoot":"","sources":["../src/data-table-pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC;;;;;;;;;;;;;GAaG;AACH,qBACa,8BAA+B,SAAQ,UAAU;IAC5D,OAAgB,MAAM,0BAAU;IAEhC,kCAAkC;IACN,IAAI,SAAK;IACe,QAAQ,SAAM;IAClE,uGAAuG;IAC3E,KAAK,SAAK;IACN,eAAe,EAAE,SAAS,MAAM,EAAE,CAAgB;cAE/D,UAAU,IAAI,IAAI;IASrC,OAAO,KAAK,SAAS,GAEpB;IAED,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkC;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkE;IACjG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmF;IAC9G,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmD;IAE9E,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAGnC;IAEO,MAAM;CAwBhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oCAAoC,EAAE,8BAA8B,CAAC;KACtE;CACF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, LitElement } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { styles } from "./data-table-pagination-styles.js";
|
|
10
|
+
/**
|
|
11
|
+
* A pagination footer for `lit-material-data-table` — a standalone,
|
|
12
|
+
* headless control rather than something the table renders itself, since
|
|
13
|
+
* the table never owns your data (see its own class docs) and paging is
|
|
14
|
+
* exactly as data-shaped a concern as sorting/selection. Place one below a
|
|
15
|
+
* table, feed it `total`/`page`/`page-size`, and re-render (or re-fetch) the
|
|
16
|
+
* table's rows in response to `page-change` — this component never touches
|
|
17
|
+
* the table directly.
|
|
18
|
+
*
|
|
19
|
+
* @element lit-material-data-table-pagination
|
|
20
|
+
*
|
|
21
|
+
* @fires page-change - `detail: { page, pageSize }`, when a nav button is activated or the page-size
|
|
22
|
+
* select changes (which also resets `page` to `0`).
|
|
23
|
+
*/
|
|
24
|
+
let LitMaterialDataTablePagination = class LitMaterialDataTablePagination extends LitElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
/** 0-based current page index. */
|
|
28
|
+
this.page = 0;
|
|
29
|
+
this.pageSize = 10;
|
|
30
|
+
/** Total row count across every page — this control has no idea what a "row" is beyond this number. */
|
|
31
|
+
this.total = 0;
|
|
32
|
+
this.pageSizeOptions = [10, 25, 50];
|
|
33
|
+
this.handleFirst = () => this.emitChange(0);
|
|
34
|
+
this.handlePrevious = () => this.emitChange(Math.max(0, this.clampedPage - 1));
|
|
35
|
+
this.handleNext = () => this.emitChange(Math.min(this.pageCount - 1, this.clampedPage + 1));
|
|
36
|
+
this.handleLast = () => this.emitChange(this.pageCount - 1);
|
|
37
|
+
this.handlePageSizeChange = (event) => {
|
|
38
|
+
this.pageSize = Number(event.target.value);
|
|
39
|
+
this.emitChange(0);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
static { this.styles = styles; }
|
|
43
|
+
willUpdate() {
|
|
44
|
+
if (!this.hasAttribute("role")) {
|
|
45
|
+
this.setAttribute("role", "group");
|
|
46
|
+
}
|
|
47
|
+
if (!this.hasAttribute("aria-label")) {
|
|
48
|
+
this.setAttribute("aria-label", "Pagination");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
get pageCount() {
|
|
52
|
+
return Math.max(1, Math.ceil(this.total / this.pageSize));
|
|
53
|
+
}
|
|
54
|
+
get clampedPage() {
|
|
55
|
+
return Math.min(Math.max(this.page, 0), this.pageCount - 1);
|
|
56
|
+
}
|
|
57
|
+
get rangeStart() {
|
|
58
|
+
return this.total === 0 ? 0 : this.clampedPage * this.pageSize + 1;
|
|
59
|
+
}
|
|
60
|
+
get rangeEnd() {
|
|
61
|
+
return Math.min(this.total, (this.clampedPage + 1) * this.pageSize);
|
|
62
|
+
}
|
|
63
|
+
emitChange(page) {
|
|
64
|
+
this.page = page;
|
|
65
|
+
this.dispatchEvent(new CustomEvent("page-change", { bubbles: true, detail: { page: this.page, pageSize: this.pageSize } }));
|
|
66
|
+
}
|
|
67
|
+
render() {
|
|
68
|
+
const page = this.clampedPage;
|
|
69
|
+
const isFirst = page <= 0;
|
|
70
|
+
const isLast = page >= this.pageCount - 1;
|
|
71
|
+
return html `
|
|
72
|
+
<div class="page-size">
|
|
73
|
+
<label id="page-size-label">Rows per page</label>
|
|
74
|
+
<select aria-labelledby="page-size-label" .value=${String(this.pageSize)} @change=${this.handlePageSizeChange}>
|
|
75
|
+
${this.pageSizeOptions.map((size) => html `<option value=${size} ?selected=${size === this.pageSize}>${size}</option>`)}
|
|
76
|
+
</select>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="range">${this.rangeStart}–${this.rangeEnd} of ${this.total}</div>
|
|
79
|
+
<div class="controls">
|
|
80
|
+
<button type="button" aria-label="First page" ?disabled=${isFirst} @click=${this.handleFirst}>⏮</button>
|
|
81
|
+
<button type="button" aria-label="Previous page" ?disabled=${isFirst} @click=${this.handlePrevious}>
|
|
82
|
+
◀
|
|
83
|
+
</button>
|
|
84
|
+
<button type="button" aria-label="Next page" ?disabled=${isLast} @click=${this.handleNext}>▶</button>
|
|
85
|
+
<button type="button" aria-label="Last page" ?disabled=${isLast} @click=${this.handleLast}>⏭</button>
|
|
86
|
+
</div>
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
__decorate([
|
|
91
|
+
property({ type: Number })
|
|
92
|
+
], LitMaterialDataTablePagination.prototype, "page", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
property({ attribute: "page-size", type: Number })
|
|
95
|
+
], LitMaterialDataTablePagination.prototype, "pageSize", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
property({ type: Number })
|
|
98
|
+
], LitMaterialDataTablePagination.prototype, "total", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ attribute: false })
|
|
101
|
+
], LitMaterialDataTablePagination.prototype, "pageSizeOptions", void 0);
|
|
102
|
+
LitMaterialDataTablePagination = __decorate([
|
|
103
|
+
customElement("lit-material-data-table-pagination")
|
|
104
|
+
], LitMaterialDataTablePagination);
|
|
105
|
+
export { LitMaterialDataTablePagination };
|
|
106
|
+
//# sourceMappingURL=data-table-pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-table-pagination.js","sourceRoot":"","sources":["../src/data-table-pagination.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AAEI,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,UAAU;IAAvD;;QAGL,kCAAkC;QACN,SAAI,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B;YACzG,IAAI,CAAC,eAAe,CAAC,GAAG,CACxB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA,iBAAiB,IAAI,cAAc,IAAI,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,WAAW,CAC3F;;;2BAGgB,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC,KAAK;;kEAEV,OAAO,WAAW,IAAI,CAAC,WAAW;qEAC/B,OAAO,WAAW,IAAI,CAAC,cAAc;;;iEAGzC,MAAM,WAAW,IAAI,CAAC,UAAU;iEAChC,MAAM,WAAW,IAAI,CAAC,UAAU;;KAE5F,CAAC;IACJ,CAAC;;AAvE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAU;AACe;IAAnD,QAAQ,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAAe;AAEtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAAW;AACN;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uEAAmD;AARvE,8BAA8B;IAD1C,aAAa,CAAC,oCAAoC,CAAC;GACvC,8BAA8B,CA4E1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-row-styles.d.ts","sourceRoot":"","sources":["../src/data-table-row-styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"data-table-row-styles.d.ts","sourceRoot":"","sources":["../src/data-table-row-styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBA8BlB,CAAC"}
|
|
@@ -6,6 +6,12 @@ export const styles = css `
|
|
|
6
6
|
transition: background-color 150ms var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
:host([flex]) {
|
|
10
|
+
display: flex;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
:host(:last-of-type) {
|
|
10
16
|
border-bottom: none;
|
|
11
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-row-styles.js","sourceRoot":"","sources":["../src/data-table-row-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"data-table-row-styles.js","sourceRoot":"","sources":["../src/data-table-row-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BxB,CAAC"}
|
package/dist/data-table-row.d.ts
CHANGED
|
@@ -8,6 +8,14 @@ import { LitElement } from "lit";
|
|
|
8
8
|
* uses `display: table-cell` — native table column alignment without an
|
|
9
9
|
* actual `<table>` element.
|
|
10
10
|
*
|
|
11
|
+
* Set `flex` instead when this row is used with `lit-material-data-table`'s
|
|
12
|
+
* virtualized (`items`/`.rowRenderer`) mode: rows rendered inside an
|
|
13
|
+
* absolutely-positioned, transformed viewport can't participate in the
|
|
14
|
+
* browser's table layout algorithm (that requires normal in-flow siblings),
|
|
15
|
+
* so virtualized rows lay themselves out with flexbox instead — give each
|
|
16
|
+
* `lit-material-data-table-cell` inside a matching `flex` and a `width` so
|
|
17
|
+
* columns still line up with the (still table-laid-out) header row.
|
|
18
|
+
*
|
|
11
19
|
* @element lit-material-data-table-row
|
|
12
20
|
*
|
|
13
21
|
* @slot - `lit-material-data-table-cell` elements.
|
|
@@ -17,6 +25,8 @@ export declare class LitMaterialDataTableRow extends LitElement {
|
|
|
17
25
|
header: boolean;
|
|
18
26
|
/** Highlights the row — set by the table from a row-select checkbox's checked state, not directly. */
|
|
19
27
|
selected: boolean;
|
|
28
|
+
/** Lays the row out with flexbox instead of `display: table-row` — see the class docs. */
|
|
29
|
+
flex: boolean;
|
|
20
30
|
protected willUpdate(changed: Map<string, unknown>): void;
|
|
21
31
|
render(): import("lit").TemplateResult<1>;
|
|
22
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-row.d.ts","sourceRoot":"","sources":["../src/data-table-row.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC
|
|
1
|
+
{"version":3,"file":"data-table-row.d.ts","sourceRoot":"","sources":["../src/data-table-row.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,uBAAwB,SAAQ,UAAU;IACrD,OAAgB,MAAM,0BAAU;IAEY,MAAM,UAAS;IAC3D,sGAAsG;IAC1D,QAAQ,UAAS;IAC7D,0FAA0F;IAC9C,IAAI,UAAS;cAEtC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAMzD,MAAM;CAGhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,6BAA6B,EAAE,uBAAuB,CAAC;KACxD;CACF"}
|
package/dist/data-table-row.js
CHANGED
|
@@ -16,6 +16,14 @@ import { styles } from "./data-table-row-styles.js";
|
|
|
16
16
|
* uses `display: table-cell` — native table column alignment without an
|
|
17
17
|
* actual `<table>` element.
|
|
18
18
|
*
|
|
19
|
+
* Set `flex` instead when this row is used with `lit-material-data-table`'s
|
|
20
|
+
* virtualized (`items`/`.rowRenderer`) mode: rows rendered inside an
|
|
21
|
+
* absolutely-positioned, transformed viewport can't participate in the
|
|
22
|
+
* browser's table layout algorithm (that requires normal in-flow siblings),
|
|
23
|
+
* so virtualized rows lay themselves out with flexbox instead — give each
|
|
24
|
+
* `lit-material-data-table-cell` inside a matching `flex` and a `width` so
|
|
25
|
+
* columns still line up with the (still table-laid-out) header row.
|
|
26
|
+
*
|
|
19
27
|
* @element lit-material-data-table-row
|
|
20
28
|
*
|
|
21
29
|
* @slot - `lit-material-data-table-cell` elements.
|
|
@@ -26,6 +34,8 @@ let LitMaterialDataTableRow = class LitMaterialDataTableRow extends LitElement {
|
|
|
26
34
|
this.header = false;
|
|
27
35
|
/** Highlights the row — set by the table from a row-select checkbox's checked state, not directly. */
|
|
28
36
|
this.selected = false;
|
|
37
|
+
/** Lays the row out with flexbox instead of `display: table-row` — see the class docs. */
|
|
38
|
+
this.flex = false;
|
|
29
39
|
}
|
|
30
40
|
static { this.styles = styles; }
|
|
31
41
|
willUpdate(changed) {
|
|
@@ -43,6 +53,9 @@ __decorate([
|
|
|
43
53
|
__decorate([
|
|
44
54
|
property({ type: Boolean, reflect: true })
|
|
45
55
|
], LitMaterialDataTableRow.prototype, "selected", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
property({ type: Boolean, reflect: true })
|
|
58
|
+
], LitMaterialDataTableRow.prototype, "flex", void 0);
|
|
46
59
|
LitMaterialDataTableRow = __decorate([
|
|
47
60
|
customElement("lit-material-data-table-row")
|
|
48
61
|
], LitMaterialDataTableRow);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-row.js","sourceRoot":"","sources":["../src/data-table-row.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD
|
|
1
|
+
{"version":3,"file":"data-table-row.js","sourceRoot":"","sources":["../src/data-table-row.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI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styles.d.ts","sourceRoot":"","sources":["../src/data-table-styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAkClB,CAAC"}
|
|
@@ -14,5 +14,24 @@ export const styles = css `
|
|
|
14
14
|
width: 100%;
|
|
15
15
|
border-collapse: collapse;
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
.viewport {
|
|
19
|
+
display: block;
|
|
20
|
+
width: 100%;
|
|
21
|
+
overflow-y: auto;
|
|
22
|
+
position: relative;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.spacer {
|
|
26
|
+
position: relative;
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.virtual-row {
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset-inline-start: 0;
|
|
33
|
+
inset-inline-end: 0;
|
|
34
|
+
top: 0;
|
|
35
|
+
}
|
|
17
36
|
`;
|
|
18
37
|
//# sourceMappingURL=data-table-styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-styles.js","sourceRoot":"","sources":["../src/data-table-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"data-table-styles.js","sourceRoot":"","sources":["../src/data-table-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCxB,CAAC"}
|
package/dist/data-table.d.ts
CHANGED
|
@@ -24,11 +24,35 @@ import type { SortDirection } from "./data-table-cell.js";
|
|
|
24
24
|
* closest-`<tr>`-equivalent (`lit-material-data-table-row`) `data-row-id`
|
|
25
25
|
* attribute.
|
|
26
26
|
*
|
|
27
|
+
* A `resizable` header cell's drag handle reports its own width via a
|
|
28
|
+
* `column-resize` event — this table is the one that actually applies it,
|
|
29
|
+
* setting an explicit `width`/`min-width`/`max-width` on every cell that
|
|
30
|
+
* shares that column index (header and body alike), not just the header
|
|
31
|
+
* cell that was dragged. That has to happen up here rather than in the cell
|
|
32
|
+
* itself: with `display: table-cell` and no real `<colgroup>`, the browser's
|
|
33
|
+
* table layout algorithm treats "same child index across sibling rows" as
|
|
34
|
+
* the column, so keeping a whole column in sync means reaching into every
|
|
35
|
+
* row, which only the table can see.
|
|
36
|
+
*
|
|
37
|
+
* Set `.items`/`.rowRenderer` for large datasets to switch on fixed-height
|
|
38
|
+
* row virtualization: only the rows within (or near) the visible scroll
|
|
39
|
+
* window are ever rendered, however many thousand `items` there are. This
|
|
40
|
+
* is the one thing here that isn't purely headless — the table owns
|
|
41
|
+
* scroll position and which slice of `items` is currently mounted — because
|
|
42
|
+
* true virtualization requires knowing the full item count up front, which
|
|
43
|
+
* "you slot real rows" (this table's normal mode) can't provide. Slot only
|
|
44
|
+
* the header row in this mode; body rows come from `rowRenderer` instead,
|
|
45
|
+
* and both the header row and every `rowRenderer`-returned row need `flex`
|
|
46
|
+
* set (see `lit-material-data-table-row`'s docs) since virtualized rows are
|
|
47
|
+
* positioned with `transform`, which native table layout can't do.
|
|
48
|
+
*
|
|
27
49
|
* @element lit-material-data-table
|
|
28
50
|
*
|
|
29
|
-
* @slot - `lit-material-data-table-row` elements.
|
|
51
|
+
* @slot - `lit-material-data-table-row` elements (in virtualized mode, the header row only).
|
|
30
52
|
*
|
|
31
53
|
* @csspart table - The table layout container.
|
|
54
|
+
* @csspart viewport - The scrollable viewport, in virtualized mode.
|
|
55
|
+
* @csspart spacer - The full-height spacer inside the viewport, in virtualized mode.
|
|
32
56
|
*
|
|
33
57
|
* @fires sort-change - `detail: { sortKey, sortDirection }`, when a sortable header cell is activated.
|
|
34
58
|
* @fires selection-change - `detail: { selected: string[] }` (the checked rows' `data-row-id` values),
|
|
@@ -38,11 +62,28 @@ export declare class LitMaterialDataTable extends LitElement {
|
|
|
38
62
|
static styles: import("lit").CSSResult;
|
|
39
63
|
sortKey?: string;
|
|
40
64
|
sortDirection: SortDirection;
|
|
65
|
+
/** The full dataset for virtualized mode. Empty (the default) means "not virtualized". */
|
|
66
|
+
items: readonly unknown[];
|
|
67
|
+
/** Renders one virtualized body row. Required alongside `items` to turn virtualization on. */
|
|
68
|
+
rowRenderer?: (item: unknown, index: number) => unknown;
|
|
69
|
+
/** Stable key per item, for correct DOM reuse as the visible window scrolls. Defaults to the index. */
|
|
70
|
+
rowKey?: (item: unknown, index: number) => string | number;
|
|
71
|
+
/** Fixed row height in pixels — every virtualized row is assumed to be exactly this tall. */
|
|
72
|
+
rowHeight: number;
|
|
73
|
+
/** Visible scroll-viewport height in pixels. */
|
|
74
|
+
viewportHeight: number;
|
|
75
|
+
/** Extra rows rendered beyond each edge of the visible window, to absorb fast scrolling. */
|
|
76
|
+
overscan: number;
|
|
77
|
+
private viewportScrollTop;
|
|
78
|
+
private scrollUpdatePending;
|
|
41
79
|
constructor();
|
|
42
80
|
protected willUpdate(changed: Map<string, unknown>): void;
|
|
81
|
+
private queryAllInTable;
|
|
43
82
|
private get headerCells();
|
|
44
83
|
private get rowCheckboxes();
|
|
45
84
|
private get selectAllCheckbox();
|
|
85
|
+
private get rows();
|
|
86
|
+
private get isVirtualized();
|
|
46
87
|
private syncSortIndicators;
|
|
47
88
|
private syncSelectAllState;
|
|
48
89
|
private syncRowSelectedState;
|
|
@@ -50,6 +91,9 @@ export declare class LitMaterialDataTable extends LitElement {
|
|
|
50
91
|
private readonly handleSlotChange;
|
|
51
92
|
private readonly handleSortRequest;
|
|
52
93
|
private readonly handleChange;
|
|
94
|
+
private readonly handleColumnResize;
|
|
95
|
+
private readonly handleViewportScroll;
|
|
96
|
+
private renderVirtualizedRows;
|
|
53
97
|
render(): import("lit").TemplateResult<1>;
|
|
54
98
|
}
|
|
55
99
|
declare global {
|
package/dist/data-table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../src/data-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../src/data-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAGvC,OAAO,KAAK,EAA4B,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,qBACa,oBAAqB,SAAQ,UAAU;IAClD,OAAgB,MAAM,0BAAU;IAEK,OAAO,CAAC,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,aAAa,CAAe;IAEtF,0FAA0F;IAC1D,KAAK,EAAE,SAAS,OAAO,EAAE,CAAM;IAC/D,8FAA8F;IAC9D,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACxF,uGAAuG;IACvE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC;IAC3F,6FAA6F;IACxC,SAAS,SAAM;IACpE,gDAAgD;IACU,cAAc,SAAO;IAC/E,4FAA4F;IAChE,QAAQ,SAAK;IAEhC,OAAO,CAAC,iBAAiB,CAAK;IACvC,OAAO,CAAC,mBAAmB,CAAS;;cASjB,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAkBlE,OAAO,CAAC,eAAe;IAUvB,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,KAAK,iBAAiB,GAE5B;IAED,OAAO,KAAK,IAAI,GAEf;IAED,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAI/B;IAEF,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAehC;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAe3B;IAEF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAcjC;IAEF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAQnC;IAEF,OAAO,CAAC,qBAAqB;IA+BpB,MAAM;CAQhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,yBAAyB,EAAE,oBAAoB,CAAC;KACjD;CACF"}
|
package/dist/data-table.js
CHANGED
|
@@ -5,7 +5,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, LitElement } from "lit";
|
|
8
|
-
import { customElement, property } from "lit/decorators.js";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
9
10
|
import { styles } from "./data-table-styles.js";
|
|
10
11
|
/**
|
|
11
12
|
* Material Design 3 data table — a container for `lit-material-data-table-row`
|
|
@@ -31,11 +32,35 @@ import { styles } from "./data-table-styles.js";
|
|
|
31
32
|
* closest-`<tr>`-equivalent (`lit-material-data-table-row`) `data-row-id`
|
|
32
33
|
* attribute.
|
|
33
34
|
*
|
|
35
|
+
* A `resizable` header cell's drag handle reports its own width via a
|
|
36
|
+
* `column-resize` event — this table is the one that actually applies it,
|
|
37
|
+
* setting an explicit `width`/`min-width`/`max-width` on every cell that
|
|
38
|
+
* shares that column index (header and body alike), not just the header
|
|
39
|
+
* cell that was dragged. That has to happen up here rather than in the cell
|
|
40
|
+
* itself: with `display: table-cell` and no real `<colgroup>`, the browser's
|
|
41
|
+
* table layout algorithm treats "same child index across sibling rows" as
|
|
42
|
+
* the column, so keeping a whole column in sync means reaching into every
|
|
43
|
+
* row, which only the table can see.
|
|
44
|
+
*
|
|
45
|
+
* Set `.items`/`.rowRenderer` for large datasets to switch on fixed-height
|
|
46
|
+
* row virtualization: only the rows within (or near) the visible scroll
|
|
47
|
+
* window are ever rendered, however many thousand `items` there are. This
|
|
48
|
+
* is the one thing here that isn't purely headless — the table owns
|
|
49
|
+
* scroll position and which slice of `items` is currently mounted — because
|
|
50
|
+
* true virtualization requires knowing the full item count up front, which
|
|
51
|
+
* "you slot real rows" (this table's normal mode) can't provide. Slot only
|
|
52
|
+
* the header row in this mode; body rows come from `rowRenderer` instead,
|
|
53
|
+
* and both the header row and every `rowRenderer`-returned row need `flex`
|
|
54
|
+
* set (see `lit-material-data-table-row`'s docs) since virtualized rows are
|
|
55
|
+
* positioned with `transform`, which native table layout can't do.
|
|
56
|
+
*
|
|
34
57
|
* @element lit-material-data-table
|
|
35
58
|
*
|
|
36
|
-
* @slot - `lit-material-data-table-row` elements.
|
|
59
|
+
* @slot - `lit-material-data-table-row` elements (in virtualized mode, the header row only).
|
|
37
60
|
*
|
|
38
61
|
* @csspart table - The table layout container.
|
|
62
|
+
* @csspart viewport - The scrollable viewport, in virtualized mode.
|
|
63
|
+
* @csspart spacer - The full-height spacer inside the viewport, in virtualized mode.
|
|
39
64
|
*
|
|
40
65
|
* @fires sort-change - `detail: { sortKey, sortDirection }`, when a sortable header cell is activated.
|
|
41
66
|
* @fires selection-change - `detail: { selected: string[] }` (the checked rows' `data-row-id` values),
|
|
@@ -46,6 +71,16 @@ let LitMaterialDataTable = class LitMaterialDataTable extends LitElement {
|
|
|
46
71
|
constructor() {
|
|
47
72
|
super();
|
|
48
73
|
this.sortDirection = "ascending";
|
|
74
|
+
/** The full dataset for virtualized mode. Empty (the default) means "not virtualized". */
|
|
75
|
+
this.items = [];
|
|
76
|
+
/** Fixed row height in pixels — every virtualized row is assumed to be exactly this tall. */
|
|
77
|
+
this.rowHeight = 44;
|
|
78
|
+
/** Visible scroll-viewport height in pixels. */
|
|
79
|
+
this.viewportHeight = 400;
|
|
80
|
+
/** Extra rows rendered beyond each edge of the visible window, to absorb fast scrolling. */
|
|
81
|
+
this.overscan = 4;
|
|
82
|
+
this.viewportScrollTop = 0;
|
|
83
|
+
this.scrollUpdatePending = false;
|
|
49
84
|
this.handleSlotChange = () => {
|
|
50
85
|
this.syncSortIndicators();
|
|
51
86
|
this.syncSelectAllState();
|
|
@@ -86,8 +121,37 @@ let LitMaterialDataTable = class LitMaterialDataTable extends LitElement {
|
|
|
86
121
|
this.dispatchSelectionChange();
|
|
87
122
|
}
|
|
88
123
|
};
|
|
124
|
+
this.handleColumnResize = (event) => {
|
|
125
|
+
const cell = event.composedPath()[0];
|
|
126
|
+
const row = cell?.parentElement;
|
|
127
|
+
if (!cell || !row)
|
|
128
|
+
return;
|
|
129
|
+
const index = Array.from(row.children).indexOf(cell);
|
|
130
|
+
if (index === -1)
|
|
131
|
+
return;
|
|
132
|
+
const width = `${event.detail.width}px`;
|
|
133
|
+
this.rows.forEach((otherRow) => {
|
|
134
|
+
const target = otherRow.children[index];
|
|
135
|
+
if (!target)
|
|
136
|
+
return;
|
|
137
|
+
target.style.width = width;
|
|
138
|
+
target.style.minWidth = width;
|
|
139
|
+
target.style.maxWidth = width;
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
this.handleViewportScroll = (event) => {
|
|
143
|
+
const target = event.currentTarget;
|
|
144
|
+
if (this.scrollUpdatePending)
|
|
145
|
+
return;
|
|
146
|
+
this.scrollUpdatePending = true;
|
|
147
|
+
requestAnimationFrame(() => {
|
|
148
|
+
this.scrollUpdatePending = false;
|
|
149
|
+
this.viewportScrollTop = target.scrollTop;
|
|
150
|
+
});
|
|
151
|
+
};
|
|
89
152
|
this.addEventListener("sort-request", this.handleSortRequest);
|
|
90
153
|
this.addEventListener("change", this.handleChange);
|
|
154
|
+
this.addEventListener("column-resize", this.handleColumnResize);
|
|
91
155
|
}
|
|
92
156
|
willUpdate(changed) {
|
|
93
157
|
// Not connectedCallback(): attribute mutations made there don't make it
|
|
@@ -101,23 +165,35 @@ let LitMaterialDataTable = class LitMaterialDataTable extends LitElement {
|
|
|
101
165
|
this.syncSortIndicators();
|
|
102
166
|
}
|
|
103
167
|
}
|
|
104
|
-
|
|
168
|
+
// Virtualized body rows live in this table's own shadow root (rendered by
|
|
169
|
+
// `rowRenderer`, not slotted), while everything else lives in the light
|
|
170
|
+
// DOM as usual — merge both trees rather than picking one, so sorting/
|
|
171
|
+
// selection delegation keeps working regardless of which mode produced a
|
|
172
|
+
// given row.
|
|
173
|
+
queryAllInTable(selector) {
|
|
105
174
|
// @lit-labs/ssr's light-DOM shim doesn't implement querySelectorAll on
|
|
106
|
-
// the host during connectedCallback — degrade to no
|
|
175
|
+
// the host during connectedCallback — degrade to no elements rather than
|
|
107
176
|
// throwing (there's no sort/selection state to sync server-side anyway).
|
|
108
177
|
if (typeof this.querySelectorAll !== "function")
|
|
109
178
|
return [];
|
|
110
|
-
|
|
179
|
+
const lightMatches = Array.from(this.querySelectorAll(selector));
|
|
180
|
+
const shadowMatches = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
181
|
+
return [...lightMatches, ...shadowMatches];
|
|
182
|
+
}
|
|
183
|
+
get headerCells() {
|
|
184
|
+
return this.queryAllInTable("lit-material-data-table-cell[header]");
|
|
111
185
|
}
|
|
112
186
|
get rowCheckboxes() {
|
|
113
|
-
|
|
114
|
-
return [];
|
|
115
|
-
return Array.from(this.querySelectorAll("[data-row-select]"));
|
|
187
|
+
return this.queryAllInTable("[data-row-select]");
|
|
116
188
|
}
|
|
117
189
|
get selectAllCheckbox() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
190
|
+
return this.queryAllInTable("[data-select-all]")[0] ?? null;
|
|
191
|
+
}
|
|
192
|
+
get rows() {
|
|
193
|
+
return this.queryAllInTable("lit-material-data-table-row");
|
|
194
|
+
}
|
|
195
|
+
get isVirtualized() {
|
|
196
|
+
return this.items.length > 0 && !!this.rowRenderer;
|
|
121
197
|
}
|
|
122
198
|
syncSortIndicators() {
|
|
123
199
|
this.headerCells.forEach((cell) => {
|
|
@@ -147,8 +223,38 @@ let LitMaterialDataTable = class LitMaterialDataTable extends LitElement {
|
|
|
147
223
|
.filter((id) => id !== null && id !== undefined);
|
|
148
224
|
this.dispatchEvent(new CustomEvent("selection-change", { bubbles: true, detail: { selected } }));
|
|
149
225
|
}
|
|
226
|
+
renderVirtualizedRows() {
|
|
227
|
+
const total = this.items.length;
|
|
228
|
+
const totalHeight = total * this.rowHeight;
|
|
229
|
+
const start = Math.max(0, Math.floor(this.viewportScrollTop / this.rowHeight) - this.overscan);
|
|
230
|
+
const visibleCount = Math.ceil(this.viewportHeight / this.rowHeight) + this.overscan * 2;
|
|
231
|
+
const end = Math.min(total, start + visibleCount);
|
|
232
|
+
const visible = this.items.slice(start, end);
|
|
233
|
+
return html `
|
|
234
|
+
<div
|
|
235
|
+
class="viewport"
|
|
236
|
+
part="viewport"
|
|
237
|
+
style="height: ${this.viewportHeight}px"
|
|
238
|
+
@scroll=${this.handleViewportScroll}
|
|
239
|
+
>
|
|
240
|
+
<div class="spacer" part="spacer" style="height: ${totalHeight}px">
|
|
241
|
+
${repeat(visible, (item, i) => (this.rowKey ? this.rowKey(item, start + i) : start + i), (item, i) => {
|
|
242
|
+
const index = start + i;
|
|
243
|
+
return html `<div class="virtual-row" style="transform: translateY(${index * this.rowHeight}px)">
|
|
244
|
+
${this.rowRenderer(item, index)}
|
|
245
|
+
</div>`;
|
|
246
|
+
})}
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
`;
|
|
250
|
+
}
|
|
150
251
|
render() {
|
|
151
|
-
return html
|
|
252
|
+
return html `
|
|
253
|
+
<div class="table" part="table">
|
|
254
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
255
|
+
${this.isVirtualized ? this.renderVirtualizedRows() : ""}
|
|
256
|
+
</div>
|
|
257
|
+
`;
|
|
152
258
|
}
|
|
153
259
|
};
|
|
154
260
|
__decorate([
|
|
@@ -157,6 +263,27 @@ __decorate([
|
|
|
157
263
|
__decorate([
|
|
158
264
|
property({ attribute: "sort-direction" })
|
|
159
265
|
], LitMaterialDataTable.prototype, "sortDirection", void 0);
|
|
266
|
+
__decorate([
|
|
267
|
+
property({ attribute: false })
|
|
268
|
+
], LitMaterialDataTable.prototype, "items", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
property({ attribute: false })
|
|
271
|
+
], LitMaterialDataTable.prototype, "rowRenderer", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
property({ attribute: false })
|
|
274
|
+
], LitMaterialDataTable.prototype, "rowKey", void 0);
|
|
275
|
+
__decorate([
|
|
276
|
+
property({ attribute: "row-height", type: Number })
|
|
277
|
+
], LitMaterialDataTable.prototype, "rowHeight", void 0);
|
|
278
|
+
__decorate([
|
|
279
|
+
property({ attribute: "viewport-height", type: Number })
|
|
280
|
+
], LitMaterialDataTable.prototype, "viewportHeight", void 0);
|
|
281
|
+
__decorate([
|
|
282
|
+
property({ type: Number })
|
|
283
|
+
], LitMaterialDataTable.prototype, "overscan", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
state()
|
|
286
|
+
], LitMaterialDataTable.prototype, "viewportScrollTop", void 0);
|
|
160
287
|
LitMaterialDataTable = __decorate([
|
|
161
288
|
customElement("lit-material-data-table")
|
|
162
289
|
], LitMaterialDataTable);
|
package/dist/data-table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.js","sourceRoot":"","sources":["../src/data-table.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBA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SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAgB;AAEV;IAAzD,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAsB;AAEnD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAc;AAExB;IAAhB,KAAK,EAAE;+DAA+B;AAnB5B,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAoNhC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { LitMaterialDataTable } from "./data-table.js";
|
|
|
2
2
|
export { LitMaterialDataTableRow } from "./data-table-row.js";
|
|
3
3
|
export { LitMaterialDataTableCell } from "./data-table-cell.js";
|
|
4
4
|
export type { SortDirection } from "./data-table-cell.js";
|
|
5
|
+
export { LitMaterialDataTablePagination } from "./data-table-pagination.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { LitMaterialDataTable } from "./data-table.js";
|
|
2
2
|
export { LitMaterialDataTableRow } from "./data-table-row.js";
|
|
3
3
|
export { LitMaterialDataTableCell } from "./data-table-cell.js";
|
|
4
|
+
export { LitMaterialDataTablePagination } from "./data-table-pagination.js";
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-material/data-table",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Material Design 3 data table web components (sortable, selectable).",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Material Design 3 data table web components (sortable, selectable, paginated, resizable, virtualized).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "bohdaq",
|