@sdcorejs/angular 19.2.13 → 19.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/STYLE-GUIDE.md +138 -10
- package/assets/scss/core/form.scss +18 -2
- package/assets/scss/core/utilities/_base.scss +3 -3
- package/assets/scss/themes/_presets.scss +52 -0
- package/assets/scss/themes/default.scss +39 -11
- package/assets/scss/themes/material-theme.scss +2 -2
- package/components/button/src/button.component.d.ts +5 -0
- package/components/file-explorer/index.d.ts +2 -0
- package/components/file-explorer/src/components/file-icon.component.d.ts +15 -0
- package/components/file-explorer/src/components/folder-tree.component.d.ts +29 -0
- package/components/file-explorer/src/components/item-list.component.d.ts +34 -0
- package/components/file-explorer/src/components/preview-panel.component.d.ts +52 -0
- package/components/file-explorer/src/components/transfer-panel.component.d.ts +29 -0
- package/components/file-explorer/src/file-explorer-icons.generated.d.ts +8 -0
- package/components/file-explorer/src/file-explorer.component.d.ts +135 -0
- package/components/file-explorer/src/file-explorer.model.d.ts +268 -0
- package/components/file-explorer/src/file-explorer.utils.d.ts +54 -0
- package/components/file-explorer/src/file-explorer.view-model.d.ts +90 -0
- package/components/index.d.ts +1 -0
- package/components/side-drawer/src/side-drawer.component.d.ts +12 -1
- package/components/tab/src/tab-group.component.d.ts +7 -1
- package/components/table/src/components/mobile-cards/mobile-cards.component.d.ts +6 -1
- package/components/table/src/directives/sd-aggregate-layout.directive.d.ts +17 -0
- package/components/table/src/models/index.d.ts +1 -0
- package/components/table/src/models/table-aggregate.model.d.ts +142 -0
- package/components/table/src/models/table-column.model.d.ts +29 -5
- package/components/table/src/models/table-option.model.d.ts +10 -0
- package/components/table/src/pipes/sd-aggregate-rows.pipe.d.ts +15 -0
- package/components/table/src/services/table-aggregate.util.d.ts +40 -0
- package/components/table/src/services/table-local/table-local.util.d.ts +1 -0
- package/components/table/src/table.component.d.ts +23 -0
- package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs +1 -1
- package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-button.mjs +12 -2
- package/fesm2022/sdcorejs-angular-components-button.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-file-explorer.mjs +2582 -0
- package/fesm2022/sdcorejs-angular-components-file-explorer.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs +3 -3
- package/fesm2022/sdcorejs-angular-components-form-generic.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-preview.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-preview.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs +91 -6
- package/fesm2022/sdcorejs-angular-components-side-drawer.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs +10 -4
- package/fesm2022/sdcorejs-angular-components-tab-router.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-tab.mjs +51 -2
- package/fesm2022/sdcorejs-angular-components-tab.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-table.mjs +501 -78
- package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components.mjs +1 -0
- package/fesm2022/sdcorejs-angular-components.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-forms-select.mjs +2 -2
- package/fesm2022/sdcorejs-angular-forms-select.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-i18n.mjs +430 -0
- package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-icon.mjs +6 -0
- package/fesm2022/sdcorejs-angular-modules-icon.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-layout.mjs +2 -2
- package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
- package/i18n/src/en.d.ts +85 -0
- package/package.json +9 -5
|
@@ -4,6 +4,7 @@ import type { SdTableItem } from '../../models/table-item.model';
|
|
|
4
4
|
import type { SdTableRowMobileDefContext } from '../../directives/sd-table-row-mobile-def.directive';
|
|
5
5
|
import { Command } from '../command/pipes/filter.pipe';
|
|
6
6
|
import { SdTableMobileAction } from './mobile-action.model';
|
|
7
|
+
import type { AggregateRow } from '../../services/table-aggregate.util';
|
|
7
8
|
import * as i0 from "@angular/core";
|
|
8
9
|
interface Card<T> {
|
|
9
10
|
row: SdTableItem<T>;
|
|
@@ -20,6 +21,10 @@ export declare class SdTableMobileCardsComponent<T = unknown> implements OnDestr
|
|
|
20
21
|
#private;
|
|
21
22
|
readonly table: import("@angular/core").InputSignal<SdTable<T>>;
|
|
22
23
|
readonly rows: import("@angular/core").InputSignal<SdTableItem<T>[]>;
|
|
24
|
+
readonly dataRows: import("@angular/core").InputSignal<SdTableItem<T>[] | undefined>;
|
|
25
|
+
readonly aggregateTemplate: import("@angular/core").InputSignal<TemplateRef<{
|
|
26
|
+
summary: AggregateRow<T>;
|
|
27
|
+
}> | undefined>;
|
|
23
28
|
readonly groupTemplate: import("@angular/core").InputSignal<TemplateRef<{
|
|
24
29
|
item: SdTableItem<T>;
|
|
25
30
|
}>>;
|
|
@@ -47,6 +52,6 @@ export declare class SdTableMobileCardsComponent<T = unknown> implements OnDestr
|
|
|
47
52
|
dragStart(): void;
|
|
48
53
|
ngOnDestroy(): void;
|
|
49
54
|
static ɵfac: i0.ɵɵFactoryDeclaration<SdTableMobileCardsComponent<any>, never>;
|
|
50
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<SdTableMobileCardsComponent<any>, "sd-table-mobile-cards", never, { "table": { "alias": "table"; "required": true; "isSignal": true; }; "rows": { "alias": "rows"; "required": true; "isSignal": true; }; "groupTemplate": { "alias": "groupTemplate"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
55
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SdTableMobileCardsComponent<any>, "sd-table-mobile-cards", never, { "table": { "alias": "table"; "required": true; "isSignal": true; }; "rows": { "alias": "rows"; "required": true; "isSignal": true; }; "dataRows": { "alias": "dataRows"; "required": false; "isSignal": true; }; "aggregateTemplate": { "alias": "aggregateTemplate"; "required": false; "isSignal": true; }; "groupTemplate": { "alias": "groupTemplate"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
51
56
|
}
|
|
52
57
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MatFooterRowDef } from '@angular/material/table';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/** Internal footer definition registered explicitly so dynamic rows retain their template order. */
|
|
4
|
+
export declare class SdTableFooterRowDefDirective extends MatFooterRowDef {
|
|
5
|
+
set sdTableFooterRowDef(value: Iterable<string>);
|
|
6
|
+
set sdTableFooterRowDefSticky(value: boolean);
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SdTableFooterRowDefDirective, never>;
|
|
8
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<SdTableFooterRowDefDirective, "[sdTableFooterRowDef]", never, { "sdTableFooterRowDef": { "alias": "sdTableFooterRowDef"; "required": false; }; "sdTableFooterRowDefSticky": { "alias": "sdTableFooterRowDefSticky"; "required": false; }; }, {}, never, never, true, never>;
|
|
9
|
+
static ngAcceptInputType_sdTableFooterRowDefSticky: unknown;
|
|
10
|
+
}
|
|
11
|
+
/** Re-measure stacked sticky footers when a consumer template changes its actual height. */
|
|
12
|
+
export declare class SdAggregateLayoutDirective {
|
|
13
|
+
readonly rows: import("@angular/core").Signal<readonly SdTableFooterRowDefDirective[]>;
|
|
14
|
+
constructor();
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SdAggregateLayoutDirective, never>;
|
|
16
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<SdAggregateLayoutDirective, "table[sdAggregateLayout]", never, {}, {}, ["rows"], never, true, never>;
|
|
17
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type * from './table-option.model';
|
|
2
2
|
export type * from './table-column.model';
|
|
3
|
+
export type * from './table-aggregate.model';
|
|
3
4
|
export type * from './table-command.model';
|
|
4
5
|
export type * from './table-option-tree.model';
|
|
5
6
|
export type { SdTableItem, SdTableMeta, SdTableDisplay } from './table-item.model';
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { TemplateRef } from '@angular/core';
|
|
2
|
+
import type { SdTableColumnNormal } from './table-column.model';
|
|
3
|
+
/** Numeric columns support every operation; date/datetime support COUNT/MIN/MAX; other data columns support COUNT. */
|
|
4
|
+
export type SdTableAggregateOperation = 'SUM' | 'AVERAGE' | 'COUNT' | 'MIN' | 'MAX';
|
|
5
|
+
/** Synchronous aggregate output. Strings render as text; HTML requires a template. Missing results render the table placeholder. */
|
|
6
|
+
export type SdTableAggregateResult = string | number | boolean | Date | null | undefined;
|
|
7
|
+
/** Metadata for the existing combined-field row group, never a synthetic data item. */
|
|
8
|
+
export interface SdTableAggregateGroup {
|
|
9
|
+
/** Stable key used by the table's group collapse state. */
|
|
10
|
+
readonly key: string;
|
|
11
|
+
/** Raw values of the fields that identify this group. */
|
|
12
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
13
|
+
}
|
|
14
|
+
/** Calculation metadata shared by callbacks and templates. Completeness is relative to the requested scope, not the database. */
|
|
15
|
+
export interface SdTableAggregateContext<T = unknown> {
|
|
16
|
+
/** Leaf data column whose raw field is aggregated; functional and parent header columns are excluded. */
|
|
17
|
+
readonly column: SdTableColumnNormal<T>;
|
|
18
|
+
/** Grand total, row-group subtotal, or descendants of a tree parent. */
|
|
19
|
+
readonly kind: 'total' | 'group' | 'tree';
|
|
20
|
+
/** Requested page or locally filtered dataset; never silently changed for server tables. */
|
|
21
|
+
readonly scope: 'page' | 'filtered';
|
|
22
|
+
/** Combined-field group metadata, present only for group subtotals. */
|
|
23
|
+
readonly group?: SdTableAggregateGroup;
|
|
24
|
+
/** Original parent data item, present only for tree subtotals; it is excluded from subtotal items. */
|
|
25
|
+
readonly parent?: T;
|
|
26
|
+
/** False during loading/error, unsupported server filtered scope, or when required lazy children are missing. A loaded server page can be complete. */
|
|
27
|
+
readonly isComplete: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Context for `TemplateRef`, including raw items and the optional calculated result. */
|
|
30
|
+
export interface SdTableAggregateTemplateContext<T = unknown, R = SdTableAggregateResult> extends SdTableAggregateContext<T> {
|
|
31
|
+
/** Implicit raw item array, identical to `items`; excludes group headers and summary rows. */
|
|
32
|
+
readonly $implicit: readonly T[];
|
|
33
|
+
/** Raw data in the requested scope. May be partial when `isComplete` is false. Never mutate it or its items. */
|
|
34
|
+
readonly items: readonly T[];
|
|
35
|
+
/** Calculation result; undefined for template-only configurations or incomplete built-ins. */
|
|
36
|
+
readonly value: R | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Pure synchronous calculation on original consumer data. Do not mutate items or call APIs.
|
|
40
|
+
* @param items Raw rows in scope, including available partial rows when context.isComplete is false.
|
|
41
|
+
* @param context Scope, column, group/tree metadata and completeness.
|
|
42
|
+
* @returns A synchronous display value. Promise/Observable results are unsupported. Strings are escaped.
|
|
43
|
+
* @example `aggregate: items => items.length` counts rows, unlike COUNT which counts nonempty field values.
|
|
44
|
+
*/
|
|
45
|
+
export type SdTableAggregateCallback<T = unknown, R extends SdTableAggregateResult = SdTableAggregateResult> = (items: readonly T[], context: SdTableAggregateContext<T>) => R;
|
|
46
|
+
/** Shared options; use SdTableColumnAggregate to require a calculation or template. */
|
|
47
|
+
export interface SdTableAggregateDefinition<T = unknown, O extends SdTableAggregateOperation = SdTableAggregateOperation> {
|
|
48
|
+
/**
|
|
49
|
+
* Built-in or pure synchronous callback. Templates receive its result without replacing the calculation.
|
|
50
|
+
* @defaultValue undefined (template-only value is undefined)
|
|
51
|
+
* @remarks COUNT excludes null/undefined, blank strings, empty arrays, nonfinite numbers and invalid Dates;
|
|
52
|
+
* it counts 0, false, {}, and [null], once per row. SUM/AVERAGE/MIN/MAX number use valid numeric values;
|
|
53
|
+
* AVERAGE divides by their number, not COUNT. Successful empty SUM/COUNT = 0; other empty built-ins = null.
|
|
54
|
+
* Numeric strings accepted by the existing number formatter are supported; booleans, blank strings,
|
|
55
|
+
* nonfinite values and locale currency strings are excluded. Date MIN/MAX use Date, native-parsable
|
|
56
|
+
* date strings (including timezone offsets) or epoch milliseconds, matching local sorting.
|
|
57
|
+
* Results use table number/date formatters; COUNT uses integer formatting. Missing values display `--`.
|
|
58
|
+
* Incomplete built-ins return undefined; callbacks inspect isComplete and may describe partial data.
|
|
59
|
+
* @example `{ calculate: 'SUM' }`
|
|
60
|
+
*/
|
|
61
|
+
calculate?: O | SdTableAggregateCallback<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Custom aggregate HTML. Overrides rendering, not calculation; template-only value is undefined.
|
|
64
|
+
* @defaultValue undefined (safe text rendered with the table formatters)
|
|
65
|
+
* @remarks Read the query only after the template exists. The example uses a static query and initializes
|
|
66
|
+
* table options in ngOnInit, avoiding an undefined TemplateRef in the column definition.
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
|
70
|
+
* import { DecimalPipe } from '@angular/common';
|
|
71
|
+
* import { SdTable, SdTableOption, SdTableAggregateTemplateContext } from '@sdcorejs/angular/components/table';
|
|
72
|
+
* interface Order { amount: number; }
|
|
73
|
+
* @Component({
|
|
74
|
+
* selector: 'app-order-summary',
|
|
75
|
+
* imports: [SdTable, DecimalPipe],
|
|
76
|
+
* template: `
|
|
77
|
+
* <ng-template #summary let-items let-value="value" let-kind="kind" let-isComplete="isComplete">
|
|
78
|
+
* @if (isComplete) {
|
|
79
|
+
* <strong>{{ value | number:'1.0-2' }}</strong>
|
|
80
|
+
* <small>{{ kind }} · {{ items.length }} bản ghi</small>
|
|
81
|
+
* } @else { <span>Chưa đủ dữ liệu</span> }
|
|
82
|
+
* </ng-template>
|
|
83
|
+
* @if (option) { <sd-table [option]="option" /> }
|
|
84
|
+
* `,
|
|
85
|
+
* })
|
|
86
|
+
* export class OrderSummary implements OnInit {
|
|
87
|
+
* @ViewChild('summary', { static: true }) summary!: TemplateRef<SdTableAggregateTemplateContext<Order>>;
|
|
88
|
+
* option?: SdTableOption<Order>;
|
|
89
|
+
* ngOnInit(): void {
|
|
90
|
+
* this.option = {
|
|
91
|
+
* type: 'local', items: () => [{ amount: 40 }, { amount: 60 }],
|
|
92
|
+
* columns: [{ field: 'amount', title: 'Amount', type: 'number',
|
|
93
|
+
* aggregate: { calculate: 'SUM', templateRef: this.summary } }],
|
|
94
|
+
* };
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
* Remove calculate for a template-only summary; then use items/context because value is undefined.
|
|
99
|
+
*/
|
|
100
|
+
templateRef?: TemplateRef<SdTableAggregateTemplateContext<T>>;
|
|
101
|
+
}
|
|
102
|
+
/** Column shorthand or nonempty object. Number/date operation restrictions are supplied by the column discriminant. */
|
|
103
|
+
export type SdTableColumnAggregate<T = unknown, O extends SdTableAggregateOperation = SdTableAggregateOperation> = O | SdTableAggregateCallback<T> | (SdTableAggregateDefinition<T, O> & (Required<Pick<SdTableAggregateDefinition<T, O>, 'templateRef'>> | (Required<Pick<SdTableAggregateDefinition<T, O>, 'calculate'>> & {
|
|
104
|
+
templateRef?: never;
|
|
105
|
+
})));
|
|
106
|
+
/** Selects data scope and optional subtotals; any visible aggregate column automatically enables the total row. */
|
|
107
|
+
export interface SdTableOptionAggregate {
|
|
108
|
+
/**
|
|
109
|
+
* page = current page after filtering; filtered = all locally filtered rows before pagination.
|
|
110
|
+
* @defaultValue 'page'
|
|
111
|
+
* @remarks Server filtered scope is unsupported: diagnostic + incomplete value, never a page fallback or an API request.
|
|
112
|
+
* @example For 50 matching local records with pageSize 10, page counts up to 10 values; filtered counts up to 50.
|
|
113
|
+
*/
|
|
114
|
+
scope?: 'page' | 'filtered';
|
|
115
|
+
/**
|
|
116
|
+
* Show a subtotal after each expanded row group. Collapse never changes the grand total.
|
|
117
|
+
* @defaultValue false
|
|
118
|
+
* @example `{ scope: 'page', group: true }` summarizes only each group's rows on this page.
|
|
119
|
+
*/
|
|
120
|
+
group?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Tree aggregation policy; does not enable option.tree. Ignored on non-tree tables.
|
|
123
|
+
* @defaultValue undefined (tree tables aggregate known leaves without branch subtotals)
|
|
124
|
+
* @example `{ tree: { items: 'roots' } }` totals root rows without requiring lazy descendants.
|
|
125
|
+
*/
|
|
126
|
+
tree?: {
|
|
127
|
+
/**
|
|
128
|
+
* roots = scope roots (subtotal: direct children); leaves = known descendant leaves;
|
|
129
|
+
* all = every node (subtotal: all descendants). The parent is excluded from its subtotal.
|
|
130
|
+
* @defaultValue 'leaves'
|
|
131
|
+
* @example Parent 100 with children 40 and 60 gives total roots=100, leaves=100, all=200.
|
|
132
|
+
* @remarks Missing lazy children make leaves/all incomplete; roots can remain complete. Never fetch children for aggregation.
|
|
133
|
+
*/
|
|
134
|
+
items?: 'roots' | 'leaves' | 'all';
|
|
135
|
+
/**
|
|
136
|
+
* Render a subtotal at the end of each expanded branch, using the selected items policy.
|
|
137
|
+
* @defaultValue false
|
|
138
|
+
* @example `{ tree: { items: 'leaves', subtotal: true } }` summarizes descendants without double-counting parents.
|
|
139
|
+
*/
|
|
140
|
+
subtotal?: boolean;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -3,7 +3,8 @@ import { SdBadge } from '@sdcorejs/angular/components/badge';
|
|
|
3
3
|
import type { SdSearch } from '@sdcorejs/angular/forms/models';
|
|
4
4
|
import { NestedKeyOf, Operator } from '@sdcorejs/utils/models';
|
|
5
5
|
import { SdUnwrapSignal } from '@sdcorejs/angular/utilities/models';
|
|
6
|
-
|
|
6
|
+
import type { SdTableAggregateOperation, SdTableColumnAggregate } from './table-aggregate.model';
|
|
7
|
+
export type SdTableColumn<T = unknown> = SdTableColumnText<T> | SdTableColumnNumber<T> | SdTableColumnBool<T> | SdTableColumnDate<T> | SdTableColumnTime<T> | SdTableColumnValues<T> | SdTableColumnLazyValues<T> | SdTableColumnChildren<T>;
|
|
7
8
|
/**
|
|
8
9
|
* Cột bảng dùng ở các API **không quan tâm kiểu hàng** — chúng chỉ đọc `field` / `type` / `hidden` /
|
|
9
10
|
* `filter` và không bao giờ chạm vào dữ liệu hàng (service filter, `SdConvertToPagingReq`, …).
|
|
@@ -44,7 +45,20 @@ interface ColumnCellOption {
|
|
|
44
45
|
type?: 'more' | 'tooltip';
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
interface SdTableColumnBase<T = unknown> {
|
|
48
|
+
interface SdTableColumnBase<T = unknown, O extends SdTableAggregateOperation = 'COUNT'> {
|
|
49
|
+
/**
|
|
50
|
+
* Independent summary above the existing footer. Omit to leave this column's summary cell empty.
|
|
51
|
+
* Number: SUM/AVERAGE/COUNT/MIN/MAX; date/datetime: COUNT/MIN/MAX; other data columns: COUNT.
|
|
52
|
+
* Callbacks receive raw readonly items and scope/completeness context; strings render as escaped text.
|
|
53
|
+
* @defaultValue undefined
|
|
54
|
+
* @remarks COUNT counts nonempty raw field values, not items.length. It excludes null/undefined,
|
|
55
|
+
* blank strings, empty arrays, nonfinite numbers and invalid Dates, but includes 0/false/{}/[null].
|
|
56
|
+
* Configure data scope/subtotals with option.aggregate; templates and calculations can be combined.
|
|
57
|
+
* @example `aggregate: 'SUM'`
|
|
58
|
+
* @example `aggregate: items => items.length`
|
|
59
|
+
* @see SdTableAggregateDefinition.templateRef for a complete Angular example.
|
|
60
|
+
*/
|
|
61
|
+
aggregate?: SdTableColumnAggregate<T, O>;
|
|
48
62
|
title: string | ColumnTitleOption;
|
|
49
63
|
cell?: ColumnCellOption;
|
|
50
64
|
width?: string;
|
|
@@ -80,7 +94,7 @@ interface SdTableColumnText<T = unknown> extends SdTableColumnBase<T> {
|
|
|
80
94
|
type: 'string';
|
|
81
95
|
useBadge?: UseBadgeFunc<T>;
|
|
82
96
|
}
|
|
83
|
-
interface SdTableColumnNumber<T = unknown> extends SdTableColumnBase<T> {
|
|
97
|
+
interface SdTableColumnNumber<T = unknown> extends SdTableColumnBase<T, SdTableAggregateOperation> {
|
|
84
98
|
field: NestedKeyOf<T>;
|
|
85
99
|
type: 'number';
|
|
86
100
|
useBadge?: UseBadgeFunc<T>;
|
|
@@ -97,9 +111,17 @@ interface SdTableColumnBool<T = unknown> extends SdTableColumnBase<T> {
|
|
|
97
111
|
displayOnFalse?: string;
|
|
98
112
|
};
|
|
99
113
|
}
|
|
100
|
-
interface SdTableColumnDate<T = unknown> extends SdTableColumnBase<T> {
|
|
114
|
+
interface SdTableColumnDate<T = unknown> extends SdTableColumnBase<T, 'COUNT' | 'MIN' | 'MAX'> {
|
|
101
115
|
field: NestedKeyOf<T>;
|
|
102
|
-
type: 'date' | 'datetime'
|
|
116
|
+
type: 'date' | 'datetime';
|
|
117
|
+
useBadge?: UseBadgeFunc<T>;
|
|
118
|
+
filter?: SdTableColumnBase<T>['filter'] & {
|
|
119
|
+
type?: 'daterange' | 'date' | 'split-date';
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
interface SdTableColumnTime<T = unknown> extends SdTableColumnBase<T> {
|
|
123
|
+
field: NestedKeyOf<T>;
|
|
124
|
+
type: 'time';
|
|
103
125
|
useBadge?: UseBadgeFunc<T>;
|
|
104
126
|
filter?: SdTableColumnBase<T>['filter'] & {
|
|
105
127
|
type?: 'daterange' | 'date' | 'split-date';
|
|
@@ -130,6 +152,8 @@ export interface SdTableColumnLazyValues<T = unknown, K = Record<string, any>> e
|
|
|
130
152
|
}
|
|
131
153
|
export type SdTableColumnNormal<T = unknown> = Exclude<SdTableColumn<T>, SdTableColumnChildren<T>>;
|
|
132
154
|
export interface SdTableColumnChildren<T = unknown> extends SdTableColumnBase<T> {
|
|
155
|
+
/** Parent headers have no data value; configure aggregates on their leaf children. */
|
|
156
|
+
aggregate?: never;
|
|
133
157
|
field: string;
|
|
134
158
|
type: 'children';
|
|
135
159
|
children: SdTableColumnNormal<T>[];
|
|
@@ -12,8 +12,18 @@ import { SdTableOptionSelector } from './table-option-selector.model';
|
|
|
12
12
|
import { SdTableOptionSort } from './table-option-sort.model';
|
|
13
13
|
import { SdTableOptionStyle } from './table-option-style.model';
|
|
14
14
|
import { SdTableOptionTree } from './table-option-tree.model';
|
|
15
|
+
import type { SdTableOptionAggregate } from './table-aggregate.model';
|
|
15
16
|
export type SdTableOption<T = any> = SdTableLocalOption<T> | SdTableServerOption<T>;
|
|
16
17
|
interface SdTableBaseOption<T = any> {
|
|
18
|
+
/**
|
|
19
|
+
* Data scope and optional group/tree subtotals for column.aggregate. Independent of sdTableFooterDef.
|
|
20
|
+
* @defaultValue page scope, no subtotals, tree items='leaves'
|
|
21
|
+
* @remarks A visible aggregate column enables the total row automatically. Server filtered scope is incomplete
|
|
22
|
+
* and never silently falls back to page; missing lazy descendants also remain incomplete.
|
|
23
|
+
* @example `{ aggregate: { scope: 'filtered', group: true } }` summarizes all matching local rows.
|
|
24
|
+
* @see SdTableOptionAggregate
|
|
25
|
+
*/
|
|
26
|
+
aggregate?: SdTableOptionAggregate;
|
|
17
27
|
/**
|
|
18
28
|
* Key định danh của table option.
|
|
19
29
|
* Thường dùng khi một số tính năng con cần lưu trạng thái riêng theo table,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PipeTransform } from '@angular/core';
|
|
2
|
+
import { SdTableItem } from '../models/table-item.model';
|
|
3
|
+
import { SdTableOption } from '../models/table-option.model';
|
|
4
|
+
import { AggregateRow, AggregateSnapshot } from '../services/table-aggregate.util';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export interface AggregateRenderHost<T> {
|
|
7
|
+
rows: WeakMap<SdTableItem<T>, AggregateRow<T>>;
|
|
8
|
+
indices: WeakMap<SdTableItem<T>, number>;
|
|
9
|
+
}
|
|
10
|
+
/** Summary wrappers belong only to the render projection, never to items()/business selection. */
|
|
11
|
+
export declare class SdAggregateRowsPipe implements PipeTransform {
|
|
12
|
+
transform<T>(rows: SdTableItem<T>[], snapshot: AggregateSnapshot<T>, option: SdTableOption<T>, host: AggregateRenderHost<T>): SdTableItem<T>[];
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SdAggregateRowsPipe, never>;
|
|
14
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<SdAggregateRowsPipe, "sdAggregateRows", true>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SdTableAggregateContext, SdTableAggregateDefinition, SdTableAggregateOperation, SdTableAggregateResult, SdTableAggregateTemplateContext } from '../models/table-aggregate.model';
|
|
2
|
+
import type { SdTableColumnNormal } from '../models/table-column.model';
|
|
3
|
+
import type { SdTableOptionTree } from '../models/table-option-tree.model';
|
|
4
|
+
import type { SdTableOption } from '../models/table-option.model';
|
|
5
|
+
import type { TemplateRef } from '@angular/core';
|
|
6
|
+
/** Presence, deliberately independent of column type, formatting and dictionary hydration. */
|
|
7
|
+
export declare function hasAggregateValue(value: unknown): boolean;
|
|
8
|
+
export declare function aggregateDefinition<T>(column: SdTableColumnNormal<T>): SdTableAggregateDefinition<T> | undefined;
|
|
9
|
+
export declare function calculateAggregate<T>(items: readonly T[], context: SdTableAggregateContext<T>, definition: SdTableAggregateDefinition<T>): SdTableAggregateResult;
|
|
10
|
+
export interface AggregateTreeSelection<T> {
|
|
11
|
+
items: T[];
|
|
12
|
+
isComplete: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Walk raw children, not expanded/formatted rows. A shared visited set prevents duplicate descendants and cycles. */
|
|
15
|
+
export declare function selectAggregateTreeItems<T>(roots: readonly T[], option: SdTableOptionTree<T>, mode: 'roots' | 'leaves' | 'all', loaded: ReadonlySet<T>, predicate?: (data: T) => boolean, excluded?: T): AggregateTreeSelection<T>;
|
|
16
|
+
export interface AggregateCell<T> {
|
|
17
|
+
context: SdTableAggregateTemplateContext<T>;
|
|
18
|
+
templateRef?: TemplateRef<SdTableAggregateTemplateContext<T>>;
|
|
19
|
+
text: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AggregateRow<T> {
|
|
22
|
+
key: string;
|
|
23
|
+
cells: ReadonlyMap<string, AggregateCell<T>>;
|
|
24
|
+
}
|
|
25
|
+
export interface AggregateSnapshot<T> {
|
|
26
|
+
total?: AggregateRow<T>;
|
|
27
|
+
groups: ReadonlyMap<string, AggregateRow<T>>;
|
|
28
|
+
branches: ReadonlyMap<T, AggregateRow<T>>;
|
|
29
|
+
}
|
|
30
|
+
/** One snapshot per data/configuration revision. Renderers consume cached text/context only. */
|
|
31
|
+
export declare function buildAggregateSnapshot<T>(args: {
|
|
32
|
+
columns: readonly SdTableColumnNormal<T>[];
|
|
33
|
+
roots: readonly T[];
|
|
34
|
+
option: SdTableOption<T>;
|
|
35
|
+
complete: boolean;
|
|
36
|
+
loadedChildren: ReadonlySet<T>;
|
|
37
|
+
predicate?: (data: T) => boolean;
|
|
38
|
+
format: (value: SdTableAggregateResult, column: SdTableColumnNormal<T>, operation?: SdTableAggregateOperation) => string;
|
|
39
|
+
diagnose: (error: unknown) => void;
|
|
40
|
+
}): AggregateSnapshot<T>;
|
|
@@ -23,6 +23,8 @@ import { SdDataStateTemplateDirective } from '@sdcorejs/angular/components/data-
|
|
|
23
23
|
import { SdReadState } from '@sdcorejs/angular/utilities/read-state';
|
|
24
24
|
import { SdQuickAction } from '@sdcorejs/angular/components/quick-action';
|
|
25
25
|
import { SdScrollDirective } from '@sdcorejs/angular/directives';
|
|
26
|
+
import { AggregateRenderHost } from './pipes/sd-aggregate-rows.pipe';
|
|
27
|
+
import { AggregateSnapshot } from './services/table-aggregate.util';
|
|
26
28
|
import { Operator } from '@sdcorejs/utils/models';
|
|
27
29
|
import { ExternalFilterComponent, MobileFilterComponent } from './components';
|
|
28
30
|
import { ConfigComponent } from './components/config/config.component';
|
|
@@ -87,6 +89,26 @@ export declare class SdTable<T = unknown> implements AfterViewInit, OnDestroy {
|
|
|
87
89
|
total: import("@angular/core").WritableSignal<number | undefined>;
|
|
88
90
|
loading: import("@angular/core").WritableSignal<boolean>;
|
|
89
91
|
loadError: import("@angular/core").WritableSignal<boolean>;
|
|
92
|
+
readonly aggregateSnapshot: import("@angular/core").WritableSignal<AggregateSnapshot<T>>;
|
|
93
|
+
readonly aggregateRenderHost: AggregateRenderHost<T>;
|
|
94
|
+
readonly aggregateColumns: import("@angular/core").Signal<{
|
|
95
|
+
id: string;
|
|
96
|
+
field: string;
|
|
97
|
+
column: SdTableColumn | undefined;
|
|
98
|
+
hidden: boolean;
|
|
99
|
+
sticky: boolean;
|
|
100
|
+
stickyEnd: boolean;
|
|
101
|
+
}[]>;
|
|
102
|
+
readonly aggregateColumnIds: import("@angular/core").Signal<string[]>;
|
|
103
|
+
readonly headerFilterColumns: import("@angular/core").Signal<{
|
|
104
|
+
id: string;
|
|
105
|
+
field: string;
|
|
106
|
+
column: SdTableColumn | undefined;
|
|
107
|
+
hidden: boolean;
|
|
108
|
+
sticky: boolean;
|
|
109
|
+
stickyEnd: boolean;
|
|
110
|
+
}[]>;
|
|
111
|
+
readonly headerFilterColumnIds: import("@angular/core").Signal<string[]>;
|
|
90
112
|
isSelectAll: import("@angular/core").WritableSignal<boolean>;
|
|
91
113
|
isSelectIndeterminate: import("@angular/core").WritableSignal<boolean>;
|
|
92
114
|
readonly sortState: import("@angular/core").WritableSignal<{
|
|
@@ -177,6 +199,7 @@ export declare class SdTable<T = unknown> implements AfterViewInit, OnDestroy {
|
|
|
177
199
|
* Data row dùng displayedColumns nguyên vẹn.
|
|
178
200
|
*/
|
|
179
201
|
isGroupHeaderRow: (_idx: number, row: SdTableItem<T>) => boolean;
|
|
202
|
+
isAggregateRow: (_idx: number, row: SdTableItem<T>) => boolean;
|
|
180
203
|
isDataRow: (_idx: number, row: SdTableItem<T>) => boolean;
|
|
181
204
|
/**
|
|
182
205
|
* Colspan cho cell sdGroupHeader trên group row = displayedColumns.length.
|
|
@@ -2538,7 +2538,7 @@ class SdApiContractNodeDrawer {
|
|
|
2538
2538
|
[title]="'core.component.api-contract-builder.drawer.save' | sdTranslate"
|
|
2539
2539
|
(click)="save()"></sd-button>
|
|
2540
2540
|
</sd-side-drawer>
|
|
2541
|
-
`, isInline: true, styles: [".sd-acb-drawer{display:flex;flex-direction:column;gap:12px;padding:16px}.sd-acb-drawer__crumbs{display:flex;flex-wrap:wrap;gap:4px;align-items:center;font-size:12px}.sd-acb-drawer__crumb{padding:2px 4px;border:0;border-radius:4px;background:transparent;color:var(--sd-primary, #005cbb);font:inherit;cursor:pointer}.sd-acb-drawer__crumb:hover{background:color-mix(in srgb,var(--sd-primary, #005cbb) 10%,transparent)}.sd-acb-drawer__crumb--current{color:var(--sd-text, #1a1b1f);font-weight:600;cursor:default}.sd-acb-drawer__crumb-sep{color:var(--sd-text-secondary, #6b6b6b)}.sd-acb-drawer__children{display:flex;flex-direction:column;gap:6px;padding-top:4px;border-top:1px solid var(--sd-border-color, #e6e6e6)}.sd-acb-drawer__children-title{margin:0;font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--sd-text-secondary, #6b6b6b)}.sd-acb-drawer__empty{margin:0;font-size:12px;font-style:italic;color:var(--sd-text-secondary, #6b6b6b)}.sd-acb-drawer__confirm{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 10px;border:1px dashed var(--sd-border-color, #e6e6e6);border-radius:6px;background:var(--sd-surface-muted, #f3f5f8);font-size:12px}\n"], dependencies: [{ kind: "component", type: SdSideDrawer, selector: "sd-side-drawer", inputs: ["title", "width", "hideClose", "disableBackdropClose", "beforeClose", "drawerClass", "autoId"], outputs: ["sdClosed", "sdCloseError"] }, { kind: "component", type: SdButton, selector: "sd-button", inputs: ["autoId", "type", "color", "size", "fontSet", "title", "width", "tooltip", "prefixIcon", "suffixIcon", "disabled", "openOnHover", "loading", "block", "htmlType"], outputs: ["click"] }, { kind: "component", type: SdInput, selector: "sd-input", inputs: ["autoId", "name", "appearance", "floatLabel", "size", "form", "label", "helperText", "placeholder", "type", "mask", "hideInlineError", "blurOnEnter", "clearable", "required", "readonly", "disabled", "viewed", "minlength", "maxlength", "pattern", "patternErrorMessage", "validator", "inlineError", "hyperlink", "model"], outputs: ["modelChange", "sdChange", "sdFocus", "sdBlur", "keyupEnter", "cleared", "sdFocusForceBlur"] }, { kind: "component", type: SdSelect, selector: "sd-select", inputs: ["autoId", "name", "size", "form", "label", "helperText", "placeholder", "valueField", "displayField", "disabledField", "cacheChecksum", "limit", "hyperlink", "minWidthPanel", "hideInlineError", "hideReadError", "required", "disabled", "viewed", "multiple", "showSelectAll", "clearable", "validator", "inlineError", "appearance", "floatLabel", "items", "model"], outputs: ["sdReadStateChange", "modelChange", "sdChange", "sdSelection"] }, { kind: "component", type: SdApiContractNodeSummary, selector: "sd-api-contract-node-summary", inputs: ["name", "node", "readonly", "autoId"], outputs: ["edit", "remove"] }, { kind: "component", type: SdApiContractSourceEditor, selector: "sd-api-contract-source-editor", inputs: ["node", "suggestions", "disabled", "autoId"], outputs: ["nodeChange"] }, { kind: "pipe", type: SdTranslatePipe, name: "sdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2541
|
+
`, isInline: true, styles: [".sd-acb-drawer{display:flex;flex-direction:column;gap:12px;padding:16px}.sd-acb-drawer__crumbs{display:flex;flex-wrap:wrap;gap:4px;align-items:center;font-size:12px}.sd-acb-drawer__crumb{padding:2px 4px;border:0;border-radius:4px;background:transparent;color:var(--sd-primary, #005cbb);font:inherit;cursor:pointer}.sd-acb-drawer__crumb:hover{background:color-mix(in srgb,var(--sd-primary, #005cbb) 10%,transparent)}.sd-acb-drawer__crumb--current{color:var(--sd-text, #1a1b1f);font-weight:600;cursor:default}.sd-acb-drawer__crumb-sep{color:var(--sd-text-secondary, #6b6b6b)}.sd-acb-drawer__children{display:flex;flex-direction:column;gap:6px;padding-top:4px;border-top:1px solid var(--sd-border-color, #e6e6e6)}.sd-acb-drawer__children-title{margin:0;font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--sd-text-secondary, #6b6b6b)}.sd-acb-drawer__empty{margin:0;font-size:12px;font-style:italic;color:var(--sd-text-secondary, #6b6b6b)}.sd-acb-drawer__confirm{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 10px;border:1px dashed var(--sd-border-color, #e6e6e6);border-radius:6px;background:var(--sd-surface-muted, #f3f5f8);font-size:12px}\n"], dependencies: [{ kind: "component", type: SdSideDrawer, selector: "sd-side-drawer", inputs: ["title", "width", "hideClose", "disableBackdropClose", "beforeClose", "container", "drawerClass", "autoId"], outputs: ["sdClosed", "sdCloseError"] }, { kind: "component", type: SdButton, selector: "sd-button", inputs: ["autoId", "type", "color", "size", "fontSet", "title", "width", "tooltip", "prefixIcon", "suffixIcon", "disabled", "openOnHover", "loading", "block", "htmlType"], outputs: ["click"] }, { kind: "component", type: SdInput, selector: "sd-input", inputs: ["autoId", "name", "appearance", "floatLabel", "size", "form", "label", "helperText", "placeholder", "type", "mask", "hideInlineError", "blurOnEnter", "clearable", "required", "readonly", "disabled", "viewed", "minlength", "maxlength", "pattern", "patternErrorMessage", "validator", "inlineError", "hyperlink", "model"], outputs: ["modelChange", "sdChange", "sdFocus", "sdBlur", "keyupEnter", "cleared", "sdFocusForceBlur"] }, { kind: "component", type: SdSelect, selector: "sd-select", inputs: ["autoId", "name", "size", "form", "label", "helperText", "placeholder", "valueField", "displayField", "disabledField", "cacheChecksum", "limit", "hyperlink", "minWidthPanel", "hideInlineError", "hideReadError", "required", "disabled", "viewed", "multiple", "showSelectAll", "clearable", "validator", "inlineError", "appearance", "floatLabel", "items", "model"], outputs: ["sdReadStateChange", "modelChange", "sdChange", "sdSelection"] }, { kind: "component", type: SdApiContractNodeSummary, selector: "sd-api-contract-node-summary", inputs: ["name", "node", "readonly", "autoId"], outputs: ["edit", "remove"] }, { kind: "component", type: SdApiContractSourceEditor, selector: "sd-api-contract-source-editor", inputs: ["node", "suggestions", "disabled", "autoId"], outputs: ["nodeChange"] }, { kind: "pipe", type: SdTranslatePipe, name: "sdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2542
2542
|
}
|
|
2543
2543
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: SdApiContractNodeDrawer, decorators: [{
|
|
2544
2544
|
type: Component,
|