@tailng-ui/primitives 0.41.0 → 0.42.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/package.json +2 -2
- package/src/lib/layout/index.d.ts +1 -0
- package/src/lib/layout/index.d.ts.map +1 -1
- package/src/lib/layout/index.js +1 -0
- package/src/lib/layout/index.js.map +1 -1
- package/src/lib/layout/table/__tests__/tng-table.test-harness.d.ts +300 -0
- package/src/lib/layout/table/__tests__/tng-table.test-harness.d.ts.map +1 -0
- package/src/lib/layout/table/__tests__/tng-table.test-harness.js +2492 -0
- package/src/lib/layout/table/__tests__/tng-table.test-harness.js.map +1 -0
- package/src/lib/layout/table/index.d.ts +6 -0
- package/src/lib/layout/table/index.d.ts.map +1 -0
- package/src/lib/layout/table/index.js +6 -0
- package/src/lib/layout/table/index.js.map +1 -0
- package/src/lib/layout/table/tng-table-render.d.ts +175 -0
- package/src/lib/layout/table/tng-table-render.d.ts.map +1 -0
- package/src/lib/layout/table/tng-table-render.js +304 -0
- package/src/lib/layout/table/tng-table-render.js.map +1 -0
- package/src/lib/layout/table/tng-table-sizing.d.ts +75 -0
- package/src/lib/layout/table/tng-table-sizing.d.ts.map +1 -0
- package/src/lib/layout/table/tng-table-sizing.js +361 -0
- package/src/lib/layout/table/tng-table-sizing.js.map +1 -0
- package/src/lib/layout/table/tng-table-sort.d.ts +53 -0
- package/src/lib/layout/table/tng-table-sort.d.ts.map +1 -0
- package/src/lib/layout/table/tng-table-sort.js +167 -0
- package/src/lib/layout/table/tng-table-sort.js.map +1 -0
- package/src/lib/layout/table/tng-table-virtual.d.ts +55 -0
- package/src/lib/layout/table/tng-table-virtual.d.ts.map +1 -0
- package/src/lib/layout/table/tng-table-virtual.js +250 -0
- package/src/lib/layout/table/tng-table-virtual.js.map +1 -0
- package/src/lib/layout/table/tng-table.d.ts +362 -0
- package/src/lib/layout/table/tng-table.d.ts.map +1 -0
- package/src/lib/layout/table/tng-table.js +1490 -0
- package/src/lib/layout/table/tng-table.js.map +1 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Directive, HostBinding, TemplateRef, computed, inject, input, } from '@angular/core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
function normalizeOptionalString(value) {
|
|
5
|
+
if (typeof value !== 'string') {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const trimmed = value.trim();
|
|
9
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
10
|
+
}
|
|
11
|
+
function isTemplateRefLike(value) {
|
|
12
|
+
return typeof value === 'object' && value !== null && 'createEmbeddedView' in value;
|
|
13
|
+
}
|
|
14
|
+
function resolveTemplateRef(value) {
|
|
15
|
+
if (isTemplateRefLike(value)) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
if (typeof value === 'object'
|
|
19
|
+
&& value !== null
|
|
20
|
+
&& 'tpl' in value
|
|
21
|
+
&& isTemplateRefLike(value.tpl)) {
|
|
22
|
+
return value.tpl;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function isIntlLocaleList(value) {
|
|
27
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === 'string');
|
|
28
|
+
}
|
|
29
|
+
function resolveIntlLocale(locale) {
|
|
30
|
+
if (isIntlLocaleList(locale)) {
|
|
31
|
+
return locale.slice();
|
|
32
|
+
}
|
|
33
|
+
return typeof locale === 'string' ? locale : undefined;
|
|
34
|
+
}
|
|
35
|
+
function formatTableText(value, context, formatter) {
|
|
36
|
+
if (formatter === null) {
|
|
37
|
+
return Object.freeze({
|
|
38
|
+
context,
|
|
39
|
+
error: null,
|
|
40
|
+
text: resolveTngTableTextContent(value),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return Object.freeze({
|
|
45
|
+
context,
|
|
46
|
+
error: null,
|
|
47
|
+
text: formatter(value, context),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return Object.freeze({
|
|
52
|
+
context,
|
|
53
|
+
error: Object.freeze({ thrown: error }),
|
|
54
|
+
text: resolveTngTableTextContent(value),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function resolveTngTableTextContent(value) {
|
|
59
|
+
if (value === null || value === undefined) {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
if (typeof value === 'string') {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
if (typeof value === 'number'
|
|
66
|
+
|| typeof value === 'bigint'
|
|
67
|
+
|| typeof value === 'boolean') {
|
|
68
|
+
return String(value);
|
|
69
|
+
}
|
|
70
|
+
if (value instanceof Date) {
|
|
71
|
+
return value.toISOString();
|
|
72
|
+
}
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
export function createTngTableIntlNumberFormatter(locale, options) {
|
|
76
|
+
const formatter = new Intl.NumberFormat(resolveIntlLocale(locale), options);
|
|
77
|
+
return (value) => typeof value === 'number'
|
|
78
|
+
? formatter.format(value)
|
|
79
|
+
: resolveTngTableTextContent(value);
|
|
80
|
+
}
|
|
81
|
+
export function createTngTableIntlDateFormatter(locale, options) {
|
|
82
|
+
const formatter = new Intl.DateTimeFormat(resolveIntlLocale(locale), options);
|
|
83
|
+
return (value) => value instanceof Date
|
|
84
|
+
? formatter.format(value)
|
|
85
|
+
: resolveTngTableTextContent(value);
|
|
86
|
+
}
|
|
87
|
+
export function createTngTableIntlFormatter(options = {}) {
|
|
88
|
+
const dateFormatter = options.date === undefined
|
|
89
|
+
? null
|
|
90
|
+
: createTngTableIntlDateFormatter(options.locale, options.date);
|
|
91
|
+
const numberFormatter = options.number === undefined
|
|
92
|
+
? null
|
|
93
|
+
: createTngTableIntlNumberFormatter(options.locale, options.number);
|
|
94
|
+
return (value, context) => {
|
|
95
|
+
if (typeof value === 'number' && numberFormatter !== null) {
|
|
96
|
+
return numberFormatter(value, context);
|
|
97
|
+
}
|
|
98
|
+
if (value instanceof Date && dateFormatter !== null) {
|
|
99
|
+
return dateFormatter(value, context);
|
|
100
|
+
}
|
|
101
|
+
return resolveTngTableTextContent(value);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export class TngTableCellTpl {
|
|
105
|
+
tpl = inject(TemplateRef);
|
|
106
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableCellTpl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
107
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: TngTableCellTpl, isStandalone: true, selector: "ng-template[tngTableCellTpl]", exportAs: ["tngTableCellTpl"], ngImport: i0 });
|
|
108
|
+
}
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableCellTpl, decorators: [{
|
|
110
|
+
type: Directive,
|
|
111
|
+
args: [{
|
|
112
|
+
selector: 'ng-template[tngTableCellTpl]',
|
|
113
|
+
exportAs: 'tngTableCellTpl',
|
|
114
|
+
}]
|
|
115
|
+
}] });
|
|
116
|
+
export class TngTableHeaderTpl {
|
|
117
|
+
tpl = inject(TemplateRef);
|
|
118
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableHeaderTpl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
119
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: TngTableHeaderTpl, isStandalone: true, selector: "ng-template[tngTableHeaderTpl]", exportAs: ["tngTableHeaderTpl"], ngImport: i0 });
|
|
120
|
+
}
|
|
121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableHeaderTpl, decorators: [{
|
|
122
|
+
type: Directive,
|
|
123
|
+
args: [{
|
|
124
|
+
selector: 'ng-template[tngTableHeaderTpl]',
|
|
125
|
+
exportAs: 'tngTableHeaderTpl',
|
|
126
|
+
}]
|
|
127
|
+
}] });
|
|
128
|
+
export class TngTableFooterTpl {
|
|
129
|
+
tpl = inject(TemplateRef);
|
|
130
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableFooterTpl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
131
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.1", type: TngTableFooterTpl, isStandalone: true, selector: "ng-template[tngTableFooterTpl]", exportAs: ["tngTableFooterTpl"], ngImport: i0 });
|
|
132
|
+
}
|
|
133
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableFooterTpl, decorators: [{
|
|
134
|
+
type: Directive,
|
|
135
|
+
args: [{
|
|
136
|
+
selector: 'ng-template[tngTableFooterTpl]',
|
|
137
|
+
exportAs: 'tngTableFooterTpl',
|
|
138
|
+
}]
|
|
139
|
+
}] });
|
|
140
|
+
export class TngTableCellOutlet {
|
|
141
|
+
columnId = input(null, { ...(ngDevMode ? { debugName: "columnId" } : {}), transform: (value) => normalizeOptionalString(value) });
|
|
142
|
+
formatter = input(null, ...(ngDevMode ? [{ debugName: "formatter" }] : []));
|
|
143
|
+
row = input(null, ...(ngDevMode ? [{ debugName: "row" }] : []));
|
|
144
|
+
rowId = input(null, { ...(ngDevMode ? { debugName: "rowId" } : {}), transform: normalizeOptionalString });
|
|
145
|
+
template = input(null, ...(ngDevMode ? [{ debugName: "template" }] : []));
|
|
146
|
+
value = input(null, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
147
|
+
context = computed(() => Object.freeze({
|
|
148
|
+
$implicit: this.value(),
|
|
149
|
+
columnId: this.columnId(),
|
|
150
|
+
row: this.row(),
|
|
151
|
+
rowId: this.rowId(),
|
|
152
|
+
value: this.value(),
|
|
153
|
+
}), ...(ngDevMode ? [{ debugName: "context" }] : []));
|
|
154
|
+
renderState = computed(() => formatTableText(this.value(), this.context(), this.formatter()), ...(ngDevMode ? [{ debugName: "renderState" }] : []));
|
|
155
|
+
resolvedTemplate = computed(() => resolveTemplateRef(this.template()), ...(ngDevMode ? [{ debugName: "resolvedTemplate" }] : []));
|
|
156
|
+
get dataFormatErrorAttr() {
|
|
157
|
+
return this.resolvedTemplate() === null && this.renderState().error !== null ? '' : null;
|
|
158
|
+
}
|
|
159
|
+
dataSlot = 'table-cell-outlet';
|
|
160
|
+
getFormatError() {
|
|
161
|
+
return this.renderState().error?.thrown ?? null;
|
|
162
|
+
}
|
|
163
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableCellOutlet, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
164
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.1", type: TngTableCellOutlet, isStandalone: true, selector: "tng-table-cell-outlet", inputs: { columnId: { classPropertyName: "columnId", publicName: "columnId", isSignal: true, isRequired: false, transformFunction: null }, formatter: { classPropertyName: "formatter", publicName: "formatter", isSignal: true, isRequired: false, transformFunction: null }, row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: false, transformFunction: null }, rowId: { classPropertyName: "rowId", publicName: "rowId", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-format-error": "this.dataFormatErrorAttr", "attr.data-slot": "this.dataSlot" } }, exportAs: ["tngTableCellOutlet"], ngImport: i0, template: `
|
|
165
|
+
@if (resolvedTemplate(); as templateRef) {
|
|
166
|
+
<ng-container
|
|
167
|
+
[ngTemplateOutlet]="templateRef"
|
|
168
|
+
[ngTemplateOutletContext]="context()"
|
|
169
|
+
/>
|
|
170
|
+
} @else {
|
|
171
|
+
{{ renderState().text }}
|
|
172
|
+
}
|
|
173
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
174
|
+
}
|
|
175
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableCellOutlet, decorators: [{
|
|
176
|
+
type: Component,
|
|
177
|
+
args: [{
|
|
178
|
+
selector: 'tng-table-cell-outlet',
|
|
179
|
+
exportAs: 'tngTableCellOutlet',
|
|
180
|
+
imports: [NgTemplateOutlet],
|
|
181
|
+
template: `
|
|
182
|
+
@if (resolvedTemplate(); as templateRef) {
|
|
183
|
+
<ng-container
|
|
184
|
+
[ngTemplateOutlet]="templateRef"
|
|
185
|
+
[ngTemplateOutletContext]="context()"
|
|
186
|
+
/>
|
|
187
|
+
} @else {
|
|
188
|
+
{{ renderState().text }}
|
|
189
|
+
}
|
|
190
|
+
`,
|
|
191
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
192
|
+
}]
|
|
193
|
+
}], propDecorators: { columnId: [{ type: i0.Input, args: [{ isSignal: true, alias: "columnId", required: false }] }], formatter: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatter", required: false }] }], row: [{ type: i0.Input, args: [{ isSignal: true, alias: "row", required: false }] }], rowId: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowId", required: false }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], dataFormatErrorAttr: [{
|
|
194
|
+
type: HostBinding,
|
|
195
|
+
args: ['attr.data-format-error']
|
|
196
|
+
}], dataSlot: [{
|
|
197
|
+
type: HostBinding,
|
|
198
|
+
args: ['attr.data-slot']
|
|
199
|
+
}] } });
|
|
200
|
+
export class TngTableHeaderOutlet {
|
|
201
|
+
columnId = input(null, { ...(ngDevMode ? { debugName: "columnId" } : {}), transform: (value) => normalizeOptionalString(value) });
|
|
202
|
+
label = input(null, { ...(ngDevMode ? { debugName: "label" } : {}), transform: normalizeOptionalString });
|
|
203
|
+
template = input(null, ...(ngDevMode ? [{ debugName: "template" }] : []));
|
|
204
|
+
labelText = computed(() => this.label() ?? this.columnId() ?? '', ...(ngDevMode ? [{ debugName: "labelText" }] : []));
|
|
205
|
+
context = computed(() => Object.freeze({
|
|
206
|
+
$implicit: this.labelText(),
|
|
207
|
+
columnId: this.columnId(),
|
|
208
|
+
label: this.labelText(),
|
|
209
|
+
}), ...(ngDevMode ? [{ debugName: "context" }] : []));
|
|
210
|
+
resolvedTemplate = computed(() => resolveTemplateRef(this.template()), ...(ngDevMode ? [{ debugName: "resolvedTemplate" }] : []));
|
|
211
|
+
dataSlot = 'table-header-outlet';
|
|
212
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableHeaderOutlet, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
213
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.1", type: TngTableHeaderOutlet, isStandalone: true, selector: "tng-table-header-outlet", inputs: { columnId: { classPropertyName: "columnId", publicName: "columnId", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-slot": "this.dataSlot" } }, exportAs: ["tngTableHeaderOutlet"], ngImport: i0, template: `
|
|
214
|
+
@if (resolvedTemplate(); as templateRef) {
|
|
215
|
+
<ng-container
|
|
216
|
+
[ngTemplateOutlet]="templateRef"
|
|
217
|
+
[ngTemplateOutletContext]="context()"
|
|
218
|
+
/>
|
|
219
|
+
} @else {
|
|
220
|
+
{{ labelText() }}
|
|
221
|
+
}
|
|
222
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
223
|
+
}
|
|
224
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableHeaderOutlet, decorators: [{
|
|
225
|
+
type: Component,
|
|
226
|
+
args: [{
|
|
227
|
+
selector: 'tng-table-header-outlet',
|
|
228
|
+
exportAs: 'tngTableHeaderOutlet',
|
|
229
|
+
imports: [NgTemplateOutlet],
|
|
230
|
+
template: `
|
|
231
|
+
@if (resolvedTemplate(); as templateRef) {
|
|
232
|
+
<ng-container
|
|
233
|
+
[ngTemplateOutlet]="templateRef"
|
|
234
|
+
[ngTemplateOutletContext]="context()"
|
|
235
|
+
/>
|
|
236
|
+
} @else {
|
|
237
|
+
{{ labelText() }}
|
|
238
|
+
}
|
|
239
|
+
`,
|
|
240
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
241
|
+
}]
|
|
242
|
+
}], propDecorators: { columnId: [{ type: i0.Input, args: [{ isSignal: true, alias: "columnId", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }], dataSlot: [{
|
|
243
|
+
type: HostBinding,
|
|
244
|
+
args: ['attr.data-slot']
|
|
245
|
+
}] } });
|
|
246
|
+
export class TngTableFooterOutlet {
|
|
247
|
+
columnId = input(null, { ...(ngDevMode ? { debugName: "columnId" } : {}), transform: (value) => normalizeOptionalString(value) });
|
|
248
|
+
formatter = input(null, ...(ngDevMode ? [{ debugName: "formatter" }] : []));
|
|
249
|
+
items = input([], ...(ngDevMode ? [{ debugName: "items" }] : []));
|
|
250
|
+
template = input(null, ...(ngDevMode ? [{ debugName: "template" }] : []));
|
|
251
|
+
value = input(null, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
252
|
+
context = computed(() => Object.freeze({
|
|
253
|
+
$implicit: this.value(),
|
|
254
|
+
columnId: this.columnId(),
|
|
255
|
+
items: this.items(),
|
|
256
|
+
value: this.value(),
|
|
257
|
+
}), ...(ngDevMode ? [{ debugName: "context" }] : []));
|
|
258
|
+
renderState = computed(() => formatTableText(this.value(), this.context(), this.formatter()), ...(ngDevMode ? [{ debugName: "renderState" }] : []));
|
|
259
|
+
resolvedTemplate = computed(() => resolveTemplateRef(this.template()), ...(ngDevMode ? [{ debugName: "resolvedTemplate" }] : []));
|
|
260
|
+
get dataFormatErrorAttr() {
|
|
261
|
+
return this.resolvedTemplate() === null && this.renderState().error !== null ? '' : null;
|
|
262
|
+
}
|
|
263
|
+
dataSlot = 'table-footer-outlet';
|
|
264
|
+
getFormatError() {
|
|
265
|
+
return this.renderState().error?.thrown ?? null;
|
|
266
|
+
}
|
|
267
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableFooterOutlet, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
268
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.1", type: TngTableFooterOutlet, isStandalone: true, selector: "tng-table-footer-outlet", inputs: { columnId: { classPropertyName: "columnId", publicName: "columnId", isSignal: true, isRequired: false, transformFunction: null }, formatter: { classPropertyName: "formatter", publicName: "formatter", isSignal: true, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-format-error": "this.dataFormatErrorAttr", "attr.data-slot": "this.dataSlot" } }, exportAs: ["tngTableFooterOutlet"], ngImport: i0, template: `
|
|
269
|
+
@if (resolvedTemplate(); as templateRef) {
|
|
270
|
+
<ng-container
|
|
271
|
+
[ngTemplateOutlet]="templateRef"
|
|
272
|
+
[ngTemplateOutletContext]="context()"
|
|
273
|
+
/>
|
|
274
|
+
} @else {
|
|
275
|
+
{{ renderState().text }}
|
|
276
|
+
}
|
|
277
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
278
|
+
}
|
|
279
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TngTableFooterOutlet, decorators: [{
|
|
280
|
+
type: Component,
|
|
281
|
+
args: [{
|
|
282
|
+
selector: 'tng-table-footer-outlet',
|
|
283
|
+
exportAs: 'tngTableFooterOutlet',
|
|
284
|
+
imports: [NgTemplateOutlet],
|
|
285
|
+
template: `
|
|
286
|
+
@if (resolvedTemplate(); as templateRef) {
|
|
287
|
+
<ng-container
|
|
288
|
+
[ngTemplateOutlet]="templateRef"
|
|
289
|
+
[ngTemplateOutletContext]="context()"
|
|
290
|
+
/>
|
|
291
|
+
} @else {
|
|
292
|
+
{{ renderState().text }}
|
|
293
|
+
}
|
|
294
|
+
`,
|
|
295
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
296
|
+
}]
|
|
297
|
+
}], propDecorators: { columnId: [{ type: i0.Input, args: [{ isSignal: true, alias: "columnId", required: false }] }], formatter: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatter", required: false }] }], items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], dataFormatErrorAttr: [{
|
|
298
|
+
type: HostBinding,
|
|
299
|
+
args: ['attr.data-format-error']
|
|
300
|
+
}], dataSlot: [{
|
|
301
|
+
type: HostBinding,
|
|
302
|
+
args: ['attr.data-slot']
|
|
303
|
+
}] } });
|
|
304
|
+
//# sourceMappingURL=tng-table-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tng-table-render.js","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/layout/table/tng-table-render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACX,QAAQ,EACR,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;;AAyDvB,SAAS,uBAAuB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC;AAED,SAAS,iBAAiB,CAAW,KAAc;IACjD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,oBAAoB,IAAI,KAAK,CAAC;AACtF,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAc;IAEd,IAAI,iBAAiB,CAAW,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IACE,OAAO,KAAK,KAAK,QAAQ;WACtB,KAAK,KAAK,IAAI;WACd,KAAK,IAAI,KAAK;WACd,iBAAiB,CAAW,KAAK,CAAC,GAAG,CAAC,EACzC,CAAC;QACD,OAAO,KAAK,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AAgB,GAAG,QAAQ,CAAC,GAAG,EAAE,CAClD,kBAAkB,CAA2D,IAAI,CAAC,QAAQ,EAAE,CAAC,4DAC9F,CAAC;IAEF,IACc,mBAAmB;QAC/B,OAAO,IAAI,CAAC,gBAAgB,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3F,CAAC;IAGkB,QAAQ,GAAG,qBAA8B,CAAC;IAEtD,cAAc;QACnB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,IAAI,CAAC;IAClD,CAAC;uGA1CU,oBAAoB;2FAApB,oBAAoB,42BAZrB;;;;;;;;;GAST,4DAVS,gBAAgB;;2FAaf,oBAAoB;kBAhBhC,SAAS;mBAAC;oBACT,QAAQ,EAAE,yBAAyB;oBACnC,QAAQ,EAAE,sBAAsB;oBAChC,OAAO,EAAE,CAAC,gBAAgB,CAAC;oBAC3B,QAAQ,EAAE;;;;;;;;;GAST;oBACD,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD;;sBAiCE,WAAW;uBAAC,wBAAwB;;sBAKpC,WAAW;uBAAC,gBAAgB","sourcesContent":["import { NgTemplateOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n Directive,\n HostBinding,\n TemplateRef,\n computed,\n inject,\n input,\n} from '@angular/core';\n\nexport type TngTableCellTplContext<\n TRow = unknown,\n TValue = unknown,\n TColumnId extends string = string,\n> = Readonly<{\n $implicit: TValue;\n columnId: TColumnId | null;\n row: TRow;\n rowId: string | null;\n value: TValue;\n}>;\n\nexport type TngTableHeaderTplContext<TColumnId extends string = string> = Readonly<{\n $implicit: string;\n columnId: TColumnId | null;\n label: string;\n}>;\n\nexport type TngTableFooterTplContext<\n TRow = unknown,\n TValue = unknown,\n TColumnId extends string = string,\n> = Readonly<{\n $implicit: TValue;\n columnId: TColumnId | null;\n items: readonly TRow[];\n value: TValue;\n}>;\n\nexport type TngTableCellFormatter<\n TRow = unknown,\n TValue = unknown,\n TColumnId extends string = string,\n> = (value: TValue, context: TngTableCellTplContext<TRow, TValue, TColumnId>) => string;\n\nexport type TngTableFooterFormatter<\n TRow = unknown,\n TValue = unknown,\n TColumnId extends string = string,\n> = (value: TValue, context: TngTableFooterTplContext<TRow, TValue, TColumnId>) => string;\n\nexport type TngTableIntlLocale = readonly string[] | string | undefined;\nexport type TngTableIntlFormatterOptions = Readonly<{\n date?: Intl.DateTimeFormatOptions;\n locale?: TngTableIntlLocale;\n number?: Intl.NumberFormatOptions;\n}>;\n\ntype TngTableFormattedTextState<TContext> = Readonly<{\n error: Readonly<{ thrown: unknown }> | null;\n text: string;\n context: TContext;\n}>;\ntype TngTableValueFormatter<TContext> = (value: unknown, context: TContext) => string;\n\nfunction normalizeOptionalString(value: unknown): string | null {\n if (typeof value !== 'string') {\n return null;\n }\n\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction isTemplateRefLike<TContext>(value: unknown): value is TemplateRef<TContext> {\n return typeof value === 'object' && value !== null && 'createEmbeddedView' in value;\n}\n\nfunction resolveTemplateRef<TContext>(\n value: unknown,\n): TemplateRef<TContext> | null {\n if (isTemplateRefLike<TContext>(value)) {\n return value;\n }\n\n if (\n typeof value === 'object'\n && value !== null\n && 'tpl' in value\n && isTemplateRefLike<TContext>(value.tpl)\n ) {\n return value.tpl;\n }\n\n return null;\n}\n\nfunction isIntlLocaleList(value: TngTableIntlLocale): value is readonly string[] {\n return Array.isArray(value) && value.every((entry) => typeof entry === 'string');\n}\n\nfunction resolveIntlLocale(locale: TngTableIntlLocale): string | string[] | undefined {\n if (isIntlLocaleList(locale)) {\n return locale.slice();\n }\n\n return typeof locale === 'string' ? locale : undefined;\n}\n\nfunction formatTableText<TValue, TContext>(\n value: TValue | null,\n context: TContext,\n formatter: ((value: TValue | null, context: TContext) => string) | null,\n): TngTableFormattedTextState<TContext> {\n if (formatter === null) {\n return Object.freeze({\n context,\n error: null,\n text: resolveTngTableTextContent(value),\n });\n }\n\n try {\n return Object.freeze({\n context,\n error: null,\n text: formatter(value, context),\n });\n } catch (error: unknown) {\n return Object.freeze({\n context,\n error: Object.freeze({ thrown: error }),\n text: resolveTngTableTextContent(value),\n });\n }\n}\n\nexport function resolveTngTableTextContent(value: unknown): string {\n if (value === null || value === undefined) {\n return '';\n }\n\n if (typeof value === 'string') {\n return value;\n }\n\n if (\n typeof value === 'number'\n || typeof value === 'bigint'\n || typeof value === 'boolean'\n ) {\n return String(value);\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n return '';\n}\n\nexport function createTngTableIntlNumberFormatter<TContext = unknown>(\n locale?: TngTableIntlLocale,\n options?: Intl.NumberFormatOptions,\n): TngTableValueFormatter<TContext> {\n const formatter = new Intl.NumberFormat(resolveIntlLocale(locale), options);\n\n return (value: unknown): string =>\n typeof value === 'number'\n ? formatter.format(value)\n : resolveTngTableTextContent(value);\n}\n\nexport function createTngTableIntlDateFormatter<TContext = unknown>(\n locale?: TngTableIntlLocale,\n options?: Intl.DateTimeFormatOptions,\n): TngTableValueFormatter<TContext> {\n const formatter = new Intl.DateTimeFormat(resolveIntlLocale(locale), options);\n\n return (value: unknown): string =>\n value instanceof Date\n ? formatter.format(value)\n : resolveTngTableTextContent(value);\n}\n\nexport function createTngTableIntlFormatter<TContext = unknown>(\n options: TngTableIntlFormatterOptions = {},\n): TngTableValueFormatter<TContext> {\n const dateFormatter = options.date === undefined\n ? null\n : createTngTableIntlDateFormatter<TContext>(options.locale, options.date);\n const numberFormatter = options.number === undefined\n ? null\n : createTngTableIntlNumberFormatter<TContext>(options.locale, options.number);\n\n return (value: unknown, context: TContext): string => {\n if (typeof value === 'number' && numberFormatter !== null) {\n return numberFormatter(value, context);\n }\n\n if (value instanceof Date && dateFormatter !== null) {\n return dateFormatter(value, context);\n }\n\n return resolveTngTableTextContent(value);\n };\n}\n\n@Directive({\n selector: 'ng-template[tngTableCellTpl]',\n exportAs: 'tngTableCellTpl',\n})\nexport class TngTableCellTpl<\n TRow = unknown,\n TValue = unknown,\n TColumnId extends string = string,\n> {\n public readonly tpl = inject<TemplateRef<TngTableCellTplContext<TRow, TValue, TColumnId>>>(\n TemplateRef,\n );\n}\n\n@Directive({\n selector: 'ng-template[tngTableHeaderTpl]',\n exportAs: 'tngTableHeaderTpl',\n})\nexport class TngTableHeaderTpl<TColumnId extends string = string> {\n public readonly tpl = inject<TemplateRef<TngTableHeaderTplContext<TColumnId>>>(TemplateRef);\n}\n\n@Directive({\n selector: 'ng-template[tngTableFooterTpl]',\n exportAs: 'tngTableFooterTpl',\n})\nexport class TngTableFooterTpl<\n TRow = unknown,\n TValue = unknown,\n TColumnId extends string = string,\n> {\n public readonly tpl = inject<TemplateRef<TngTableFooterTplContext<TRow, TValue, TColumnId>>>(\n TemplateRef,\n );\n}\n\n@Component({\n selector: 'tng-table-cell-outlet',\n exportAs: 'tngTableCellOutlet',\n imports: [NgTemplateOutlet],\n template: `\n @if (resolvedTemplate(); as templateRef) {\n <ng-container\n [ngTemplateOutlet]=\"templateRef\"\n [ngTemplateOutletContext]=\"context()\"\n />\n } @else {\n {{ renderState().text }}\n }\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TngTableCellOutlet<\n TRow = unknown,\n TValue = unknown,\n TColumnId extends string = string,\n> {\n public readonly columnId = input<TColumnId | null, unknown>(null, {\n transform: (value: unknown): TColumnId | null => normalizeOptionalString(value) as TColumnId | null,\n });\n public readonly formatter = input<TngTableCellFormatter<TRow, TValue | null, TColumnId> | null>(null);\n public readonly row = input<TRow | null>(null);\n public readonly rowId = input<string | null, unknown>(null, {\n transform: normalizeOptionalString,\n });\n public readonly template = input<\n | TemplateRef<TngTableCellTplContext<TRow, TValue | null, TColumnId>>\n | TngTableCellTpl<TRow, TValue | null, TColumnId>\n | null\n >(null);\n public readonly value = input<TValue | null>(null);\n\n protected readonly context = computed<TngTableCellTplContext<TRow, TValue | null, TColumnId>>(() =>\n Object.freeze({\n $implicit: this.value(),\n columnId: this.columnId(),\n row: this.row() as TRow,\n rowId: this.rowId(),\n value: this.value(),\n }),\n );\n protected readonly renderState = computed<\n TngTableFormattedTextState<TngTableCellTplContext<TRow, TValue | null, TColumnId>>\n >(() => formatTableText(this.value(), this.context(), this.formatter()));\n protected readonly resolvedTemplate = computed(() =>\n resolveTemplateRef<TngTableCellTplContext<TRow, TValue | null, TColumnId>>(this.template()),\n );\n\n @HostBinding('attr.data-format-error')\n protected get dataFormatErrorAttr(): '' | null {\n return this.resolvedTemplate() === null && this.renderState().error !== null ? '' : null;\n }\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'table-cell-outlet' as const;\n\n public getFormatError(): unknown {\n return this.renderState().error?.thrown ?? null;\n }\n}\n\n@Component({\n selector: 'tng-table-header-outlet',\n exportAs: 'tngTableHeaderOutlet',\n imports: [NgTemplateOutlet],\n template: `\n @if (resolvedTemplate(); as templateRef) {\n <ng-container\n [ngTemplateOutlet]=\"templateRef\"\n [ngTemplateOutletContext]=\"context()\"\n />\n } @else {\n {{ labelText() }}\n }\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TngTableHeaderOutlet<TColumnId extends string = string> {\n public readonly columnId = input<TColumnId | null, unknown>(null, {\n transform: (value: unknown): TColumnId | null => normalizeOptionalString(value) as TColumnId | null,\n });\n public readonly label = input<string | null, unknown>(null, {\n transform: normalizeOptionalString,\n });\n public readonly template = input<\n TemplateRef<TngTableHeaderTplContext<TColumnId>> | TngTableHeaderTpl<TColumnId> | null\n >(null);\n\n protected readonly labelText = computed(() => this.label() ?? this.columnId() ?? '');\n protected readonly context = computed<TngTableHeaderTplContext<TColumnId>>(() =>\n Object.freeze({\n $implicit: this.labelText(),\n columnId: this.columnId(),\n label: this.labelText(),\n }),\n );\n protected readonly resolvedTemplate = computed(() =>\n resolveTemplateRef<TngTableHeaderTplContext<TColumnId>>(this.template()),\n );\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'table-header-outlet' as const;\n}\n\n@Component({\n selector: 'tng-table-footer-outlet',\n exportAs: 'tngTableFooterOutlet',\n imports: [NgTemplateOutlet],\n template: `\n @if (resolvedTemplate(); as templateRef) {\n <ng-container\n [ngTemplateOutlet]=\"templateRef\"\n [ngTemplateOutletContext]=\"context()\"\n />\n } @else {\n {{ renderState().text }}\n }\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TngTableFooterOutlet<\n TRow = unknown,\n TValue = unknown,\n TColumnId extends string = string,\n> {\n public readonly columnId = input<TColumnId | null, unknown>(null, {\n transform: (value: unknown): TColumnId | null => normalizeOptionalString(value) as TColumnId | null,\n });\n public readonly formatter = input<TngTableFooterFormatter<TRow, TValue | null, TColumnId> | null>(null);\n public readonly items = input<readonly TRow[]>([]);\n public readonly template = input<\n | TemplateRef<TngTableFooterTplContext<TRow, TValue | null, TColumnId>>\n | TngTableFooterTpl<TRow, TValue | null, TColumnId>\n | null\n >(null);\n public readonly value = input<TValue | null>(null);\n\n protected readonly context = computed<TngTableFooterTplContext<TRow, TValue | null, TColumnId>>(() =>\n Object.freeze({\n $implicit: this.value(),\n columnId: this.columnId(),\n items: this.items(),\n value: this.value(),\n }),\n );\n protected readonly renderState = computed<\n TngTableFormattedTextState<TngTableFooterTplContext<TRow, TValue | null, TColumnId>>\n >(() => formatTableText(this.value(), this.context(), this.formatter()));\n protected readonly resolvedTemplate = computed(() =>\n resolveTemplateRef<TngTableFooterTplContext<TRow, TValue | null, TColumnId>>(this.template()),\n );\n\n @HostBinding('attr.data-format-error')\n protected get dataFormatErrorAttr(): '' | null {\n return this.resolvedTemplate() === null && this.renderState().error !== null ? '' : null;\n }\n\n @HostBinding('attr.data-slot')\n protected readonly dataSlot = 'table-footer-outlet' as const;\n\n public getFormatError(): unknown {\n return this.renderState().error?.thrown ?? null;\n }\n}\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type OnDestroy, type OnInit } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export type TngTableColumnWidthMap = Readonly<Record<string, string>>;
|
|
4
|
+
export declare class TngTableColumnSizing {
|
|
5
|
+
private readonly columns;
|
|
6
|
+
private readonly table;
|
|
7
|
+
private uncontrolledWidths;
|
|
8
|
+
private resizingColumnId;
|
|
9
|
+
readonly widths: import("@angular/core").InputSignal<Record<string, unknown> | null | undefined>;
|
|
10
|
+
readonly columnWidthsChange: import("@angular/core").OutputEmitterRef<Readonly<Record<string, string>>>;
|
|
11
|
+
protected readonly dataColumnSizing: "";
|
|
12
|
+
getResolvedMaxWidth(column: TngTableColumn): string | null;
|
|
13
|
+
getResolvedMinWidth(column: TngTableColumn): string | null;
|
|
14
|
+
getResolvedWidth(column: TngTableColumn): string | null;
|
|
15
|
+
isResizing(columnId: string | null): boolean;
|
|
16
|
+
registerColumn(column: TngTableColumn): void;
|
|
17
|
+
resize(columnId: string, startWidth: number, delta: number): void;
|
|
18
|
+
resolveColumnPixelWidth(columnId: string): number;
|
|
19
|
+
stopResize(): void;
|
|
20
|
+
unregisterColumn(column: TngTableColumn): void;
|
|
21
|
+
private clampPixelWidth;
|
|
22
|
+
private clampWidthValue;
|
|
23
|
+
private commit;
|
|
24
|
+
private getCurrentWidths;
|
|
25
|
+
private resolveColumnDefaultWidth;
|
|
26
|
+
private resolveColumnMaxWidth;
|
|
27
|
+
private resolveColumnMinWidth;
|
|
28
|
+
private resolveMeasuredWidth;
|
|
29
|
+
private findColumnsById;
|
|
30
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TngTableColumnSizing, never>;
|
|
31
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<TngTableColumnSizing, "table[tngTable][tngTableColumnSizing]", ["tngTableColumnSizing"], { "widths": { "alias": "tngTableColumnWidths"; "required": false; "isSignal": true; }; }, { "columnWidthsChange": "columnWidthsChange"; }, never, never, true, never>;
|
|
32
|
+
}
|
|
33
|
+
export declare class TngTableColumn implements OnDestroy, OnInit {
|
|
34
|
+
private readonly cell;
|
|
35
|
+
private readonly headerCell;
|
|
36
|
+
private readonly hostRef;
|
|
37
|
+
private readonly sizing;
|
|
38
|
+
readonly columnId: import("@angular/core").InputSignalWithTransform<string | null, unknown>;
|
|
39
|
+
readonly defaultWidth: import("@angular/core").InputSignalWithTransform<string | null, unknown>;
|
|
40
|
+
readonly minWidth: import("@angular/core").InputSignalWithTransform<string | null, unknown>;
|
|
41
|
+
readonly maxWidth: import("@angular/core").InputSignalWithTransform<string | null, unknown>;
|
|
42
|
+
protected get dataColumnIdAttr(): string | null;
|
|
43
|
+
protected get dataColumnMaxWidthAttr(): string | null;
|
|
44
|
+
protected get dataColumnMinWidthAttr(): string | null;
|
|
45
|
+
protected get dataColumnWidthAttr(): string | null;
|
|
46
|
+
protected get maxWidthAttr(): string | null;
|
|
47
|
+
protected get minWidthAttr(): string | null;
|
|
48
|
+
protected get widthAttr(): string | null;
|
|
49
|
+
ngOnDestroy(): void;
|
|
50
|
+
ngOnInit(): void;
|
|
51
|
+
getColumnId(): string | null;
|
|
52
|
+
getDefaultWidth(): string | null;
|
|
53
|
+
getHostElement(): HTMLElement;
|
|
54
|
+
getMaxWidth(): string | null;
|
|
55
|
+
getMinWidth(): string | null;
|
|
56
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TngTableColumn, never>;
|
|
57
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<TngTableColumn, "th[tngTableColumn],td[tngTableColumn]", ["tngTableColumn"], { "columnId": { "alias": "tngTableColumn"; "required": false; "isSignal": true; }; "defaultWidth": { "alias": "tngTableColumnWidth"; "required": false; "isSignal": true; }; "minWidth": { "alias": "tngTableColumnMinWidth"; "required": false; "isSignal": true; }; "maxWidth": { "alias": "tngTableColumnMaxWidth"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
58
|
+
}
|
|
59
|
+
export declare class TngTableColumnResizer implements OnDestroy {
|
|
60
|
+
private readonly sizing;
|
|
61
|
+
private activeResize;
|
|
62
|
+
readonly columnId: import("@angular/core").InputSignalWithTransform<string | null, unknown>;
|
|
63
|
+
readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, string | boolean>;
|
|
64
|
+
protected readonly ariaOrientation: "vertical";
|
|
65
|
+
protected get dataResizingAttr(): '' | null;
|
|
66
|
+
protected readonly dataSlot: "table-column-resizer";
|
|
67
|
+
protected readonly cursor: "col-resize";
|
|
68
|
+
ngOnDestroy(): void;
|
|
69
|
+
protected onDocumentMouseMove(event: MouseEvent): void;
|
|
70
|
+
protected onDocumentMouseUp(): void;
|
|
71
|
+
protected onMouseDown(event: MouseEvent): void;
|
|
72
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TngTableColumnResizer, never>;
|
|
73
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<TngTableColumnResizer, "[tngTableColumnResizer]", ["tngTableColumnResizer"], { "columnId": { "alias": "tngTableColumnResizer"; "required": false; "isSignal": true; }; "disabled": { "alias": "tngTableColumnResizerDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=tng-table-sizing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tng-table-sizing.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/tailng-ui/primitives/src/lib/layout/table/tng-table-sizing.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,MAAM,EAMZ,MAAM,eAAe,CAAC;;AAGvB,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAkEtE,qBAIa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,kBAAkB,CAA8B;IACxD,OAAO,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