@su-labs/table 0.0.0-stage → 20.1.1
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/CHANGELOG.md +53 -0
- package/LICENSE +21 -0
- package/README.md +379 -2
- package/fesm2022/su-labs-table.mjs +713 -0
- package/fesm2022/su-labs-table.mjs.map +1 -0
- package/index.d.ts +301 -0
- package/package.json +52 -3
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
import { SuTableController, SU_TABLE_LABELS, suTableDropIndex } from '@su-labs/core/table';
|
|
2
|
+
export { SU_TABLE_LABELS, suCheckboxEditor, suDateEditor, suNumberEditor, suSelectEditor, suTextEditor } from '@su-labs/core/table';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { input, inject, TemplateRef, Directive, output, computed, ChangeDetectionStrategy, Component, viewChild, signal, booleanAttribute, ElementRef, contentChildren, DestroyRef, effect, untracked, afterRenderEffect } from '@angular/core';
|
|
5
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A custom cell for one column, in place of its text:
|
|
9
|
+
* `<ng-template suTableCell="status" [suTableCellOf]="users()" let-user>…</ng-template>`.
|
|
10
|
+
* `suTableCellOf` only types `let-user` as the row.
|
|
11
|
+
*/
|
|
12
|
+
class SuTableCellDirective {
|
|
13
|
+
/** The column's key */
|
|
14
|
+
key = input.required(...(ngDevMode ? [{ debugName: "key", alias: 'suTableCell' }] : [{ alias: 'suTableCell' }]));
|
|
15
|
+
/** The table's rows, to type the template's row */
|
|
16
|
+
rowsOf = input([], ...(ngDevMode ? [{ debugName: "rowsOf", alias: 'suTableCellOf' }] : [{ alias: 'suTableCellOf' }]));
|
|
17
|
+
template = inject(TemplateRef);
|
|
18
|
+
static ngTemplateContextGuard(_directive, context) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTableCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
22
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.35", type: SuTableCellDirective, isStandalone: true, selector: "ng-template[suTableCell]", inputs: { key: { classPropertyName: "key", publicName: "suTableCell", isSignal: true, isRequired: true, transformFunction: null }, rowsOf: { classPropertyName: "rowsOf", publicName: "suTableCellOf", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
23
|
+
}
|
|
24
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTableCellDirective, decorators: [{
|
|
25
|
+
type: Directive,
|
|
26
|
+
args: [{ selector: 'ng-template[suTableCell]' }]
|
|
27
|
+
}], propDecorators: { key: [{ type: i0.Input, args: [{ isSignal: true, alias: "suTableCell", required: true }] }], rowsOf: [{ type: i0.Input, args: [{ isSignal: true, alias: "suTableCellOf", required: false }] }] } });
|
|
28
|
+
|
|
29
|
+
/** The form control of one field being edited, chosen by its editor's input */
|
|
30
|
+
class SuTableFieldComponent {
|
|
31
|
+
field = input.required(...(ngDevMode ? [{ debugName: "field" }] : []));
|
|
32
|
+
controlId = input.required(...(ngDevMode ? [{ debugName: "controlId" }] : []));
|
|
33
|
+
/** The control's name when no visible `<label>` points at it */
|
|
34
|
+
ariaLabel = input(null, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : []));
|
|
35
|
+
mixedLabel = input.required(...(ngDevMode ? [{ debugName: "mixedLabel" }] : []));
|
|
36
|
+
valueChange = output();
|
|
37
|
+
errorId = computed(() => `${this.controlId()}-error`, ...(ngDevMode ? [{ debugName: "errorId" }] : []));
|
|
38
|
+
placeholder = computed(() => {
|
|
39
|
+
const field = this.field();
|
|
40
|
+
return field.mixed
|
|
41
|
+
? this.mixedLabel()
|
|
42
|
+
: (field.editor.attributes.placeholder ?? null);
|
|
43
|
+
}, ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
|
|
44
|
+
onChange(event) {
|
|
45
|
+
const target = event.target;
|
|
46
|
+
if (target instanceof HTMLInputElement && target.type === 'checkbox') {
|
|
47
|
+
this.valueChange.emit(target.checked);
|
|
48
|
+
}
|
|
49
|
+
else if (target instanceof HTMLInputElement ||
|
|
50
|
+
target instanceof HTMLSelectElement ||
|
|
51
|
+
target instanceof HTMLTextAreaElement) {
|
|
52
|
+
this.valueChange.emit(target.value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTableFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
56
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: SuTableFieldComponent, isStandalone: true, selector: "su-lib-table-field", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: true, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, mixedLabel: { classPropertyName: "mixedLabel", publicName: "mixedLabel", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { classAttribute: "su-table-field" }, ngImport: i0, template: "@let item = field();\n@let attributes = item.editor.attributes;\n@switch (item.editor.input) {\n @case ('checkbox') {\n <input\n type=\"checkbox\"\n class=\"su-table-checkbox\"\n [id]=\"controlId()\"\n [checked]=\"item.value === true\"\n [indeterminate]=\"item.mixed\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-invalid]=\"item.error ? true : null\"\n [attr.aria-describedby]=\"item.error ? errorId() : null\"\n (change)=\"onChange($event)\"\n />\n }\n @case ('select') {\n <select\n class=\"su-table-control\"\n [id]=\"controlId()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-invalid]=\"item.error ? true : null\"\n [attr.aria-describedby]=\"item.error ? errorId() : null\"\n (change)=\"onChange($event)\"\n >\n @if (item.mixed) {\n <option value=\"\" disabled selected>{{ mixedLabel() }}</option>\n }\n @for (option of item.editor.options; track option.value) {\n <option [value]=\"option.value\" [selected]=\"!item.mixed && option.value === item.value\">\n {{ option.label }}\n </option>\n }\n </select>\n }\n @case ('textarea') {\n <textarea\n class=\"su-table-control\"\n rows=\"2\"\n [id]=\"controlId()\"\n [value]=\"item.value\"\n [attr.placeholder]=\"placeholder()\"\n [attr.maxlength]=\"attributes.maxLength ?? null\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-invalid]=\"item.error ? true : null\"\n [attr.aria-describedby]=\"item.error ? errorId() : null\"\n (input)=\"onChange($event)\"\n ></textarea>\n }\n @default {\n <input\n class=\"su-table-control\"\n [type]=\"item.editor.input\"\n [id]=\"controlId()\"\n [value]=\"item.value\"\n [attr.placeholder]=\"placeholder()\"\n [attr.min]=\"attributes.min ?? null\"\n [attr.max]=\"attributes.max ?? null\"\n [attr.step]=\"attributes.step ?? null\"\n [attr.maxlength]=\"attributes.maxLength ?? null\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-invalid]=\"item.error ? true : null\"\n [attr.aria-describedby]=\"item.error ? errorId() : null\"\n (input)=\"onChange($event)\"\n />\n }\n}\n@if (item.error) {\n <span class=\"su-table-error\" [id]=\"errorId()\">{{ item.error }}</span>\n}\n", styles: [":host{display:flex;flex-direction:column;gap:.2rem}.su-table-control{background:var(--su-table-input-background, transparent);border:var(--su-table-input-border, 1px solid rgba(0, 0, 0, .25));border-radius:var(--su-table-input-radius, 6px);box-sizing:border-box;color:inherit;font:inherit;min-height:2rem;min-width:6rem;padding:.3rem .45rem;width:100%}.su-table-control:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-control[aria-invalid=true]{border-color:var(--su-table-danger-color, #b42318)}.su-table-checkbox{accent-color:var(--su-table-accent, #2563eb);height:1rem;margin:0;width:1rem}.su-table-checkbox:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-error{color:var(--su-table-danger-color, #b42318);font-size:.8em;font-weight:400}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
57
|
+
}
|
|
58
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTableFieldComponent, decorators: [{
|
|
59
|
+
type: Component,
|
|
60
|
+
args: [{ selector: 'su-lib-table-field', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'su-table-field' }, template: "@let item = field();\n@let attributes = item.editor.attributes;\n@switch (item.editor.input) {\n @case ('checkbox') {\n <input\n type=\"checkbox\"\n class=\"su-table-checkbox\"\n [id]=\"controlId()\"\n [checked]=\"item.value === true\"\n [indeterminate]=\"item.mixed\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-invalid]=\"item.error ? true : null\"\n [attr.aria-describedby]=\"item.error ? errorId() : null\"\n (change)=\"onChange($event)\"\n />\n }\n @case ('select') {\n <select\n class=\"su-table-control\"\n [id]=\"controlId()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-invalid]=\"item.error ? true : null\"\n [attr.aria-describedby]=\"item.error ? errorId() : null\"\n (change)=\"onChange($event)\"\n >\n @if (item.mixed) {\n <option value=\"\" disabled selected>{{ mixedLabel() }}</option>\n }\n @for (option of item.editor.options; track option.value) {\n <option [value]=\"option.value\" [selected]=\"!item.mixed && option.value === item.value\">\n {{ option.label }}\n </option>\n }\n </select>\n }\n @case ('textarea') {\n <textarea\n class=\"su-table-control\"\n rows=\"2\"\n [id]=\"controlId()\"\n [value]=\"item.value\"\n [attr.placeholder]=\"placeholder()\"\n [attr.maxlength]=\"attributes.maxLength ?? null\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-invalid]=\"item.error ? true : null\"\n [attr.aria-describedby]=\"item.error ? errorId() : null\"\n (input)=\"onChange($event)\"\n ></textarea>\n }\n @default {\n <input\n class=\"su-table-control\"\n [type]=\"item.editor.input\"\n [id]=\"controlId()\"\n [value]=\"item.value\"\n [attr.placeholder]=\"placeholder()\"\n [attr.min]=\"attributes.min ?? null\"\n [attr.max]=\"attributes.max ?? null\"\n [attr.step]=\"attributes.step ?? null\"\n [attr.maxlength]=\"attributes.maxLength ?? null\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-invalid]=\"item.error ? true : null\"\n [attr.aria-describedby]=\"item.error ? errorId() : null\"\n (input)=\"onChange($event)\"\n />\n }\n}\n@if (item.error) {\n <span class=\"su-table-error\" [id]=\"errorId()\">{{ item.error }}</span>\n}\n", styles: [":host{display:flex;flex-direction:column;gap:.2rem}.su-table-control{background:var(--su-table-input-background, transparent);border:var(--su-table-input-border, 1px solid rgba(0, 0, 0, .25));border-radius:var(--su-table-input-radius, 6px);box-sizing:border-box;color:inherit;font:inherit;min-height:2rem;min-width:6rem;padding:.3rem .45rem;width:100%}.su-table-control:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-control[aria-invalid=true]{border-color:var(--su-table-danger-color, #b42318)}.su-table-checkbox{accent-color:var(--su-table-accent, #2563eb);height:1rem;margin:0;width:1rem}.su-table-checkbox:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-error{color:var(--su-table-danger-color, #b42318);font-size:.8em;font-weight:400}\n"] }]
|
|
61
|
+
}], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "field", required: true }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], mixedLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "mixedLabel", required: true }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }] } });
|
|
62
|
+
|
|
63
|
+
/** The page controls under a table: rows per page, the range on screen, and previous and next */
|
|
64
|
+
class SuTablePaginatorComponent {
|
|
65
|
+
pagination = input.required(...(ngDevMode ? [{ debugName: "pagination" }] : []));
|
|
66
|
+
labels = input.required(...(ngDevMode ? [{ debugName: "labels" }] : []));
|
|
67
|
+
controlId = input.required(...(ngDevMode ? [{ debugName: "controlId" }] : []));
|
|
68
|
+
pageChange = output();
|
|
69
|
+
pageSizeChange = output();
|
|
70
|
+
/** The buttons stay focusable at the first and last page (`aria-disabled`), so focus isn't lost on the way */
|
|
71
|
+
turn(page) {
|
|
72
|
+
const { pageCount } = this.pagination();
|
|
73
|
+
if (page >= 0 && page < pageCount) {
|
|
74
|
+
this.pageChange.emit(page);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
onPageSize(event) {
|
|
78
|
+
if (event.target instanceof HTMLSelectElement) {
|
|
79
|
+
const { value } = event.target;
|
|
80
|
+
const size = this.pagination().pageSizes.find(item => String(item) === value);
|
|
81
|
+
if (size !== undefined) {
|
|
82
|
+
this.pageSizeChange.emit(size);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTablePaginatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
87
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: SuTablePaginatorComponent, isStandalone: true, selector: "su-lib-table-paginator", inputs: { pagination: { classPropertyName: "pagination", publicName: "pagination", isSignal: true, isRequired: true, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: true, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { pageChange: "pageChange", pageSizeChange: "pageSizeChange" }, ngImport: i0, template: "@let paging = pagination();\n@let t = labels();\n<nav class=\"su-table-paginator\" [attr.aria-label]=\"t.pagination\">\n @if (paging.pageSizes.length > 0) {\n <div class=\"su-table-paginator-size\">\n <label [for]=\"controlId()\">{{ t.rowsPerPage }}</label>\n <select class=\"su-table-paginator-select\" [id]=\"controlId()\" (change)=\"onPageSize($event)\">\n @for (size of paging.pageSizes; track size) {\n <option [value]=\"size\" [selected]=\"size === paging.pageSize\">{{ size === 'all' ? t.allRows : size }}</option>\n }\n </select>\n </div>\n }\n <span class=\"su-table-paginator-range\">{{ t.range(paging.rangeStart, paging.rangeEnd, paging.totalRows) }}</span>\n @if (paging.pageCount > 1) {\n <div class=\"su-table-paginator-pages\">\n <button\n type=\"button\"\n class=\"su-table-paginator-button\"\n [attr.aria-label]=\"t.previousPage\"\n [attr.aria-disabled]=\"paging.page === 0\"\n (click)=\"turn(paging.page - 1)\"\n >\n <span aria-hidden=\"true\">\u2039</span>\n </button>\n <span class=\"su-table-paginator-page\">{{ t.page(paging.page + 1, paging.pageCount) }}</span>\n <button\n type=\"button\"\n class=\"su-table-paginator-button\"\n [attr.aria-label]=\"t.nextPage\"\n [attr.aria-disabled]=\"paging.page === paging.pageCount - 1\"\n (click)=\"turn(paging.page + 1)\"\n >\n <span aria-hidden=\"true\">\u203A</span>\n </button>\n </div>\n }\n</nav>\n", styles: [":host{display:block;margin-top:.75rem}.su-table-paginator{align-items:center;display:flex;flex-wrap:wrap;font-size:.875em;gap:.5rem 1.25rem;justify-content:flex-end}.su-table-paginator-size,.su-table-paginator-pages{align-items:center;display:flex;gap:.5rem}.su-table-paginator-range,.su-table-paginator-page{font-variant-numeric:tabular-nums}.su-table-paginator-select,.su-table-paginator-button{background:var(--su-table-input-background, transparent);border:var(--su-table-input-border, 1px solid rgba(0, 0, 0, .25));border-radius:var(--su-table-input-radius, 6px);box-sizing:border-box;color:inherit;font:inherit;min-height:2rem}.su-table-paginator-select:focus-visible,.su-table-paginator-button:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-paginator-select{padding:.2rem .4rem}.su-table-paginator-button{cursor:pointer;font-size:1.1em;line-height:1;min-width:2rem}.su-table-paginator-button[aria-disabled=true]{cursor:not-allowed;opacity:.4}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
88
|
+
}
|
|
89
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTablePaginatorComponent, decorators: [{
|
|
90
|
+
type: Component,
|
|
91
|
+
args: [{ selector: 'su-lib-table-paginator', changeDetection: ChangeDetectionStrategy.OnPush, template: "@let paging = pagination();\n@let t = labels();\n<nav class=\"su-table-paginator\" [attr.aria-label]=\"t.pagination\">\n @if (paging.pageSizes.length > 0) {\n <div class=\"su-table-paginator-size\">\n <label [for]=\"controlId()\">{{ t.rowsPerPage }}</label>\n <select class=\"su-table-paginator-select\" [id]=\"controlId()\" (change)=\"onPageSize($event)\">\n @for (size of paging.pageSizes; track size) {\n <option [value]=\"size\" [selected]=\"size === paging.pageSize\">{{ size === 'all' ? t.allRows : size }}</option>\n }\n </select>\n </div>\n }\n <span class=\"su-table-paginator-range\">{{ t.range(paging.rangeStart, paging.rangeEnd, paging.totalRows) }}</span>\n @if (paging.pageCount > 1) {\n <div class=\"su-table-paginator-pages\">\n <button\n type=\"button\"\n class=\"su-table-paginator-button\"\n [attr.aria-label]=\"t.previousPage\"\n [attr.aria-disabled]=\"paging.page === 0\"\n (click)=\"turn(paging.page - 1)\"\n >\n <span aria-hidden=\"true\">\u2039</span>\n </button>\n <span class=\"su-table-paginator-page\">{{ t.page(paging.page + 1, paging.pageCount) }}</span>\n <button\n type=\"button\"\n class=\"su-table-paginator-button\"\n [attr.aria-label]=\"t.nextPage\"\n [attr.aria-disabled]=\"paging.page === paging.pageCount - 1\"\n (click)=\"turn(paging.page + 1)\"\n >\n <span aria-hidden=\"true\">\u203A</span>\n </button>\n </div>\n }\n</nav>\n", styles: [":host{display:block;margin-top:.75rem}.su-table-paginator{align-items:center;display:flex;flex-wrap:wrap;font-size:.875em;gap:.5rem 1.25rem;justify-content:flex-end}.su-table-paginator-size,.su-table-paginator-pages{align-items:center;display:flex;gap:.5rem}.su-table-paginator-range,.su-table-paginator-page{font-variant-numeric:tabular-nums}.su-table-paginator-select,.su-table-paginator-button{background:var(--su-table-input-background, transparent);border:var(--su-table-input-border, 1px solid rgba(0, 0, 0, .25));border-radius:var(--su-table-input-radius, 6px);box-sizing:border-box;color:inherit;font:inherit;min-height:2rem}.su-table-paginator-select:focus-visible,.su-table-paginator-button:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-paginator-select{padding:.2rem .4rem}.su-table-paginator-button{cursor:pointer;font-size:1.1em;line-height:1;min-width:2rem}.su-table-paginator-button[aria-disabled=true]{cursor:not-allowed;opacity:.4}\n"] }]
|
|
92
|
+
}], propDecorators: { pagination: [{ type: i0.Input, args: [{ isSignal: true, alias: "pagination", required: true }] }], labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: true }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: true }] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], pageSizeChange: [{ type: i0.Output, args: ["pageSizeChange"] }] } });
|
|
93
|
+
|
|
94
|
+
/** Makes a table cell stick to its edge while the other columns scroll */
|
|
95
|
+
class SuTablePinDirective {
|
|
96
|
+
placement = input(null, ...(ngDevMode ? [{ debugName: "placement", alias: 'suTablePin' }] : [{
|
|
97
|
+
alias: 'suTablePin',
|
|
98
|
+
}]));
|
|
99
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTablePinDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
100
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.35", type: SuTablePinDirective, isStandalone: true, selector: "[suTablePin]", inputs: { placement: { classPropertyName: "placement", publicName: "suTablePin", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.is-pinned-start": "placement()?.pin === 'start'", "class.is-pinned-end": "placement()?.pin === 'end'", "class.is-pinned-edge": "placement()?.edge", "style.inset-inline-start.px": "placement()?.pin === 'start' ? placement()?.offset : null", "style.inset-inline-end.px": "placement()?.pin === 'end' ? placement()?.offset : null" } }, ngImport: i0 });
|
|
101
|
+
}
|
|
102
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTablePinDirective, decorators: [{
|
|
103
|
+
type: Directive,
|
|
104
|
+
args: [{
|
|
105
|
+
selector: '[suTablePin]',
|
|
106
|
+
host: {
|
|
107
|
+
'[class.is-pinned-start]': "placement()?.pin === 'start'",
|
|
108
|
+
'[class.is-pinned-end]': "placement()?.pin === 'end'",
|
|
109
|
+
'[class.is-pinned-edge]': 'placement()?.edge',
|
|
110
|
+
'[style.inset-inline-start.px]': "placement()?.pin === 'start' ? placement()?.offset : null",
|
|
111
|
+
'[style.inset-inline-end.px]': "placement()?.pin === 'end' ? placement()?.offset : null",
|
|
112
|
+
},
|
|
113
|
+
}]
|
|
114
|
+
}], propDecorators: { placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "suTablePin", required: false }] }] } });
|
|
115
|
+
|
|
116
|
+
/** The pin drawn on pinned columns and pin buttons: `<svg suTablePinIcon></svg>` */
|
|
117
|
+
class SuTablePinIconComponent {
|
|
118
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTablePinIconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
119
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.35", type: SuTablePinIconComponent, isStandalone: true, selector: "svg[suTablePinIcon]", host: { attributes: { "viewBox": "0 0 16 16", "aria-hidden": "true", "fill": "currentColor" } }, ngImport: i0, template: `<svg:path
|
|
120
|
+
d="M10 1.5 14.5 6l-1.6 1.6-1-.3-2.4 2.4.2 2.8-1.3 1.3L6 11 2.5 14.5 1.5 13.5 5 10 2.2 7.6l1.3-1.3 2.8.2 2.4-2.4-.3-1z" />`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
121
|
+
}
|
|
122
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTablePinIconComponent, decorators: [{
|
|
123
|
+
type: Component,
|
|
124
|
+
args: [{
|
|
125
|
+
selector: 'svg[suTablePinIcon]',
|
|
126
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
127
|
+
host: { viewBox: '0 0 16 16', 'aria-hidden': 'true', fill: 'currentColor' },
|
|
128
|
+
template: `<svg:path
|
|
129
|
+
d="M10 1.5 14.5 6l-1.6 1.6-1-.3-2.4 2.4.2 2.8-1.3 1.3L6 11 2.5 14.5 1.5 13.5 5 10 2.2 7.6l1.3-1.3 2.8.2 2.4-2.4-.3-1z" />`,
|
|
130
|
+
}]
|
|
131
|
+
}] });
|
|
132
|
+
|
|
133
|
+
/** The bar above a table: the search box, and the Columns button with its menu to show, hide and pin columns */
|
|
134
|
+
class SuTableToolbarComponent {
|
|
135
|
+
labels = input.required(...(ngDevMode ? [{ debugName: "labels" }] : []));
|
|
136
|
+
/** Prefix for the ids of the controls */
|
|
137
|
+
controlId = input.required(...(ngDevMode ? [{ debugName: "controlId" }] : []));
|
|
138
|
+
searchable = input(false, ...(ngDevMode ? [{ debugName: "searchable" }] : []));
|
|
139
|
+
query = input('', ...(ngDevMode ? [{ debugName: "query" }] : []));
|
|
140
|
+
columnControls = input(false, ...(ngDevMode ? [{ debugName: "columnControls" }] : []));
|
|
141
|
+
/** The columns in the order they were set up */
|
|
142
|
+
columns = input([], ...(ngDevMode ? [{ debugName: "columns" }] : []));
|
|
143
|
+
queryChange = output();
|
|
144
|
+
pinnableChange = output();
|
|
145
|
+
visibilityChange = output();
|
|
146
|
+
/** Every column shown (true), or all hidden but one (false) */
|
|
147
|
+
allVisibilityChange = output();
|
|
148
|
+
menu = viewChild('menu', ...(ngDevMode ? [{ debugName: "menu" }] : []));
|
|
149
|
+
menuButton = viewChild('menuButton', ...(ngDevMode ? [{ debugName: "menuButton" }] : []));
|
|
150
|
+
columnsOpen = signal(false, ...(ngDevMode ? [{ debugName: "columnsOpen" }] : []));
|
|
151
|
+
columnQuery = signal('', ...(ngDevMode ? [{ debugName: "columnQuery" }] : []));
|
|
152
|
+
/** The columns matching the menu's search */
|
|
153
|
+
listedColumns = computed(() => {
|
|
154
|
+
const query = this.columnQuery().trim().toLocaleLowerCase();
|
|
155
|
+
return this.columns().filter(column => column.header.toLocaleLowerCase().includes(query));
|
|
156
|
+
}, ...(ngDevMode ? [{ debugName: "listedColumns" }] : []));
|
|
157
|
+
shownCount = computed(() => this.columns().filter(column => column.visible).length, ...(ngDevMode ? [{ debugName: "shownCount" }] : []));
|
|
158
|
+
toggleMenu() {
|
|
159
|
+
this.columnsOpen.update(open => !open);
|
|
160
|
+
this.columnQuery.set('');
|
|
161
|
+
}
|
|
162
|
+
/** Escape closes the menu and puts focus back on its button */
|
|
163
|
+
closeMenu() {
|
|
164
|
+
this.columnsOpen.set(false);
|
|
165
|
+
this.menuButton()?.nativeElement.focus();
|
|
166
|
+
}
|
|
167
|
+
closeOutside(event) {
|
|
168
|
+
const menu = this.menu()?.nativeElement;
|
|
169
|
+
if (menu && event.target instanceof Node && !menu.contains(event.target)) {
|
|
170
|
+
this.columnsOpen.set(false);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
onQuery(event) {
|
|
174
|
+
if (event.target instanceof HTMLInputElement) {
|
|
175
|
+
this.queryChange.emit(event.target.value);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
clearQuery(event) {
|
|
179
|
+
if (event.target instanceof HTMLInputElement && event.target.value !== '') {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
event.stopPropagation();
|
|
182
|
+
event.target.value = '';
|
|
183
|
+
this.queryChange.emit('');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
onColumnQuery(event) {
|
|
187
|
+
if (event.target instanceof HTMLInputElement) {
|
|
188
|
+
this.columnQuery.set(event.target.value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
onVisible(key, event) {
|
|
192
|
+
if (event.target instanceof HTMLInputElement) {
|
|
193
|
+
this.visibilityChange.emit({ key, visible: event.target.checked });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
onAllVisible(event) {
|
|
197
|
+
if (event.target instanceof HTMLInputElement) {
|
|
198
|
+
this.allVisibilityChange.emit(event.target.checked);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/** The pin button shows or hides the column's pin in its heading; that pin is what pins it */
|
|
202
|
+
togglePinnable(column) {
|
|
203
|
+
this.pinnableChange.emit({ key: column.key, pinnable: !column.pinnable });
|
|
204
|
+
}
|
|
205
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTableToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
206
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: SuTableToolbarComponent, isStandalone: true, selector: "su-lib-table-toolbar", inputs: { labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: true, transformFunction: null }, controlId: { classPropertyName: "controlId", publicName: "controlId", isSignal: true, isRequired: true, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: true, isRequired: false, transformFunction: null }, query: { classPropertyName: "query", publicName: "query", isSignal: true, isRequired: false, transformFunction: null }, columnControls: { classPropertyName: "columnControls", publicName: "columnControls", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { queryChange: "queryChange", pinnableChange: "pinnableChange", visibilityChange: "visibilityChange", allVisibilityChange: "allVisibilityChange" }, host: { listeners: { "document:pointerdown": "closeOutside($event)" } }, viewQueries: [{ propertyName: "menu", first: true, predicate: ["menu"], descendants: true, isSignal: true }, { propertyName: "menuButton", first: true, predicate: ["menuButton"], descendants: true, isSignal: true }], ngImport: i0, template: "@let t = labels();\n<div class=\"su-table-bar\">\n @if (searchable()) {\n <div class=\"su-table-search\">\n <svg class=\"su-table-search-icon\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\">\n <circle cx=\"7\" cy=\"7\" r=\"4.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" />\n <path d=\"m10.5 10.5 3.5 3.5\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" />\n </svg>\n <input\n type=\"search\"\n class=\"su-table-search-input\"\n [id]=\"controlId() + '-search'\"\n [value]=\"query()\"\n [attr.aria-label]=\"t.search\"\n [attr.placeholder]=\"t.search\"\n (input)=\"onQuery($event)\"\n (keydown.escape)=\"clearQuery($event)\"\n />\n </div>\n }\n @if (columnControls()) {\n <div #menu class=\"su-table-columns\">\n <button\n #menuButton\n type=\"button\"\n class=\"su-table-button\"\n [attr.aria-expanded]=\"columnsOpen()\"\n [attr.aria-controls]=\"controlId() + '-columns'\"\n (click)=\"toggleMenu()\"\n >\n {{ t.columns }}\n </button>\n @if (columnsOpen()) {\n <div\n class=\"su-table-menu\"\n role=\"group\"\n [id]=\"controlId() + '-columns'\"\n [attr.aria-labelledby]=\"controlId() + '-columns-title'\"\n (keydown.escape)=\"closeMenu()\"\n >\n <p class=\"su-table-menu-title\" [id]=\"controlId() + '-columns-title'\">{{ t.columns }}</p>\n <div class=\"su-table-search\">\n <svg class=\"su-table-search-icon\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\">\n <circle cx=\"7\" cy=\"7\" r=\"4.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" />\n <path d=\"m10.5 10.5 3.5 3.5\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" />\n </svg>\n <input\n type=\"search\"\n class=\"su-table-search-input\"\n [value]=\"columnQuery()\"\n [attr.aria-label]=\"t.searchColumns\"\n [attr.placeholder]=\"t.search\"\n (input)=\"onColumnQuery($event)\"\n />\n </div>\n <label class=\"su-table-menu-item is-all\">\n <input\n type=\"checkbox\"\n [checked]=\"shownCount() === columns().length\"\n [indeterminate]=\"shownCount() > 0 && shownCount() < columns().length\"\n (change)=\"onAllVisible($event)\"\n />\n <span>{{ t.allColumns }}</span>\n </label>\n <ul class=\"su-table-menu-list\">\n @for (column of listedColumns(); track column.key) {\n <li class=\"su-table-menu-item\">\n <label>\n <input\n type=\"checkbox\"\n [checked]=\"column.visible\"\n [disabled]=\"column.visible && shownCount() === 1\"\n (change)=\"onVisible(column.key, $event)\"\n />\n <span>{{ column.header }}</span>\n </label>\n <button\n type=\"button\"\n class=\"su-table-menu-pin\"\n [attr.aria-label]=\"t.showPin(column.header)\"\n [attr.aria-pressed]=\"column.pinnable\"\n [disabled]=\"!column.visible\"\n (click)=\"togglePinnable(column)\"\n >\n <svg suTablePinIcon width=\"13\" height=\"13\"></svg>\n </button>\n </li>\n }\n </ul>\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host{display:block}.su-table-bar{align-items:center;display:flex;flex-wrap:wrap;gap:.5rem;justify-content:flex-end;margin-bottom:.75rem}.su-table-search{align-items:center;display:flex;flex:1 1 14rem;margin-inline-end:auto;max-width:22rem;position:relative}.su-table-search-icon{inset-inline-start:.6rem;opacity:.55;pointer-events:none;position:absolute}.su-table-search-input{background:var(--su-table-input-background, transparent);border:var(--su-table-input-border, 1px solid rgba(0, 0, 0, .25));border-radius:var(--su-table-input-radius, 6px);box-sizing:border-box;color:inherit;font:inherit;min-height:2.1rem;padding:.3rem .6rem .3rem 2rem;width:100%}.su-table-search-input:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-button{background:var(--su-table-button-background, transparent);border:var(--su-table-button-border, 1px solid rgba(0, 0, 0, .2));border-radius:var(--su-table-button-radius, 6px);color:var(--su-table-button-color, inherit);cursor:pointer;font:inherit;font-size:.875em;padding:var(--su-table-button-padding, .3rem .7rem);white-space:nowrap}.su-table-button:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-button:disabled{cursor:not-allowed;opacity:.45}.su-table-button.is-primary{background:var(--su-table-primary-background, #111);border-color:transparent;color:var(--su-table-primary-color, #fff)}.su-table-button.is-danger{border-color:var(--su-table-danger-border, color-mix(in srgb, #b42318 35%, transparent));color:var(--su-table-danger-color, #b42318)}.su-table-button.is-quiet{border-color:transparent}.su-table-columns{position:relative}.su-table-menu{background:var(--su-table-menu-background, Canvas);border:var(--su-table-border, 1px solid rgba(0, 0, 0, .12));border-radius:var(--su-table-radius, 10px);box-shadow:var(--su-table-menu-shadow, 0 12px 32px rgba(0, 0, 0, .18));box-sizing:border-box;display:grid;gap:.6rem;inset-inline-end:0;max-height:22rem;max-width:calc(100vw - 2rem);overflow:auto;padding:.85rem;position:absolute;top:calc(100% + .4rem);width:16rem;z-index:10}.su-table-menu .su-table-search{flex:none;margin:0;max-width:none}.su-table-menu-title{font-weight:600;margin:0}.su-table-menu-list{display:grid;gap:.15rem;list-style:none;margin:0;padding:0}.su-table-menu-item{align-items:center;display:flex;gap:.5rem;justify-content:space-between}.su-table-menu-item label{align-items:center;cursor:pointer;display:flex;flex:1;gap:.55rem;min-width:0;padding:.3rem 0}.su-table-menu-item input{accent-color:var(--su-table-accent, #2563eb);flex:none;height:1rem;margin:0;width:1rem}.su-table-menu-item input:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-menu-item.is-all{border-bottom:var(--su-table-row-border, 1px solid rgba(0, 0, 0, .08));cursor:pointer;gap:.55rem;justify-content:flex-start;padding:.3rem 0 .5rem}.su-table-menu-pin{align-items:center;background:none;border:1px solid transparent;border-radius:6px;color:inherit;cursor:pointer;display:inline-flex;height:1.75rem;justify-content:center;width:1.75rem}.su-table-menu-pin:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-menu-pin svg{opacity:.35}.su-table-menu-pin[aria-pressed=true]{border-color:var(--su-table-accent, #2563eb);color:var(--su-table-accent, #2563eb)}.su-table-menu-pin[aria-pressed=true] svg{opacity:1}.su-table-menu-pin:disabled{cursor:not-allowed;opacity:.4}\n"], dependencies: [{ kind: "component", type: SuTablePinIconComponent, selector: "svg[suTablePinIcon]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
207
|
+
}
|
|
208
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTableToolbarComponent, decorators: [{
|
|
209
|
+
type: Component,
|
|
210
|
+
args: [{ selector: 'su-lib-table-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, imports: [SuTablePinIconComponent], host: { '(document:pointerdown)': 'closeOutside($event)' }, template: "@let t = labels();\n<div class=\"su-table-bar\">\n @if (searchable()) {\n <div class=\"su-table-search\">\n <svg class=\"su-table-search-icon\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\">\n <circle cx=\"7\" cy=\"7\" r=\"4.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" />\n <path d=\"m10.5 10.5 3.5 3.5\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" />\n </svg>\n <input\n type=\"search\"\n class=\"su-table-search-input\"\n [id]=\"controlId() + '-search'\"\n [value]=\"query()\"\n [attr.aria-label]=\"t.search\"\n [attr.placeholder]=\"t.search\"\n (input)=\"onQuery($event)\"\n (keydown.escape)=\"clearQuery($event)\"\n />\n </div>\n }\n @if (columnControls()) {\n <div #menu class=\"su-table-columns\">\n <button\n #menuButton\n type=\"button\"\n class=\"su-table-button\"\n [attr.aria-expanded]=\"columnsOpen()\"\n [attr.aria-controls]=\"controlId() + '-columns'\"\n (click)=\"toggleMenu()\"\n >\n {{ t.columns }}\n </button>\n @if (columnsOpen()) {\n <div\n class=\"su-table-menu\"\n role=\"group\"\n [id]=\"controlId() + '-columns'\"\n [attr.aria-labelledby]=\"controlId() + '-columns-title'\"\n (keydown.escape)=\"closeMenu()\"\n >\n <p class=\"su-table-menu-title\" [id]=\"controlId() + '-columns-title'\">{{ t.columns }}</p>\n <div class=\"su-table-search\">\n <svg class=\"su-table-search-icon\" viewBox=\"0 0 16 16\" width=\"14\" height=\"14\" aria-hidden=\"true\">\n <circle cx=\"7\" cy=\"7\" r=\"4.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" />\n <path d=\"m10.5 10.5 3.5 3.5\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" />\n </svg>\n <input\n type=\"search\"\n class=\"su-table-search-input\"\n [value]=\"columnQuery()\"\n [attr.aria-label]=\"t.searchColumns\"\n [attr.placeholder]=\"t.search\"\n (input)=\"onColumnQuery($event)\"\n />\n </div>\n <label class=\"su-table-menu-item is-all\">\n <input\n type=\"checkbox\"\n [checked]=\"shownCount() === columns().length\"\n [indeterminate]=\"shownCount() > 0 && shownCount() < columns().length\"\n (change)=\"onAllVisible($event)\"\n />\n <span>{{ t.allColumns }}</span>\n </label>\n <ul class=\"su-table-menu-list\">\n @for (column of listedColumns(); track column.key) {\n <li class=\"su-table-menu-item\">\n <label>\n <input\n type=\"checkbox\"\n [checked]=\"column.visible\"\n [disabled]=\"column.visible && shownCount() === 1\"\n (change)=\"onVisible(column.key, $event)\"\n />\n <span>{{ column.header }}</span>\n </label>\n <button\n type=\"button\"\n class=\"su-table-menu-pin\"\n [attr.aria-label]=\"t.showPin(column.header)\"\n [attr.aria-pressed]=\"column.pinnable\"\n [disabled]=\"!column.visible\"\n (click)=\"togglePinnable(column)\"\n >\n <svg suTablePinIcon width=\"13\" height=\"13\"></svg>\n </button>\n </li>\n }\n </ul>\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host{display:block}.su-table-bar{align-items:center;display:flex;flex-wrap:wrap;gap:.5rem;justify-content:flex-end;margin-bottom:.75rem}.su-table-search{align-items:center;display:flex;flex:1 1 14rem;margin-inline-end:auto;max-width:22rem;position:relative}.su-table-search-icon{inset-inline-start:.6rem;opacity:.55;pointer-events:none;position:absolute}.su-table-search-input{background:var(--su-table-input-background, transparent);border:var(--su-table-input-border, 1px solid rgba(0, 0, 0, .25));border-radius:var(--su-table-input-radius, 6px);box-sizing:border-box;color:inherit;font:inherit;min-height:2.1rem;padding:.3rem .6rem .3rem 2rem;width:100%}.su-table-search-input:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-button{background:var(--su-table-button-background, transparent);border:var(--su-table-button-border, 1px solid rgba(0, 0, 0, .2));border-radius:var(--su-table-button-radius, 6px);color:var(--su-table-button-color, inherit);cursor:pointer;font:inherit;font-size:.875em;padding:var(--su-table-button-padding, .3rem .7rem);white-space:nowrap}.su-table-button:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-button:disabled{cursor:not-allowed;opacity:.45}.su-table-button.is-primary{background:var(--su-table-primary-background, #111);border-color:transparent;color:var(--su-table-primary-color, #fff)}.su-table-button.is-danger{border-color:var(--su-table-danger-border, color-mix(in srgb, #b42318 35%, transparent));color:var(--su-table-danger-color, #b42318)}.su-table-button.is-quiet{border-color:transparent}.su-table-columns{position:relative}.su-table-menu{background:var(--su-table-menu-background, Canvas);border:var(--su-table-border, 1px solid rgba(0, 0, 0, .12));border-radius:var(--su-table-radius, 10px);box-shadow:var(--su-table-menu-shadow, 0 12px 32px rgba(0, 0, 0, .18));box-sizing:border-box;display:grid;gap:.6rem;inset-inline-end:0;max-height:22rem;max-width:calc(100vw - 2rem);overflow:auto;padding:.85rem;position:absolute;top:calc(100% + .4rem);width:16rem;z-index:10}.su-table-menu .su-table-search{flex:none;margin:0;max-width:none}.su-table-menu-title{font-weight:600;margin:0}.su-table-menu-list{display:grid;gap:.15rem;list-style:none;margin:0;padding:0}.su-table-menu-item{align-items:center;display:flex;gap:.5rem;justify-content:space-between}.su-table-menu-item label{align-items:center;cursor:pointer;display:flex;flex:1;gap:.55rem;min-width:0;padding:.3rem 0}.su-table-menu-item input{accent-color:var(--su-table-accent, #2563eb);flex:none;height:1rem;margin:0;width:1rem}.su-table-menu-item input:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-menu-item.is-all{border-bottom:var(--su-table-row-border, 1px solid rgba(0, 0, 0, .08));cursor:pointer;gap:.55rem;justify-content:flex-start;padding:.3rem 0 .5rem}.su-table-menu-pin{align-items:center;background:none;border:1px solid transparent;border-radius:6px;color:inherit;cursor:pointer;display:inline-flex;height:1.75rem;justify-content:center;width:1.75rem}.su-table-menu-pin:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-menu-pin svg{opacity:.35}.su-table-menu-pin[aria-pressed=true]{border-color:var(--su-table-accent, #2563eb);color:var(--su-table-accent, #2563eb)}.su-table-menu-pin[aria-pressed=true] svg{opacity:1}.su-table-menu-pin:disabled{cursor:not-allowed;opacity:.4}\n"] }]
|
|
211
|
+
}], propDecorators: { labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: true }] }], controlId: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlId", required: true }] }], searchable: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchable", required: false }] }], query: [{ type: i0.Input, args: [{ isSignal: true, alias: "query", required: false }] }], columnControls: [{ type: i0.Input, args: [{ isSignal: true, alias: "columnControls", required: false }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], queryChange: [{ type: i0.Output, args: ["queryChange"] }], pinnableChange: [{ type: i0.Output, args: ["pinnableChange"] }], visibilityChange: [{ type: i0.Output, args: ["visibilityChange"] }], allVisibilityChange: [{ type: i0.Output, args: ["allVisibilityChange"] }], menu: [{ type: i0.ViewChild, args: ['menu', { isSignal: true }] }], menuButton: [{ type: i0.ViewChild, args: ['menuButton', { isSignal: true }] }] } });
|
|
212
|
+
|
|
213
|
+
/** The action id the table handles itself: it edits the row inline */
|
|
214
|
+
const SU_TABLE_EDIT_ACTION = 'edit';
|
|
215
|
+
let nextTableId = 0;
|
|
216
|
+
/** The room, in pixels, the pinned columns leave for the scrolling ones before they stop sticking */
|
|
217
|
+
const MIN_SCROLLING_WIDTH = 96;
|
|
218
|
+
/** How long typing pauses, in milliseconds, before the search runs */
|
|
219
|
+
const SEARCH_DELAY = 200;
|
|
220
|
+
/**
|
|
221
|
+
* An accessible data table over `SuTableController` from `@su-labs/core/table`: typed columns map the API's rows,
|
|
222
|
+
* with sorting, selection, inline and bulk editing, drag-and-drop and keyboard reordering, row actions and announced
|
|
223
|
+
* changes. Edited rows come out in the API's own shape through `edited`.
|
|
224
|
+
*/
|
|
225
|
+
class SuTableComponent {
|
|
226
|
+
columns = input.required(...(ngDevMode ? [{ debugName: "columns" }] : []));
|
|
227
|
+
rows = input.required(...(ngDevMode ? [{ debugName: "rows" }] : []));
|
|
228
|
+
/** The table's name for screen readers, shown as its caption */
|
|
229
|
+
caption = input.required(...(ngDevMode ? [{ debugName: "caption" }] : []));
|
|
230
|
+
/** Shows the caption on screen too @default false */
|
|
231
|
+
showCaption = input(false, ...(ngDevMode ? [{ debugName: "showCaption", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
232
|
+
/** The row's identity, e.g. the API's id; keeps the selection and edits across new rows */
|
|
233
|
+
rowId = input(...(ngDevMode ? [undefined, { debugName: "rowId" }] : []));
|
|
234
|
+
/** Buttons on each row; the `edit` id edits the row inline */
|
|
235
|
+
actions = input([], ...(ngDevMode ? [{ debugName: "actions" }] : []));
|
|
236
|
+
/** Rows can be selected, to edit or act on many at once @default false */
|
|
237
|
+
selectable = input(false, ...(ngDevMode ? [{ debugName: "selectable", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
238
|
+
/** Rows can be reordered, by dragging or with the keyboard @default false */
|
|
239
|
+
reorderable = input(false, ...(ngDevMode ? [{ debugName: "reorderable", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
240
|
+
/** A Columns button with a menu to show or hide columns and the pin in their headings @default false */
|
|
241
|
+
columnControls = input(false, ...(ngDevMode ? [{ debugName: "columnControls", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
242
|
+
/** A search box above the table that narrows the rows by their text @default false */
|
|
243
|
+
searchable = input(false, ...(ngDevMode ? [{ debugName: "searchable", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
244
|
+
/**
|
|
245
|
+
* The most the table grows before it scrolls inside, any CSS length (e.g. `'28rem'`); the header and the pinned
|
|
246
|
+
* rows stay in view while the rows scroll under them
|
|
247
|
+
*/
|
|
248
|
+
maxHeight = input(...(ngDevMode ? [undefined, { debugName: "maxHeight" }] : []));
|
|
249
|
+
/**
|
|
250
|
+
* Extra classes for a row, e.g. `(user) => (user.active ? null : 'is-muted')`. The table styles `is-muted` and
|
|
251
|
+
* `is-highlighted`; other classes are yours to style
|
|
252
|
+
*/
|
|
253
|
+
rowClass = input(...(ngDevMode ? [undefined, { debugName: "rowClass" }] : []));
|
|
254
|
+
/** A double-click on an editable cell edits its row, starting in that field @default true */
|
|
255
|
+
editOnDoubleClick = input(true, ...(ngDevMode ? [{ debugName: "editOnDoubleClick", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
256
|
+
/** Rows per page; without it, every row shows @default 'all' */
|
|
257
|
+
pageSize = input(...(ngDevMode ? [undefined, { debugName: "pageSize" }] : []));
|
|
258
|
+
/** The page sizes people choose from under the table, e.g. `[10, 25, 50, 'all']` */
|
|
259
|
+
pageSizes = input([], ...(ngDevMode ? [{ debugName: "pageSizes" }] : []));
|
|
260
|
+
/** A Pin button on each row, keeping it above the others on every page @default false */
|
|
261
|
+
rowPinning = input(false, ...(ngDevMode ? [{ debugName: "rowPinning", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
|
|
262
|
+
/** The ids of the rows pinned to start with */
|
|
263
|
+
pinnedRows = input(...(ngDevMode ? [undefined, { debugName: "pinnedRows" }] : []));
|
|
264
|
+
/** Texts to replace, e.g. in the page's language */
|
|
265
|
+
labels = input({}, ...(ngDevMode ? [{ debugName: "labels" }] : []));
|
|
266
|
+
/** Rows were edited and saved; send them to the API as they are */
|
|
267
|
+
edited = output();
|
|
268
|
+
reordered = output();
|
|
269
|
+
action = output();
|
|
270
|
+
sortChange = output();
|
|
271
|
+
selectionChange = output();
|
|
272
|
+
/** The search changed, after typing paused */
|
|
273
|
+
searchChange = output();
|
|
274
|
+
/** The pinned rows changed: their ids, in pin order */
|
|
275
|
+
pinnedRowsChange = output();
|
|
276
|
+
/** A column was shown, hidden, pinned or unpinned from the Columns menu: every column's state, e.g. to save it */
|
|
277
|
+
columnsChange = output();
|
|
278
|
+
/** The page or the page size changed */
|
|
279
|
+
pageChange = output();
|
|
280
|
+
controller = new SuTableController();
|
|
281
|
+
host = inject(ElementRef);
|
|
282
|
+
cellTemplates = contentChildren(SuTableCellDirective, ...(ngDevMode ? [{ debugName: "cellTemplates" }] : []));
|
|
283
|
+
focusHandleId = signal(null, ...(ngDevMode ? [{ debugName: "focusHandleId" }] : []));
|
|
284
|
+
/** The id of the field to focus once it renders, after a double-click */
|
|
285
|
+
focusFieldId = signal(null, ...(ngDevMode ? [{ debugName: "focusFieldId" }] : []));
|
|
286
|
+
searchTimer;
|
|
287
|
+
headerWidths = signal([], ...(ngDevMode ? [{ debugName: "headerWidths" }] : []));
|
|
288
|
+
scrollerWidth = signal(0, ...(ngDevMode ? [{ debugName: "scrollerWidth" }] : []));
|
|
289
|
+
headerLayout = computed(() => `${this.state()
|
|
290
|
+
.columns.map(column => `${String(column.key)}:${column.pinned}`)
|
|
291
|
+
.join()}|${this.reorderable()}|${this.selectable()}|${this.hasActions()}|${this.state()
|
|
292
|
+
.pinnedRows.map(row => row.id)
|
|
293
|
+
.join()}`, ...(ngDevMode ? [{ debugName: "headerLayout" }] : []));
|
|
294
|
+
headerHeight = signal(0, ...(ngDevMode ? [{ debugName: "headerHeight" }] : []));
|
|
295
|
+
pinnedRowHeights = signal([], ...(ngDevMode ? [{ debugName: "pinnedRowHeights" }] : []));
|
|
296
|
+
tableId = `su-table-${nextTableId++}`;
|
|
297
|
+
state = signal(this.controller.state.get(), ...(ngDevMode ? [{ debugName: "state" }] : []));
|
|
298
|
+
text = computed(() => ({
|
|
299
|
+
...SU_TABLE_LABELS,
|
|
300
|
+
...this.labels(),
|
|
301
|
+
}), ...(ngDevMode ? [{ debugName: "text" }] : []));
|
|
302
|
+
drag = signal(null, ...(ngDevMode ? [{ debugName: "drag" }] : []));
|
|
303
|
+
inlineDraft = computed(() => {
|
|
304
|
+
const draft = this.state().draft;
|
|
305
|
+
return draft && !draft.bulk ? draft : null;
|
|
306
|
+
}, ...(ngDevMode ? [{ debugName: "inlineDraft" }] : []));
|
|
307
|
+
bulkDraft = computed(() => {
|
|
308
|
+
const draft = this.state().draft;
|
|
309
|
+
return draft?.bulk ? draft : null;
|
|
310
|
+
}, ...(ngDevMode ? [{ debugName: "bulkDraft" }] : []));
|
|
311
|
+
/** The actions column also shows, for Save and Cancel, while a row is edited by double-click */
|
|
312
|
+
hasActions = computed(() => this.actions().length > 0 ||
|
|
313
|
+
this.rowPinning() ||
|
|
314
|
+
this.inlineDraft() !== null, ...(ngDevMode ? [{ debugName: "hasActions" }] : []));
|
|
315
|
+
/** The pinned rows, then the current page */
|
|
316
|
+
bodyRows = computed(() => {
|
|
317
|
+
const { pinnedRows, rows } = this.state();
|
|
318
|
+
return [...pinnedRows, ...rows];
|
|
319
|
+
}, ...(ngDevMode ? [{ debugName: "bodyRows" }] : []));
|
|
320
|
+
scrolledFromStart = signal(false, ...(ngDevMode ? [{ debugName: "scrolledFromStart" }] : []));
|
|
321
|
+
moreAtEnd = signal(false, ...(ngDevMode ? [{ debugName: "moreAtEnd" }] : []));
|
|
322
|
+
scrolledFromTop = signal(false, ...(ngDevMode ? [{ debugName: "scrolledFromTop" }] : []));
|
|
323
|
+
/** Where each pinned row sticks: under the header and the pinned rows above it */
|
|
324
|
+
pinnedRowTops = computed(() => {
|
|
325
|
+
let top = this.headerHeight();
|
|
326
|
+
return this.pinnedRowHeights().map(height => {
|
|
327
|
+
const rowTop = top;
|
|
328
|
+
top += height;
|
|
329
|
+
return rowTop;
|
|
330
|
+
});
|
|
331
|
+
}, ...(ngDevMode ? [{ debugName: "pinnedRowTops" }] : []));
|
|
332
|
+
columnSlot = computed(() => Number(this.reorderable()) + Number(this.selectable()), ...(ngDevMode ? [{ debugName: "columnSlot" }] : []));
|
|
333
|
+
/**
|
|
334
|
+
* Where each header slot sticks, in order: the move handles, the checkboxes, the columns and the actions. The
|
|
335
|
+
* handles and checkboxes stay with columns pinned to the start, the actions with columns pinned to the end.
|
|
336
|
+
* When the pinned cells would leave too little room to scroll the rest (e.g. on a phone), nothing sticks.
|
|
337
|
+
*/
|
|
338
|
+
placements = computed(() => {
|
|
339
|
+
const columns = this.state().columns;
|
|
340
|
+
const utilityPin = columns.some(column => column.pinned === 'start')
|
|
341
|
+
? 'start'
|
|
342
|
+
: null;
|
|
343
|
+
const actionsPin = columns.some(column => column.pinned === 'end')
|
|
344
|
+
? 'end'
|
|
345
|
+
: null;
|
|
346
|
+
const pins = [
|
|
347
|
+
...(this.reorderable() ? [utilityPin] : []),
|
|
348
|
+
...(this.selectable() ? [utilityPin] : []),
|
|
349
|
+
...columns.map(column => column.pinned),
|
|
350
|
+
...(this.hasActions() ? [actionsPin] : []),
|
|
351
|
+
];
|
|
352
|
+
const widths = this.headerWidths();
|
|
353
|
+
const pinnedWidth = pins.reduce((sum, pin, index) => (pin ? sum + (widths[index] ?? 0) : sum), 0);
|
|
354
|
+
if (pinnedWidth > this.scrollerWidth() - MIN_SCROLLING_WIDTH) {
|
|
355
|
+
return pins.map(() => null);
|
|
356
|
+
}
|
|
357
|
+
const lastStart = pins.lastIndexOf('start');
|
|
358
|
+
const firstEnd = pins.indexOf('end');
|
|
359
|
+
const widthOf = (pin, from, to) => pins
|
|
360
|
+
.slice(from, to)
|
|
361
|
+
.reduce((sum, slotPin, index) => slotPin === pin ? sum + (widths[from + index] ?? 0) : sum, 0);
|
|
362
|
+
return pins.map((pin, index) => pin
|
|
363
|
+
? {
|
|
364
|
+
pin,
|
|
365
|
+
offset: pin === 'start'
|
|
366
|
+
? widthOf(pin, 0, index)
|
|
367
|
+
: widthOf(pin, index + 1, pins.length),
|
|
368
|
+
edge: index === (pin === 'start' ? lastStart : firstEnd),
|
|
369
|
+
}
|
|
370
|
+
: null);
|
|
371
|
+
}, ...(ngDevMode ? [{ debugName: "placements" }] : []));
|
|
372
|
+
columnCount = computed(() => this.state().columns.length +
|
|
373
|
+
Number(this.reorderable()) +
|
|
374
|
+
Number(this.selectable()) +
|
|
375
|
+
Number(this.hasActions()), ...(ngDevMode ? [{ debugName: "columnCount" }] : []));
|
|
376
|
+
constructor() {
|
|
377
|
+
const unsubscribe = this.controller.state.subscribe(state => this.state.set(state));
|
|
378
|
+
inject(DestroyRef).onDestroy(() => {
|
|
379
|
+
unsubscribe();
|
|
380
|
+
clearTimeout(this.searchTimer);
|
|
381
|
+
});
|
|
382
|
+
effect(() => {
|
|
383
|
+
const options = {
|
|
384
|
+
columns: this.columns(),
|
|
385
|
+
rowId: this.rowId(),
|
|
386
|
+
actions: this.actions(),
|
|
387
|
+
labels: this.labels(),
|
|
388
|
+
pageSizes: this.pageSizes(),
|
|
389
|
+
};
|
|
390
|
+
untracked(() => this.controller.configure(options));
|
|
391
|
+
});
|
|
392
|
+
effect(() => {
|
|
393
|
+
const rows = this.rows();
|
|
394
|
+
untracked(() => this.controller.setRows(rows));
|
|
395
|
+
});
|
|
396
|
+
effect(() => {
|
|
397
|
+
const pinnedRows = this.pinnedRows();
|
|
398
|
+
if (pinnedRows !== undefined) {
|
|
399
|
+
untracked(() => this.controller.configure({ pinnedRows }));
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
effect(() => {
|
|
403
|
+
const pageSize = this.pageSize();
|
|
404
|
+
if (pageSize !== undefined) {
|
|
405
|
+
untracked(() => this.controller.configure({ pageSize }));
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
afterRenderEffect(onCleanup => {
|
|
409
|
+
this.headerLayout();
|
|
410
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const host = this.host.nativeElement;
|
|
414
|
+
const scroller = host.querySelector('.su-table-scroll');
|
|
415
|
+
const headers = [...host.querySelectorAll('thead th')];
|
|
416
|
+
const head = host.querySelector('thead');
|
|
417
|
+
const pinnedRows = [
|
|
418
|
+
...host.querySelectorAll('tbody > tr.is-pinned-row'),
|
|
419
|
+
];
|
|
420
|
+
const observer = new ResizeObserver(() => {
|
|
421
|
+
this.headerHeight.set(head?.getBoundingClientRect().height ?? 0);
|
|
422
|
+
const heights = pinnedRows.map(row => row.getBoundingClientRect().height);
|
|
423
|
+
const currentHeights = untracked(() => this.pinnedRowHeights());
|
|
424
|
+
if (heights.length !== currentHeights.length ||
|
|
425
|
+
heights.some((height, index) => height !== currentHeights[index])) {
|
|
426
|
+
this.pinnedRowHeights.set(heights);
|
|
427
|
+
}
|
|
428
|
+
const widths = headers.map(header => header.getBoundingClientRect().width);
|
|
429
|
+
const current = untracked(() => this.headerWidths());
|
|
430
|
+
if (widths.some((width, index) => width !== current[index])) {
|
|
431
|
+
this.headerWidths.set(widths);
|
|
432
|
+
}
|
|
433
|
+
if (scroller) {
|
|
434
|
+
this.scrollerWidth.set(scroller.clientWidth);
|
|
435
|
+
this.updateScrollEdges(scroller);
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
[...headers, ...pinnedRows].forEach(element => observer.observe(element));
|
|
439
|
+
if (scroller) {
|
|
440
|
+
observer.observe(scroller);
|
|
441
|
+
}
|
|
442
|
+
onCleanup(() => observer.disconnect());
|
|
443
|
+
});
|
|
444
|
+
afterRenderEffect(() => {
|
|
445
|
+
const id = this.focusFieldId();
|
|
446
|
+
const field = id ? document.getElementById(id) : null;
|
|
447
|
+
if (field instanceof HTMLInputElement ||
|
|
448
|
+
field instanceof HTMLTextAreaElement) {
|
|
449
|
+
field.focus();
|
|
450
|
+
field.select();
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
field?.focus();
|
|
454
|
+
}
|
|
455
|
+
if (field) {
|
|
456
|
+
this.focusFieldId.set(null);
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
afterRenderEffect(() => {
|
|
460
|
+
const id = this.focusHandleId();
|
|
461
|
+
this.state();
|
|
462
|
+
const handle = this.host.nativeElement.querySelector(`[data-su-handle="${id}"]`);
|
|
463
|
+
if (id !== null && handle && document.activeElement !== handle) {
|
|
464
|
+
handle.focus();
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
cellTemplate(key) {
|
|
469
|
+
return (this.cellTemplates().find(cell => cell.key() === String(key))?.template ??
|
|
470
|
+
null);
|
|
471
|
+
}
|
|
472
|
+
inlineField(key) {
|
|
473
|
+
return this.inlineDraft()?.fields.find(field => field.key === key) ?? null;
|
|
474
|
+
}
|
|
475
|
+
controlId(id, key) {
|
|
476
|
+
return `${this.tableId}-${id}-${String(key)}`;
|
|
477
|
+
}
|
|
478
|
+
/** The pin in a heading unpins its column, or pins it back to the side it was set up with (by default the start) */
|
|
479
|
+
toggleColumnPin(key, pinned) {
|
|
480
|
+
const setUpPin = this.columns().find(column => column.key === key)?.pinned;
|
|
481
|
+
this.controller.pinColumn(key, pinned ? null : (setUpPin ?? 'start'));
|
|
482
|
+
this.columnsChange.emit(this.state().allColumns);
|
|
483
|
+
}
|
|
484
|
+
setColumnPinnable({ key, pinnable, }) {
|
|
485
|
+
this.controller.setColumnPinnable(key, pinnable);
|
|
486
|
+
this.columnsChange.emit(this.state().allColumns);
|
|
487
|
+
}
|
|
488
|
+
setColumnsVisible(visible) {
|
|
489
|
+
this.controller.setColumnsVisible(visible);
|
|
490
|
+
this.columnsChange.emit(this.state().allColumns);
|
|
491
|
+
}
|
|
492
|
+
setColumnVisible({ key, visible, }) {
|
|
493
|
+
this.controller.setColumnVisible(key, visible);
|
|
494
|
+
this.columnsChange.emit(this.state().allColumns);
|
|
495
|
+
}
|
|
496
|
+
/** Narrows the rows once typing pauses, so each keystroke isn't announced */
|
|
497
|
+
search(query) {
|
|
498
|
+
clearTimeout(this.searchTimer);
|
|
499
|
+
this.searchTimer = setTimeout(() => {
|
|
500
|
+
this.controller.search(query);
|
|
501
|
+
this.searchChange.emit(query);
|
|
502
|
+
}, SEARCH_DELAY);
|
|
503
|
+
}
|
|
504
|
+
onScroll(event) {
|
|
505
|
+
if (event.target instanceof HTMLElement) {
|
|
506
|
+
this.updateScrollEdges(event.target);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
sortBy(key) {
|
|
510
|
+
this.controller.sortBy(key);
|
|
511
|
+
this.sortChange.emit(this.state().sort);
|
|
512
|
+
}
|
|
513
|
+
select(id) {
|
|
514
|
+
this.controller.select(id);
|
|
515
|
+
this.selectionChange.emit(this.controller.selectedRows());
|
|
516
|
+
}
|
|
517
|
+
selectAll(selected) {
|
|
518
|
+
this.controller.selectAll(selected);
|
|
519
|
+
this.selectionChange.emit(this.controller.selectedRows());
|
|
520
|
+
}
|
|
521
|
+
pinRow(id) {
|
|
522
|
+
this.controller.pinRow(id);
|
|
523
|
+
this.pinnedRowsChange.emit(this.state().pinnedRows.map(row => row.id));
|
|
524
|
+
}
|
|
525
|
+
runAction(action, row) {
|
|
526
|
+
if (action.id === SU_TABLE_EDIT_ACTION && this.state().editable) {
|
|
527
|
+
this.controller.startEdit([row.id]);
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
this.action.emit({ id: action.id, rows: [row.data] });
|
|
531
|
+
}
|
|
532
|
+
runBulkAction(action) {
|
|
533
|
+
this.action.emit({ id: action.id, rows: this.controller.selectedRows() });
|
|
534
|
+
}
|
|
535
|
+
setPage(page) {
|
|
536
|
+
this.controller.setPage(page);
|
|
537
|
+
this.emitPage();
|
|
538
|
+
}
|
|
539
|
+
setPageSize(pageSize) {
|
|
540
|
+
this.controller.setPageSize(pageSize);
|
|
541
|
+
this.emitPage();
|
|
542
|
+
}
|
|
543
|
+
/** Whether a double-click on this cell edits its row */
|
|
544
|
+
editsOnDoubleClick(key) {
|
|
545
|
+
return (this.editOnDoubleClick() &&
|
|
546
|
+
this.state().columns.some(column => column.key === key && column.editor));
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Edits the row of a double-clicked cell, starting in its field. While another row (or several) is being edited,
|
|
550
|
+
* only a cell of that same row moves the focus, so unsaved changes are never dropped.
|
|
551
|
+
*/
|
|
552
|
+
editCell(row, key) {
|
|
553
|
+
if (!this.editsOnDoubleClick(key)) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const draft = this.state().draft;
|
|
557
|
+
if (!draft) {
|
|
558
|
+
this.controller.startEdit([row.id]);
|
|
559
|
+
}
|
|
560
|
+
else if (draft.bulk || draft.ids[0] !== row.id) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
this.focusFieldId.set(this.controlId(row.id, key));
|
|
564
|
+
}
|
|
565
|
+
/** The second click of a double-click doesn't select the word under it */
|
|
566
|
+
keepTextUnselected(event, key) {
|
|
567
|
+
if (event.detail > 1 && this.editsOnDoubleClick(key)) {
|
|
568
|
+
event.preventDefault();
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
editSelected() {
|
|
572
|
+
this.controller.startEdit();
|
|
573
|
+
}
|
|
574
|
+
setDraft(key, value) {
|
|
575
|
+
this.controller.setDraft(key, value);
|
|
576
|
+
}
|
|
577
|
+
save(event) {
|
|
578
|
+
event?.preventDefault();
|
|
579
|
+
const result = this.controller.save();
|
|
580
|
+
if (result.ok && result.rows.length > 0) {
|
|
581
|
+
this.edited.emit(result.rows);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
cancelEdit() {
|
|
585
|
+
this.controller.cancelEdit();
|
|
586
|
+
}
|
|
587
|
+
/** Enter saves the row being edited inline (but adds a line in a text area), Escape cancels */
|
|
588
|
+
onEditKey(event) {
|
|
589
|
+
if (event.key === 'Escape') {
|
|
590
|
+
this.cancelEdit();
|
|
591
|
+
}
|
|
592
|
+
else if (event.key === 'Enter' &&
|
|
593
|
+
!(event.target instanceof HTMLTextAreaElement)) {
|
|
594
|
+
this.save(event);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
onHandleKey(event, id) {
|
|
598
|
+
const result = this.controller.moveKey(id, event.key);
|
|
599
|
+
if (!result.handled) {
|
|
600
|
+
this.focusHandleId.set(null);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
event.preventDefault();
|
|
604
|
+
this.focusHandleId.set(id);
|
|
605
|
+
if (result.order) {
|
|
606
|
+
this.emitReorder(result.order);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
onHandleDown(event, id, index) {
|
|
610
|
+
if (event.button !== 0) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
event.preventDefault();
|
|
614
|
+
if (event.target instanceof Element) {
|
|
615
|
+
event.target.setPointerCapture(event.pointerId);
|
|
616
|
+
}
|
|
617
|
+
const rows = [
|
|
618
|
+
...this.host.nativeElement.querySelectorAll('tbody > tr[data-su-row]'),
|
|
619
|
+
].map(row => row.getBoundingClientRect());
|
|
620
|
+
this.drag.set({
|
|
621
|
+
id,
|
|
622
|
+
from: index,
|
|
623
|
+
to: index,
|
|
624
|
+
startY: event.clientY + window.scrollY,
|
|
625
|
+
offsetY: 0,
|
|
626
|
+
height: rows[index]?.height ?? 0,
|
|
627
|
+
middles: rows.map(({ top, height }) => top + window.scrollY + height / 2),
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
onHandleMove(event) {
|
|
631
|
+
const drag = this.drag();
|
|
632
|
+
if (!drag) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
const pointerY = event.clientY + window.scrollY;
|
|
636
|
+
this.drag.set({
|
|
637
|
+
...drag,
|
|
638
|
+
to: suTableDropIndex(pointerY, drag.middles, drag.from),
|
|
639
|
+
offsetY: pointerY - drag.startY,
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
onHandleUp() {
|
|
643
|
+
const drag = this.drag();
|
|
644
|
+
this.drag.set(null);
|
|
645
|
+
const order = drag ? this.controller.move(drag.id, drag.to) : null;
|
|
646
|
+
if (order) {
|
|
647
|
+
this.emitReorder(order);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
onHandleCancel() {
|
|
651
|
+
this.drag.set(null);
|
|
652
|
+
}
|
|
653
|
+
/** While dragging, the dragged row follows the pointer and the rows it passes slide aside to open its place */
|
|
654
|
+
rowClassOf(row) {
|
|
655
|
+
return this.rowClass()?.(row.data) ?? null;
|
|
656
|
+
}
|
|
657
|
+
/** Where the drop line shows while dragging: on the edge of the gap the dragged row will land in */
|
|
658
|
+
dropSide(index) {
|
|
659
|
+
const drag = this.drag();
|
|
660
|
+
if (!drag || drag.to === drag.from || drag.to !== index) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
return drag.to > drag.from ? 'after' : 'before';
|
|
664
|
+
}
|
|
665
|
+
dragTransform(index) {
|
|
666
|
+
const drag = this.drag();
|
|
667
|
+
if (!drag) {
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
if (index === drag.from) {
|
|
671
|
+
return `translateY(${drag.offsetY}px)`;
|
|
672
|
+
}
|
|
673
|
+
const slidesUp = index > drag.from && index <= drag.to;
|
|
674
|
+
const slidesDown = index < drag.from && index >= drag.to;
|
|
675
|
+
return slidesUp || slidesDown
|
|
676
|
+
? `translateY(${slidesUp ? -drag.height : drag.height}px)`
|
|
677
|
+
: null;
|
|
678
|
+
}
|
|
679
|
+
/** Shadows show on the pinned edges only while columns or rows are scrolled under them */
|
|
680
|
+
updateScrollEdges(scroller) {
|
|
681
|
+
this.scrolledFromTop.set(scroller.scrollTop > 1);
|
|
682
|
+
const position = Math.abs(scroller.scrollLeft);
|
|
683
|
+
this.scrolledFromStart.set(position > 1);
|
|
684
|
+
this.moreAtEnd.set(position < scroller.scrollWidth - scroller.clientWidth - 1);
|
|
685
|
+
}
|
|
686
|
+
emitPage() {
|
|
687
|
+
const { page, pageSize } = this.state().pagination;
|
|
688
|
+
this.pageChange.emit({ page, pageSize });
|
|
689
|
+
}
|
|
690
|
+
emitReorder(ids) {
|
|
691
|
+
this.reordered.emit({ ids, rows: this.controller.rowsOf(ids) });
|
|
692
|
+
}
|
|
693
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
694
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.35", type: SuTableComponent, isStandalone: true, selector: "su-lib-table", inputs: { columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: true, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: true, transformFunction: null }, caption: { classPropertyName: "caption", publicName: "caption", isSignal: true, isRequired: true, transformFunction: null }, showCaption: { classPropertyName: "showCaption", publicName: "showCaption", isSignal: true, isRequired: false, transformFunction: null }, rowId: { classPropertyName: "rowId", publicName: "rowId", isSignal: true, isRequired: false, transformFunction: null }, actions: { classPropertyName: "actions", publicName: "actions", isSignal: true, isRequired: false, transformFunction: null }, selectable: { classPropertyName: "selectable", publicName: "selectable", isSignal: true, isRequired: false, transformFunction: null }, reorderable: { classPropertyName: "reorderable", publicName: "reorderable", isSignal: true, isRequired: false, transformFunction: null }, columnControls: { classPropertyName: "columnControls", publicName: "columnControls", isSignal: true, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, rowClass: { classPropertyName: "rowClass", publicName: "rowClass", isSignal: true, isRequired: false, transformFunction: null }, editOnDoubleClick: { classPropertyName: "editOnDoubleClick", publicName: "editOnDoubleClick", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, pageSizes: { classPropertyName: "pageSizes", publicName: "pageSizes", isSignal: true, isRequired: false, transformFunction: null }, rowPinning: { classPropertyName: "rowPinning", publicName: "rowPinning", isSignal: true, isRequired: false, transformFunction: null }, pinnedRows: { classPropertyName: "pinnedRows", publicName: "pinnedRows", isSignal: true, isRequired: false, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { edited: "edited", reordered: "reordered", action: "action", sortChange: "sortChange", selectionChange: "selectionChange", searchChange: "searchChange", pinnedRowsChange: "pinnedRowsChange", columnsChange: "columnsChange", pageChange: "pageChange" }, host: { classAttribute: "su-table" }, queries: [{ propertyName: "cellTemplates", predicate: SuTableCellDirective, isSignal: true }], ngImport: i0, template: "@let current = state();\n@let t = text();\n@let selectedCount = current.selectedIds.length;\n@let pins = placements();\n@let firstColumnSlot = columnSlot();\n@if (searchable() || columnControls()) {\n <su-lib-table-toolbar\n [labels]=\"t\"\n [controlId]=\"tableId\"\n [searchable]=\"searchable()\"\n [query]=\"current.query\"\n [columnControls]=\"columnControls()\"\n [columns]=\"current.allColumns\"\n (queryChange)=\"search($event)\"\n (pinnableChange)=\"setColumnPinnable($event)\"\n (visibilityChange)=\"setColumnVisible($event)\"\n (allVisibilityChange)=\"setColumnsVisible($event)\"\n />\n}\n@if (selectable() && selectedCount > 0) {\n <div class=\"su-table-toolbar\" role=\"toolbar\" [attr.aria-label]=\"t.selected(selectedCount)\">\n <span class=\"su-table-toolbar-count\">{{ t.selected(selectedCount) }}</span>\n @if (current.editable && !current.draft) {\n <button type=\"button\" class=\"su-table-button\" (click)=\"editSelected()\">\n {{ t.editSelected(selectedCount) }}\n </button>\n }\n @for (action of current.bulkActions; track action.id) {\n <button type=\"button\" class=\"su-table-button\" [class.is-danger]=\"action.danger\" (click)=\"runBulkAction(action)\">\n {{ action.label }}\n </button>\n }\n <button type=\"button\" class=\"su-table-button is-quiet\" (click)=\"selectAll(false)\">{{ t.clearSelection }}</button>\n </div>\n}\n\n@if (bulkDraft(); as draft) {\n <form\n class=\"su-table-bulk\"\n [attr.aria-labelledby]=\"tableId + '-bulk-title'\"\n (submit)=\"save($event)\"\n (keydown.escape)=\"cancelEdit()\"\n >\n <h3 class=\"su-table-bulk-title\" [id]=\"tableId + '-bulk-title'\">{{ t.editing(draft.ids.length) }}</h3>\n <div class=\"su-table-bulk-fields\">\n @for (field of draft.fields; track field.key) {\n <div class=\"su-table-bulk-field\">\n <label class=\"su-table-label\" [for]=\"controlId('bulk', field.key)\">{{ field.header }}</label>\n <su-lib-table-field\n [field]=\"field\"\n [controlId]=\"controlId('bulk', field.key)\"\n [mixedLabel]=\"t.mixed\"\n (valueChange)=\"setDraft(field.key, $event)\"\n />\n </div>\n }\n </div>\n <div class=\"su-table-bulk-actions\">\n <button type=\"submit\" class=\"su-table-button is-primary\">{{ t.save }}</button>\n <button type=\"button\" class=\"su-table-button\" (click)=\"cancelEdit()\">{{ t.cancel }}</button>\n </div>\n </form>\n}\n\n<div\n class=\"su-table-scroll\"\n [class.is-scrolled-start]=\"scrolledFromStart()\"\n [class.has-more-end]=\"moreAtEnd()\"\n [class.is-scrolled-top]=\"scrolledFromTop()\"\n [class.has-pinned-rows]=\"current.pinnedRows.length > 0\"\n [style.max-height]=\"maxHeight()\"\n (scroll)=\"onScroll($event)\"\n>\n <table class=\"su-table-grid\" [class.is-dragging-rows]=\"drag() !== null\">\n <caption [class.su-table-visually-hidden]=\"!showCaption()\">{{ caption() }}</caption>\n <thead>\n <tr>\n @if (reorderable()) {\n <th scope=\"col\" class=\"su-table-handle-cell\" [suTablePin]=\"pins[0]\">\n <span class=\"su-table-visually-hidden\">{{ t.order }}</span>\n </th>\n }\n @if (selectable()) {\n <th scope=\"col\" class=\"su-table-select-cell\" [suTablePin]=\"pins[firstColumnSlot - 1]\">\n <input\n type=\"checkbox\"\n class=\"su-table-checkbox\"\n [checked]=\"current.selection === 'all'\"\n [indeterminate]=\"current.selection === 'some'\"\n [disabled]=\"current.rows.length === 0\"\n [attr.aria-label]=\"t.selectAll\"\n (change)=\"selectAll()\"\n />\n </th>\n }\n @for (column of current.columns; track column.key; let columnIndex = $index) {\n <th\n scope=\"col\"\n class=\"su-table-align-{{ column.align }}\"\n [class.is-sorted]=\"column.sort !== 'none'\"\n [suTablePin]=\"pins[firstColumnSlot + columnIndex]\"\n [attr.aria-sort]=\"column.sort === 'none' ? null : column.sort\"\n >\n @if (column.sortable) {\n <button type=\"button\" class=\"su-table-sort\" (click)=\"sortBy(column.key)\">\n {{ column.header }}\n <span class=\"su-table-sort-icon is-{{ column.sort }}\" aria-hidden=\"true\"></span>\n </button>\n } @else {\n {{ column.header }}\n }\n @if (column.pinnable) {\n <button\n type=\"button\"\n class=\"su-table-header-pin\"\n [attr.aria-label]=\"t.pinColumn(column.header)\"\n [attr.aria-pressed]=\"column.pinned !== null\"\n (click)=\"toggleColumnPin(column.key, column.pinned)\"\n >\n <svg suTablePinIcon width=\"12\" height=\"12\"></svg>\n </button>\n } @else if (pins[firstColumnSlot + columnIndex]) {\n <svg suTablePinIcon class=\"su-table-pinned-icon\" width=\"11\" height=\"11\"></svg>\n }\n </th>\n }\n @if (hasActions()) {\n <th scope=\"col\" class=\"su-table-actions-cell\" [suTablePin]=\"pins[pins.length - 1]\">{{ t.actions }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of bodyRows(); track row.id; let rowIndex = $index) {\n @let editing = inlineDraft()?.ids?.[0] === row.id;\n @let index = rowIndex - current.pinnedRows.length;\n <tr\n [attr.data-su-row]=\"row.pinned ? null : ''\"\n [class.is-pinned-row]=\"row.pinned\"\n [class.is-last-pinned-row]=\"index === -1\"\n [style.--su-table-row-top]=\"row.pinned ? pinnedRowTops()[rowIndex] + 'px' : null\"\n [class.is-selected]=\"row.selected\"\n [class.is-editing]=\"editing\"\n [class.is-grabbed]=\"current.grabbedId === row.id\"\n [class]=\"rowClassOf(row)\"\n [class.is-dragging]=\"drag()?.id === row.id\"\n [class.is-drop-before]=\"dropSide(index) === 'before'\"\n [class.is-drop-after]=\"dropSide(index) === 'after'\"\n [style.transform]=\"dragTransform(index)\"\n (keydown)=\"editing && onEditKey($event)\"\n >\n @if (reorderable()) {\n <td class=\"su-table-handle-cell\" [suTablePin]=\"pins[0]\">\n @if (!row.pinned && !current.searching) {\n <button\n type=\"button\"\n class=\"su-table-handle\"\n [attr.data-su-handle]=\"row.id\"\n [attr.aria-label]=\"t.moveRow(row.label)\"\n [attr.aria-pressed]=\"current.grabbedId === row.id\"\n (keydown)=\"onHandleKey($event, row.id)\"\n (pointerdown)=\"onHandleDown($event, row.id, index)\"\n (pointermove)=\"onHandleMove($event)\"\n (pointerup)=\"onHandleUp()\"\n (pointercancel)=\"onHandleCancel()\"\n >\n <span class=\"su-table-grip\" aria-hidden=\"true\"></span>\n </button>\n }\n </td>\n }\n @if (selectable()) {\n <td class=\"su-table-select-cell\" [suTablePin]=\"pins[firstColumnSlot - 1]\">\n <input\n type=\"checkbox\"\n class=\"su-table-checkbox\"\n [checked]=\"row.selected\"\n [attr.aria-label]=\"t.selectRow(row.label)\"\n (change)=\"select(row.id)\"\n />\n </td>\n }\n @for (cell of row.cells; track cell.key; let cellIndex = $index) {\n @let column = current.columns[cellIndex];\n @let pin = pins[firstColumnSlot + cellIndex];\n <td\n class=\"su-table-align-{{ column.align }}\"\n [attr.role]=\"cell.key === current.rowHeaderKey ? 'rowheader' : null\"\n [class.su-table-row-header]=\"cell.key === current.rowHeaderKey\"\n [class.is-sorted]=\"column.sort !== 'none'\"\n [class.is-editable]=\"!editing && editsOnDoubleClick(cell.key)\"\n [suTablePin]=\"pin\"\n (mousedown)=\"keepTextUnselected($event, cell.key)\"\n (dblclick)=\"editCell(row, cell.key)\"\n >\n @if (editing && inlineField(cell.key); as field) {\n <su-lib-table-field\n [field]=\"field\"\n [controlId]=\"controlId(row.id, cell.key)\"\n [ariaLabel]=\"column.header\"\n [mixedLabel]=\"t.mixed\"\n (valueChange)=\"setDraft(cell.key, $event)\"\n />\n } @else {\n @if (cellTemplate(cell.key); as template) {\n <ng-container *ngTemplateOutlet=\"template; context: { $implicit: row.data, text: cell.text }\" />\n } @else {\n {{ cell.text }}\n }\n }\n </td>\n }\n @if (hasActions()) {\n <td class=\"su-table-actions-cell\" [suTablePin]=\"pins[pins.length - 1]\">\n <div class=\"su-table-actions\">\n @if (editing) {\n <button type=\"button\" class=\"su-table-button is-primary\" (click)=\"save()\">{{ t.save }}</button>\n <button type=\"button\" class=\"su-table-button\" (click)=\"cancelEdit()\">{{ t.cancel }}</button>\n } @else {\n @if (rowPinning()) {\n <button\n type=\"button\"\n class=\"su-table-button su-table-pin-button\"\n [attr.aria-pressed]=\"row.pinned\"\n [attr.aria-label]=\"t.pinRow + ', ' + row.label\"\n (click)=\"pinRow(row.id)\"\n >\n <svg suTablePinIcon width=\"12\" height=\"12\"></svg>\n {{ t.pinRow }}\n </button>\n }\n @for (action of row.actions; track action.id) {\n <button\n type=\"button\"\n class=\"su-table-button\"\n [class.is-danger]=\"action.danger\"\n [disabled]=\"action.disabled\"\n [attr.aria-label]=\"action.label + ', ' + row.label\"\n (click)=\"runAction(action, row)\"\n >\n {{ action.label }}\n </button>\n }\n }\n </div>\n </td>\n }\n </tr>\n }\n @if (current.rows.length === 0) {\n <tr>\n <td class=\"su-table-empty\" [attr.colspan]=\"columnCount()\">\n {{ current.searching ? t.noMatches(current.query) : t.empty }}\n </td>\n </tr>\n }\n </tbody>\n </table>\n</div>\n\n@if (current.pagination.pageSizes.length > 0 || current.pagination.pageSize !== 'all') {\n <su-lib-table-paginator\n [pagination]=\"current.pagination\"\n [labels]=\"t\"\n [controlId]=\"tableId + '-page-size'\"\n (pageChange)=\"setPage($event)\"\n (pageSizeChange)=\"setPageSize($event)\"\n />\n}\n\n<div class=\"su-table-visually-hidden\" role=\"status\">{{ current.announcement }}</div>\n", styles: [":host{color:var(--su-table-text-color, inherit);display:block;min-width:0;font-family:var(--su-table-font-family, inherit);font-size:var(--su-table-font-size, .95rem)}.su-table-scroll{border:var(--su-table-border, 1px solid rgba(0, 0, 0, .12));border-radius:var(--su-table-radius, 10px);overflow:auto}.su-table-grid{background:var(--su-table-background, transparent);border-collapse:separate;border-spacing:0;min-width:100%}caption{caption-side:top;color:var(--su-table-caption-color, inherit);font-size:var(--su-table-caption-font-size, inherit);font-weight:600;padding:var(--su-table-cell-padding, .6rem .75rem);text-align:start}th,td{background-image:linear-gradient(var(--su-table-cell-tint, transparent),var(--su-table-cell-tint, transparent));border-bottom:var(--su-table-row-border, 1px solid rgba(0, 0, 0, .08));padding:var(--su-table-cell-padding, .6rem .75rem);text-align:start;vertical-align:var(--su-table-cell-vertical-align, middle)}thead th{--su-table-row-tint: var(--su-table-header-background, rgb(0 0 0 / .03));border-bottom:var(--su-table-header-border, var(--su-table-row-border, 1px solid rgba(0, 0, 0, .08)));color:var(--su-table-header-color, inherit);font-size:var(--su-table-header-font-size, inherit);font-weight:var(--su-table-header-font-weight, 600);letter-spacing:var(--su-table-header-letter-spacing, normal);padding:var(--su-table-header-padding, var(--su-table-cell-padding, .6rem .75rem));text-transform:var(--su-table-header-text-transform, none);white-space:nowrap}.is-sorted{--su-table-cell-tint: var(--su-table-sorted-background, transparent)}td.is-editable:hover,th.is-editable:hover{--su-table-cell-tint: var(--su-table-editable-hover-background, color-mix(in srgb, currentColor 6%, transparent))}.su-table-row-header{font-weight:var(--su-table-row-header-weight, 600)}tbody tr:last-child>*{border-bottom:none}tbody tr{--su-table-row-tint: var(--su-table-row-background, transparent);background:var(--su-table-row-tint);color:var(--su-table-row-color, inherit)}tbody tr:nth-child(2n){--su-table-row-tint: var(--su-table-stripe-background, var(--su-table-row-background, transparent))}tbody tr.is-muted{--su-table-row-tint: var(--su-table-muted-background, transparent);color:color-mix(in srgb,currentColor var(--su-table-muted-text, 55%),transparent)}tbody tr.is-highlighted{--su-table-row-tint: var(--su-table-highlight-background, color-mix(in srgb, #f59e0b 14%, transparent))}tbody tr:hover{--su-table-row-tint: var(--su-table-hover-background, rgb(0 0 0 / .025))}tbody tr.is-selected{--su-table-row-tint: var(--su-table-selected-background, color-mix(in srgb, #2563eb 8%, transparent));color:var(--su-table-selected-color, inherit)}tbody tr.is-editing{--su-table-row-tint: var(--su-table-editing-background, color-mix(in srgb, #2563eb 5%, transparent))}tbody tr.is-pinned-row{--su-table-row-tint: var(--su-table-pinned-row-background, color-mix(in srgb, #2563eb 6%, transparent))}tbody tr.is-last-pinned-row>*{border-bottom:var(--su-table-pinned-row-border, 2px solid color-mix(in srgb, #2563eb 40%, transparent))}tbody tr.is-grabbed,tbody tr.is-dragging{--su-table-row-tint: var(--su-table-grabbed-background, color-mix(in srgb, #2563eb 14%, transparent));outline:var(--su-table-grabbed-outline, 2px solid color-mix(in srgb, #2563eb 60%, transparent));outline-offset:-2px}tbody tr.is-dragging{background:linear-gradient(var(--su-table-row-tint),var(--su-table-row-tint)),var(--su-table-dragging-background, Canvas);box-shadow:var(--su-table-dragging-shadow, 0 8px 24px rgba(0, 0, 0, .18));cursor:grabbing;position:relative;z-index:3}tbody tr.is-drop-before>*{box-shadow:inset 0 var(--su-table-drop-line-width, 2px) 0 var(--su-table-drop-line-color, #2563eb)}tbody tr.is-drop-after>*{box-shadow:inset 0 calc(-1 * var(--su-table-drop-line-width, 2px)) 0 var(--su-table-drop-line-color, #2563eb)}thead th,tbody tr.is-pinned-row>*,.is-pinned-start,.is-pinned-end{background:linear-gradient(var(--su-table-cell-tint, transparent),var(--su-table-cell-tint, transparent)),linear-gradient(var(--su-table-row-tint, transparent),var(--su-table-row-tint, transparent)),var(--su-table-pinned-background, Canvas);position:sticky;z-index:1}thead th{top:0;z-index:4}thead th.is-pinned-start,thead th.is-pinned-end{z-index:5}tbody tr.is-pinned-row>*{top:var(--su-table-row-top, 0);z-index:2}tbody tr.is-pinned-row>*.is-pinned-start,tbody tr.is-pinned-row>*.is-pinned-end{z-index:3}.is-scrolled-top:not(.has-pinned-rows) thead th,.is-scrolled-top tr.is-last-pinned-row>*{box-shadow:var(--su-table-sticky-shadow, 0 6px 8px -6px rgba(0, 0, 0, .25))}.is-pinned-edge:after{content:\"\";inset-block:0;opacity:0;pointer-events:none;position:absolute;transition:opacity .15s ease-out;width:1rem}.is-pinned-start.is-pinned-edge{border-inline-end:var(--su-table-pinned-border, 1px solid rgba(0, 0, 0, .14))}.is-pinned-end.is-pinned-edge{border-inline-start:var(--su-table-pinned-border, 1px solid rgba(0, 0, 0, .14))}.su-table-pinned-icon{margin-inline-start:.35rem;opacity:.45;vertical-align:-1px}.su-table-header-pin{background:none;border:none;border-radius:4px;color:inherit;cursor:pointer;margin-inline-start:.2rem;opacity:.3;padding:.2rem;vertical-align:middle}.su-table-header-pin:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-header-pin:hover{opacity:.7}.su-table-header-pin[aria-pressed=true]{color:var(--su-table-accent, #2563eb);opacity:1}.is-pinned-start.is-pinned-edge:after{background:linear-gradient(to right,var(--su-table-pinned-shadow, rgba(0, 0, 0, .22)),transparent);inset-inline-start:100%}.is-pinned-end.is-pinned-edge:after{background:linear-gradient(to left,var(--su-table-pinned-shadow, rgba(0, 0, 0, .22)),transparent);inset-inline-end:100%}.is-scrolled-start .is-pinned-start.is-pinned-edge:after,.has-more-end .is-pinned-end.is-pinned-edge:after{opacity:1}@media(prefers-reduced-motion:no-preference){.is-dragging-rows tbody tr:not(.is-dragging){transition:transform .15s ease-out}}td.is-editable,th.is-editable{cursor:text}.su-table-align-start{text-align:start}.su-table-align-center{text-align:center}.su-table-align-end{text-align:end}.su-table-handle-cell,.su-table-select-cell{text-align:center;width:1%}.su-table-actions-cell{text-align:end;width:1%}.su-table-actions{display:flex;gap:.35rem;justify-content:flex-end}.su-table-sort{align-items:center;background:none;border:none;border-radius:4px;color:inherit;cursor:pointer;display:inline-flex;font:inherit;letter-spacing:inherit;text-transform:inherit;gap:.35rem;margin:-.2rem -.35rem;padding:.2rem .35rem}.su-table-sort-icon{border-left:.3rem solid transparent;border-right:.3rem solid transparent;height:0;opacity:.35;width:0}.su-table-sort-icon.is-none,.su-table-sort-icon.is-ascending{border-bottom:.4rem solid currentColor}.su-table-sort-icon.is-descending{border-top:.4rem solid currentColor}.su-table-sort-icon.is-ascending,.su-table-sort-icon.is-descending{opacity:1}.su-table-handle{background:none;border:none;border-radius:4px;color:var(--su-table-handle-color, inherit);cursor:grab;display:inline-flex;padding:.35rem .3rem;touch-action:none}.su-table-handle:active{cursor:grabbing}.su-table-grip{background-image:radial-gradient(currentColor 1.2px,transparent 1.4px);background-size:6px 6px;display:block;height:18px;opacity:.6;width:12px}.su-table-button{background:var(--su-table-button-background, transparent);border:var(--su-table-button-border, 1px solid rgba(0, 0, 0, .2));border-radius:var(--su-table-button-radius, 6px);color:var(--su-table-button-color, inherit);cursor:pointer;font:inherit;font-size:.875em;padding:var(--su-table-button-padding, .3rem .7rem);white-space:nowrap}.su-table-button:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-button:disabled{cursor:not-allowed;opacity:.45}.su-table-button.is-primary{background:var(--su-table-primary-background, #111);border-color:transparent;color:var(--su-table-primary-color, #fff)}.su-table-button.is-danger{border-color:var(--su-table-danger-border, color-mix(in srgb, #b42318 35%, transparent));color:var(--su-table-danger-color, #b42318)}.su-table-button.is-quiet{border-color:transparent}.su-table-button.su-table-pin-button{align-items:center;display:inline-flex;gap:.3rem}.su-table-button.su-table-pin-button svg{opacity:.5}.su-table-button.su-table-pin-button[aria-pressed=true]{border-color:var(--su-table-accent, #2563eb);color:var(--su-table-accent, #2563eb)}.su-table-button.su-table-pin-button[aria-pressed=true] svg{opacity:1}.su-table-sort:focus-visible,.su-table-handle:focus-visible,.su-table-checkbox:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-checkbox{accent-color:var(--su-table-accent, #2563eb);height:var(--su-table-checkbox-size, 1rem);margin:0;width:var(--su-table-checkbox-size, 1rem)}.su-table-toolbar,.su-table-bulk{background:var(--su-table-panel-background, rgba(0, 0, 0, .03));border-radius:var(--su-table-radius, 10px);margin-bottom:.75rem;padding:.6rem .75rem}.su-table-toolbar{align-items:center;display:flex;flex-wrap:wrap;gap:.5rem}.su-table-toolbar-count{font-weight:600;margin-right:auto}.su-table-bulk-title{font-size:1rem;margin:0 0 .75rem}.su-table-bulk-fields{display:grid;gap:.75rem;grid-template-columns:repeat(auto-fill,minmax(12rem,1fr))}.su-table-bulk-field{display:flex;flex-direction:column;gap:.3rem}.su-table-label{font-size:.85em;font-weight:600}.su-table-bulk-actions{display:flex;gap:.5rem;margin-top:.75rem}.su-table-empty{opacity:.7;padding:1.5rem;text-align:center}.su-table-visually-hidden{clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}@media(prefers-reduced-motion:no-preference){tbody tr{transition:background-color .12s ease-out}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: SuTableFieldComponent, selector: "su-lib-table-field", inputs: ["field", "controlId", "ariaLabel", "mixedLabel"], outputs: ["valueChange"] }, { kind: "component", type: SuTablePaginatorComponent, selector: "su-lib-table-paginator", inputs: ["pagination", "labels", "controlId"], outputs: ["pageChange", "pageSizeChange"] }, { kind: "directive", type: SuTablePinDirective, selector: "[suTablePin]", inputs: ["suTablePin"] }, { kind: "component", type: SuTablePinIconComponent, selector: "svg[suTablePinIcon]" }, { kind: "component", type: SuTableToolbarComponent, selector: "su-lib-table-toolbar", inputs: ["labels", "controlId", "searchable", "query", "columnControls", "columns"], outputs: ["queryChange", "pinnableChange", "visibilityChange", "allVisibilityChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
695
|
+
}
|
|
696
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.35", ngImport: i0, type: SuTableComponent, decorators: [{
|
|
697
|
+
type: Component,
|
|
698
|
+
args: [{ selector: 'su-lib-table', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
699
|
+
NgTemplateOutlet,
|
|
700
|
+
SuTableFieldComponent,
|
|
701
|
+
SuTablePaginatorComponent,
|
|
702
|
+
SuTablePinDirective,
|
|
703
|
+
SuTablePinIconComponent,
|
|
704
|
+
SuTableToolbarComponent,
|
|
705
|
+
], host: { class: 'su-table' }, template: "@let current = state();\n@let t = text();\n@let selectedCount = current.selectedIds.length;\n@let pins = placements();\n@let firstColumnSlot = columnSlot();\n@if (searchable() || columnControls()) {\n <su-lib-table-toolbar\n [labels]=\"t\"\n [controlId]=\"tableId\"\n [searchable]=\"searchable()\"\n [query]=\"current.query\"\n [columnControls]=\"columnControls()\"\n [columns]=\"current.allColumns\"\n (queryChange)=\"search($event)\"\n (pinnableChange)=\"setColumnPinnable($event)\"\n (visibilityChange)=\"setColumnVisible($event)\"\n (allVisibilityChange)=\"setColumnsVisible($event)\"\n />\n}\n@if (selectable() && selectedCount > 0) {\n <div class=\"su-table-toolbar\" role=\"toolbar\" [attr.aria-label]=\"t.selected(selectedCount)\">\n <span class=\"su-table-toolbar-count\">{{ t.selected(selectedCount) }}</span>\n @if (current.editable && !current.draft) {\n <button type=\"button\" class=\"su-table-button\" (click)=\"editSelected()\">\n {{ t.editSelected(selectedCount) }}\n </button>\n }\n @for (action of current.bulkActions; track action.id) {\n <button type=\"button\" class=\"su-table-button\" [class.is-danger]=\"action.danger\" (click)=\"runBulkAction(action)\">\n {{ action.label }}\n </button>\n }\n <button type=\"button\" class=\"su-table-button is-quiet\" (click)=\"selectAll(false)\">{{ t.clearSelection }}</button>\n </div>\n}\n\n@if (bulkDraft(); as draft) {\n <form\n class=\"su-table-bulk\"\n [attr.aria-labelledby]=\"tableId + '-bulk-title'\"\n (submit)=\"save($event)\"\n (keydown.escape)=\"cancelEdit()\"\n >\n <h3 class=\"su-table-bulk-title\" [id]=\"tableId + '-bulk-title'\">{{ t.editing(draft.ids.length) }}</h3>\n <div class=\"su-table-bulk-fields\">\n @for (field of draft.fields; track field.key) {\n <div class=\"su-table-bulk-field\">\n <label class=\"su-table-label\" [for]=\"controlId('bulk', field.key)\">{{ field.header }}</label>\n <su-lib-table-field\n [field]=\"field\"\n [controlId]=\"controlId('bulk', field.key)\"\n [mixedLabel]=\"t.mixed\"\n (valueChange)=\"setDraft(field.key, $event)\"\n />\n </div>\n }\n </div>\n <div class=\"su-table-bulk-actions\">\n <button type=\"submit\" class=\"su-table-button is-primary\">{{ t.save }}</button>\n <button type=\"button\" class=\"su-table-button\" (click)=\"cancelEdit()\">{{ t.cancel }}</button>\n </div>\n </form>\n}\n\n<div\n class=\"su-table-scroll\"\n [class.is-scrolled-start]=\"scrolledFromStart()\"\n [class.has-more-end]=\"moreAtEnd()\"\n [class.is-scrolled-top]=\"scrolledFromTop()\"\n [class.has-pinned-rows]=\"current.pinnedRows.length > 0\"\n [style.max-height]=\"maxHeight()\"\n (scroll)=\"onScroll($event)\"\n>\n <table class=\"su-table-grid\" [class.is-dragging-rows]=\"drag() !== null\">\n <caption [class.su-table-visually-hidden]=\"!showCaption()\">{{ caption() }}</caption>\n <thead>\n <tr>\n @if (reorderable()) {\n <th scope=\"col\" class=\"su-table-handle-cell\" [suTablePin]=\"pins[0]\">\n <span class=\"su-table-visually-hidden\">{{ t.order }}</span>\n </th>\n }\n @if (selectable()) {\n <th scope=\"col\" class=\"su-table-select-cell\" [suTablePin]=\"pins[firstColumnSlot - 1]\">\n <input\n type=\"checkbox\"\n class=\"su-table-checkbox\"\n [checked]=\"current.selection === 'all'\"\n [indeterminate]=\"current.selection === 'some'\"\n [disabled]=\"current.rows.length === 0\"\n [attr.aria-label]=\"t.selectAll\"\n (change)=\"selectAll()\"\n />\n </th>\n }\n @for (column of current.columns; track column.key; let columnIndex = $index) {\n <th\n scope=\"col\"\n class=\"su-table-align-{{ column.align }}\"\n [class.is-sorted]=\"column.sort !== 'none'\"\n [suTablePin]=\"pins[firstColumnSlot + columnIndex]\"\n [attr.aria-sort]=\"column.sort === 'none' ? null : column.sort\"\n >\n @if (column.sortable) {\n <button type=\"button\" class=\"su-table-sort\" (click)=\"sortBy(column.key)\">\n {{ column.header }}\n <span class=\"su-table-sort-icon is-{{ column.sort }}\" aria-hidden=\"true\"></span>\n </button>\n } @else {\n {{ column.header }}\n }\n @if (column.pinnable) {\n <button\n type=\"button\"\n class=\"su-table-header-pin\"\n [attr.aria-label]=\"t.pinColumn(column.header)\"\n [attr.aria-pressed]=\"column.pinned !== null\"\n (click)=\"toggleColumnPin(column.key, column.pinned)\"\n >\n <svg suTablePinIcon width=\"12\" height=\"12\"></svg>\n </button>\n } @else if (pins[firstColumnSlot + columnIndex]) {\n <svg suTablePinIcon class=\"su-table-pinned-icon\" width=\"11\" height=\"11\"></svg>\n }\n </th>\n }\n @if (hasActions()) {\n <th scope=\"col\" class=\"su-table-actions-cell\" [suTablePin]=\"pins[pins.length - 1]\">{{ t.actions }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of bodyRows(); track row.id; let rowIndex = $index) {\n @let editing = inlineDraft()?.ids?.[0] === row.id;\n @let index = rowIndex - current.pinnedRows.length;\n <tr\n [attr.data-su-row]=\"row.pinned ? null : ''\"\n [class.is-pinned-row]=\"row.pinned\"\n [class.is-last-pinned-row]=\"index === -1\"\n [style.--su-table-row-top]=\"row.pinned ? pinnedRowTops()[rowIndex] + 'px' : null\"\n [class.is-selected]=\"row.selected\"\n [class.is-editing]=\"editing\"\n [class.is-grabbed]=\"current.grabbedId === row.id\"\n [class]=\"rowClassOf(row)\"\n [class.is-dragging]=\"drag()?.id === row.id\"\n [class.is-drop-before]=\"dropSide(index) === 'before'\"\n [class.is-drop-after]=\"dropSide(index) === 'after'\"\n [style.transform]=\"dragTransform(index)\"\n (keydown)=\"editing && onEditKey($event)\"\n >\n @if (reorderable()) {\n <td class=\"su-table-handle-cell\" [suTablePin]=\"pins[0]\">\n @if (!row.pinned && !current.searching) {\n <button\n type=\"button\"\n class=\"su-table-handle\"\n [attr.data-su-handle]=\"row.id\"\n [attr.aria-label]=\"t.moveRow(row.label)\"\n [attr.aria-pressed]=\"current.grabbedId === row.id\"\n (keydown)=\"onHandleKey($event, row.id)\"\n (pointerdown)=\"onHandleDown($event, row.id, index)\"\n (pointermove)=\"onHandleMove($event)\"\n (pointerup)=\"onHandleUp()\"\n (pointercancel)=\"onHandleCancel()\"\n >\n <span class=\"su-table-grip\" aria-hidden=\"true\"></span>\n </button>\n }\n </td>\n }\n @if (selectable()) {\n <td class=\"su-table-select-cell\" [suTablePin]=\"pins[firstColumnSlot - 1]\">\n <input\n type=\"checkbox\"\n class=\"su-table-checkbox\"\n [checked]=\"row.selected\"\n [attr.aria-label]=\"t.selectRow(row.label)\"\n (change)=\"select(row.id)\"\n />\n </td>\n }\n @for (cell of row.cells; track cell.key; let cellIndex = $index) {\n @let column = current.columns[cellIndex];\n @let pin = pins[firstColumnSlot + cellIndex];\n <td\n class=\"su-table-align-{{ column.align }}\"\n [attr.role]=\"cell.key === current.rowHeaderKey ? 'rowheader' : null\"\n [class.su-table-row-header]=\"cell.key === current.rowHeaderKey\"\n [class.is-sorted]=\"column.sort !== 'none'\"\n [class.is-editable]=\"!editing && editsOnDoubleClick(cell.key)\"\n [suTablePin]=\"pin\"\n (mousedown)=\"keepTextUnselected($event, cell.key)\"\n (dblclick)=\"editCell(row, cell.key)\"\n >\n @if (editing && inlineField(cell.key); as field) {\n <su-lib-table-field\n [field]=\"field\"\n [controlId]=\"controlId(row.id, cell.key)\"\n [ariaLabel]=\"column.header\"\n [mixedLabel]=\"t.mixed\"\n (valueChange)=\"setDraft(cell.key, $event)\"\n />\n } @else {\n @if (cellTemplate(cell.key); as template) {\n <ng-container *ngTemplateOutlet=\"template; context: { $implicit: row.data, text: cell.text }\" />\n } @else {\n {{ cell.text }}\n }\n }\n </td>\n }\n @if (hasActions()) {\n <td class=\"su-table-actions-cell\" [suTablePin]=\"pins[pins.length - 1]\">\n <div class=\"su-table-actions\">\n @if (editing) {\n <button type=\"button\" class=\"su-table-button is-primary\" (click)=\"save()\">{{ t.save }}</button>\n <button type=\"button\" class=\"su-table-button\" (click)=\"cancelEdit()\">{{ t.cancel }}</button>\n } @else {\n @if (rowPinning()) {\n <button\n type=\"button\"\n class=\"su-table-button su-table-pin-button\"\n [attr.aria-pressed]=\"row.pinned\"\n [attr.aria-label]=\"t.pinRow + ', ' + row.label\"\n (click)=\"pinRow(row.id)\"\n >\n <svg suTablePinIcon width=\"12\" height=\"12\"></svg>\n {{ t.pinRow }}\n </button>\n }\n @for (action of row.actions; track action.id) {\n <button\n type=\"button\"\n class=\"su-table-button\"\n [class.is-danger]=\"action.danger\"\n [disabled]=\"action.disabled\"\n [attr.aria-label]=\"action.label + ', ' + row.label\"\n (click)=\"runAction(action, row)\"\n >\n {{ action.label }}\n </button>\n }\n }\n </div>\n </td>\n }\n </tr>\n }\n @if (current.rows.length === 0) {\n <tr>\n <td class=\"su-table-empty\" [attr.colspan]=\"columnCount()\">\n {{ current.searching ? t.noMatches(current.query) : t.empty }}\n </td>\n </tr>\n }\n </tbody>\n </table>\n</div>\n\n@if (current.pagination.pageSizes.length > 0 || current.pagination.pageSize !== 'all') {\n <su-lib-table-paginator\n [pagination]=\"current.pagination\"\n [labels]=\"t\"\n [controlId]=\"tableId + '-page-size'\"\n (pageChange)=\"setPage($event)\"\n (pageSizeChange)=\"setPageSize($event)\"\n />\n}\n\n<div class=\"su-table-visually-hidden\" role=\"status\">{{ current.announcement }}</div>\n", styles: [":host{color:var(--su-table-text-color, inherit);display:block;min-width:0;font-family:var(--su-table-font-family, inherit);font-size:var(--su-table-font-size, .95rem)}.su-table-scroll{border:var(--su-table-border, 1px solid rgba(0, 0, 0, .12));border-radius:var(--su-table-radius, 10px);overflow:auto}.su-table-grid{background:var(--su-table-background, transparent);border-collapse:separate;border-spacing:0;min-width:100%}caption{caption-side:top;color:var(--su-table-caption-color, inherit);font-size:var(--su-table-caption-font-size, inherit);font-weight:600;padding:var(--su-table-cell-padding, .6rem .75rem);text-align:start}th,td{background-image:linear-gradient(var(--su-table-cell-tint, transparent),var(--su-table-cell-tint, transparent));border-bottom:var(--su-table-row-border, 1px solid rgba(0, 0, 0, .08));padding:var(--su-table-cell-padding, .6rem .75rem);text-align:start;vertical-align:var(--su-table-cell-vertical-align, middle)}thead th{--su-table-row-tint: var(--su-table-header-background, rgb(0 0 0 / .03));border-bottom:var(--su-table-header-border, var(--su-table-row-border, 1px solid rgba(0, 0, 0, .08)));color:var(--su-table-header-color, inherit);font-size:var(--su-table-header-font-size, inherit);font-weight:var(--su-table-header-font-weight, 600);letter-spacing:var(--su-table-header-letter-spacing, normal);padding:var(--su-table-header-padding, var(--su-table-cell-padding, .6rem .75rem));text-transform:var(--su-table-header-text-transform, none);white-space:nowrap}.is-sorted{--su-table-cell-tint: var(--su-table-sorted-background, transparent)}td.is-editable:hover,th.is-editable:hover{--su-table-cell-tint: var(--su-table-editable-hover-background, color-mix(in srgb, currentColor 6%, transparent))}.su-table-row-header{font-weight:var(--su-table-row-header-weight, 600)}tbody tr:last-child>*{border-bottom:none}tbody tr{--su-table-row-tint: var(--su-table-row-background, transparent);background:var(--su-table-row-tint);color:var(--su-table-row-color, inherit)}tbody tr:nth-child(2n){--su-table-row-tint: var(--su-table-stripe-background, var(--su-table-row-background, transparent))}tbody tr.is-muted{--su-table-row-tint: var(--su-table-muted-background, transparent);color:color-mix(in srgb,currentColor var(--su-table-muted-text, 55%),transparent)}tbody tr.is-highlighted{--su-table-row-tint: var(--su-table-highlight-background, color-mix(in srgb, #f59e0b 14%, transparent))}tbody tr:hover{--su-table-row-tint: var(--su-table-hover-background, rgb(0 0 0 / .025))}tbody tr.is-selected{--su-table-row-tint: var(--su-table-selected-background, color-mix(in srgb, #2563eb 8%, transparent));color:var(--su-table-selected-color, inherit)}tbody tr.is-editing{--su-table-row-tint: var(--su-table-editing-background, color-mix(in srgb, #2563eb 5%, transparent))}tbody tr.is-pinned-row{--su-table-row-tint: var(--su-table-pinned-row-background, color-mix(in srgb, #2563eb 6%, transparent))}tbody tr.is-last-pinned-row>*{border-bottom:var(--su-table-pinned-row-border, 2px solid color-mix(in srgb, #2563eb 40%, transparent))}tbody tr.is-grabbed,tbody tr.is-dragging{--su-table-row-tint: var(--su-table-grabbed-background, color-mix(in srgb, #2563eb 14%, transparent));outline:var(--su-table-grabbed-outline, 2px solid color-mix(in srgb, #2563eb 60%, transparent));outline-offset:-2px}tbody tr.is-dragging{background:linear-gradient(var(--su-table-row-tint),var(--su-table-row-tint)),var(--su-table-dragging-background, Canvas);box-shadow:var(--su-table-dragging-shadow, 0 8px 24px rgba(0, 0, 0, .18));cursor:grabbing;position:relative;z-index:3}tbody tr.is-drop-before>*{box-shadow:inset 0 var(--su-table-drop-line-width, 2px) 0 var(--su-table-drop-line-color, #2563eb)}tbody tr.is-drop-after>*{box-shadow:inset 0 calc(-1 * var(--su-table-drop-line-width, 2px)) 0 var(--su-table-drop-line-color, #2563eb)}thead th,tbody tr.is-pinned-row>*,.is-pinned-start,.is-pinned-end{background:linear-gradient(var(--su-table-cell-tint, transparent),var(--su-table-cell-tint, transparent)),linear-gradient(var(--su-table-row-tint, transparent),var(--su-table-row-tint, transparent)),var(--su-table-pinned-background, Canvas);position:sticky;z-index:1}thead th{top:0;z-index:4}thead th.is-pinned-start,thead th.is-pinned-end{z-index:5}tbody tr.is-pinned-row>*{top:var(--su-table-row-top, 0);z-index:2}tbody tr.is-pinned-row>*.is-pinned-start,tbody tr.is-pinned-row>*.is-pinned-end{z-index:3}.is-scrolled-top:not(.has-pinned-rows) thead th,.is-scrolled-top tr.is-last-pinned-row>*{box-shadow:var(--su-table-sticky-shadow, 0 6px 8px -6px rgba(0, 0, 0, .25))}.is-pinned-edge:after{content:\"\";inset-block:0;opacity:0;pointer-events:none;position:absolute;transition:opacity .15s ease-out;width:1rem}.is-pinned-start.is-pinned-edge{border-inline-end:var(--su-table-pinned-border, 1px solid rgba(0, 0, 0, .14))}.is-pinned-end.is-pinned-edge{border-inline-start:var(--su-table-pinned-border, 1px solid rgba(0, 0, 0, .14))}.su-table-pinned-icon{margin-inline-start:.35rem;opacity:.45;vertical-align:-1px}.su-table-header-pin{background:none;border:none;border-radius:4px;color:inherit;cursor:pointer;margin-inline-start:.2rem;opacity:.3;padding:.2rem;vertical-align:middle}.su-table-header-pin:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-header-pin:hover{opacity:.7}.su-table-header-pin[aria-pressed=true]{color:var(--su-table-accent, #2563eb);opacity:1}.is-pinned-start.is-pinned-edge:after{background:linear-gradient(to right,var(--su-table-pinned-shadow, rgba(0, 0, 0, .22)),transparent);inset-inline-start:100%}.is-pinned-end.is-pinned-edge:after{background:linear-gradient(to left,var(--su-table-pinned-shadow, rgba(0, 0, 0, .22)),transparent);inset-inline-end:100%}.is-scrolled-start .is-pinned-start.is-pinned-edge:after,.has-more-end .is-pinned-end.is-pinned-edge:after{opacity:1}@media(prefers-reduced-motion:no-preference){.is-dragging-rows tbody tr:not(.is-dragging){transition:transform .15s ease-out}}td.is-editable,th.is-editable{cursor:text}.su-table-align-start{text-align:start}.su-table-align-center{text-align:center}.su-table-align-end{text-align:end}.su-table-handle-cell,.su-table-select-cell{text-align:center;width:1%}.su-table-actions-cell{text-align:end;width:1%}.su-table-actions{display:flex;gap:.35rem;justify-content:flex-end}.su-table-sort{align-items:center;background:none;border:none;border-radius:4px;color:inherit;cursor:pointer;display:inline-flex;font:inherit;letter-spacing:inherit;text-transform:inherit;gap:.35rem;margin:-.2rem -.35rem;padding:.2rem .35rem}.su-table-sort-icon{border-left:.3rem solid transparent;border-right:.3rem solid transparent;height:0;opacity:.35;width:0}.su-table-sort-icon.is-none,.su-table-sort-icon.is-ascending{border-bottom:.4rem solid currentColor}.su-table-sort-icon.is-descending{border-top:.4rem solid currentColor}.su-table-sort-icon.is-ascending,.su-table-sort-icon.is-descending{opacity:1}.su-table-handle{background:none;border:none;border-radius:4px;color:var(--su-table-handle-color, inherit);cursor:grab;display:inline-flex;padding:.35rem .3rem;touch-action:none}.su-table-handle:active{cursor:grabbing}.su-table-grip{background-image:radial-gradient(currentColor 1.2px,transparent 1.4px);background-size:6px 6px;display:block;height:18px;opacity:.6;width:12px}.su-table-button{background:var(--su-table-button-background, transparent);border:var(--su-table-button-border, 1px solid rgba(0, 0, 0, .2));border-radius:var(--su-table-button-radius, 6px);color:var(--su-table-button-color, inherit);cursor:pointer;font:inherit;font-size:.875em;padding:var(--su-table-button-padding, .3rem .7rem);white-space:nowrap}.su-table-button:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-button:disabled{cursor:not-allowed;opacity:.45}.su-table-button.is-primary{background:var(--su-table-primary-background, #111);border-color:transparent;color:var(--su-table-primary-color, #fff)}.su-table-button.is-danger{border-color:var(--su-table-danger-border, color-mix(in srgb, #b42318 35%, transparent));color:var(--su-table-danger-color, #b42318)}.su-table-button.is-quiet{border-color:transparent}.su-table-button.su-table-pin-button{align-items:center;display:inline-flex;gap:.3rem}.su-table-button.su-table-pin-button svg{opacity:.5}.su-table-button.su-table-pin-button[aria-pressed=true]{border-color:var(--su-table-accent, #2563eb);color:var(--su-table-accent, #2563eb)}.su-table-button.su-table-pin-button[aria-pressed=true] svg{opacity:1}.su-table-sort:focus-visible,.su-table-handle:focus-visible,.su-table-checkbox:focus-visible{outline:var(--su-table-focus-outline, 2px solid currentColor);outline-offset:2px}.su-table-checkbox{accent-color:var(--su-table-accent, #2563eb);height:var(--su-table-checkbox-size, 1rem);margin:0;width:var(--su-table-checkbox-size, 1rem)}.su-table-toolbar,.su-table-bulk{background:var(--su-table-panel-background, rgba(0, 0, 0, .03));border-radius:var(--su-table-radius, 10px);margin-bottom:.75rem;padding:.6rem .75rem}.su-table-toolbar{align-items:center;display:flex;flex-wrap:wrap;gap:.5rem}.su-table-toolbar-count{font-weight:600;margin-right:auto}.su-table-bulk-title{font-size:1rem;margin:0 0 .75rem}.su-table-bulk-fields{display:grid;gap:.75rem;grid-template-columns:repeat(auto-fill,minmax(12rem,1fr))}.su-table-bulk-field{display:flex;flex-direction:column;gap:.3rem}.su-table-label{font-size:.85em;font-weight:600}.su-table-bulk-actions{display:flex;gap:.5rem;margin-top:.75rem}.su-table-empty{opacity:.7;padding:1.5rem;text-align:center}.su-table-visually-hidden{clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}@media(prefers-reduced-motion:no-preference){tbody tr{transition:background-color .12s ease-out}}\n"] }]
|
|
706
|
+
}], ctorParameters: () => [], propDecorators: { columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: true }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: true }] }], caption: [{ type: i0.Input, args: [{ isSignal: true, alias: "caption", required: true }] }], showCaption: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCaption", required: false }] }], rowId: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowId", required: false }] }], actions: [{ type: i0.Input, args: [{ isSignal: true, alias: "actions", required: false }] }], selectable: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectable", required: false }] }], reorderable: [{ type: i0.Input, args: [{ isSignal: true, alias: "reorderable", required: false }] }], columnControls: [{ type: i0.Input, args: [{ isSignal: true, alias: "columnControls", required: false }] }], searchable: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchable", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], rowClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowClass", required: false }] }], editOnDoubleClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "editOnDoubleClick", required: false }] }], pageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSize", required: false }] }], pageSizes: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSizes", required: false }] }], rowPinning: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowPinning", required: false }] }], pinnedRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "pinnedRows", required: false }] }], labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: false }] }], edited: [{ type: i0.Output, args: ["edited"] }], reordered: [{ type: i0.Output, args: ["reordered"] }], action: [{ type: i0.Output, args: ["action"] }], sortChange: [{ type: i0.Output, args: ["sortChange"] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], searchChange: [{ type: i0.Output, args: ["searchChange"] }], pinnedRowsChange: [{ type: i0.Output, args: ["pinnedRowsChange"] }], columnsChange: [{ type: i0.Output, args: ["columnsChange"] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], cellTemplates: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => SuTableCellDirective), { isSignal: true }] }] } });
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Generated bundle index. Do not edit.
|
|
710
|
+
*/
|
|
711
|
+
|
|
712
|
+
export { SU_TABLE_EDIT_ACTION, SuTableCellDirective, SuTableComponent, SuTableFieldComponent, SuTablePaginatorComponent, SuTablePinDirective, SuTableToolbarComponent };
|
|
713
|
+
//# sourceMappingURL=su-labs-table.mjs.map
|