@ni/nimble-components 29.8.2 → 29.9.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/dist/all-components-bundle.js +142 -14
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +1109 -1106
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/table-column/anchor/index.d.ts +23 -6
- package/dist/esm/table-column/anchor/index.js +14 -5
- package/dist/esm/table-column/anchor/index.js.map +1 -1
- package/dist/esm/table-column/anchor/models/table-column-anchor-validator.d.ts +8 -0
- package/dist/esm/table-column/anchor/models/table-column-anchor-validator.js +13 -0
- package/dist/esm/table-column/anchor/models/table-column-anchor-validator.js.map +1 -0
- package/dist/esm/table-column/base/models/column-validator.d.ts +1 -1
- package/dist/esm/table-column/base/models/column-validator.js +4 -4
- package/dist/esm/table-column/base/models/column-validator.js.map +1 -1
- package/dist/esm/table-column/mixins/custom-sort-order.d.ts +26 -0
- package/dist/esm/table-column/mixins/custom-sort-order.js +66 -0
- package/dist/esm/table-column/mixins/custom-sort-order.js.map +1 -0
- package/dist/esm/table-column/text/index.d.ts +24 -6
- package/dist/esm/table-column/text/index.js +20 -4
- package/dist/esm/table-column/text/index.js.map +1 -1
- package/dist/esm/table-column/text/models/table-column-text-validator.d.ts +8 -0
- package/dist/esm/table-column/text/models/table-column-text-validator.js +13 -0
- package/dist/esm/table-column/text/models/table-column-text-validator.js.map +1 -0
- package/dist/esm/utilities/models/tracker.d.ts +1 -0
- package/dist/esm/utilities/models/tracker.js +19 -2
- package/dist/esm/utilities/models/tracker.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TableColumn } from '../base';
|
|
2
|
+
import { TableColumnSortOperation } from '../base/types';
|
|
2
3
|
import type { TableStringField } from '../../table/types';
|
|
3
4
|
import type { AnchorAppearance } from '../../anchor/types';
|
|
4
5
|
import type { ColumnInternalsOptions } from '../base/models/column-internals';
|
|
5
|
-
import {
|
|
6
|
+
import { TableColumnAnchorValidator } from './models/table-column-anchor-validator';
|
|
6
7
|
export type TableColumnAnchorCellRecord = TableStringField<'label' | 'href'>;
|
|
7
8
|
export interface TableColumnAnchorColumnConfig {
|
|
8
9
|
appearance: AnchorAppearance;
|
|
@@ -26,13 +27,13 @@ declare const TableColumnAnchor_base: (abstract new (...args: any[]) => {
|
|
|
26
27
|
groupIndex?: number | null | undefined;
|
|
27
28
|
groupingDisabledChanged(): void;
|
|
28
29
|
groupIndexChanged(): void;
|
|
29
|
-
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, ColumnValidator<[]>>;
|
|
30
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, import("../base/models/column-validator").ColumnValidator<[]>>;
|
|
30
31
|
}) & (abstract new (...args: any[]) => {
|
|
31
32
|
fractionalWidth?: number | null | undefined;
|
|
32
33
|
minPixelWidth?: number | null | undefined;
|
|
33
34
|
fractionalWidthChanged(): void;
|
|
34
35
|
minPixelWidthChanged(): void;
|
|
35
|
-
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, ColumnValidator<[]>>;
|
|
36
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, import("../base/models/column-validator").ColumnValidator<[]>>;
|
|
36
37
|
}) & (abstract new (...args: any[]) => {
|
|
37
38
|
placeholder?: string | undefined;
|
|
38
39
|
placeholderChanged(): void;
|
|
@@ -43,8 +44,21 @@ declare const TableColumnAnchor_base: (abstract new (...args: any[]) => {
|
|
|
43
44
|
sortingDisabledChanged(): void;
|
|
44
45
|
sortDirectionChanged(): void;
|
|
45
46
|
sortIndexChanged(): void;
|
|
46
|
-
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, ColumnValidator<[]>>;
|
|
47
|
-
}) & (
|
|
47
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, import("../base/models/column-validator").ColumnValidator<[]>>;
|
|
48
|
+
}) & (abstract new (...args: any[]) => {
|
|
49
|
+
sortByFieldName?: string | undefined;
|
|
50
|
+
customSortOrderColumnNotifier?: import("@microsoft/fast-element").Notifier | undefined;
|
|
51
|
+
customSortOrderColumnChangeHandler: {
|
|
52
|
+
handleChange: (_source: unknown, args: unknown) => void;
|
|
53
|
+
};
|
|
54
|
+
getResolvedOperandDataRecordFieldName(initialOperandFieldName: string | undefined): string | undefined;
|
|
55
|
+
getResolvedSortOperation(initialSortOperation: TableColumnSortOperation): TableColumnSortOperation;
|
|
56
|
+
sortByFieldNameChanged(): void;
|
|
57
|
+
handleSortConfigurationChange(): void;
|
|
58
|
+
handleCustomSortOrderColumnChange(_source: unknown, args: unknown): void;
|
|
59
|
+
updateCustomColumnSortingValidity(): void;
|
|
60
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, import("../base/models/column-validator").ColumnValidator<["invalidCustomSortWithGrouping"]>>;
|
|
61
|
+
}) & ((abstract new () => TableColumn<TableColumnAnchorColumnConfig, TableColumnAnchorValidator>) & {
|
|
48
62
|
compose<T extends import("@microsoft/fast-foundation").FoundationElementDefinition = import("@microsoft/fast-foundation").FoundationElementDefinition, K extends import("@microsoft/fast-element").Constructable<import("@microsoft/fast-foundation").FoundationElement> = import("@microsoft/fast-element").Constructable<import("@microsoft/fast-foundation").FoundationElement>>(this: K, elementDefinition: T): (overrideDefinition?: import("@microsoft/fast-foundation").OverrideFoundationElementDefinition<T> | undefined) => import("@microsoft/fast-foundation").FoundationElementRegistry<T, K>;
|
|
49
63
|
from<TBase extends {
|
|
50
64
|
new (): HTMLElement;
|
|
@@ -67,8 +81,10 @@ export declare class TableColumnAnchor extends TableColumnAnchor_base {
|
|
|
67
81
|
target?: string;
|
|
68
82
|
type?: string;
|
|
69
83
|
download?: string;
|
|
84
|
+
private readonly defaultSortOperation;
|
|
70
85
|
placeholderChanged(): void;
|
|
71
|
-
|
|
86
|
+
handleSortConfigurationChange(): void;
|
|
87
|
+
protected getColumnInternalsOptions(): ColumnInternalsOptions<TableColumnAnchorValidator>;
|
|
72
88
|
protected labelFieldNameChanged(): void;
|
|
73
89
|
protected hrefFieldNameChanged(): void;
|
|
74
90
|
protected appearanceChanged(): void;
|
|
@@ -81,6 +97,7 @@ export declare class TableColumnAnchor extends TableColumnAnchor_base {
|
|
|
81
97
|
protected typeChanged(): void;
|
|
82
98
|
protected downloadChanged(): void;
|
|
83
99
|
private updateColumnConfig;
|
|
100
|
+
private updateColumnInternalsSortConfiguration;
|
|
84
101
|
}
|
|
85
102
|
export declare const tableColumnAnchorTag = "nimble-table-column-anchor";
|
|
86
103
|
export {};
|
|
@@ -10,27 +10,32 @@ import { mixinGroupableColumnAPI } from '../mixins/groupable-column';
|
|
|
10
10
|
import { mixinColumnWithPlaceholderAPI } from '../mixins/placeholder';
|
|
11
11
|
import { tableColumnAnchorCellViewTag } from './cell-view';
|
|
12
12
|
import { tableColumnTextGroupHeaderViewTag } from '../text/group-header-view';
|
|
13
|
-
import { ColumnValidator } from '../base/models/column-validator';
|
|
14
13
|
import { mixinSortableColumnAPI } from '../mixins/sortable-column';
|
|
14
|
+
import { mixinCustomSortOrderColumnAPI } from '../mixins/custom-sort-order';
|
|
15
|
+
import { TableColumnAnchorValidator } from './models/table-column-anchor-validator';
|
|
15
16
|
/**
|
|
16
17
|
* A table column for displaying links.
|
|
17
18
|
*/
|
|
18
|
-
export class TableColumnAnchor extends mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(mixinColumnWithPlaceholderAPI(mixinSortableColumnAPI((TableColumn))))) {
|
|
19
|
+
export class TableColumnAnchor extends mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(mixinColumnWithPlaceholderAPI(mixinSortableColumnAPI(mixinCustomSortOrderColumnAPI((TableColumn)))))) {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments);
|
|
21
22
|
this.underlineHidden = false;
|
|
23
|
+
this.defaultSortOperation = TableColumnSortOperation.localeAwareCaseSensitive;
|
|
22
24
|
}
|
|
23
25
|
placeholderChanged() {
|
|
24
26
|
this.updateColumnConfig();
|
|
25
27
|
}
|
|
28
|
+
handleSortConfigurationChange() {
|
|
29
|
+
this.updateColumnInternalsSortConfiguration();
|
|
30
|
+
}
|
|
26
31
|
getColumnInternalsOptions() {
|
|
27
32
|
return {
|
|
28
33
|
cellRecordFieldNames: ['label', 'href'],
|
|
29
34
|
cellViewTag: tableColumnAnchorCellViewTag,
|
|
30
35
|
groupHeaderViewTag: tableColumnTextGroupHeaderViewTag,
|
|
31
36
|
delegatedEvents: ['click'],
|
|
32
|
-
sortOperation:
|
|
33
|
-
validator: new
|
|
37
|
+
sortOperation: this.getResolvedSortOperation(this.defaultSortOperation),
|
|
38
|
+
validator: new TableColumnAnchorValidator()
|
|
34
39
|
};
|
|
35
40
|
}
|
|
36
41
|
labelFieldNameChanged() {
|
|
@@ -38,7 +43,7 @@ export class TableColumnAnchor extends mixinGroupableColumnAPI(mixinFractionalWi
|
|
|
38
43
|
this.labelFieldName,
|
|
39
44
|
this.hrefFieldName
|
|
40
45
|
];
|
|
41
|
-
this.
|
|
46
|
+
this.updateColumnInternalsSortConfiguration();
|
|
42
47
|
}
|
|
43
48
|
hrefFieldNameChanged() {
|
|
44
49
|
this.columnInternals.dataRecordFieldNames = [
|
|
@@ -87,6 +92,10 @@ export class TableColumnAnchor extends mixinGroupableColumnAPI(mixinFractionalWi
|
|
|
87
92
|
placeholder: this.placeholder
|
|
88
93
|
};
|
|
89
94
|
}
|
|
95
|
+
updateColumnInternalsSortConfiguration() {
|
|
96
|
+
this.columnInternals.operandDataRecordFieldName = this.getResolvedOperandDataRecordFieldName(this.labelFieldName);
|
|
97
|
+
this.columnInternals.sortOperation = this.getResolvedSortOperation(this.defaultSortOperation);
|
|
98
|
+
}
|
|
90
99
|
}
|
|
91
100
|
__decorate([
|
|
92
101
|
attr({ attribute: 'label-field-name' })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table-column/anchor/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAG9E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table-column/anchor/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO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AA/HU;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;yDACT;AAGxB;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;wDACT;AAGvB;IADN,IAAI;qDACgC;AAG9B;IADN,IAAI,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;0DAC1B;AAGxB;IADN,IAAI;mDACoB;AAGlB;IADN,IAAI;+CACgB;AAGd;IADN,IAAI;yDAC0B;AAGxB;IADN,IAAI;8CACe;AAGb;IADN,IAAI;iDACkB;AAGhB;IADN,IAAI;+CACgB;AAGd;IADN,IAAI;mDACoB;AAmG7B,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,OAAO,CAAC;IACtD,QAAQ,EAAE,qBAAqB;IAC/B,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,uBAAuB,EAAE,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC","sourcesContent":["import { DesignSystem } from '@microsoft/fast-foundation';\nimport { attr } from '@microsoft/fast-element';\nimport { TableColumn } from '../base';\nimport { styles } from '../base/styles';\nimport { template } from '../base/template';\nimport { TableColumnSortOperation } from '../base/types';\nimport { mixinFractionalWidthColumnAPI } from '../mixins/fractional-width-column';\nimport { mixinGroupableColumnAPI } from '../mixins/groupable-column';\nimport { mixinColumnWithPlaceholderAPI } from '../mixins/placeholder';\nimport type { TableStringField } from '../../table/types';\nimport { tableColumnAnchorCellViewTag } from './cell-view';\nimport { tableColumnTextGroupHeaderViewTag } from '../text/group-header-view';\nimport type { AnchorAppearance } from '../../anchor/types';\nimport type { ColumnInternalsOptions } from '../base/models/column-internals';\nimport { mixinSortableColumnAPI } from '../mixins/sortable-column';\nimport { mixinCustomSortOrderColumnAPI } from '../mixins/custom-sort-order';\nimport { TableColumnAnchorValidator } from './models/table-column-anchor-validator';\n\nexport type TableColumnAnchorCellRecord = TableStringField<'label' | 'href'>;\nexport interface TableColumnAnchorColumnConfig {\n appearance: AnchorAppearance;\n underlineHidden?: boolean;\n hreflang?: string;\n ping?: string;\n referrerpolicy?: string;\n rel?: string;\n target?: string;\n type?: string;\n download?: string;\n placeholder?: string;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-table-column-anchor': TableColumnAnchor;\n }\n}\n\n/**\n * A table column for displaying links.\n */\nexport class TableColumnAnchor extends mixinGroupableColumnAPI(\n mixinFractionalWidthColumnAPI(\n mixinColumnWithPlaceholderAPI(\n mixinSortableColumnAPI(\n mixinCustomSortOrderColumnAPI(\n TableColumn<\n TableColumnAnchorColumnConfig,\n TableColumnAnchorValidator\n >\n )\n )\n )\n )\n) {\n @attr({ attribute: 'label-field-name' })\n public labelFieldName?: string;\n\n @attr({ attribute: 'href-field-name' })\n public hrefFieldName?: string;\n\n @attr\n public appearance?: AnchorAppearance;\n\n @attr({ attribute: 'underline-hidden', mode: 'boolean' })\n public underlineHidden = false;\n\n @attr\n public hreflang?: string;\n\n @attr\n public ping?: string;\n\n @attr\n public referrerpolicy?: string;\n\n @attr\n public rel?: string;\n\n @attr\n public target?: string;\n\n @attr\n public type?: string;\n\n @attr\n public download?: string;\n\n private readonly defaultSortOperation = TableColumnSortOperation.localeAwareCaseSensitive;\n\n public placeholderChanged(): void {\n this.updateColumnConfig();\n }\n\n public override handleSortConfigurationChange(): void {\n this.updateColumnInternalsSortConfiguration();\n }\n\n protected override getColumnInternalsOptions(): ColumnInternalsOptions<TableColumnAnchorValidator> {\n return {\n cellRecordFieldNames: ['label', 'href'],\n cellViewTag: tableColumnAnchorCellViewTag,\n groupHeaderViewTag: tableColumnTextGroupHeaderViewTag,\n delegatedEvents: ['click'],\n sortOperation: this.getResolvedSortOperation(\n this.defaultSortOperation\n ),\n validator: new TableColumnAnchorValidator()\n };\n }\n\n protected labelFieldNameChanged(): void {\n this.columnInternals.dataRecordFieldNames = [\n this.labelFieldName,\n this.hrefFieldName\n ] as const;\n this.updateColumnInternalsSortConfiguration();\n }\n\n protected hrefFieldNameChanged(): void {\n this.columnInternals.dataRecordFieldNames = [\n this.labelFieldName,\n this.hrefFieldName\n ] as const;\n }\n\n protected appearanceChanged(): void {\n this.updateColumnConfig();\n }\n\n protected underlineHiddenChanged(): void {\n this.updateColumnConfig();\n }\n\n protected hreflangChanged(): void {\n this.updateColumnConfig();\n }\n\n protected pingChanged(): void {\n this.updateColumnConfig();\n }\n\n protected referrerpolicyChanged(): void {\n this.updateColumnConfig();\n }\n\n protected relChanged(): void {\n this.updateColumnConfig();\n }\n\n protected targetChanged(): void {\n this.updateColumnConfig();\n }\n\n protected typeChanged(): void {\n this.updateColumnConfig();\n }\n\n protected downloadChanged(): void {\n this.updateColumnConfig();\n }\n\n private updateColumnConfig(): void {\n this.columnInternals.columnConfig = {\n appearance: this.appearance,\n underlineHidden: this.underlineHidden,\n hreflang: this.hreflang,\n ping: this.ping,\n referrerpolicy: this.referrerpolicy,\n rel: this.rel,\n target: this.target,\n type: this.type,\n download: this.download,\n placeholder: this.placeholder\n };\n }\n\n private updateColumnInternalsSortConfiguration(): void {\n this.columnInternals.operandDataRecordFieldName = this.getResolvedOperandDataRecordFieldName(this.labelFieldName);\n this.columnInternals.sortOperation = this.getResolvedSortOperation(\n this.defaultSortOperation\n );\n }\n}\n\nconst nimbleTableColumnAnchor = TableColumnAnchor.compose({\n baseName: 'table-column-anchor',\n template,\n styles\n});\n\nDesignSystem.getOrCreate()\n .withPrefix('nimble')\n .register(nimbleTableColumnAnchor());\nexport const tableColumnAnchorTag = 'nimble-table-column-anchor';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnValidator } from '../../base/models/column-validator';
|
|
2
|
+
export declare const columnAnchorValidityFlagNames: readonly ["invalidCustomSortWithGrouping"];
|
|
3
|
+
/**
|
|
4
|
+
* Validator class for the anchor table column.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TableColumnAnchorValidator extends ColumnValidator<typeof columnAnchorValidityFlagNames> {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ColumnValidator } from '../../base/models/column-validator';
|
|
2
|
+
export const columnAnchorValidityFlagNames = [
|
|
3
|
+
'invalidCustomSortWithGrouping'
|
|
4
|
+
];
|
|
5
|
+
/**
|
|
6
|
+
* Validator class for the anchor table column.
|
|
7
|
+
*/
|
|
8
|
+
export class TableColumnAnchorValidator extends ColumnValidator {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(columnAnchorValidityFlagNames);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=table-column-anchor-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-column-anchor-validator.js","sourceRoot":"","sources":["../../../../../src/table-column/anchor/models/table-column-anchor-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,MAAM,CAAC,MAAM,6BAA6B,GAAG;IACzC,+BAA+B;CACzB,CAAC;AAEX;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,eAE/C;IACG;QACI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import { ColumnValidator } from '../../base/models/column-validator';\n\nexport const columnAnchorValidityFlagNames = [\n 'invalidCustomSortWithGrouping'\n] as const;\n\n/**\n * Validator class for the anchor table column.\n */\nexport class TableColumnAnchorValidator extends ColumnValidator<\n typeof columnAnchorValidityFlagNames\n> {\n public constructor() {\n super(columnAnchorValidityFlagNames);\n }\n}\n"]}
|
|
@@ -10,9 +10,9 @@ export declare class ColumnValidator<ValidityFlagNames extends readonly string[]
|
|
|
10
10
|
* @returns an object containing flags for various ways the configuation can be invalid
|
|
11
11
|
*/
|
|
12
12
|
getValidity(): TableColumnValidity;
|
|
13
|
+
onTrackingChange(): void;
|
|
13
14
|
/**
|
|
14
15
|
* Sets a particular validity condition flag's value, e.g. "hasInvalidFooValue" = true
|
|
15
16
|
*/
|
|
16
17
|
protected setConditionValue(name: ValidityFlagNames extends readonly (infer U)[] ? U : never, isInvalid: boolean): void;
|
|
17
|
-
private updateColumnInternalsFlag;
|
|
18
18
|
}
|
|
@@ -15,6 +15,10 @@ export class ColumnValidator extends Validator {
|
|
|
15
15
|
getValidity() {
|
|
16
16
|
return this.getValidationFlags();
|
|
17
17
|
}
|
|
18
|
+
onTrackingChange() {
|
|
19
|
+
super.onTrackingChange();
|
|
20
|
+
this.isColumnValid = this.isValid();
|
|
21
|
+
}
|
|
18
22
|
/**
|
|
19
23
|
* Sets a particular validity condition flag's value, e.g. "hasInvalidFooValue" = true
|
|
20
24
|
*/
|
|
@@ -25,10 +29,6 @@ export class ColumnValidator extends Validator {
|
|
|
25
29
|
else {
|
|
26
30
|
this.untrack(name);
|
|
27
31
|
}
|
|
28
|
-
this.updateColumnInternalsFlag();
|
|
29
|
-
}
|
|
30
|
-
updateColumnInternalsFlag() {
|
|
31
|
-
this.isColumnValid = this.isValid();
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-validator.js","sourceRoot":"","sources":["../../../../../src/table-column/base/models/column-validator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAGhE;;GAEG;AACH,MAAM,OAAO,eAEX,SAAQ,SAA4B;IAIlC,YAAmB,kBAAqC;QACpD,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAHvB,kBAAa,GAAG,IAAI,CAAC;IAI5B,CAAC;IAED;;OAEG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACO,iBAAiB,CACvB,IAAgE,EAChE,SAAkB;QAElB,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACpB;aAAM;YACH,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB;
|
|
1
|
+
{"version":3,"file":"column-validator.js","sourceRoot":"","sources":["../../../../../src/table-column/base/models/column-validator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAGhE;;GAEG;AACH,MAAM,OAAO,eAEX,SAAQ,SAA4B;IAIlC,YAAmB,kBAAqC;QACpD,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAHvB,kBAAa,GAAG,IAAI,CAAC;IAI5B,CAAC;IAED;;OAEG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACrC,CAAC;IAEe,gBAAgB;QAC5B,KAAK,CAAC,gBAAgB,EAAE,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAED;;OAEG;IACO,iBAAiB,CACvB,IAAgE,EAChE,SAAkB;QAElB,IAAI,SAAS,EAAE;YACX,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACpB;aAAM;YACH,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB;IACL,CAAC;CACJ;AA/BU;IADN,UAAU;sDACiB","sourcesContent":["import { observable } from '@microsoft/fast-element';\nimport { Validator } from '../../../utilities/models/validator';\nimport type { TableColumnValidity } from '../types';\n\n/**\n * Base column validator\n */\nexport class ColumnValidator<\n ValidityFlagNames extends readonly string[]\n> extends Validator<ValidityFlagNames> {\n @observable\n public isColumnValid = true;\n\n public constructor(configValidityKeys: ValidityFlagNames) {\n super(configValidityKeys);\n }\n\n /**\n * @returns an object containing flags for various ways the configuation can be invalid\n */\n public getValidity(): TableColumnValidity {\n return this.getValidationFlags();\n }\n\n public override onTrackingChange(): void {\n super.onTrackingChange();\n this.isColumnValid = this.isValid();\n }\n\n /**\n * Sets a particular validity condition flag's value, e.g. \"hasInvalidFooValue\" = true\n */\n protected setConditionValue(\n name: ValidityFlagNames extends readonly (infer U)[] ? U : never,\n isInvalid: boolean\n ): void {\n if (isInvalid) {\n this.track(name);\n } else {\n this.untrack(name);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Notifier } from '@microsoft/fast-element';
|
|
2
|
+
import type { TableColumn } from '../base';
|
|
3
|
+
import { TableColumnSortOperation } from '../base/types';
|
|
4
|
+
import type { ColumnValidator } from '../base/models/column-validator';
|
|
5
|
+
type CustomSortOrderTableColumn<TColumnValidator extends ColumnValidator<['invalidCustomSortWithGrouping']>> = Pick<TableColumn<unknown, TColumnValidator>, 'columnInternals'>;
|
|
6
|
+
type CustomSortOrderTableColumnConstructor<TColumnValidator extends ColumnValidator<['invalidCustomSortWithGrouping']>> = abstract new (...args: any[]) => CustomSortOrderTableColumn<TColumnValidator>;
|
|
7
|
+
export declare function mixinCustomSortOrderColumnAPI<TBase extends CustomSortOrderTableColumnConstructor<TColumnValidator>, TColumnValidator extends ColumnValidator<['invalidCustomSortWithGrouping']>>(base: TBase): (abstract new (...args: any[]) => {
|
|
8
|
+
sortByFieldName?: string | undefined;
|
|
9
|
+
/** @internal */
|
|
10
|
+
customSortOrderColumnNotifier?: Notifier | undefined;
|
|
11
|
+
/** @internal */
|
|
12
|
+
customSortOrderColumnChangeHandler: {
|
|
13
|
+
handleChange: (_source: unknown, args: unknown) => void;
|
|
14
|
+
};
|
|
15
|
+
getResolvedOperandDataRecordFieldName(initialOperandFieldName: string | undefined): string | undefined;
|
|
16
|
+
getResolvedSortOperation(initialSortOperation: TableColumnSortOperation): TableColumnSortOperation;
|
|
17
|
+
/** @internal */
|
|
18
|
+
sortByFieldNameChanged(): void;
|
|
19
|
+
handleSortConfigurationChange(): void;
|
|
20
|
+
/** @internal */
|
|
21
|
+
handleCustomSortOrderColumnChange(_source: unknown, args: unknown): void;
|
|
22
|
+
/** @internal */
|
|
23
|
+
updateCustomColumnSortingValidity(): void;
|
|
24
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, TColumnValidator>;
|
|
25
|
+
}) & TBase;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Observable, attr } from '@microsoft/fast-element';
|
|
2
|
+
import { TableColumnSortOperation } from '../base/types';
|
|
3
|
+
// As the returned class is internal to the function, we can't write a signature that uses is directly, so rely on inference
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
|
|
5
|
+
export function mixinCustomSortOrderColumnAPI(base) {
|
|
6
|
+
/**
|
|
7
|
+
* The Mixin that provides a concrete column with the API to allow sorting
|
|
8
|
+
* by a field other than the default for that column.
|
|
9
|
+
*/
|
|
10
|
+
class CustomSortOrderColumn extends base {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
/** @internal */
|
|
14
|
+
this.customSortOrderColumnChangeHandler = {
|
|
15
|
+
handleChange: this.handleCustomSortOrderColumnChange.bind(this)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
getResolvedOperandDataRecordFieldName(initialOperandFieldName) {
|
|
19
|
+
return typeof this.sortByFieldName === 'string'
|
|
20
|
+
? this.sortByFieldName
|
|
21
|
+
: initialOperandFieldName;
|
|
22
|
+
}
|
|
23
|
+
getResolvedSortOperation(initialSortOperation) {
|
|
24
|
+
return typeof this.sortByFieldName === 'string'
|
|
25
|
+
? TableColumnSortOperation.basic
|
|
26
|
+
: initialSortOperation;
|
|
27
|
+
}
|
|
28
|
+
/** @internal */
|
|
29
|
+
sortByFieldNameChanged() {
|
|
30
|
+
this.handleSortConfigurationChange();
|
|
31
|
+
this.updateCustomColumnSortingValidity();
|
|
32
|
+
if (typeof this.sortByFieldName === 'string'
|
|
33
|
+
&& !this.customSortOrderColumnNotifier) {
|
|
34
|
+
this.customSortOrderColumnNotifier = Observable.getNotifier(this.columnInternals);
|
|
35
|
+
this.customSortOrderColumnNotifier.subscribe(this.customSortOrderColumnChangeHandler);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.customSortOrderColumnNotifier?.unsubscribe(this.customSortOrderColumnChangeHandler);
|
|
39
|
+
this.customSortOrderColumnNotifier = undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
handleCustomSortOrderColumnChange(_source, args) {
|
|
44
|
+
if (args === 'groupingDisabled') {
|
|
45
|
+
this.updateCustomColumnSortingValidity();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** @internal */
|
|
49
|
+
updateCustomColumnSortingValidity() {
|
|
50
|
+
const hasCustomColumnSorting = typeof this.sortByFieldName === 'string';
|
|
51
|
+
const isGroupingEnabled = !this.columnInternals.groupingDisabled;
|
|
52
|
+
const isValid = !isGroupingEnabled || !hasCustomColumnSorting;
|
|
53
|
+
if (isValid) {
|
|
54
|
+
this.columnInternals.validator.untrack('invalidCustomSortWithGrouping');
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.columnInternals.validator.track('invalidCustomSortWithGrouping');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
attr({ attribute: 'sort-by-field-name' })(
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
63
|
+
CustomSortOrderColumn.prototype, 'sortByFieldName');
|
|
64
|
+
return CustomSortOrderColumn;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=custom-sort-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-sort-order.js","sourceRoot":"","sources":["../../../../src/table-column/mixins/custom-sort-order.ts"],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AAgB;QACT,iCAAiC,CACpC,OAAgB,EAChB,IAAa;YAEb,IAAI,IAAI,KAAK,kBAAkB,EAAE;gBAC7B,IAAI,CAAC,iCAAiC,EAAE,CAAC;aAC5C;QACL,CAAC;QAED,gBAAgB;QACT,iCAAiC;YACpC,MAAM,sBAAsB,GAAG,OAAO,IAAI,CAAC,eAAe,KAAK,QAAQ,CAAC;YACxE,MAAM,iBAAiB,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC;YACjE,MAAM,OAAO,GAAG,CAAC,iBAAiB,IAAI,CAAC,sBAAsB,CAAC;YAC9D,IAAI,OAAO,EAAE;gBACT,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,OAAO,CAClC,+BAA+B,CAClC,CAAC;aACL;iBAAM;gBACH,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,KAAK,CAChC,+BAA+B,CAClC,CAAC;aACL;QACL,CAAC;KACJ;IAED,IAAI,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;IACrC,iEAAiE;IACjE,qBAAqB,CAAC,SAAS,EAC/B,iBAAiB,CACpB,CAAC;IAEF,OAAO,qBAAqB,CAAC;AACjC,CAAC","sourcesContent":["import { Notifier, Observable, attr } from '@microsoft/fast-element';\nimport type { TableColumn } from '../base';\nimport { TableColumnSortOperation } from '../base/types';\nimport type { ColumnValidator } from '../base/models/column-validator';\n\n// Pick just the relevant properties the mixin depends on (typescript complains if the mixin declares private / protected base exports)\ntype CustomSortOrderTableColumn<\n TColumnValidator extends ColumnValidator<['invalidCustomSortWithGrouping']>\n> = Pick<TableColumn<unknown, TColumnValidator>, 'columnInternals'>;\n// prettier-ignore\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype CustomSortOrderTableColumnConstructor<TColumnValidator extends ColumnValidator<['invalidCustomSortWithGrouping']>> = abstract new (...args: any[]) => CustomSortOrderTableColumn<TColumnValidator>;\n\n// As the returned class is internal to the function, we can't write a signature that uses is directly, so rely on inference\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type\nexport function mixinCustomSortOrderColumnAPI<\n TBase extends CustomSortOrderTableColumnConstructor<TColumnValidator>,\n TColumnValidator extends ColumnValidator<['invalidCustomSortWithGrouping']>\n>(base: TBase) {\n /**\n * The Mixin that provides a concrete column with the API to allow sorting\n * by a field other than the default for that column.\n */\n abstract class CustomSortOrderColumn extends base {\n public sortByFieldName?: string;\n\n /** @internal */\n public customSortOrderColumnNotifier?: Notifier;\n\n /** @internal */\n public customSortOrderColumnChangeHandler = {\n handleChange: this.handleCustomSortOrderColumnChange.bind(this)\n };\n\n public getResolvedOperandDataRecordFieldName(\n initialOperandFieldName: string | undefined\n ): string | undefined {\n return typeof this.sortByFieldName === 'string'\n ? this.sortByFieldName\n : initialOperandFieldName;\n }\n\n public getResolvedSortOperation(\n initialSortOperation: TableColumnSortOperation\n ): TableColumnSortOperation {\n return typeof this.sortByFieldName === 'string'\n ? TableColumnSortOperation.basic\n : initialSortOperation;\n }\n\n /** @internal */\n public sortByFieldNameChanged(): void {\n this.handleSortConfigurationChange();\n this.updateCustomColumnSortingValidity();\n\n if (\n typeof this.sortByFieldName === 'string'\n && !this.customSortOrderColumnNotifier\n ) {\n this.customSortOrderColumnNotifier = Observable.getNotifier(\n this.columnInternals\n );\n this.customSortOrderColumnNotifier.subscribe(\n this.customSortOrderColumnChangeHandler\n );\n } else {\n this.customSortOrderColumnNotifier?.unsubscribe(\n this.customSortOrderColumnChangeHandler\n );\n this.customSortOrderColumnNotifier = undefined;\n }\n }\n\n public abstract handleSortConfigurationChange(): void;\n\n /** @internal */\n public handleCustomSortOrderColumnChange(\n _source: unknown,\n args: unknown\n ): void {\n if (args === 'groupingDisabled') {\n this.updateCustomColumnSortingValidity();\n }\n }\n\n /** @internal */\n public updateCustomColumnSortingValidity(): void {\n const hasCustomColumnSorting = typeof this.sortByFieldName === 'string';\n const isGroupingEnabled = !this.columnInternals.groupingDisabled;\n const isValid = !isGroupingEnabled || !hasCustomColumnSorting;\n if (isValid) {\n this.columnInternals.validator.untrack(\n 'invalidCustomSortWithGrouping'\n );\n } else {\n this.columnInternals.validator.track(\n 'invalidCustomSortWithGrouping'\n );\n }\n }\n }\n\n attr({ attribute: 'sort-by-field-name' })(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n CustomSortOrderColumn.prototype,\n 'sortByFieldName'\n );\n\n return CustomSortOrderColumn;\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { TableStringField } from '../../table/types';
|
|
2
2
|
import { TableColumnTextBase } from '../text-base';
|
|
3
|
+
import { TableColumnSortOperation } from '../base/types';
|
|
3
4
|
import type { ColumnInternalsOptions } from '../base/models/column-internals';
|
|
4
5
|
import type { TableColumnTextBaseColumnConfig } from '../text-base/cell-view';
|
|
5
|
-
import {
|
|
6
|
+
import { TableColumnTextValidator } from './models/table-column-text-validator';
|
|
6
7
|
export type TableColumnTextCellRecord = TableStringField<'value'>;
|
|
7
8
|
export interface TableColumnTextColumnConfig extends TableColumnTextBaseColumnConfig {
|
|
8
9
|
}
|
|
@@ -12,17 +13,30 @@ declare global {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
declare const TableColumnText_base: (abstract new (...args: any[]) => {
|
|
16
|
+
sortByFieldName?: string | undefined;
|
|
17
|
+
customSortOrderColumnNotifier?: import("@microsoft/fast-element").Notifier | undefined;
|
|
18
|
+
customSortOrderColumnChangeHandler: {
|
|
19
|
+
handleChange: (_source: unknown, args: unknown) => void;
|
|
20
|
+
};
|
|
21
|
+
getResolvedOperandDataRecordFieldName(initialOperandFieldName: string | undefined): string | undefined;
|
|
22
|
+
getResolvedSortOperation(initialSortOperation: TableColumnSortOperation): TableColumnSortOperation;
|
|
23
|
+
sortByFieldNameChanged(): void;
|
|
24
|
+
handleSortConfigurationChange(): void;
|
|
25
|
+
handleCustomSortOrderColumnChange(_source: unknown, args: unknown): void;
|
|
26
|
+
updateCustomColumnSortingValidity(): void;
|
|
27
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, import("../base/models/column-validator").ColumnValidator<["invalidCustomSortWithGrouping"]>>;
|
|
28
|
+
}) & (abstract new (...args: any[]) => {
|
|
15
29
|
groupingDisabled: boolean;
|
|
16
30
|
groupIndex?: number | null | undefined;
|
|
17
31
|
groupingDisabledChanged(): void;
|
|
18
32
|
groupIndexChanged(): void;
|
|
19
|
-
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, ColumnValidator<[]>>;
|
|
33
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, import("../base/models/column-validator").ColumnValidator<[]>>;
|
|
20
34
|
}) & (abstract new (...args: any[]) => {
|
|
21
35
|
fractionalWidth?: number | null | undefined;
|
|
22
36
|
minPixelWidth?: number | null | undefined;
|
|
23
37
|
fractionalWidthChanged(): void;
|
|
24
38
|
minPixelWidthChanged(): void;
|
|
25
|
-
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, ColumnValidator<[]>>;
|
|
39
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, import("../base/models/column-validator").ColumnValidator<[]>>;
|
|
26
40
|
}) & (abstract new (...args: any[]) => {
|
|
27
41
|
placeholder?: string | undefined;
|
|
28
42
|
placeholderChanged(): void;
|
|
@@ -33,8 +47,8 @@ declare const TableColumnText_base: (abstract new (...args: any[]) => {
|
|
|
33
47
|
sortingDisabledChanged(): void;
|
|
34
48
|
sortDirectionChanged(): void;
|
|
35
49
|
sortIndexChanged(): void;
|
|
36
|
-
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, ColumnValidator<[]>>;
|
|
37
|
-
}) & ((abstract new () => TableColumnTextBase<TableColumnTextColumnConfig,
|
|
50
|
+
readonly columnInternals: import("../base/models/column-internals").ColumnInternals<unknown, import("../base/models/column-validator").ColumnValidator<[]>>;
|
|
51
|
+
}) & ((abstract new () => TableColumnTextBase<TableColumnTextColumnConfig, TableColumnTextValidator>) & {
|
|
38
52
|
compose<T extends import("@microsoft/fast-foundation").FoundationElementDefinition = import("@microsoft/fast-foundation").FoundationElementDefinition, K extends import("@microsoft/fast-element").Constructable<import("@microsoft/fast-foundation").FoundationElement> = import("@microsoft/fast-element").Constructable<import("@microsoft/fast-foundation").FoundationElement>>(this: K, elementDefinition: T): (overrideDefinition?: import("@microsoft/fast-foundation").OverrideFoundationElementDefinition<T> | undefined) => import("@microsoft/fast-foundation").FoundationElementRegistry<T, K>;
|
|
39
53
|
from<TBase extends {
|
|
40
54
|
new (): HTMLElement;
|
|
@@ -46,8 +60,12 @@ declare const TableColumnText_base: (abstract new (...args: any[]) => {
|
|
|
46
60
|
* The table column for displaying string fields as text.
|
|
47
61
|
*/
|
|
48
62
|
export declare class TableColumnText extends TableColumnText_base {
|
|
63
|
+
private readonly defaultSortOperation;
|
|
49
64
|
placeholderChanged(): void;
|
|
50
|
-
|
|
65
|
+
handleSortConfigurationChange(): void;
|
|
66
|
+
protected getColumnInternalsOptions(): ColumnInternalsOptions<TableColumnTextValidator>;
|
|
67
|
+
protected fieldNameChanged(): void;
|
|
68
|
+
private updateColumnInternalsSortConfiguration;
|
|
51
69
|
}
|
|
52
70
|
export declare const tableColumnTextTag = "nimble-table-column-text";
|
|
53
71
|
export {};
|
|
@@ -5,26 +5,42 @@ import { TableColumnTextBase, mixinTextBase } from '../text-base';
|
|
|
5
5
|
import { TableColumnSortOperation } from '../base/types';
|
|
6
6
|
import { tableColumnTextGroupHeaderViewTag } from './group-header-view';
|
|
7
7
|
import { tableColumnTextCellViewTag } from './cell-view';
|
|
8
|
-
import {
|
|
8
|
+
import { mixinCustomSortOrderColumnAPI } from '../mixins/custom-sort-order';
|
|
9
|
+
import { TableColumnTextValidator } from './models/table-column-text-validator';
|
|
9
10
|
/**
|
|
10
11
|
* The table column for displaying string fields as text.
|
|
11
12
|
*/
|
|
12
|
-
export class TableColumnText extends mixinTextBase((TableColumnTextBase)) {
|
|
13
|
+
export class TableColumnText extends mixinCustomSortOrderColumnAPI(mixinTextBase((TableColumnTextBase))) {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.defaultSortOperation = TableColumnSortOperation.localeAwareCaseSensitive;
|
|
17
|
+
}
|
|
13
18
|
placeholderChanged() {
|
|
14
19
|
this.columnInternals.columnConfig = {
|
|
15
20
|
placeholder: this.placeholder
|
|
16
21
|
};
|
|
17
22
|
}
|
|
23
|
+
handleSortConfigurationChange() {
|
|
24
|
+
this.updateColumnInternalsSortConfiguration();
|
|
25
|
+
}
|
|
18
26
|
getColumnInternalsOptions() {
|
|
19
27
|
return {
|
|
20
28
|
cellRecordFieldNames: ['value'],
|
|
21
29
|
cellViewTag: tableColumnTextCellViewTag,
|
|
22
30
|
groupHeaderViewTag: tableColumnTextGroupHeaderViewTag,
|
|
23
31
|
delegatedEvents: [],
|
|
24
|
-
sortOperation:
|
|
25
|
-
validator: new
|
|
32
|
+
sortOperation: this.getResolvedSortOperation(this.defaultSortOperation),
|
|
33
|
+
validator: new TableColumnTextValidator()
|
|
26
34
|
};
|
|
27
35
|
}
|
|
36
|
+
fieldNameChanged() {
|
|
37
|
+
this.columnInternals.dataRecordFieldNames = [this.fieldName];
|
|
38
|
+
this.updateColumnInternalsSortConfiguration();
|
|
39
|
+
}
|
|
40
|
+
updateColumnInternalsSortConfiguration() {
|
|
41
|
+
this.columnInternals.operandDataRecordFieldName = this.getResolvedOperandDataRecordFieldName(this.fieldName);
|
|
42
|
+
this.columnInternals.sortOperation = this.getResolvedSortOperation(this.defaultSortOperation);
|
|
43
|
+
}
|
|
28
44
|
}
|
|
29
45
|
const nimbleTableColumnText = TableColumnText.compose({
|
|
30
46
|
baseName: 'table-column-text',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table-column/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC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C,EAAE,CAAC;IAClD,CAAC;IAEkB,yBAAyB;QACxC,OAAO;YACH,oBAAoB,EAAE,CAAC,OAAO,CAAC;YAC/B,WAAW,EAAE,0BAA0B;YACvC,kBAAkB,EAAE,iCAAiC;YACrD,eAAe,EAAE,EAAE;YACnB,aAAa,EAAE,IAAI,CAAC,wBAAwB,CACxC,IAAI,CAAC,oBAAoB,CAC5B;YACD,SAAS,EAAE,IAAI,wBAAwB,EAAE;SAC5C,CAAC;IACN,CAAC;IAEkB,gBAAgB;QAC/B,IAAI,CAAC,eAAe,CAAC,oBAAoB,GAAG,CAAC,IAAI,CAAC,SAAS,CAAU,CAAC;QACtE,IAAI,CAAC,sCAAsC,EAAE,CAAC;IAClD,CAAC;IAEO,sCAAsC;QAC1C,IAAI,CAAC,eAAe,CAAC,0BAA0B,GAAG,IAAI,CAAC,qCAAqC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7G,IAAI,CAAC,eAAe,CAAC,aAAa,GAAG,IAAI,CAAC,wBAAwB,CAC9D,IAAI,CAAC,oBAAoB,CAC5B,CAAC;IACN,CAAC;CACJ;AAED,MAAM,qBAAqB,GAAG,eAAe,CAAC,OAAO,CAAC;IAClD,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC","sourcesContent":["import { DesignSystem } from '@microsoft/fast-foundation';\nimport { styles } from '../base/styles';\nimport { template } from '../base/template';\nimport type { TableStringField } from '../../table/types';\nimport { TableColumnTextBase, mixinTextBase } from '../text-base';\nimport { TableColumnSortOperation } from '../base/types';\nimport { tableColumnTextGroupHeaderViewTag } from './group-header-view';\nimport { tableColumnTextCellViewTag } from './cell-view';\nimport type { ColumnInternalsOptions } from '../base/models/column-internals';\nimport type { TableColumnTextBaseColumnConfig } from '../text-base/cell-view';\nimport { mixinCustomSortOrderColumnAPI } from '../mixins/custom-sort-order';\nimport { TableColumnTextValidator } from './models/table-column-text-validator';\n\nexport type TableColumnTextCellRecord = TableStringField<'value'>;\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface TableColumnTextColumnConfig\n extends TableColumnTextBaseColumnConfig {}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nimble-table-column-text': TableColumnText;\n }\n}\n\n/**\n * The table column for displaying string fields as text.\n */\nexport class TableColumnText extends mixinCustomSortOrderColumnAPI(\n mixinTextBase(\n TableColumnTextBase<\n TableColumnTextColumnConfig,\n TableColumnTextValidator\n >\n )\n) {\n private readonly defaultSortOperation = TableColumnSortOperation.localeAwareCaseSensitive;\n\n public placeholderChanged(): void {\n this.columnInternals.columnConfig = {\n placeholder: this.placeholder\n };\n }\n\n public override handleSortConfigurationChange(): void {\n this.updateColumnInternalsSortConfiguration();\n }\n\n protected override getColumnInternalsOptions(): ColumnInternalsOptions<TableColumnTextValidator> {\n return {\n cellRecordFieldNames: ['value'],\n cellViewTag: tableColumnTextCellViewTag,\n groupHeaderViewTag: tableColumnTextGroupHeaderViewTag,\n delegatedEvents: [],\n sortOperation: this.getResolvedSortOperation(\n this.defaultSortOperation\n ),\n validator: new TableColumnTextValidator()\n };\n }\n\n protected override fieldNameChanged(): void {\n this.columnInternals.dataRecordFieldNames = [this.fieldName] as const;\n this.updateColumnInternalsSortConfiguration();\n }\n\n private updateColumnInternalsSortConfiguration(): void {\n this.columnInternals.operandDataRecordFieldName = this.getResolvedOperandDataRecordFieldName(this.fieldName);\n this.columnInternals.sortOperation = this.getResolvedSortOperation(\n this.defaultSortOperation\n );\n }\n}\n\nconst nimbleTableColumnText = TableColumnText.compose({\n baseName: 'table-column-text',\n template,\n styles\n});\n\nDesignSystem.getOrCreate()\n .withPrefix('nimble')\n .register(nimbleTableColumnText());\nexport const tableColumnTextTag = 'nimble-table-column-text';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnValidator } from '../../base/models/column-validator';
|
|
2
|
+
export declare const columnTextValidityFlagNames: readonly ["invalidCustomSortWithGrouping"];
|
|
3
|
+
/**
|
|
4
|
+
* Validator class for the text table column.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TableColumnTextValidator extends ColumnValidator<typeof columnTextValidityFlagNames> {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ColumnValidator } from '../../base/models/column-validator';
|
|
2
|
+
export const columnTextValidityFlagNames = [
|
|
3
|
+
'invalidCustomSortWithGrouping'
|
|
4
|
+
];
|
|
5
|
+
/**
|
|
6
|
+
* Validator class for the text table column.
|
|
7
|
+
*/
|
|
8
|
+
export class TableColumnTextValidator extends ColumnValidator {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(columnTextValidityFlagNames);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=table-column-text-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-column-text-validator.js","sourceRoot":"","sources":["../../../../../src/table-column/text/models/table-column-text-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACvC,+BAA+B;CACzB,CAAC;AAEX;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,eAE7C;IACG;QACI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import { ColumnValidator } from '../../base/models/column-validator';\n\nexport const columnTextValidityFlagNames = [\n 'invalidCustomSortWithGrouping'\n] as const;\n\n/**\n * Validator class for the text table column.\n */\nexport class TableColumnTextValidator extends ColumnValidator<\n typeof columnTextValidityFlagNames\n> {\n public constructor() {\n super(columnTextValidityFlagNames);\n }\n}\n"]}
|
|
@@ -18,16 +18,32 @@ export class Tracker {
|
|
|
18
18
|
return this.trackedItems[key];
|
|
19
19
|
}
|
|
20
20
|
track(key) {
|
|
21
|
-
this.trackedItems[key]
|
|
21
|
+
const wasTracked = this.trackedItems[key];
|
|
22
|
+
if (!wasTracked) {
|
|
23
|
+
this.trackedItems[key] = true;
|
|
24
|
+
this.onTrackingChange();
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
untrack(key) {
|
|
24
|
-
this.trackedItems[key]
|
|
28
|
+
const wasTracked = this.trackedItems[key];
|
|
29
|
+
if (wasTracked) {
|
|
30
|
+
this.trackedItems[key] = false;
|
|
31
|
+
this.onTrackingChange();
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
trackAll() {
|
|
35
|
+
if (this.allTracked()) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
27
38
|
this.setAllKeys(true);
|
|
39
|
+
this.onTrackingChange();
|
|
28
40
|
}
|
|
29
41
|
untrackAll() {
|
|
42
|
+
if (this.noneTracked()) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
30
45
|
this.setAllKeys(false);
|
|
46
|
+
this.onTrackingChange();
|
|
31
47
|
}
|
|
32
48
|
allTracked() {
|
|
33
49
|
return Object.values(this.trackedItems).every(x => x);
|
|
@@ -38,6 +54,7 @@ export class Tracker {
|
|
|
38
54
|
noneTracked() {
|
|
39
55
|
return Object.values(this.trackedItems).every(x => !x);
|
|
40
56
|
}
|
|
57
|
+
onTrackingChange() { }
|
|
41
58
|
setAllKeys(value) {
|
|
42
59
|
this.trackedItems = Object.keys(this.trackedItems).reduce((r, key) => {
|
|
43
60
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracker.js","sourceRoot":"","sources":["../../../../src/utilities/models/tracker.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,OAAO,OAAO;IAGhB,YAAmB,gBAAkC;QAEjD,IAAI,CAAC,YAAY,GAAG,EAAkB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,MAAM,CACrD,CAAC,CAAC,EAAE,GAAG,EAAgB,EAAE;YACrB,OAAO;gBACH,GAAG,CAAC;gBACJ,CAAC,GAAG,CAAC,EAAE,KAAK;aACf,CAAC;QACN,CAAC,EACD,IAAI,CAAC,YAAY,CACpB,CAAC;IACN,CAAC;CACJ","sourcesContent":["type ObjectFromList<T extends readonly string[]> = {\n [K in T extends readonly (infer U)[] ? U : never]: boolean;\n};\n\n/**\n * Generic Tracker which sets or resets provided flags\n */\nexport class Tracker<TrackedItemsList extends readonly string[]> {\n private trackedItems: ObjectFromList<TrackedItemsList>;\n\n public constructor(trackedItemsList: TrackedItemsList) {\n type TrackedItems = typeof this.trackedItems;\n this.trackedItems = {} as TrackedItems;\n this.trackedItems = trackedItemsList.reduce<TrackedItems>(\n (r, key): TrackedItems => {\n return {\n ...r,\n [key]: false\n };\n },\n this.trackedItems\n );\n }\n\n public getTrackedItems(): ObjectFromList<TrackedItemsList> {\n return { ...this.trackedItems };\n }\n\n public isTracked(key: keyof ObjectFromList<TrackedItemsList>): boolean {\n return this.trackedItems[key];\n }\n\n public track(key: keyof ObjectFromList<TrackedItemsList>): void {\n const wasTracked = this.trackedItems[key];\n if (!wasTracked) {\n this.trackedItems[key] = true;\n this.onTrackingChange();\n }\n }\n\n public untrack(key: keyof ObjectFromList<TrackedItemsList>): void {\n const wasTracked = this.trackedItems[key];\n if (wasTracked) {\n this.trackedItems[key] = false;\n this.onTrackingChange();\n }\n }\n\n public trackAll(): void {\n if (this.allTracked()) {\n return;\n }\n\n this.setAllKeys(true);\n this.onTrackingChange();\n }\n\n public untrackAll(): void {\n if (this.noneTracked()) {\n return;\n }\n\n this.setAllKeys(false);\n this.onTrackingChange();\n }\n\n public allTracked(): boolean {\n return Object.values(this.trackedItems).every(x => x);\n }\n\n public anyTracked(): boolean {\n return Object.values(this.trackedItems).some(x => x);\n }\n\n public noneTracked(): boolean {\n return Object.values(this.trackedItems).every(x => !x);\n }\n\n public onTrackingChange(): void {}\n\n private setAllKeys(value: boolean): void {\n type TrackedItems = typeof this.trackedItems;\n this.trackedItems = Object.keys(this.trackedItems).reduce<TrackedItems>(\n (r, key): TrackedItems => {\n return {\n ...r,\n [key]: value\n };\n },\n this.trackedItems\n );\n }\n}\n"]}
|