dap-design-system 0.61.11 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,56 +1,66 @@
1
- var I = Object.defineProperty, L = Object.defineProperties;
2
- var A = Object.getOwnPropertyDescriptors;
3
- var B = Object.getOwnPropertySymbols;
4
- var O = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
5
- var _ = (d, t, e) => t in d ? I(d, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[t] = e, m = (d, t) => {
1
+ var O = Object.defineProperty, M = Object.defineProperties;
2
+ var N = Object.getOwnPropertyDescriptors;
3
+ var C = Object.getOwnPropertySymbols;
4
+ var I = Object.prototype.hasOwnProperty, P = Object.prototype.propertyIsEnumerable;
5
+ var B = (d, t, e) => t in d ? O(d, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[t] = e, m = (d, t) => {
6
6
  for (var e in t || (t = {}))
7
- O.call(t, e) && _(d, e, t[e]);
8
- if (B)
9
- for (var e of B(t))
10
- E.call(t, e) && _(d, e, t[e]);
7
+ I.call(t, e) && B(d, e, t[e]);
8
+ if (C)
9
+ for (var e of C(t))
10
+ P.call(t, e) && B(d, e, t[e]);
11
11
  return d;
12
- }, y = (d, t) => L(d, A(t));
13
- import { TableController as H, flexRender as C } from "../../node_modules/@tanstack/lit-table/build/lib/index.js";
14
- import { clsx as f } from "../../node_modules/clsx/dist/clsx.js";
12
+ }, S = (d, t) => M(d, N(t));
13
+ var E = (d) => typeof d == "symbol" ? d : d + "", T = (d, t) => {
14
+ var e = {};
15
+ for (var i in d)
16
+ I.call(d, i) && t.indexOf(i) < 0 && (e[i] = d[i]);
17
+ if (d != null && C)
18
+ for (var i of C(d))
19
+ t.indexOf(i) < 0 && P.call(d, i) && (e[i] = d[i]);
20
+ return e;
21
+ };
22
+ import { TableController as U, flexRender as R } from "../../node_modules/@tanstack/lit-table/build/lib/index.js";
23
+ import { clsx as y } from "../../node_modules/clsx/dist/clsx.js";
15
24
  import "../../node_modules/@lit/reactive-element/reactive-element.js";
16
- import { nothing as z } from "../../node_modules/lit-html/lit-html.js";
25
+ import { nothing as f } from "../../node_modules/lit-html/lit-html.js";
17
26
  import "../../node_modules/lit-element/lit-element.js";
18
- import { property as a } from "../../node_modules/@lit/reactive-element/decorators/property.js";
19
- import { state as $ } from "../../node_modules/@lit/reactive-element/decorators/state.js";
20
- import { ifDefined as u } from "../../node_modules/lit-html/directives/if-defined.js";
21
- import { repeat as S } from "../../node_modules/lit-html/directives/repeat.js";
22
- import { html as p, unsafeStatic as P } from "../../node_modules/lit-html/static.js";
23
- import { DdsElement as M } from "../../internal/dds-hu-element.js";
27
+ import { property as l } from "../../node_modules/@lit/reactive-element/decorators/property.js";
28
+ import { state as z } from "../../node_modules/@lit/reactive-element/decorators/state.js";
29
+ import { ifDefined as b } from "../../node_modules/lit-html/directives/if-defined.js";
30
+ import { repeat as w } from "../../node_modules/lit-html/directives/repeat.js";
31
+ import { html as p, unsafeStatic as L } from "../../node_modules/lit-html/static.js";
32
+ import { DdsElement as K } from "../../internal/dds-hu-element.js";
24
33
  import "../../localization/localization.js";
25
- import D from "../checkbox/checkbox.component.js";
26
- import N from "../icons/arrows/arrows-arrow-down-s-line/arrows-arrow-down-s-line.component.js";
27
- import U from "../icons/arrows/arrows-arrow-up-s-line/arrows-arrow-up-s-line.component.js";
28
- import j from "../pager/pager.component.js";
29
- import K from "../skeleton/skeleton.component.js";
30
- import F from "../spinner/spinner.component.js";
31
- import q from "./datatable.scss.js";
32
- import { renderCellContent as G } from "./utils/cell-renderer.js";
33
- import { t as c } from "../../node_modules/i18next/dist/esm/i18next.js";
34
- import { getPaginationRowModel as V, getSortedRowModel as X, getCoreRowModel as J } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
35
- import { unsafeCSS as Q } from "../../node_modules/@lit/reactive-element/css-tag.js";
36
- var W = Object.defineProperty, i = (d, t, e, l) => {
37
- for (var r = void 0, n = d.length - 1, s; n >= 0; n--)
38
- (s = d[n]) && (r = s(t, e, r) || r);
39
- return r && W(t, e, r), r;
34
+ import F from "../checkbox/checkbox.component.js";
35
+ import j from "../icons/arrows/arrows-arrow-down-s-line/arrows-arrow-down-s-line.component.js";
36
+ import W from "../icons/arrows/arrows-arrow-up-s-line/arrows-arrow-up-s-line.component.js";
37
+ import X from "../pager/pager.component.js";
38
+ import Z from "../skeleton/skeleton.component.js";
39
+ import G from "../spinner/spinner.component.js";
40
+ import V from "./datatable.scss.js";
41
+ import { renderCellContent as Y } from "./utils/cell-renderer.js";
42
+ import { t as u } from "../../node_modules/i18next/dist/esm/i18next.js";
43
+ import { getPaginationRowModel as q, getSortedRowModel as J, getCoreRowModel as Q } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
44
+ import { unsafeCSS as tt } from "../../node_modules/@lit/reactive-element/css-tag.js";
45
+ var et = Object.defineProperty, r = (d, t, e, i) => {
46
+ for (var n = void 0, s = d.length - 1, o; s >= 0; s--)
47
+ (o = d[s]) && (n = o(t, e, n) || n);
48
+ return n && et(t, e, n), n;
40
49
  };
41
- const k = "__multiSelect__", w = class w extends M {
50
+ const x = "__multiSelect__", it = 40, A = 10, $ = class $ extends K {
42
51
  constructor() {
43
- super(...arguments), this.tableController = new H(this), this.stickyOffsets = /* @__PURE__ */ new Map(), this.data = [], this.columns = [], this.rowKey = "id", this.enableRowSelection = !1, this.stickySelectionColumn = !1, this.enableSorting = !1, this.manualSorting = !1, this.manualPagination = !1, this.autoResetPageIndex = !1, this.enableRowClick = !1, this.loading = !1, this.enableStripedRows = !1, this.loadingType = "spinner", this.loadingVariant = "neutral", this.loadingSize = "lg", this.disableHeaderOnEmpty = "true", this.showPagerOnEmpty = !1, this.pager = !1, this.showPageSizeOptions = "true", this.showPageIndex = "true", this.showPageCount = "true", this.showFirstButton = "true", this.showPreviousButton = "true", this.showNextButton = "true", this.showLastButton = "true", this.showPageNumbers = "false", this.siblingCount = 1, this.sortButtonTestId = "datatable-sort-button", this.pageSizeOptions = [10, 25, 50, 100], this._sorting = [], this._rowSelection = {}, this._pagination = {
52
+ super(...arguments), this.tableController = new U(this), this.stickyOffsets = /* @__PURE__ */ new Map(), this.data = [], this.columns = [], this.rowKey = "id", this.enableRowSelection = !1, this.stickySelectionColumn = !1, this.enableSorting = !1, this.enableColumnResizing = !1, this.manualSorting = !1, this.manualPagination = !1, this.autoResetPageIndex = !1, this.enableRowClick = !1, this.loading = !1, this.enableStripedRows = !1, this.loadingType = "spinner", this.loadingVariant = "neutral", this.loadingSize = "lg", this.disableHeaderOnEmpty = "true", this.showPagerOnEmpty = !1, this.pager = !1, this.showPageSizeOptions = "true", this.showPageIndex = "true", this.showPageCount = "true", this.showFirstButton = "true", this.showPreviousButton = "true", this.showNextButton = "true", this.showLastButton = "true", this.showPageNumbers = "false", this.siblingCount = 1, this.sortButtonTestId = "datatable-sort-button", this.pageSizeOptions = [10, 25, 50, 100], this._sorting = [], this._rowSelection = {}, this._pagination = {
44
53
  pageIndex: 0,
45
54
  pageSize: 10
46
55
  }, this._columnSizing = {}, this.ariaLabel = null, this._statusMessage = "", this.debug = !1, this.columnsMemo = () => {
47
- const t = this.columns.map((e) => !e.size && !e.minSize && !e.maxSize ? y(m({}, e), { minSize: 0 }) : e);
56
+ const t = this.columns.map((e) => !e.size && !e.minSize && !e.maxSize ? S(m({}, e), { minSize: 0 }) : e);
48
57
  return [
49
- ...this.enableRowSelection && this.columns[0] && this.columns[0].id !== k ? [
50
- y(m({
51
- id: k,
52
- accessorKey: k,
58
+ ...this.enableRowSelection && this.columns[0] && this.columns[0].id !== x ? [
59
+ S(m({
60
+ id: x,
61
+ accessorKey: x,
53
62
  enableSorting: !1,
63
+ enableResizing: !1,
54
64
  size: 50,
55
65
  maxSize: 50
56
66
  }, this.stickySelectionColumn ? { sticky: "left" } : {}), {
@@ -70,50 +80,50 @@ const k = "__multiSelect__", w = class w extends M {
70
80
  ...t
71
81
  ];
72
82
  }, this.renderColgroup = (t) => {
73
- const e = this.columnsMemo(), l = this.columnSizing || this._columnSizing;
83
+ const e = this.columnsMemo(), i = this._columnSizing;
74
84
  return p`
75
85
  <colgroup>
76
- ${S(
86
+ ${w(
77
87
  e,
78
- (r, n) => r.id || `col-${n}`,
79
- (r) => {
80
- const n = r;
81
- let s;
82
- return l && n.id && l[n.id] ? s = `${l[n.id]}px` : n.size ? s = `${n.size}px` : s = "auto", p`<col style="width: ${s};" />`;
88
+ (n, s) => n.id || `col-${s}`,
89
+ (n) => {
90
+ const s = n;
91
+ let o;
92
+ return i && s.id && i[s.id] ? o = `${i[s.id]}px` : s.size ? o = `${s.size}px` : o = "auto", p`<col style="width: ${o};" />`;
83
93
  }
84
94
  )}
85
95
  </colgroup>
86
96
  `;
87
97
  }, this.renderHeader = (t) => p`
88
98
  <thead part="header">
89
- ${S(
99
+ ${w(
90
100
  t.getHeaderGroups(),
91
101
  (e) => e.id,
92
102
  (e) => p`
93
103
  <tr
94
104
  part="header-row"
95
- class=${f("data-table-header-row", {
105
+ class=${y("data-table-header-row", {
96
106
  "data-table-header-row--striped": this.enableStripedRows
97
107
  })}>
98
- ${S(
108
+ ${w(
99
109
  e.headers,
100
- (l) => l.id,
101
- (l) => this.renderHeaderCell(l)
110
+ (i) => i.id,
111
+ (i) => this.renderHeaderCell(i)
102
112
  )}
103
113
  </tr>
104
114
  `
105
115
  )}
106
116
  </thead>
107
117
  `, this.renderSkeletonRows = (t, e) => p`
108
- ${S(
109
- Array.from({ length: t }, (l, r) => r),
110
- (l) => l,
111
- (l) => p`
118
+ ${w(
119
+ Array.from({ length: t }, (i, n) => n),
120
+ (i) => i,
121
+ (i) => p`
112
122
  <tr class="data-table-row">
113
- ${S(
114
- Array.from({ length: e }, (r, n) => n),
115
- (r) => r,
116
- (r) => p`<td class="data-table-cell">
123
+ ${w(
124
+ Array.from({ length: e }, (n, s) => s),
125
+ (n) => n,
126
+ (n) => p`<td class="data-table-cell">
117
127
  <dap-ds-skeleton></dap-ds-skeleton>
118
128
  </td>`
119
129
  )}
@@ -121,7 +131,7 @@ const k = "__multiSelect__", w = class w extends M {
121
131
  `
122
132
  )}
123
133
  `, this.renderBody = (t) => {
124
- var e, l;
134
+ var e, i;
125
135
  return p`
126
136
  ${this.loading ? p`<tbody part="body">
127
137
  ${this.loadingType === "spinner" ? p`
@@ -155,40 +165,40 @@ const k = "__multiSelect__", w = class w extends M {
155
165
  <div part="empty" class="data-table-placeholder">
156
166
  <slot name="empty">
157
167
  <span
158
- >${(l = this.emptyText) != null ? l : c("datatable.noData")}</span
168
+ >${(i = this.emptyText) != null ? i : u("datatable.noData")}</span
159
169
  >
160
170
  </slot>
161
171
  </div>
162
172
  </td>
163
173
  </tr>` : t.getRowModel().rows.map(
164
- (r, n) => p`
174
+ (n, s) => p`
165
175
  <tr
166
176
  part="row"
167
177
  role=${this.enableRowClick ? "button" : "row"}
168
178
  tabindex=${this.enableRowClick ? 0 : -1}
169
- aria-selected=${r.getIsSelected()}
170
- aria-rowindex=${n + 2}
171
- class=${f("data-table-row", {
172
- "data-table-row--selected": r.getIsSelected(),
179
+ aria-selected=${n.getIsSelected()}
180
+ aria-rowindex=${s + 2}
181
+ class=${y("data-table-row", {
182
+ "data-table-row--selected": n.getIsSelected(),
173
183
  "data-table-row--clickable": this.enableRowClick,
174
184
  "data-table-row--striped": this.enableStripedRows
175
185
  })}
176
- @click=${() => this.handleRowClick(r)}
177
- @keydown=${(s) => this.handleRowKeydown(s, r)}>
178
- ${r.getVisibleCells().map((s) => {
179
- const g = s.column.columnDef, h = this.stickyOffsets.get(s.column.id), b = [
186
+ @click=${() => this.handleRowClick(n)}
187
+ @keydown=${(o) => this.handleRowKeydown(o, n)}>
188
+ ${n.getVisibleCells().map((o) => {
189
+ const g = o.column.columnDef, c = this.stickyOffsets.get(o.column.id), h = [
180
190
  g.textAlign && `text-align: ${g.textAlign};`,
181
- this.getStickyStyle(s.column.id)
191
+ this.getStickyStyle(o.column.id)
182
192
  ].filter(Boolean).join(" ") || void 0;
183
193
  return p`
184
194
  <td
185
195
  part="cell"
186
- class=${f(
196
+ class=${y(
187
197
  "data-table-cell",
188
- h && `data-table-cell--sticky-${h.side}`
198
+ c && `data-table-cell--sticky-${c.side}`
189
199
  )}
190
- style="${u(b)}">
191
- ${this.renderCell(s)}
200
+ style="${b(h)}">
201
+ ${this.renderCell(o)}
192
202
  </td>
193
203
  `;
194
204
  })}
@@ -209,10 +219,16 @@ const k = "__multiSelect__", w = class w extends M {
209
219
  return this.disableHeaderOnEmpty === "true" && this.isTableEmpty;
210
220
  }
211
221
  firstUpdated(t) {
212
- super.firstUpdated(t), this.sorting && (this._sorting = this.sorting), this.rowSelection && (this._rowSelection = this.rowSelection), this.pagination ? this._pagination = this.pagination : this.pageSizeOptions && this.pageSizeOptions.length > 0 && (this._pagination = y(m({}, this._pagination), {
222
+ super.firstUpdated(t), this.sorting && (this._sorting = this.sorting), this.rowSelection && (this._rowSelection = this.rowSelection), this.pagination ? this._pagination = this.pagination : this.pageSizeOptions && this.pageSizeOptions.length > 0 && (this._pagination = S(m({}, this._pagination), {
213
223
  pageSize: this.pageSizeOptions[0]
214
224
  }));
215
225
  }
226
+ // Synced before render (not in updated()) so restored widths paint in the same
227
+ // frame instead of one render late
228
+ willUpdate(t) {
229
+ var e;
230
+ super.willUpdate(t), t.has("columnSizing") && (this._columnSizing = (e = this.columnSizing) != null ? e : {});
231
+ }
216
232
  updated(t) {
217
233
  super.updated(t), t.has("pagination") && (this._pagination = this.pagination), t.has("sorting") && (this._sorting = this.sorting), (t.has("rowSelection") || t.has("rowselection")) && (this._rowSelection = this.rowSelection), t.has("data") && this.requestUpdate();
218
234
  }
@@ -227,15 +243,15 @@ const k = "__multiSelect__", w = class w extends M {
227
243
  // that side). getSize() resolves to the column's `size`, so a pinned column
228
244
  // without a size contributes 0 and the next one on that side would overlap it.
229
245
  computeStickyOffsets(t) {
230
- const e = /* @__PURE__ */ new Map(), l = t.getVisibleLeafColumns();
231
- let r = 0;
232
- for (let s = l.length - 1; s >= 0; s--) {
233
- const g = l[s];
234
- g.columnDef.sticky === "right" && (e.set(g.id, { side: "right", offset: r }), r += g.getSize());
235
- }
246
+ const e = /* @__PURE__ */ new Map(), i = t.getVisibleLeafColumns();
236
247
  let n = 0;
237
- for (const s of l)
238
- s.columnDef.sticky === "left" && (e.set(s.id, { side: "left", offset: n }), n += s.getSize());
248
+ for (let o = i.length - 1; o >= 0; o--) {
249
+ const g = i[o];
250
+ g.columnDef.sticky === "right" && (e.set(g.id, { side: "right", offset: n }), n += g.getSize());
251
+ }
252
+ let s = 0;
253
+ for (const o of i)
254
+ o.columnDef.sticky === "left" && (e.set(o.id, { side: "left", offset: s }), s += o.getSize());
239
255
  this.stickyOffsets = e;
240
256
  }
241
257
  // Inline sticky positioning for a pinned column. z-index lifts the cell above
@@ -248,57 +264,159 @@ const k = "__multiSelect__", w = class w extends M {
248
264
  return `position: sticky; ${e.side}: ${e.offset}px; z-index: 1;`;
249
265
  }
250
266
  renderHeaderCell(t, e = !1) {
251
- var v;
252
- const l = t.column.columnDef, r = t.column.getCanSort(), n = t.column.getIsSorted(), s = t.column.getNextSortingOrder(), g = (v = l.disableDefaultSorting) != null ? v : !1, h = this.stickyOffsets.get(t.column.id), b = [this.getHeaderCellStyle(t), this.getStickyStyle(t.column.id)].filter(Boolean).join(" ") || void 0, x = l.headerTextAlign ? `justify-content: ${l.headerTextAlign};` : void 0, R = this.getSortIcon(n), T = this.getSortTitle(r, s);
267
+ var k;
268
+ const i = t.column.columnDef, n = t.column.getCanSort(), s = t.column.getIsSorted(), o = t.column.getNextSortingOrder(), g = (k = i.disableDefaultSorting) != null ? k : !1, c = this.stickyOffsets.get(t.column.id), h = [this.getHeaderCellStyle(t), this.getStickyStyle(t.column.id)].filter(Boolean).join(" ") || void 0, v = i.headerTextAlign ? `justify-content: ${i.headerTextAlign};` : void 0, D = this.getSortIcon(s), H = this.getSortTitle(n, o), _ = this.getCanResize(t);
253
269
  return p`
254
270
  <th
255
271
  colspan="${t.colSpan}"
256
272
  rowspan="${t.rowSpan}"
257
273
  part="header-cell"
258
- class=${f(
274
+ id="${this.getHeaderCellId(t.column.id)}"
275
+ class=${y(
259
276
  "data-table-header-cell",
260
- h && `data-table-header-cell--sticky-${h.side}`
277
+ c && `data-table-header-cell--sticky-${c.side}`,
278
+ _ && "data-table-header-cell--resizable"
261
279
  )}
262
280
  scope="col"
263
- aria-sort=${r && !this.shouldDisableHeaderActions ? this.getAriaSortValue(n) : "none"}
264
- style="${u(b)}">
281
+ aria-sort=${n && !this.shouldDisableHeaderActions ? this.getAriaSortValue(s) : "none"}
282
+ style="${b(h)}">
265
283
  ${this.renderHeaderCellContent(
266
284
  t,
267
- l,
268
- r,
285
+ i,
286
+ n,
269
287
  g,
270
- T,
271
- x,
272
- R
288
+ H,
289
+ v,
290
+ D
273
291
  )}
292
+ ${_ ? this.renderResizeHandle(t) : f}
274
293
  </th>
275
294
  `;
276
295
  }
277
- renderHeaderCellContent(t, e, l, r, n, s, g) {
278
- if (!l)
279
- return C(e.header, t.getContext());
280
- const h = r || this.shouldDisableHeaderActions ? "div" : "dap-ds-button", b = !r && !this.shouldDisableHeaderActions ? t.column.getToggleSortingHandler() : null, x = l && !this.shouldDisableHeaderActions ? "pointer" : "not-allowed";
281
- return p`<${P(h)}
296
+ getHeaderCellId(t) {
297
+ return `data-table-header-${t}`;
298
+ }
299
+ getCanResize(t) {
300
+ const e = t.column.columnDef;
301
+ return this.enableColumnResizing && t.colSpan === 1 && t.column.id !== x && e.enableResizing !== !1;
302
+ }
303
+ getResizeBounds(t) {
304
+ const { minSize: e, maxSize: i } = t.column.columnDef;
305
+ return {
306
+ min: e || it,
307
+ max: i && i < Number.MAX_SAFE_INTEGER ? i : void 0
308
+ };
309
+ }
310
+ // A resize steps from the column's nominal width (its resized width, else its
311
+ // defined size), not the rendered one: a fixed-layout table narrower than its
312
+ // container stretches every column, and feeding that stretch back in would
313
+ // make each step overshoot. Only an `auto` column has no nominal width, so it
314
+ // starts from what is on screen.
315
+ getStartWidth(t, e) {
316
+ var s;
317
+ const i = (s = this._columnSizing[t.column.id]) != null ? s : t.column.columnDef.size;
318
+ if (i) return i;
319
+ const n = e.closest("th");
320
+ return (n == null ? void 0 : n.getBoundingClientRect().width) || t.column.getSize();
321
+ }
322
+ setColumnWidth(t, e) {
323
+ const { min: i, max: n } = this.getResizeBounds(t), s = Math.round(
324
+ Math.min(Math.max(e, i), n != null ? n : Number.POSITIVE_INFINITY)
325
+ );
326
+ return this._columnSizing[t.column.id] === s ? !1 : (this._columnSizing = S(m({}, this._columnSizing), { [t.column.id]: s }), !0);
327
+ }
328
+ emitColumnSizingChange() {
329
+ this.emit("dds-column-sizing-change", {
330
+ columnSizing: m({}, this._columnSizing)
331
+ });
332
+ }
333
+ handleResizePointerDown(t, e) {
334
+ if (t.button !== 0) return;
335
+ t.preventDefault(), t.stopPropagation();
336
+ const i = t.currentTarget, n = t.clientX, s = this.getStartWidth(e, i);
337
+ let o = !1;
338
+ try {
339
+ i.setPointerCapture(t.pointerId);
340
+ } catch (h) {
341
+ }
342
+ this.toggleAttribute("resizing", !0);
343
+ const g = (h) => {
344
+ o = this.setColumnWidth(e, s + h.clientX - n) || o;
345
+ }, c = () => {
346
+ window.removeEventListener("pointermove", g), window.removeEventListener("pointerup", c), window.removeEventListener("pointercancel", c), this.toggleAttribute("resizing", !1), o && this.emitColumnSizingChange();
347
+ };
348
+ window.addEventListener("pointermove", g), window.addEventListener("pointerup", c), window.addEventListener("pointercancel", c);
349
+ }
350
+ handleResizeKeydown(t, e) {
351
+ const { min: i, max: n } = this.getResizeBounds(e), s = this.getStartWidth(e, t.currentTarget), o = {
352
+ ArrowLeft: s - A,
353
+ ArrowRight: s + A,
354
+ Home: i,
355
+ End: n
356
+ };
357
+ if (!(t.key in o)) return;
358
+ t.preventDefault(), t.stopPropagation();
359
+ const g = o[t.key];
360
+ g !== void 0 && this.setColumnWidth(e, g) && this.emitColumnSizingChange();
361
+ }
362
+ // Double-click drops the override, so the column falls back to its defined size
363
+ handleResizeReset(t, e) {
364
+ var s;
365
+ if (t.preventDefault(), t.stopPropagation(), !(e.column.id in this._columnSizing)) return;
366
+ const o = this._columnSizing, { [s = e.column.id]: i } = o, n = T(o, [E(s)]);
367
+ this._columnSizing = n, this.emitColumnSizingChange();
368
+ }
369
+ // A focusable splitter (WAI-ARIA window splitter pattern): drag with the
370
+ // pointer, ArrowLeft/ArrowRight to step, Home/End for the bounds. It is a
371
+ // sibling of the sort button, so its clicks never toggle sorting.
372
+ renderResizeHandle(t) {
373
+ var s;
374
+ const { min: e, max: i } = this.getResizeBounds(t), n = Math.round(
375
+ (s = this._columnSizing[t.column.id]) != null ? s : t.column.getSize()
376
+ );
377
+ return p`<div
378
+ part="resize-handle"
379
+ class="data-table-resize-handle"
380
+ role="separator"
381
+ tabindex="0"
382
+ aria-orientation="vertical"
383
+ aria-labelledby="data-table-resize-label ${this.getHeaderCellId(
384
+ t.column.id
385
+ )}"
386
+ aria-valuenow=${n}
387
+ aria-valuemin=${e}
388
+ aria-valuemax=${b(i)}
389
+ @pointerdown=${(o) => this.handleResizePointerDown(o, t)}
390
+ @keydown=${(o) => this.handleResizeKeydown(o, t)}
391
+ @dblclick=${(o) => this.handleResizeReset(o, t)}
392
+ @click=${(o) => o.stopPropagation()}></div>`;
393
+ }
394
+ renderHeaderCellContent(t, e, i, n, s, o, g) {
395
+ if (!i)
396
+ return R(e.header, t.getContext());
397
+ const c = n || this.shouldDisableHeaderActions ? "div" : "dap-ds-button", h = !n && !this.shouldDisableHeaderActions ? t.column.getToggleSortingHandler() : null, v = i && !this.shouldDisableHeaderActions ? "pointer" : "not-allowed";
398
+ return p`<${L(c)}
282
399
  class="data-table-header-cell__controller"
283
400
  variant="clean"
284
401
  data-testid="${this.sortButtonTestId}-${t.column.id}"
285
- title=${u(n)}
286
- @click="${b}"
287
- style="cursor: ${x}">
402
+ title=${b(s)}
403
+ @click="${h}"
404
+ style="cursor: ${v}">
288
405
  <span
289
406
  part="content"
290
407
  class="data-table-header-cell__content"
291
- style="${u(s)}">
292
- ${C(e.header, t.getContext())}
408
+ style="${b(o)}">
409
+ ${R(e.header, t.getContext())}
293
410
  ${g}
294
411
  </span>
295
- </${P(h)}>`;
412
+ </${L(c)}>`;
296
413
  }
297
414
  getHeaderCellStyle(t) {
298
- const e = t.column.columnDef;
299
- if (!(!e.size && !e.maxSize && !e.headerTextAlign))
415
+ var n;
416
+ const e = t.column.columnDef, i = (n = this._columnSizing[t.column.id]) != null ? n : e.size;
417
+ if (!(!i && !e.maxSize && !e.headerTextAlign))
300
418
  return `
301
- ${e.size ? `width: ${e.size}px;` : ""}
419
+ ${i ? `width: ${i}px;` : ""}
302
420
  ${e.maxSize ? `max-width: ${e.maxSize}px;` : ""}
303
421
  ${e.headerTextAlign ? `text-align: ${e.headerTextAlign};` : ""}
304
422
  `;
@@ -311,7 +429,7 @@ const k = "__multiSelect__", w = class w extends M {
311
429
  }
312
430
  getSortTitle(t, e) {
313
431
  if (t)
314
- return e === "asc" ? c("datatable.sortAscending") : e === "desc" ? c("datatable.sortDescending") : c("datatable.clearSort");
432
+ return e === "asc" ? u("datatable.sortAscending") : e === "desc" ? u("datatable.sortDescending") : u("datatable.clearSort");
315
433
  }
316
434
  getAriaSortValue(t) {
317
435
  return t === "asc" ? "ascending" : t === "desc" ? "descending" : "none";
@@ -322,57 +440,58 @@ const k = "__multiSelect__", w = class w extends M {
322
440
  * render callbacks, and Lit templates
323
441
  */
324
442
  renderCell(t) {
325
- const e = t.column.columnDef.cell, l = t.getContext(), r = typeof e == "function" ? e(l) : e, n = G(r);
326
- return typeof n == "string" || typeof n == "number" || typeof n == "boolean" || n === null || n === void 0 || n instanceof HTMLElement ? n : C(e, l);
443
+ const e = t.column.columnDef.cell, i = t.getContext(), n = typeof e == "function" ? e(i) : e, s = Y(n);
444
+ return typeof s == "string" || typeof s == "number" || typeof s == "boolean" || s === null || s === void 0 || s instanceof HTMLElement ? s : R(e, i);
327
445
  }
328
446
  handleRowClick(t) {
329
447
  this.enableRowClick && this.emit("dds-row-click", { row: t });
330
448
  }
331
449
  handleRowKeydown(t, e) {
332
450
  if (t.key === "Enter" || t.key === " ") {
333
- if (t.composedPath().some((n) => n instanceof HTMLElement ? !!(["BUTTON", "A", "INPUT", "SELECT", "TEXTAREA"].includes(
334
- n.tagName
335
- ) || n.getAttribute("role") === "button" || n.tagName.toLowerCase().includes("button") || n.tagName.toLowerCase().includes("btn")) : !1))
451
+ if (t.composedPath().some((s) => s instanceof HTMLElement ? !!(["BUTTON", "A", "INPUT", "SELECT", "TEXTAREA"].includes(
452
+ s.tagName
453
+ ) || s.getAttribute("role") === "button" || s.tagName.toLowerCase().includes("button") || s.tagName.toLowerCase().includes("btn")) : !1))
336
454
  return;
337
455
  t.preventDefault(), this.handleRowClick(e);
338
456
  }
339
457
  }
340
458
  render() {
341
- var e, l, r, n;
342
- const t = this.tableController.table(y(m({
459
+ var e, i, n, s;
460
+ const t = this.tableController.table(S(m({
343
461
  data: this.data,
344
462
  columns: this.columnsMemo(),
345
463
  filterFns: {},
346
464
  state: {
347
465
  sorting: this._sorting,
348
466
  rowSelection: this._rowSelection,
349
- pagination: this._pagination
467
+ pagination: this._pagination,
468
+ columnSizing: this._columnSizing
350
469
  },
351
470
  manualSorting: this.manualSorting,
352
471
  enableSorting: this.enableSorting,
353
472
  enableRowSelection: this.enableRowSelection,
354
473
  manualPagination: this.manualPagination,
355
474
  autoResetPageIndex: this.autoResetPageIndex,
356
- onSortingChange: (s) => {
357
- typeof s == "function" ? this._sorting = s(this._sorting) : this._sorting = s, this.emit("dds-sorting-change", { sorting: this._sorting });
475
+ onSortingChange: (o) => {
476
+ typeof o == "function" ? this._sorting = o(this._sorting) : this._sorting = o, this.emit("dds-sorting-change", { sorting: this._sorting });
358
477
  },
359
- getCoreRowModel: J()
478
+ getCoreRowModel: Q()
360
479
  }, !this.manualSorting && {
361
- getSortedRowModel: X()
480
+ getSortedRowModel: J()
362
481
  }), {
363
- getPaginationRowModel: V(),
364
- onPaginationChange: (s) => {
365
- typeof s == "function" ? this._pagination = s(this._pagination) : this._pagination = s, this.emit("dds-pagination-change", {
482
+ getPaginationRowModel: q(),
483
+ onPaginationChange: (o) => {
484
+ typeof o == "function" ? this._pagination = o(this._pagination) : this._pagination = o, this.emit("dds-pagination-change", {
366
485
  pagination: {
367
486
  pageIndex: this._pagination.pageIndex,
368
487
  pageSize: this._pagination.pageSize
369
488
  }
370
489
  });
371
490
  },
372
- onRowSelectionChange: (s) => {
373
- typeof s == "function" ? this._rowSelection = s(this._rowSelection) : this._rowSelection = s, this.emit("dds-selection-change", { selection: this._rowSelection });
491
+ onRowSelectionChange: (o) => {
492
+ typeof o == "function" ? this._rowSelection = o(this._rowSelection) : this._rowSelection = o, this.emit("dds-selection-change", { selection: this._rowSelection });
374
493
  },
375
- getRowId: (s) => s[this.rowKey],
494
+ getRowId: (o) => o[this.rowKey],
376
495
  rowCount: (e = this.rowCount) != null ? e : this.data ? this.data.length : 0,
377
496
  debugTable: this.debug,
378
497
  debugHeaders: this.debug,
@@ -383,28 +502,31 @@ const k = "__multiSelect__", w = class w extends M {
383
502
  <table
384
503
  part="base"
385
504
  role="table"
386
- aria-label=${u(
387
- (l = this.ariaLabel) != null ? l : c("datatable.tableDescription")
505
+ aria-label=${b(
506
+ (i = this.ariaLabel) != null ? i : u("datatable.tableDescription")
388
507
  )}
389
- aria-describedby=${u(this.ariaDescribedBy)}
390
- aria-rowcount=${(r = this.rowCount) != null ? r : this.data ? this.data.length : 0}
391
- class=${f("data-table", {
508
+ aria-describedby=${b(this.ariaDescribedBy)}
509
+ aria-rowcount=${(n = this.rowCount) != null ? n : this.data ? this.data.length : 0}
510
+ class=${y("data-table", {
392
511
  "data-table--loading": this.loading
393
512
  })}>
394
513
  ${this.caption ? p`<caption class="visually-hidden">
395
514
  ${this.caption}
396
- </caption>` : z}
515
+ </caption>` : f}
397
516
  ${this.renderColgroup(t)} ${this.renderHeader(t)}
398
517
  ${this.renderBody(t)}
399
518
  </table>
400
519
  </div>
520
+ ${this.enableColumnResizing ? p`<span id="data-table-resize-label" hidden
521
+ >${u("datatable.resizeColumn")}</span
522
+ >` : f}
401
523
  ${this._statusMessage ? p`<div
402
524
  aria-live="polite"
403
525
  aria-atomic="true"
404
526
  class="visually-hidden"
405
527
  id="table-status">
406
528
  ${this._statusMessage}
407
- </div>` : z}
529
+ </div>` : f}
408
530
  ${this.pager && !this.isTableEmpty || this.pager && this.showPagerOnEmpty && this.isTableEmpty ? p`<dap-ds-pager
409
531
  class="data-table-pager"
410
532
  part="pager"
@@ -412,7 +534,7 @@ const k = "__multiSelect__", w = class w extends M {
412
534
  .manualPagination=${this.manualPagination}
413
535
  .pageIndex=${t.getState().pagination.pageIndex}
414
536
  .pageSize=${t.getState().pagination.pageSize}
415
- .totalRows=${(n = this.rowCount) != null ? n : this.data ? this.data.length : 0}
537
+ .totalRows=${(s = this.rowCount) != null ? s : this.data ? this.data.length : 0}
416
538
  .pageSizeOptions=${this.pageSizeOptions}
417
539
  .showPageSizeOptions=${this.showPageSizeOptions}
418
540
  .showPageIndex=${this.showPageIndex}
@@ -429,185 +551,188 @@ const k = "__multiSelect__", w = class w extends M {
429
551
  .lastButtonLabel=${this.lastButtonLabel}
430
552
  .pageStateText=${this.pageStateText}
431
553
  exportparts="base:pager-base, first:pager-first, previous:pager-previous, next:pager-next, last:pager-last, page-size:pager-page-size-select, page-size-select-base:page-size-select-base, page-size-select-trigger:page-size-select-trigger, pager-button-first-base:pager-button-first-base, pager-button-first-content:pager-button-first-content, pager-button-previous-base:pager-button-previous-base, pager-button-previous-content:pager-button-previous-content, pager-button-next-base:pager-button-next-base, pager-button-next-content:pager-button-next-content, pager-button-last-base:pager-button-last-base, pager-button-last-content:pager-button-last-content, page-numbers:pager-page-numbers, page-number:pager-page-number, page-number-active:pager-page-number-active, page-number-base:pager-page-number-base, page-number-content:pager-page-number-content, page-info:pager-page-info"
432
- @dds-pagination-change=${(s) => {
433
- s.preventDefault(), s.stopPropagation(), s.detail.action === "pageSize" ? t.setPageSize(s.detail.pagination.pageSize) : t.setPageIndex(s.detail.pagination.pageIndex);
554
+ @dds-pagination-change=${(o) => {
555
+ o.preventDefault(), o.stopPropagation(), o.detail.action === "pageSize" ? t.setPageSize(o.detail.pagination.pageSize) : t.setPageIndex(o.detail.pagination.pageIndex);
434
556
  }}>
435
557
  <slot name="first-button-label" slot="first-button-label">
436
- ${this.firstButtonLabel || c("pager.first")}
558
+ ${this.firstButtonLabel || u("pager.first")}
437
559
  </slot>
438
560
  <slot name="previous-button-label" slot="previous-button-label">
439
- ${this.previousButtonLabel || c("pager.previous")}
561
+ ${this.previousButtonLabel || u("pager.previous")}
440
562
  </slot>
441
563
  <slot name="next-button-label" slot="next-button-label">
442
- ${this.nextButtonLabel || c("pager.next")}
564
+ ${this.nextButtonLabel || u("pager.next")}
443
565
  </slot>
444
566
  <slot name="last-button-label" slot="last-button-label">
445
- ${this.lastButtonLabel || c("pager.last")}
567
+ ${this.lastButtonLabel || u("pager.last")}
446
568
  </slot>
447
- </dap-ds-pager>` : z}
569
+ </dap-ds-pager>` : f}
448
570
  `;
449
571
  }
450
572
  };
451
- w.tagName = "dap-ds-datatable", w.dependencies = {
452
- "dap-ds-checkbox": D,
453
- "dap-ds-icon-arrow-up-s-line": U,
454
- "dap-ds-icon-arrow-down-s-line": N,
455
- "dap-ds-skeleton": K,
456
- "dap-ds-spinner": F,
457
- "dap-ds-pager": j
458
- }, w.styles = Q(q);
459
- let o = w;
460
- i([
461
- a({ attribute: !1 })
462
- ], o.prototype, "data");
463
- i([
464
- a({ attribute: !1 })
465
- ], o.prototype, "columns");
466
- i([
467
- a()
468
- ], o.prototype, "rowKey");
469
- i([
470
- a({ type: Boolean })
471
- ], o.prototype, "enableRowSelection");
472
- i([
473
- a({ type: Boolean })
474
- ], o.prototype, "stickySelectionColumn");
475
- i([
476
- a({ type: Boolean })
477
- ], o.prototype, "enableSorting");
478
- i([
479
- a({ type: Boolean })
480
- ], o.prototype, "manualSorting");
481
- i([
482
- a({ type: Boolean })
483
- ], o.prototype, "manualPagination");
484
- i([
485
- a({ type: Boolean })
486
- ], o.prototype, "autoResetPageIndex");
487
- i([
488
- a({ type: Boolean })
489
- ], o.prototype, "enableRowClick");
490
- i([
491
- a({ type: Boolean })
492
- ], o.prototype, "loading");
493
- i([
494
- a({ type: Boolean })
495
- ], o.prototype, "enableStripedRows");
496
- i([
497
- a({ type: Number })
498
- ], o.prototype, "rowCount");
499
- i([
500
- a({ type: String })
501
- ], o.prototype, "caption");
502
- i([
503
- a({ type: String })
504
- ], o.prototype, "loadingType");
505
- i([
506
- a({ type: String, reflect: !0 })
507
- ], o.prototype, "loadingVariant");
508
- i([
509
- a({ type: String, reflect: !0 })
510
- ], o.prototype, "loadingSize");
511
- i([
512
- a({ type: Number })
513
- ], o.prototype, "loadingStaticSize");
514
- i([
515
- a({ type: String })
516
- ], o.prototype, "loadingText");
517
- i([
518
- a({ type: String })
519
- ], o.prototype, "emptyText");
520
- i([
521
- a({ type: String })
522
- ], o.prototype, "disableHeaderOnEmpty");
523
- i([
524
- a({ type: Boolean })
525
- ], o.prototype, "showPagerOnEmpty");
526
- i([
527
- a({ type: Boolean })
528
- ], o.prototype, "pager");
529
- i([
530
- a({ type: String })
531
- ], o.prototype, "showPageSizeOptions");
532
- i([
533
- a({ type: String })
534
- ], o.prototype, "showPageIndex");
535
- i([
536
- a({ type: String })
537
- ], o.prototype, "showPageCount");
538
- i([
539
- a({ type: String })
540
- ], o.prototype, "showFirstButton");
541
- i([
542
- a({ type: String })
543
- ], o.prototype, "showPreviousButton");
544
- i([
545
- a({ type: String })
546
- ], o.prototype, "showNextButton");
547
- i([
548
- a({ type: String })
549
- ], o.prototype, "showLastButton");
550
- i([
551
- a({ type: String })
552
- ], o.prototype, "showPageNumbers");
553
- i([
554
- a({ type: Number })
555
- ], o.prototype, "siblingCount");
556
- i([
557
- a({ type: String })
558
- ], o.prototype, "firstButtonLabel");
559
- i([
560
- a({ type: String })
561
- ], o.prototype, "previousButtonLabel");
562
- i([
563
- a({ type: String })
564
- ], o.prototype, "nextButtonLabel");
565
- i([
566
- a({ type: String })
567
- ], o.prototype, "lastButtonLabel");
568
- i([
569
- a()
570
- ], o.prototype, "sortButtonTestId");
571
- i([
572
- a({ attribute: !1 })
573
- ], o.prototype, "pageStateText");
574
- i([
575
- a({ type: Array })
576
- ], o.prototype, "pageSizeOptions");
577
- i([
578
- a({ type: Array })
579
- ], o.prototype, "sorting");
580
- i([
581
- $()
582
- ], o.prototype, "_sorting");
583
- i([
584
- a({ type: Object })
585
- ], o.prototype, "rowSelection");
586
- i([
587
- $()
588
- ], o.prototype, "_rowSelection");
589
- i([
590
- a({ type: Object })
591
- ], o.prototype, "pagination");
592
- i([
593
- $()
594
- ], o.prototype, "_pagination");
595
- i([
596
- a({ type: Object })
597
- ], o.prototype, "columnSizing");
598
- i([
599
- $()
600
- ], o.prototype, "_columnSizing");
601
- i([
602
- a({ type: String })
603
- ], o.prototype, "ariaLabel");
604
- i([
605
- $()
606
- ], o.prototype, "_statusMessage");
607
- i([
608
- a({ type: Boolean })
609
- ], o.prototype, "debug");
573
+ $.tagName = "dap-ds-datatable", $.dependencies = {
574
+ "dap-ds-checkbox": F,
575
+ "dap-ds-icon-arrow-up-s-line": W,
576
+ "dap-ds-icon-arrow-down-s-line": j,
577
+ "dap-ds-skeleton": Z,
578
+ "dap-ds-spinner": G,
579
+ "dap-ds-pager": X
580
+ }, $.styles = tt(V);
581
+ let a = $;
582
+ r([
583
+ l({ attribute: !1 })
584
+ ], a.prototype, "data");
585
+ r([
586
+ l({ attribute: !1 })
587
+ ], a.prototype, "columns");
588
+ r([
589
+ l()
590
+ ], a.prototype, "rowKey");
591
+ r([
592
+ l({ type: Boolean })
593
+ ], a.prototype, "enableRowSelection");
594
+ r([
595
+ l({ type: Boolean })
596
+ ], a.prototype, "stickySelectionColumn");
597
+ r([
598
+ l({ type: Boolean })
599
+ ], a.prototype, "enableSorting");
600
+ r([
601
+ l({ type: Boolean })
602
+ ], a.prototype, "enableColumnResizing");
603
+ r([
604
+ l({ type: Boolean })
605
+ ], a.prototype, "manualSorting");
606
+ r([
607
+ l({ type: Boolean })
608
+ ], a.prototype, "manualPagination");
609
+ r([
610
+ l({ type: Boolean })
611
+ ], a.prototype, "autoResetPageIndex");
612
+ r([
613
+ l({ type: Boolean })
614
+ ], a.prototype, "enableRowClick");
615
+ r([
616
+ l({ type: Boolean })
617
+ ], a.prototype, "loading");
618
+ r([
619
+ l({ type: Boolean })
620
+ ], a.prototype, "enableStripedRows");
621
+ r([
622
+ l({ type: Number })
623
+ ], a.prototype, "rowCount");
624
+ r([
625
+ l({ type: String })
626
+ ], a.prototype, "caption");
627
+ r([
628
+ l({ type: String })
629
+ ], a.prototype, "loadingType");
630
+ r([
631
+ l({ type: String, reflect: !0 })
632
+ ], a.prototype, "loadingVariant");
633
+ r([
634
+ l({ type: String, reflect: !0 })
635
+ ], a.prototype, "loadingSize");
636
+ r([
637
+ l({ type: Number })
638
+ ], a.prototype, "loadingStaticSize");
639
+ r([
640
+ l({ type: String })
641
+ ], a.prototype, "loadingText");
642
+ r([
643
+ l({ type: String })
644
+ ], a.prototype, "emptyText");
645
+ r([
646
+ l({ type: String })
647
+ ], a.prototype, "disableHeaderOnEmpty");
648
+ r([
649
+ l({ type: Boolean })
650
+ ], a.prototype, "showPagerOnEmpty");
651
+ r([
652
+ l({ type: Boolean })
653
+ ], a.prototype, "pager");
654
+ r([
655
+ l({ type: String })
656
+ ], a.prototype, "showPageSizeOptions");
657
+ r([
658
+ l({ type: String })
659
+ ], a.prototype, "showPageIndex");
660
+ r([
661
+ l({ type: String })
662
+ ], a.prototype, "showPageCount");
663
+ r([
664
+ l({ type: String })
665
+ ], a.prototype, "showFirstButton");
666
+ r([
667
+ l({ type: String })
668
+ ], a.prototype, "showPreviousButton");
669
+ r([
670
+ l({ type: String })
671
+ ], a.prototype, "showNextButton");
672
+ r([
673
+ l({ type: String })
674
+ ], a.prototype, "showLastButton");
675
+ r([
676
+ l({ type: String })
677
+ ], a.prototype, "showPageNumbers");
678
+ r([
679
+ l({ type: Number })
680
+ ], a.prototype, "siblingCount");
681
+ r([
682
+ l({ type: String })
683
+ ], a.prototype, "firstButtonLabel");
684
+ r([
685
+ l({ type: String })
686
+ ], a.prototype, "previousButtonLabel");
687
+ r([
688
+ l({ type: String })
689
+ ], a.prototype, "nextButtonLabel");
690
+ r([
691
+ l({ type: String })
692
+ ], a.prototype, "lastButtonLabel");
693
+ r([
694
+ l()
695
+ ], a.prototype, "sortButtonTestId");
696
+ r([
697
+ l({ attribute: !1 })
698
+ ], a.prototype, "pageStateText");
699
+ r([
700
+ l({ type: Array })
701
+ ], a.prototype, "pageSizeOptions");
702
+ r([
703
+ l({ type: Array })
704
+ ], a.prototype, "sorting");
705
+ r([
706
+ z()
707
+ ], a.prototype, "_sorting");
708
+ r([
709
+ l({ type: Object })
710
+ ], a.prototype, "rowSelection");
711
+ r([
712
+ z()
713
+ ], a.prototype, "_rowSelection");
714
+ r([
715
+ l({ type: Object })
716
+ ], a.prototype, "pagination");
717
+ r([
718
+ z()
719
+ ], a.prototype, "_pagination");
720
+ r([
721
+ l({ type: Object })
722
+ ], a.prototype, "columnSizing");
723
+ r([
724
+ z()
725
+ ], a.prototype, "_columnSizing");
726
+ r([
727
+ l({ type: String })
728
+ ], a.prototype, "ariaLabel");
729
+ r([
730
+ z()
731
+ ], a.prototype, "_statusMessage");
732
+ r([
733
+ l({ type: Boolean })
734
+ ], a.prototype, "debug");
610
735
  export {
611
- o as default
736
+ a as default
612
737
  };
613
738
  //# sourceMappingURL=datatable.component.js.map