@ship-ui/core 0.22.10 → 0.22.12
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/assets/mcp/components.json +5030 -4
- package/bin/ship-fg-scanner +0 -0
- package/fesm2022/ship-ui-core-ship-list.mjs +2 -2
- package/fesm2022/ship-ui-core-ship-list.mjs.map +1 -1
- package/fesm2022/ship-ui-core-ship-sortable.mjs +238 -5
- package/fesm2022/ship-ui-core-ship-sortable.mjs.map +1 -1
- package/fesm2022/ship-ui-core-ship-table.mjs +321 -30
- package/fesm2022/ship-ui-core-ship-table.mjs.map +1 -1
- package/fesm2022/ship-ui-core-ship-tree.mjs +238 -0
- package/fesm2022/ship-ui-core-ship-tree.mjs.map +1 -0
- package/package.json +5 -1
- package/styles/index.scss +1 -1
- package/types/ship-ui-core-ship-sortable.d.ts +27 -3
- package/types/ship-ui-core-ship-table.d.ts +40 -4
- package/types/ship-ui-core-ship-tree.d.ts +67 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, Renderer2, input, HostListener, Directive, computed, output, model, viewChild, signal, DestroyRef, effect, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, Renderer2, input, HostListener, Directive, computed, output, model, contentChild, viewChild, signal, DestroyRef, effect, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
3
4
|
import { ShipProgressBar } from '@ship-ui/core/ship-progress-bar';
|
|
4
5
|
import { shipComponentClasses, observeChildren } from '@ship-ui/core';
|
|
6
|
+
import { ShipIcon } from '@ship-ui/core/ship-icon';
|
|
7
|
+
import { ShipChip } from '@ship-ui/core/ship-chip';
|
|
5
8
|
|
|
6
9
|
class ShipResize {
|
|
7
10
|
constructor() {
|
|
@@ -125,16 +128,27 @@ class ShipSort {
|
|
|
125
128
|
return currentSort === `-${thisColumn}`;
|
|
126
129
|
}, /* @ts-ignore */
|
|
127
130
|
...(ngDevMode ? [{ debugName: "sortDesc" }] : /* istanbul ignore next */ []));
|
|
131
|
+
this.ariaSort = computed(() => {
|
|
132
|
+
if (this.sortAsc())
|
|
133
|
+
return 'ascending';
|
|
134
|
+
if (this.sortDesc())
|
|
135
|
+
return 'descending';
|
|
136
|
+
return 'none';
|
|
137
|
+
}, /* @ts-ignore */
|
|
138
|
+
...(ngDevMode ? [{ debugName: "ariaSort" }] : /* istanbul ignore next */ []));
|
|
128
139
|
}
|
|
129
140
|
#table;
|
|
130
|
-
toggleSort() {
|
|
141
|
+
toggleSort(event) {
|
|
142
|
+
if (event) {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
}
|
|
131
145
|
const sortCol = this.shSort();
|
|
132
146
|
if (!sortCol)
|
|
133
147
|
return;
|
|
134
148
|
this.#table.toggleSort(sortCol);
|
|
135
149
|
}
|
|
136
150
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipSort, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
137
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.0", type: ShipSort, isStandalone: true, selector: "[shSort]", inputs: { shSort: { classPropertyName: "shSort", publicName: "shSort", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "
|
|
151
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.0", type: ShipSort, isStandalone: true, selector: "[shSort]", inputs: { shSort: { classPropertyName: "shSort", publicName: "shSort", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "columnheader" }, listeners: { "click": "shSort() ? toggleSort() : null", "keydown.enter": "shSort() ? toggleSort() : null", "keydown.space": "shSort() ? toggleSort($event) : null" }, properties: { "class.sortable": "!!shSort()", "attr.tabindex": "shSort() ? \"0\" : null", "attr.aria-sort": "shSort() ? ariaSort() : null", "class.sort-asc": "sortAsc()", "class.sort-desc": "sortDesc()" } }, ngImport: i0 }); }
|
|
138
152
|
}
|
|
139
153
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipSort, decorators: [{
|
|
140
154
|
type: Directive,
|
|
@@ -142,8 +156,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImpor
|
|
|
142
156
|
selector: '[shSort]',
|
|
143
157
|
standalone: true,
|
|
144
158
|
host: {
|
|
145
|
-
|
|
146
|
-
'
|
|
159
|
+
'role': 'columnheader',
|
|
160
|
+
'[class.sortable]': '!!shSort()',
|
|
161
|
+
'[attr.tabindex]': 'shSort() ? "0" : null',
|
|
162
|
+
'(click)': 'shSort() ? toggleSort() : null',
|
|
163
|
+
'(keydown.enter)': 'shSort() ? toggleSort() : null',
|
|
164
|
+
'(keydown.space)': 'shSort() ? toggleSort($event) : null',
|
|
165
|
+
'[attr.aria-sort]': 'shSort() ? ariaSort() : null',
|
|
147
166
|
'[class.sort-asc]': 'sortAsc()',
|
|
148
167
|
'[class.sort-desc]': 'sortDesc()',
|
|
149
168
|
},
|
|
@@ -198,13 +217,21 @@ class ShipTable {
|
|
|
198
217
|
...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
|
|
199
218
|
this.variant = input(null, /* @ts-ignore */
|
|
200
219
|
...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
220
|
+
this.ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
221
|
+
this.ariaLabelledby = input(null, { ...(ngDevMode ? { debugName: "ariaLabelledby" } : /* istanbul ignore next */ {}), alias: 'aria-labelledby' });
|
|
201
222
|
this.hostClasses = shipComponentClasses('table', {
|
|
202
223
|
color: this.color,
|
|
203
224
|
variant: this.variant,
|
|
204
225
|
});
|
|
205
|
-
this.
|
|
226
|
+
this.content = contentChild(ShipTableContent, /* @ts-ignore */
|
|
227
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
228
|
+
this.theadLocal = viewChild('theadLocal', /* @ts-ignore */
|
|
229
|
+
...(ngDevMode ? [{ debugName: "theadLocal" }] : /* istanbul ignore next */ []));
|
|
230
|
+
this.tbodyLocal = viewChild('tbodyLocal', /* @ts-ignore */
|
|
231
|
+
...(ngDevMode ? [{ debugName: "tbodyLocal" }] : /* istanbul ignore next */ []));
|
|
232
|
+
this.thead = computed(() => this.content()?.thead() || this.theadLocal(), /* @ts-ignore */
|
|
206
233
|
...(ngDevMode ? [{ debugName: "thead" }] : /* istanbul ignore next */ []));
|
|
207
|
-
this.tbody =
|
|
234
|
+
this.tbody = computed(() => this.content()?.tbody() || this.tbodyLocal(), /* @ts-ignore */
|
|
208
235
|
...(ngDevMode ? [{ debugName: "tbody" }] : /* istanbul ignore next */ []));
|
|
209
236
|
this.columns = observeChildren(this.thead, ['tr:first-child th']);
|
|
210
237
|
this.stickyHeaderHeight = signal(0, /* @ts-ignore */
|
|
@@ -294,17 +321,44 @@ class ShipTable {
|
|
|
294
321
|
const column = sortByColumn.startsWith('-') ? sortByColumn.slice(1) : sortByColumn;
|
|
295
322
|
const isDescending = sortByColumn.startsWith('-');
|
|
296
323
|
const sortedData = this.data().sort((a, b) => {
|
|
324
|
+
const colConfig = this.content()?.columns()?.find((c) => c.id === column);
|
|
325
|
+
if (colConfig?.sortPredicate) {
|
|
326
|
+
const predicateResult = colConfig.sortPredicate(a, b);
|
|
327
|
+
return isDescending ? -predicateResult : predicateResult;
|
|
328
|
+
}
|
|
297
329
|
const valueA = a[column];
|
|
298
330
|
const valueB = b[column];
|
|
299
331
|
let comparison = 0;
|
|
300
|
-
if (
|
|
301
|
-
|
|
332
|
+
if (colConfig?.type === 'date') {
|
|
333
|
+
const dateA = valueA ? new Date(valueA).getTime() : 0;
|
|
334
|
+
const dateB = valueB ? new Date(valueB).getTime() : 0;
|
|
335
|
+
comparison = dateA - dateB;
|
|
336
|
+
}
|
|
337
|
+
else if (colConfig?.type === 'number') {
|
|
338
|
+
const numA = Number(valueA) || 0;
|
|
339
|
+
const numB = Number(valueB) || 0;
|
|
340
|
+
comparison = numA - numB;
|
|
341
|
+
}
|
|
342
|
+
else if (colConfig?.type === 'boolean') {
|
|
343
|
+
const boolA = valueA ? 1 : 0;
|
|
344
|
+
const boolB = valueB ? 1 : 0;
|
|
345
|
+
comparison = boolA - boolB;
|
|
302
346
|
}
|
|
303
|
-
if (
|
|
304
|
-
|
|
347
|
+
else if (colConfig?.type === 'string' || colConfig?.type === 'badge') {
|
|
348
|
+
const strA = (valueA ?? '').toString();
|
|
349
|
+
const strB = (valueB ?? '').toString();
|
|
350
|
+
comparison = strA.localeCompare(strB, undefined, { sensitivity: 'base' });
|
|
305
351
|
}
|
|
306
|
-
|
|
307
|
-
|
|
352
|
+
else {
|
|
353
|
+
if (typeof valueA === 'number' && typeof valueB === 'number') {
|
|
354
|
+
comparison = valueA - valueB;
|
|
355
|
+
}
|
|
356
|
+
else if (valueA instanceof Date && valueB instanceof Date) {
|
|
357
|
+
comparison = valueA.getTime() - valueB.getTime();
|
|
358
|
+
}
|
|
359
|
+
else if (typeof valueA === 'string' && typeof valueB === 'string') {
|
|
360
|
+
comparison = valueA.localeCompare(valueB, undefined, { sensitivity: 'base' });
|
|
361
|
+
}
|
|
308
362
|
}
|
|
309
363
|
return isDescending ? -comparison : comparison;
|
|
310
364
|
});
|
|
@@ -367,7 +421,7 @@ class ShipTable {
|
|
|
367
421
|
this.canScrollY.set(canScrollY);
|
|
368
422
|
}
|
|
369
423
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipTable, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
370
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ShipTable, isStandalone: true, selector: "sh-table", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, sortByColumn: { classPropertyName: "sortByColumn", publicName: "sortByColumn", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dataChange: "dataChange", sortByColumn: "sortByColumnChange" }, host: { listeners: { "scroll": "onScroll()", "window:resize": "onResize($event)" }, properties: { "class": "hostClasses()", "style.grid-template-columns": "columnSizes()", "class.resizing": "resizing()", "class.can-scroll-x": "canScrollX()", "class.can-scroll-y": "canScrollY()", "class.scrolled-x": "scrollXState() >= 0", "class.scrolled-x-end": "scrollXState() === 1", "class.scrolled-y": "scrollYState() >= 0", "class.scrolled-y-end": "scrollYState() === 1" } }, viewQueries: [{ propertyName: "
|
|
424
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ShipTable, isStandalone: true, selector: "sh-table", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, sortByColumn: { classPropertyName: "sortByColumn", publicName: "sortByColumn", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dataChange: "dataChange", sortByColumn: "sortByColumnChange" }, host: { attributes: { "role": "table" }, listeners: { "scroll": "onScroll()", "window:resize": "onResize($event)" }, properties: { "attr.aria-busy": "loading()", "attr.aria-label": "ariaLabel()", "attr.aria-labelledby": "ariaLabelledby()", "class": "hostClasses()", "style.grid-template-columns": "columnSizes()", "class.resizing": "resizing()", "class.can-scroll-x": "canScrollX()", "class.can-scroll-y": "canScrollY()", "class.scrolled-x": "scrollXState() >= 0", "class.scrolled-x-end": "scrollXState() === 1", "class.scrolled-y": "scrollYState() >= 0", "class.scrolled-y-end": "scrollYState() === 1" } }, queries: [{ propertyName: "content", first: true, predicate: ShipTableContent, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "theadLocal", first: true, predicate: ["theadLocal"], descendants: true, isSignal: true }, { propertyName: "tbodyLocal", first: true, predicate: ["tbodyLocal"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
371
425
|
<div class="actionbar">
|
|
372
426
|
<ng-content select="[actionbar]:not([align-right])" />
|
|
373
427
|
<div class="actionbar-right">
|
|
@@ -379,14 +433,18 @@ class ShipTable {
|
|
|
379
433
|
<sh-progress-bar class="indeterminate primary" />
|
|
380
434
|
}
|
|
381
435
|
|
|
382
|
-
<
|
|
383
|
-
<ng-content select="th" />
|
|
384
|
-
<ng-content select="[thead]" />
|
|
385
|
-
</thead>
|
|
436
|
+
<ng-content select="sh-table-content" />
|
|
386
437
|
|
|
387
|
-
|
|
388
|
-
<
|
|
389
|
-
|
|
438
|
+
@if (!content()) {
|
|
439
|
+
<thead #theadLocal role="rowgroup">
|
|
440
|
+
<ng-content select="th" />
|
|
441
|
+
<ng-content select="[thead]" />
|
|
442
|
+
</thead>
|
|
443
|
+
|
|
444
|
+
<tbody #tbodyLocal role="rowgroup">
|
|
445
|
+
<ng-content />
|
|
446
|
+
</tbody>
|
|
447
|
+
}
|
|
390
448
|
|
|
391
449
|
@if (!loading()) {
|
|
392
450
|
<div class="no-rows">
|
|
@@ -409,14 +467,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImpor
|
|
|
409
467
|
<sh-progress-bar class="indeterminate primary" />
|
|
410
468
|
}
|
|
411
469
|
|
|
412
|
-
<
|
|
413
|
-
<ng-content select="th" />
|
|
414
|
-
<ng-content select="[thead]" />
|
|
415
|
-
</thead>
|
|
470
|
+
<ng-content select="sh-table-content" />
|
|
416
471
|
|
|
417
|
-
|
|
418
|
-
<
|
|
419
|
-
|
|
472
|
+
@if (!content()) {
|
|
473
|
+
<thead #theadLocal role="rowgroup">
|
|
474
|
+
<ng-content select="th" />
|
|
475
|
+
<ng-content select="[thead]" />
|
|
476
|
+
</thead>
|
|
477
|
+
|
|
478
|
+
<tbody #tbodyLocal role="rowgroup">
|
|
479
|
+
<ng-content />
|
|
480
|
+
</tbody>
|
|
481
|
+
}
|
|
420
482
|
|
|
421
483
|
@if (!loading()) {
|
|
422
484
|
<div class="no-rows">
|
|
@@ -424,6 +486,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImpor
|
|
|
424
486
|
</div>
|
|
425
487
|
}
|
|
426
488
|
`, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
489
|
+
'role': 'table',
|
|
490
|
+
'[attr.aria-busy]': 'loading()',
|
|
491
|
+
'[attr.aria-label]': 'ariaLabel()',
|
|
492
|
+
'[attr.aria-labelledby]': 'ariaLabelledby()',
|
|
427
493
|
'[class]': 'hostClasses()',
|
|
428
494
|
'[style.grid-template-columns]': 'columnSizes()',
|
|
429
495
|
'[class.resizing]': 'resizing()',
|
|
@@ -435,14 +501,239 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImpor
|
|
|
435
501
|
'[class.scrolled-y]': 'scrollYState() >= 0',
|
|
436
502
|
'[class.scrolled-y-end]': 'scrollYState() === 1',
|
|
437
503
|
}, styles: ["sh-table{--table-bc: var(--base-4);--table-th-bg: var(--base-2);--table-tr-bg: var(--base-1);--table-td-bg: var(--base-1);--table-th-c: var(--base-8);--table-th-f: var(--paragraph-30);--table-td-c: var(--base-8);--table-td-f: var(--paragraph-30);--table-th-p: 0 1.25rem;--table-td-p: 0 1.25rem;--table-th-mh: 3rem;--table-td-mh: 4.875rem;--table-th-g: .25rem;--table-td-g: .5rem;--table-ws: nowrap;--table-th-bw: 0;--table-td-bw: .0625rem 0 0;--table-columns: 1fr 1fr 1fr max-content;--table-sticky-bw: .0625rem}sh-table.type-a tbody>th,sh-table.type-a tbody>td,sh-table.type-a thead>th,sh-table.type-a thead>td{padding-right:0}sh-table.type-a tbody>th:first-child,sh-table.type-a tbody>td:first-child,sh-table.type-a thead>th:first-child,sh-table.type-a thead>td:first-child{padding:0}sh-table.type-b{--table-th-p: 0 .75rem;--table-td-p: 0 .75rem;--table-th-mh: 2.25rem;--table-td-mh: 3.5rem;--table-th-bw: .0625rem 0 .0625rem .0625rem;--table-td-bw: 0 0 .0625rem .0625rem;--table-sticky-bw: .0625rem}sh-table.type-b th:first-child{border-left-width:0;padding:var(--table-th-p)}sh-table.type-b td:first-child{border-left-width:0;padding:var(--table-td-p)}sh-table.type-b td.sticky,sh-table.type-b th.sticky{border-left-width:0;border-right:var(--table-sticky-bw) solid var(--table-bc)}sh-table.type-b [shStickyColumns] th,sh-table.type-b [shStickyColumns] td{border-right:var(--table-sticky-bw) solid var(--table-bc)}sh-table.type-b th.sticky-end,sh-table.type-b td.sticky-end,sh-table.type-b [shStickyColumns=end] th,sh-table.type-b [shStickyColumns=end] td{border-left:var(--table-sticky-bw) solid var(--table-bc);border-right:0}sh-table.type-b .sticky+th,sh-table.type-b .sticky+td,sh-table.type-b [shStickyColumns]+th,sh-table.type-b [shStickyColumns]+td{border-left-width:0}sh-table.type-b tr:hover td{background-color:var(--base-2)}sh-table.type-b div[table-header] tr:first-child th{border-bottom:0}sh-table.type-b tbody tr:last-child td{border-bottom-width:0}sh-table.type-b .actionbar{background-color:var(--base-2);border-width:.0625rem 0 0}sh-table{width:100%;display:grid;overflow:auto;overscroll-behavior-x:none;grid-template-columns:var(--table-columns);position:relative;container-type:inline-size}sh-table.resizing{-webkit-user-select:none;user-select:none}sh-table:has([shTableResize]) td{overflow:auto}sh-table.no-resize .sh-resizer{display:none}sh-table.no-resize td{overflow:initial}sh-table .actionbar{display:flex;align-items:center;gap:.5rem;grid-column:1/-1;position:sticky;left:0;z-index:10;background-color:var(--base-1);width:100cqw;box-sizing:border-box;padding:.5rem;border:var(--border-10);border-width:.0625rem 0;opacity:1;transition:padding .3s ease-out,border-width .3s ease-out,opacity .3s ease-out;overflow:hidden}sh-table .actionbar:empty,sh-table .actionbar:not(:has(>:not(.actionbar-right))):has(>.actionbar-right:empty){display:none}sh-table .actionbar>*{min-height:0}sh-table .actionbar .actionbar-right{display:flex;align-items:center;gap:.5rem;margin-left:auto;flex-shrink:0}sh-table .actionbar .actionbar-right:empty{display:none}sh-table tbody{position:relative}sh-table tbody:has(tr.sticky){position:sticky;top:0;z-index:1}sh-table thead{position:relative}sh-table thead:has(tr.sticky){position:sticky;top:0;z-index:2}sh-table sh-progress-bar{grid-column:1/-1;position:absolute;top:100%;transform:translateY(-50%);z-index:200}sh-table tbody,sh-table thead,sh-table tr{display:grid;grid-column:1/-1;grid-template-columns:subgrid}sh-table tr{background:var(--table-tr-bg);position:relative;z-index:0}sh-table tr.sticky{position:sticky;top:0;z-index:1}sh-table tr.sticky-end{position:sticky;bottom:0;z-index:3}sh-table tr:has(th.sticky-end) th:nth-last-child(2){padding:var(--table-th-p)}sh-table tr:has(td.sticky-end) td:nth-last-child(2){padding:var(--table-td-p)}sh-table th{display:flex;align-items:center;padding:var(--table-th-p);min-height:var(--table-th-mh);font:var(--table-th-f);line-height:1em;white-space:var(--table-ws);color:var(--table-th-c);border:0;border-color:var(--table-bc);border-style:solid;border-width:var(--table-th-bw);background:var(--table-th-bg);gap:var(--table-th-g);z-index:100}sh-table th:has(.sh-resizer){position:relative}sh-table th.sortable{--caret-color: var(--base-10);--caret-size: .375rem;cursor:pointer;-webkit-user-select:none;user-select:none}sh-table th.sortable sh-icon{opacity:.35;transition:opacity 125ms ease-in-out}sh-table th.sortable:hover sh-icon{opacity:.7}sh-table th.sortable.sort-asc sh-icon,sh-table th.sortable.sort-desc sh-icon{opacity:1}sh-table th.sortable:not(:has(sh-icon)):after{content:\"\";border:var(--caret-size) solid transparent;width:0;height:0;opacity:0;transition:opacity 125ms ease-in-out}sh-table th.sortable:not(:has(sh-icon)).sort-desc:after{opacity:1;transform:translateY(-4px);border-bottom-color:var(--caret-color)}sh-table th.sortable:not(:has(sh-icon)).sort-asc:after{opacity:1;transform:translateY(4px);border-top-color:var(--caret-color)}sh-table th .sh-resizer{width:10px;height:100%;position:absolute;top:0;right:0;cursor:col-resize}sh-table th .sh-resizer:before,sh-table th .sh-resizer:after{content:\"\";position:absolute;top:50%;transform:translateY(-50%);height:.75rem;right:.1875rem;width:.0625rem;background-color:var(--base-4)}sh-table th .sh-resizer:hover:before,sh-table th .sh-resizer:hover:after{background-color:var(--primary-8)}sh-table th .sh-resizer:before{left:.1875rem}sh-table td{display:flex;align-items:center;padding:var(--table-td-p);min-height:var(--table-td-mh);gap:var(--table-td-g);color:var(--table-td-c);font:var(--table-td-f);white-space:var(--table-ws);border-color:var(--table-bc);border-style:solid;border-width:var(--table-td-bw);background:var(--table-td-bg)}sh-table td+td.sticky-end:last-child{padding:var(--table-td-p)}sh-table th.sticky,sh-table th.sticky-end,sh-table td.sticky,sh-table td.sticky-end{position:sticky;overflow:hidden;right:auto;left:0;z-index:1;padding:var(--table-td-p)}sh-table th.sticky:first-child,sh-table th.sticky-end:first-child,sh-table td.sticky:first-child,sh-table td.sticky-end:first-child{padding:var(--table-th-p)}sh-table th.sticky-end,sh-table td.sticky-end{right:0;left:auto}sh-table th.sticky,sh-table th.sticky-end{background:var(--base-1);padding:var(--table-th-p);z-index:101}sh-table th.sticky:first-child,sh-table th.sticky-end:first-child{padding:var(--table-th-p)}sh-table [shStickyColumns]{display:grid;grid-template-columns:subgrid;position:sticky;left:0;z-index:1000;border:0;border-color:var(--table-bc);border-style:solid}sh-table [shStickyColumns] th{background-color:var(--base-1)}sh-table [shStickyColumns=end]{left:auto;right:0}sh-table .span-all{grid-column:1/-1;white-space:initial;align-items:flex-start;padding:0;border-left-width:0;position:sticky;left:0;width:100cqw;box-sizing:border-box}sh-table .no-rows{display:none;grid-column:1/-1}sh-table tbody:empty+.no-rows{display:block}\n"] }]
|
|
438
|
-
}], propDecorators: { loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], dataChange: [{ type: i0.Output, args: ["dataChange"] }], sortByColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "sortByColumn", required: false }] }, { type: i0.Output, args: ["sortByColumnChange"] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }],
|
|
504
|
+
}], propDecorators: { loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], dataChange: [{ type: i0.Output, args: ["dataChange"] }], sortByColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "sortByColumn", required: false }] }, { type: i0.Output, args: ["sortByColumnChange"] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledby: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], content: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ShipTableContent), { isSignal: true }] }], theadLocal: [{ type: i0.ViewChild, args: ['theadLocal', { isSignal: true }] }], tbodyLocal: [{ type: i0.ViewChild, args: ['tbodyLocal', { isSignal: true }] }], onResize: [{
|
|
439
505
|
type: HostListener,
|
|
440
506
|
args: ['window:resize', ['$event']]
|
|
441
507
|
}] } });
|
|
508
|
+
class ShipTableContent {
|
|
509
|
+
constructor() {
|
|
510
|
+
this.#table = inject(ShipTable);
|
|
511
|
+
this.columns = input([], /* @ts-ignore */
|
|
512
|
+
...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
513
|
+
this.data = input([], /* @ts-ignore */
|
|
514
|
+
...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
515
|
+
this.sortByColumn = this.#table.sortByColumn;
|
|
516
|
+
this.thead = viewChild('thead', /* @ts-ignore */
|
|
517
|
+
...(ngDevMode ? [{ debugName: "thead" }] : /* istanbul ignore next */ []));
|
|
518
|
+
this.tbody = viewChild('tbody', /* @ts-ignore */
|
|
519
|
+
...(ngDevMode ? [{ debugName: "tbody" }] : /* istanbul ignore next */ []));
|
|
520
|
+
}
|
|
521
|
+
#table;
|
|
522
|
+
getValue(row, col) {
|
|
523
|
+
if (!row)
|
|
524
|
+
return '';
|
|
525
|
+
const key = col.accessorKey || col.id;
|
|
526
|
+
return row[key];
|
|
527
|
+
}
|
|
528
|
+
formatDate(value) {
|
|
529
|
+
if (!value)
|
|
530
|
+
return '';
|
|
531
|
+
const date = new Date(value);
|
|
532
|
+
if (isNaN(date.getTime()))
|
|
533
|
+
return String(value);
|
|
534
|
+
return date.toLocaleDateString();
|
|
535
|
+
}
|
|
536
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipTableContent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
537
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ShipTableContent, isStandalone: true, selector: "sh-table-content", inputs: { columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: contents" }, viewQueries: [{ propertyName: "thead", first: true, predicate: ["thead"], descendants: true, isSignal: true }, { propertyName: "tbody", first: true, predicate: ["tbody"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
538
|
+
<thead #thead role="rowgroup">
|
|
539
|
+
<tr role="row">
|
|
540
|
+
@for (col of columns(); track col.id) {
|
|
541
|
+
@if (col.resizable) {
|
|
542
|
+
<th role="columnheader"
|
|
543
|
+
[id]="col.id"
|
|
544
|
+
[attr.aria-label]="col.header"
|
|
545
|
+
[shSort]="col.sortable ? col.id : undefined"
|
|
546
|
+
shResize
|
|
547
|
+
[minWidth]="col.minWidth ?? 50"
|
|
548
|
+
[maxWidth]="col.maxWidth ?? null"
|
|
549
|
+
[attr.size]="col.size || null"
|
|
550
|
+
[class.sticky]="col.sticky === 'start'"
|
|
551
|
+
[class.sticky-end]="col.sticky === 'end'">
|
|
552
|
+
{{ col.header }}
|
|
553
|
+
@if (col.sortable) {
|
|
554
|
+
@if (sortByColumn() === col.id) {
|
|
555
|
+
<sh-icon>caret-up</sh-icon>
|
|
556
|
+
} @else if (sortByColumn() === '-' + col.id) {
|
|
557
|
+
<sh-icon>caret-down</sh-icon>
|
|
558
|
+
} @else {
|
|
559
|
+
<sh-icon>arrows-down-up</sh-icon>
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
</th>
|
|
563
|
+
} @else {
|
|
564
|
+
<th role="columnheader"
|
|
565
|
+
[id]="col.id"
|
|
566
|
+
[attr.aria-label]="col.header"
|
|
567
|
+
[shSort]="col.sortable ? col.id : undefined"
|
|
568
|
+
[attr.size]="col.size || null"
|
|
569
|
+
[class.sticky]="col.sticky === 'start'"
|
|
570
|
+
[class.sticky-end]="col.sticky === 'end'">
|
|
571
|
+
{{ col.header }}
|
|
572
|
+
@if (col.sortable) {
|
|
573
|
+
@if (sortByColumn() === col.id) {
|
|
574
|
+
<sh-icon>caret-up</sh-icon>
|
|
575
|
+
} @else if (sortByColumn() === '-' + col.id) {
|
|
576
|
+
<sh-icon>caret-down</sh-icon>
|
|
577
|
+
} @else {
|
|
578
|
+
<sh-icon>arrows-down-up</sh-icon>
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
</th>
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
</tr>
|
|
585
|
+
</thead>
|
|
586
|
+
|
|
587
|
+
<tbody #tbody role="rowgroup">
|
|
588
|
+
@for (row of data(); track $index) {
|
|
589
|
+
@let rowIndex = $index;
|
|
590
|
+
<tr role="row">
|
|
591
|
+
@for (col of columns(); track col.id) {
|
|
592
|
+
<td [class.sticky]="col.sticky === 'start'"
|
|
593
|
+
[class.sticky-end]="col.sticky === 'end'"
|
|
594
|
+
[id]="col.id + '-' + rowIndex"
|
|
595
|
+
[attr.aria-labelledby]="col.id + ' ' + col.id + '-' + rowIndex"
|
|
596
|
+
[attr.role]="col.rowHeader ? 'rowheader' : 'cell'">
|
|
597
|
+
@if (col.cellTemplate) {
|
|
598
|
+
<ng-container [ngTemplateOutlet]="col.cellTemplate" [ngTemplateOutletContext]="{ $implicit: row, column: col }" />
|
|
599
|
+
} @else if (col.cell) {
|
|
600
|
+
{{ col.cell(row) }}
|
|
601
|
+
} @else if (col.format) {
|
|
602
|
+
{{ col.format(getValue(row, col), row) }}
|
|
603
|
+
} @else {
|
|
604
|
+
@switch (col.type) {
|
|
605
|
+
@case ('date') {
|
|
606
|
+
{{ formatDate(getValue(row, col)) }}
|
|
607
|
+
}
|
|
608
|
+
@case ('boolean') {
|
|
609
|
+
@if (getValue(row, col)) {
|
|
610
|
+
<sh-icon class="text-success">check</sh-icon>
|
|
611
|
+
} @else {
|
|
612
|
+
<sh-icon class="text-muted">x</sh-icon>
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
@case ('badge') {
|
|
616
|
+
<sh-chip>{{ getValue(row, col) }}</sh-chip>
|
|
617
|
+
}
|
|
618
|
+
@default {
|
|
619
|
+
{{ getValue(row, col) }}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
</td>
|
|
624
|
+
}
|
|
625
|
+
</tr>
|
|
626
|
+
}
|
|
627
|
+
</tbody>
|
|
628
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: ShipSort, selector: "[shSort]", inputs: ["shSort"] }, { kind: "directive", type: ShipResize, selector: "[shResize]", inputs: ["resizable", "minWidth", "maxWidth"] }, { kind: "component", type: ShipIcon, selector: "sh-icon", inputs: ["color", "size"] }, { kind: "component", type: ShipChip, selector: "sh-chip", inputs: ["color", "variant", "size", "sharp", "dynamic", "readonly", "noBg"] }] }); }
|
|
629
|
+
}
|
|
630
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipTableContent, decorators: [{
|
|
631
|
+
type: Component,
|
|
632
|
+
args: [{
|
|
633
|
+
selector: 'sh-table-content',
|
|
634
|
+
standalone: true,
|
|
635
|
+
imports: [NgTemplateOutlet, ShipSort, ShipResize, ShipIcon, ShipChip],
|
|
636
|
+
host: {
|
|
637
|
+
'style': 'display: contents',
|
|
638
|
+
},
|
|
639
|
+
template: `
|
|
640
|
+
<thead #thead role="rowgroup">
|
|
641
|
+
<tr role="row">
|
|
642
|
+
@for (col of columns(); track col.id) {
|
|
643
|
+
@if (col.resizable) {
|
|
644
|
+
<th role="columnheader"
|
|
645
|
+
[id]="col.id"
|
|
646
|
+
[attr.aria-label]="col.header"
|
|
647
|
+
[shSort]="col.sortable ? col.id : undefined"
|
|
648
|
+
shResize
|
|
649
|
+
[minWidth]="col.minWidth ?? 50"
|
|
650
|
+
[maxWidth]="col.maxWidth ?? null"
|
|
651
|
+
[attr.size]="col.size || null"
|
|
652
|
+
[class.sticky]="col.sticky === 'start'"
|
|
653
|
+
[class.sticky-end]="col.sticky === 'end'">
|
|
654
|
+
{{ col.header }}
|
|
655
|
+
@if (col.sortable) {
|
|
656
|
+
@if (sortByColumn() === col.id) {
|
|
657
|
+
<sh-icon>caret-up</sh-icon>
|
|
658
|
+
} @else if (sortByColumn() === '-' + col.id) {
|
|
659
|
+
<sh-icon>caret-down</sh-icon>
|
|
660
|
+
} @else {
|
|
661
|
+
<sh-icon>arrows-down-up</sh-icon>
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
</th>
|
|
665
|
+
} @else {
|
|
666
|
+
<th role="columnheader"
|
|
667
|
+
[id]="col.id"
|
|
668
|
+
[attr.aria-label]="col.header"
|
|
669
|
+
[shSort]="col.sortable ? col.id : undefined"
|
|
670
|
+
[attr.size]="col.size || null"
|
|
671
|
+
[class.sticky]="col.sticky === 'start'"
|
|
672
|
+
[class.sticky-end]="col.sticky === 'end'">
|
|
673
|
+
{{ col.header }}
|
|
674
|
+
@if (col.sortable) {
|
|
675
|
+
@if (sortByColumn() === col.id) {
|
|
676
|
+
<sh-icon>caret-up</sh-icon>
|
|
677
|
+
} @else if (sortByColumn() === '-' + col.id) {
|
|
678
|
+
<sh-icon>caret-down</sh-icon>
|
|
679
|
+
} @else {
|
|
680
|
+
<sh-icon>arrows-down-up</sh-icon>
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
</th>
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
</tr>
|
|
687
|
+
</thead>
|
|
688
|
+
|
|
689
|
+
<tbody #tbody role="rowgroup">
|
|
690
|
+
@for (row of data(); track $index) {
|
|
691
|
+
@let rowIndex = $index;
|
|
692
|
+
<tr role="row">
|
|
693
|
+
@for (col of columns(); track col.id) {
|
|
694
|
+
<td [class.sticky]="col.sticky === 'start'"
|
|
695
|
+
[class.sticky-end]="col.sticky === 'end'"
|
|
696
|
+
[id]="col.id + '-' + rowIndex"
|
|
697
|
+
[attr.aria-labelledby]="col.id + ' ' + col.id + '-' + rowIndex"
|
|
698
|
+
[attr.role]="col.rowHeader ? 'rowheader' : 'cell'">
|
|
699
|
+
@if (col.cellTemplate) {
|
|
700
|
+
<ng-container [ngTemplateOutlet]="col.cellTemplate" [ngTemplateOutletContext]="{ $implicit: row, column: col }" />
|
|
701
|
+
} @else if (col.cell) {
|
|
702
|
+
{{ col.cell(row) }}
|
|
703
|
+
} @else if (col.format) {
|
|
704
|
+
{{ col.format(getValue(row, col), row) }}
|
|
705
|
+
} @else {
|
|
706
|
+
@switch (col.type) {
|
|
707
|
+
@case ('date') {
|
|
708
|
+
{{ formatDate(getValue(row, col)) }}
|
|
709
|
+
}
|
|
710
|
+
@case ('boolean') {
|
|
711
|
+
@if (getValue(row, col)) {
|
|
712
|
+
<sh-icon class="text-success">check</sh-icon>
|
|
713
|
+
} @else {
|
|
714
|
+
<sh-icon class="text-muted">x</sh-icon>
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
@case ('badge') {
|
|
718
|
+
<sh-chip>{{ getValue(row, col) }}</sh-chip>
|
|
719
|
+
}
|
|
720
|
+
@default {
|
|
721
|
+
{{ getValue(row, col) }}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
</td>
|
|
726
|
+
}
|
|
727
|
+
</tr>
|
|
728
|
+
}
|
|
729
|
+
</tbody>
|
|
730
|
+
`
|
|
731
|
+
}]
|
|
732
|
+
}], propDecorators: { columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], thead: [{ type: i0.ViewChild, args: ['thead', { isSignal: true }] }], tbody: [{ type: i0.ViewChild, args: ['tbody', { isSignal: true }] }] } });
|
|
442
733
|
|
|
443
734
|
/**
|
|
444
735
|
* Generated bundle index. Do not edit.
|
|
445
736
|
*/
|
|
446
737
|
|
|
447
|
-
export { ShipResize, ShipSort, ShipStickyColumns, ShipTable };
|
|
738
|
+
export { ShipResize, ShipSort, ShipStickyColumns, ShipTable, ShipTableContent };
|
|
448
739
|
//# sourceMappingURL=ship-ui-core-ship-table.mjs.map
|