@timlassiter11/yatl 1.2.4 → 1.3.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.
- package/dist/index.d.mts +647 -510
- package/dist/index.d.ts +647 -510
- package/dist/index.js +660 -364
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +647 -357
- package/dist/index.mjs.map +1 -1
- package/dist/yatl.min.global.js +126 -45
- package/dist/yatl.min.global.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,7 +28,12 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
28
28
|
// src/index.ts
|
|
29
29
|
var src_exports = {};
|
|
30
30
|
__export(src_exports, {
|
|
31
|
+
InputEditor: () => InputEditor,
|
|
32
|
+
NumberEditor: () => NumberEditor,
|
|
33
|
+
SelectEditor: () => SelectEditor,
|
|
34
|
+
TextEditor: () => TextEditor,
|
|
31
35
|
TypedEventTarget: () => TypedEventTarget,
|
|
36
|
+
YatlCellEditEvent: () => YatlCellEditEvent,
|
|
32
37
|
YatlColumnReorderEvent: () => YatlColumnReorderEvent,
|
|
33
38
|
YatlColumnReorderRequest: () => YatlColumnReorderRequest,
|
|
34
39
|
YatlColumnResizeEvent: () => YatlColumnResizeEvent,
|
|
@@ -41,6 +46,7 @@ __export(src_exports, {
|
|
|
41
46
|
YatlRowSelectRequest: () => YatlRowSelectRequest,
|
|
42
47
|
YatlTable: () => YatlTable,
|
|
43
48
|
YatlTableController: () => YatlTableController,
|
|
49
|
+
YatlTableControllerEvent: () => YatlTableControllerEvent,
|
|
44
50
|
YatlTableSearchEvent: () => YatlTableSearchEvent,
|
|
45
51
|
YatlTableStateChangeEvent: () => YatlTableStateChangeEvent,
|
|
46
52
|
YatlTableViewChangeEvent: () => YatlTableViewChangeEvent,
|
|
@@ -69,6 +75,8 @@ var YatlEvent = class extends Event {
|
|
|
69
75
|
});
|
|
70
76
|
}
|
|
71
77
|
};
|
|
78
|
+
var YatlTableControllerEvent = class extends YatlEvent {
|
|
79
|
+
};
|
|
72
80
|
var YatlRowClickEvent = class _YatlRowClickEvent extends YatlEvent {
|
|
73
81
|
constructor(row, rowId, index, field, originalEvent) {
|
|
74
82
|
super(_YatlRowClickEvent.EVENT_NAME);
|
|
@@ -81,15 +89,6 @@ var YatlRowClickEvent = class _YatlRowClickEvent extends YatlEvent {
|
|
|
81
89
|
static {
|
|
82
90
|
this.EVENT_NAME = "yatl-row-click";
|
|
83
91
|
}
|
|
84
|
-
clone() {
|
|
85
|
-
return new _YatlRowClickEvent(
|
|
86
|
-
this.row,
|
|
87
|
-
this.rowId,
|
|
88
|
-
this.index,
|
|
89
|
-
this.field,
|
|
90
|
-
this.originalEvent
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
92
|
};
|
|
94
93
|
var YatlRowSelectRequest = class _YatlRowSelectRequest extends YatlEvent {
|
|
95
94
|
constructor(rowId, selected, currentlySelectedRows) {
|
|
@@ -101,15 +100,8 @@ var YatlRowSelectRequest = class _YatlRowSelectRequest extends YatlEvent {
|
|
|
101
100
|
static {
|
|
102
101
|
this.EVENT_NAME = "yatl-row-select-request";
|
|
103
102
|
}
|
|
104
|
-
clone() {
|
|
105
|
-
return new _YatlRowSelectRequest(
|
|
106
|
-
this.rowId,
|
|
107
|
-
this.selected,
|
|
108
|
-
this.currentlySelectedRows
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
103
|
};
|
|
112
|
-
var YatlRowSelectEvent = class _YatlRowSelectEvent extends
|
|
104
|
+
var YatlRowSelectEvent = class _YatlRowSelectEvent extends YatlTableControllerEvent {
|
|
113
105
|
constructor(selectedIds, previouslySelectedRows) {
|
|
114
106
|
super(_YatlRowSelectEvent.EVENT_NAME);
|
|
115
107
|
this.selectedIds = selectedIds;
|
|
@@ -135,11 +127,8 @@ var YatlColumnSortRequest = class _YatlColumnSortRequest extends YatlEvent {
|
|
|
135
127
|
static {
|
|
136
128
|
this.EVENT_NAME = "yatl-column-sort-request";
|
|
137
129
|
}
|
|
138
|
-
clone() {
|
|
139
|
-
return new _YatlColumnSortRequest(this.field, this.order, this.multisort);
|
|
140
|
-
}
|
|
141
130
|
};
|
|
142
|
-
var YatlColumnSortEvent = class _YatlColumnSortEvent extends
|
|
131
|
+
var YatlColumnSortEvent = class _YatlColumnSortEvent extends YatlTableControllerEvent {
|
|
143
132
|
constructor(field, order, multisort) {
|
|
144
133
|
super(_YatlColumnSortEvent.EVENT_NAME);
|
|
145
134
|
this.field = field;
|
|
@@ -153,7 +142,7 @@ var YatlColumnSortEvent = class _YatlColumnSortEvent extends YatlEvent {
|
|
|
153
142
|
return new _YatlColumnSortEvent(this.field, this.order, this.multisort);
|
|
154
143
|
}
|
|
155
144
|
};
|
|
156
|
-
var YatlColumnToggleEvent = class _YatlColumnToggleEvent extends
|
|
145
|
+
var YatlColumnToggleEvent = class _YatlColumnToggleEvent extends YatlTableControllerEvent {
|
|
157
146
|
constructor(field, visible) {
|
|
158
147
|
super(_YatlColumnToggleEvent.EVENT_NAME);
|
|
159
148
|
this.field = field;
|
|
@@ -166,7 +155,7 @@ var YatlColumnToggleEvent = class _YatlColumnToggleEvent extends YatlEvent {
|
|
|
166
155
|
return new _YatlColumnToggleEvent(this.field, this.visible);
|
|
167
156
|
}
|
|
168
157
|
};
|
|
169
|
-
var YatlColumnResizeEvent = class _YatlColumnResizeEvent extends
|
|
158
|
+
var YatlColumnResizeEvent = class _YatlColumnResizeEvent extends YatlTableControllerEvent {
|
|
170
159
|
constructor(field, width) {
|
|
171
160
|
super(_YatlColumnResizeEvent.EVENT_NAME);
|
|
172
161
|
this.field = field;
|
|
@@ -189,15 +178,8 @@ var YatlColumnReorderRequest = class _YatlColumnReorderRequest extends YatlEvent
|
|
|
189
178
|
static {
|
|
190
179
|
this.EVENT_NAME = "yatl-column-reorder-request";
|
|
191
180
|
}
|
|
192
|
-
clone() {
|
|
193
|
-
return new _YatlColumnReorderRequest(
|
|
194
|
-
this.movedColumn,
|
|
195
|
-
this.originalIndex,
|
|
196
|
-
this.newIndex
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
181
|
};
|
|
200
|
-
var YatlColumnReorderEvent = class _YatlColumnReorderEvent extends
|
|
182
|
+
var YatlColumnReorderEvent = class _YatlColumnReorderEvent extends YatlTableControllerEvent {
|
|
201
183
|
constructor(order) {
|
|
202
184
|
super(_YatlColumnReorderEvent.EVENT_NAME);
|
|
203
185
|
this.order = order;
|
|
@@ -209,7 +191,20 @@ var YatlColumnReorderEvent = class _YatlColumnReorderEvent extends YatlEvent {
|
|
|
209
191
|
return new _YatlColumnReorderEvent(this.order);
|
|
210
192
|
}
|
|
211
193
|
};
|
|
212
|
-
var
|
|
194
|
+
var YatlCellEditEvent = class _YatlCellEditEvent extends YatlEvent {
|
|
195
|
+
constructor(row, rowId, field, originalValue, currentValue) {
|
|
196
|
+
super(_YatlCellEditEvent.EVENT_NAME);
|
|
197
|
+
this.row = row;
|
|
198
|
+
this.rowId = rowId;
|
|
199
|
+
this.field = field;
|
|
200
|
+
this.originalValue = originalValue;
|
|
201
|
+
this.currentValue = currentValue;
|
|
202
|
+
}
|
|
203
|
+
static {
|
|
204
|
+
this.EVENT_NAME = "yatl-cell-edit";
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
var YatlTableSearchEvent = class _YatlTableSearchEvent extends YatlTableControllerEvent {
|
|
213
208
|
constructor(query2) {
|
|
214
209
|
super(_YatlTableSearchEvent.EVENT_NAME);
|
|
215
210
|
this.query = query2;
|
|
@@ -221,7 +216,7 @@ var YatlTableSearchEvent = class _YatlTableSearchEvent extends YatlEvent {
|
|
|
221
216
|
return new _YatlTableSearchEvent(this.query);
|
|
222
217
|
}
|
|
223
218
|
};
|
|
224
|
-
var YatlTableViewChangeEvent = class _YatlTableViewChangeEvent extends
|
|
219
|
+
var YatlTableViewChangeEvent = class _YatlTableViewChangeEvent extends YatlTableControllerEvent {
|
|
225
220
|
constructor(data) {
|
|
226
221
|
super(_YatlTableViewChangeEvent.EVENT_NAME);
|
|
227
222
|
this.data = data;
|
|
@@ -233,7 +228,7 @@ var YatlTableViewChangeEvent = class _YatlTableViewChangeEvent extends YatlEvent
|
|
|
233
228
|
return new _YatlTableViewChangeEvent(this.data);
|
|
234
229
|
}
|
|
235
230
|
};
|
|
236
|
-
var YatlTableStateChangeEvent = class _YatlTableStateChangeEvent extends
|
|
231
|
+
var YatlTableStateChangeEvent = class _YatlTableStateChangeEvent extends YatlTableControllerEvent {
|
|
237
232
|
constructor(state2, triggers) {
|
|
238
233
|
super(_YatlTableStateChangeEvent.EVENT_NAME);
|
|
239
234
|
this.state = state2;
|
|
@@ -247,6 +242,139 @@ var YatlTableStateChangeEvent = class _YatlTableStateChangeEvent extends YatlEve
|
|
|
247
242
|
}
|
|
248
243
|
};
|
|
249
244
|
|
|
245
|
+
// src/editors/input-editor.ts
|
|
246
|
+
var import_lit = require("lit");
|
|
247
|
+
var import_if_defined = require("lit/directives/if-defined.js");
|
|
248
|
+
var import_live = require("lit/directives/live.js");
|
|
249
|
+
|
|
250
|
+
// src/editors/base.ts
|
|
251
|
+
var BaseEditor = class {
|
|
252
|
+
constructor(options) {
|
|
253
|
+
this.options = options;
|
|
254
|
+
}
|
|
255
|
+
reset() {
|
|
256
|
+
this.currentValue = void 0;
|
|
257
|
+
}
|
|
258
|
+
canEdit(field, row) {
|
|
259
|
+
return this.options?.canEdit?.(field, row) ?? true;
|
|
260
|
+
}
|
|
261
|
+
save(originalValue, field, row, _controller) {
|
|
262
|
+
if (this.currentValue === void 0 || this.currentValue === originalValue) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (!this.options?.onSave) {
|
|
266
|
+
return this.currentValue;
|
|
267
|
+
}
|
|
268
|
+
return this.options.onSave(originalValue, this.currentValue, field, row);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// src/editors/input-editor.ts
|
|
273
|
+
var InputEditor = class extends BaseEditor {
|
|
274
|
+
constructor(options) {
|
|
275
|
+
super(options);
|
|
276
|
+
this.options = options;
|
|
277
|
+
this.handleChange = (event) => {
|
|
278
|
+
const target = event.target;
|
|
279
|
+
const { type, max, min } = this.options ?? {};
|
|
280
|
+
if (type === "checkbox") {
|
|
281
|
+
this.currentValue = target.checked;
|
|
282
|
+
} else if (type === "date" || type === "datetime-local") {
|
|
283
|
+
this.currentValue = target.valueAsDate;
|
|
284
|
+
} else if (type === "number") {
|
|
285
|
+
let value = target.valueAsNumber;
|
|
286
|
+
if (isNaN(value)) {
|
|
287
|
+
value = null;
|
|
288
|
+
} else {
|
|
289
|
+
if (typeof max === "number" && value > max) {
|
|
290
|
+
target.valueAsNumber = max;
|
|
291
|
+
value = max;
|
|
292
|
+
} else if (typeof min === "number" && value < min) {
|
|
293
|
+
target.valueAsNumber = min;
|
|
294
|
+
value = min;
|
|
295
|
+
}
|
|
296
|
+
this.currentValue = value;
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
this.currentValue = target.value;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
render(value, _field, _row, _controller) {
|
|
304
|
+
return import_lit.html`
|
|
305
|
+
<input
|
|
306
|
+
.value=${(0, import_live.live)(String(value ?? ""))}
|
|
307
|
+
type=${(0, import_if_defined.ifDefined)(this.options?.type)}
|
|
308
|
+
minlength=${(0, import_if_defined.ifDefined)(this.options?.minlength)}
|
|
309
|
+
maxlength=${(0, import_if_defined.ifDefined)(this.options?.maxlength)}
|
|
310
|
+
min=${(0, import_if_defined.ifDefined)(this.options?.min)}
|
|
311
|
+
max=${(0, import_if_defined.ifDefined)(this.options?.max)}
|
|
312
|
+
step=${(0, import_if_defined.ifDefined)(this.options?.step)}
|
|
313
|
+
pattern=${(0, import_if_defined.ifDefined)(this.options?.pattern)}
|
|
314
|
+
placeholder=${(0, import_if_defined.ifDefined)(this.options?.placeholder)}
|
|
315
|
+
autofocus
|
|
316
|
+
@input=${this.handleChange}
|
|
317
|
+
/>
|
|
318
|
+
`;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/editors/number-editor.ts
|
|
323
|
+
var NumberEditor = class extends InputEditor {
|
|
324
|
+
constructor(options) {
|
|
325
|
+
super({
|
|
326
|
+
type: "number",
|
|
327
|
+
...options
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
// src/editors/select-editor.ts
|
|
333
|
+
var import_lit2 = require("lit");
|
|
334
|
+
var import_live2 = require("lit/directives/live.js");
|
|
335
|
+
var import_repeat = require("lit/directives/repeat.js");
|
|
336
|
+
var SelectEditor = class extends BaseEditor {
|
|
337
|
+
constructor(options) {
|
|
338
|
+
super(options);
|
|
339
|
+
this.options = options;
|
|
340
|
+
this.handleChange = (event) => {
|
|
341
|
+
const target = event.target;
|
|
342
|
+
this.currentValue = target.value;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
render(value, field, row, controller) {
|
|
346
|
+
const values = controller.getColumnFilterValues(field, false);
|
|
347
|
+
return import_lit2.html`
|
|
348
|
+
<select .value=${(0, import_live2.live)(String(value))} @change=${this.handleChange}>
|
|
349
|
+
${(0, import_repeat.repeat)(
|
|
350
|
+
values.keys(),
|
|
351
|
+
(option) => option,
|
|
352
|
+
(option) => this.renderOption(option, option === value)
|
|
353
|
+
)}
|
|
354
|
+
</select>
|
|
355
|
+
`;
|
|
356
|
+
}
|
|
357
|
+
renderOption(option, select) {
|
|
358
|
+
const [value, display] = this.options?.labelRenderer?.(option) ?? [
|
|
359
|
+
String(option),
|
|
360
|
+
String(option)
|
|
361
|
+
];
|
|
362
|
+
return import_lit2.html`
|
|
363
|
+
<option value=${value} ?selected=${select}>${display}</option>
|
|
364
|
+
`;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// src/editors/text-editor.ts
|
|
369
|
+
var TextEditor = class extends InputEditor {
|
|
370
|
+
constructor(options) {
|
|
371
|
+
super({
|
|
372
|
+
type: "text",
|
|
373
|
+
...options
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
250
378
|
// src/utils/columns.ts
|
|
251
379
|
function findColumn(columns, field) {
|
|
252
380
|
return columns.find((c) => c.field === field);
|
|
@@ -359,7 +487,7 @@ var TypedEventTarget = class extends EventTarget {
|
|
|
359
487
|
};
|
|
360
488
|
|
|
361
489
|
// src/table/utils.ts
|
|
362
|
-
var
|
|
490
|
+
var import_lit3 = require("lit");
|
|
363
491
|
function highlightText(text, ranges) {
|
|
364
492
|
if (!text || !ranges || ranges.length === 0) {
|
|
365
493
|
return text;
|
|
@@ -386,25 +514,25 @@ function highlightText(text, ranges) {
|
|
|
386
514
|
result.push(text.slice(lastIndex, safeStart));
|
|
387
515
|
}
|
|
388
516
|
result.push(
|
|
389
|
-
|
|
517
|
+
import_lit3.html`<mark class="highlight">${text.slice(safeStart, safeEnd)}</mark>`
|
|
390
518
|
);
|
|
391
519
|
lastIndex = safeEnd;
|
|
392
520
|
}
|
|
393
521
|
if (lastIndex < text.length) {
|
|
394
522
|
result.push(text.slice(lastIndex));
|
|
395
523
|
}
|
|
396
|
-
return
|
|
524
|
+
return import_lit3.html`${result}`;
|
|
397
525
|
}
|
|
398
526
|
var toHumanReadable = (str) => {
|
|
399
527
|
return str.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char) => char.toUpperCase());
|
|
400
528
|
};
|
|
401
529
|
|
|
402
530
|
// src/table/table.ts
|
|
403
|
-
var
|
|
531
|
+
var import_lit5 = require("lit");
|
|
404
532
|
var import_decorators = require("lit/decorators.js");
|
|
405
533
|
var import_class_map = require("lit/directives/class-map.js");
|
|
406
|
-
var
|
|
407
|
-
var
|
|
534
|
+
var import_if_defined2 = require("lit/directives/if-defined.js");
|
|
535
|
+
var import_repeat2 = require("lit/directives/repeat.js");
|
|
408
536
|
var import_style_map = require("lit/directives/style-map.js");
|
|
409
537
|
var import_virtualizer = require("@lit-labs/virtualizer");
|
|
410
538
|
var import_virtualize = require("@lit-labs/virtualizer/virtualize.js");
|
|
@@ -448,7 +576,7 @@ function createRankMap(values, locale) {
|
|
|
448
576
|
// src/table-controller/table-controller.ts
|
|
449
577
|
var STATE_SAVE_DEBOUNCE = 1e3;
|
|
450
578
|
var DEFAULT_STORAGE_OPTIONS = {
|
|
451
|
-
storage:
|
|
579
|
+
storage: window.localStorage,
|
|
452
580
|
saveColumnSortOrders: true,
|
|
453
581
|
saveColumnVisibility: true,
|
|
454
582
|
saveColumnWidths: true,
|
|
@@ -468,8 +596,8 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
468
596
|
// #region State Data
|
|
469
597
|
// Property data
|
|
470
598
|
this.hosts = /* @__PURE__ */ new Set();
|
|
471
|
-
this.
|
|
472
|
-
this.
|
|
599
|
+
this._tokenizedSearch = false;
|
|
600
|
+
this._scoredSearch = false;
|
|
473
601
|
// Original options passed by the user
|
|
474
602
|
this._columns = [];
|
|
475
603
|
// Options mapped by field for faster lookup
|
|
@@ -513,10 +641,10 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
513
641
|
this.attach(host);
|
|
514
642
|
}
|
|
515
643
|
if (options) {
|
|
516
|
-
if (options.
|
|
517
|
-
this.
|
|
518
|
-
if (options.
|
|
519
|
-
this.
|
|
644
|
+
if (options.scoredSearch !== void 0)
|
|
645
|
+
this.scoredSearch = options.scoredSearch;
|
|
646
|
+
if (options.tokenizedSearch !== void 0)
|
|
647
|
+
this.tokenizedSearch = options.tokenizedSearch;
|
|
520
648
|
if (options.searchTokenizer !== void 0)
|
|
521
649
|
this.searchTokenizer = options.searchTokenizer;
|
|
522
650
|
if (options.rowIdCallback !== void 0)
|
|
@@ -531,46 +659,6 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
531
659
|
}
|
|
532
660
|
// #endregion
|
|
533
661
|
// #region Properties
|
|
534
|
-
/**
|
|
535
|
-
* Enables tokenized search behavior.
|
|
536
|
-
* When enabled, the search query is split into individual tokens using the
|
|
537
|
-
* `searchTokenizer` function (defaults to splitting on whitespace).
|
|
538
|
-
* A row is considered a match if **ANY** of the tokens appear in the searchable fields.
|
|
539
|
-
* @default false
|
|
540
|
-
*/
|
|
541
|
-
get enableSearchTokenization() {
|
|
542
|
-
return this._enableSearchTokenization;
|
|
543
|
-
}
|
|
544
|
-
set enableSearchTokenization(enable) {
|
|
545
|
-
if (this._enableSearchTokenization === enable) {
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
this._enableSearchTokenization = enable;
|
|
549
|
-
this.updateInternalQuery();
|
|
550
|
-
this.filterDirty = true;
|
|
551
|
-
this.requestUpdate("enableSearchTokenization");
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Enables weighted relevance scoring for search results.
|
|
555
|
-
* When enabled, exact matches and prefix matches are ranked higher than substring matches.
|
|
556
|
-
* Rows are sorted by their relevance score descending.
|
|
557
|
-
* @default false
|
|
558
|
-
*/
|
|
559
|
-
get enableSearchScoring() {
|
|
560
|
-
return this._enableSearchScoring;
|
|
561
|
-
}
|
|
562
|
-
set enableSearchScoring(enable) {
|
|
563
|
-
if (this._enableSearchScoring === enable) {
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
566
|
-
this._enableSearchScoring = enable;
|
|
567
|
-
this.filterDirty = true;
|
|
568
|
-
this.requestUpdate("enableSearchScoring");
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* The definitions for the columns to be rendered.
|
|
572
|
-
* This defines the field mapping, titles, sortability, and other static options.
|
|
573
|
-
*/
|
|
574
662
|
get columns() {
|
|
575
663
|
return [...this._columns];
|
|
576
664
|
}
|
|
@@ -612,10 +700,43 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
612
700
|
}
|
|
613
701
|
this.requestUpdate("columnStates");
|
|
614
702
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
703
|
+
get data() {
|
|
704
|
+
return [...this._data];
|
|
705
|
+
}
|
|
706
|
+
set data(data) {
|
|
707
|
+
if (this._data === data) {
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
this._data = [...data];
|
|
711
|
+
this.createMetadata();
|
|
712
|
+
this._dataUpdateTimestamp = /* @__PURE__ */ new Date();
|
|
713
|
+
this.filterDirty = true;
|
|
714
|
+
this.requestUpdate("data");
|
|
715
|
+
}
|
|
716
|
+
get filteredData() {
|
|
717
|
+
if (this.filterDirty) {
|
|
718
|
+
this.filterRows();
|
|
719
|
+
} else if (this.sortDirty) {
|
|
720
|
+
this.sortRows();
|
|
721
|
+
}
|
|
722
|
+
this.filterDirty = false;
|
|
723
|
+
this.sortDirty = false;
|
|
724
|
+
return [...this._filteredData];
|
|
725
|
+
}
|
|
726
|
+
get dataUpdateTimestamp() {
|
|
727
|
+
return this._dataUpdateTimestamp;
|
|
728
|
+
}
|
|
729
|
+
get filters() {
|
|
730
|
+
return this._filters;
|
|
731
|
+
}
|
|
732
|
+
set filters(filters) {
|
|
733
|
+
if (this._filters === filters) {
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
this._filters = filters;
|
|
737
|
+
this.filterDirty = true;
|
|
738
|
+
this.requestUpdate("filters");
|
|
739
|
+
}
|
|
619
740
|
get searchQuery() {
|
|
620
741
|
return this._searchQuery;
|
|
621
742
|
}
|
|
@@ -628,11 +749,29 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
628
749
|
this.filterDirty = true;
|
|
629
750
|
this.requestUpdate("searchQuery");
|
|
630
751
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
752
|
+
get tokenizedSearch() {
|
|
753
|
+
return this._tokenizedSearch;
|
|
754
|
+
}
|
|
755
|
+
set tokenizedSearch(enable) {
|
|
756
|
+
if (this._tokenizedSearch === enable) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
this._tokenizedSearch = enable;
|
|
760
|
+
this.updateInternalQuery();
|
|
761
|
+
this.filterDirty = true;
|
|
762
|
+
this.requestUpdate("tokenizedSearch");
|
|
763
|
+
}
|
|
764
|
+
get scoredSearch() {
|
|
765
|
+
return this._scoredSearch;
|
|
766
|
+
}
|
|
767
|
+
set scoredSearch(enable) {
|
|
768
|
+
if (this._scoredSearch === enable) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
this._scoredSearch = enable;
|
|
772
|
+
this.filterDirty = true;
|
|
773
|
+
this.requestUpdate("scoredSearch");
|
|
774
|
+
}
|
|
636
775
|
get searchTokenizer() {
|
|
637
776
|
return this._searchTokenizer;
|
|
638
777
|
}
|
|
@@ -644,38 +783,6 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
644
783
|
this.filterDirty = true;
|
|
645
784
|
this.requestUpdate("searchTokenizer");
|
|
646
785
|
}
|
|
647
|
-
/**
|
|
648
|
-
* An optional set of criteria to filter the visible rows.
|
|
649
|
-
* This runs **before** the global search query is applied.
|
|
650
|
-
* * You can provide:
|
|
651
|
-
* 1. A **Partial Object**: matches rows where specific keys equal specific values (AND logic).
|
|
652
|
-
* 2. A **Callback Function**: returns `true` to keep the row, `false` to hide it.
|
|
653
|
-
* * @example
|
|
654
|
-
* // 1. Object Syntax (Simple Exact Match)
|
|
655
|
-
* // Shows rows where status is 'active' AND role is 'admin'
|
|
656
|
-
* table.filters = { status: 'active', role: 'admin' };
|
|
657
|
-
* * @example
|
|
658
|
-
* // 2. Callback Syntax (Complex Logic)
|
|
659
|
-
* // Shows rows where age is over 21 OR they are a VIP
|
|
660
|
-
* table.filters = (row) => row.age > 21 || row.isVip;
|
|
661
|
-
*/
|
|
662
|
-
get filters() {
|
|
663
|
-
return this._filters;
|
|
664
|
-
}
|
|
665
|
-
set filters(filters) {
|
|
666
|
-
if (this._filters === filters) {
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
this._filters = filters;
|
|
670
|
-
this.filterDirty = true;
|
|
671
|
-
this.requestUpdate("filters");
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* The row selection method to use.
|
|
675
|
-
* * single - Only a single row can be selected at a time
|
|
676
|
-
* * multi - Multiple rows can be selected at a time
|
|
677
|
-
* * null - Disable row selection
|
|
678
|
-
*/
|
|
679
786
|
get rowSelectionMethod() {
|
|
680
787
|
return this._rowSelectionMethod;
|
|
681
788
|
}
|
|
@@ -686,11 +793,6 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
686
793
|
this._rowSelectionMethod = selection;
|
|
687
794
|
this.requestUpdate("rowSelectionMethod");
|
|
688
795
|
}
|
|
689
|
-
/**
|
|
690
|
-
* List of currently selected row indexes.
|
|
691
|
-
* * **NOTE**: These indexes are based off the of
|
|
692
|
-
* the original data array index, *not* the filtered data.
|
|
693
|
-
*/
|
|
694
796
|
get selectedRowIds() {
|
|
695
797
|
let selectedRows = [...this._selectedRowIds];
|
|
696
798
|
if (this.rowSelectionMethod === "single") {
|
|
@@ -707,23 +809,6 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
707
809
|
this._selectedRowIds = new Set(rows);
|
|
708
810
|
this.requestUpdate("selectedRowIds");
|
|
709
811
|
}
|
|
710
|
-
/**
|
|
711
|
-
* Configuration options for automatically saving and restoring table state
|
|
712
|
-
* (column width, order, visibility, etc.) to browser storage.
|
|
713
|
-
*/
|
|
714
|
-
get storageOptions() {
|
|
715
|
-
return this._storageOptions ? { ...this._storageOptions } : null;
|
|
716
|
-
}
|
|
717
|
-
set storageOptions(options) {
|
|
718
|
-
if (this._storageOptions === options) {
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
this._storageOptions = options ? { ...options } : null;
|
|
722
|
-
if (!this.hasRestoredState) {
|
|
723
|
-
this.loadStateFromStorage();
|
|
724
|
-
this.requestUpdate("storageOptions");
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
812
|
get rowIdCallback() {
|
|
728
813
|
return this._rowIdCallback;
|
|
729
814
|
}
|
|
@@ -738,32 +823,18 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
738
823
|
}
|
|
739
824
|
this.requestUpdate("rowIdCallback");
|
|
740
825
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
* Objects must satisfy the `WeakKey` constraint (objects only, no primitives).
|
|
744
|
-
*/
|
|
745
|
-
get data() {
|
|
746
|
-
return [...this._data];
|
|
747
|
-
}
|
|
748
|
-
set data(data) {
|
|
749
|
-
this._data = [...data];
|
|
750
|
-
this.createMetadata();
|
|
751
|
-
this._dataUpdateTimestamp = /* @__PURE__ */ new Date();
|
|
752
|
-
this.filterDirty = true;
|
|
753
|
-
this.requestUpdate("data");
|
|
826
|
+
get storageOptions() {
|
|
827
|
+
return this._storageOptions ? { ...this._storageOptions } : null;
|
|
754
828
|
}
|
|
755
|
-
|
|
756
|
-
if (this.
|
|
757
|
-
|
|
758
|
-
}
|
|
759
|
-
|
|
829
|
+
set storageOptions(options) {
|
|
830
|
+
if (this._storageOptions === options) {
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
this._storageOptions = options ? { ...options } : null;
|
|
834
|
+
if (!this.hasRestoredState) {
|
|
835
|
+
this.loadStateFromStorage();
|
|
836
|
+
this.requestUpdate("storageOptions");
|
|
760
837
|
}
|
|
761
|
-
this.filterDirty = false;
|
|
762
|
-
this.sortDirty = false;
|
|
763
|
-
return [...this._filteredData];
|
|
764
|
-
}
|
|
765
|
-
get dataUpdateTimestamp() {
|
|
766
|
-
return this._dataUpdateTimestamp;
|
|
767
838
|
}
|
|
768
839
|
attach(host) {
|
|
769
840
|
this.hosts.add(host);
|
|
@@ -840,9 +911,14 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
840
911
|
if (column?.valueFormatter) {
|
|
841
912
|
value = column.valueFormatter(value, row);
|
|
842
913
|
}
|
|
843
|
-
if (value
|
|
844
|
-
|
|
845
|
-
|
|
914
|
+
if (!Array.isArray(value)) {
|
|
915
|
+
value = [value];
|
|
916
|
+
}
|
|
917
|
+
for (const item of value) {
|
|
918
|
+
if (item != null || includeNull) {
|
|
919
|
+
const valueCount = values.get(item) ?? 0;
|
|
920
|
+
values.set(item, valueCount + 1);
|
|
921
|
+
}
|
|
846
922
|
}
|
|
847
923
|
}
|
|
848
924
|
return values;
|
|
@@ -1024,7 +1100,7 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1024
1100
|
if (isDisplayColumn(column) && typeof column.valueFormatter === "function") {
|
|
1025
1101
|
value = column.valueFormatter(value, row);
|
|
1026
1102
|
}
|
|
1027
|
-
value = String(value).replace('"', '""');
|
|
1103
|
+
value = String(value ?? "").replace('"', '""');
|
|
1028
1104
|
list.push(`"${value}"`);
|
|
1029
1105
|
}
|
|
1030
1106
|
}
|
|
@@ -1077,8 +1153,7 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1077
1153
|
updateRow(rowId, data) {
|
|
1078
1154
|
const row = this.idToRowMap.get(rowId);
|
|
1079
1155
|
if (row) {
|
|
1080
|
-
|
|
1081
|
-
this.requestUpdate("data");
|
|
1156
|
+
this.updateRowData(row, data);
|
|
1082
1157
|
}
|
|
1083
1158
|
}
|
|
1084
1159
|
/**
|
|
@@ -1097,8 +1172,7 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1097
1172
|
updateRowAtIndex(index, data) {
|
|
1098
1173
|
const row = this.data[index];
|
|
1099
1174
|
if (row) {
|
|
1100
|
-
|
|
1101
|
-
this.requestUpdate("data");
|
|
1175
|
+
this.updateRowData(row, data);
|
|
1102
1176
|
}
|
|
1103
1177
|
}
|
|
1104
1178
|
/**
|
|
@@ -1177,6 +1251,9 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1177
1251
|
new YatlTableStateChangeEvent(this.getTableState(), triggers)
|
|
1178
1252
|
);
|
|
1179
1253
|
}
|
|
1254
|
+
if (props.includes("data")) {
|
|
1255
|
+
this.filterDirty = true;
|
|
1256
|
+
}
|
|
1180
1257
|
for (const host of this.hosts) {
|
|
1181
1258
|
host.requestUpdate();
|
|
1182
1259
|
}
|
|
@@ -1242,7 +1319,7 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1242
1319
|
}
|
|
1243
1320
|
};
|
|
1244
1321
|
if (query2.quoted || !tokens) {
|
|
1245
|
-
if (!this.
|
|
1322
|
+
if (!this.scoredSearch) {
|
|
1246
1323
|
if (value.includes(query2.value)) {
|
|
1247
1324
|
result.score = 1;
|
|
1248
1325
|
addRangesFromValue(query2.value);
|
|
@@ -1254,7 +1331,7 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1254
1331
|
}
|
|
1255
1332
|
return result;
|
|
1256
1333
|
}
|
|
1257
|
-
if (!this.
|
|
1334
|
+
if (!this.scoredSearch) {
|
|
1258
1335
|
const isMatch = tokens.some((token) => token.includes(query2.value));
|
|
1259
1336
|
if (isMatch) {
|
|
1260
1337
|
result.score = 1;
|
|
@@ -1389,7 +1466,7 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1389
1466
|
this._filteredData = this._filteredData.toSorted((a, b) => {
|
|
1390
1467
|
const aMetadata = this.rowMetadata.get(a);
|
|
1391
1468
|
const bMetadata = this.rowMetadata.get(b);
|
|
1392
|
-
if (this.
|
|
1469
|
+
if (this.scoredSearch && this.queryTokens) {
|
|
1393
1470
|
const aValue = aMetadata.searchScore || 0;
|
|
1394
1471
|
const bValue = bMetadata.searchScore || 0;
|
|
1395
1472
|
if (aValue > bValue) return -1;
|
|
@@ -1452,6 +1529,11 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1452
1529
|
}
|
|
1453
1530
|
}
|
|
1454
1531
|
}
|
|
1532
|
+
updateRowData(row, data) {
|
|
1533
|
+
Object.assign(row, data);
|
|
1534
|
+
this.createMetadata();
|
|
1535
|
+
this.requestUpdate("data");
|
|
1536
|
+
}
|
|
1455
1537
|
updateInternalQuery() {
|
|
1456
1538
|
if (this.searchQuery.length === 0) {
|
|
1457
1539
|
this.queryTokens = null;
|
|
@@ -1460,7 +1542,7 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1460
1542
|
this.queryTokens = [
|
|
1461
1543
|
{ value: this.searchQuery.toLocaleLowerCase(), quoted: true }
|
|
1462
1544
|
];
|
|
1463
|
-
if (this.
|
|
1545
|
+
if (this.tokenizedSearch) {
|
|
1464
1546
|
this.queryTokens.push(...this.searchTokenizer(this.searchQuery));
|
|
1465
1547
|
}
|
|
1466
1548
|
}
|
|
@@ -1502,7 +1584,7 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1502
1584
|
}
|
|
1503
1585
|
savedTableState.columns?.push(savedColumnState);
|
|
1504
1586
|
}
|
|
1505
|
-
const storage = options.storage
|
|
1587
|
+
const storage = options.storage ?? window.localStorage;
|
|
1506
1588
|
try {
|
|
1507
1589
|
storage.setItem(options.key, JSON.stringify(savedTableState));
|
|
1508
1590
|
} catch (error) {
|
|
@@ -1514,7 +1596,8 @@ var YatlTableController = class extends TypedEventTarget {
|
|
|
1514
1596
|
return;
|
|
1515
1597
|
}
|
|
1516
1598
|
const options = { ...DEFAULT_STORAGE_OPTIONS, ...this.storageOptions };
|
|
1517
|
-
const
|
|
1599
|
+
const storage = options.storage ?? window.localStorage;
|
|
1600
|
+
const json = storage.getItem(options.key);
|
|
1518
1601
|
if (!json) {
|
|
1519
1602
|
return;
|
|
1520
1603
|
}
|
|
@@ -1579,8 +1662,8 @@ function warnInvalidIdFunction(index, rowId, row) {
|
|
|
1579
1662
|
}
|
|
1580
1663
|
|
|
1581
1664
|
// src/table/table.styles.ts
|
|
1582
|
-
var
|
|
1583
|
-
var table_styles_default =
|
|
1665
|
+
var import_lit4 = require("lit");
|
|
1666
|
+
var table_styles_default = import_lit4.css`
|
|
1584
1667
|
@layer base, striped, hover, selected;
|
|
1585
1668
|
|
|
1586
1669
|
:host {
|
|
@@ -1603,7 +1686,7 @@ var table_styles_default = import_lit2.css`
|
|
|
1603
1686
|
);
|
|
1604
1687
|
|
|
1605
1688
|
--table-header-text: var(--yatl-table-header-text, var(--yatl-text-1));
|
|
1606
|
-
--table-header-bg: var(--yatl-table-header-bg, var(--yatl-surface-
|
|
1689
|
+
--table-header-bg: var(--yatl-table-header-bg, var(--yatl-surface-2));
|
|
1607
1690
|
--table-header-hover-bg: var(
|
|
1608
1691
|
--yatl-table-header-hover-bg,
|
|
1609
1692
|
color-mix(in srgb, var(--yatl-color-mix) 4%, var(--table-header-bg))
|
|
@@ -1705,6 +1788,20 @@ var table_styles_default = import_lit2.css`
|
|
|
1705
1788
|
justify-content: flex-end;
|
|
1706
1789
|
}
|
|
1707
1790
|
|
|
1791
|
+
.cell.is-editing {
|
|
1792
|
+
padding: 0;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
.cell.is-editing > * {
|
|
1796
|
+
width: 100%;
|
|
1797
|
+
height: 100%;
|
|
1798
|
+
box-sizing: border-box;
|
|
1799
|
+
outline: none;
|
|
1800
|
+
padding: var(--yatl-spacing-m);
|
|
1801
|
+
border: 1px solid var(--yatl-color-brand);
|
|
1802
|
+
border-radius: var(--yatl-radius-xs);
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1708
1805
|
.table.resizing * {
|
|
1709
1806
|
cursor: col-resize !important;
|
|
1710
1807
|
}
|
|
@@ -1732,8 +1829,17 @@ var table_styles_default = import_lit2.css`
|
|
|
1732
1829
|
transition: background-color 0.2s;
|
|
1733
1830
|
}
|
|
1734
1831
|
|
|
1832
|
+
.cell-wrapper:has(.cell-index) {
|
|
1833
|
+
overflow: visible;
|
|
1834
|
+
background-color: var(--table-header-bg);
|
|
1835
|
+
height: calc(100% + var(--table-border-width));
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1735
1838
|
.row-number-cell {
|
|
1736
1839
|
background-color: var(--table-header-bg);
|
|
1840
|
+
border-right-width: var(--table-border-width);
|
|
1841
|
+
border-right-color: var(--table-border-color);
|
|
1842
|
+
border-right-style: solid;
|
|
1737
1843
|
}
|
|
1738
1844
|
|
|
1739
1845
|
.message {
|
|
@@ -1780,11 +1886,10 @@ var table_styles_default = import_lit2.css`
|
|
|
1780
1886
|
}
|
|
1781
1887
|
|
|
1782
1888
|
/* Layout stuff
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
/* stylelint-disable-next-line no-duplicate-selectors */
|
|
1889
|
+
* Most of this is functional and needed
|
|
1890
|
+
* for the table to work properly.
|
|
1891
|
+
* Modify with caution!
|
|
1892
|
+
*/
|
|
1788
1893
|
:host {
|
|
1789
1894
|
display: block;
|
|
1790
1895
|
width: 100%;
|
|
@@ -1965,29 +2070,42 @@ var table_styles_default = import_lit2.css`
|
|
|
1965
2070
|
white-space: nowrap;
|
|
1966
2071
|
overflow: hidden;
|
|
1967
2072
|
}
|
|
2073
|
+
|
|
2074
|
+
@media print {
|
|
2075
|
+
.table {
|
|
2076
|
+
color: black;
|
|
2077
|
+
width: 100%;
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
.row {
|
|
2081
|
+
break-inside: avoid;
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
.cell {
|
|
2085
|
+
border: 1px solid black;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
1968
2088
|
`;
|
|
1969
2089
|
|
|
1970
2090
|
// src/table/table.ts
|
|
1971
|
-
var YatlTable = class extends
|
|
2091
|
+
var YatlTable = class extends import_lit5.LitElement {
|
|
1972
2092
|
constructor() {
|
|
1973
2093
|
super(...arguments);
|
|
1974
2094
|
// #region --- State Data ---
|
|
1975
|
-
// Property data
|
|
1976
2095
|
this.resizeState = null;
|
|
1977
2096
|
// Column drag & drop state
|
|
1978
2097
|
this.dragColumn = null;
|
|
1979
2098
|
this.useYatlUi = false;
|
|
1980
|
-
|
|
1981
|
-
// #region --- Properties ---
|
|
2099
|
+
this.editingState = null;
|
|
1982
2100
|
this._controller = new YatlTableController(this);
|
|
1983
2101
|
this.striped = false;
|
|
1984
|
-
this.sortable =
|
|
1985
|
-
this.resizable =
|
|
1986
|
-
this.
|
|
1987
|
-
this.
|
|
1988
|
-
this.
|
|
1989
|
-
this.
|
|
1990
|
-
this.
|
|
2102
|
+
this.sortable = false;
|
|
2103
|
+
this.resizable = false;
|
|
2104
|
+
this.reorderable = false;
|
|
2105
|
+
this.rowNumbers = false;
|
|
2106
|
+
this.virtualScroll = false;
|
|
2107
|
+
this.hideFooter = false;
|
|
2108
|
+
this.disableEditing = false;
|
|
1991
2109
|
this.nullValuePlaceholder = "-";
|
|
1992
2110
|
this.emptyMessage = "No records to display";
|
|
1993
2111
|
this.noResultsMessage = "No matching records found";
|
|
@@ -2005,7 +2123,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2005
2123
|
"yatl-table-view-change"
|
|
2006
2124
|
];
|
|
2007
2125
|
this.redispatchControllerEvent = (event) => {
|
|
2008
|
-
if (event instanceof
|
|
2126
|
+
if (event instanceof YatlTableControllerEvent) {
|
|
2009
2127
|
this.dispatchEvent(event.clone());
|
|
2010
2128
|
}
|
|
2011
2129
|
};
|
|
@@ -2035,7 +2153,13 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2035
2153
|
this.sort(column.field, sortOrder, !multiSort);
|
|
2036
2154
|
};
|
|
2037
2155
|
this.handleCellClick = (event, row, field) => {
|
|
2038
|
-
if (window.getSelection()?.toString())
|
|
2156
|
+
if (this.editingState || window.getSelection()?.toString()) {
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
const target = event.target;
|
|
2160
|
+
if (target.tagName === "A" || target.tagName === "BUTTON" || target.tagName === "YATL-BUTTON") {
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2039
2163
|
const rowId = this.controller.getRowId(row);
|
|
2040
2164
|
const rowIndex = this.controller.getRowIndex(row);
|
|
2041
2165
|
this.dispatchEvent(
|
|
@@ -2149,6 +2273,8 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2149
2273
|
return this.virtualizer[import_virtualize.virtualizerRef];
|
|
2150
2274
|
}
|
|
2151
2275
|
}
|
|
2276
|
+
// #endregion
|
|
2277
|
+
// #region --- Properties ---
|
|
2152
2278
|
get controller() {
|
|
2153
2279
|
return this._controller;
|
|
2154
2280
|
}
|
|
@@ -2164,36 +2290,12 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2164
2290
|
oldController.detach(this);
|
|
2165
2291
|
controller.attach(this);
|
|
2166
2292
|
this._controller = controller;
|
|
2167
|
-
this.requestUpdate("controller", oldController);
|
|
2168
|
-
}
|
|
2169
|
-
get enableSearchTokenization() {
|
|
2170
|
-
return this.controller.enableSearchTokenization;
|
|
2171
|
-
}
|
|
2172
|
-
set enableSearchTokenization(enable) {
|
|
2173
|
-
const oldValue = this.enableSearchTokenization;
|
|
2174
|
-
if (oldValue === enable) {
|
|
2175
|
-
return;
|
|
2176
|
-
}
|
|
2177
|
-
this.controller.enableSearchTokenization = enable;
|
|
2178
|
-
this.requestUpdate("enableSearchTokenization", oldValue);
|
|
2179
|
-
}
|
|
2180
|
-
get enableSearchScoring() {
|
|
2181
|
-
return this.controller.enableSearchScoring;
|
|
2182
|
-
}
|
|
2183
|
-
set enableSearchScoring(enable) {
|
|
2184
|
-
const oldValue = this.enableSearchScoring;
|
|
2185
|
-
if (oldValue === enable) {
|
|
2186
|
-
return;
|
|
2187
|
-
}
|
|
2188
|
-
this.controller.enableSearchScoring = enable;
|
|
2189
|
-
this.requestUpdate("enableSearchScoring", oldValue);
|
|
2190
2293
|
}
|
|
2191
2294
|
get columns() {
|
|
2192
2295
|
return this.controller.columns;
|
|
2193
2296
|
}
|
|
2194
2297
|
set columns(columns) {
|
|
2195
|
-
|
|
2196
|
-
if (oldValue === columns) {
|
|
2298
|
+
if (this.columns === columns) {
|
|
2197
2299
|
return;
|
|
2198
2300
|
}
|
|
2199
2301
|
for (const column of columns) {
|
|
@@ -2202,7 +2304,6 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2202
2304
|
}
|
|
2203
2305
|
}
|
|
2204
2306
|
this.controller.columns = columns;
|
|
2205
|
-
this.requestUpdate("columns", oldValue);
|
|
2206
2307
|
}
|
|
2207
2308
|
/**
|
|
2208
2309
|
* Gets a list of columns with the display role
|
|
@@ -2215,7 +2316,6 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2215
2316
|
return this.controller.columnStates;
|
|
2216
2317
|
}
|
|
2217
2318
|
set columnStates(states) {
|
|
2218
|
-
const oldValue = this.columnStates;
|
|
2219
2319
|
let changed = false;
|
|
2220
2320
|
for (const state2 of states) {
|
|
2221
2321
|
const oldState = this.getColumnState(state2.field);
|
|
@@ -2229,51 +2329,76 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2229
2329
|
return;
|
|
2230
2330
|
}
|
|
2231
2331
|
this.controller.columnStates = states;
|
|
2232
|
-
this.requestUpdate("columnStates", oldValue);
|
|
2233
2332
|
}
|
|
2333
|
+
get data() {
|
|
2334
|
+
return this.controller.data;
|
|
2335
|
+
}
|
|
2336
|
+
set data(value) {
|
|
2337
|
+
this.controller.data = value;
|
|
2338
|
+
}
|
|
2339
|
+
get filteredData() {
|
|
2340
|
+
return this.controller.filteredData;
|
|
2341
|
+
}
|
|
2342
|
+
get dataUpdateTimestamp() {
|
|
2343
|
+
return this.controller.dataUpdateTimestamp;
|
|
2344
|
+
}
|
|
2345
|
+
get filters() {
|
|
2346
|
+
return this.controller.filters;
|
|
2347
|
+
}
|
|
2348
|
+
set filters(filters) {
|
|
2349
|
+
if (this.filters === filters) {
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2352
|
+
this.controller.filters = filters;
|
|
2353
|
+
}
|
|
2354
|
+
/** @attr search-query */
|
|
2234
2355
|
get searchQuery() {
|
|
2235
2356
|
return this.controller.searchQuery;
|
|
2236
2357
|
}
|
|
2237
2358
|
set searchQuery(query2) {
|
|
2238
|
-
|
|
2239
|
-
if (oldValue === query2) {
|
|
2359
|
+
if (this.searchQuery === query2) {
|
|
2240
2360
|
return;
|
|
2241
2361
|
}
|
|
2242
2362
|
this.controller.searchQuery = query2;
|
|
2243
|
-
this.requestUpdate("searchQuery", oldValue);
|
|
2244
2363
|
}
|
|
2245
|
-
|
|
2246
|
-
|
|
2364
|
+
/** @attr tokenized-search */
|
|
2365
|
+
get tokenizedSearch() {
|
|
2366
|
+
return this.controller.tokenizedSearch;
|
|
2247
2367
|
}
|
|
2248
|
-
set
|
|
2249
|
-
|
|
2250
|
-
if (oldValue === tokenizer) {
|
|
2368
|
+
set tokenizedSearch(enable) {
|
|
2369
|
+
if (this.tokenizedSearch === enable) {
|
|
2251
2370
|
return;
|
|
2252
2371
|
}
|
|
2253
|
-
this.controller.
|
|
2254
|
-
this.requestUpdate("searchTokenizer", oldValue);
|
|
2372
|
+
this.controller.tokenizedSearch = enable;
|
|
2255
2373
|
}
|
|
2256
|
-
|
|
2257
|
-
|
|
2374
|
+
/** @attr scored-search */
|
|
2375
|
+
get scoredSearch() {
|
|
2376
|
+
return this.controller.scoredSearch;
|
|
2258
2377
|
}
|
|
2259
|
-
set
|
|
2260
|
-
|
|
2261
|
-
if (oldValue === filters) {
|
|
2378
|
+
set scoredSearch(enable) {
|
|
2379
|
+
if (this.scoredSearch === enable) {
|
|
2262
2380
|
return;
|
|
2263
2381
|
}
|
|
2264
|
-
this.controller.
|
|
2265
|
-
|
|
2382
|
+
this.controller.scoredSearch = enable;
|
|
2383
|
+
}
|
|
2384
|
+
get searchTokenizer() {
|
|
2385
|
+
return this.controller.searchTokenizer;
|
|
2266
2386
|
}
|
|
2387
|
+
set searchTokenizer(tokenizer) {
|
|
2388
|
+
if (this.searchTokenizer === tokenizer) {
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
this.controller.searchTokenizer = tokenizer;
|
|
2392
|
+
}
|
|
2393
|
+
/** @attr row-selection-method */
|
|
2267
2394
|
get rowSelectionMethod() {
|
|
2268
2395
|
return this.controller.rowSelectionMethod;
|
|
2269
2396
|
}
|
|
2270
2397
|
set rowSelectionMethod(selection) {
|
|
2271
|
-
|
|
2272
|
-
if (oldValue === selection) {
|
|
2398
|
+
if (this.rowSelectionMethod === selection) {
|
|
2273
2399
|
return;
|
|
2274
2400
|
}
|
|
2275
2401
|
this.controller.rowSelectionMethod = selection;
|
|
2276
|
-
this.requestUpdate("rowSelectionMethod", oldValue);
|
|
2277
2402
|
}
|
|
2278
2403
|
get selectedRowIds() {
|
|
2279
2404
|
return this.controller.selectedRowIds;
|
|
@@ -2284,40 +2409,21 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2284
2409
|
return;
|
|
2285
2410
|
}
|
|
2286
2411
|
this.controller.selectedRowIds = rows;
|
|
2287
|
-
this.requestUpdate("selectedRows", [...oldValue]);
|
|
2288
2412
|
}
|
|
2289
2413
|
get storageOptions() {
|
|
2290
2414
|
return this.controller.storageOptions;
|
|
2291
2415
|
}
|
|
2292
2416
|
set storageOptions(options) {
|
|
2293
|
-
const oldValue = this.storageOptions;
|
|
2294
2417
|
this.controller.storageOptions = options;
|
|
2295
|
-
this.requestUpdate("storageOptions", oldValue);
|
|
2296
2418
|
}
|
|
2297
2419
|
get rowIdCallback() {
|
|
2298
2420
|
return this.controller.rowIdCallback;
|
|
2299
2421
|
}
|
|
2300
2422
|
set rowIdCallback(callback) {
|
|
2301
|
-
|
|
2302
|
-
if (oldValue === callback) {
|
|
2423
|
+
if (this.rowIdCallback === callback) {
|
|
2303
2424
|
return;
|
|
2304
2425
|
}
|
|
2305
2426
|
this.controller.rowIdCallback = callback;
|
|
2306
|
-
this.requestUpdate("rowIdCallback", oldValue);
|
|
2307
|
-
}
|
|
2308
|
-
get data() {
|
|
2309
|
-
return this.controller.data;
|
|
2310
|
-
}
|
|
2311
|
-
set data(value) {
|
|
2312
|
-
const oldValue = this.data;
|
|
2313
|
-
this.controller.data = value;
|
|
2314
|
-
this.requestUpdate("data", oldValue);
|
|
2315
|
-
}
|
|
2316
|
-
get filteredData() {
|
|
2317
|
-
return this.controller.filteredData;
|
|
2318
|
-
}
|
|
2319
|
-
get dataUpdateTimestamp() {
|
|
2320
|
-
return this.controller.dataUpdateTimestamp;
|
|
2321
2427
|
}
|
|
2322
2428
|
// #endregion
|
|
2323
2429
|
// #region --- Public Methods ---
|
|
@@ -2445,6 +2551,38 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2445
2551
|
a.click();
|
|
2446
2552
|
a.remove();
|
|
2447
2553
|
}
|
|
2554
|
+
async print(title) {
|
|
2555
|
+
if (title) {
|
|
2556
|
+
document.title = title;
|
|
2557
|
+
}
|
|
2558
|
+
const printSheet = new CSSStyleSheet();
|
|
2559
|
+
printSheet.replaceSync(`
|
|
2560
|
+
@media print {
|
|
2561
|
+
body > *:not(.yatl-printable) {
|
|
2562
|
+
display: none !important;
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
body {
|
|
2566
|
+
height: auto !important;
|
|
2567
|
+
overflow: visible !important;
|
|
2568
|
+
background: white !important;
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
`);
|
|
2572
|
+
const documentStyleSheets = document.adoptedStyleSheets;
|
|
2573
|
+
document.adoptedStyleSheets = [...documentStyleSheets, printSheet];
|
|
2574
|
+
const printTable = document.createElement("yatl-table");
|
|
2575
|
+
printTable.classList.add("yatl-printable");
|
|
2576
|
+
printTable.controller = this.controller;
|
|
2577
|
+
printTable.virtualScroll = false;
|
|
2578
|
+
document.body.append(printTable);
|
|
2579
|
+
await printTable.updateComplete;
|
|
2580
|
+
requestAnimationFrame(() => {
|
|
2581
|
+
window.print();
|
|
2582
|
+
printTable.remove();
|
|
2583
|
+
document.adoptedStyleSheets = documentStyleSheets;
|
|
2584
|
+
});
|
|
2585
|
+
}
|
|
2448
2586
|
scrollToRow(row) {
|
|
2449
2587
|
const index = this.data.findIndex((v) => v === row);
|
|
2450
2588
|
if (typeof index === "number") {
|
|
@@ -2586,28 +2724,28 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2586
2724
|
// #endregion
|
|
2587
2725
|
// #region Render Methods
|
|
2588
2726
|
renderColumnSortIcon(column, state2) {
|
|
2589
|
-
return column.sortable ?? this.sortable ?
|
|
2727
|
+
return column.sortable ?? this.sortable ? import_lit5.html`<div
|
|
2590
2728
|
part="header-sort-icon"
|
|
2591
2729
|
class=${(0, import_class_map.classMap)({
|
|
2592
2730
|
"sort-icon": true,
|
|
2593
2731
|
ascending: state2.sort?.order === "asc",
|
|
2594
2732
|
descending: state2.sort?.order === "desc"
|
|
2595
2733
|
})}
|
|
2596
|
-
></div>` :
|
|
2734
|
+
></div>` : import_lit5.nothing;
|
|
2597
2735
|
}
|
|
2598
2736
|
renderColumnResizer(column, _state) {
|
|
2599
|
-
return column.resizable ?? this.resizable ?
|
|
2737
|
+
return column.resizable ?? this.resizable ? import_lit5.html`
|
|
2600
2738
|
<div
|
|
2601
2739
|
part="header-resizer"
|
|
2602
2740
|
class="resizer"
|
|
2603
2741
|
@click=${(event) => event.stopPropagation()}
|
|
2604
2742
|
@mousedown=${(event) => this.handleResizeMouseDown(event, column.field)}
|
|
2605
2743
|
></div>
|
|
2606
|
-
` :
|
|
2744
|
+
` : import_lit5.nothing;
|
|
2607
2745
|
}
|
|
2608
2746
|
renderHeaderCell(column) {
|
|
2609
2747
|
if (!column) {
|
|
2610
|
-
return
|
|
2748
|
+
return import_lit5.nothing;
|
|
2611
2749
|
}
|
|
2612
2750
|
const state2 = this.getColumnState(column.field);
|
|
2613
2751
|
const title = column.title ?? column.field;
|
|
@@ -2620,15 +2758,16 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2620
2758
|
cell: true,
|
|
2621
2759
|
sortable: column.sortable ?? this.sortable
|
|
2622
2760
|
};
|
|
2623
|
-
return this.renderCellWrapper(
|
|
2761
|
+
return this.renderCellWrapper(import_lit5.html`
|
|
2624
2762
|
<div
|
|
2625
|
-
role=${(0,
|
|
2626
|
-
aria-hidden=${(0,
|
|
2763
|
+
role=${(0, import_if_defined2.ifDefined)(role)}
|
|
2764
|
+
aria-hidden=${(0, import_if_defined2.ifDefined)(hidden)}
|
|
2627
2765
|
aria-sort=${ariaSort}
|
|
2628
2766
|
aria-label=${title}
|
|
2629
2767
|
part="cell header-cell"
|
|
2630
2768
|
class=${(0, import_class_map.classMap)(classes)}
|
|
2631
|
-
|
|
2769
|
+
title=${title}
|
|
2770
|
+
draggable=${(0, import_if_defined2.ifDefined)(this.reorderable ? true : void 0)}
|
|
2632
2771
|
data-field=${column.field}
|
|
2633
2772
|
@dragstart=${(event) => this.handleDragColumnStart(event, column.field)}
|
|
2634
2773
|
@dragenter=${this.handleDragColumnEnter}
|
|
@@ -2651,20 +2790,20 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2651
2790
|
}
|
|
2652
2791
|
renderRowNumberHeader() {
|
|
2653
2792
|
return this.renderCellWrapper(
|
|
2654
|
-
|
|
2793
|
+
import_lit5.html`<div part="cell-index" class="cell-index"></div>`
|
|
2655
2794
|
);
|
|
2656
2795
|
}
|
|
2657
2796
|
renderSelectionHeader() {
|
|
2658
2797
|
return this.renderCellWrapper(
|
|
2659
|
-
|
|
2798
|
+
import_lit5.html`<div part="cell-selector" class="cell-selector"></div>`
|
|
2660
2799
|
);
|
|
2661
2800
|
}
|
|
2662
2801
|
renderHeader() {
|
|
2663
2802
|
const classes = {
|
|
2664
2803
|
header: true,
|
|
2665
|
-
reorderable: this.
|
|
2804
|
+
reorderable: this.reorderable
|
|
2666
2805
|
};
|
|
2667
|
-
return
|
|
2806
|
+
return import_lit5.html`
|
|
2668
2807
|
<div role="rowgroup" part="header" class=${(0, import_class_map.classMap)(classes)}>
|
|
2669
2808
|
<div role="row" class="row header-row" part="row header-row">
|
|
2670
2809
|
${this.renderRowNumberHeader()} ${this.renderSelectionHeader()}
|
|
@@ -2681,7 +2820,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2681
2820
|
return this.nullValuePlaceholder;
|
|
2682
2821
|
}
|
|
2683
2822
|
const indices = this.controller.getRowHighlightIndicies(row);
|
|
2684
|
-
return
|
|
2823
|
+
return indices ? highlightText(String(value), indices[column.field]) : value;
|
|
2685
2824
|
}
|
|
2686
2825
|
renderCell(column, row) {
|
|
2687
2826
|
let value = getNestedValue(row, column.field);
|
|
@@ -2689,22 +2828,37 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2689
2828
|
if (Array.isArray(userParts)) {
|
|
2690
2829
|
userParts = userParts.join(" ");
|
|
2691
2830
|
}
|
|
2692
|
-
const
|
|
2831
|
+
const inputType = this.getInputTypeFromValue(value);
|
|
2693
2832
|
const classes = {
|
|
2694
2833
|
cell: true,
|
|
2695
|
-
"is-number":
|
|
2834
|
+
"is-number": inputType === "number"
|
|
2696
2835
|
};
|
|
2836
|
+
const rowId = this.controller.getRowId(row);
|
|
2837
|
+
const field = column.field;
|
|
2838
|
+
if (column.editor && !this.disableEditing && this.editingState && this.editingState.id === rowId && this.editingState.field === field) {
|
|
2839
|
+
return this.renderCellWrapper(import_lit5.html`
|
|
2840
|
+
<div
|
|
2841
|
+
role="cell"
|
|
2842
|
+
part="cell body-cell cell-${column.field}"
|
|
2843
|
+
class=${(0, import_class_map.classMap)({ ...classes, "is-editing": true })}
|
|
2844
|
+
data-field=${column.field}
|
|
2845
|
+
>
|
|
2846
|
+
${column.editor.render(value, field, row, this.controller)}
|
|
2847
|
+
</div>
|
|
2848
|
+
`);
|
|
2849
|
+
}
|
|
2697
2850
|
if (typeof column.valueFormatter === "function") {
|
|
2698
2851
|
value = column.valueFormatter(value, row);
|
|
2699
2852
|
}
|
|
2700
|
-
return this.renderCellWrapper(
|
|
2853
|
+
return this.renderCellWrapper(import_lit5.html`
|
|
2701
2854
|
<div
|
|
2702
2855
|
role="cell"
|
|
2703
2856
|
part="cell body-cell cell-${column.field} ${userParts}"
|
|
2704
2857
|
data-field=${column.field}
|
|
2705
2858
|
class=${(0, import_class_map.classMap)(classes)}
|
|
2706
|
-
title=${(0,
|
|
2707
|
-
@click=${(event) => this.handleCellClick(event, row,
|
|
2859
|
+
title=${(0, import_if_defined2.ifDefined)(value ? String(value) : void 0)}
|
|
2860
|
+
@click=${(event) => this.handleCellClick(event, row, field)}
|
|
2861
|
+
@dblclick=${() => this.handleCellDoubleClick(row, field)}
|
|
2708
2862
|
>
|
|
2709
2863
|
<span class="truncate">
|
|
2710
2864
|
${this.renderCellContents(value, column, row)}
|
|
@@ -2713,12 +2867,12 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2713
2867
|
`);
|
|
2714
2868
|
}
|
|
2715
2869
|
renderCheckbox(row, selected) {
|
|
2716
|
-
return this.useYatlUi ?
|
|
2870
|
+
return this.useYatlUi ? import_lit5.html`<yatl-checkbox
|
|
2717
2871
|
part="row-checkbox"
|
|
2718
2872
|
class="row-checkbox"
|
|
2719
2873
|
.checked=${selected}
|
|
2720
2874
|
@change=${(event) => this.handleRowSelectionClicked(event, row)}
|
|
2721
|
-
></yatl-checkbox>` :
|
|
2875
|
+
></yatl-checkbox>` : import_lit5.html`<input
|
|
2722
2876
|
part="row-checkbox"
|
|
2723
2877
|
class="row-checkbox"
|
|
2724
2878
|
type="checkbox"
|
|
@@ -2727,7 +2881,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2727
2881
|
/>`;
|
|
2728
2882
|
}
|
|
2729
2883
|
renderRowSelectorCell(row, selected) {
|
|
2730
|
-
return this.renderCellWrapper(
|
|
2884
|
+
return this.renderCellWrapper(import_lit5.html`
|
|
2731
2885
|
<div part="cell body-cell" class="cell body-cell">
|
|
2732
2886
|
<div part="row-selector-cell" class="row-selector-cell">
|
|
2733
2887
|
<label> ${this.renderCheckbox(row, selected)} </label>
|
|
@@ -2736,7 +2890,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2736
2890
|
`);
|
|
2737
2891
|
}
|
|
2738
2892
|
renderRowNumberCell(rowNumber) {
|
|
2739
|
-
return this.renderCellWrapper(
|
|
2893
|
+
return this.renderCellWrapper(import_lit5.html`
|
|
2740
2894
|
<div part="cell body-cell" class="cell body-cell">
|
|
2741
2895
|
<div part="row-number-cell" class="row-number-cell">${rowNumber}</div>
|
|
2742
2896
|
</div>
|
|
@@ -2755,7 +2909,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2755
2909
|
"row-odd": renderIndex % 2 !== 0
|
|
2756
2910
|
};
|
|
2757
2911
|
const rowIndex = renderIndex + 1;
|
|
2758
|
-
return
|
|
2912
|
+
return import_lit5.html`
|
|
2759
2913
|
<div
|
|
2760
2914
|
role="row"
|
|
2761
2915
|
aria-rowindex=${rowIndex}
|
|
@@ -2771,22 +2925,22 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2771
2925
|
}
|
|
2772
2926
|
renderBodyContents() {
|
|
2773
2927
|
if (!this.hasVisibleColumn()) {
|
|
2774
|
-
return
|
|
2928
|
+
return import_lit5.html`
|
|
2775
2929
|
<div part="message" class="message">No visible columns.</div>
|
|
2776
2930
|
`;
|
|
2777
2931
|
}
|
|
2778
2932
|
if (this.data.length === 0) {
|
|
2779
|
-
return
|
|
2933
|
+
return import_lit5.html`
|
|
2780
2934
|
<div part="message" class="message">${this.emptyMessage}</div>
|
|
2781
2935
|
`;
|
|
2782
2936
|
}
|
|
2783
2937
|
if (this.filteredData.length === 0) {
|
|
2784
|
-
return
|
|
2938
|
+
return import_lit5.html`
|
|
2785
2939
|
<div part="message" class="message">${this.noResultsMessage}</div>
|
|
2786
2940
|
`;
|
|
2787
2941
|
}
|
|
2788
|
-
if (this.
|
|
2789
|
-
return
|
|
2942
|
+
if (this.virtualScroll) {
|
|
2943
|
+
return import_lit5.html`
|
|
2790
2944
|
<lit-virtualizer
|
|
2791
2945
|
.items=${this.filteredData}
|
|
2792
2946
|
.renderItem=${(item, index) => this.renderRow(item, index)}
|
|
@@ -2794,8 +2948,8 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2794
2948
|
</lit-virtualizer>
|
|
2795
2949
|
`;
|
|
2796
2950
|
}
|
|
2797
|
-
return
|
|
2798
|
-
${(0,
|
|
2951
|
+
return import_lit5.html`
|
|
2952
|
+
${(0, import_repeat2.repeat)(
|
|
2799
2953
|
this.filteredData,
|
|
2800
2954
|
(item) => this.controller.getRowId(item),
|
|
2801
2955
|
(item, index) => this.renderRow(item, index)
|
|
@@ -2803,8 +2957,8 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2803
2957
|
`;
|
|
2804
2958
|
}
|
|
2805
2959
|
renderFooter() {
|
|
2806
|
-
if (
|
|
2807
|
-
return
|
|
2960
|
+
if (this.hideFooter) {
|
|
2961
|
+
return import_lit5.nothing;
|
|
2808
2962
|
}
|
|
2809
2963
|
const total = this.data.length;
|
|
2810
2964
|
const filtered = this.filteredData.length;
|
|
@@ -2817,7 +2971,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2817
2971
|
timeStyle: "short"
|
|
2818
2972
|
});
|
|
2819
2973
|
const lastUpdateText = this.dataUpdateTimestamp ? formatter.format(this.dataUpdateTimestamp) : "Never";
|
|
2820
|
-
return
|
|
2974
|
+
return import_lit5.html`
|
|
2821
2975
|
<div part="footer" class="footer">
|
|
2822
2976
|
<slot name="footer">
|
|
2823
2977
|
<span part="row-count">${rowCountText}</span>
|
|
@@ -2831,7 +2985,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2831
2985
|
const style = {
|
|
2832
2986
|
"--grid-template": gridTemplate
|
|
2833
2987
|
};
|
|
2834
|
-
return
|
|
2988
|
+
return import_lit5.html`
|
|
2835
2989
|
<div
|
|
2836
2990
|
role="table"
|
|
2837
2991
|
aria-label="Data Table"
|
|
@@ -2851,13 +3005,15 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2851
3005
|
`;
|
|
2852
3006
|
}
|
|
2853
3007
|
renderCellWrapper(content) {
|
|
2854
|
-
return
|
|
3008
|
+
return import_lit5.html` <div class="cell-wrapper">${content}</div> `;
|
|
2855
3009
|
}
|
|
2856
3010
|
// #endregion
|
|
2857
3011
|
// #region --- Lifecycle Methods ---
|
|
2858
3012
|
connectedCallback() {
|
|
2859
3013
|
super.connectedCallback();
|
|
2860
3014
|
this.addControllerListeners(this.controller);
|
|
3015
|
+
this.addEventListener("mousedown", this.handleMouseDown);
|
|
3016
|
+
this.addEventListener("keydown", this.handleCellInputKeypress);
|
|
2861
3017
|
if (!this.useYatlUi) {
|
|
2862
3018
|
customElements.whenDefined("yatl-checkbox").then(() => {
|
|
2863
3019
|
this.useYatlUi = true;
|
|
@@ -2867,8 +3023,21 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2867
3023
|
disconnectedCallback() {
|
|
2868
3024
|
super.disconnectedCallback();
|
|
2869
3025
|
this.removeControllerListeners(this.controller);
|
|
2870
|
-
|
|
2871
|
-
|
|
3026
|
+
this.removeEventListener("mousedown", this.handleMouseDown);
|
|
3027
|
+
this.removeEventListener("keydown", this.handleCellInputKeypress);
|
|
3028
|
+
window.removeEventListener("mousemove", this.handleResizeMouseMove);
|
|
3029
|
+
window.removeEventListener("mouseup", this.handleResizeMouseUp);
|
|
3030
|
+
}
|
|
3031
|
+
updated(changedProperties) {
|
|
3032
|
+
super.updated(changedProperties);
|
|
3033
|
+
if (this.editor && document.activeElement !== this.editor) {
|
|
3034
|
+
setTimeout(() => {
|
|
3035
|
+
this.editor?.focus();
|
|
3036
|
+
if (this.editor instanceof HTMLInputElement) {
|
|
3037
|
+
this.editor.select();
|
|
3038
|
+
}
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
2872
3041
|
}
|
|
2873
3042
|
addControllerListeners(controller) {
|
|
2874
3043
|
for (const name of this.eventNames) {
|
|
@@ -2889,7 +3058,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2889
3058
|
*/
|
|
2890
3059
|
getGridWidths() {
|
|
2891
3060
|
const widths = [];
|
|
2892
|
-
if (this.
|
|
3061
|
+
if (this.rowNumbers) {
|
|
2893
3062
|
widths.push("var(--yatl-row-number-column-width, 48px)");
|
|
2894
3063
|
} else {
|
|
2895
3064
|
widths.push("0");
|
|
@@ -2906,7 +3075,7 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2906
3075
|
if (hasPixelWidth) {
|
|
2907
3076
|
widths.push(`${state2.width}px`);
|
|
2908
3077
|
} else {
|
|
2909
|
-
widths.push("minmax(
|
|
3078
|
+
widths.push("minmax(50px, 1fr)");
|
|
2910
3079
|
}
|
|
2911
3080
|
} else {
|
|
2912
3081
|
if (hasPixelWidth) {
|
|
@@ -2918,6 +3087,121 @@ var YatlTable = class extends import_lit3.LitElement {
|
|
|
2918
3087
|
}
|
|
2919
3088
|
return widths;
|
|
2920
3089
|
}
|
|
3090
|
+
getInputTypeFromValue(value) {
|
|
3091
|
+
const valueType = typeof value;
|
|
3092
|
+
if (valueType === "bigint" || valueType === "number") {
|
|
3093
|
+
return "number";
|
|
3094
|
+
}
|
|
3095
|
+
if (valueType === "boolean") {
|
|
3096
|
+
return "boolean";
|
|
3097
|
+
}
|
|
3098
|
+
if (value instanceof Date) {
|
|
3099
|
+
return "date";
|
|
3100
|
+
}
|
|
3101
|
+
return "text";
|
|
3102
|
+
}
|
|
3103
|
+
getNextEditableField(row, currentField) {
|
|
3104
|
+
let index = 0;
|
|
3105
|
+
if (currentField) {
|
|
3106
|
+
index = this.displayColumns.findIndex((c) => c.field === currentField);
|
|
3107
|
+
if (index < 0) {
|
|
3108
|
+
index = 0;
|
|
3109
|
+
} else {
|
|
3110
|
+
index++;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
for (const col of this.displayColumns.slice(index)) {
|
|
3114
|
+
if (col.editor && col.editor.canEdit(col.field, row)) {
|
|
3115
|
+
return col.field;
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
async saveEdits() {
|
|
3120
|
+
if (!this.editingState) {
|
|
3121
|
+
return;
|
|
3122
|
+
}
|
|
3123
|
+
const { id: rowId, field, originalValue } = this.editingState;
|
|
3124
|
+
const column = this.getDisplayColumn(field);
|
|
3125
|
+
const row = this.getRow(rowId);
|
|
3126
|
+
if (!column?.editor || !row) {
|
|
3127
|
+
return;
|
|
3128
|
+
}
|
|
3129
|
+
let value;
|
|
3130
|
+
const result = column.editor.save(
|
|
3131
|
+
originalValue,
|
|
3132
|
+
field,
|
|
3133
|
+
row,
|
|
3134
|
+
this.controller
|
|
3135
|
+
);
|
|
3136
|
+
if (result instanceof Promise) {
|
|
3137
|
+
value = await result;
|
|
3138
|
+
} else {
|
|
3139
|
+
value = result;
|
|
3140
|
+
}
|
|
3141
|
+
if (value !== void 0) {
|
|
3142
|
+
const updateData = {};
|
|
3143
|
+
setNestedValue(updateData, field, value);
|
|
3144
|
+
this.updateRow(rowId, updateData);
|
|
3145
|
+
this.dispatchEvent(
|
|
3146
|
+
new YatlCellEditEvent(row, rowId, field, originalValue, value)
|
|
3147
|
+
);
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
handleCellDoubleClick(row, field) {
|
|
3151
|
+
const column = this.getDisplayColumn(field);
|
|
3152
|
+
if (!column || !column.editor || !column.editor.canEdit(field, row)) {
|
|
3153
|
+
return;
|
|
3154
|
+
}
|
|
3155
|
+
column.editor.reset();
|
|
3156
|
+
const value = getNestedValue(row, field);
|
|
3157
|
+
this.editingState = {
|
|
3158
|
+
id: this.controller.getRowId(row),
|
|
3159
|
+
field,
|
|
3160
|
+
originalValue: value
|
|
3161
|
+
};
|
|
3162
|
+
}
|
|
3163
|
+
handleCellInputKeypress(event) {
|
|
3164
|
+
if (!this.editingState) {
|
|
3165
|
+
return;
|
|
3166
|
+
}
|
|
3167
|
+
if (event.key === "Escape") {
|
|
3168
|
+
this.editingState = null;
|
|
3169
|
+
} else if (event.key === "Enter") {
|
|
3170
|
+
this.saveEdits();
|
|
3171
|
+
this.editingState = null;
|
|
3172
|
+
} else if (event.key === "Tab") {
|
|
3173
|
+
this.saveEdits();
|
|
3174
|
+
const { id: rowId } = this.editingState;
|
|
3175
|
+
const row = this.getRow(rowId);
|
|
3176
|
+
let nextColumn = this.getNextEditableField(row, this.editingState.field);
|
|
3177
|
+
if (nextColumn) {
|
|
3178
|
+
return this.handleCellDoubleClick(row, nextColumn);
|
|
3179
|
+
}
|
|
3180
|
+
let rowIndex = this.filteredData.indexOf(row);
|
|
3181
|
+
if (rowIndex < 0) {
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
rowIndex++;
|
|
3185
|
+
if (rowIndex >= this.filteredData.length) {
|
|
3186
|
+
rowIndex = 0;
|
|
3187
|
+
}
|
|
3188
|
+
const nextRow = this.filteredData[rowIndex];
|
|
3189
|
+
nextColumn = this.getNextEditableField(nextRow);
|
|
3190
|
+
if (!nextColumn) {
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
this.handleCellDoubleClick(nextRow, nextColumn);
|
|
3194
|
+
event.preventDefault();
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
handleMouseDown(event) {
|
|
3198
|
+
const containsEditing = event.composedPath().filter((e) => e instanceof HTMLElement).some((e) => e.classList.contains("is-editing"));
|
|
3199
|
+
if (this.editingState && !containsEditing) {
|
|
3200
|
+
console.log("saving");
|
|
3201
|
+
this.saveEdits();
|
|
3202
|
+
this.editingState = null;
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
2921
3205
|
handleResizeMouseDown(event, field) {
|
|
2922
3206
|
event.preventDefault();
|
|
2923
3207
|
event.stopPropagation();
|
|
@@ -2967,90 +3251,101 @@ __decorateClass([
|
|
|
2967
3251
|
__decorateClass([
|
|
2968
3252
|
(0, import_decorators.query)("lit-virtualizer")
|
|
2969
3253
|
], YatlTable.prototype, "virtualizer", 2);
|
|
3254
|
+
__decorateClass([
|
|
3255
|
+
(0, import_decorators.query)(".cell.is-editing > *")
|
|
3256
|
+
], YatlTable.prototype, "editor", 2);
|
|
2970
3257
|
__decorateClass([
|
|
2971
3258
|
(0, import_decorators.state)()
|
|
2972
3259
|
], YatlTable.prototype, "useYatlUi", 2);
|
|
3260
|
+
__decorateClass([
|
|
3261
|
+
(0, import_decorators.state)()
|
|
3262
|
+
], YatlTable.prototype, "editingState", 2);
|
|
2973
3263
|
__decorateClass([
|
|
2974
3264
|
(0, import_decorators.property)({ attribute: false })
|
|
2975
3265
|
], YatlTable.prototype, "controller", 1);
|
|
2976
|
-
__decorateClass([
|
|
2977
|
-
(0, import_decorators.property)({ type: Boolean, reflect: true })
|
|
2978
|
-
], YatlTable.prototype, "striped", 2);
|
|
2979
|
-
__decorateClass([
|
|
2980
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "sortable" })
|
|
2981
|
-
], YatlTable.prototype, "sortable", 2);
|
|
2982
|
-
__decorateClass([
|
|
2983
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "resizable" })
|
|
2984
|
-
], YatlTable.prototype, "resizable", 2);
|
|
2985
|
-
__decorateClass([
|
|
2986
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "enable-virtual-scroll" })
|
|
2987
|
-
], YatlTable.prototype, "enableVirtualScroll", 2);
|
|
2988
|
-
__decorateClass([
|
|
2989
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "enable-search-highlight" })
|
|
2990
|
-
], YatlTable.prototype, "enableSearchHighlight", 2);
|
|
2991
|
-
__decorateClass([
|
|
2992
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "enable-search-tokenization" })
|
|
2993
|
-
], YatlTable.prototype, "enableSearchTokenization", 1);
|
|
2994
|
-
__decorateClass([
|
|
2995
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "enable-search-scoring" })
|
|
2996
|
-
], YatlTable.prototype, "enableSearchScoring", 1);
|
|
2997
|
-
__decorateClass([
|
|
2998
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "enable-column-reorder" })
|
|
2999
|
-
], YatlTable.prototype, "enableColumnReorder", 2);
|
|
3000
|
-
__decorateClass([
|
|
3001
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "enable-row-number-column" })
|
|
3002
|
-
], YatlTable.prototype, "enableRowNumberColumn", 2);
|
|
3003
|
-
__decorateClass([
|
|
3004
|
-
(0, import_decorators.property)({ type: Boolean, attribute: "enable-footer" })
|
|
3005
|
-
], YatlTable.prototype, "enableFooter", 2);
|
|
3006
|
-
__decorateClass([
|
|
3007
|
-
(0, import_decorators.property)({ type: String, attribute: "null-value-placeholder" })
|
|
3008
|
-
], YatlTable.prototype, "nullValuePlaceholder", 2);
|
|
3009
|
-
__decorateClass([
|
|
3010
|
-
(0, import_decorators.property)({ type: String, attribute: "empty-message" })
|
|
3011
|
-
], YatlTable.prototype, "emptyMessage", 2);
|
|
3012
|
-
__decorateClass([
|
|
3013
|
-
(0, import_decorators.property)({ type: String, attribute: "no-results-message" })
|
|
3014
|
-
], YatlTable.prototype, "noResultsMessage", 2);
|
|
3015
3266
|
__decorateClass([
|
|
3016
3267
|
(0, import_decorators.property)({ attribute: false })
|
|
3017
3268
|
], YatlTable.prototype, "columns", 1);
|
|
3018
3269
|
__decorateClass([
|
|
3019
3270
|
(0, import_decorators.property)({ attribute: false })
|
|
3020
3271
|
], YatlTable.prototype, "columnStates", 1);
|
|
3021
|
-
__decorateClass([
|
|
3022
|
-
(0, import_decorators.property)({ type: String, attribute: "search-query" })
|
|
3023
|
-
], YatlTable.prototype, "searchQuery", 1);
|
|
3024
3272
|
__decorateClass([
|
|
3025
3273
|
(0, import_decorators.property)({ attribute: false })
|
|
3026
|
-
], YatlTable.prototype, "
|
|
3274
|
+
], YatlTable.prototype, "data", 1);
|
|
3027
3275
|
__decorateClass([
|
|
3028
3276
|
(0, import_decorators.property)({ attribute: false })
|
|
3029
3277
|
], YatlTable.prototype, "filters", 1);
|
|
3278
|
+
__decorateClass([
|
|
3279
|
+
(0, import_decorators.property)({ type: String, attribute: "search-query" })
|
|
3280
|
+
], YatlTable.prototype, "searchQuery", 1);
|
|
3281
|
+
__decorateClass([
|
|
3282
|
+
(0, import_decorators.property)({ type: Boolean, attribute: "tokenized-search" })
|
|
3283
|
+
], YatlTable.prototype, "tokenizedSearch", 1);
|
|
3284
|
+
__decorateClass([
|
|
3285
|
+
(0, import_decorators.property)({ type: Boolean, attribute: "scored-search" })
|
|
3286
|
+
], YatlTable.prototype, "scoredSearch", 1);
|
|
3030
3287
|
__decorateClass([
|
|
3031
3288
|
(0, import_decorators.property)({ attribute: false })
|
|
3032
|
-
], YatlTable.prototype, "
|
|
3289
|
+
], YatlTable.prototype, "searchTokenizer", 1);
|
|
3033
3290
|
__decorateClass([
|
|
3034
|
-
(0, import_decorators.property)({ type: String })
|
|
3291
|
+
(0, import_decorators.property)({ type: String, attribute: "row-selection-method" })
|
|
3035
3292
|
], YatlTable.prototype, "rowSelectionMethod", 1);
|
|
3036
3293
|
__decorateClass([
|
|
3037
3294
|
(0, import_decorators.property)({ attribute: false })
|
|
3038
3295
|
], YatlTable.prototype, "selectedRowIds", 1);
|
|
3039
3296
|
__decorateClass([
|
|
3040
|
-
(0, import_decorators.property)({
|
|
3297
|
+
(0, import_decorators.property)({ attribute: false })
|
|
3041
3298
|
], YatlTable.prototype, "storageOptions", 1);
|
|
3042
3299
|
__decorateClass([
|
|
3043
3300
|
(0, import_decorators.property)({ attribute: false })
|
|
3044
3301
|
], YatlTable.prototype, "rowIdCallback", 1);
|
|
3302
|
+
__decorateClass([
|
|
3303
|
+
(0, import_decorators.property)({ type: Boolean, reflect: true })
|
|
3304
|
+
], YatlTable.prototype, "striped", 2);
|
|
3305
|
+
__decorateClass([
|
|
3306
|
+
(0, import_decorators.property)({ type: Boolean })
|
|
3307
|
+
], YatlTable.prototype, "sortable", 2);
|
|
3308
|
+
__decorateClass([
|
|
3309
|
+
(0, import_decorators.property)({ type: Boolean })
|
|
3310
|
+
], YatlTable.prototype, "resizable", 2);
|
|
3311
|
+
__decorateClass([
|
|
3312
|
+
(0, import_decorators.property)({ type: Boolean })
|
|
3313
|
+
], YatlTable.prototype, "reorderable", 2);
|
|
3314
|
+
__decorateClass([
|
|
3315
|
+
(0, import_decorators.property)({ type: Boolean, attribute: "row-numbers" })
|
|
3316
|
+
], YatlTable.prototype, "rowNumbers", 2);
|
|
3317
|
+
__decorateClass([
|
|
3318
|
+
(0, import_decorators.property)({ type: Boolean, attribute: "virtual-scroll" })
|
|
3319
|
+
], YatlTable.prototype, "virtualScroll", 2);
|
|
3320
|
+
__decorateClass([
|
|
3321
|
+
(0, import_decorators.property)({ type: Boolean, attribute: "hide-footer" })
|
|
3322
|
+
], YatlTable.prototype, "hideFooter", 2);
|
|
3323
|
+
__decorateClass([
|
|
3324
|
+
(0, import_decorators.property)({ type: Boolean, attribute: "disable-editing" })
|
|
3325
|
+
], YatlTable.prototype, "disableEditing", 2);
|
|
3326
|
+
__decorateClass([
|
|
3327
|
+
(0, import_decorators.property)({ type: String, attribute: "null-value-placeholder" })
|
|
3328
|
+
], YatlTable.prototype, "nullValuePlaceholder", 2);
|
|
3329
|
+
__decorateClass([
|
|
3330
|
+
(0, import_decorators.property)({ type: String, attribute: "empty-message" })
|
|
3331
|
+
], YatlTable.prototype, "emptyMessage", 2);
|
|
3332
|
+
__decorateClass([
|
|
3333
|
+
(0, import_decorators.property)({ type: String, attribute: "no-results-message" })
|
|
3334
|
+
], YatlTable.prototype, "noResultsMessage", 2);
|
|
3045
3335
|
__decorateClass([
|
|
3046
3336
|
(0, import_decorators.property)({ attribute: false })
|
|
3047
|
-
], YatlTable.prototype, "
|
|
3337
|
+
], YatlTable.prototype, "rowParts", 2);
|
|
3048
3338
|
YatlTable = __decorateClass([
|
|
3049
3339
|
(0, import_decorators.customElement)("yatl-table")
|
|
3050
3340
|
], YatlTable);
|
|
3051
3341
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3052
3342
|
0 && (module.exports = {
|
|
3343
|
+
InputEditor,
|
|
3344
|
+
NumberEditor,
|
|
3345
|
+
SelectEditor,
|
|
3346
|
+
TextEditor,
|
|
3053
3347
|
TypedEventTarget,
|
|
3348
|
+
YatlCellEditEvent,
|
|
3054
3349
|
YatlColumnReorderEvent,
|
|
3055
3350
|
YatlColumnReorderRequest,
|
|
3056
3351
|
YatlColumnResizeEvent,
|
|
@@ -3063,6 +3358,7 @@ YatlTable = __decorateClass([
|
|
|
3063
3358
|
YatlRowSelectRequest,
|
|
3064
3359
|
YatlTable,
|
|
3065
3360
|
YatlTableController,
|
|
3361
|
+
YatlTableControllerEvent,
|
|
3066
3362
|
YatlTableSearchEvent,
|
|
3067
3363
|
YatlTableStateChangeEvent,
|
|
3068
3364
|
YatlTableViewChangeEvent,
|