@4sh/ui-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +7 -0
- package/README.md +229 -0
- package/fesm2022/4sh-ui-kit-forms.mjs +501 -0
- package/fesm2022/4sh-ui-kit-forms.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-motion.mjs +155 -0
- package/fesm2022/4sh-ui-kit-motion.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-overlay.mjs +61 -0
- package/fesm2022/4sh-ui-kit-overlay.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-theming.mjs +120 -0
- package/fesm2022/4sh-ui-kit-theming.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-types.mjs +12 -0
- package/fesm2022/4sh-ui-kit-types.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-accordion.mjs +244 -0
- package/fesm2022/4sh-ui-kit-ui-accordion.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-alert.mjs +160 -0
- package/fesm2022/4sh-ui-kit-ui-alert.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-autocomplete.mjs +926 -0
- package/fesm2022/4sh-ui-kit-ui-autocomplete.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-avatar-group.mjs +34 -0
- package/fesm2022/4sh-ui-kit-ui-avatar-group.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-avatar.mjs +122 -0
- package/fesm2022/4sh-ui-kit-ui-avatar.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-badge.mjs +95 -0
- package/fesm2022/4sh-ui-kit-ui-badge.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-breadcrumb.mjs +190 -0
- package/fesm2022/4sh-ui-kit-ui-breadcrumb.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-button-split.mjs +151 -0
- package/fesm2022/4sh-ui-kit-ui-button-split.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-button.mjs +222 -0
- package/fesm2022/4sh-ui-kit-ui-button.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-card.mjs +164 -0
- package/fesm2022/4sh-ui-kit-ui-card.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-checkbox.mjs +118 -0
- package/fesm2022/4sh-ui-kit-ui-checkbox.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-chip.mjs +205 -0
- package/fesm2022/4sh-ui-kit-ui-chip.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-context-menu.mjs +219 -0
- package/fesm2022/4sh-ui-kit-ui-context-menu.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-datepicker.mjs +1508 -0
- package/fesm2022/4sh-ui-kit-ui-datepicker.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-drawer.mjs +300 -0
- package/fesm2022/4sh-ui-kit-ui-drawer.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-empty-state.mjs +148 -0
- package/fesm2022/4sh-ui-kit-ui-empty-state.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-field.mjs +102 -0
- package/fesm2022/4sh-ui-kit-ui-field.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-file-upload.mjs +568 -0
- package/fesm2022/4sh-ui-kit-ui-file-upload.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-helper.mjs +85 -0
- package/fesm2022/4sh-ui-kit-ui-helper.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-icon.mjs +98 -0
- package/fesm2022/4sh-ui-kit-ui-icon.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-image.mjs +201 -0
- package/fesm2022/4sh-ui-kit-ui-image.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-group.mjs +119 -0
- package/fesm2022/4sh-ui-kit-ui-input-group.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-mask.mjs +125 -0
- package/fesm2022/4sh-ui-kit-ui-input-mask.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-number.mjs +234 -0
- package/fesm2022/4sh-ui-kit-ui-input-number.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-otp.mjs +288 -0
- package/fesm2022/4sh-ui-kit-ui-input-otp.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-tags.mjs +679 -0
- package/fesm2022/4sh-ui-kit-ui-input-tags.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input.mjs +121 -0
- package/fesm2022/4sh-ui-kit-ui-input.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-label.mjs +61 -0
- package/fesm2022/4sh-ui-kit-ui-label.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-link.mjs +147 -0
- package/fesm2022/4sh-ui-kit-ui-link.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-menu.mjs +484 -0
- package/fesm2022/4sh-ui-kit-ui-menu.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-modal.mjs +555 -0
- package/fesm2022/4sh-ui-kit-ui-modal.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-nudger.mjs +168 -0
- package/fesm2022/4sh-ui-kit-ui-nudger.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-paginator.mjs +245 -0
- package/fesm2022/4sh-ui-kit-ui-paginator.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-popover.mjs +296 -0
- package/fesm2022/4sh-ui-kit-ui-popover.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-progress-bar.mjs +124 -0
- package/fesm2022/4sh-ui-kit-ui-progress-bar.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-radio.mjs +92 -0
- package/fesm2022/4sh-ui-kit-ui-radio.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-rating.mjs +185 -0
- package/fesm2022/4sh-ui-kit-ui-rating.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-read-only.mjs +146 -0
- package/fesm2022/4sh-ui-kit-ui-read-only.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-segment-control.mjs +386 -0
- package/fesm2022/4sh-ui-kit-ui-segment-control.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-select.mjs +868 -0
- package/fesm2022/4sh-ui-kit-ui-select.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-separator.mjs +77 -0
- package/fesm2022/4sh-ui-kit-ui-separator.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-sidebar.mjs +577 -0
- package/fesm2022/4sh-ui-kit-ui-sidebar.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-skeleton.mjs +81 -0
- package/fesm2022/4sh-ui-kit-ui-skeleton.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-slider.mjs +340 -0
- package/fesm2022/4sh-ui-kit-ui-slider.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-spinner.mjs +132 -0
- package/fesm2022/4sh-ui-kit-ui-spinner.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-stepper.mjs +389 -0
- package/fesm2022/4sh-ui-kit-ui-stepper.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-table.mjs +1406 -0
- package/fesm2022/4sh-ui-kit-ui-table.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-tabs.mjs +503 -0
- package/fesm2022/4sh-ui-kit-ui-tabs.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-tag.mjs +84 -0
- package/fesm2022/4sh-ui-kit-ui-tag.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-textarea.mjs +119 -0
- package/fesm2022/4sh-ui-kit-ui-textarea.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-toast.mjs +424 -0
- package/fesm2022/4sh-ui-kit-ui-toast.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-toggle.mjs +120 -0
- package/fesm2022/4sh-ui-kit-ui-toggle.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-tooltip.mjs +445 -0
- package/fesm2022/4sh-ui-kit-ui-tooltip.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit.mjs +16 -0
- package/fesm2022/4sh-ui-kit.mjs.map +1 -0
- package/package.json +287 -0
- package/styles/base/_base.scss +19 -0
- package/styles/base/_motion.scss +144 -0
- package/styles/base/_typography.scss +99 -0
- package/styles/generated/_tokens-breakpoint.scss +8 -0
- package/styles/generated/_tokens-metrics.scss +37 -0
- package/styles/generated/_tokens-primitives.scss +284 -0
- package/styles/generated/_tokens-responsive.scss +99 -0
- package/styles/generated/_tokens-semantics.scss +1274 -0
- package/styles/generated/_tokens-styles.scss +35 -0
- package/styles/generated/_tokens-transitions.scss +11 -0
- package/styles/generated/_tokens-typography.scss +14 -0
- package/styles/generated/_tokens.scss +10 -0
- package/styles/index.scss +25 -0
- package/styles/settings/_ui-config.scss +67 -0
- package/styles/utils/_functions.scss +67 -0
- package/styles/utils/_helpers.scss +129 -0
- package/styles/utils/_mixins.scss +186 -0
- package/styles/utils/_motion.scss +47 -0
- package/styles/utils/_overlay.scss +26 -0
- package/styles/utils.scss +15 -0
- package/styles.css +1 -0
- package/types/4sh-ui-kit-forms.d.ts +259 -0
- package/types/4sh-ui-kit-motion.d.ts +111 -0
- package/types/4sh-ui-kit-overlay.d.ts +31 -0
- package/types/4sh-ui-kit-theming.d.ts +54 -0
- package/types/4sh-ui-kit-types.d.ts +13 -0
- package/types/4sh-ui-kit-ui-accordion.d.ts +140 -0
- package/types/4sh-ui-kit-ui-alert.d.ts +89 -0
- package/types/4sh-ui-kit-ui-autocomplete.d.ts +411 -0
- package/types/4sh-ui-kit-ui-avatar-group.d.ts +17 -0
- package/types/4sh-ui-kit-ui-avatar.d.ts +55 -0
- package/types/4sh-ui-kit-ui-badge.d.ts +38 -0
- package/types/4sh-ui-kit-ui-breadcrumb.d.ts +131 -0
- package/types/4sh-ui-kit-ui-button-split.d.ts +102 -0
- package/types/4sh-ui-kit-ui-button.d.ts +91 -0
- package/types/4sh-ui-kit-ui-card.d.ts +102 -0
- package/types/4sh-ui-kit-ui-checkbox.d.ts +54 -0
- package/types/4sh-ui-kit-ui-chip.d.ts +114 -0
- package/types/4sh-ui-kit-ui-context-menu.d.ts +105 -0
- package/types/4sh-ui-kit-ui-datepicker.d.ts +539 -0
- package/types/4sh-ui-kit-ui-drawer.d.ts +147 -0
- package/types/4sh-ui-kit-ui-empty-state.d.ts +93 -0
- package/types/4sh-ui-kit-ui-field.d.ts +53 -0
- package/types/4sh-ui-kit-ui-file-upload.d.ts +268 -0
- package/types/4sh-ui-kit-ui-helper.d.ts +46 -0
- package/types/4sh-ui-kit-ui-icon.d.ts +69 -0
- package/types/4sh-ui-kit-ui-image.d.ts +88 -0
- package/types/4sh-ui-kit-ui-input-group.d.ts +54 -0
- package/types/4sh-ui-kit-ui-input-mask.d.ts +63 -0
- package/types/4sh-ui-kit-ui-input-number.d.ts +96 -0
- package/types/4sh-ui-kit-ui-input-otp.d.ts +130 -0
- package/types/4sh-ui-kit-ui-input-tags.d.ts +350 -0
- package/types/4sh-ui-kit-ui-input.d.ts +78 -0
- package/types/4sh-ui-kit-ui-label.d.ts +36 -0
- package/types/4sh-ui-kit-ui-link.d.ts +72 -0
- package/types/4sh-ui-kit-ui-menu.d.ts +235 -0
- package/types/4sh-ui-kit-ui-modal.d.ts +241 -0
- package/types/4sh-ui-kit-ui-nudger.d.ts +79 -0
- package/types/4sh-ui-kit-ui-paginator.d.ts +150 -0
- package/types/4sh-ui-kit-ui-popover.d.ts +125 -0
- package/types/4sh-ui-kit-ui-progress-bar.d.ts +82 -0
- package/types/4sh-ui-kit-ui-radio.d.ts +44 -0
- package/types/4sh-ui-kit-ui-rating.d.ts +90 -0
- package/types/4sh-ui-kit-ui-read-only.d.ts +70 -0
- package/types/4sh-ui-kit-ui-segment-control.d.ts +184 -0
- package/types/4sh-ui-kit-ui-select.d.ts +392 -0
- package/types/4sh-ui-kit-ui-separator.d.ts +43 -0
- package/types/4sh-ui-kit-ui-sidebar.d.ts +358 -0
- package/types/4sh-ui-kit-ui-skeleton.d.ts +52 -0
- package/types/4sh-ui-kit-ui-slider.d.ts +127 -0
- package/types/4sh-ui-kit-ui-spinner.d.ts +67 -0
- package/types/4sh-ui-kit-ui-stepper.d.ts +220 -0
- package/types/4sh-ui-kit-ui-table.d.ts +570 -0
- package/types/4sh-ui-kit-ui-tabs.d.ts +225 -0
- package/types/4sh-ui-kit-ui-tag.d.ts +46 -0
- package/types/4sh-ui-kit-ui-textarea.d.ts +61 -0
- package/types/4sh-ui-kit-ui-toast.d.ts +247 -0
- package/types/4sh-ui-kit-ui-toggle.d.ts +67 -0
- package/types/4sh-ui-kit-ui-tooltip.d.ts +167 -0
- package/types/4sh-ui-kit.d.ts +4 -0
|
@@ -0,0 +1,1406 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, booleanAttribute, model, numberAttribute, output, contentChild, viewChild, signal, inject, DestroyRef, linkedSignal, computed, isDevMode, effect, afterRenderEffect, afterNextRender, ViewEncapsulation, Component, Directive, ElementRef, Injector } from '@angular/core';
|
|
3
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
4
|
+
import * as i1 from '@angular/forms';
|
|
5
|
+
import { FormsModule } from '@angular/forms';
|
|
6
|
+
import { UiCheckbox } from '@4sh/ui-kit/ui-checkbox';
|
|
7
|
+
import { UiRadio } from '@4sh/ui-kit/ui-radio';
|
|
8
|
+
import { UiIcon } from '@4sh/ui-kit/ui-icon';
|
|
9
|
+
import { UiEmptyState } from '@4sh/ui-kit/ui-empty-state';
|
|
10
|
+
import { UiSpinner } from '@4sh/ui-kit/ui-spinner';
|
|
11
|
+
import { UiPaginator } from '@4sh/ui-kit/ui-paginator';
|
|
12
|
+
|
|
13
|
+
/** Reads a (possibly dotted) field path on a row object. */
|
|
14
|
+
function resolveFieldData(data, field) {
|
|
15
|
+
if (data == null)
|
|
16
|
+
return null;
|
|
17
|
+
if (!field.includes('.'))
|
|
18
|
+
return data[field];
|
|
19
|
+
let value = data;
|
|
20
|
+
for (const part of field.split('.')) {
|
|
21
|
+
if (value == null)
|
|
22
|
+
return null;
|
|
23
|
+
value = value[part];
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
/** Null-safe, locale-aware comparison shared by the sort pipeline. */
|
|
28
|
+
function compareValues(a, b) {
|
|
29
|
+
if (a == null && b == null)
|
|
30
|
+
return 0;
|
|
31
|
+
if (a == null)
|
|
32
|
+
return -1;
|
|
33
|
+
if (b == null)
|
|
34
|
+
return 1;
|
|
35
|
+
if (typeof a === 'string' && typeof b === 'string')
|
|
36
|
+
return a.localeCompare(b);
|
|
37
|
+
const na = a;
|
|
38
|
+
const nb = b;
|
|
39
|
+
return na < nb ? -1 : na > nb ? 1 : 0;
|
|
40
|
+
}
|
|
41
|
+
/** Minimum width a column can be resized down to (px). */
|
|
42
|
+
const COLUMN_MIN_WIDTH = 64;
|
|
43
|
+
let nextUid = 0;
|
|
44
|
+
/**
|
|
45
|
+
* ui-table — headless data table.
|
|
46
|
+
*
|
|
47
|
+
* The consumer owns the markup of the rows (`#header` / `#body` / `#footer`
|
|
48
|
+
* templates rendering real `<tr>/<th>/<td>`); the component owns the data
|
|
49
|
+
* pipeline (sort → pagination — unless `lazy`, where the consumer owns it and
|
|
50
|
+
* refetches on `pageChange`/`sortChange`), the selection / expansion state,
|
|
51
|
+
* the scroll shell and the paginator. Column-level behaviors are opt-in via the
|
|
52
|
+
* companion directives (`uiSortableColumn`, `uiSelectableRow`,
|
|
53
|
+
* `uiFrozenColumn`, `uiResizableColumn`, `uiRowToggler`) and sub-components
|
|
54
|
+
* (`ui-table-sort-icon`, `ui-table-checkbox`, `ui-table-header-checkbox`,
|
|
55
|
+
* `ui-table-radio`).
|
|
56
|
+
*
|
|
57
|
+
* Styles are global (`ViewEncapsulation.None`, everything nested under
|
|
58
|
+
* `.ui-table`) because the row markup is projected from the consumer and
|
|
59
|
+
* would not match emulated-encapsulation selectors.
|
|
60
|
+
*/
|
|
61
|
+
class UiTable {
|
|
62
|
+
constructor() {
|
|
63
|
+
/** Rows to display. */
|
|
64
|
+
this.value = input([], /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
66
|
+
/** Property (dotted path allowed) uniquely identifying a row — required for expansion, recommended for selection. */
|
|
67
|
+
this.dataKey = input(/* @ts-ignore */
|
|
68
|
+
...(ngDevMode ? [undefined, { debugName: "dataKey" }] : /* istanbul ignore next */ []));
|
|
69
|
+
/** Cell padding density. */
|
|
70
|
+
this.size = input('default', /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
72
|
+
/** Displays borders between cells. */
|
|
73
|
+
this.showGridlines = input(false, { ...(ngDevMode ? { debugName: "showGridlines" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
74
|
+
/** Alternates the background of even rows. */
|
|
75
|
+
this.stripedRows = input(false, { ...(ngDevMode ? { debugName: "stripedRows" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
76
|
+
/** Highlights the hovered row (implicit when a selection mode is active). */
|
|
77
|
+
this.rowHover = input(false, { ...(ngDevMode ? { debugName: "rowHover" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
78
|
+
/** Inline styles applied to the inner `<table>` (e.g. `{'min-width': '60rem'}` for horizontal scroll). */
|
|
79
|
+
this.tableStyle = input(/* @ts-ignore */
|
|
80
|
+
...(ngDevMode ? [undefined, { debugName: "tableStyle" }] : /* istanbul ignore next */ []));
|
|
81
|
+
// --- Selection --------------------------------------------------------
|
|
82
|
+
/** Row selection behavior. `single` keeps one row, `multiple` an array. */
|
|
83
|
+
this.selectionMode = input(null, /* @ts-ignore */
|
|
84
|
+
...(ngDevMode ? [{ debugName: "selectionMode" }] : /* istanbul ignore next */ []));
|
|
85
|
+
/** Selected row (single) or rows (multiple). Two-way bindable. */
|
|
86
|
+
this.selection = model(null, /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
|
|
88
|
+
/** Desktop-like selection: plain click replaces, Ctrl/Cmd+click toggles, Shift+click ranges. */
|
|
89
|
+
this.metaKeySelection = input(false, { ...(ngDevMode ? { debugName: "metaKeySelection" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
90
|
+
// --- Sort ---------------------------------------------------------------
|
|
91
|
+
/** One column at a time, or several with Ctrl/Cmd + click. */
|
|
92
|
+
this.sortMode = input('single', /* @ts-ignore */
|
|
93
|
+
...(ngDevMode ? [{ debugName: "sortMode" }] : /* istanbul ignore next */ []));
|
|
94
|
+
/** Initial sorted field (presort). */
|
|
95
|
+
this.sortField = input(/* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [undefined, { debugName: "sortField" }] : /* istanbul ignore next */ []));
|
|
97
|
+
/** Initial sort direction (1 asc, -1 desc). */
|
|
98
|
+
this.sortOrder = input(1, { ...(ngDevMode ? { debugName: "sortOrder" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
99
|
+
/** Initial multiple-sort state (presort, `sortMode="multiple"`). */
|
|
100
|
+
this.multiSortMeta = input(/* @ts-ignore */
|
|
101
|
+
...(ngDevMode ? [undefined, { debugName: "multiSortMeta" }] : /* istanbul ignore next */ []));
|
|
102
|
+
/** Direction applied when a column becomes sorted. */
|
|
103
|
+
this.defaultSortOrder = input(1, { ...(ngDevMode ? { debugName: "defaultSortOrder" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
104
|
+
/** Delegates sorting: the table stops sorting itself and emits `sortFunction`. */
|
|
105
|
+
this.customSort = input(false, { ...(ngDevMode ? { debugName: "customSort" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
106
|
+
// --- Pagination ---------------------------------------------------------
|
|
107
|
+
/** Splits rows into pages and renders the paginator bar. */
|
|
108
|
+
this.paginator = input(false, { ...(ngDevMode ? { debugName: "paginator" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
109
|
+
/** Rows per page. */
|
|
110
|
+
this.rows = input(10, { ...(ngDevMode ? { debugName: "rows" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
111
|
+
/** Index of the first displayed row. Two-way bindable (programmatic pagination). */
|
|
112
|
+
this.first = model(0, /* @ts-ignore */
|
|
113
|
+
...(ngDevMode ? [{ debugName: "first" }] : /* istanbul ignore next */ []));
|
|
114
|
+
/** Choices offered in the rows-per-page select (omit to hide it). */
|
|
115
|
+
this.rowsPerPageOptions = input(/* @ts-ignore */
|
|
116
|
+
...(ngDevMode ? [undefined, { debugName: "rowsPerPageOptions" }] : /* istanbul ignore next */ []));
|
|
117
|
+
/** Maximum number of page-number buttons. */
|
|
118
|
+
this.pageLinks = input(5, { ...(ngDevMode ? { debugName: "pageLinks" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
119
|
+
/** Total row count on the server (lazy mode) — drives the paginator; ignored otherwise. */
|
|
120
|
+
this.totalRecords = input(/* @ts-ignore */
|
|
121
|
+
...(ngDevMode ? [undefined, { debugName: "totalRecords" }] : /* istanbul ignore next */ []));
|
|
122
|
+
// --- Scroll -------------------------------------------------------------
|
|
123
|
+
/** Enables the scroll shell (sticky header inside the scrollable viewport). */
|
|
124
|
+
this.scrollable = input(false, { ...(ngDevMode ? { debugName: "scrollable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
125
|
+
/** Viewport height: a CSS size (e.g. `'400px'`) or `'flex'` to fill the flex parent. */
|
|
126
|
+
this.scrollHeight = input(/* @ts-ignore */
|
|
127
|
+
...(ngDevMode ? [undefined, { debugName: "scrollHeight" }] : /* istanbul ignore next */ []));
|
|
128
|
+
// --- Frozen rows ----------------------------------------------------------
|
|
129
|
+
/** Rows pinned above the body while scrolling. */
|
|
130
|
+
this.frozenValue = input(/* @ts-ignore */
|
|
131
|
+
...(ngDevMode ? [undefined, { debugName: "frozenValue" }] : /* istanbul ignore next */ []));
|
|
132
|
+
// --- Expansion ------------------------------------------------------------
|
|
133
|
+
/** Expanded rows, keyed by `dataKey` value. Two-way bindable. */
|
|
134
|
+
this.expandedRowKeys = model({}, /* @ts-ignore */
|
|
135
|
+
...(ngDevMode ? [{ debugName: "expandedRowKeys" }] : /* istanbul ignore next */ []));
|
|
136
|
+
// --- Column resize ----------------------------------------------------------
|
|
137
|
+
/** Enables column resizing (fit mode: the next column absorbs the delta). */
|
|
138
|
+
this.resizableColumns = input(false, { ...(ngDevMode ? { debugName: "resizableColumns" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
139
|
+
// --- Loading -------------------------------------------------------------------
|
|
140
|
+
/** Displays a mask + spinner over the table while data is being fetched. */
|
|
141
|
+
this.loading = input(false, { ...(ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
142
|
+
/** Accessible name of the loading indicator. */
|
|
143
|
+
this.loadingAriaLabel = input('Chargement des données', /* @ts-ignore */
|
|
144
|
+
...(ngDevMode ? [{ debugName: "loadingAriaLabel" }] : /* istanbul ignore next */ []));
|
|
145
|
+
// --- Empty state ------------------------------------------------------------------
|
|
146
|
+
/** Title of the default empty state (rendered with `ui-empty-state`; `#emptymessage` overrides it). */
|
|
147
|
+
this.emptyMessage = input('Aucune donnée à afficher', /* @ts-ignore */
|
|
148
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
149
|
+
/** Icon of the default empty state. */
|
|
150
|
+
this.emptyIcon = input('inbox', /* @ts-ignore */
|
|
151
|
+
...(ngDevMode ? [{ debugName: "emptyIcon" }] : /* istanbul ignore next */ []));
|
|
152
|
+
// --- Virtual scroll ------------------------------------------------------------------
|
|
153
|
+
/** Windows the rendered rows to the visible viewport (requires `scrollable` + a fixed `scrollHeight`). */
|
|
154
|
+
this.virtualScroll = input(false, { ...(ngDevMode ? { debugName: "virtualScroll" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
155
|
+
/** Fixed row height in px (also apply it to the `<tr>` of the body template). */
|
|
156
|
+
this.virtualScrollItemSize = input(50, { ...(ngDevMode ? { debugName: "virtualScrollItemSize" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
157
|
+
/**
|
|
158
|
+
* Lazy/server mode: the consumer owns sorting and pagination — `value` is the
|
|
159
|
+
* currently loaded page (with `paginator` + `totalRecords`, listen to
|
|
160
|
+
* `pageChange`/`sortChange` to refetch) or the loaded window (with
|
|
161
|
+
* `virtualScroll`, `lazyLoad` emits the rendered range). No client-side
|
|
162
|
+
* sorting or page slicing is applied.
|
|
163
|
+
*/
|
|
164
|
+
this.lazy = input(false, { ...(ngDevMode ? { debugName: "lazy" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
165
|
+
/** Emitted when a row becomes selected. */
|
|
166
|
+
this.rowSelect = output();
|
|
167
|
+
/** Emitted when a row becomes unselected. */
|
|
168
|
+
this.rowUnselect = output();
|
|
169
|
+
/** Emitted when the header select-all checkbox is toggled. */
|
|
170
|
+
this.headerCheckboxToggle = output();
|
|
171
|
+
/** Emitted instead of sorting internally when `customSort` is enabled. */
|
|
172
|
+
this.sortFunction = output();
|
|
173
|
+
/** Emitted whenever the sort state changes from a header interaction (lazy mode: refetch with it). */
|
|
174
|
+
this.sortChange = output();
|
|
175
|
+
/** Emitted on any pagination change (navigation or rows-per-page). */
|
|
176
|
+
this.pageChange = output();
|
|
177
|
+
/** Emitted when a row expands. */
|
|
178
|
+
this.rowExpand = output();
|
|
179
|
+
/** Emitted when a row collapses. */
|
|
180
|
+
this.rowCollapse = output();
|
|
181
|
+
/** Emitted after a column resize. */
|
|
182
|
+
this.colResize = output();
|
|
183
|
+
/** Emitted after a row drag & drop, with the reordered copy of `value`. */
|
|
184
|
+
this.rowReorder = output();
|
|
185
|
+
/** Emitted when the virtual-scroll window changes (lazy mode). */
|
|
186
|
+
this.lazyLoad = output();
|
|
187
|
+
// --- Templates (projected) -------------------------------------------------
|
|
188
|
+
/** @ignore Free content rendered above the table. */
|
|
189
|
+
this.captionTemplate = contentChild('caption', /* @ts-ignore */
|
|
190
|
+
...(ngDevMode ? [{ debugName: "captionTemplate" }] : /* istanbul ignore next */ []));
|
|
191
|
+
/** @ignore `<tr>` of header cells. */
|
|
192
|
+
this.headerTemplate = contentChild('header', /* @ts-ignore */
|
|
193
|
+
...(ngDevMode ? [{ debugName: "headerTemplate" }] : /* istanbul ignore next */ []));
|
|
194
|
+
/** @ignore Row template (context: row, rowIndex, even, selected, expanded, frozen). */
|
|
195
|
+
this.bodyTemplate = contentChild('body', /* @ts-ignore */
|
|
196
|
+
...(ngDevMode ? [{ debugName: "bodyTemplate" }] : /* istanbul ignore next */ []));
|
|
197
|
+
/** @ignore `<tr>` of footer cells. */
|
|
198
|
+
this.footerTemplate = contentChild('footer', /* @ts-ignore */
|
|
199
|
+
...(ngDevMode ? [{ debugName: "footerTemplate" }] : /* istanbul ignore next */ []));
|
|
200
|
+
/** @ignore Extra `<tr>` rendered under an expanded row. */
|
|
201
|
+
this.expandedRowTemplate = contentChild('expandedrow', /* @ts-ignore */
|
|
202
|
+
...(ngDevMode ? [{ debugName: "expandedRowTemplate" }] : /* istanbul ignore next */ []));
|
|
203
|
+
/** @ignore Content of the "no rows" cell. */
|
|
204
|
+
this.emptyMessageTemplate = contentChild('emptymessage', /* @ts-ignore */
|
|
205
|
+
...(ngDevMode ? [{ debugName: "emptyMessageTemplate" }] : /* istanbul ignore next */ []));
|
|
206
|
+
/** @ignore */
|
|
207
|
+
this.tableEl = viewChild('tableEl', /* @ts-ignore */
|
|
208
|
+
...(ngDevMode ? [{ debugName: "tableEl" }] : /* istanbul ignore next */ []));
|
|
209
|
+
/** @ignore */
|
|
210
|
+
this.theadEl = viewChild('theadEl', /* @ts-ignore */
|
|
211
|
+
...(ngDevMode ? [{ debugName: "theadEl" }] : /* istanbul ignore next */ []));
|
|
212
|
+
/** @ignore */
|
|
213
|
+
this.wrapperEl = viewChild('wrapperEl', /* @ts-ignore */
|
|
214
|
+
...(ngDevMode ? [{ debugName: "wrapperEl" }] : /* istanbul ignore next */ []));
|
|
215
|
+
/** @ignore Scroll position of the wrapper (drives the virtual window). */
|
|
216
|
+
this.wrapperScrollTop = signal(0, /* @ts-ignore */
|
|
217
|
+
...(ngDevMode ? [{ debugName: "wrapperScrollTop" }] : /* istanbul ignore next */ []));
|
|
218
|
+
/** @ignore Measured height of the scroll viewport. */
|
|
219
|
+
this.wrapperHeight = signal(0, /* @ts-ignore */
|
|
220
|
+
...(ngDevMode ? [{ debugName: "wrapperHeight" }] : /* istanbul ignore next */ []));
|
|
221
|
+
/** @ignore Row index currently dragged (row reorder). */
|
|
222
|
+
this.draggedRowIndex = null;
|
|
223
|
+
/** @ignore Selectable-row directives currently rendered, by host element (keyboard range selection). */
|
|
224
|
+
this.selectableRowRefs = new Map();
|
|
225
|
+
/** @ignore Shift-selection anchor (absolute row index). */
|
|
226
|
+
this.anchorRowIndex = null;
|
|
227
|
+
/** @ignore */
|
|
228
|
+
this.uid = `ui-table-${nextUid++}`;
|
|
229
|
+
/** @ignore */
|
|
230
|
+
this.destroyRef = inject(DestroyRef);
|
|
231
|
+
// --- Internal state (linked to the presort / pagination inputs) -----------
|
|
232
|
+
/** @ignore Active single sort; reset when the `sortField`/`sortOrder` inputs change. */
|
|
233
|
+
this.sortState = linkedSignal(() => {
|
|
234
|
+
const field = this.sortField();
|
|
235
|
+
return field ? { field, order: this.sortOrder() } : null;
|
|
236
|
+
}, /* @ts-ignore */
|
|
237
|
+
...(ngDevMode ? [{ debugName: "sortState" }] : /* istanbul ignore next */ []));
|
|
238
|
+
/** @ignore Active multiple sort. */
|
|
239
|
+
this.multiSortState = linkedSignal(() => this.multiSortMeta() ?? [], /* @ts-ignore */
|
|
240
|
+
...(ngDevMode ? [{ debugName: "multiSortState" }] : /* istanbul ignore next */ []));
|
|
241
|
+
/** @ignore Effective rows-per-page (user can change it via the paginator select). */
|
|
242
|
+
this.rowsState = linkedSignal(() => this.rows(), /* @ts-ignore */
|
|
243
|
+
...(ngDevMode ? [{ debugName: "rowsState" }] : /* istanbul ignore next */ []));
|
|
244
|
+
/** @ignore Number of header cells (drives the colspan of the empty row). */
|
|
245
|
+
this.columnCount = signal(1, /* @ts-ignore */
|
|
246
|
+
...(ngDevMode ? [{ debugName: "columnCount" }] : /* istanbul ignore next */ []));
|
|
247
|
+
/** @ignore Measured header height (sticky offset of frozen rows). */
|
|
248
|
+
this.frozenRowsTop = signal(0, /* @ts-ignore */
|
|
249
|
+
...(ngDevMode ? [{ debugName: "frozenRowsTop" }] : /* istanbul ignore next */ []));
|
|
250
|
+
// --- Data pipeline ---------------------------------------------------------
|
|
251
|
+
/** @ignore Sorted dataset (identity when `customSort` delegates sorting). */
|
|
252
|
+
this.processedData = computed(() => {
|
|
253
|
+
const data = this.value() ?? [];
|
|
254
|
+
// Lazy mode: the consumer owns the ordering (sortChange → server round-trip).
|
|
255
|
+
if (!data.length || this.customSort() || this.lazy())
|
|
256
|
+
return data;
|
|
257
|
+
if (this.sortMode() === 'single') {
|
|
258
|
+
const sort = this.sortState();
|
|
259
|
+
if (!sort)
|
|
260
|
+
return data;
|
|
261
|
+
return [...data].sort((a, b) => sort.order * compareValues(resolveFieldData(a, sort.field), resolveFieldData(b, sort.field)));
|
|
262
|
+
}
|
|
263
|
+
const metas = this.multiSortState();
|
|
264
|
+
if (!metas.length)
|
|
265
|
+
return data;
|
|
266
|
+
return [...data].sort((a, b) => {
|
|
267
|
+
for (const meta of metas) {
|
|
268
|
+
const result = meta.order * compareValues(resolveFieldData(a, meta.field), resolveFieldData(b, meta.field));
|
|
269
|
+
if (result !== 0)
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
return 0;
|
|
273
|
+
});
|
|
274
|
+
}, /* @ts-ignore */
|
|
275
|
+
...(ngDevMode ? [{ debugName: "processedData" }] : /* istanbul ignore next */ []));
|
|
276
|
+
/** @ignore Paginator total: server-provided in lazy mode, client count otherwise. */
|
|
277
|
+
this.effectiveTotalRecords = computed(() => this.lazy() ? (this.totalRecords() ?? this.processedData().length) : this.processedData().length, /* @ts-ignore */
|
|
278
|
+
...(ngDevMode ? [{ debugName: "effectiveTotalRecords" }] : /* istanbul ignore next */ []));
|
|
279
|
+
/** @ignore */
|
|
280
|
+
this.pageCount = computed(() => Math.max(1, Math.ceil(this.effectiveTotalRecords() / Math.max(1, this.rowsState()))), /* @ts-ignore */
|
|
281
|
+
...(ngDevMode ? [{ debugName: "pageCount" }] : /* istanbul ignore next */ []));
|
|
282
|
+
/** @ignore `first` clamped to the dataset (data may shrink under the cursor). */
|
|
283
|
+
this.clampedFirst = computed(() => {
|
|
284
|
+
const rows = Math.max(1, this.rowsState());
|
|
285
|
+
const maxFirst = (this.pageCount() - 1) * rows;
|
|
286
|
+
return Math.min(Math.max(0, this.first()), maxFirst);
|
|
287
|
+
}, /* @ts-ignore */
|
|
288
|
+
...(ngDevMode ? [{ debugName: "clampedFirst" }] : /* istanbul ignore next */ []));
|
|
289
|
+
/** @ignore Rendered window of the virtual scroll (with a small buffer). */
|
|
290
|
+
this.virtualRange = computed(() => {
|
|
291
|
+
const total = this.processedData().length;
|
|
292
|
+
if (!this.virtualScroll())
|
|
293
|
+
return { start: 0, end: total };
|
|
294
|
+
const itemSize = Math.max(1, this.virtualScrollItemSize());
|
|
295
|
+
const buffer = 5;
|
|
296
|
+
const start = Math.max(0, Math.floor(this.wrapperScrollTop() / itemSize) - buffer);
|
|
297
|
+
const visible = Math.ceil(Math.max(0, this.wrapperHeight()) / itemSize) + 2 * buffer;
|
|
298
|
+
return { start, end: Math.min(total, start + visible) };
|
|
299
|
+
}, /* @ts-ignore */
|
|
300
|
+
...(ngDevMode ? [{ debugName: "virtualRange" }] : /* istanbul ignore next */ []));
|
|
301
|
+
/** @ignore Heights of the spacer rows keeping the scrollbar honest (virtual scroll). */
|
|
302
|
+
this.virtualPadding = computed(() => {
|
|
303
|
+
if (!this.virtualScroll())
|
|
304
|
+
return { top: 0, bottom: 0 };
|
|
305
|
+
const itemSize = Math.max(1, this.virtualScrollItemSize());
|
|
306
|
+
const { start, end } = this.virtualRange();
|
|
307
|
+
return { top: start * itemSize, bottom: (this.processedData().length - end) * itemSize };
|
|
308
|
+
}, /* @ts-ignore */
|
|
309
|
+
...(ngDevMode ? [{ debugName: "virtualPadding" }] : /* istanbul ignore next */ []));
|
|
310
|
+
/** @ignore Absolute index of the first rendered row. */
|
|
311
|
+
this.pageOffset = computed(() => {
|
|
312
|
+
if (this.virtualScroll())
|
|
313
|
+
return this.virtualRange().start;
|
|
314
|
+
return this.paginator() ? this.clampedFirst() : 0;
|
|
315
|
+
}, /* @ts-ignore */
|
|
316
|
+
...(ngDevMode ? [{ debugName: "pageOffset" }] : /* istanbul ignore next */ []));
|
|
317
|
+
/** @ignore Rows actually rendered (page, virtual window, or whole dataset). */
|
|
318
|
+
this.pageData = computed(() => {
|
|
319
|
+
const data = this.processedData();
|
|
320
|
+
if (this.virtualScroll()) {
|
|
321
|
+
const { start, end } = this.virtualRange();
|
|
322
|
+
return data.slice(start, end);
|
|
323
|
+
}
|
|
324
|
+
// Lazy pagination: `value` IS the current server page — never slice it.
|
|
325
|
+
if (!this.paginator() || this.lazy())
|
|
326
|
+
return data;
|
|
327
|
+
const start = this.clampedFirst();
|
|
328
|
+
return data.slice(start, start + this.rowsState());
|
|
329
|
+
}, /* @ts-ignore */
|
|
330
|
+
...(ngDevMode ? [{ debugName: "pageData" }] : /* istanbul ignore next */ []));
|
|
331
|
+
/** @ignore */
|
|
332
|
+
this.isFlexScroll = computed(() => this.scrollable() && this.scrollHeight() === 'flex', /* @ts-ignore */
|
|
333
|
+
...(ngDevMode ? [{ debugName: "isFlexScroll" }] : /* istanbul ignore next */ []));
|
|
334
|
+
/** @ignore Viewport max-height (fixed scrollHeight mode only). */
|
|
335
|
+
this.scrollMaxHeight = computed(() => {
|
|
336
|
+
const height = this.scrollHeight();
|
|
337
|
+
return this.scrollable() && height && height !== 'flex' ? height : null;
|
|
338
|
+
}, /* @ts-ignore */
|
|
339
|
+
...(ngDevMode ? [{ debugName: "scrollMaxHeight" }] : /* istanbul ignore next */ []));
|
|
340
|
+
/** @ignore */
|
|
341
|
+
this.classes = computed(() => {
|
|
342
|
+
const c = ['ui-table'];
|
|
343
|
+
if (this.size() !== 'default')
|
|
344
|
+
c.push(`_${this.size()}`);
|
|
345
|
+
if (this.showGridlines())
|
|
346
|
+
c.push('_gridlines');
|
|
347
|
+
if (this.stripedRows())
|
|
348
|
+
c.push('_striped');
|
|
349
|
+
if (this.rowHover() || this.selectionMode())
|
|
350
|
+
c.push('_hoverable');
|
|
351
|
+
if (this.scrollable())
|
|
352
|
+
c.push('_scrollable');
|
|
353
|
+
if (this.isFlexScroll())
|
|
354
|
+
c.push('_flex-scroll');
|
|
355
|
+
if (this.resizableColumns())
|
|
356
|
+
c.push('_resizable');
|
|
357
|
+
if (this.virtualScroll())
|
|
358
|
+
c.push('_virtual');
|
|
359
|
+
return c.join(' ');
|
|
360
|
+
}, /* @ts-ignore */
|
|
361
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
362
|
+
/** @ignore Selection normalized as an array. */
|
|
363
|
+
this.selectionArray = computed(() => {
|
|
364
|
+
const sel = this.selection();
|
|
365
|
+
if (sel == null)
|
|
366
|
+
return [];
|
|
367
|
+
return Array.isArray(sel) ? sel : [sel];
|
|
368
|
+
}, /* @ts-ignore */
|
|
369
|
+
...(ngDevMode ? [{ debugName: "selectionArray" }] : /* istanbul ignore next */ []));
|
|
370
|
+
/** @ignore Every processed row is selected (header checkbox state). */
|
|
371
|
+
this.allSelected = computed(() => {
|
|
372
|
+
const data = this.processedData();
|
|
373
|
+
if (!data.length)
|
|
374
|
+
return false;
|
|
375
|
+
const selection = this.selectionArray();
|
|
376
|
+
return data.every((row) => selection.some((s) => this.rowEquals(s, row)));
|
|
377
|
+
}, /* @ts-ignore */
|
|
378
|
+
...(ngDevMode ? [{ debugName: "allSelected" }] : /* istanbul ignore next */ []));
|
|
379
|
+
/** @ignore Partial selection (header checkbox indeterminate state). */
|
|
380
|
+
this.partiallySelected = computed(() => !this.allSelected() && this.selectionArray().length > 0, /* @ts-ignore */
|
|
381
|
+
...(ngDevMode ? [{ debugName: "partiallySelected" }] : /* istanbul ignore next */ []));
|
|
382
|
+
// --- Keyboard selection helpers ---------------------------------------------------------------
|
|
383
|
+
/** @ignore Row receiving the tab stop (first selected row on the page, else the first row). */
|
|
384
|
+
this.tabbableRow = computed(() => {
|
|
385
|
+
const page = this.pageData();
|
|
386
|
+
return page.find((row) => this.isSelected(row)) ?? page[0];
|
|
387
|
+
}, /* @ts-ignore */
|
|
388
|
+
...(ngDevMode ? [{ debugName: "tabbableRow" }] : /* istanbul ignore next */ []));
|
|
389
|
+
/** @ignore Stable id base for internal controls. */
|
|
390
|
+
this.idBase = this.uid;
|
|
391
|
+
if (isDevMode()) {
|
|
392
|
+
effect(() => {
|
|
393
|
+
if (Object.keys(this.expandedRowKeys()).length && !this.dataKey()) {
|
|
394
|
+
console.warn('[ui-table] `expandedRowKeys` requires `dataKey` to identify rows.');
|
|
395
|
+
}
|
|
396
|
+
if (this.virtualScroll() && (!this.scrollable() || !this.scrollHeight() || this.scrollHeight() === 'flex')) {
|
|
397
|
+
console.warn('[ui-table] `virtualScroll` requires `scrollable` and a fixed `scrollHeight`.');
|
|
398
|
+
}
|
|
399
|
+
if (this.totalRecords() !== undefined && !this.lazy()) {
|
|
400
|
+
console.warn('[ui-table] `totalRecords` is ignored without `lazy`.');
|
|
401
|
+
}
|
|
402
|
+
if (this.lazy() && this.paginator() && this.totalRecords() === undefined) {
|
|
403
|
+
console.warn('[ui-table] `lazy` + `paginator` requires `totalRecords` (server total) for the paginator.');
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
// Lazy virtual scroll: notify the consumer whenever the window moves.
|
|
408
|
+
let lastLazyRange = null;
|
|
409
|
+
effect(() => {
|
|
410
|
+
if (!this.virtualScroll() || !this.lazy())
|
|
411
|
+
return;
|
|
412
|
+
const { start, end } = this.virtualRange();
|
|
413
|
+
if (lastLazyRange?.first === start && lastLazyRange?.last === end)
|
|
414
|
+
return;
|
|
415
|
+
lastLazyRange = { first: start, last: end };
|
|
416
|
+
this.lazyLoad.emit(lastLazyRange);
|
|
417
|
+
});
|
|
418
|
+
// Measured DOM facts: column count (empty-row colspan) + header height
|
|
419
|
+
// (sticky offset of the frozen rows). Reads happen after each render so
|
|
420
|
+
// template-driven changes (columns, size…) are picked up.
|
|
421
|
+
afterRenderEffect(() => {
|
|
422
|
+
this.value();
|
|
423
|
+
this.size();
|
|
424
|
+
this.headerTemplate();
|
|
425
|
+
this.frozenValue();
|
|
426
|
+
this.measureStickyMetrics();
|
|
427
|
+
const wrapper = this.wrapperEl()?.nativeElement;
|
|
428
|
+
if (wrapper)
|
|
429
|
+
this.wrapperHeight.set(wrapper.clientHeight);
|
|
430
|
+
});
|
|
431
|
+
// Late layout shifts (font loading, column resize…) move the sticky
|
|
432
|
+
// offsets without any signal change: re-measure when the table resizes.
|
|
433
|
+
afterNextRender(() => {
|
|
434
|
+
if (typeof ResizeObserver === 'undefined')
|
|
435
|
+
return;
|
|
436
|
+
const table = this.tableEl()?.nativeElement;
|
|
437
|
+
const wrapper = this.wrapperEl()?.nativeElement;
|
|
438
|
+
const observer = new ResizeObserver(() => {
|
|
439
|
+
this.measureStickyMetrics();
|
|
440
|
+
if (wrapper)
|
|
441
|
+
this.wrapperHeight.set(wrapper.clientHeight);
|
|
442
|
+
});
|
|
443
|
+
if (table)
|
|
444
|
+
observer.observe(table);
|
|
445
|
+
if (wrapper)
|
|
446
|
+
observer.observe(wrapper);
|
|
447
|
+
this.destroyRef.onDestroy(() => observer.disconnect());
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
/** @ignore Measures the header height + stacks the frozen-row sticky offsets. */
|
|
451
|
+
measureStickyMetrics() {
|
|
452
|
+
const thead = this.theadEl()?.nativeElement;
|
|
453
|
+
if (!thead)
|
|
454
|
+
return;
|
|
455
|
+
const cells = thead.querySelectorAll('th').length;
|
|
456
|
+
if (cells > 0)
|
|
457
|
+
this.columnCount.set(cells);
|
|
458
|
+
const headerHeight = thead.getBoundingClientRect().height;
|
|
459
|
+
this.frozenRowsTop.set(Math.floor(headerHeight));
|
|
460
|
+
const frozenBody = thead.parentElement?.querySelector('tbody._frozen-rows');
|
|
461
|
+
if (!frozenBody)
|
|
462
|
+
return;
|
|
463
|
+
// Each frozen row sticks below the previous one (heights are unaffected
|
|
464
|
+
// by the sticky shift, unlike offsetTop). Offsets accumulate fractional
|
|
465
|
+
// heights and are FLOORED: rounding up would open a sub-pixel gap where
|
|
466
|
+
// the scrolled content shows through between two stuck rows — flooring
|
|
467
|
+
// makes rows overlap the previous one by <1px instead (invisible).
|
|
468
|
+
let offset = headerHeight;
|
|
469
|
+
for (const row of Array.from(frozenBody.rows)) {
|
|
470
|
+
for (const cell of Array.from(row.cells))
|
|
471
|
+
cell.style.top = `${Math.floor(offset)}px`;
|
|
472
|
+
offset += row.getBoundingClientRect().height;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
/** @ignore Template context of a body row. */
|
|
476
|
+
rowContext(row, pageIndex, frozen = false) {
|
|
477
|
+
return {
|
|
478
|
+
$implicit: row,
|
|
479
|
+
rowIndex: frozen ? pageIndex : this.pageOffset() + pageIndex,
|
|
480
|
+
even: pageIndex % 2 === 1,
|
|
481
|
+
selected: this.isSelected(row),
|
|
482
|
+
expanded: this.isRowExpanded(row),
|
|
483
|
+
frozen,
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
// --- Sort --------------------------------------------------------------------
|
|
487
|
+
/** Current direction of a column: 1, -1, or 0 when unsorted. */
|
|
488
|
+
getSortOrder(field) {
|
|
489
|
+
if (this.sortMode() === 'single') {
|
|
490
|
+
const sort = this.sortState();
|
|
491
|
+
return sort?.field === field ? sort.order : 0;
|
|
492
|
+
}
|
|
493
|
+
return this.multiSortState().find((m) => m.field === field)?.order ?? 0;
|
|
494
|
+
}
|
|
495
|
+
/** @ignore Cycles the sort of a column (called by `uiSortableColumn`). */
|
|
496
|
+
toggleColumnSort(field, originalEvent) {
|
|
497
|
+
const defaultOrder = this.defaultSortOrder() || 1;
|
|
498
|
+
if (this.sortMode() === 'single') {
|
|
499
|
+
const current = this.sortState();
|
|
500
|
+
if (current?.field === field) {
|
|
501
|
+
// asc → desc → unsorted cycle.
|
|
502
|
+
this.sortState.set(current.order === defaultOrder ? { field, order: -defaultOrder } : null);
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
this.sortState.set({ field, order: defaultOrder });
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
const metas = [...this.multiSortState()];
|
|
510
|
+
const index = metas.findIndex((m) => m.field === field);
|
|
511
|
+
const metaKey = originalEvent instanceof MouseEvent && (originalEvent.metaKey || originalEvent.ctrlKey);
|
|
512
|
+
if (!metaKey) {
|
|
513
|
+
// Plain click: restart a fresh sort on this column alone.
|
|
514
|
+
const existing = index >= 0 ? metas[index] : undefined;
|
|
515
|
+
this.multiSortState.set([{ field, order: existing ? -existing.order : defaultOrder }]);
|
|
516
|
+
}
|
|
517
|
+
else if (index >= 0) {
|
|
518
|
+
metas[index] = { field, order: -metas[index].order };
|
|
519
|
+
this.multiSortState.set(metas);
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
this.multiSortState.set([...metas, { field, order: defaultOrder }]);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
const single = this.sortState();
|
|
526
|
+
if (this.customSort()) {
|
|
527
|
+
this.sortFunction.emit({
|
|
528
|
+
data: this.value() ?? [],
|
|
529
|
+
mode: this.sortMode(),
|
|
530
|
+
field: this.sortMode() === 'single' ? single?.field : undefined,
|
|
531
|
+
order: this.sortMode() === 'single' ? (single?.order ?? 0) : undefined,
|
|
532
|
+
multiSortMeta: this.sortMode() === 'multiple' ? this.multiSortState() : undefined,
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
this.sortChange.emit({
|
|
536
|
+
mode: this.sortMode(),
|
|
537
|
+
field: this.sortMode() === 'single' ? single?.field : undefined,
|
|
538
|
+
order: this.sortMode() === 'single' ? (single?.order ?? 0) : undefined,
|
|
539
|
+
multiSortMeta: this.sortMode() === 'multiple' ? this.multiSortState() : undefined,
|
|
540
|
+
});
|
|
541
|
+
if (this.paginator())
|
|
542
|
+
this.first.set(0);
|
|
543
|
+
}
|
|
544
|
+
// --- Selection ------------------------------------------------------------------
|
|
545
|
+
/** @ignore Row equality: by `dataKey` when provided, by reference otherwise. */
|
|
546
|
+
rowEquals(a, b) {
|
|
547
|
+
const key = this.dataKey();
|
|
548
|
+
return key ? resolveFieldData(a, key) === resolveFieldData(b, key) : a === b;
|
|
549
|
+
}
|
|
550
|
+
/** True when the row is part of the current selection. */
|
|
551
|
+
isSelected(row) {
|
|
552
|
+
return this.selectionArray().some((s) => this.rowEquals(s, row));
|
|
553
|
+
}
|
|
554
|
+
/** @ignore Row click / Enter / Space (called by `uiSelectableRow`). */
|
|
555
|
+
handleRowClick(originalEvent, data, index) {
|
|
556
|
+
const mode = this.selectionMode();
|
|
557
|
+
if (!mode)
|
|
558
|
+
return;
|
|
559
|
+
// Clicks on interactive descendants (buttons, links, form controls…)
|
|
560
|
+
// belong to those controls, not to the row selection.
|
|
561
|
+
const target = originalEvent.target;
|
|
562
|
+
if (target?.closest('button, a, input, label, select, textarea'))
|
|
563
|
+
return;
|
|
564
|
+
const pointer = originalEvent instanceof MouseEvent ? originalEvent : null;
|
|
565
|
+
if (mode === 'multiple' && pointer?.shiftKey && this.anchorRowIndex != null) {
|
|
566
|
+
this.selectRange(originalEvent, index);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const selected = this.isSelected(data);
|
|
570
|
+
const metaKey = !!pointer && (pointer.metaKey || pointer.ctrlKey);
|
|
571
|
+
if (this.metaKeySelection()) {
|
|
572
|
+
if (selected && metaKey) {
|
|
573
|
+
this.unselectRow(originalEvent, data, index, 'row');
|
|
574
|
+
}
|
|
575
|
+
else if (mode === 'single') {
|
|
576
|
+
this.selection.set(data);
|
|
577
|
+
this.rowSelect.emit({ originalEvent, data, index, type: 'row' });
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
this.selection.set(metaKey ? [...this.selectionArray(), data] : [data]);
|
|
581
|
+
this.rowSelect.emit({ originalEvent, data, index, type: 'row' });
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
else if (selected) {
|
|
585
|
+
this.unselectRow(originalEvent, data, index, 'row');
|
|
586
|
+
}
|
|
587
|
+
else if (mode === 'single') {
|
|
588
|
+
this.selection.set(data);
|
|
589
|
+
this.rowSelect.emit({ originalEvent, data, index, type: 'row' });
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
this.selection.set([...this.selectionArray(), data]);
|
|
593
|
+
this.rowSelect.emit({ originalEvent, data, index, type: 'row' });
|
|
594
|
+
}
|
|
595
|
+
this.anchorRowIndex = index;
|
|
596
|
+
}
|
|
597
|
+
/** @ignore Maps an absolute row index onto `processedData` (page-local in lazy pagination). */
|
|
598
|
+
dataIndex(index) {
|
|
599
|
+
return this.lazy() && this.paginator() && !this.virtualScroll() ? index - this.clampedFirst() : index;
|
|
600
|
+
}
|
|
601
|
+
/** @ignore Shift+click / Shift+Arrow range selection (replaces the selection). */
|
|
602
|
+
selectRange(originalEvent, index) {
|
|
603
|
+
const anchorLocal = this.anchorRowIndex == null ? null : this.dataIndex(this.anchorRowIndex);
|
|
604
|
+
// Lazy pagination: an anchor from a page no longer loaded can't seed a range — restart from this click.
|
|
605
|
+
const anchor = anchorLocal == null || anchorLocal < 0 || anchorLocal >= this.processedData().length
|
|
606
|
+
? index
|
|
607
|
+
: this.anchorRowIndex;
|
|
608
|
+
this.anchorRowIndex = anchor;
|
|
609
|
+
const start = Math.min(anchor, index);
|
|
610
|
+
const end = Math.max(anchor, index);
|
|
611
|
+
const range = this.processedData().slice(this.dataIndex(start), this.dataIndex(end) + 1);
|
|
612
|
+
this.selection.set([...range]);
|
|
613
|
+
for (const [offset, data] of range.entries()) {
|
|
614
|
+
this.rowSelect.emit({ originalEvent, data, index: start + offset, type: 'row' });
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
/** @ignore Checkbox-column toggle (called by `ui-table-checkbox`). */
|
|
618
|
+
toggleRowWithCheckbox(originalEvent, data, index) {
|
|
619
|
+
if (this.isSelected(data)) {
|
|
620
|
+
this.selection.set(this.selectionArray().filter((s) => !this.rowEquals(s, data)));
|
|
621
|
+
this.rowUnselect.emit({ originalEvent, data, index, type: 'checkbox' });
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
this.selection.set([...this.selectionArray(), data]);
|
|
625
|
+
this.rowSelect.emit({ originalEvent, data, index, type: 'checkbox' });
|
|
626
|
+
}
|
|
627
|
+
this.anchorRowIndex = index ?? null;
|
|
628
|
+
}
|
|
629
|
+
/** @ignore Header checkbox toggle: selects / clears every processed row. */
|
|
630
|
+
toggleAllRows(originalEvent, checked) {
|
|
631
|
+
this.selection.set(checked ? [...this.processedData()] : []);
|
|
632
|
+
this.headerCheckboxToggle.emit({ originalEvent, checked });
|
|
633
|
+
}
|
|
634
|
+
/** @ignore Radio-column selection (called by `ui-table-radio`). */
|
|
635
|
+
selectRowWithRadio(originalEvent, data, index) {
|
|
636
|
+
if (this.isSelected(data))
|
|
637
|
+
return;
|
|
638
|
+
this.selection.set(data);
|
|
639
|
+
this.rowSelect.emit({ originalEvent, data, index, type: 'radio' });
|
|
640
|
+
this.anchorRowIndex = index ?? null;
|
|
641
|
+
}
|
|
642
|
+
/** @ignore */
|
|
643
|
+
unselectRow(originalEvent, data, index, type) {
|
|
644
|
+
const mode = this.selectionMode();
|
|
645
|
+
if (mode === 'single')
|
|
646
|
+
this.selection.set(null);
|
|
647
|
+
else
|
|
648
|
+
this.selection.set(this.selectionArray().filter((s) => !this.rowEquals(s, data)));
|
|
649
|
+
this.rowUnselect.emit({ originalEvent, data, index, type });
|
|
650
|
+
}
|
|
651
|
+
// --- Expansion ----------------------------------------------------------------------
|
|
652
|
+
/** @ignore Key of a row for the expansion map. */
|
|
653
|
+
rowKey(data) {
|
|
654
|
+
const key = this.dataKey();
|
|
655
|
+
if (!key) {
|
|
656
|
+
if (isDevMode())
|
|
657
|
+
console.warn('[ui-table] Row expansion requires `dataKey`.');
|
|
658
|
+
return undefined;
|
|
659
|
+
}
|
|
660
|
+
return String(resolveFieldData(data, key));
|
|
661
|
+
}
|
|
662
|
+
/** True when the row is expanded. */
|
|
663
|
+
isRowExpanded(data) {
|
|
664
|
+
const key = this.dataKey();
|
|
665
|
+
if (!key)
|
|
666
|
+
return false;
|
|
667
|
+
return !!this.expandedRowKeys()[String(resolveFieldData(data, key))];
|
|
668
|
+
}
|
|
669
|
+
/** Toggles the expansion of a row (used by `uiRowToggler`). */
|
|
670
|
+
toggleRow(data, originalEvent) {
|
|
671
|
+
const key = this.rowKey(data);
|
|
672
|
+
if (key === undefined)
|
|
673
|
+
return;
|
|
674
|
+
const keys = { ...this.expandedRowKeys() };
|
|
675
|
+
if (keys[key]) {
|
|
676
|
+
delete keys[key];
|
|
677
|
+
this.expandedRowKeys.set(keys);
|
|
678
|
+
this.rowCollapse.emit({ originalEvent, data });
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
keys[key] = true;
|
|
682
|
+
this.expandedRowKeys.set(keys);
|
|
683
|
+
this.rowExpand.emit({ originalEvent, data });
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
// --- Pagination (delegated to the standalone ui-paginator) ------------------------------
|
|
687
|
+
/** @ignore Rows-per-page picked in the paginator select. */
|
|
688
|
+
onPaginatorRows(rows) {
|
|
689
|
+
this.rowsState.set(rows);
|
|
690
|
+
}
|
|
691
|
+
// --- Row reorder (drag & drop) -----------------------------------------------------------
|
|
692
|
+
/** @ignore Drop of a dragged row: emits the reordered copy of `value`. */
|
|
693
|
+
dropRow(dropIndex) {
|
|
694
|
+
const dragIndex = this.draggedRowIndex;
|
|
695
|
+
this.draggedRowIndex = null;
|
|
696
|
+
if (dragIndex == null || dragIndex === dropIndex)
|
|
697
|
+
return;
|
|
698
|
+
const value = [...(this.value() ?? [])];
|
|
699
|
+
if (dragIndex < 0 || dragIndex >= value.length || dropIndex < 0 || dropIndex >= value.length)
|
|
700
|
+
return;
|
|
701
|
+
const [moved] = value.splice(dragIndex, 1);
|
|
702
|
+
value.splice(dropIndex, 0, moved);
|
|
703
|
+
this.rowReorder.emit({ dragIndex, dropIndex, value });
|
|
704
|
+
}
|
|
705
|
+
// --- Virtual scroll -------------------------------------------------------------------------
|
|
706
|
+
/** @ignore */
|
|
707
|
+
onWrapperScroll() {
|
|
708
|
+
if (!this.virtualScroll())
|
|
709
|
+
return;
|
|
710
|
+
const wrapper = this.wrapperEl()?.nativeElement;
|
|
711
|
+
if (wrapper)
|
|
712
|
+
this.wrapperScrollTop.set(wrapper.scrollTop);
|
|
713
|
+
}
|
|
714
|
+
/** @ignore Roving tabindex: only one row is tabbable (WAI-ARIA grid-like navigation). */
|
|
715
|
+
isRowTabbable(data) {
|
|
716
|
+
const tabbable = this.tabbableRow();
|
|
717
|
+
return tabbable !== undefined && this.rowEquals(tabbable, data);
|
|
718
|
+
}
|
|
719
|
+
/** @ignore Selects every processed row (Ctrl+A). */
|
|
720
|
+
selectAllRows(originalEvent) {
|
|
721
|
+
if (this.selectionMode() !== 'multiple')
|
|
722
|
+
return;
|
|
723
|
+
this.selection.set([...this.processedData()]);
|
|
724
|
+
this.headerCheckboxToggle.emit({ originalEvent, checked: true });
|
|
725
|
+
}
|
|
726
|
+
/** @ignore Selects from a row to the first / last processed row (Ctrl+Shift+Home / End). */
|
|
727
|
+
selectRangeToEdge(index, edge) {
|
|
728
|
+
if (this.selectionMode() !== 'multiple')
|
|
729
|
+
return;
|
|
730
|
+
const data = this.processedData();
|
|
731
|
+
const localIndex = this.dataIndex(index);
|
|
732
|
+
const range = edge === 'start' ? data.slice(0, localIndex + 1) : data.slice(localIndex);
|
|
733
|
+
this.selection.set([...range]);
|
|
734
|
+
this.anchorRowIndex = index;
|
|
735
|
+
}
|
|
736
|
+
// --- Column resize (fit mode) -------------------------------------------------------------
|
|
737
|
+
/** @ignore Freezes every column width in px so the drag only moves the shared edge. */
|
|
738
|
+
lockColumnWidths() {
|
|
739
|
+
const table = this.tableEl()?.nativeElement;
|
|
740
|
+
if (!table)
|
|
741
|
+
return;
|
|
742
|
+
const headerRow = table.querySelector('thead tr');
|
|
743
|
+
if (!headerRow)
|
|
744
|
+
return;
|
|
745
|
+
// Measure everything BEFORE mutating: setting a width relayouts the table.
|
|
746
|
+
const tableWidth = table.getBoundingClientRect().width;
|
|
747
|
+
const cells = Array.from(headerRow.children);
|
|
748
|
+
const widths = cells.map((cell) => cell.getBoundingClientRect().width);
|
|
749
|
+
cells.forEach((cell, i) => (cell.style.width = `${widths[i]}px`));
|
|
750
|
+
table.style.tableLayout = 'fixed';
|
|
751
|
+
table.style.width = `${tableWidth}px`;
|
|
752
|
+
}
|
|
753
|
+
/** @ignore Fit-mode resize: the delta moves the edge between `cell` and its next sibling. */
|
|
754
|
+
resizeColumnFit(cell, startWidth, nextStartWidth, delta) {
|
|
755
|
+
const next = cell.nextElementSibling;
|
|
756
|
+
if (!next)
|
|
757
|
+
return false;
|
|
758
|
+
const width = startWidth + delta;
|
|
759
|
+
const nextWidth = nextStartWidth - delta;
|
|
760
|
+
if (width < COLUMN_MIN_WIDTH || nextWidth < COLUMN_MIN_WIDTH)
|
|
761
|
+
return false;
|
|
762
|
+
cell.style.width = `${width}px`;
|
|
763
|
+
next.style.width = `${nextWidth}px`;
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
/** @ignore Forwarded from the resize directive once the drag ends. */
|
|
767
|
+
notifyColResize(element, delta) {
|
|
768
|
+
this.colResize.emit({ element, delta });
|
|
769
|
+
}
|
|
770
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTable, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
771
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: UiTable, isStandalone: true, selector: "ui-table", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, showGridlines: { classPropertyName: "showGridlines", publicName: "showGridlines", isSignal: true, isRequired: false, transformFunction: null }, stripedRows: { classPropertyName: "stripedRows", publicName: "stripedRows", isSignal: true, isRequired: false, transformFunction: null }, rowHover: { classPropertyName: "rowHover", publicName: "rowHover", isSignal: true, isRequired: false, transformFunction: null }, tableStyle: { classPropertyName: "tableStyle", publicName: "tableStyle", isSignal: true, isRequired: false, transformFunction: null }, selectionMode: { classPropertyName: "selectionMode", publicName: "selectionMode", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, metaKeySelection: { classPropertyName: "metaKeySelection", publicName: "metaKeySelection", isSignal: true, isRequired: false, transformFunction: null }, sortMode: { classPropertyName: "sortMode", publicName: "sortMode", isSignal: true, isRequired: false, transformFunction: null }, sortField: { classPropertyName: "sortField", publicName: "sortField", isSignal: true, isRequired: false, transformFunction: null }, sortOrder: { classPropertyName: "sortOrder", publicName: "sortOrder", isSignal: true, isRequired: false, transformFunction: null }, multiSortMeta: { classPropertyName: "multiSortMeta", publicName: "multiSortMeta", isSignal: true, isRequired: false, transformFunction: null }, defaultSortOrder: { classPropertyName: "defaultSortOrder", publicName: "defaultSortOrder", isSignal: true, isRequired: false, transformFunction: null }, customSort: { classPropertyName: "customSort", publicName: "customSort", isSignal: true, isRequired: false, transformFunction: null }, paginator: { classPropertyName: "paginator", publicName: "paginator", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null }, first: { classPropertyName: "first", publicName: "first", isSignal: true, isRequired: false, transformFunction: null }, rowsPerPageOptions: { classPropertyName: "rowsPerPageOptions", publicName: "rowsPerPageOptions", isSignal: true, isRequired: false, transformFunction: null }, pageLinks: { classPropertyName: "pageLinks", publicName: "pageLinks", isSignal: true, isRequired: false, transformFunction: null }, totalRecords: { classPropertyName: "totalRecords", publicName: "totalRecords", isSignal: true, isRequired: false, transformFunction: null }, scrollable: { classPropertyName: "scrollable", publicName: "scrollable", isSignal: true, isRequired: false, transformFunction: null }, scrollHeight: { classPropertyName: "scrollHeight", publicName: "scrollHeight", isSignal: true, isRequired: false, transformFunction: null }, frozenValue: { classPropertyName: "frozenValue", publicName: "frozenValue", isSignal: true, isRequired: false, transformFunction: null }, expandedRowKeys: { classPropertyName: "expandedRowKeys", publicName: "expandedRowKeys", isSignal: true, isRequired: false, transformFunction: null }, resizableColumns: { classPropertyName: "resizableColumns", publicName: "resizableColumns", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, loadingAriaLabel: { classPropertyName: "loadingAriaLabel", publicName: "loadingAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, emptyIcon: { classPropertyName: "emptyIcon", publicName: "emptyIcon", isSignal: true, isRequired: false, transformFunction: null }, virtualScroll: { classPropertyName: "virtualScroll", publicName: "virtualScroll", isSignal: true, isRequired: false, transformFunction: null }, virtualScrollItemSize: { classPropertyName: "virtualScrollItemSize", publicName: "virtualScrollItemSize", isSignal: true, isRequired: false, transformFunction: null }, lazy: { classPropertyName: "lazy", publicName: "lazy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selection: "selectionChange", first: "firstChange", expandedRowKeys: "expandedRowKeysChange", rowSelect: "rowSelect", rowUnselect: "rowUnselect", headerCheckboxToggle: "headerCheckboxToggle", sortFunction: "sortFunction", sortChange: "sortChange", pageChange: "pageChange", rowExpand: "rowExpand", rowCollapse: "rowCollapse", colResize: "colResize", rowReorder: "rowReorder", lazyLoad: "lazyLoad" }, queries: [{ propertyName: "captionTemplate", first: true, predicate: ["caption"], descendants: true, isSignal: true }, { propertyName: "headerTemplate", first: true, predicate: ["header"], descendants: true, isSignal: true }, { propertyName: "bodyTemplate", first: true, predicate: ["body"], descendants: true, isSignal: true }, { propertyName: "footerTemplate", first: true, predicate: ["footer"], descendants: true, isSignal: true }, { propertyName: "expandedRowTemplate", first: true, predicate: ["expandedrow"], descendants: true, isSignal: true }, { propertyName: "emptyMessageTemplate", first: true, predicate: ["emptymessage"], descendants: true, isSignal: true }], viewQueries: [{ propertyName: "tableEl", first: true, predicate: ["tableEl"], descendants: true, isSignal: true }, { propertyName: "theadEl", first: true, predicate: ["theadEl"], descendants: true, isSignal: true }, { propertyName: "wrapperEl", first: true, predicate: ["wrapperEl"], descendants: true, isSignal: true }], ngImport: i0, template: "<div [class]=\"classes()\" [attr.aria-busy]=\"loading() ? 'true' : null\">\n @if (captionTemplate(); as caption) {\n <div class=\"ui-table-caption\">\n <ng-container [ngTemplateOutlet]=\"caption\" />\n </div>\n }\n\n <div class=\"ui-table-container\">\n <div\n #wrapperEl\n class=\"ui-table-wrapper\"\n [style.max-height]=\"scrollMaxHeight()\"\n [style.--ui-table-frozen-top.px]=\"frozenRowsTop()\"\n (scroll)=\"onWrapperScroll()\"\n >\n <table #tableEl class=\"ui-table-table\" [style]=\"tableStyle() ?? null\">\n @if (headerTemplate(); as header) {\n <thead #theadEl class=\"ui-table-thead\">\n <ng-container [ngTemplateOutlet]=\"header\" />\n </thead>\n }\n\n @if (!loading() && frozenValue()?.length) {\n <tbody class=\"ui-table-tbody _frozen-rows\">\n @for (row of frozenValue(); track $index) {\n @if (bodyTemplate(); as body) {\n <ng-container [ngTemplateOutlet]=\"body\" [ngTemplateOutletContext]=\"rowContext(row, $index, true)\" />\n }\n }\n </tbody>\n }\n\n <tbody class=\"ui-table-tbody\">\n @if (loading()) {\n <tr class=\"ui-table-loading-row\">\n <td class=\"ui-table-loading-cell\" [attr.colspan]=\"columnCount()\">\n <ui-spinner [ariaLabel]=\"loadingAriaLabel()\" />\n </td>\n </tr>\n } @else {\n @if (virtualScroll() && virtualPadding().top > 0) {\n <tr class=\"ui-table-virtual-spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"columnCount()\" [style.height.px]=\"virtualPadding().top\"></td>\n </tr>\n }\n\n @for (row of pageData(); track $index) {\n @if (bodyTemplate(); as body) {\n <ng-container [ngTemplateOutlet]=\"body\" [ngTemplateOutletContext]=\"rowContext(row, $index)\" />\n }\n @if (expandedRowTemplate(); as expansion) {\n @if (isRowExpanded(row)) {\n <ng-container [ngTemplateOutlet]=\"expansion\" [ngTemplateOutletContext]=\"rowContext(row, $index)\" />\n }\n }\n } @empty {\n <tr class=\"ui-table-empty-row\">\n <td class=\"ui-table-empty-cell\" [attr.colspan]=\"columnCount()\">\n @if (emptyMessageTemplate(); as empty) {\n <ng-container [ngTemplateOutlet]=\"empty\" />\n } @else {\n <ui-empty-state size=\"small\" [icon]=\"emptyIcon()\" [title]=\"emptyMessage()\" />\n }\n </td>\n </tr>\n }\n\n @if (virtualScroll() && virtualPadding().bottom > 0) {\n <tr class=\"ui-table-virtual-spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"columnCount()\" [style.height.px]=\"virtualPadding().bottom\"></td>\n </tr>\n }\n }\n </tbody>\n\n @if (footerTemplate(); as footer) {\n <tfoot class=\"ui-table-tfoot\">\n <ng-container [ngTemplateOutlet]=\"footer\" />\n </tfoot>\n }\n </table>\n </div>\n </div>\n\n @if (paginator()) {\n <ui-paginator\n [totalRecords]=\"effectiveTotalRecords()\"\n [rows]=\"rowsState()\"\n (rowsChange)=\"onPaginatorRows($event)\"\n [first]=\"first()\"\n (firstChange)=\"first.set($event)\"\n [pageLinks]=\"pageLinks()\"\n [rowsPerPageOptions]=\"rowsPerPageOptions()\"\n ariaLabel=\"Pagination du tableau\"\n (pageChange)=\"pageChange.emit($event)\"\n />\n }\n</div>\n", styles: ["ui-table{display:block;min-width:0}ui-table:has(>.ui-table._flex-scroll){display:flex;flex-direction:column;flex:1 1 auto;min-height:0}.ui-table{font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);color:var(--table-body-content-odd)}.ui-table-container{min-width:0}.ui-table-wrapper{min-width:0;overflow-x:auto}.ui-table-loading-cell{text-align:center}.ui-table-loading-cell ui-spinner{display:flex;justify-content:center;padding:var(--units-3xl) 0}.ui-table-table{width:100%;border-collapse:separate;border-spacing:0}.ui-table-table th,.ui-table-table td{box-sizing:border-box}.ui-table-caption{padding:var(--units-md) var(--units-default);font-weight:var(--weight-bold)}.ui-table-thead th{padding:var(--units-md) var(--units-default);background-color:var(--table-head-surface-default);color:var(--table-head-content-default);border-bottom:var(--stroke-sm) solid var(--table-head-stroke-default);font-size:var(--size-typography-text-md);font-weight:var(--weight-bold);text-align:left;white-space:nowrap}.ui-table-tbody td{padding:var(--units-default);background-color:var(--table-body-surface-odd);color:var(--table-body-content-odd);border-bottom:var(--stroke-sm) solid var(--table-body-stroke-odd);transition:background-color var(--transition-default) var(--transition-easeinout),color var(--transition-default) var(--transition-easeinout)}.ui-table-tbody tr:last-child td{border-bottom-color:transparent}.ui-table._striped .ui-table-tbody tr:nth-child(2n) td{background-color:var(--table-body-surface-even);color:var(--table-body-content-even);border-bottom-color:var(--table-body-stroke-even)}.ui-table._hoverable .ui-table-tbody tr:hover td{background-color:var(--table-body-surface-hover);color:var(--table-body-content-hover)}.ui-table-tbody tr._selected td,.ui-table._striped .ui-table-tbody tr._selected td{background-color:var(--informative-highlightlow-surface-default);color:var(--informative-highlightlow-content-default);border-bottom-color:var(--informative-highlightlow-stroke-default)}.ui-table._hoverable .ui-table-tbody tr._selected:hover td{background-color:var(--informative-highlightlow-surface-hover);color:var(--informative-highlightlow-content-hover)}.ui-table-selectable-row{cursor:pointer}.ui-table-selectable-row:focus-visible{outline:var(--units-2xs) solid var(--global-border-focus);outline-offset:calc(-1 * var(--units-2xs))}.ui-table-reorderable-row{cursor:grab}.ui-table-reorderable-row._drop-above td{box-shadow:inset 0 var(--stroke-lg) 0 0 var(--global-border-focus)}.ui-table-reorderable-row._drop-below td{box-shadow:inset 0 calc(-1 * var(--stroke-lg)) 0 0 var(--global-border-focus)}.ui-table-empty-cell{text-align:center}.ui-table-empty-cell ui-empty-state{display:flex;justify-content:center;padding:var(--units-xl) 0}.ui-table-virtual-spacer td{padding:0;border:none;background:none}.ui-table-tfoot td{padding:var(--units-md) var(--units-default);background-color:var(--table-footer-surface-default);color:var(--table-footer-content-default);border-top:var(--stroke-sm) solid var(--table-footer-stroke-default);font-weight:var(--weight-bold);text-align:left}.ui-table._small .ui-table-tbody td,.ui-table._small .ui-table-thead th,.ui-table._small .ui-table-tfoot td{padding:var(--units-sm) var(--units-md)}.ui-table._large .ui-table-tbody td{padding:var(--units-xl) var(--units-default)}.ui-table._large .ui-table-thead th,.ui-table._large .ui-table-tfoot td{padding:var(--units-default)}.ui-table._gridlines .ui-table-table{border:var(--stroke-sm) solid var(--table-body-stroke-odd)}.ui-table._gridlines .ui-table-thead th,.ui-table._gridlines .ui-table-tbody td,.ui-table._gridlines .ui-table-tfoot td{border-right:var(--stroke-sm) solid var(--table-body-stroke-odd)}.ui-table._gridlines .ui-table-thead th:last-child,.ui-table._gridlines .ui-table-tbody td:last-child,.ui-table._gridlines .ui-table-tfoot td:last-child{border-right:none}.ui-table-sortable-column{cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--transition-default) var(--transition-easeinout),color var(--transition-default) var(--transition-easeinout)}.ui-table-sortable-column:hover{background-color:var(--table-head-surface-hover);color:var(--table-head-content-hover)}.ui-table-sortable-column:focus-visible{outline:none;box-shadow:inset 0 0 0 var(--units-2xs) var(--global-border-focus)}.ui-table-sortable-column .ui-table-sort-icon{margin-left:var(--units-xs);vertical-align:middle}.ui-table._scrollable .ui-table-wrapper{overflow:auto}.ui-table._scrollable .ui-table-thead th{position:sticky;top:0;z-index:2}.ui-table._scrollable .ui-table-thead th._frozen-left,.ui-table._scrollable .ui-table-thead th._frozen-right{z-index:3}.ui-table._scrollable .ui-table-tfoot td{position:sticky;bottom:0;z-index:2}.ui-table._scrollable .ui-table-tbody._frozen-rows td{position:sticky;top:var(--ui-table-frozen-top, 0);z-index:1;font-weight:var(--weight-bold)}.ui-table._flex-scroll{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}.ui-table._flex-scroll .ui-table-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0}.ui-table._flex-scroll .ui-table-wrapper{flex:1 1 0;min-height:0}.ui-table._virtual .ui-table-wrapper{overflow-anchor:none}.ui-table .ui-table-table th._frozen-left,.ui-table .ui-table-table th._frozen-right,.ui-table .ui-table-table td._frozen-left,.ui-table .ui-table-table td._frozen-right{position:sticky;z-index:1}.ui-table-thead th._frozen-left,.ui-table-thead th._frozen-right{z-index:3}.ui-table._resizable .ui-table-thead th{position:relative;overflow:hidden}.ui-table-column-resizer{position:absolute;top:0;right:0;width:var(--units-sm);height:100%;cursor:col-resize;touch-action:none}.ui-table-column-resizer:hover{border-right:var(--stroke-default) solid var(--global-border-default-hover)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: UiPaginator, selector: "ui-paginator", inputs: ["totalRecords", "rows", "first", "pageLinks", "ellipsis", "boundaryCount", "rowsPerPageOptions", "showFirstLastIcon", "showPageLinks", "showCurrentPageReport", "currentPageReportTemplate", "disabled", "ariaLabel", "pageAriaLabel", "firstPageAriaLabel", "prevPageAriaLabel", "nextPageAriaLabel", "lastPageAriaLabel", "rowsPerPageAriaLabel"], outputs: ["rowsChange", "firstChange", "pageChange"] }, { kind: "component", type: UiEmptyState, selector: "ui-empty-state", inputs: ["title", "description", "icon", "iconType", "size", "showMedia", "ariaLabel", "ariaLabelledBy"] }, { kind: "component", type: UiSpinner, selector: "ui-spinner", inputs: ["size", "orientation", "label", "ariaLabel", "spinnerTemplate", "image", "imageAlt", "icon", "strokeWidth", "fill", "animationDuration", "delay"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
|
772
|
+
}
|
|
773
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTable, decorators: [{
|
|
774
|
+
type: Component,
|
|
775
|
+
args: [{ selector: 'ui-table', imports: [NgTemplateOutlet, UiPaginator, UiEmptyState, UiSpinner], encapsulation: ViewEncapsulation.None, template: "<div [class]=\"classes()\" [attr.aria-busy]=\"loading() ? 'true' : null\">\n @if (captionTemplate(); as caption) {\n <div class=\"ui-table-caption\">\n <ng-container [ngTemplateOutlet]=\"caption\" />\n </div>\n }\n\n <div class=\"ui-table-container\">\n <div\n #wrapperEl\n class=\"ui-table-wrapper\"\n [style.max-height]=\"scrollMaxHeight()\"\n [style.--ui-table-frozen-top.px]=\"frozenRowsTop()\"\n (scroll)=\"onWrapperScroll()\"\n >\n <table #tableEl class=\"ui-table-table\" [style]=\"tableStyle() ?? null\">\n @if (headerTemplate(); as header) {\n <thead #theadEl class=\"ui-table-thead\">\n <ng-container [ngTemplateOutlet]=\"header\" />\n </thead>\n }\n\n @if (!loading() && frozenValue()?.length) {\n <tbody class=\"ui-table-tbody _frozen-rows\">\n @for (row of frozenValue(); track $index) {\n @if (bodyTemplate(); as body) {\n <ng-container [ngTemplateOutlet]=\"body\" [ngTemplateOutletContext]=\"rowContext(row, $index, true)\" />\n }\n }\n </tbody>\n }\n\n <tbody class=\"ui-table-tbody\">\n @if (loading()) {\n <tr class=\"ui-table-loading-row\">\n <td class=\"ui-table-loading-cell\" [attr.colspan]=\"columnCount()\">\n <ui-spinner [ariaLabel]=\"loadingAriaLabel()\" />\n </td>\n </tr>\n } @else {\n @if (virtualScroll() && virtualPadding().top > 0) {\n <tr class=\"ui-table-virtual-spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"columnCount()\" [style.height.px]=\"virtualPadding().top\"></td>\n </tr>\n }\n\n @for (row of pageData(); track $index) {\n @if (bodyTemplate(); as body) {\n <ng-container [ngTemplateOutlet]=\"body\" [ngTemplateOutletContext]=\"rowContext(row, $index)\" />\n }\n @if (expandedRowTemplate(); as expansion) {\n @if (isRowExpanded(row)) {\n <ng-container [ngTemplateOutlet]=\"expansion\" [ngTemplateOutletContext]=\"rowContext(row, $index)\" />\n }\n }\n } @empty {\n <tr class=\"ui-table-empty-row\">\n <td class=\"ui-table-empty-cell\" [attr.colspan]=\"columnCount()\">\n @if (emptyMessageTemplate(); as empty) {\n <ng-container [ngTemplateOutlet]=\"empty\" />\n } @else {\n <ui-empty-state size=\"small\" [icon]=\"emptyIcon()\" [title]=\"emptyMessage()\" />\n }\n </td>\n </tr>\n }\n\n @if (virtualScroll() && virtualPadding().bottom > 0) {\n <tr class=\"ui-table-virtual-spacer\" aria-hidden=\"true\">\n <td [attr.colspan]=\"columnCount()\" [style.height.px]=\"virtualPadding().bottom\"></td>\n </tr>\n }\n }\n </tbody>\n\n @if (footerTemplate(); as footer) {\n <tfoot class=\"ui-table-tfoot\">\n <ng-container [ngTemplateOutlet]=\"footer\" />\n </tfoot>\n }\n </table>\n </div>\n </div>\n\n @if (paginator()) {\n <ui-paginator\n [totalRecords]=\"effectiveTotalRecords()\"\n [rows]=\"rowsState()\"\n (rowsChange)=\"onPaginatorRows($event)\"\n [first]=\"first()\"\n (firstChange)=\"first.set($event)\"\n [pageLinks]=\"pageLinks()\"\n [rowsPerPageOptions]=\"rowsPerPageOptions()\"\n ariaLabel=\"Pagination du tableau\"\n (pageChange)=\"pageChange.emit($event)\"\n />\n }\n</div>\n", styles: ["ui-table{display:block;min-width:0}ui-table:has(>.ui-table._flex-scroll){display:flex;flex-direction:column;flex:1 1 auto;min-height:0}.ui-table{font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);color:var(--table-body-content-odd)}.ui-table-container{min-width:0}.ui-table-wrapper{min-width:0;overflow-x:auto}.ui-table-loading-cell{text-align:center}.ui-table-loading-cell ui-spinner{display:flex;justify-content:center;padding:var(--units-3xl) 0}.ui-table-table{width:100%;border-collapse:separate;border-spacing:0}.ui-table-table th,.ui-table-table td{box-sizing:border-box}.ui-table-caption{padding:var(--units-md) var(--units-default);font-weight:var(--weight-bold)}.ui-table-thead th{padding:var(--units-md) var(--units-default);background-color:var(--table-head-surface-default);color:var(--table-head-content-default);border-bottom:var(--stroke-sm) solid var(--table-head-stroke-default);font-size:var(--size-typography-text-md);font-weight:var(--weight-bold);text-align:left;white-space:nowrap}.ui-table-tbody td{padding:var(--units-default);background-color:var(--table-body-surface-odd);color:var(--table-body-content-odd);border-bottom:var(--stroke-sm) solid var(--table-body-stroke-odd);transition:background-color var(--transition-default) var(--transition-easeinout),color var(--transition-default) var(--transition-easeinout)}.ui-table-tbody tr:last-child td{border-bottom-color:transparent}.ui-table._striped .ui-table-tbody tr:nth-child(2n) td{background-color:var(--table-body-surface-even);color:var(--table-body-content-even);border-bottom-color:var(--table-body-stroke-even)}.ui-table._hoverable .ui-table-tbody tr:hover td{background-color:var(--table-body-surface-hover);color:var(--table-body-content-hover)}.ui-table-tbody tr._selected td,.ui-table._striped .ui-table-tbody tr._selected td{background-color:var(--informative-highlightlow-surface-default);color:var(--informative-highlightlow-content-default);border-bottom-color:var(--informative-highlightlow-stroke-default)}.ui-table._hoverable .ui-table-tbody tr._selected:hover td{background-color:var(--informative-highlightlow-surface-hover);color:var(--informative-highlightlow-content-hover)}.ui-table-selectable-row{cursor:pointer}.ui-table-selectable-row:focus-visible{outline:var(--units-2xs) solid var(--global-border-focus);outline-offset:calc(-1 * var(--units-2xs))}.ui-table-reorderable-row{cursor:grab}.ui-table-reorderable-row._drop-above td{box-shadow:inset 0 var(--stroke-lg) 0 0 var(--global-border-focus)}.ui-table-reorderable-row._drop-below td{box-shadow:inset 0 calc(-1 * var(--stroke-lg)) 0 0 var(--global-border-focus)}.ui-table-empty-cell{text-align:center}.ui-table-empty-cell ui-empty-state{display:flex;justify-content:center;padding:var(--units-xl) 0}.ui-table-virtual-spacer td{padding:0;border:none;background:none}.ui-table-tfoot td{padding:var(--units-md) var(--units-default);background-color:var(--table-footer-surface-default);color:var(--table-footer-content-default);border-top:var(--stroke-sm) solid var(--table-footer-stroke-default);font-weight:var(--weight-bold);text-align:left}.ui-table._small .ui-table-tbody td,.ui-table._small .ui-table-thead th,.ui-table._small .ui-table-tfoot td{padding:var(--units-sm) var(--units-md)}.ui-table._large .ui-table-tbody td{padding:var(--units-xl) var(--units-default)}.ui-table._large .ui-table-thead th,.ui-table._large .ui-table-tfoot td{padding:var(--units-default)}.ui-table._gridlines .ui-table-table{border:var(--stroke-sm) solid var(--table-body-stroke-odd)}.ui-table._gridlines .ui-table-thead th,.ui-table._gridlines .ui-table-tbody td,.ui-table._gridlines .ui-table-tfoot td{border-right:var(--stroke-sm) solid var(--table-body-stroke-odd)}.ui-table._gridlines .ui-table-thead th:last-child,.ui-table._gridlines .ui-table-tbody td:last-child,.ui-table._gridlines .ui-table-tfoot td:last-child{border-right:none}.ui-table-sortable-column{cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--transition-default) var(--transition-easeinout),color var(--transition-default) var(--transition-easeinout)}.ui-table-sortable-column:hover{background-color:var(--table-head-surface-hover);color:var(--table-head-content-hover)}.ui-table-sortable-column:focus-visible{outline:none;box-shadow:inset 0 0 0 var(--units-2xs) var(--global-border-focus)}.ui-table-sortable-column .ui-table-sort-icon{margin-left:var(--units-xs);vertical-align:middle}.ui-table._scrollable .ui-table-wrapper{overflow:auto}.ui-table._scrollable .ui-table-thead th{position:sticky;top:0;z-index:2}.ui-table._scrollable .ui-table-thead th._frozen-left,.ui-table._scrollable .ui-table-thead th._frozen-right{z-index:3}.ui-table._scrollable .ui-table-tfoot td{position:sticky;bottom:0;z-index:2}.ui-table._scrollable .ui-table-tbody._frozen-rows td{position:sticky;top:var(--ui-table-frozen-top, 0);z-index:1;font-weight:var(--weight-bold)}.ui-table._flex-scroll{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}.ui-table._flex-scroll .ui-table-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0}.ui-table._flex-scroll .ui-table-wrapper{flex:1 1 0;min-height:0}.ui-table._virtual .ui-table-wrapper{overflow-anchor:none}.ui-table .ui-table-table th._frozen-left,.ui-table .ui-table-table th._frozen-right,.ui-table .ui-table-table td._frozen-left,.ui-table .ui-table-table td._frozen-right{position:sticky;z-index:1}.ui-table-thead th._frozen-left,.ui-table-thead th._frozen-right{z-index:3}.ui-table._resizable .ui-table-thead th{position:relative;overflow:hidden}.ui-table-column-resizer{position:absolute;top:0;right:0;width:var(--units-sm);height:100%;cursor:col-resize;touch-action:none}.ui-table-column-resizer:hover{border-right:var(--stroke-default) solid var(--global-border-default-hover)}\n"] }]
|
|
776
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], dataKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "dataKey", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], showGridlines: [{ type: i0.Input, args: [{ isSignal: true, alias: "showGridlines", required: false }] }], stripedRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "stripedRows", required: false }] }], rowHover: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowHover", required: false }] }], tableStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableStyle", required: false }] }], selectionMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionMode", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }, { type: i0.Output, args: ["selectionChange"] }], metaKeySelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "metaKeySelection", required: false }] }], sortMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "sortMode", required: false }] }], sortField: [{ type: i0.Input, args: [{ isSignal: true, alias: "sortField", required: false }] }], sortOrder: [{ type: i0.Input, args: [{ isSignal: true, alias: "sortOrder", required: false }] }], multiSortMeta: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiSortMeta", required: false }] }], defaultSortOrder: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultSortOrder", required: false }] }], customSort: [{ type: i0.Input, args: [{ isSignal: true, alias: "customSort", required: false }] }], paginator: [{ type: i0.Input, args: [{ isSignal: true, alias: "paginator", required: false }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: false }] }], first: [{ type: i0.Input, args: [{ isSignal: true, alias: "first", required: false }] }, { type: i0.Output, args: ["firstChange"] }], rowsPerPageOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowsPerPageOptions", required: false }] }], pageLinks: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageLinks", required: false }] }], totalRecords: [{ type: i0.Input, args: [{ isSignal: true, alias: "totalRecords", required: false }] }], scrollable: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollable", required: false }] }], scrollHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollHeight", required: false }] }], frozenValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "frozenValue", required: false }] }], expandedRowKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "expandedRowKeys", required: false }] }, { type: i0.Output, args: ["expandedRowKeysChange"] }], resizableColumns: [{ type: i0.Input, args: [{ isSignal: true, alias: "resizableColumns", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], loadingAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingAriaLabel", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], emptyIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyIcon", required: false }] }], virtualScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualScroll", required: false }] }], virtualScrollItemSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "virtualScrollItemSize", required: false }] }], lazy: [{ type: i0.Input, args: [{ isSignal: true, alias: "lazy", required: false }] }], rowSelect: [{ type: i0.Output, args: ["rowSelect"] }], rowUnselect: [{ type: i0.Output, args: ["rowUnselect"] }], headerCheckboxToggle: [{ type: i0.Output, args: ["headerCheckboxToggle"] }], sortFunction: [{ type: i0.Output, args: ["sortFunction"] }], sortChange: [{ type: i0.Output, args: ["sortChange"] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], rowExpand: [{ type: i0.Output, args: ["rowExpand"] }], rowCollapse: [{ type: i0.Output, args: ["rowCollapse"] }], colResize: [{ type: i0.Output, args: ["colResize"] }], rowReorder: [{ type: i0.Output, args: ["rowReorder"] }], lazyLoad: [{ type: i0.Output, args: ["lazyLoad"] }], captionTemplate: [{ type: i0.ContentChild, args: ['caption', { isSignal: true }] }], headerTemplate: [{ type: i0.ContentChild, args: ['header', { isSignal: true }] }], bodyTemplate: [{ type: i0.ContentChild, args: ['body', { isSignal: true }] }], footerTemplate: [{ type: i0.ContentChild, args: ['footer', { isSignal: true }] }], expandedRowTemplate: [{ type: i0.ContentChild, args: ['expandedrow', { isSignal: true }] }], emptyMessageTemplate: [{ type: i0.ContentChild, args: ['emptymessage', { isSignal: true }] }], tableEl: [{ type: i0.ViewChild, args: ['tableEl', { isSignal: true }] }], theadEl: [{ type: i0.ViewChild, args: ['theadEl', { isSignal: true }] }], wrapperEl: [{ type: i0.ViewChild, args: ['wrapperEl', { isSignal: true }] }] } });
|
|
777
|
+
/**
|
|
778
|
+
* uiSortableColumn — makes a `<th>` sortable.
|
|
779
|
+
*
|
|
780
|
+
* Click / Enter / Space cycles ascending → descending → unsorted (single
|
|
781
|
+
* mode) or composes with Ctrl/Cmd in multiple mode. Exposes `aria-sort`.
|
|
782
|
+
*/
|
|
783
|
+
class UiTableSortableColumn {
|
|
784
|
+
constructor() {
|
|
785
|
+
/** @ignore */
|
|
786
|
+
this.table = inject(UiTable);
|
|
787
|
+
/** Field (dotted path allowed) this column sorts on. */
|
|
788
|
+
this.field = input.required({ ...(ngDevMode ? { debugName: "field" } : /* istanbul ignore next */ {}), alias: 'uiSortableColumn' });
|
|
789
|
+
/** Disables the sort interaction. */
|
|
790
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'uiSortableColumnDisabled' });
|
|
791
|
+
/** @ignore */
|
|
792
|
+
this.sorted = computed(() => this.table.getSortOrder(this.field()) !== 0, /* @ts-ignore */
|
|
793
|
+
...(ngDevMode ? [{ debugName: "sorted" }] : /* istanbul ignore next */ []));
|
|
794
|
+
/** @ignore */
|
|
795
|
+
this.ariaSort = computed(() => {
|
|
796
|
+
const order = this.table.getSortOrder(this.field());
|
|
797
|
+
return order === 0 ? 'none' : order > 0 ? 'ascending' : 'descending';
|
|
798
|
+
}, /* @ts-ignore */
|
|
799
|
+
...(ngDevMode ? [{ debugName: "ariaSort" }] : /* istanbul ignore next */ []));
|
|
800
|
+
}
|
|
801
|
+
/** @ignore */
|
|
802
|
+
onTrigger(event) {
|
|
803
|
+
if (this.disabled())
|
|
804
|
+
return;
|
|
805
|
+
event.preventDefault();
|
|
806
|
+
this.table.toggleColumnSort(this.field(), event);
|
|
807
|
+
}
|
|
808
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableSortableColumn, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
809
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: UiTableSortableColumn, isStandalone: true, selector: "[uiSortableColumn]", inputs: { field: { classPropertyName: "field", publicName: "uiSortableColumn", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "uiSortableColumnDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onTrigger($event)", "keydown.enter": "onTrigger($event)", "keydown.space": "onTrigger($event)" }, properties: { "class._sorted": "sorted()", "attr.tabindex": "disabled() ? null : 0", "attr.role": "\"columnheader\"", "attr.aria-sort": "ariaSort()" }, classAttribute: "ui-table-sortable-column" }, ngImport: i0 }); }
|
|
810
|
+
}
|
|
811
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableSortableColumn, decorators: [{
|
|
812
|
+
type: Directive,
|
|
813
|
+
args: [{
|
|
814
|
+
selector: '[uiSortableColumn]',
|
|
815
|
+
host: {
|
|
816
|
+
class: 'ui-table-sortable-column',
|
|
817
|
+
'[class._sorted]': 'sorted()',
|
|
818
|
+
'[attr.tabindex]': 'disabled() ? null : 0',
|
|
819
|
+
'[attr.role]': '"columnheader"',
|
|
820
|
+
'[attr.aria-sort]': 'ariaSort()',
|
|
821
|
+
'(click)': 'onTrigger($event)',
|
|
822
|
+
'(keydown.enter)': 'onTrigger($event)',
|
|
823
|
+
'(keydown.space)': 'onTrigger($event)',
|
|
824
|
+
},
|
|
825
|
+
}]
|
|
826
|
+
}], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiSortableColumn", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiSortableColumnDisabled", required: false }] }] } });
|
|
827
|
+
/**
|
|
828
|
+
* ui-table-sort-icon — direction indicator of a sortable column.
|
|
829
|
+
* Decorative: the accessible state lives on the `<th>` (`aria-sort`).
|
|
830
|
+
*/
|
|
831
|
+
class UiTableSortIcon {
|
|
832
|
+
constructor() {
|
|
833
|
+
/** @ignore */
|
|
834
|
+
this.table = inject(UiTable);
|
|
835
|
+
/** Field of the column this icon reflects. */
|
|
836
|
+
this.field = input.required(/* @ts-ignore */
|
|
837
|
+
...(ngDevMode ? [{ debugName: "field" }] : /* istanbul ignore next */ []));
|
|
838
|
+
/** @ignore */
|
|
839
|
+
this.iconName = computed(() => {
|
|
840
|
+
const order = this.table.getSortOrder(this.field());
|
|
841
|
+
return order === 0 ? 'sort' : order > 0 ? 'sort-up' : 'sort-down';
|
|
842
|
+
}, /* @ts-ignore */
|
|
843
|
+
...(ngDevMode ? [{ debugName: "iconName" }] : /* istanbul ignore next */ []));
|
|
844
|
+
}
|
|
845
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableSortIcon, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
846
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.8", type: UiTableSortIcon, isStandalone: true, selector: "ui-table-sort-icon", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `<ui-icon class="ui-table-sort-icon" [name]="iconName()" size="sm" />`, isInline: true, dependencies: [{ kind: "component", type: UiIcon, selector: "ui-icon", inputs: ["name", "size", "type", "family", "decorative", "ariaLabel"] }] }); }
|
|
847
|
+
}
|
|
848
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableSortIcon, decorators: [{
|
|
849
|
+
type: Component,
|
|
850
|
+
args: [{
|
|
851
|
+
selector: 'ui-table-sort-icon',
|
|
852
|
+
imports: [UiIcon],
|
|
853
|
+
template: `<ui-icon class="ui-table-sort-icon" [name]="iconName()" size="sm" />`,
|
|
854
|
+
}]
|
|
855
|
+
}], propDecorators: { field: [{ type: i0.Input, args: [{ isSignal: true, alias: "field", required: true }] }] } });
|
|
856
|
+
/**
|
|
857
|
+
* uiSelectableRow — makes a `<tr>` selectable.
|
|
858
|
+
*
|
|
859
|
+
* Click selects (composing with Ctrl/Cmd / Shift according to
|
|
860
|
+
* `metaKeySelection`); Arrow Up/Down moves the focus between rows, Space /
|
|
861
|
+
* Enter toggles, Shift+Arrow extends the range.
|
|
862
|
+
*/
|
|
863
|
+
class UiTableSelectableRow {
|
|
864
|
+
constructor() {
|
|
865
|
+
/** @ignore */
|
|
866
|
+
this.table = inject(UiTable);
|
|
867
|
+
/** @ignore */
|
|
868
|
+
this.el = inject(ElementRef);
|
|
869
|
+
/** Row data carried by this `<tr>`. */
|
|
870
|
+
this.data = input.required({ ...(ngDevMode ? { debugName: "data" } : /* istanbul ignore next */ {}), alias: 'uiSelectableRow' });
|
|
871
|
+
/** Absolute row index (from the body template context). */
|
|
872
|
+
this.index = input(0, { ...(ngDevMode ? { debugName: "index" } : /* istanbul ignore next */ {}), transform: numberAttribute, alias: 'uiSelectableRowIndex' });
|
|
873
|
+
/** Disables the selection interaction. */
|
|
874
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'uiSelectableRowDisabled' });
|
|
875
|
+
/** @ignore */
|
|
876
|
+
this.selected = computed(() => this.table.isSelected(this.data()), /* @ts-ignore */
|
|
877
|
+
...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
878
|
+
/** @ignore Roving tabindex: a single row carries the tab stop. */
|
|
879
|
+
this.tabindex = computed(() => {
|
|
880
|
+
if (this.disabled())
|
|
881
|
+
return null;
|
|
882
|
+
return this.table.isRowTabbable(this.data()) ? 0 : -1;
|
|
883
|
+
}, /* @ts-ignore */
|
|
884
|
+
...(ngDevMode ? [{ debugName: "tabindex" }] : /* istanbul ignore next */ []));
|
|
885
|
+
// Registry lookup used by Shift+Arrow (the moving row must resolve the
|
|
886
|
+
// data/index of its target sibling).
|
|
887
|
+
effect(() => {
|
|
888
|
+
this.table.selectableRowRefs.set(this.el.nativeElement, { data: this.data(), index: this.index() });
|
|
889
|
+
});
|
|
890
|
+
inject(DestroyRef).onDestroy(() => this.table.selectableRowRefs.delete(this.el.nativeElement));
|
|
891
|
+
}
|
|
892
|
+
/** @ignore */
|
|
893
|
+
onClick(event) {
|
|
894
|
+
if (this.disabled())
|
|
895
|
+
return;
|
|
896
|
+
this.table.handleRowClick(event, this.data(), this.index());
|
|
897
|
+
}
|
|
898
|
+
/** @ignore */
|
|
899
|
+
onKeydown(event) {
|
|
900
|
+
if (this.disabled())
|
|
901
|
+
return;
|
|
902
|
+
const meta = event.metaKey || event.ctrlKey;
|
|
903
|
+
switch (event.key) {
|
|
904
|
+
case 'ArrowDown':
|
|
905
|
+
case 'ArrowUp': {
|
|
906
|
+
event.preventDefault();
|
|
907
|
+
const target = this.findSiblingRow(event.key === 'ArrowDown' ? 'next' : 'previous');
|
|
908
|
+
if (!target)
|
|
909
|
+
return;
|
|
910
|
+
target.focus();
|
|
911
|
+
if (event.shiftKey) {
|
|
912
|
+
const ref = this.table.selectableRowRefs.get(target);
|
|
913
|
+
if (ref)
|
|
914
|
+
this.table.selectRange(event, ref.index);
|
|
915
|
+
}
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
case 'Home':
|
|
919
|
+
case 'End': {
|
|
920
|
+
event.preventDefault();
|
|
921
|
+
const edge = event.key === 'Home' ? 'start' : 'end';
|
|
922
|
+
this.findEdgeRow(edge)?.focus();
|
|
923
|
+
if (meta && event.shiftKey)
|
|
924
|
+
this.table.selectRangeToEdge(this.index(), edge);
|
|
925
|
+
break;
|
|
926
|
+
}
|
|
927
|
+
case 'Enter': {
|
|
928
|
+
event.preventDefault();
|
|
929
|
+
this.table.handleRowClick(event, this.data(), this.index());
|
|
930
|
+
break;
|
|
931
|
+
}
|
|
932
|
+
case ' ': {
|
|
933
|
+
event.preventDefault();
|
|
934
|
+
// Shift+Space selects the range from the last anchor to this row.
|
|
935
|
+
if (event.shiftKey)
|
|
936
|
+
this.table.selectRange(event, this.index());
|
|
937
|
+
else
|
|
938
|
+
this.table.handleRowClick(event, this.data(), this.index());
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
case 'a':
|
|
942
|
+
case 'A': {
|
|
943
|
+
if (!meta)
|
|
944
|
+
return;
|
|
945
|
+
event.preventDefault();
|
|
946
|
+
this.table.selectAllRows(event);
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
/** @ignore Nearest selectable `<tr>` sibling (skips expansion rows). */
|
|
952
|
+
findSiblingRow(direction) {
|
|
953
|
+
let el = this.el.nativeElement;
|
|
954
|
+
while ((el = direction === 'next' ? el.nextElementSibling : el.previousElementSibling)) {
|
|
955
|
+
if (el.classList.contains('ui-table-selectable-row'))
|
|
956
|
+
return el;
|
|
957
|
+
}
|
|
958
|
+
return null;
|
|
959
|
+
}
|
|
960
|
+
/** @ignore First / last selectable row of the table. */
|
|
961
|
+
findEdgeRow(edge) {
|
|
962
|
+
const rows = this.el.nativeElement.closest('table')?.querySelectorAll('.ui-table-selectable-row');
|
|
963
|
+
if (!rows?.length)
|
|
964
|
+
return null;
|
|
965
|
+
return edge === 'start' ? rows[0] : rows[rows.length - 1];
|
|
966
|
+
}
|
|
967
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableSelectableRow, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
968
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: UiTableSelectableRow, isStandalone: true, selector: "[uiSelectableRow]", inputs: { data: { classPropertyName: "data", publicName: "uiSelectableRow", isSignal: true, isRequired: true, transformFunction: null }, index: { classPropertyName: "index", publicName: "uiSelectableRowIndex", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "uiSelectableRowDisabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "onClick($event)", "keydown": "onKeydown($event)" }, properties: { "class._selected": "selected()", "attr.tabindex": "tabindex()", "attr.aria-selected": "selected()" }, classAttribute: "ui-table-selectable-row" }, ngImport: i0 }); }
|
|
969
|
+
}
|
|
970
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableSelectableRow, decorators: [{
|
|
971
|
+
type: Directive,
|
|
972
|
+
args: [{
|
|
973
|
+
selector: '[uiSelectableRow]',
|
|
974
|
+
host: {
|
|
975
|
+
class: 'ui-table-selectable-row',
|
|
976
|
+
'[class._selected]': 'selected()',
|
|
977
|
+
'[attr.tabindex]': 'tabindex()',
|
|
978
|
+
'[attr.aria-selected]': 'selected()',
|
|
979
|
+
'(click)': 'onClick($event)',
|
|
980
|
+
'(keydown)': 'onKeydown($event)',
|
|
981
|
+
},
|
|
982
|
+
}]
|
|
983
|
+
}], ctorParameters: () => [], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiSelectableRow", required: true }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiSelectableRowIndex", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiSelectableRowDisabled", required: false }] }] } });
|
|
984
|
+
/**
|
|
985
|
+
* ui-table-checkbox — row checkbox of a checkbox-based multiple selection.
|
|
986
|
+
* Instantiates `ui-checkbox` bound to the table selection.
|
|
987
|
+
*/
|
|
988
|
+
class UiTableCheckbox {
|
|
989
|
+
constructor() {
|
|
990
|
+
/** @ignore */
|
|
991
|
+
this.table = inject(UiTable);
|
|
992
|
+
/** Row this checkbox (un)selects. */
|
|
993
|
+
this.value = input.required(/* @ts-ignore */
|
|
994
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
995
|
+
/** Absolute row index (forwarded to the selection events). */
|
|
996
|
+
this.index = input(undefined, { ...(ngDevMode ? { debugName: "index" } : /* istanbul ignore next */ {}), transform: (v) => (v == null ? undefined : Number(v)) });
|
|
997
|
+
/** Disables the checkbox. */
|
|
998
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
999
|
+
/** Accessible name of the checkbox. */
|
|
1000
|
+
this.ariaLabel = input('Sélectionner la ligne', /* @ts-ignore */
|
|
1001
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
1002
|
+
/** @ignore */
|
|
1003
|
+
this.checked = computed(() => this.table.isSelected(this.value()), /* @ts-ignore */
|
|
1004
|
+
...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
1005
|
+
}
|
|
1006
|
+
/** @ignore */
|
|
1007
|
+
onToggle(_checked) {
|
|
1008
|
+
this.table.toggleRowWithCheckbox(undefined, this.value(), this.index());
|
|
1009
|
+
}
|
|
1010
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1011
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.8", type: UiTableCheckbox, isStandalone: true, selector: "ui-table-checkbox", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
1012
|
+
<ui-checkbox
|
|
1013
|
+
[ngModel]="checked()"
|
|
1014
|
+
[disabled]="disabled()"
|
|
1015
|
+
[ariaLabel]="ariaLabel()"
|
|
1016
|
+
(checkboxChange)="onToggle($event)"
|
|
1017
|
+
/>
|
|
1018
|
+
`, isInline: true, dependencies: [{ kind: "component", type: UiCheckbox, selector: "ui-checkbox", inputs: ["label", "trueValue", "falseValue", "indeterminate", "checkIcon", "indeterminateIcon"], outputs: ["checkboxChange", "checkboxFocus", "checkboxBlur"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
|
|
1019
|
+
}
|
|
1020
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableCheckbox, decorators: [{
|
|
1021
|
+
type: Component,
|
|
1022
|
+
args: [{
|
|
1023
|
+
selector: 'ui-table-checkbox',
|
|
1024
|
+
imports: [UiCheckbox, FormsModule],
|
|
1025
|
+
template: `
|
|
1026
|
+
<ui-checkbox
|
|
1027
|
+
[ngModel]="checked()"
|
|
1028
|
+
[disabled]="disabled()"
|
|
1029
|
+
[ariaLabel]="ariaLabel()"
|
|
1030
|
+
(checkboxChange)="onToggle($event)"
|
|
1031
|
+
/>
|
|
1032
|
+
`,
|
|
1033
|
+
}]
|
|
1034
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }] } });
|
|
1035
|
+
/**
|
|
1036
|
+
* ui-table-header-checkbox — header select-all checkbox (checkbox selection).
|
|
1037
|
+
* Checked when every row is selected, indeterminate on partial selection.
|
|
1038
|
+
*/
|
|
1039
|
+
class UiTableHeaderCheckbox {
|
|
1040
|
+
constructor() {
|
|
1041
|
+
/** @ignore */
|
|
1042
|
+
this.table = inject(UiTable);
|
|
1043
|
+
/** Disables the checkbox. */
|
|
1044
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1045
|
+
/** Accessible name of the checkbox. */
|
|
1046
|
+
this.ariaLabel = input('Tout sélectionner', /* @ts-ignore */
|
|
1047
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
1048
|
+
}
|
|
1049
|
+
/** @ignore */
|
|
1050
|
+
onToggle(checked) {
|
|
1051
|
+
this.table.toggleAllRows(undefined, checked === true);
|
|
1052
|
+
}
|
|
1053
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableHeaderCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1054
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.8", type: UiTableHeaderCheckbox, isStandalone: true, selector: "ui-table-header-checkbox", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
1055
|
+
<ui-checkbox
|
|
1056
|
+
[ngModel]="table.allSelected()"
|
|
1057
|
+
[indeterminate]="table.partiallySelected()"
|
|
1058
|
+
[disabled]="disabled()"
|
|
1059
|
+
[ariaLabel]="ariaLabel()"
|
|
1060
|
+
(checkboxChange)="onToggle($event)"
|
|
1061
|
+
/>
|
|
1062
|
+
`, isInline: true, dependencies: [{ kind: "component", type: UiCheckbox, selector: "ui-checkbox", inputs: ["label", "trueValue", "falseValue", "indeterminate", "checkIcon", "indeterminateIcon"], outputs: ["checkboxChange", "checkboxFocus", "checkboxBlur"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
|
|
1063
|
+
}
|
|
1064
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableHeaderCheckbox, decorators: [{
|
|
1065
|
+
type: Component,
|
|
1066
|
+
args: [{
|
|
1067
|
+
selector: 'ui-table-header-checkbox',
|
|
1068
|
+
imports: [UiCheckbox, FormsModule],
|
|
1069
|
+
template: `
|
|
1070
|
+
<ui-checkbox
|
|
1071
|
+
[ngModel]="table.allSelected()"
|
|
1072
|
+
[indeterminate]="table.partiallySelected()"
|
|
1073
|
+
[disabled]="disabled()"
|
|
1074
|
+
[ariaLabel]="ariaLabel()"
|
|
1075
|
+
(checkboxChange)="onToggle($event)"
|
|
1076
|
+
/>
|
|
1077
|
+
`,
|
|
1078
|
+
}]
|
|
1079
|
+
}], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }] } });
|
|
1080
|
+
/**
|
|
1081
|
+
* ui-table-radio — row radio button of a radio-based single selection.
|
|
1082
|
+
* Instantiates `ui-radio` bound to the table selection.
|
|
1083
|
+
*/
|
|
1084
|
+
class UiTableRadio {
|
|
1085
|
+
constructor() {
|
|
1086
|
+
/** @ignore */
|
|
1087
|
+
this.table = inject(UiTable);
|
|
1088
|
+
/** Row this radio selects. */
|
|
1089
|
+
this.value = input.required(/* @ts-ignore */
|
|
1090
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1091
|
+
/** Absolute row index (forwarded to the selection events). */
|
|
1092
|
+
this.index = input(undefined, { ...(ngDevMode ? { debugName: "index" } : /* istanbul ignore next */ {}), transform: (v) => (v == null ? undefined : Number(v)) });
|
|
1093
|
+
/** Native group name (defaults to a per-table group). */
|
|
1094
|
+
this.name = input('ui-table-radio', /* @ts-ignore */
|
|
1095
|
+
...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
1096
|
+
/** Disables the radio. */
|
|
1097
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1098
|
+
/** Accessible name of the radio. */
|
|
1099
|
+
this.ariaLabel = input('Sélectionner la ligne', /* @ts-ignore */
|
|
1100
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
1101
|
+
}
|
|
1102
|
+
/** @ignore */
|
|
1103
|
+
onSelect() {
|
|
1104
|
+
this.table.selectRowWithRadio(undefined, this.value(), this.index());
|
|
1105
|
+
}
|
|
1106
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableRadio, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1107
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.8", type: UiTableRadio, isStandalone: true, selector: "ui-table-radio", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
1108
|
+
<ui-radio
|
|
1109
|
+
[value]="value()"
|
|
1110
|
+
[ngModel]="table.isSelected(value()) ? value() : undefined"
|
|
1111
|
+
[name]="name()"
|
|
1112
|
+
[disabled]="disabled()"
|
|
1113
|
+
[ariaLabel]="ariaLabel()"
|
|
1114
|
+
(radioChange)="onSelect()"
|
|
1115
|
+
/>
|
|
1116
|
+
`, isInline: true, dependencies: [{ kind: "component", type: UiRadio, selector: "ui-radio", inputs: ["value", "label"], outputs: ["radioChange", "radioFocus", "radioBlur"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
|
|
1117
|
+
}
|
|
1118
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableRadio, decorators: [{
|
|
1119
|
+
type: Component,
|
|
1120
|
+
args: [{
|
|
1121
|
+
selector: 'ui-table-radio',
|
|
1122
|
+
imports: [UiRadio, FormsModule],
|
|
1123
|
+
template: `
|
|
1124
|
+
<ui-radio
|
|
1125
|
+
[value]="value()"
|
|
1126
|
+
[ngModel]="table.isSelected(value()) ? value() : undefined"
|
|
1127
|
+
[name]="name()"
|
|
1128
|
+
[disabled]="disabled()"
|
|
1129
|
+
[ariaLabel]="ariaLabel()"
|
|
1130
|
+
(radioChange)="onSelect()"
|
|
1131
|
+
/>
|
|
1132
|
+
`,
|
|
1133
|
+
}]
|
|
1134
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }] } });
|
|
1135
|
+
/**
|
|
1136
|
+
* uiRowToggler — toggles the expansion of a row. Place it on the expand
|
|
1137
|
+
* button (native `<button>` or `ui-button`); `aria-expanded` is reflected.
|
|
1138
|
+
*/
|
|
1139
|
+
class UiTableRowToggler {
|
|
1140
|
+
constructor() {
|
|
1141
|
+
/** @ignore */
|
|
1142
|
+
this.table = inject(UiTable);
|
|
1143
|
+
/** Row whose expansion this button toggles. */
|
|
1144
|
+
this.data = input.required({ ...(ngDevMode ? { debugName: "data" } : /* istanbul ignore next */ {}), alias: 'uiRowToggler' });
|
|
1145
|
+
/** @ignore */
|
|
1146
|
+
this.expanded = computed(() => this.table.isRowExpanded(this.data()), /* @ts-ignore */
|
|
1147
|
+
...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
1148
|
+
}
|
|
1149
|
+
/** @ignore */
|
|
1150
|
+
onToggle(event) {
|
|
1151
|
+
this.table.toggleRow(this.data(), event);
|
|
1152
|
+
event.stopPropagation();
|
|
1153
|
+
}
|
|
1154
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableRowToggler, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1155
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: UiTableRowToggler, isStandalone: true, selector: "[uiRowToggler]", inputs: { data: { classPropertyName: "data", publicName: "uiRowToggler", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "click": "onToggle($event)" }, properties: { "attr.aria-expanded": "expanded()" } }, ngImport: i0 }); }
|
|
1156
|
+
}
|
|
1157
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableRowToggler, decorators: [{
|
|
1158
|
+
type: Directive,
|
|
1159
|
+
args: [{
|
|
1160
|
+
selector: '[uiRowToggler]',
|
|
1161
|
+
host: {
|
|
1162
|
+
'[attr.aria-expanded]': 'expanded()',
|
|
1163
|
+
'(click)': 'onToggle($event)',
|
|
1164
|
+
},
|
|
1165
|
+
}]
|
|
1166
|
+
}], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiRowToggler", required: true }] }] } });
|
|
1167
|
+
/**
|
|
1168
|
+
* uiFrozenColumn — pins a column while scrolling horizontally.
|
|
1169
|
+
* Apply to every `<th>`/`<td>` of the column; `alignFrozen` picks the edge.
|
|
1170
|
+
*/
|
|
1171
|
+
class UiTableFrozenColumn {
|
|
1172
|
+
constructor() {
|
|
1173
|
+
/** @ignore */
|
|
1174
|
+
this.el = inject(ElementRef);
|
|
1175
|
+
/** @ignore */
|
|
1176
|
+
this.injector = inject(Injector);
|
|
1177
|
+
/** Enables the pinning (attribute presence defaults to true). */
|
|
1178
|
+
this.frozen = input(true, { ...(ngDevMode ? { debugName: "frozen" } : /* istanbul ignore next */ {}), alias: 'uiFrozenColumn',
|
|
1179
|
+
transform: (value) => value === '' || value == null || booleanAttribute(value) });
|
|
1180
|
+
/** Edge the column sticks to. */
|
|
1181
|
+
this.alignFrozen = input('left', /* @ts-ignore */
|
|
1182
|
+
...(ngDevMode ? [{ debugName: "alignFrozen" }] : /* istanbul ignore next */ []));
|
|
1183
|
+
/** @ignore */
|
|
1184
|
+
this.isFrozen = computed(() => this.frozen(), /* @ts-ignore */
|
|
1185
|
+
...(ngDevMode ? [{ debugName: "isFrozen" }] : /* istanbul ignore next */ []));
|
|
1186
|
+
// Offset = accumulated width of the previously pinned columns on the same
|
|
1187
|
+
// edge. Re-measured whenever the row resizes (column resize, data change).
|
|
1188
|
+
afterNextRender(() => {
|
|
1189
|
+
this.updatePosition();
|
|
1190
|
+
const row = this.el.nativeElement.parentElement;
|
|
1191
|
+
if (row && typeof ResizeObserver !== 'undefined') {
|
|
1192
|
+
const observer = new ResizeObserver(() => this.updatePosition());
|
|
1193
|
+
observer.observe(row);
|
|
1194
|
+
this.injector.get(DestroyRef).onDestroy(() => observer.disconnect());
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
effect(() => {
|
|
1198
|
+
this.frozen();
|
|
1199
|
+
this.alignFrozen();
|
|
1200
|
+
this.updatePosition();
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
/** @ignore */
|
|
1204
|
+
updatePosition() {
|
|
1205
|
+
const cell = this.el.nativeElement;
|
|
1206
|
+
if (!this.frozen()) {
|
|
1207
|
+
cell.style.left = '';
|
|
1208
|
+
cell.style.right = '';
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
if (this.alignFrozen() === 'left') {
|
|
1212
|
+
let offset = 0;
|
|
1213
|
+
let sibling = cell.previousElementSibling;
|
|
1214
|
+
while (sibling) {
|
|
1215
|
+
if (sibling.classList.contains('_frozen-left'))
|
|
1216
|
+
offset += sibling.getBoundingClientRect().width;
|
|
1217
|
+
sibling = sibling.previousElementSibling;
|
|
1218
|
+
}
|
|
1219
|
+
cell.style.left = `${offset}px`;
|
|
1220
|
+
cell.style.right = '';
|
|
1221
|
+
}
|
|
1222
|
+
else {
|
|
1223
|
+
let offset = 0;
|
|
1224
|
+
let sibling = cell.nextElementSibling;
|
|
1225
|
+
while (sibling) {
|
|
1226
|
+
if (sibling.classList.contains('_frozen-right'))
|
|
1227
|
+
offset += sibling.getBoundingClientRect().width;
|
|
1228
|
+
sibling = sibling.nextElementSibling;
|
|
1229
|
+
}
|
|
1230
|
+
cell.style.right = `${offset}px`;
|
|
1231
|
+
cell.style.left = '';
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableFrozenColumn, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1235
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: UiTableFrozenColumn, isStandalone: true, selector: "[uiFrozenColumn]", inputs: { frozen: { classPropertyName: "frozen", publicName: "uiFrozenColumn", isSignal: true, isRequired: false, transformFunction: null }, alignFrozen: { classPropertyName: "alignFrozen", publicName: "alignFrozen", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class._frozen-left": "isFrozen() && alignFrozen() === \"left\"", "class._frozen-right": "isFrozen() && alignFrozen() === \"right\"" } }, ngImport: i0 }); }
|
|
1236
|
+
}
|
|
1237
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableFrozenColumn, decorators: [{
|
|
1238
|
+
type: Directive,
|
|
1239
|
+
args: [{
|
|
1240
|
+
selector: '[uiFrozenColumn]',
|
|
1241
|
+
host: {
|
|
1242
|
+
'[class._frozen-left]': 'isFrozen() && alignFrozen() === "left"',
|
|
1243
|
+
'[class._frozen-right]': 'isFrozen() && alignFrozen() === "right"',
|
|
1244
|
+
},
|
|
1245
|
+
}]
|
|
1246
|
+
}], ctorParameters: () => [], propDecorators: { frozen: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiFrozenColumn", required: false }] }], alignFrozen: [{ type: i0.Input, args: [{ isSignal: true, alias: "alignFrozen", required: false }] }] } });
|
|
1247
|
+
/**
|
|
1248
|
+
* uiResizableColumn — drag handle on a `<th>` to resize the column.
|
|
1249
|
+
* Fit mode: the next column absorbs the delta, the table width is preserved.
|
|
1250
|
+
*/
|
|
1251
|
+
class UiTableResizableColumn {
|
|
1252
|
+
constructor() {
|
|
1253
|
+
/** @ignore */
|
|
1254
|
+
this.table = inject(UiTable);
|
|
1255
|
+
/** @ignore */
|
|
1256
|
+
this.el = inject(ElementRef);
|
|
1257
|
+
/** @ignore */
|
|
1258
|
+
this.destroyRef = inject(DestroyRef);
|
|
1259
|
+
/** @ignore */
|
|
1260
|
+
this.startX = 0;
|
|
1261
|
+
/** @ignore */
|
|
1262
|
+
this.startWidth = 0;
|
|
1263
|
+
/** @ignore */
|
|
1264
|
+
this.nextStartWidth = 0;
|
|
1265
|
+
/** @ignore */
|
|
1266
|
+
this.appliedDelta = 0;
|
|
1267
|
+
/** @ignore */
|
|
1268
|
+
this.cleanupDrag = null;
|
|
1269
|
+
/** @ignore */
|
|
1270
|
+
this.onPointerDown = (event) => {
|
|
1271
|
+
const cell = this.el.nativeElement;
|
|
1272
|
+
const next = cell.nextElementSibling;
|
|
1273
|
+
if (!next)
|
|
1274
|
+
return;
|
|
1275
|
+
event.preventDefault();
|
|
1276
|
+
this.table.lockColumnWidths();
|
|
1277
|
+
this.startX = event.clientX;
|
|
1278
|
+
this.startWidth = cell.getBoundingClientRect().width;
|
|
1279
|
+
this.nextStartWidth = next.getBoundingClientRect().width;
|
|
1280
|
+
this.appliedDelta = 0;
|
|
1281
|
+
const onMove = (moveEvent) => {
|
|
1282
|
+
const delta = moveEvent.clientX - this.startX;
|
|
1283
|
+
if (this.table.resizeColumnFit(cell, this.startWidth, this.nextStartWidth, delta)) {
|
|
1284
|
+
this.appliedDelta = delta;
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
const onUp = () => {
|
|
1288
|
+
this.cleanupDrag?.();
|
|
1289
|
+
if (this.appliedDelta !== 0)
|
|
1290
|
+
this.table.notifyColResize(cell, this.appliedDelta);
|
|
1291
|
+
};
|
|
1292
|
+
document.addEventListener('pointermove', onMove);
|
|
1293
|
+
document.addEventListener('pointerup', onUp);
|
|
1294
|
+
this.cleanupDrag = () => {
|
|
1295
|
+
document.removeEventListener('pointermove', onMove);
|
|
1296
|
+
document.removeEventListener('pointerup', onUp);
|
|
1297
|
+
this.cleanupDrag = null;
|
|
1298
|
+
};
|
|
1299
|
+
};
|
|
1300
|
+
afterNextRender(() => {
|
|
1301
|
+
const handle = document.createElement('span');
|
|
1302
|
+
handle.className = 'ui-table-column-resizer';
|
|
1303
|
+
handle.setAttribute('aria-hidden', 'true');
|
|
1304
|
+
handle.addEventListener('pointerdown', this.onPointerDown);
|
|
1305
|
+
this.el.nativeElement.appendChild(handle);
|
|
1306
|
+
});
|
|
1307
|
+
this.destroyRef.onDestroy(() => this.cleanupDrag?.());
|
|
1308
|
+
}
|
|
1309
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableResizableColumn, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1310
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.8", type: UiTableResizableColumn, isStandalone: true, selector: "[uiResizableColumn]", host: { classAttribute: "ui-table-resizable-column" }, ngImport: i0 }); }
|
|
1311
|
+
}
|
|
1312
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableResizableColumn, decorators: [{
|
|
1313
|
+
type: Directive,
|
|
1314
|
+
args: [{
|
|
1315
|
+
selector: '[uiResizableColumn]',
|
|
1316
|
+
host: { class: 'ui-table-resizable-column' },
|
|
1317
|
+
}]
|
|
1318
|
+
}], ctorParameters: () => [] });
|
|
1319
|
+
/**
|
|
1320
|
+
* uiReorderableRow — drag & drop a `<tr>` to reorder rows.
|
|
1321
|
+
*
|
|
1322
|
+
* Pass the absolute `rowIndex` from the body template context. On drop the
|
|
1323
|
+
* table emits `rowReorder` with a reordered copy of `value` (rebind it).
|
|
1324
|
+
* Intended for unsorted data (reordering a sorted view is ambiguous).
|
|
1325
|
+
*/
|
|
1326
|
+
class UiTableReorderableRow {
|
|
1327
|
+
constructor() {
|
|
1328
|
+
/** @ignore */
|
|
1329
|
+
this.table = inject(UiTable);
|
|
1330
|
+
/** @ignore */
|
|
1331
|
+
this.el = inject(ElementRef);
|
|
1332
|
+
/** Absolute row index (from the body template context). */
|
|
1333
|
+
this.index = input.required({ ...(ngDevMode ? { debugName: "index" } : /* istanbul ignore next */ {}), alias: 'uiReorderableRow', transform: numberAttribute });
|
|
1334
|
+
/** @ignore Visual drop indicator (edge of the hovered row). */
|
|
1335
|
+
this.dropPosition = signal(null, /* @ts-ignore */
|
|
1336
|
+
...(ngDevMode ? [{ debugName: "dropPosition" }] : /* istanbul ignore next */ []));
|
|
1337
|
+
}
|
|
1338
|
+
/** @ignore */
|
|
1339
|
+
onDragStart(event) {
|
|
1340
|
+
this.table.draggedRowIndex = this.index();
|
|
1341
|
+
// Firefox requires data for the drag to start.
|
|
1342
|
+
event.dataTransfer?.setData('text/plain', String(this.index()));
|
|
1343
|
+
if (event.dataTransfer)
|
|
1344
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
1345
|
+
}
|
|
1346
|
+
/** @ignore */
|
|
1347
|
+
onDragOver(event) {
|
|
1348
|
+
if (this.table.draggedRowIndex == null)
|
|
1349
|
+
return;
|
|
1350
|
+
event.preventDefault();
|
|
1351
|
+
const rect = this.el.nativeElement.getBoundingClientRect();
|
|
1352
|
+
this.dropPosition.set(event.clientY < rect.top + rect.height / 2 ? 'above' : 'below');
|
|
1353
|
+
}
|
|
1354
|
+
/** @ignore */
|
|
1355
|
+
onDragLeave() {
|
|
1356
|
+
this.dropPosition.set(null);
|
|
1357
|
+
}
|
|
1358
|
+
/** @ignore */
|
|
1359
|
+
onDrop(event) {
|
|
1360
|
+
event.preventDefault();
|
|
1361
|
+
const position = this.dropPosition();
|
|
1362
|
+
this.dropPosition.set(null);
|
|
1363
|
+
if (position == null)
|
|
1364
|
+
return;
|
|
1365
|
+
const drag = this.table.draggedRowIndex;
|
|
1366
|
+
let drop = position === 'above' ? this.index() : this.index() + 1;
|
|
1367
|
+
if (drag != null && drag < drop)
|
|
1368
|
+
drop--;
|
|
1369
|
+
this.table.dropRow(drop);
|
|
1370
|
+
}
|
|
1371
|
+
/** @ignore */
|
|
1372
|
+
onDragEnd() {
|
|
1373
|
+
this.dropPosition.set(null);
|
|
1374
|
+
this.table.draggedRowIndex = null;
|
|
1375
|
+
}
|
|
1376
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableReorderableRow, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1377
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.8", type: UiTableReorderableRow, isStandalone: true, selector: "[uiReorderableRow]", inputs: { index: { classPropertyName: "index", publicName: "uiReorderableRow", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "dragstart": "onDragStart($event)", "dragover": "onDragOver($event)", "dragleave": "onDragLeave()", "drop": "onDrop($event)", "dragend": "onDragEnd()" }, properties: { "attr.draggable": "true", "class._drop-above": "dropPosition() === \"above\"", "class._drop-below": "dropPosition() === \"below\"" }, classAttribute: "ui-table-reorderable-row" }, ngImport: i0 }); }
|
|
1378
|
+
}
|
|
1379
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiTableReorderableRow, decorators: [{
|
|
1380
|
+
type: Directive,
|
|
1381
|
+
args: [{
|
|
1382
|
+
selector: '[uiReorderableRow]',
|
|
1383
|
+
host: {
|
|
1384
|
+
class: 'ui-table-reorderable-row',
|
|
1385
|
+
'[attr.draggable]': 'true',
|
|
1386
|
+
'[class._drop-above]': 'dropPosition() === "above"',
|
|
1387
|
+
'[class._drop-below]': 'dropPosition() === "below"',
|
|
1388
|
+
'(dragstart)': 'onDragStart($event)',
|
|
1389
|
+
'(dragover)': 'onDragOver($event)',
|
|
1390
|
+
'(dragleave)': 'onDragLeave()',
|
|
1391
|
+
'(drop)': 'onDrop($event)',
|
|
1392
|
+
'(dragend)': 'onDragEnd()',
|
|
1393
|
+
},
|
|
1394
|
+
}]
|
|
1395
|
+
}], propDecorators: { index: [{ type: i0.Input, args: [{ isSignal: true, alias: "uiReorderableRow", required: true }] }] } });
|
|
1396
|
+
|
|
1397
|
+
/*
|
|
1398
|
+
* Public API Surface of ui-kit/ui-table
|
|
1399
|
+
*/
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Generated bundle index. Do not edit.
|
|
1403
|
+
*/
|
|
1404
|
+
|
|
1405
|
+
export { UiTable, UiTableCheckbox, UiTableFrozenColumn, UiTableHeaderCheckbox, UiTableRadio, UiTableReorderableRow, UiTableResizableColumn, UiTableRowToggler, UiTableSelectableRow, UiTableSortIcon, UiTableSortableColumn };
|
|
1406
|
+
//# sourceMappingURL=4sh-ui-kit-ui-table.mjs.map
|