@sebgroup/green-core 2.35.0 → 2.35.1-rc.20260224134357073
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/components/pagination/pagination.component.js +8 -4
- package/components/segmented-control/segmented-control.component.js +4 -1
- package/components/segmented-control/segmented-control.styles.js +4 -1
- package/components/table/table.component.d.ts +16 -1
- package/components/table/table.component.js +105 -187
- package/components/table/table.stories.data.d.ts +33 -47
- package/components/table/table.stories.data.js +229 -284
- package/components/table/table.styles.js +15 -2
- package/components/table/table.types.d.ts +15 -81
- package/components/table/table.types.js +40 -10
- package/custom-elements.json +10444 -10255
- package/gds-element.js +1 -1
- package/generated/mcp/components.json +1 -1
- package/generated/mcp/icons.json +1 -1
- package/generated/mcp/index.json +1 -1
- package/generated/mcp/table/api.md +2 -1
- package/generated/react/index.d.ts +6 -6
- package/generated/react/index.js +6 -6
- package/generated/react/table/index.d.ts +2 -1
- package/package.json +1 -1
- package/utils/helpers/custom-element-scoping.js +1 -1
|
@@ -363,7 +363,9 @@ handlePopoverStateChange_fn = function(e) {
|
|
|
363
363
|
this._jumpPopoverOpen = e.detail.open;
|
|
364
364
|
if (e.detail.open) {
|
|
365
365
|
const popover = e.target;
|
|
366
|
-
const input = popover.querySelector(
|
|
366
|
+
const input = popover.querySelector(
|
|
367
|
+
'[gds-element="gds-input"]'
|
|
368
|
+
);
|
|
367
369
|
if (input) {
|
|
368
370
|
requestAnimationFrame(() => {
|
|
369
371
|
input.focus();
|
|
@@ -373,13 +375,15 @@ handlePopoverStateChange_fn = function(e) {
|
|
|
373
375
|
};
|
|
374
376
|
handleCustomPageInput_fn = function(e) {
|
|
375
377
|
const input = e.target;
|
|
376
|
-
const pageInput = input.closest(
|
|
378
|
+
const pageInput = input.closest(
|
|
379
|
+
'[gds-element="gds-input"]'
|
|
380
|
+
);
|
|
377
381
|
if (pageInput) {
|
|
378
382
|
const pageNum = parseInt(pageInput.value, 10);
|
|
379
383
|
if (pageNum && pageNum >= 1 && pageNum <= __privateGet(this, _GdsPagination_instances, pageCount_get)) {
|
|
380
384
|
__privateMethod(this, _GdsPagination_instances, handlePageChange_fn).call(this, pageNum);
|
|
381
|
-
const popover = pageInput.closest("gds-popover");
|
|
382
|
-
if (popover) popover.
|
|
385
|
+
const popover = pageInput.closest('[gds-element="gds-popover"]');
|
|
386
|
+
if (popover) popover.open = false;
|
|
383
387
|
}
|
|
384
388
|
}
|
|
385
389
|
};
|
|
@@ -96,7 +96,10 @@ let GdsSegmentedControl = class extends withLayoutChildProps(
|
|
|
96
96
|
if (selectedSegment) {
|
|
97
97
|
this.segments.forEach((s) => s.selected = false);
|
|
98
98
|
selectedSegment.selected = true;
|
|
99
|
-
|
|
99
|
+
selectedSegment.scrollIntoView({
|
|
100
|
+
block: "nearest",
|
|
101
|
+
inline: "nearest"
|
|
102
|
+
});
|
|
100
103
|
}
|
|
101
104
|
});
|
|
102
105
|
});
|
|
@@ -13,10 +13,12 @@ const style = css`
|
|
|
13
13
|
width: 100%;
|
|
14
14
|
position: relative;
|
|
15
15
|
overflow: hidden;
|
|
16
|
+
--_gds-segment-scroll-margin-inline: 2.75rem;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
:host([size='small']) {
|
|
19
20
|
height: 2.5rem;
|
|
21
|
+
--_gds-segment-scroll-margin-inline: 2.25rem;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
#track {
|
|
@@ -24,6 +26,7 @@ const style = css`
|
|
|
24
26
|
display: flex;
|
|
25
27
|
flex-grow: 1;
|
|
26
28
|
scroll-snap-type: inline mandatory;
|
|
29
|
+
scroll-padding-inline: var(--_gds-segment-scroll-margin-inline);
|
|
27
30
|
overscroll-behavior-x: contain;
|
|
28
31
|
scroll-behavior: smooth;
|
|
29
32
|
overflow-x: scroll;
|
|
@@ -91,7 +94,7 @@ const style = css`
|
|
|
91
94
|
flex-grow: 1;
|
|
92
95
|
flex-shrink: 0;
|
|
93
96
|
z-index: 1;
|
|
94
|
-
scroll-margin:
|
|
97
|
+
scroll-margin-inline: var(--_gds-segment-scroll-margin-inline);
|
|
95
98
|
scroll-snap-align: start;
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -15,7 +15,7 @@ import * as Types from './table.types';
|
|
|
15
15
|
* @event gds-page-change - Fired when the active page changes. Detail: `{ page: number }`
|
|
16
16
|
* @event gds-rows-change - Fired when the rows per page value changes. Detail: `{ rows: number }`
|
|
17
17
|
* @event gds-sort-change - Fired when sorting changes. Detail: `{ sortColumn: string, sortDirection: 'asc' | 'desc' }`
|
|
18
|
-
* @event gds-table-data-loaded - Fired when data is successfully loaded.
|
|
18
|
+
* @event gds-table-data-loaded - Fired when data is successfully loaded. Detail: `{ rows: T[], total: number, page: number, rowsPerPage: number, searchQuery: string, sortColumn?: string, sortDirection?: 'asc' | 'desc' }`
|
|
19
19
|
* @event gds-table-data-error - Fired when data loading fails.
|
|
20
20
|
* @event gds-table-selection - Fired when row selection changes.
|
|
21
21
|
*/
|
|
@@ -70,6 +70,10 @@ export declare class GdsTable<T extends Types.Row = Types.Row> extends GdsElemen
|
|
|
70
70
|
* Enables row selection functionality.
|
|
71
71
|
*/
|
|
72
72
|
selectable: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Disables select all checkbox in header.
|
|
75
|
+
*/
|
|
76
|
+
disableSelectAll: boolean;
|
|
73
77
|
/**
|
|
74
78
|
* Transforms table layout for mobile screens.
|
|
75
79
|
*/
|
|
@@ -132,6 +136,17 @@ export declare class GdsTable<T extends Types.Row = Types.Row> extends GdsElemen
|
|
|
132
136
|
private _selected;
|
|
133
137
|
private _error;
|
|
134
138
|
private _onDataChange;
|
|
139
|
+
/**
|
|
140
|
+
* Syncs the external `page` property to internal view state and reloads data.
|
|
141
|
+
* Without this, setting `.page` from outside (e.g. via attribute or binding)
|
|
142
|
+
* would update the Lit property but not trigger a data fetch.
|
|
143
|
+
*/
|
|
144
|
+
private _onPageChange;
|
|
145
|
+
/**
|
|
146
|
+
* Syncs the external `rows` property to internal view state and reloads data.
|
|
147
|
+
* Resets to page 1 since changing page size invalidates the current position.
|
|
148
|
+
*/
|
|
149
|
+
private _onRowsChange;
|
|
135
150
|
private _onColumnsChange;
|
|
136
151
|
connectedCallback(): void;
|
|
137
152
|
render(): any;
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
__privateMethod,
|
|
6
6
|
__privateSet
|
|
7
7
|
} from "../../chunks/chunk.QU3DSPNU.js";
|
|
8
|
-
var _cache, _cacheDuration,
|
|
8
|
+
var _cache, _cacheDuration, _GdsTable_instances, Density_get, hasSelection_get, isAllSelected_get, isPartialSelection_get, getCacheKey_fn, isCacheValid_fn, loadData_fn, getRowKey_fn, renderCellWrapped_fn, renderMobileLabel_fn, renderSlotElement_fn, renderCellContent_fn, renderSortIcon_fn, hasHeaderContent_fn, renderHeaderControls_fn, renderColumnHeader_fn, renderActionsHeader_fn, renderSelectableHeader_fn, renderColumnHeaders_fn, renderTableHeader_fn, renderTableCell_fn, renderSelectableCell_fn, renderRowCells_fn, renderActionsCell_fn, renderTableRow_fn, renderCheckbox_fn, renderSkeletonCell_fn, renderSkeletonRow_fn, renderTableBody_fn, renderTable_fn, renderErrorState_fn, renderEmptyState_fn, renderFooter_fn, renderHeadline_fn, handleSearch_fn, handleSearchClear_fn, handleSort_fn, handlePageChange_fn, handlePageSizeChange_fn, handleColumnVisibility_fn, handleSelectAll_fn, handleRowSelect_fn, selectAllInternal_fn, clearSelectionInternal_fn, emitSelectionChange_fn, initializeScrollTracking_fn, updateVerticalScrollState_fn, updateHorizontalScrollState_fn;
|
|
9
9
|
import { localized, msg } from "@lit/localize";
|
|
10
10
|
import { property, state } from "lit/decorators.js";
|
|
11
11
|
import { classMap } from "lit/directives/class-map.js";
|
|
@@ -29,7 +29,6 @@ let GdsTable = class extends GdsElement {
|
|
|
29
29
|
__privateAdd(this, _GdsTable_instances);
|
|
30
30
|
__privateAdd(this, _cache, {});
|
|
31
31
|
__privateAdd(this, _cacheDuration, 5 * 60 * 1e3);
|
|
32
|
-
__privateAdd(this, _templateCache, /* @__PURE__ */ new Map());
|
|
33
32
|
this.headlineTag = "h2";
|
|
34
33
|
this.options = [5, 10, 20, 50, 100];
|
|
35
34
|
this.page = 1;
|
|
@@ -37,6 +36,7 @@ let GdsTable = class extends GdsElement {
|
|
|
37
36
|
this.columns = [];
|
|
38
37
|
this.density = "comfortable";
|
|
39
38
|
this.selectable = false;
|
|
39
|
+
this.disableSelectAll = false;
|
|
40
40
|
this.responsive = false;
|
|
41
41
|
this.plain = false;
|
|
42
42
|
this.searchable = false;
|
|
@@ -65,6 +65,14 @@ let GdsTable = class extends GdsElement {
|
|
|
65
65
|
__privateSet(this, _cache, {});
|
|
66
66
|
__privateMethod(this, _GdsTable_instances, loadData_fn).call(this);
|
|
67
67
|
}
|
|
68
|
+
_onPageChange() {
|
|
69
|
+
this._view = { ...this._view, page: Number(this.page ?? 1) };
|
|
70
|
+
__privateMethod(this, _GdsTable_instances, loadData_fn).call(this);
|
|
71
|
+
}
|
|
72
|
+
_onRowsChange() {
|
|
73
|
+
this._view = { ...this._view, rows: Number(this.rows ?? 10), page: 1 };
|
|
74
|
+
__privateMethod(this, _GdsTable_instances, loadData_fn).call(this);
|
|
75
|
+
}
|
|
68
76
|
_onColumnsChange() {
|
|
69
77
|
__privateSet(this, _cache, {});
|
|
70
78
|
this._view = {
|
|
@@ -147,7 +155,6 @@ let GdsTable = class extends GdsElement {
|
|
|
147
155
|
};
|
|
148
156
|
_cache = new WeakMap();
|
|
149
157
|
_cacheDuration = new WeakMap();
|
|
150
|
-
_templateCache = new WeakMap();
|
|
151
158
|
_GdsTable_instances = new WeakSet();
|
|
152
159
|
Density_get = function() {
|
|
153
160
|
return Types.DENSITY_CONFIG[this.density];
|
|
@@ -182,6 +189,18 @@ loadData_fn = async function() {
|
|
|
182
189
|
this._rowsState = cachedData.rows;
|
|
183
190
|
this._total = cachedData.total;
|
|
184
191
|
this._loaded = false;
|
|
192
|
+
this.dispatchCustomEvent("gds-table-data-loaded", {
|
|
193
|
+
detail: {
|
|
194
|
+
rows: cachedData.rows,
|
|
195
|
+
total: cachedData.total,
|
|
196
|
+
page: this._view.page,
|
|
197
|
+
rowsPerPage: this._view.rows,
|
|
198
|
+
searchQuery: this._view.searchQuery,
|
|
199
|
+
sortColumn: this._view.sortColumn,
|
|
200
|
+
sortDirection: this._view.sortDirection
|
|
201
|
+
},
|
|
202
|
+
bubbles: true
|
|
203
|
+
});
|
|
185
204
|
return;
|
|
186
205
|
}
|
|
187
206
|
}
|
|
@@ -208,7 +227,14 @@ loadData_fn = async function() {
|
|
|
208
227
|
this._selected.clear();
|
|
209
228
|
this._loaded = false;
|
|
210
229
|
this.dispatchCustomEvent("gds-table-data-loaded", {
|
|
211
|
-
detail:
|
|
230
|
+
detail: {
|
|
231
|
+
...response,
|
|
232
|
+
page: this._view.page,
|
|
233
|
+
rowsPerPage: this._view.rows,
|
|
234
|
+
searchQuery: this._view.searchQuery,
|
|
235
|
+
sortColumn: this._view.sortColumn,
|
|
236
|
+
sortDirection: this._view.sortDirection
|
|
237
|
+
},
|
|
212
238
|
bubbles: true
|
|
213
239
|
});
|
|
214
240
|
} catch (error) {
|
|
@@ -222,190 +248,64 @@ loadData_fn = async function() {
|
|
|
222
248
|
}
|
|
223
249
|
};
|
|
224
250
|
/**
|
|
225
|
-
*
|
|
226
|
-
* Uses caching to prevent repeated DOM queries for better performance in large tables.
|
|
251
|
+
* Gets the unique key for slot naming (prioritizes: custom key > row.id > index)
|
|
227
252
|
*/
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
const template = this.querySelector(
|
|
232
|
-
`template[name="${slot}"]`
|
|
233
|
-
);
|
|
234
|
-
__privateGet(this, _templateCache).set(slot, template);
|
|
253
|
+
getRowKey_fn = function(row, index, slotKey) {
|
|
254
|
+
if (typeof slotKey === "string" || typeof slotKey === "number") {
|
|
255
|
+
return slotKey;
|
|
235
256
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (!config) return null;
|
|
240
|
-
if (Array.isArray(config)) {
|
|
241
|
-
return config.map((c) => __privateMethod(this, _GdsTable_instances, renderCell_fn).call(this, c, row));
|
|
242
|
-
}
|
|
243
|
-
const resolve = (value) => typeof value === "function" ? value(row) : value;
|
|
244
|
-
switch (config.type) {
|
|
245
|
-
case "badge": {
|
|
246
|
-
const variant = resolve(config.variant) || "information";
|
|
247
|
-
const size = resolve(config.size) || __privateGet(this, _GdsTable_instances, Density_get).badge;
|
|
248
|
-
return html`
|
|
249
|
-
<gds-badge size="${size}" variant="${variant}">
|
|
250
|
-
${resolve(config.value)}
|
|
251
|
-
</gds-badge>
|
|
252
|
-
`;
|
|
253
|
-
}
|
|
254
|
-
case "image": {
|
|
255
|
-
const src = resolve(config.src);
|
|
256
|
-
if (!src) return null;
|
|
257
|
-
const width = resolve(config.width) || "24px";
|
|
258
|
-
const height = resolve(config.height) || "24px";
|
|
259
|
-
const borderRadius = resolve(config["border-radius"]) || "max";
|
|
260
|
-
const objectFit = resolve(config["object-fit"]) || "cover";
|
|
261
|
-
const alt = resolve(config.alt) || "";
|
|
262
|
-
return html`
|
|
263
|
-
<gds-img
|
|
264
|
-
src="${src}"
|
|
265
|
-
alt="${alt}"
|
|
266
|
-
width="${width}"
|
|
267
|
-
height="${height}"
|
|
268
|
-
border-radius="${borderRadius}"
|
|
269
|
-
object-fit="${objectFit}"
|
|
270
|
-
object-position="center"
|
|
271
|
-
></gds-img>
|
|
272
|
-
`;
|
|
273
|
-
}
|
|
274
|
-
case "icon": {
|
|
275
|
-
const template = resolve(config.template);
|
|
276
|
-
const size = resolve(config.size);
|
|
277
|
-
const color = resolve(config.color);
|
|
278
|
-
const clonedSlot = __privateMethod(this, _GdsTable_instances, getSlotContent_fn).call(this, template);
|
|
279
|
-
if (!clonedSlot) return null;
|
|
280
|
-
if (clonedSlot instanceof DocumentFragment) {
|
|
281
|
-
const iconElement = clonedSlot.firstElementChild;
|
|
282
|
-
if (iconElement) {
|
|
283
|
-
if (size) iconElement.setAttribute("size", size);
|
|
284
|
-
if (color) iconElement.setAttribute("color", color);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return clonedSlot;
|
|
288
|
-
}
|
|
289
|
-
case "button": {
|
|
290
|
-
const size = resolve(config.size) || __privateGet(this, _GdsTable_instances, Density_get).button;
|
|
291
|
-
const variant = resolve(config.variant);
|
|
292
|
-
const rank = resolve(config.rank);
|
|
293
|
-
const label = resolve(config.label);
|
|
294
|
-
const template = resolve(config.template);
|
|
295
|
-
const clonedSlot = __privateMethod(this, _GdsTable_instances, getSlotContent_fn).call(this, template);
|
|
296
|
-
const content = [label, clonedSlot];
|
|
297
|
-
return html`
|
|
298
|
-
<gds-button
|
|
299
|
-
size="${size}"
|
|
300
|
-
variant="${variant || "neutral"}"
|
|
301
|
-
rank="${rank || "secondary"}"
|
|
302
|
-
@click="${(e) => {
|
|
303
|
-
e.stopPropagation();
|
|
304
|
-
config.onClick(row);
|
|
305
|
-
}}"
|
|
306
|
-
>
|
|
307
|
-
${content}
|
|
308
|
-
</gds-button>
|
|
309
|
-
`;
|
|
310
|
-
}
|
|
311
|
-
case "link": {
|
|
312
|
-
const href = resolve(config.href);
|
|
313
|
-
if (!href) return null;
|
|
314
|
-
const label = resolve(config.label);
|
|
315
|
-
const target = resolve(config.target);
|
|
316
|
-
const download = resolve(config.download);
|
|
317
|
-
const template = resolve(config.template);
|
|
318
|
-
const clonedSlot = __privateMethod(this, _GdsTable_instances, getSlotContent_fn).call(this, template);
|
|
319
|
-
const content = [label, clonedSlot];
|
|
320
|
-
return html`
|
|
321
|
-
<gds-link
|
|
322
|
-
href=${ifDefined(href)}
|
|
323
|
-
target=${ifDefined(target)}
|
|
324
|
-
.download=${download}
|
|
325
|
-
text-decoration="underline"
|
|
326
|
-
>
|
|
327
|
-
${content}
|
|
328
|
-
</gds-link>
|
|
329
|
-
`;
|
|
330
|
-
}
|
|
331
|
-
case "context-menu": {
|
|
332
|
-
const items = config.items;
|
|
333
|
-
const size = __privateGet(this, _GdsTable_instances, Density_get).button;
|
|
334
|
-
return html`
|
|
335
|
-
<gds-context-menu>
|
|
336
|
-
<gds-button
|
|
337
|
-
slot="trigger"
|
|
338
|
-
size="${size}"
|
|
339
|
-
rank="tertiary"
|
|
340
|
-
label="${msg("Actions")}"
|
|
341
|
-
>
|
|
342
|
-
<gds-icon-dot-grid-one-horizontal></gds-icon-dot-grid-one-horizontal>
|
|
343
|
-
</gds-button>
|
|
344
|
-
${items.map((item) => {
|
|
345
|
-
const label = resolve(item.label);
|
|
346
|
-
return html`
|
|
347
|
-
<gds-menu-item @click="${() => item.onClick(row)}">
|
|
348
|
-
${label}
|
|
349
|
-
</gds-menu-item>
|
|
350
|
-
`;
|
|
351
|
-
})}
|
|
352
|
-
</gds-context-menu>
|
|
353
|
-
`;
|
|
354
|
-
}
|
|
355
|
-
case "formatted-number": {
|
|
356
|
-
const value = resolve(config.value);
|
|
357
|
-
const formatter = Table.FormatNumber[config.format || "decimalsAndThousands"];
|
|
358
|
-
return formatter(value, config.locale, config.currency, config.decimals);
|
|
359
|
-
}
|
|
360
|
-
case "formatted-account": {
|
|
361
|
-
const value = resolve(config.value);
|
|
362
|
-
const formatter = Table.FormatAccount[config.format || "seb-account"];
|
|
363
|
-
return formatter(value);
|
|
364
|
-
}
|
|
365
|
-
case "formatted-date": {
|
|
366
|
-
const value = resolve(config.value);
|
|
367
|
-
const formatter = Table.FormatDate[config.format || "dateLong"];
|
|
368
|
-
return formatter(value, config.locale);
|
|
369
|
-
}
|
|
370
|
-
default:
|
|
371
|
-
return null;
|
|
257
|
+
const rowId = row?.id;
|
|
258
|
+
if (typeof rowId === "string" || typeof rowId === "number") {
|
|
259
|
+
return rowId;
|
|
372
260
|
}
|
|
261
|
+
return index + 1;
|
|
262
|
+
};
|
|
263
|
+
renderCellWrapped_fn = function(content) {
|
|
264
|
+
return html`<span class="cell-wrapped-content">${content}</span>`;
|
|
265
|
+
};
|
|
266
|
+
renderMobileLabel_fn = function(column) {
|
|
267
|
+
return html`<span class="column-label" aria-hidden="true">
|
|
268
|
+
${column.label}:
|
|
269
|
+
</span>`;
|
|
270
|
+
};
|
|
271
|
+
renderSlotElement_fn = function(columnKey, rowKey, slotId) {
|
|
272
|
+
const slotName = `${columnKey}:${rowKey}:${slotId}`;
|
|
273
|
+
return html`<slot name="${slotName}"></slot>`;
|
|
373
274
|
};
|
|
374
275
|
/**
|
|
375
|
-
* Renders
|
|
376
|
-
*
|
|
276
|
+
* Renders cell content with proper ordering and wrapping.
|
|
277
|
+
*
|
|
278
|
+
* **Slot-based content:**
|
|
279
|
+
* - Renders in exact order: ['lead', 'value', 'button'] → icon, text, button
|
|
280
|
+
* - Wraps value when column.justify is set (for flexbox)
|
|
281
|
+
* - Slots stay unwrapped
|
|
377
282
|
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* 2. cell.value - Cell type configuration (badge, button, etc.)
|
|
381
|
-
* 3. row[column.key] - Raw data value
|
|
283
|
+
* **Plain content:**
|
|
284
|
+
* - Wraps when column.justify is set, otherwise renders directly
|
|
382
285
|
*/
|
|
383
|
-
renderCellContent_fn = function(row, column) {
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
286
|
+
renderCellContent_fn = function(row, column, index) {
|
|
287
|
+
const rawValue = column.value ? column.value(row) : row[column.key];
|
|
288
|
+
const isMobile = this._isMobile && this.responsive;
|
|
289
|
+
const shouldWrap = !!column.justify;
|
|
290
|
+
let content;
|
|
291
|
+
if (Types.isSlotValue(rawValue)) {
|
|
292
|
+
const rowKey = __privateMethod(this, _GdsTable_instances, getRowKey_fn).call(this, row, index, rawValue.key);
|
|
293
|
+
content = rawValue.slots.map((slotItem) => {
|
|
294
|
+
if (slotItem === "value") {
|
|
295
|
+
if (rawValue.value === void 0) return null;
|
|
296
|
+
return shouldWrap ? __privateMethod(this, _GdsTable_instances, renderCellWrapped_fn).call(this, rawValue.value) : rawValue.value;
|
|
297
|
+
}
|
|
298
|
+
return __privateMethod(this, _GdsTable_instances, renderSlotElement_fn).call(this, column.key, rowKey, slotItem);
|
|
299
|
+
});
|
|
390
300
|
} else {
|
|
391
|
-
|
|
301
|
+
content = shouldWrap ? __privateMethod(this, _GdsTable_instances, renderCellWrapped_fn).call(this, rawValue) : rawValue;
|
|
392
302
|
}
|
|
393
|
-
const processedValue = column.justify ? html`<span>${value}</span>` : value;
|
|
394
|
-
const isResponsive = this._isMobile && this.responsive;
|
|
395
|
-
const mobileLabel = isResponsive ? html`
|
|
396
|
-
<span class="column-label" aria-hidden="true">
|
|
397
|
-
${column.label}:
|
|
398
|
-
</span>
|
|
399
|
-
` : null;
|
|
400
|
-
const ariaLabel = isResponsive ? `${column.label}: ` : "";
|
|
401
303
|
return html`
|
|
402
|
-
<div
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
__privateMethod(this, _GdsTable_instances, renderCell_fn).call(this, cell?.trail, row)
|
|
408
|
-
]}
|
|
304
|
+
<div
|
|
305
|
+
class="cell-content"
|
|
306
|
+
aria-label=${ifDefined(isMobile ? column.label : void 0)}
|
|
307
|
+
>
|
|
308
|
+
${isMobile ? __privateMethod(this, _GdsTable_instances, renderMobileLabel_fn).call(this, column) : null} ${content}
|
|
409
309
|
</div>
|
|
410
310
|
`;
|
|
411
311
|
};
|
|
@@ -549,7 +449,8 @@ renderSelectableHeader_fn = function() {
|
|
|
549
449
|
checked: __privateGet(this, _GdsTable_instances, isAllSelected_get),
|
|
550
450
|
indeterminate: __privateGet(this, _GdsTable_instances, isPartialSelection_get),
|
|
551
451
|
ariaLabel: msg("Select all rows"),
|
|
552
|
-
onToggle: () => __privateMethod(this, _GdsTable_instances, handleSelectAll_fn).call(this, {})
|
|
452
|
+
onToggle: () => __privateMethod(this, _GdsTable_instances, handleSelectAll_fn).call(this, {}),
|
|
453
|
+
skip: this.disableSelectAll
|
|
553
454
|
})}
|
|
554
455
|
</th>
|
|
555
456
|
`;
|
|
@@ -570,7 +471,7 @@ renderTableHeader_fn = function() {
|
|
|
570
471
|
</thead>
|
|
571
472
|
`;
|
|
572
473
|
};
|
|
573
|
-
renderTableCell_fn = function(row, column) {
|
|
474
|
+
renderTableCell_fn = function(row, column, index) {
|
|
574
475
|
const classes = classMap({
|
|
575
476
|
[`align-${column.align}`]: !!column.align,
|
|
576
477
|
[`justify-${column.justify}`]: !!column.justify,
|
|
@@ -581,7 +482,7 @@ renderTableCell_fn = function(row, column) {
|
|
|
581
482
|
});
|
|
582
483
|
return html`
|
|
583
484
|
<td style=${style} class=${classes}>
|
|
584
|
-
${__privateMethod(this, _GdsTable_instances, renderCellContent_fn).call(this, row, column)}
|
|
485
|
+
${__privateMethod(this, _GdsTable_instances, renderCellContent_fn).call(this, row, column, index)}
|
|
585
486
|
</td>
|
|
586
487
|
`;
|
|
587
488
|
};
|
|
@@ -601,8 +502,8 @@ renderSelectableCell_fn = function(index) {
|
|
|
601
502
|
</td>
|
|
602
503
|
`;
|
|
603
504
|
};
|
|
604
|
-
renderRowCells_fn = function(row) {
|
|
605
|
-
return this.columns.filter((column) => this._view.visibleColumns.has(column.key)).map((column) => __privateMethod(this, _GdsTable_instances, renderTableCell_fn).call(this, row, column));
|
|
505
|
+
renderRowCells_fn = function(row, index) {
|
|
506
|
+
return this.columns.filter((column) => this._view.visibleColumns.has(column.key)).map((column) => __privateMethod(this, _GdsTable_instances, renderTableCell_fn).call(this, row, column, index));
|
|
606
507
|
};
|
|
607
508
|
renderActionsCell_fn = function(row, index) {
|
|
608
509
|
if (!this.actions) return null;
|
|
@@ -613,7 +514,7 @@ renderActionsCell_fn = function(row, index) {
|
|
|
613
514
|
</td>
|
|
614
515
|
`;
|
|
615
516
|
}
|
|
616
|
-
const
|
|
517
|
+
const rowKey = __privateMethod(this, _GdsTable_instances, getRowKey_fn).call(this, row, index);
|
|
617
518
|
const classes = classMap({
|
|
618
519
|
"actions-cell": true,
|
|
619
520
|
[`align-${this.actions.align}`]: !!this.actions.align,
|
|
@@ -621,7 +522,9 @@ renderActionsCell_fn = function(row, index) {
|
|
|
621
522
|
});
|
|
622
523
|
return html`
|
|
623
524
|
<td class="${classes}">
|
|
624
|
-
<div class="cell-content"
|
|
525
|
+
<div class="cell-content">
|
|
526
|
+
${__privateMethod(this, _GdsTable_instances, renderSlotElement_fn).call(this, "actions", rowKey, "main")}
|
|
527
|
+
</div>
|
|
625
528
|
</td>
|
|
626
529
|
`;
|
|
627
530
|
};
|
|
@@ -635,7 +538,7 @@ renderTableRow_fn = function(row, index) {
|
|
|
635
538
|
>
|
|
636
539
|
${[
|
|
637
540
|
__privateMethod(this, _GdsTable_instances, renderSelectableCell_fn).call(this, index),
|
|
638
|
-
__privateMethod(this, _GdsTable_instances, renderRowCells_fn).call(this, row),
|
|
541
|
+
__privateMethod(this, _GdsTable_instances, renderRowCells_fn).call(this, row, index),
|
|
639
542
|
__privateMethod(this, _GdsTable_instances, renderActionsCell_fn).call(this, row, index)
|
|
640
543
|
]}
|
|
641
544
|
</tr>
|
|
@@ -646,8 +549,10 @@ renderCheckbox_fn = function({
|
|
|
646
549
|
indeterminate = false,
|
|
647
550
|
disabled = false,
|
|
648
551
|
ariaLabel,
|
|
649
|
-
onToggle
|
|
552
|
+
onToggle,
|
|
553
|
+
skip = false
|
|
650
554
|
}) {
|
|
555
|
+
if (skip) return null;
|
|
651
556
|
const toggle = (e) => {
|
|
652
557
|
e.stopPropagation();
|
|
653
558
|
if (disabled) return;
|
|
@@ -1072,6 +977,13 @@ __decorateClass([
|
|
|
1072
977
|
__decorateClass([
|
|
1073
978
|
property({ type: Boolean, reflect: false })
|
|
1074
979
|
], GdsTable.prototype, "selectable", 2);
|
|
980
|
+
__decorateClass([
|
|
981
|
+
property({
|
|
982
|
+
attribute: "disable-select-all",
|
|
983
|
+
type: Boolean,
|
|
984
|
+
reflect: false
|
|
985
|
+
})
|
|
986
|
+
], GdsTable.prototype, "disableSelectAll", 2);
|
|
1075
987
|
__decorateClass([
|
|
1076
988
|
property({ type: Boolean, reflect: false })
|
|
1077
989
|
], GdsTable.prototype, "responsive", 2);
|
|
@@ -1137,6 +1049,12 @@ __decorateClass([
|
|
|
1137
1049
|
watch("dataLoadKey"),
|
|
1138
1050
|
watch("data")
|
|
1139
1051
|
], GdsTable.prototype, "_onDataChange", 1);
|
|
1052
|
+
__decorateClass([
|
|
1053
|
+
watch("page", { waitUntilFirstUpdate: true })
|
|
1054
|
+
], GdsTable.prototype, "_onPageChange", 1);
|
|
1055
|
+
__decorateClass([
|
|
1056
|
+
watch("rows", { waitUntilFirstUpdate: true })
|
|
1057
|
+
], GdsTable.prototype, "_onRowsChange", 1);
|
|
1140
1058
|
__decorateClass([
|
|
1141
1059
|
watch("columns")
|
|
1142
1060
|
], GdsTable.prototype, "_onColumnsChange", 1);
|
|
@@ -1,53 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
id: number;
|
|
4
|
-
name: string;
|
|
5
|
-
email: string;
|
|
6
|
-
role: 'Admin' | 'User' | 'Editor';
|
|
7
|
-
status: 'Active' | 'Inactive';
|
|
8
|
-
amount: number;
|
|
9
|
-
account: string;
|
|
10
|
-
lastLogin: string;
|
|
11
|
-
avatarUrl?: string;
|
|
12
|
-
department?: string;
|
|
13
|
-
download?: string;
|
|
14
|
-
}
|
|
15
|
-
interface FeedbackData {
|
|
16
|
-
id: number;
|
|
17
|
-
name: string;
|
|
18
|
-
email: string;
|
|
19
|
-
feedback: string;
|
|
20
|
-
notes: string;
|
|
21
|
-
status: 'Active' | 'Inactive';
|
|
22
|
-
department: string;
|
|
23
|
-
}
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import type { TableActions, TableColumn, TableRequest, TableResponse } from './table.types';
|
|
24
3
|
export declare const Users: {
|
|
25
4
|
Columns: TableColumn[];
|
|
26
|
-
Actions:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
divider: boolean;
|
|
39
|
-
label: string;
|
|
40
|
-
})[];
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
Data: (request: TableRequest) => Promise<TableResponse<UserData>>;
|
|
5
|
+
Actions: TableActions;
|
|
6
|
+
Data: (request: TableRequest) => Promise<TableResponse<any>>;
|
|
7
|
+
/**
|
|
8
|
+
* Generates slot content for the given rows (current page).
|
|
9
|
+
* Creates per-row slot elements using `columnKey:rowKey:slotId` convention.
|
|
10
|
+
*
|
|
11
|
+
* Used with Lit's `render()` to update table light DOM on each data load:
|
|
12
|
+
* ```ts
|
|
13
|
+
* @gds-table-data-loaded=${(e) => render(Users.SlotContent(e.detail.rows), table)}
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
SlotContent: (rows: any[]) => TemplateResult;
|
|
44
17
|
};
|
|
45
18
|
export declare const Feedback: {
|
|
46
19
|
Columns: TableColumn[];
|
|
47
|
-
MultipleActions:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
20
|
+
MultipleActions: TableActions;
|
|
21
|
+
/**
|
|
22
|
+
* Slot content: multiple button actions per row.
|
|
23
|
+
*/
|
|
24
|
+
MultipleActionsSlotContent: (rows: any[]) => TemplateResult;
|
|
25
|
+
ActionLink: TableActions & {
|
|
26
|
+
cell: unknown[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Slot content: link action per row.
|
|
30
|
+
*/
|
|
31
|
+
ActionLinkSlotContent: (rows: any[]) => TemplateResult;
|
|
32
|
+
ActionButton: TableActions;
|
|
33
|
+
ActionContextMenu: TableActions;
|
|
34
|
+
/**
|
|
35
|
+
* Slot content: context menu action per row.
|
|
36
|
+
*/
|
|
37
|
+
ActionContextMenuSlotContent: (rows: any[]) => TemplateResult;
|
|
38
|
+
Data: (request: TableRequest) => Promise<TableResponse<any>>;
|
|
52
39
|
};
|
|
53
|
-
export {};
|