@wcardinal/wcardinal-ui 0.294.0 → 0.295.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/types/wcardinal/ui/d-table-data-tree-item-accessor.d.ts +9 -4
- package/dist/types/wcardinal/ui/d-table-data-tree-selection-impl.d.ts +2 -1
- package/dist/types/wcardinal/ui/d-table-data-tree.d.ts +2 -2
- package/dist/wcardinal/ui/d-table-data-tree-filter.js +12 -8
- package/dist/wcardinal/ui/d-table-data-tree-filter.js.map +1 -1
- package/dist/wcardinal/ui/d-table-data-tree-item-accessor.js +13 -3
- package/dist/wcardinal/ui/d-table-data-tree-item-accessor.js.map +1 -1
- package/dist/wcardinal/ui/d-table-data-tree-selection-impl.js +7 -5
- package/dist/wcardinal/ui/d-table-data-tree-selection-impl.js.map +1 -1
- package/dist/wcardinal/ui/d-table-data-tree.js +5 -4
- package/dist/wcardinal/ui/d-table-data-tree.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark.js +1 -1
- package/dist/wcardinal-ui-theme-dark.min.js +1 -1
- package/dist/wcardinal-ui-theme-white.js +1 -1
- package/dist/wcardinal-ui-theme-white.min.js +1 -1
- package/dist/wcardinal-ui.cjs.js +38 -21
- package/dist/wcardinal-ui.js +38 -21
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
export declare type DTableDataTreeItemAccessorToParent<NODE> = (node: NODE) => NODE | null | undefined;
|
|
2
|
+
export declare type DTableDataTreeItemAccessorToChildren<NODE> = (node: NODE) => NODE[] | null | undefined;
|
|
3
|
+
export declare type DTableDataTreeItemAccessorHasChildren<NODE> = (node: NODE, children?: NODE[] | null) => children is NODE[];
|
|
1
4
|
export interface DTableDataTreeItemAccessorOptions<NODE> {
|
|
2
|
-
toParent?:
|
|
3
|
-
toChildren?:
|
|
5
|
+
toParent?: DTableDataTreeItemAccessorToParent<NODE>;
|
|
6
|
+
toChildren?: DTableDataTreeItemAccessorToChildren<NODE>;
|
|
7
|
+
hasChildren?: DTableDataTreeItemAccessorHasChildren<NODE>;
|
|
4
8
|
}
|
|
5
9
|
export declare class DTableDataTreeItemAccessor<NODE> {
|
|
6
|
-
toParent:
|
|
7
|
-
toChildren:
|
|
10
|
+
toParent: DTableDataTreeItemAccessorToParent<NODE>;
|
|
11
|
+
toChildren: DTableDataTreeItemAccessorToChildren<NODE>;
|
|
12
|
+
hasChildren: DTableDataTreeItemAccessorHasChildren<NODE>;
|
|
8
13
|
constructor(options?: DTableDataTreeItemAccessorOptions<NODE>);
|
|
9
14
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { utils } from "pixi.js";
|
|
2
2
|
import { DTableData } from "./d-table-data";
|
|
3
3
|
import { DTableDataSelectionEachIteratee, DTableDataSelectionOptions, DTableDataSelectionType } from "./d-table-data-selection";
|
|
4
|
+
import { DTableDataTreeItemAccessorHasChildren, DTableDataTreeItemAccessorToChildren } from "./d-table-data-tree-item-accessor";
|
|
4
5
|
import { DTableDataTreeSelection, DTableDataTreeSelectionParent } from "./d-table-data-tree-selection";
|
|
5
6
|
export declare class DTableDataTreeSelectionImpl<NODE> extends utils.EventEmitter implements DTableDataTreeSelection<NODE> {
|
|
6
7
|
protected _parent: DTableDataTreeSelectionParent<NODE>;
|
|
@@ -9,7 +10,7 @@ export declare class DTableDataTreeSelectionImpl<NODE> extends utils.EventEmitte
|
|
|
9
10
|
constructor(parent: DTableDataTreeSelectionParent<NODE>, options?: DTableDataSelectionOptions);
|
|
10
11
|
get parent(): DTableData<NODE>;
|
|
11
12
|
onNodeChange(nodes?: NODE[]): void;
|
|
12
|
-
protected newRows(nodes: NODE[], toChildren:
|
|
13
|
+
protected newRows(nodes: NODE[], toChildren: DTableDataTreeItemAccessorToChildren<NODE>, hasChildren: DTableDataTreeItemAccessorHasChildren<NODE>, rows: Set<NODE>, result: Set<NODE>): Set<NODE>;
|
|
13
14
|
get indices(): number[];
|
|
14
15
|
get rows(): NODE[];
|
|
15
16
|
get type(): DTableDataSelectionType;
|
|
@@ -6,7 +6,7 @@ import { DTableDataSelection } from "./d-table-data-selection";
|
|
|
6
6
|
import { DTableDataComparator, DTableDataSorter } from "./d-table-data-sorter";
|
|
7
7
|
import { DTableDataTreeSorter } from "./d-table-data-tree-sorter";
|
|
8
8
|
import { DTableDataTreeNode } from "./d-table-data-tree-item";
|
|
9
|
-
import { DTableDataTreeItemAccessor, DTableDataTreeItemAccessorOptions } from "./d-table-data-tree-item-accessor";
|
|
9
|
+
import { DTableDataTreeItemAccessor, DTableDataTreeItemAccessorHasChildren, DTableDataTreeItemAccessorOptions, DTableDataTreeItemAccessorToChildren } from "./d-table-data-tree-item-accessor";
|
|
10
10
|
import { DTableDataTreeSelection, DTableDataTreeSelectionCreator, DTableDataTreeSelectionOptions } from "./d-table-data-tree-selection";
|
|
11
11
|
import { DBaseEvents } from "./d-base";
|
|
12
12
|
import { DOnOptions } from "./d-on-options";
|
|
@@ -88,7 +88,7 @@ export declare class DTableDataTree<NODE extends DTableDataTreeNode<NODE, NODE>>
|
|
|
88
88
|
get accessor(): DTableDataTreeItemAccessor<NODE>;
|
|
89
89
|
protected updateRows(nodes: NODE[] | undefined): void;
|
|
90
90
|
protected toSupplimental(ilevel: number, hasChildren: boolean, isOpened: boolean): number;
|
|
91
|
-
protected newRows(nodes: NODE[], irows: number, ilevel: number, rows: NODE[], supplimentals: number[], flags: WeakMap<NODE, number>, reverse: boolean, toChildren:
|
|
91
|
+
protected newRows(nodes: NODE[], irows: number, ilevel: number, rows: NODE[], supplimentals: number[], flags: WeakMap<NODE, number>, reverse: boolean, toChildren: DTableDataTreeItemAccessorToChildren<NODE>, hasChildren: DTableDataTreeItemAccessorHasChildren<NODE>): number;
|
|
92
92
|
update(forcibly?: boolean): void;
|
|
93
93
|
size(): number;
|
|
94
94
|
get(index: number): NODE | null;
|
|
@@ -48,43 +48,47 @@ var DTableDataTreeFilter = /** @class */ (function (_super) {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
DTableDataTreeFilter.prototype.hasFiltered = function (parent, nodes, filter) {
|
|
51
|
-
var
|
|
51
|
+
var accessor = this._parent.accessor;
|
|
52
|
+
var toChildren = accessor.toChildren;
|
|
53
|
+
var hasChildren = accessor.hasChildren;
|
|
52
54
|
for (var i = 0, imax = nodes.length; i < imax; ++i) {
|
|
53
55
|
var node = nodes[i];
|
|
54
56
|
if (this.isFiltered(node, -1, filter)) {
|
|
55
57
|
return true;
|
|
56
58
|
}
|
|
57
59
|
var children = toChildren(node);
|
|
58
|
-
if (children
|
|
59
|
-
0 < children.length &&
|
|
60
|
-
this.hasFiltered(parent, children, filter)) {
|
|
60
|
+
if (hasChildren(node, children) && this.hasFiltered(parent, children, filter)) {
|
|
61
61
|
return true;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
return false;
|
|
65
65
|
};
|
|
66
66
|
DTableDataTreeFilter.prototype.addAllToFiltered = function (parent, nodes, filtered, cursor) {
|
|
67
|
-
var
|
|
67
|
+
var accessor = this._parent.accessor;
|
|
68
|
+
var toChildren = accessor.toChildren;
|
|
69
|
+
var hasChildren = accessor.hasChildren;
|
|
68
70
|
for (var i = 0, imax = nodes.length; i < imax; ++i) {
|
|
69
71
|
var node = nodes[i];
|
|
70
72
|
filtered.push(cursor[0]);
|
|
71
73
|
cursor[0] += 1;
|
|
72
74
|
var children = toChildren(node);
|
|
73
|
-
if (
|
|
75
|
+
if (hasChildren(node, children) && parent.isOpened(node)) {
|
|
74
76
|
this.addAllToFiltered(parent, children, filtered, cursor);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
};
|
|
78
80
|
DTableDataTreeFilter.prototype.newFilteredSub = function (parent, nodes, filter, filtered, cursor) {
|
|
79
81
|
var result = false;
|
|
80
|
-
var
|
|
82
|
+
var accessor = this._parent.accessor;
|
|
83
|
+
var toChildren = accessor.toChildren;
|
|
84
|
+
var hasChildren = accessor.hasChildren;
|
|
81
85
|
for (var i = 0, imax = nodes.length; i < imax; ++i) {
|
|
82
86
|
var node = nodes[i];
|
|
83
87
|
var index = cursor[0];
|
|
84
88
|
cursor[0] += 1;
|
|
85
89
|
var isFiltered = this.isFiltered(node, index, filter);
|
|
86
90
|
var children = toChildren(node);
|
|
87
|
-
if (
|
|
91
|
+
if (hasChildren(node, children)) {
|
|
88
92
|
if (parent.isOpened(node)) {
|
|
89
93
|
if (isFiltered) {
|
|
90
94
|
filtered.push(index);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-table-data-tree-filter.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-table-data-tree-filter.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIhC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAShD;IACS,wCAAkB;IAU1B,8BAAY,MAAwC;QAApD,YACC,iBAAO,SASP;QAPA,KAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QACb,KAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;QACrB,KAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAExB,KAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,KAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,KAAI,CAAC,SAAS,GAAG,IAAI,CAAC;;IACvB,CAAC;IAED,sBAAI,oCAAE;aAAN;YACC,OAAO,IAAI,CAAC,GAAG,CAAC;QACjB,CAAC;;;OAAA;IAED,oCAAK,GAAL;QACC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;IAED,sCAAO,GAAP;QACC,IAAI,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,CAA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M,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACtC,IAAI,CAAC,IAAI,KAAK,EAAE;gBACf,MAAM,GAAG,KAAK,CAAC;aACf;iBAAM;gBACN,OAAO,IAAI,CAAC;aACZ;SACD;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAED,oCAAK,GAAL,UAAM,KAAa;QAClB,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,OAAO,EAAE;YACZ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;SACzB;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IACF,2BAAC;AAAD,CAAC,AA/MD,CACS,KAAK,CAAC,YAAY,GA8M1B","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DTableDataFilter, DTableDataFilterer } from \"./d-table-data-filter\";\nimport { DTableDataTreeNode } from \"./d-table-data-tree-item\";\nimport { DTableDataTreeItemAccessor } from \"./d-table-data-tree-item-accessor\";\nimport { isFunction } from \"./util/is-function\";\n\nexport interface DTableDataTreeFilterParent<NODE> {\n\treadonly nodes: NODE[] | undefined;\n\treadonly accessor: DTableDataTreeItemAccessor<NODE>;\n\tisOpened(node: NODE): boolean;\n\tupdate(): void;\n}\n\nexport class DTableDataTreeFilter<NODE extends DTableDataTreeNode<NODE, NODE>>\n\textends utils.EventEmitter\n\timplements DTableDataFilter<NODE>\n{\n\tprotected _id: number;\n\tprotected _idUpdated: number;\n\tprotected _isApplied: boolean;\n\tprotected _parent: DTableDataTreeFilterParent<NODE>;\n\tprotected _filter: DTableDataFilterer<NODE> | null;\n\tprotected _filtered: number[] | null;\n\n\tconstructor(parent: DTableDataTreeFilterParent<NODE>) {\n\t\tsuper();\n\n\t\tthis._id = 0;\n\t\tthis._idUpdated = -1;\n\t\tthis._isApplied = false;\n\n\t\tthis._parent = parent;\n\t\tthis._filter = null;\n\t\tthis._filtered = null;\n\t}\n\n\tget id(): number {\n\t\treturn this._id;\n\t}\n\n\tapply(): void {\n\t\tthis._isApplied = true;\n\t\tthis._id += 1;\n\t\tthis._parent.update();\n\t}\n\n\tunapply(): void {\n\t\tif (this._isApplied) {\n\t\t\tthis._isApplied = false;\n\t\t\tthis._id += 1;\n\t\t\tthis._parent.update();\n\t\t}\n\t}\n\n\tisApplied(): boolean {\n\t\treturn this._isApplied;\n\t}\n\n\tprotected isFiltered(node: NODE, index: number, filter: DTableDataFilterer<NODE>): boolean {\n\t\tif (isFunction(filter)) {\n\t\t\treturn filter(node, index);\n\t\t} else {\n\t\t\treturn filter.test(node, index);\n\t\t}\n\t}\n\n\tprotected hasFiltered(\n\t\tparent: DTableDataTreeFilterParent<NODE>,\n\t\tnodes: NODE[],\n\t\tfilter: DTableDataFilterer<NODE>\n\t): boolean {\n\t\tconst toChildren = this._parent.accessor.toChildren;\n\t\tfor (let i = 0, imax = nodes.length; i < imax; ++i) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (this.isFiltered(node, -1, filter)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst children = toChildren(node);\n\t\t\tif (\n\t\t\t\tchildren != null &&\n\t\t\t\t0 < children.length &&\n\t\t\t\tthis.hasFiltered(parent, children, filter)\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected addAllToFiltered(\n\t\tparent: DTableDataTreeFilterParent<NODE>,\n\t\tnodes: NODE[],\n\t\tfiltered: number[],\n\t\tcursor: [number]\n\t): void {\n\t\tconst toChildren = this._parent.accessor.toChildren;\n\t\tfor (let i = 0, imax = nodes.length; i < imax; ++i) {\n\t\t\tconst node = nodes[i];\n\t\t\tfiltered.push(cursor[0]);\n\t\t\tcursor[0] += 1;\n\t\t\tconst children = toChildren(node);\n\t\t\tif (children != null && 0 < children.length && parent.isOpened(node)) {\n\t\t\t\tthis.addAllToFiltered(parent, children, filtered, cursor);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected newFilteredSub(\n\t\tparent: DTableDataTreeFilterParent<NODE>,\n\t\tnodes: NODE[],\n\t\tfilter: DTableDataFilterer<NODE>,\n\t\tfiltered: number[],\n\t\tcursor: [number]\n\t): boolean {\n\t\tlet result = false;\n\t\tconst toChildren = this._parent.accessor.toChildren;\n\t\tfor (let i = 0, imax = nodes.length; i < imax; ++i) {\n\t\t\tconst node = nodes[i];\n\t\t\tconst index = cursor[0];\n\t\t\tcursor[0] += 1;\n\t\t\tconst isFiltered = this.isFiltered(node, index, filter);\n\t\t\tconst children = toChildren(node);\n\t\t\tif (children != null && 0 < children.length) {\n\t\t\t\tif (parent.isOpened(node)) {\n\t\t\t\t\tif (isFiltered) {\n\t\t\t\t\t\tfiltered.push(index);\n\t\t\t\t\t\tresult = true;\n\t\t\t\t\t\tthis.addAllToFiltered(parent, children, filtered, cursor);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst position = filtered.length;\n\t\t\t\t\t\tif (this.newFilteredSub(parent, children, filter, filtered, cursor)) {\n\t\t\t\t\t\t\tfiltered.splice(position, 0, index);\n\t\t\t\t\t\t\tresult = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (isFiltered || this.hasFiltered(parent, children, filter)) {\n\t\t\t\t\tfiltered.push(index);\n\t\t\t\t\tresult = true;\n\t\t\t\t}\n\t\t\t} else if (isFiltered) {\n\t\t\t\tfiltered.push(index);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected newFiltered(): number[] | null {\n\t\tconst filter = this._filter;\n\t\tif (filter != null) {\n\t\t\tconst filtered: number[] = [];\n\t\t\tconst parent = this._parent;\n\t\t\tconst nodes = parent.nodes;\n\t\t\tif (nodes) {\n\t\t\t\tconst cursor: [number] = [0];\n\t\t\t\tthis.newFilteredSub(parent, nodes, filter, filtered, cursor);\n\t\t\t}\n\t\t\treturn filtered;\n\t\t}\n\t\treturn null;\n\t}\n\n\tget(): DTableDataFilterer<NODE> | null {\n\t\treturn this._filter;\n\t}\n\n\tset(filter: DTableDataFilterer<NODE> | null): void {\n\t\tif (this._filter !== filter) {\n\t\t\tthis._filter = filter;\n\t\t}\n\t}\n\n\ttoDirty(): void {\n\t\tthis._id += 1;\n\t}\n\n\tupdate(): void {\n\t\tif (this._id !== this._idUpdated) {\n\t\t\tthis._idUpdated = this._id;\n\t\t\tif (this._isApplied) {\n\t\t\t\tthis._filtered = this.newFiltered();\n\t\t\t\tthis.emit(\"change\", this);\n\t\t\t} else if (this._filtered != null) {\n\t\t\t\tthis._filtered = null;\n\t\t\t\tthis.emit(\"change\", this);\n\t\t\t}\n\t\t}\n\t}\n\n\tget indices(): number[] | null {\n\t\tthis.update();\n\t\treturn this._filtered;\n\t}\n\n\tmap(sortedIndex: number): number | null {\n\t\tlet result = sortedIndex;\n\n\t\tconst indices = this.indices;\n\t\tif (indices) {\n\t\t\tconst index = indices.indexOf(result);\n\t\t\tif (0 <= index) {\n\t\t\t\tresult = index;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tunmap(index: number): number {\n\t\tlet result = index;\n\n\t\tconst indices = this.indices;\n\t\tif (indices) {\n\t\t\tresult = indices[result];\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"d-table-data-tree-filter.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-table-data-tree-filter.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIhC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAShD;IACS,wCAAkB;IAU1B,8BAAY,MAAwC;QAApD,YACC,iBAAO,SASP;QAPA,KAAI,CAAC,GAAG,GAAG,CAAC,CAA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AgN1B","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DTableDataFilter, DTableDataFilterer } from \"./d-table-data-filter\";\nimport { DTableDataTreeNode } from \"./d-table-data-tree-item\";\nimport { DTableDataTreeItemAccessor } from \"./d-table-data-tree-item-accessor\";\nimport { isFunction } from \"./util/is-function\";\n\nexport interface DTableDataTreeFilterParent<NODE> {\n\treadonly nodes: NODE[] | undefined;\n\treadonly accessor: DTableDataTreeItemAccessor<NODE>;\n\tisOpened(node: NODE): boolean;\n\tupdate(): void;\n}\n\nexport class DTableDataTreeFilter<NODE extends DTableDataTreeNode<NODE, NODE>>\n\textends utils.EventEmitter\n\timplements DTableDataFilter<NODE>\n{\n\tprotected _id: number;\n\tprotected _idUpdated: number;\n\tprotected _isApplied: boolean;\n\tprotected _parent: DTableDataTreeFilterParent<NODE>;\n\tprotected _filter: DTableDataFilterer<NODE> | null;\n\tprotected _filtered: number[] | null;\n\n\tconstructor(parent: DTableDataTreeFilterParent<NODE>) {\n\t\tsuper();\n\n\t\tthis._id = 0;\n\t\tthis._idUpdated = -1;\n\t\tthis._isApplied = false;\n\n\t\tthis._parent = parent;\n\t\tthis._filter = null;\n\t\tthis._filtered = null;\n\t}\n\n\tget id(): number {\n\t\treturn this._id;\n\t}\n\n\tapply(): void {\n\t\tthis._isApplied = true;\n\t\tthis._id += 1;\n\t\tthis._parent.update();\n\t}\n\n\tunapply(): void {\n\t\tif (this._isApplied) {\n\t\t\tthis._isApplied = false;\n\t\t\tthis._id += 1;\n\t\t\tthis._parent.update();\n\t\t}\n\t}\n\n\tisApplied(): boolean {\n\t\treturn this._isApplied;\n\t}\n\n\tprotected isFiltered(node: NODE, index: number, filter: DTableDataFilterer<NODE>): boolean {\n\t\tif (isFunction(filter)) {\n\t\t\treturn filter(node, index);\n\t\t} else {\n\t\t\treturn filter.test(node, index);\n\t\t}\n\t}\n\n\tprotected hasFiltered(\n\t\tparent: DTableDataTreeFilterParent<NODE>,\n\t\tnodes: NODE[],\n\t\tfilter: DTableDataFilterer<NODE>\n\t): boolean {\n\t\tconst accessor = this._parent.accessor;\n\t\tconst toChildren = accessor.toChildren;\n\t\tconst hasChildren = accessor.hasChildren;\n\t\tfor (let i = 0, imax = nodes.length; i < imax; ++i) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (this.isFiltered(node, -1, filter)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst children = toChildren(node);\n\t\t\tif (hasChildren(node, children) && this.hasFiltered(parent, children, filter)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected addAllToFiltered(\n\t\tparent: DTableDataTreeFilterParent<NODE>,\n\t\tnodes: NODE[],\n\t\tfiltered: number[],\n\t\tcursor: [number]\n\t): void {\n\t\tconst accessor = this._parent.accessor;\n\t\tconst toChildren = accessor.toChildren;\n\t\tconst hasChildren = accessor.hasChildren;\n\t\tfor (let i = 0, imax = nodes.length; i < imax; ++i) {\n\t\t\tconst node = nodes[i];\n\t\t\tfiltered.push(cursor[0]);\n\t\t\tcursor[0] += 1;\n\t\t\tconst children = toChildren(node);\n\t\t\tif (hasChildren(node, children) && parent.isOpened(node)) {\n\t\t\t\tthis.addAllToFiltered(parent, children, filtered, cursor);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected newFilteredSub(\n\t\tparent: DTableDataTreeFilterParent<NODE>,\n\t\tnodes: NODE[],\n\t\tfilter: DTableDataFilterer<NODE>,\n\t\tfiltered: number[],\n\t\tcursor: [number]\n\t): boolean {\n\t\tlet result = false;\n\t\tconst accessor = this._parent.accessor;\n\t\tconst toChildren = accessor.toChildren;\n\t\tconst hasChildren = accessor.hasChildren;\n\t\tfor (let i = 0, imax = nodes.length; i < imax; ++i) {\n\t\t\tconst node = nodes[i];\n\t\t\tconst index = cursor[0];\n\t\t\tcursor[0] += 1;\n\t\t\tconst isFiltered = this.isFiltered(node, index, filter);\n\t\t\tconst children = toChildren(node);\n\t\t\tif (hasChildren(node, children)) {\n\t\t\t\tif (parent.isOpened(node)) {\n\t\t\t\t\tif (isFiltered) {\n\t\t\t\t\t\tfiltered.push(index);\n\t\t\t\t\t\tresult = true;\n\t\t\t\t\t\tthis.addAllToFiltered(parent, children, filtered, cursor);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst position = filtered.length;\n\t\t\t\t\t\tif (this.newFilteredSub(parent, children, filter, filtered, cursor)) {\n\t\t\t\t\t\t\tfiltered.splice(position, 0, index);\n\t\t\t\t\t\t\tresult = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (isFiltered || this.hasFiltered(parent, children, filter)) {\n\t\t\t\t\tfiltered.push(index);\n\t\t\t\t\tresult = true;\n\t\t\t\t}\n\t\t\t} else if (isFiltered) {\n\t\t\t\tfiltered.push(index);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected newFiltered(): number[] | null {\n\t\tconst filter = this._filter;\n\t\tif (filter != null) {\n\t\t\tconst filtered: number[] = [];\n\t\t\tconst parent = this._parent;\n\t\t\tconst nodes = parent.nodes;\n\t\t\tif (nodes) {\n\t\t\t\tconst cursor: [number] = [0];\n\t\t\t\tthis.newFilteredSub(parent, nodes, filter, filtered, cursor);\n\t\t\t}\n\t\t\treturn filtered;\n\t\t}\n\t\treturn null;\n\t}\n\n\tget(): DTableDataFilterer<NODE> | null {\n\t\treturn this._filter;\n\t}\n\n\tset(filter: DTableDataFilterer<NODE> | null): void {\n\t\tif (this._filter !== filter) {\n\t\t\tthis._filter = filter;\n\t\t}\n\t}\n\n\ttoDirty(): void {\n\t\tthis._id += 1;\n\t}\n\n\tupdate(): void {\n\t\tif (this._id !== this._idUpdated) {\n\t\t\tthis._idUpdated = this._id;\n\t\t\tif (this._isApplied) {\n\t\t\t\tthis._filtered = this.newFiltered();\n\t\t\t\tthis.emit(\"change\", this);\n\t\t\t} else if (this._filtered != null) {\n\t\t\t\tthis._filtered = null;\n\t\t\t\tthis.emit(\"change\", this);\n\t\t\t}\n\t\t}\n\t}\n\n\tget indices(): number[] | null {\n\t\tthis.update();\n\t\treturn this._filtered;\n\t}\n\n\tmap(sortedIndex: number): number | null {\n\t\tlet result = sortedIndex;\n\n\t\tconst indices = this.indices;\n\t\tif (indices) {\n\t\t\tconst index = indices.indexOf(result);\n\t\t\tif (0 <= index) {\n\t\t\t\tresult = index;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tunmap(index: number): number {\n\t\tlet result = index;\n\n\t\tconst indices = this.indices;\n\t\tif (indices) {\n\t\t\tresult = indices[result];\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"]}
|
|
@@ -8,11 +8,21 @@ var toParent = function (node) {
|
|
|
8
8
|
var toChildren = function (node) {
|
|
9
9
|
return node.children;
|
|
10
10
|
};
|
|
11
|
+
var hasChildren = function (node, children) {
|
|
12
|
+
return children != null && 0 < children.length;
|
|
13
|
+
};
|
|
11
14
|
var DTableDataTreeItemAccessor = /** @class */ (function () {
|
|
12
15
|
function DTableDataTreeItemAccessor(options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
if (options != null) {
|
|
17
|
+
this.toParent = options.toParent || toParent;
|
|
18
|
+
this.toChildren = options.toChildren || toChildren;
|
|
19
|
+
this.hasChildren = options.hasChildren || hasChildren;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.toParent = toParent;
|
|
23
|
+
this.toChildren = toChildren;
|
|
24
|
+
this.hasChildren = hasChildren;
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
return DTableDataTreeItemAccessor;
|
|
18
28
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-table-data-tree-item-accessor.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-table-data-tree-item-accessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"d-table-data-tree-item-accessor.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-table-data-tree-item-accessor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,IAAM,QAAQ,GAAG,UAAO,IAAS;IAChC,OAAO,IAAI,CAAC,MAAM,CAAC;AACpB,CAAC,CAAC;AAEF,IAAM,UAAU,GAAG,UAAO,IAAS;IAClC,OAAO,IAAI,CAAC,QAAQ,CAAC;AACtB,CAAC,CAAC;AAEF,IAAM,WAAW,GAAG,UAAO,IAAS,EAAE,QAAmC;IACxE,OAAO,QAAQ,IAAI,IAAI,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;AAChD,CAAC,CAAC;AAEF;IAKC,oCAAY,OAAiD;QAC5D,IAAI,OAAO,IAAI,IAAI,EAAE;YACpB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC;YAC7C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,UAAU,CAAC;YACnD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,WAAW,CAAC;SACtD;aAAM;YACN,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;YAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;SAC/B;IACF,CAAC;IACF,iCAAC;AAAD,CAAC,AAhBD,IAgBC","sourcesContent":["/*\n * Copyright (C) 2021 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport type DTableDataTreeItemAccessorToParent<NODE> = (node: NODE) => NODE | null | undefined;\n\nexport type DTableDataTreeItemAccessorToChildren<NODE> = (node: NODE) => NODE[] | null | undefined;\n\nexport type DTableDataTreeItemAccessorHasChildren<NODE> = (\n\tnode: NODE,\n\tchildren?: NODE[] | null\n) => children is NODE[];\n\nexport interface DTableDataTreeItemAccessorOptions<NODE> {\n\ttoParent?: DTableDataTreeItemAccessorToParent<NODE>;\n\ttoChildren?: DTableDataTreeItemAccessorToChildren<NODE>;\n\thasChildren?: DTableDataTreeItemAccessorHasChildren<NODE>;\n}\n\nconst toParent = <NODE>(node: any): NODE | null | undefined => {\n\treturn node.parent;\n};\n\nconst toChildren = <NODE>(node: any): NODE | null | undefined => {\n\treturn node.children;\n};\n\nconst hasChildren = <NODE>(node: any, children: NODE[] | null | undefined): children is NODE[] => {\n\treturn children != null && 0 < children.length;\n};\n\nexport class DTableDataTreeItemAccessor<NODE> {\n\ttoParent: DTableDataTreeItemAccessorToParent<NODE>;\n\ttoChildren: DTableDataTreeItemAccessorToChildren<NODE>;\n\thasChildren: DTableDataTreeItemAccessorHasChildren<NODE>;\n\n\tconstructor(options?: DTableDataTreeItemAccessorOptions<NODE>) {\n\t\tif (options != null) {\n\t\t\tthis.toParent = options.toParent || toParent;\n\t\t\tthis.toChildren = options.toChildren || toChildren;\n\t\t\tthis.hasChildren = options.hasChildren || hasChildren;\n\t\t} else {\n\t\t\tthis.toParent = toParent;\n\t\t\tthis.toChildren = toChildren;\n\t\t\tthis.hasChildren = hasChildren;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -39,9 +39,11 @@ var DTableDataTreeSelectionImpl = /** @class */ (function (_super) {
|
|
|
39
39
|
});
|
|
40
40
|
DTableDataTreeSelectionImpl.prototype.onNodeChange = function (nodes) {
|
|
41
41
|
if (nodes != null) {
|
|
42
|
-
var
|
|
42
|
+
var accessor = this._parent.accessor;
|
|
43
|
+
var toChildren = accessor.toChildren;
|
|
44
|
+
var hasChildren = accessor.hasChildren;
|
|
43
45
|
var oldRows = this._rows;
|
|
44
|
-
var newRows = this.newRows(nodes, toChildren, oldRows, new Set());
|
|
46
|
+
var newRows = this.newRows(nodes, toChildren, hasChildren, oldRows, new Set());
|
|
45
47
|
if (oldRows.size !== newRows.size) {
|
|
46
48
|
this._rows = newRows;
|
|
47
49
|
this.onChange();
|
|
@@ -55,15 +57,15 @@ var DTableDataTreeSelectionImpl = /** @class */ (function (_super) {
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
|
-
DTableDataTreeSelectionImpl.prototype.newRows = function (nodes, toChildren, rows, result) {
|
|
60
|
+
DTableDataTreeSelectionImpl.prototype.newRows = function (nodes, toChildren, hasChildren, rows, result) {
|
|
59
61
|
for (var i = 0, imax = nodes.length; i < imax; ++i) {
|
|
60
62
|
var node = nodes[i];
|
|
61
63
|
if (rows.has(node)) {
|
|
62
64
|
result.add(node);
|
|
63
65
|
}
|
|
64
66
|
var children = toChildren(node);
|
|
65
|
-
if (children
|
|
66
|
-
this.newRows(children, toChildren, rows, result);
|
|
67
|
+
if (hasChildren(node, children)) {
|
|
68
|
+
this.newRows(children, toChildren, hasChildren, rows, result);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-table-data-tree-selection-impl.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-table-data-tree-selection-impl.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAGN,uBAAuB,EACvB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,IAAM,UAAU,GAAG,UAAC,CAAoB,EAAE,CAAoB;IAC7D,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF;IACS,+CAAkB;IAO1B,qCAAY,MAA2C,EAAE,OAAoC;QAA7F,iBAgBC;;gBAfA,iBAAO;QACP,KAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,KAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAA,OAAO,aAAP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M,MAAM,GAAG,IAAI,GAAG,EAAgB,CAAC;QACvC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,GAAS,EAAE,KAAa;YAC1C,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAClB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;aACvB;QACF,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IACf,CAAC;IACF,kCAAC;AAAD,CAAC,AArVD,CACS,KAAK,CAAC,YAAY,GAoV1B","sourcesContent":["/*\n * Copyright (C) 2021 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DTableData } from \"./d-table-data\";\nimport {\n\tDTableDataSelectionEachIteratee,\n\tDTableDataSelectionOptions,\n\tDTableDataSelectionType\n} from \"./d-table-data-selection\";\nimport {\n\tDTableDataTreeSelection,\n\tDTableDataTreeSelectionParent\n} from \"./d-table-data-tree-selection\";\nimport { toEnum } from \"./util/to-enum\";\n\nconst COMPARATOR = (a: [number, unknown], b: [number, unknown]): number => {\n\treturn a[0] - b[0];\n};\n\nexport class DTableDataTreeSelectionImpl<NODE>\n\textends utils.EventEmitter\n\timplements DTableDataTreeSelection<NODE>\n{\n\tprotected _parent: DTableDataTreeSelectionParent<NODE>;\n\tprotected _type: DTableDataSelectionType;\n\tprotected _rows: Set<NODE>;\n\n\tconstructor(parent: DTableDataTreeSelectionParent<NODE>, options?: DTableDataSelectionOptions) {\n\t\tsuper();\n\t\tthis._parent = parent;\n\t\tthis._type = toEnum(options?.type ?? DTableDataSelectionType.NONE, DTableDataSelectionType);\n\t\tthis._rows = new Set<NODE>();\n\n\t\t// Events\n\t\tconst on = options?.on;\n\t\tif (on) {\n\t\t\tfor (const name in on) {\n\t\t\t\tconst handler = on[name];\n\t\t\t\tif (handler) {\n\t\t\t\t\tthis.on(name, handler);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tget parent(): DTableData<NODE> {\n\t\treturn this._parent;\n\t}\n\n\tonNodeChange(nodes?: NODE[]): void {\n\t\tif (nodes != null) {\n\t\t\tconst toChildren = this._parent.accessor.toChildren;\n\t\t\tconst oldRows = this._rows;\n\t\t\tconst newRows = this.newRows(nodes, toChildren, oldRows, new Set<NODE>());\n\t\t\tif (oldRows.size !== newRows.size) {\n\t\t\t\tthis._rows = newRows;\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t} else {\n\t\t\tconst rows = this._rows;\n\t\t\tif (0 < rows.size) {\n\t\t\t\trows.clear();\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected newRows(\n\t\tnodes: NODE[],\n\t\ttoChildren: (node: NODE) => NODE[] | null | undefined,\n\t\trows: Set<NODE>,\n\t\tresult: Set<NODE>\n\t): Set<NODE> {\n\t\tfor (let i = 0, imax = nodes.length; i < imax; ++i) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (rows.has(node)) {\n\t\t\t\tresult.add(node);\n\t\t\t}\n\t\t\tconst children = toChildren(node);\n\t\t\tif (children != null) {\n\t\t\t\tthis.newRows(children, toChildren, rows, result);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tget indices(): number[] {\n\t\tconst rows = this._rows;\n\t\tconst result: number[] = [];\n\t\tthis._parent.each((row: NODE, index: number): void => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tresult.push(index);\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n\n\tget rows(): NODE[] {\n\t\tconst result: NODE[] = [];\n\t\tthis._rows.forEach((row: NODE): void => {\n\t\t\tresult.push(row);\n\t\t});\n\t\treturn result;\n\t}\n\n\tget type(): DTableDataSelectionType {\n\t\treturn this._type;\n\t}\n\n\tprotected getFirst(): NODE | null {\n\t\tconst rows = this._rows;\n\t\tif (0 < rows.size) {\n\t\t\tlet result: NODE | null = null;\n\t\t\trows.forEach((row: NODE): void => {\n\t\t\t\tif (result == null) {\n\t\t\t\t\tresult = row;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\t\treturn null;\n\t}\n\n\tprotected getLast(): NODE | null {\n\t\tconst rows = this._rows;\n\t\tif (0 < rows.size) {\n\t\t\tlet result: NODE | null = null;\n\t\t\trows.forEach((row: NODE): void => {\n\t\t\t\tresult = row;\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\t\treturn null;\n\t}\n\n\tprotected toIndex(target: NODE): number | null {\n\t\tlet result: number | null = null;\n\t\tthis._parent.each((row: NODE, index: number): boolean => {\n\t\t\tif (target === row) {\n\t\t\t\tresult = index;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\t\treturn result;\n\t}\n\n\tget first(): number | null {\n\t\tconst row = this.getFirst();\n\t\tif (row) {\n\t\t\treturn this.toIndex(row);\n\t\t}\n\t\treturn null;\n\t}\n\n\tget last(): number | null {\n\t\tconst row = this.getLast();\n\t\tif (row) {\n\t\t\treturn this.toIndex(row);\n\t\t}\n\t\treturn null;\n\t}\n\n\tprotected onChange(): void {\n\t\tthis._parent.update();\n\t\tthis.emit(\"change\", this);\n\t}\n\n\ttoggle(rowIndex: number): void {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\tconst rows = this._rows;\n\t\t\tif (rows.has(row)) {\n\t\t\t\trows.delete(row);\n\t\t\t} else {\n\t\t\t\trows.add(row);\n\t\t\t}\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\tadd(rowIndex: number): void {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\tconst rows = this._rows;\n\t\t\tif (!rows.has(row)) {\n\t\t\t\trows.add(row);\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t}\n\t}\n\n\taddTo(rowIndex: number): void {\n\t\tconst lastRowIndex = this.last;\n\t\tif (lastRowIndex != null) {\n\t\t\tthis.addRange(lastRowIndex, false, rowIndex, true);\n\t\t}\n\t}\n\n\taddRange(from: number, includeFrom: boolean, to: number, includeTo: boolean): void {\n\t\tconst rows = this._rows;\n\t\tconst oldSize = rows.size;\n\t\tconst parent = this._parent;\n\t\tif (from < to) {\n\t\t\tparent.each(\n\t\t\t\t(row: NODE): void => {\n\t\t\t\t\trows.add(row);\n\t\t\t\t},\n\t\t\t\tfrom + (includeFrom ? 0 : 1),\n\t\t\t\tto + (includeTo ? 1 : 0)\n\t\t\t);\n\t\t} else {\n\t\t\tparent.each(\n\t\t\t\t(row: NODE): void => {\n\t\t\t\t\trows.add(row);\n\t\t\t\t},\n\t\t\t\tto + (includeTo ? 0 : 1),\n\t\t\t\tfrom + (includeFrom ? 1 : 0)\n\t\t\t);\n\t\t}\n\t\tconst newSize = rows.size;\n\t\tif (oldSize !== newSize) {\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\taddAll(rowIndices: number[]): void {\n\t\tif (0 < rowIndices.length) {\n\t\t\tconst rows = this._rows;\n\t\t\tconst parent = this._parent;\n\t\t\tfor (let i = 0, imax = rowIndices.length; i < imax; ++i) {\n\t\t\t\tconst row = parent.get(rowIndices[i]);\n\t\t\t\tif (row) {\n\t\t\t\t\trows.add(row);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\tcontains(rowIndex: number): boolean {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\treturn this._rows.has(row);\n\t\t}\n\t\treturn false;\n\t}\n\n\tremove(rowIndex: number): void {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\tconst rows = this._rows;\n\t\t\tif (rows.has(row)) {\n\t\t\t\trows.delete(row);\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t}\n\t}\n\n\tclear(): void {\n\t\tconst rows = this._rows;\n\t\tif (0 < rows.size) {\n\t\t\trows.clear();\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\tclearAndAdd(rowIndex: number): void {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\tconst rows = this._rows;\n\t\t\tif (rows.has(row)) {\n\t\t\t\tif (1 < rows.size) {\n\t\t\t\t\trows.clear();\n\t\t\t\t\trows.add(row);\n\t\t\t\t\tthis.onChange();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trows.clear();\n\t\t\t\trows.add(row);\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t}\n\t}\n\n\tclearAndAddAll(rowIndices: number[]): void {\n\t\tconst rows = this._rows;\n\t\tif (0 < rows.size || 0 < rowIndices.length) {\n\t\t\trows.clear();\n\t\t\tconst parent = this._parent;\n\t\t\tfor (let i = 0, imax = rowIndices.length; i < imax; ++i) {\n\t\t\t\tconst row = parent.get(rowIndices[i]);\n\t\t\t\tif (row) {\n\t\t\t\t\trows.add(row);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\tshift(rowIndex: number, amount: number): void {\n\t\t// DO NOTHING\n\t}\n\n\tsize(): number {\n\t\treturn this._rows.size;\n\t}\n\n\tisEmpty(): boolean {\n\t\treturn this._rows.size <= 0;\n\t}\n\n\teach(iteratee: DTableDataSelectionEachIteratee): void {\n\t\tconst rows = this._rows;\n\t\tthis._parent.each((row: NODE, index: number): boolean => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tif (iteratee(index) === false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\t}\n\n\ttoArray(): Array<[number, NODE]> {\n\t\tconst rows = this._rows;\n\t\tconst result: Array<[number, NODE]> = [];\n\t\tthis._parent.each((row: NODE, index: number): void => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tresult.push([index, row]);\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n\n\ttoSortedArray(): Array<[number, NODE]> {\n\t\treturn this.toArray().sort(COMPARATOR);\n\t}\n\n\ttoObject(): Record<number, NODE> {\n\t\tconst rows = this._rows;\n\t\tconst result: Record<number, NODE> = {};\n\t\tthis._parent.each((row: NODE, index: number): void => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tresult[index] = row;\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n\n\ttoMap(): Map<number, NODE> {\n\t\tconst rows = this._rows;\n\t\tconst result = new Map<number, NODE>();\n\t\tthis._parent.each((row: NODE, index: number): void => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tresult.set(index, row);\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"d-table-data-tree-selection-impl.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-table-data-tree-selection-impl.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAGN,uBAAuB,EACvB,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,IAAM,UAAU,GAAG,UAAC,CAAoB,EAAE,CAAoB;IAC7D,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF;IACS,+CAAkB;IAO1B,qCAAY,MAA2C,EAAE,OAAoC;QAA7F,iBAgBC;;gBAfA,iBAAO;QACP,KAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,KAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,uBAAuB,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;QAC5F,KAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAQ,CAAC;QAE7B,SAAS;QACT,IAAM,EAAE,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,EAAE,CAAC;QACvB,IAAI,EAAE,EAAE;YACP,KAAK,IAAM,MAAI,IAAI,EA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C,GAAG,CAAC,EAAE;gBAClB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;aACvB;QACF,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IACf,CAAC;IACF,kCAAC;AAAD,CAAC,AAxVD,CACS,KAAK,CAAC,YAAY,GAuV1B","sourcesContent":["/*\n * Copyright (C) 2021 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DTableData } from \"./d-table-data\";\nimport {\n\tDTableDataSelectionEachIteratee,\n\tDTableDataSelectionOptions,\n\tDTableDataSelectionType\n} from \"./d-table-data-selection\";\nimport {\n\tDTableDataTreeItemAccessorHasChildren,\n\tDTableDataTreeItemAccessorToChildren\n} from \"./d-table-data-tree-item-accessor\";\nimport {\n\tDTableDataTreeSelection,\n\tDTableDataTreeSelectionParent\n} from \"./d-table-data-tree-selection\";\nimport { toEnum } from \"./util/to-enum\";\n\nconst COMPARATOR = (a: [number, unknown], b: [number, unknown]): number => {\n\treturn a[0] - b[0];\n};\n\nexport class DTableDataTreeSelectionImpl<NODE>\n\textends utils.EventEmitter\n\timplements DTableDataTreeSelection<NODE>\n{\n\tprotected _parent: DTableDataTreeSelectionParent<NODE>;\n\tprotected _type: DTableDataSelectionType;\n\tprotected _rows: Set<NODE>;\n\n\tconstructor(parent: DTableDataTreeSelectionParent<NODE>, options?: DTableDataSelectionOptions) {\n\t\tsuper();\n\t\tthis._parent = parent;\n\t\tthis._type = toEnum(options?.type ?? DTableDataSelectionType.NONE, DTableDataSelectionType);\n\t\tthis._rows = new Set<NODE>();\n\n\t\t// Events\n\t\tconst on = options?.on;\n\t\tif (on) {\n\t\t\tfor (const name in on) {\n\t\t\t\tconst handler = on[name];\n\t\t\t\tif (handler) {\n\t\t\t\t\tthis.on(name, handler);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tget parent(): DTableData<NODE> {\n\t\treturn this._parent;\n\t}\n\n\tonNodeChange(nodes?: NODE[]): void {\n\t\tif (nodes != null) {\n\t\t\tconst accessor = this._parent.accessor;\n\t\t\tconst toChildren = accessor.toChildren;\n\t\t\tconst hasChildren = accessor.hasChildren;\n\t\t\tconst oldRows = this._rows;\n\t\t\tconst newRows = this.newRows(nodes, toChildren, hasChildren, oldRows, new Set<NODE>());\n\t\t\tif (oldRows.size !== newRows.size) {\n\t\t\t\tthis._rows = newRows;\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t} else {\n\t\t\tconst rows = this._rows;\n\t\t\tif (0 < rows.size) {\n\t\t\t\trows.clear();\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected newRows(\n\t\tnodes: NODE[],\n\t\ttoChildren: DTableDataTreeItemAccessorToChildren<NODE>,\n\t\thasChildren: DTableDataTreeItemAccessorHasChildren<NODE>,\n\t\trows: Set<NODE>,\n\t\tresult: Set<NODE>\n\t): Set<NODE> {\n\t\tfor (let i = 0, imax = nodes.length; i < imax; ++i) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (rows.has(node)) {\n\t\t\t\tresult.add(node);\n\t\t\t}\n\t\t\tconst children = toChildren(node);\n\t\t\tif (hasChildren(node, children)) {\n\t\t\t\tthis.newRows(children, toChildren, hasChildren, rows, result);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tget indices(): number[] {\n\t\tconst rows = this._rows;\n\t\tconst result: number[] = [];\n\t\tthis._parent.each((row: NODE, index: number): void => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tresult.push(index);\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n\n\tget rows(): NODE[] {\n\t\tconst result: NODE[] = [];\n\t\tthis._rows.forEach((row: NODE): void => {\n\t\t\tresult.push(row);\n\t\t});\n\t\treturn result;\n\t}\n\n\tget type(): DTableDataSelectionType {\n\t\treturn this._type;\n\t}\n\n\tprotected getFirst(): NODE | null {\n\t\tconst rows = this._rows;\n\t\tif (0 < rows.size) {\n\t\t\tlet result: NODE | null = null;\n\t\t\trows.forEach((row: NODE): void => {\n\t\t\t\tif (result == null) {\n\t\t\t\t\tresult = row;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\t\treturn null;\n\t}\n\n\tprotected getLast(): NODE | null {\n\t\tconst rows = this._rows;\n\t\tif (0 < rows.size) {\n\t\t\tlet result: NODE | null = null;\n\t\t\trows.forEach((row: NODE): void => {\n\t\t\t\tresult = row;\n\t\t\t});\n\t\t\treturn result;\n\t\t}\n\t\treturn null;\n\t}\n\n\tprotected toIndex(target: NODE): number | null {\n\t\tlet result: number | null = null;\n\t\tthis._parent.each((row: NODE, index: number): boolean => {\n\t\t\tif (target === row) {\n\t\t\t\tresult = index;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\t\treturn result;\n\t}\n\n\tget first(): number | null {\n\t\tconst row = this.getFirst();\n\t\tif (row) {\n\t\t\treturn this.toIndex(row);\n\t\t}\n\t\treturn null;\n\t}\n\n\tget last(): number | null {\n\t\tconst row = this.getLast();\n\t\tif (row) {\n\t\t\treturn this.toIndex(row);\n\t\t}\n\t\treturn null;\n\t}\n\n\tprotected onChange(): void {\n\t\tthis._parent.update();\n\t\tthis.emit(\"change\", this);\n\t}\n\n\ttoggle(rowIndex: number): void {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\tconst rows = this._rows;\n\t\t\tif (rows.has(row)) {\n\t\t\t\trows.delete(row);\n\t\t\t} else {\n\t\t\t\trows.add(row);\n\t\t\t}\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\tadd(rowIndex: number): void {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\tconst rows = this._rows;\n\t\t\tif (!rows.has(row)) {\n\t\t\t\trows.add(row);\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t}\n\t}\n\n\taddTo(rowIndex: number): void {\n\t\tconst lastRowIndex = this.last;\n\t\tif (lastRowIndex != null) {\n\t\t\tthis.addRange(lastRowIndex, false, rowIndex, true);\n\t\t}\n\t}\n\n\taddRange(from: number, includeFrom: boolean, to: number, includeTo: boolean): void {\n\t\tconst rows = this._rows;\n\t\tconst oldSize = rows.size;\n\t\tconst parent = this._parent;\n\t\tif (from < to) {\n\t\t\tparent.each(\n\t\t\t\t(row: NODE): void => {\n\t\t\t\t\trows.add(row);\n\t\t\t\t},\n\t\t\t\tfrom + (includeFrom ? 0 : 1),\n\t\t\t\tto + (includeTo ? 1 : 0)\n\t\t\t);\n\t\t} else {\n\t\t\tparent.each(\n\t\t\t\t(row: NODE): void => {\n\t\t\t\t\trows.add(row);\n\t\t\t\t},\n\t\t\t\tto + (includeTo ? 0 : 1),\n\t\t\t\tfrom + (includeFrom ? 1 : 0)\n\t\t\t);\n\t\t}\n\t\tconst newSize = rows.size;\n\t\tif (oldSize !== newSize) {\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\taddAll(rowIndices: number[]): void {\n\t\tif (0 < rowIndices.length) {\n\t\t\tconst rows = this._rows;\n\t\t\tconst parent = this._parent;\n\t\t\tfor (let i = 0, imax = rowIndices.length; i < imax; ++i) {\n\t\t\t\tconst row = parent.get(rowIndices[i]);\n\t\t\t\tif (row) {\n\t\t\t\t\trows.add(row);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\tcontains(rowIndex: number): boolean {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\treturn this._rows.has(row);\n\t\t}\n\t\treturn false;\n\t}\n\n\tremove(rowIndex: number): void {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\tconst rows = this._rows;\n\t\t\tif (rows.has(row)) {\n\t\t\t\trows.delete(row);\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t}\n\t}\n\n\tclear(): void {\n\t\tconst rows = this._rows;\n\t\tif (0 < rows.size) {\n\t\t\trows.clear();\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\tclearAndAdd(rowIndex: number): void {\n\t\tconst row = this._parent.get(rowIndex);\n\t\tif (row) {\n\t\t\tconst rows = this._rows;\n\t\t\tif (rows.has(row)) {\n\t\t\t\tif (1 < rows.size) {\n\t\t\t\t\trows.clear();\n\t\t\t\t\trows.add(row);\n\t\t\t\t\tthis.onChange();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trows.clear();\n\t\t\t\trows.add(row);\n\t\t\t\tthis.onChange();\n\t\t\t}\n\t\t}\n\t}\n\n\tclearAndAddAll(rowIndices: number[]): void {\n\t\tconst rows = this._rows;\n\t\tif (0 < rows.size || 0 < rowIndices.length) {\n\t\t\trows.clear();\n\t\t\tconst parent = this._parent;\n\t\t\tfor (let i = 0, imax = rowIndices.length; i < imax; ++i) {\n\t\t\t\tconst row = parent.get(rowIndices[i]);\n\t\t\t\tif (row) {\n\t\t\t\t\trows.add(row);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.onChange();\n\t\t}\n\t}\n\n\tshift(rowIndex: number, amount: number): void {\n\t\t// DO NOTHING\n\t}\n\n\tsize(): number {\n\t\treturn this._rows.size;\n\t}\n\n\tisEmpty(): boolean {\n\t\treturn this._rows.size <= 0;\n\t}\n\n\teach(iteratee: DTableDataSelectionEachIteratee): void {\n\t\tconst rows = this._rows;\n\t\tthis._parent.each((row: NODE, index: number): boolean => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tif (iteratee(index) === false) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\t}\n\n\ttoArray(): Array<[number, NODE]> {\n\t\tconst rows = this._rows;\n\t\tconst result: Array<[number, NODE]> = [];\n\t\tthis._parent.each((row: NODE, index: number): void => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tresult.push([index, row]);\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n\n\ttoSortedArray(): Array<[number, NODE]> {\n\t\treturn this.toArray().sort(COMPARATOR);\n\t}\n\n\ttoObject(): Record<number, NODE> {\n\t\tconst rows = this._rows;\n\t\tconst result: Record<number, NODE> = {};\n\t\tthis._parent.each((row: NODE, index: number): void => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tresult[index] = row;\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n\n\ttoMap(): Map<number, NODE> {\n\t\tconst rows = this._rows;\n\t\tconst result = new Map<number, NODE>();\n\t\tthis._parent.each((row: NODE, index: number): void => {\n\t\t\tif (rows.has(row)) {\n\t\t\t\tresult.set(index, row);\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n}\n"]}
|
|
@@ -111,7 +111,8 @@ var DTableDataTree = /** @class */ (function (_super) {
|
|
|
111
111
|
var supplimentals = this._supplimentals;
|
|
112
112
|
var flags = this._flags;
|
|
113
113
|
if (nodes != null) {
|
|
114
|
-
var
|
|
114
|
+
var accessor = this._accessor;
|
|
115
|
+
var irows = this.newRows(nodes, 0, 0, rows, supplimentals, flags, this._reverse, accessor.toChildren, accessor.hasChildren);
|
|
115
116
|
if (irows !== rows.length) {
|
|
116
117
|
rows.length = irows;
|
|
117
118
|
supplimentals.length = irows;
|
|
@@ -125,7 +126,7 @@ var DTableDataTree = /** @class */ (function (_super) {
|
|
|
125
126
|
DTableDataTree.prototype.toSupplimental = function (ilevel, hasChildren, isOpened) {
|
|
126
127
|
return (ilevel << 2) | (hasChildren ? 2 : 0) | (isOpened ? 1 : 0);
|
|
127
128
|
};
|
|
128
|
-
DTableDataTree.prototype.newRows = function (nodes, irows, ilevel, rows, supplimentals, flags, reverse, toChildren) {
|
|
129
|
+
DTableDataTree.prototype.newRows = function (nodes, irows, ilevel, rows, supplimentals, flags, reverse, toChildren, hasChildren) {
|
|
129
130
|
var nodesLength = nodes.length;
|
|
130
131
|
var istart = reverse ? nodesLength - 1 : 0;
|
|
131
132
|
var idelta = reverse ? -1 : +1;
|
|
@@ -133,7 +134,7 @@ var DTableDataTree = /** @class */ (function (_super) {
|
|
|
133
134
|
var node = nodes[i];
|
|
134
135
|
var children = toChildren(node);
|
|
135
136
|
var isOpened = flags.has(node);
|
|
136
|
-
var supplimental = this.toSupplimental(ilevel,
|
|
137
|
+
var supplimental = this.toSupplimental(ilevel, hasChildren(node, children), isOpened);
|
|
137
138
|
if (irows < rows.length) {
|
|
138
139
|
rows[irows] = node;
|
|
139
140
|
supplimentals[irows] = supplimental;
|
|
@@ -144,7 +145,7 @@ var DTableDataTree = /** @class */ (function (_super) {
|
|
|
144
145
|
}
|
|
145
146
|
irows += 1;
|
|
146
147
|
if (isOpened && children) {
|
|
147
|
-
irows = this.newRows(children, irows, ilevel + 1, rows, supplimentals, flags, reverse, toChildren);
|
|
148
|
+
irows = this.newRows(children, irows, ilevel + 1, rows, supplimentals, flags, reverse, toChildren, hasChildren);
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
return irows;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-table-data-tree.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-table-data-tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EACN,0BAA0B,EAE1B,MAAM,mCAAmC,CAAC;AAM3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAoEhD;;GAEG;AACH;IACS,kCAAkB;IAgB1B,wBAAY,OAAqC;QAAjD,YACC,iBAAO,SAmCP;QAjCA,KAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,KAAI,CAAC,SAAS,GAAG,KA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EAAE;gBAC/B,MAAM;aACN;SACD;IACF,CAAC;IAED,sBAAI,qCAAS;aAAb;YACC,OAAO,IAAI,CAAC,UAAU,CAAC;QACxB,CAAC;;;OAAA;IAED,sBAAI,kCAAM;aAAV;YACC,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;;;OAAA;IAED,sBAAI,kCAAM;aAAV;YACC,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;;;OAAA;IAED,sBAAI,kCAAM;aAAV;YACC,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;;;OAAA;IACF,qBAAC;AAAD,CAAC,AApSD,CACS,KAAK,CAAC,YAAY,GAmS1B","sourcesContent":["/*\n * Copyright (C) 2021 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DTableData, DTableDataMapped, DTableDataParent } from \"./d-table-data\";\nimport { DTableDataFilter, DTableDataFilterer } from \"./d-table-data-filter\";\nimport { DTableDataTreeFilter } from \"./d-table-data-tree-filter\";\nimport { DTableDataListMapped } from \"./d-table-data-list-mapped\";\nimport { DTableDataSelection } from \"./d-table-data-selection\";\nimport { DTableDataComparator, DTableDataSorter } from \"./d-table-data-sorter\";\nimport { DTableDataTreeSorter } from \"./d-table-data-tree-sorter\";\nimport { DTableDataTreeNode } from \"./d-table-data-tree-item\";\nimport {\n\tDTableDataTreeItemAccessor,\n\tDTableDataTreeItemAccessorOptions\n} from \"./d-table-data-tree-item-accessor\";\nimport {\n\tDTableDataTreeSelection,\n\tDTableDataTreeSelectionCreator,\n\tDTableDataTreeSelectionOptions\n} from \"./d-table-data-tree-selection\";\nimport { DTableDataTreeSelectionImpl } from \"./d-table-data-tree-selection-impl\";\nimport { isFunction } from \"./util/is-function\";\nimport { DBaseEvents } from \"./d-base\";\nimport { DOnOptions } from \"./d-on-options\";\n\n/**\n * {@link DTableDataTree} events.\n */\nexport interface DTableDataTreeEvents<NODE, EMITTER> extends DBaseEvents<EMITTER> {\n\t/**\n\t * Triggered when a node is expanded.\n\t *\n\t * @param node a node\n\t * @param emitter an emitter\n\t */\n\texpand(node: NODE, emitter: EMITTER): void;\n\n\t/**\n\t * Triggered when a node is collapsed.\n\t *\n\t * @param node a node\n\t * @param emitter an emitter\n\t */\n\tcollapse(node: NODE, emitter: EMITTER): void;\n}\n\n/**\n * {@link DTableDataTree} \"on\" options.\n */\nexport interface DTableDataTreeOnOptions<NODE, EMITTER>\n\textends Partial<DTableDataTreeEvents<NODE, EMITTER>>,\n\t\tDOnOptions {}\n\n/**\n * {@link DTableDataTree} options.\n */\nexport interface DTableDataTreeOptions<NODE, EMITTER = any>\n\textends DTableDataTreeItemAccessorOptions<NODE> {\n\tnodes?: NODE[];\n\n\t/**\n\t * Selection options.\n\t */\n\tselection?:\n\t\t| DTableDataTreeSelection<NODE>\n\t\t| DTableDataTreeSelectionCreator<NODE>\n\t\t| DTableDataTreeSelectionOptions;\n\n\t/**\n\t * A filter.\n\t */\n\tfilter?: DTableDataFilterer<NODE>;\n\n\t/**\n\t * A comparator.\n\t */\n\tcomparator?: DTableDataComparator<NODE>;\n\n\t/**\n\t * True to list up nodes in the given node array in the reverse order.\n\t */\n\treverse?: boolean;\n\n\t/**\n\t * Mappings of event names and event handlers.\n\t */\n\ton?: DTableDataTreeOnOptions<NODE, EMITTER>;\n}\n\n/**\n * Please note that this data class does not support the sorter.\n */\nexport class DTableDataTree<NODE extends DTableDataTreeNode<NODE, NODE>>\n\textends utils.EventEmitter\n\timplements DTableData<NODE>\n{\n\tprotected _parent: DTableDataParent | null;\n\tprotected _nodes?: NODE[];\n\tprotected _rows: NODE[];\n\tprotected _isRowsDirty: boolean;\n\tprotected _supplimentals: number[];\n\tprotected _flags: WeakMap<NODE, number>;\n\tprotected _filter: DTableDataTreeFilter<NODE>;\n\tprotected _sorter: DTableDataTreeSorter<NODE>;\n\tprotected _selection: DTableDataTreeSelection<NODE>;\n\tprotected _mapped: DTableDataMapped<NODE>;\n\tprotected _accessor: DTableDataTreeItemAccessor<NODE>;\n\tprotected _reverse: boolean;\n\n\tconstructor(options?: DTableDataTreeOptions<NODE>) {\n\t\tsuper();\n\n\t\tthis._parent = null;\n\t\tthis._accessor = this.toAccessor(options);\n\t\tthis._mapped = new DTableDataListMapped<NODE>(this);\n\t\tthis._rows = [];\n\t\tthis._isRowsDirty = false;\n\t\tthis._supplimentals = [];\n\t\tthis._flags = new WeakMap<NODE, number>();\n\t\tthis._reverse = !!options?.reverse;\n\t\tthis._selection = this.toSelection(options?.selection);\n\t\tthis._filter = new DTableDataTreeFilter<NODE>(this);\n\t\tthis._sorter = new DTableDataTreeSorter<NODE>();\n\n\t\tif (options) {\n\t\t\t// Filter\n\t\t\tconst filter = options.filter;\n\t\t\tif (filter) {\n\t\t\t\tthis._filter.set(filter);\n\t\t\t}\n\n\t\t\t// Events\n\t\t\tconst on = options.on;\n\t\t\tif (on) {\n\t\t\t\tfor (const name in on) {\n\t\t\t\t\tconst handler = on[name];\n\t\t\t\t\tif (handler) {\n\t\t\t\t\t\tthis.on(name, handler);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update rows\n\t\tthis.nodes = options?.nodes;\n\t}\n\n\tprotected toSelection(\n\t\toptions?:\n\t\t\t| DTableDataTreeSelection<NODE>\n\t\t\t| DTableDataTreeSelectionCreator<NODE>\n\t\t\t| DTableDataTreeSelectionOptions\n\t): DTableDataTreeSelection<NODE> {\n\t\tif (options instanceof utils.EventEmitter) {\n\t\t\treturn options;\n\t\t} else if (isFunction(options)) {\n\t\t\treturn options(this);\n\t\t}\n\t\treturn this.newSelection(options);\n\t}\n\n\tprotected newSelection(\n\t\toptions?: DTableDataTreeSelectionOptions\n\t): DTableDataTreeSelection<NODE> {\n\t\treturn new DTableDataTreeSelectionImpl(this, options);\n\t}\n\n\tprotected toAccessor(options?: DTableDataTreeOptions<NODE>): DTableDataTreeItemAccessor<NODE> {\n\t\treturn new DTableDataTreeItemAccessor(options);\n\t}\n\n\tbind(parent: DTableDataParent): void {\n\t\tthis._parent = parent;\n\t}\n\n\tget nodes(): NODE[] | undefined {\n\t\treturn this._nodes;\n\t}\n\n\tset nodes(nodes: NODE[] | undefined) {\n\t\tthis._nodes = nodes;\n\t\tthis._isRowsDirty = true;\n\t\tthis._selection.onNodeChange(nodes);\n\t\tthis._filter.toDirty();\n\t\tthis.update(true);\n\t}\n\n\tget rows(): NODE[] {\n\t\tif (this._isRowsDirty) {\n\t\t\tthis._isRowsDirty = false;\n\t\t\tthis.updateRows(this._nodes);\n\t\t}\n\t\treturn this._rows;\n\t}\n\n\tget supplimentals(): number[] {\n\t\treturn this._supplimentals;\n\t}\n\n\tget accessor(): DTableDataTreeItemAccessor<NODE> {\n\t\treturn this._accessor;\n\t}\n\n\tprotected updateRows(nodes: NODE[] | undefined): void {\n\t\tconst rows = this._rows;\n\t\tconst supplimentals = this._supplimentals;\n\t\tconst flags = this._flags;\n\t\tif (nodes != null) {\n\t\t\tconst irows = this.newRows(\n\t\t\t\tnodes,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\trows,\n\t\t\t\tsupplimentals,\n\t\t\t\tflags,\n\t\t\t\tthis._reverse,\n\t\t\t\tthis._accessor.toChildren\n\t\t\t);\n\t\t\tif (irows !== rows.length) {\n\t\t\t\trows.length = irows;\n\t\t\t\tsupplimentals.length = irows;\n\t\t\t}\n\t\t} else {\n\t\t\trows.length = 0;\n\t\t\tsupplimentals.length = 0;\n\t\t}\n\t}\n\n\tprotected toSupplimental(ilevel: number, hasChildren: boolean, isOpened: boolean): number {\n\t\treturn (ilevel << 2) | (hasChildren ? 2 : 0) | (isOpened ? 1 : 0);\n\t}\n\n\tprotected newRows(\n\t\tnodes: NODE[],\n\t\tirows: number,\n\t\tilevel: number,\n\t\trows: NODE[],\n\t\tsupplimentals: number[],\n\t\tflags: WeakMap<NODE, number>,\n\t\treverse: boolean,\n\t\ttoChildren: (node: NODE) => NODE[] | null | undefined\n\t): number {\n\t\tconst nodesLength = nodes.length;\n\t\tconst istart = reverse ? nodesLength - 1 : 0;\n\t\tconst idelta = reverse ? -1 : +1;\n\t\tfor (let i = istart; 0 <= i && i < nodesLength; i += idelta) {\n\t\t\tconst node = nodes[i];\n\t\t\tconst children = toChildren(node);\n\t\t\tconst isOpened = flags.has(node);\n\t\t\tconst supplimental = this.toSupplimental(\n\t\t\t\tilevel,\n\t\t\t\t!!(children && 0 < children.length),\n\t\t\t\tisOpened\n\t\t\t);\n\t\t\tif (irows < rows.length) {\n\t\t\t\trows[irows] = node;\n\t\t\t\tsupplimentals[irows] = supplimental;\n\t\t\t} else {\n\t\t\t\trows.push(node);\n\t\t\t\tsupplimentals.push(supplimental);\n\t\t\t}\n\t\t\tirows += 1;\n\n\t\t\tif (isOpened && children) {\n\t\t\t\tirows = this.newRows(\n\t\t\t\t\tchildren,\n\t\t\t\t\tirows,\n\t\t\t\t\tilevel + 1,\n\t\t\t\t\trows,\n\t\t\t\t\tsupplimentals,\n\t\t\t\t\tflags,\n\t\t\t\t\treverse,\n\t\t\t\t\ttoChildren\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn irows;\n\t}\n\n\tupdate(forcibly?: boolean): void {\n\t\tconst parent = this._parent;\n\t\tif (parent) {\n\t\t\tparent.update(forcibly);\n\t\t}\n\t}\n\n\tsize(): number {\n\t\treturn this.rows.length;\n\t}\n\n\tget(index: number): NODE | null {\n\t\tconst rows = this.rows;\n\t\tif (0 <= index && index < rows.length) {\n\t\t\treturn rows[index];\n\t\t}\n\t\treturn null;\n\t}\n\n\texpand(node: NODE): boolean {\n\t\tconst flags = this._flags;\n\t\tif (!flags.has(node)) {\n\t\t\tflags.set(node, 1);\n\t\t\tthis._isRowsDirty = true;\n\t\t\tthis._filter.toDirty();\n\t\t\tthis.update(true);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tcollapse(node: NODE): boolean {\n\t\tconst flags = this._flags;\n\t\tif (flags.has(node)) {\n\t\t\tflags.delete(node);\n\t\t\tthis._isRowsDirty = true;\n\t\t\tthis._filter.toDirty();\n\t\t\tthis.update(true);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tisCollapsed(node: NODE): boolean {\n\t\treturn !this._flags.has(node);\n\t}\n\n\tisExpanded(node: NODE): boolean {\n\t\treturn this._flags.has(node);\n\t}\n\n\ttoggle(node: NODE): boolean {\n\t\tif (this.isExpanded(node)) {\n\t\t\treturn this.collapse(node);\n\t\t} else {\n\t\t\treturn this.expand(node);\n\t\t}\n\t}\n\n\t/** @deprecated in favor of {@link expand}. */\n\topen(node: NODE): boolean {\n\t\treturn this.expand(node);\n\t}\n\n\t/** @deprecated in favor of {@link collapse}. */\n\tclose(node: NODE): boolean {\n\t\treturn this.collapse(node);\n\t}\n\n\t/** @deprecated in favor of {@link isExpanded}. */\n\tisOpened(node: NODE): boolean {\n\t\treturn this.isExpanded(node);\n\t}\n\n\teach(\n\t\titeratee: (node: NODE, index: number) => boolean | void,\n\t\tifrom?: number,\n\t\tito?: number\n\t): void {\n\t\tconst rows = this.rows;\n\t\tifrom = ifrom != null ? Math.max(0, ifrom) : 0;\n\t\tito = ito != null ? Math.min(rows.length, ito) : rows.length;\n\t\tfor (let i = ifrom; i < ito; ++i) {\n\t\t\tconst row = rows[i];\n\t\t\tif (iteratee(row, i) === false) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tget selection(): DTableDataSelection<NODE> {\n\t\treturn this._selection;\n\t}\n\n\tget filter(): DTableDataFilter<NODE> {\n\t\treturn this._filter;\n\t}\n\n\tget sorter(): DTableDataSorter<NODE> {\n\t\treturn this._sorter;\n\t}\n\n\tget mapped(): DTableDataMapped<NODE> {\n\t\treturn this._mapped;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"d-table-data-tree.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-table-data-tree.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AA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,GAAJ,UACC,QAAuD,EACvD,KAAc,EACd,GAAY;QAEZ,IAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,KAAK,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAC7D,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE;YACjC,IAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;gBAC/B,MAAM;aACN;SACD;IACF,CAAC;IAED,sBAAI,qCAAS;aAAb;YACC,OAAO,IAAI,CAAC,UAAU,CAAC;QACxB,CAAC;;;OAAA;IAED,sBAAI,kCAAM;aAAV;YACC,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;;;OAAA;IAED,sBAAI,kCAAM;aAAV;YACC,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;;;OAAA;IAED,sBAAI,kCAAM;aAAV;YACC,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;;;OAAA;IACF,qBAAC;AAAD,CAAC,AApSD,CACS,KAAK,CAAC,YAAY,GAmS1B","sourcesContent":["/*\n * Copyright (C) 2021 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DTableData, DTableDataMapped, DTableDataParent } from \"./d-table-data\";\nimport { DTableDataFilter, DTableDataFilterer } from \"./d-table-data-filter\";\nimport { DTableDataTreeFilter } from \"./d-table-data-tree-filter\";\nimport { DTableDataListMapped } from \"./d-table-data-list-mapped\";\nimport { DTableDataSelection } from \"./d-table-data-selection\";\nimport { DTableDataComparator, DTableDataSorter } from \"./d-table-data-sorter\";\nimport { DTableDataTreeSorter } from \"./d-table-data-tree-sorter\";\nimport { DTableDataTreeNode } from \"./d-table-data-tree-item\";\nimport {\n\tDTableDataTreeItemAccessor,\n\tDTableDataTreeItemAccessorHasChildren,\n\tDTableDataTreeItemAccessorOptions,\n\tDTableDataTreeItemAccessorToChildren\n} from \"./d-table-data-tree-item-accessor\";\nimport {\n\tDTableDataTreeSelection,\n\tDTableDataTreeSelectionCreator,\n\tDTableDataTreeSelectionOptions\n} from \"./d-table-data-tree-selection\";\nimport { DTableDataTreeSelectionImpl } from \"./d-table-data-tree-selection-impl\";\nimport { isFunction } from \"./util/is-function\";\nimport { DBaseEvents } from \"./d-base\";\nimport { DOnOptions } from \"./d-on-options\";\n\n/**\n * {@link DTableDataTree} events.\n */\nexport interface DTableDataTreeEvents<NODE, EMITTER> extends DBaseEvents<EMITTER> {\n\t/**\n\t * Triggered when a node is expanded.\n\t *\n\t * @param node a node\n\t * @param emitter an emitter\n\t */\n\texpand(node: NODE, emitter: EMITTER): void;\n\n\t/**\n\t * Triggered when a node is collapsed.\n\t *\n\t * @param node a node\n\t * @param emitter an emitter\n\t */\n\tcollapse(node: NODE, emitter: EMITTER): void;\n}\n\n/**\n * {@link DTableDataTree} \"on\" options.\n */\nexport interface DTableDataTreeOnOptions<NODE, EMITTER>\n\textends Partial<DTableDataTreeEvents<NODE, EMITTER>>,\n\t\tDOnOptions {}\n\n/**\n * {@link DTableDataTree} options.\n */\nexport interface DTableDataTreeOptions<NODE, EMITTER = any>\n\textends DTableDataTreeItemAccessorOptions<NODE> {\n\tnodes?: NODE[];\n\n\t/**\n\t * Selection options.\n\t */\n\tselection?:\n\t\t| DTableDataTreeSelection<NODE>\n\t\t| DTableDataTreeSelectionCreator<NODE>\n\t\t| DTableDataTreeSelectionOptions;\n\n\t/**\n\t * A filter.\n\t */\n\tfilter?: DTableDataFilterer<NODE>;\n\n\t/**\n\t * A comparator.\n\t */\n\tcomparator?: DTableDataComparator<NODE>;\n\n\t/**\n\t * True to list up nodes in the given node array in the reverse order.\n\t */\n\treverse?: boolean;\n\n\t/**\n\t * Mappings of event names and event handlers.\n\t */\n\ton?: DTableDataTreeOnOptions<NODE, EMITTER>;\n}\n\n/**\n * Please note that this data class does not support the sorter.\n */\nexport class DTableDataTree<NODE extends DTableDataTreeNode<NODE, NODE>>\n\textends utils.EventEmitter\n\timplements DTableData<NODE>\n{\n\tprotected _parent: DTableDataParent | null;\n\tprotected _nodes?: NODE[];\n\tprotected _rows: NODE[];\n\tprotected _isRowsDirty: boolean;\n\tprotected _supplimentals: number[];\n\tprotected _flags: WeakMap<NODE, number>;\n\tprotected _filter: DTableDataTreeFilter<NODE>;\n\tprotected _sorter: DTableDataTreeSorter<NODE>;\n\tprotected _selection: DTableDataTreeSelection<NODE>;\n\tprotected _mapped: DTableDataMapped<NODE>;\n\tprotected _accessor: DTableDataTreeItemAccessor<NODE>;\n\tprotected _reverse: boolean;\n\n\tconstructor(options?: DTableDataTreeOptions<NODE>) {\n\t\tsuper();\n\n\t\tthis._parent = null;\n\t\tthis._accessor = this.toAccessor(options);\n\t\tthis._mapped = new DTableDataListMapped<NODE>(this);\n\t\tthis._rows = [];\n\t\tthis._isRowsDirty = false;\n\t\tthis._supplimentals = [];\n\t\tthis._flags = new WeakMap<NODE, number>();\n\t\tthis._reverse = !!options?.reverse;\n\t\tthis._selection = this.toSelection(options?.selection);\n\t\tthis._filter = new DTableDataTreeFilter<NODE>(this);\n\t\tthis._sorter = new DTableDataTreeSorter<NODE>();\n\n\t\tif (options) {\n\t\t\t// Filter\n\t\t\tconst filter = options.filter;\n\t\t\tif (filter) {\n\t\t\t\tthis._filter.set(filter);\n\t\t\t}\n\n\t\t\t// Events\n\t\t\tconst on = options.on;\n\t\t\tif (on) {\n\t\t\t\tfor (const name in on) {\n\t\t\t\t\tconst handler = on[name];\n\t\t\t\t\tif (handler) {\n\t\t\t\t\t\tthis.on(name, handler);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update rows\n\t\tthis.nodes = options?.nodes;\n\t}\n\n\tprotected toSelection(\n\t\toptions?:\n\t\t\t| DTableDataTreeSelection<NODE>\n\t\t\t| DTableDataTreeSelectionCreator<NODE>\n\t\t\t| DTableDataTreeSelectionOptions\n\t): DTableDataTreeSelection<NODE> {\n\t\tif (options instanceof utils.EventEmitter) {\n\t\t\treturn options;\n\t\t} else if (isFunction(options)) {\n\t\t\treturn options(this);\n\t\t}\n\t\treturn this.newSelection(options);\n\t}\n\n\tprotected newSelection(\n\t\toptions?: DTableDataTreeSelectionOptions\n\t): DTableDataTreeSelection<NODE> {\n\t\treturn new DTableDataTreeSelectionImpl(this, options);\n\t}\n\n\tprotected toAccessor(options?: DTableDataTreeOptions<NODE>): DTableDataTreeItemAccessor<NODE> {\n\t\treturn new DTableDataTreeItemAccessor(options);\n\t}\n\n\tbind(parent: DTableDataParent): void {\n\t\tthis._parent = parent;\n\t}\n\n\tget nodes(): NODE[] | undefined {\n\t\treturn this._nodes;\n\t}\n\n\tset nodes(nodes: NODE[] | undefined) {\n\t\tthis._nodes = nodes;\n\t\tthis._isRowsDirty = true;\n\t\tthis._selection.onNodeChange(nodes);\n\t\tthis._filter.toDirty();\n\t\tthis.update(true);\n\t}\n\n\tget rows(): NODE[] {\n\t\tif (this._isRowsDirty) {\n\t\t\tthis._isRowsDirty = false;\n\t\t\tthis.updateRows(this._nodes);\n\t\t}\n\t\treturn this._rows;\n\t}\n\n\tget supplimentals(): number[] {\n\t\treturn this._supplimentals;\n\t}\n\n\tget accessor(): DTableDataTreeItemAccessor<NODE> {\n\t\treturn this._accessor;\n\t}\n\n\tprotected updateRows(nodes: NODE[] | undefined): void {\n\t\tconst rows = this._rows;\n\t\tconst supplimentals = this._supplimentals;\n\t\tconst flags = this._flags;\n\t\tif (nodes != null) {\n\t\t\tconst accessor = this._accessor;\n\t\t\tconst irows = this.newRows(\n\t\t\t\tnodes,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\trows,\n\t\t\t\tsupplimentals,\n\t\t\t\tflags,\n\t\t\t\tthis._reverse,\n\t\t\t\taccessor.toChildren,\n\t\t\t\taccessor.hasChildren\n\t\t\t);\n\t\t\tif (irows !== rows.length) {\n\t\t\t\trows.length = irows;\n\t\t\t\tsupplimentals.length = irows;\n\t\t\t}\n\t\t} else {\n\t\t\trows.length = 0;\n\t\t\tsupplimentals.length = 0;\n\t\t}\n\t}\n\n\tprotected toSupplimental(ilevel: number, hasChildren: boolean, isOpened: boolean): number {\n\t\treturn (ilevel << 2) | (hasChildren ? 2 : 0) | (isOpened ? 1 : 0);\n\t}\n\n\tprotected newRows(\n\t\tnodes: NODE[],\n\t\tirows: number,\n\t\tilevel: number,\n\t\trows: NODE[],\n\t\tsupplimentals: number[],\n\t\tflags: WeakMap<NODE, number>,\n\t\treverse: boolean,\n\t\ttoChildren: DTableDataTreeItemAccessorToChildren<NODE>,\n\t\thasChildren: DTableDataTreeItemAccessorHasChildren<NODE>\n\t): number {\n\t\tconst nodesLength = nodes.length;\n\t\tconst istart = reverse ? nodesLength - 1 : 0;\n\t\tconst idelta = reverse ? -1 : +1;\n\t\tfor (let i = istart; 0 <= i && i < nodesLength; i += idelta) {\n\t\t\tconst node = nodes[i];\n\t\t\tconst children = toChildren(node);\n\t\t\tconst isOpened = flags.has(node);\n\t\t\tconst supplimental = this.toSupplimental(ilevel, hasChildren(node, children), isOpened);\n\t\t\tif (irows < rows.length) {\n\t\t\t\trows[irows] = node;\n\t\t\t\tsupplimentals[irows] = supplimental;\n\t\t\t} else {\n\t\t\t\trows.push(node);\n\t\t\t\tsupplimentals.push(supplimental);\n\t\t\t}\n\t\t\tirows += 1;\n\n\t\t\tif (isOpened && children) {\n\t\t\t\tirows = this.newRows(\n\t\t\t\t\tchildren,\n\t\t\t\t\tirows,\n\t\t\t\t\tilevel + 1,\n\t\t\t\t\trows,\n\t\t\t\t\tsupplimentals,\n\t\t\t\t\tflags,\n\t\t\t\t\treverse,\n\t\t\t\t\ttoChildren,\n\t\t\t\t\thasChildren\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn irows;\n\t}\n\n\tupdate(forcibly?: boolean): void {\n\t\tconst parent = this._parent;\n\t\tif (parent) {\n\t\t\tparent.update(forcibly);\n\t\t}\n\t}\n\n\tsize(): number {\n\t\treturn this.rows.length;\n\t}\n\n\tget(index: number): NODE | null {\n\t\tconst rows = this.rows;\n\t\tif (0 <= index && index < rows.length) {\n\t\t\treturn rows[index];\n\t\t}\n\t\treturn null;\n\t}\n\n\texpand(node: NODE): boolean {\n\t\tconst flags = this._flags;\n\t\tif (!flags.has(node)) {\n\t\t\tflags.set(node, 1);\n\t\t\tthis._isRowsDirty = true;\n\t\t\tthis._filter.toDirty();\n\t\t\tthis.update(true);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tcollapse(node: NODE): boolean {\n\t\tconst flags = this._flags;\n\t\tif (flags.has(node)) {\n\t\t\tflags.delete(node);\n\t\t\tthis._isRowsDirty = true;\n\t\t\tthis._filter.toDirty();\n\t\t\tthis.update(true);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tisCollapsed(node: NODE): boolean {\n\t\treturn !this._flags.has(node);\n\t}\n\n\tisExpanded(node: NODE): boolean {\n\t\treturn this._flags.has(node);\n\t}\n\n\ttoggle(node: NODE): boolean {\n\t\tif (this.isExpanded(node)) {\n\t\t\treturn this.collapse(node);\n\t\t} else {\n\t\t\treturn this.expand(node);\n\t\t}\n\t}\n\n\t/** @deprecated in favor of {@link expand}. */\n\topen(node: NODE): boolean {\n\t\treturn this.expand(node);\n\t}\n\n\t/** @deprecated in favor of {@link collapse}. */\n\tclose(node: NODE): boolean {\n\t\treturn this.collapse(node);\n\t}\n\n\t/** @deprecated in favor of {@link isExpanded}. */\n\tisOpened(node: NODE): boolean {\n\t\treturn this.isExpanded(node);\n\t}\n\n\teach(\n\t\titeratee: (node: NODE, index: number) => boolean | void,\n\t\tifrom?: number,\n\t\tito?: number\n\t): void {\n\t\tconst rows = this.rows;\n\t\tifrom = ifrom != null ? Math.max(0, ifrom) : 0;\n\t\tito = ito != null ? Math.min(rows.length, ito) : rows.length;\n\t\tfor (let i = ifrom; i < ito; ++i) {\n\t\t\tconst row = rows[i];\n\t\t\tif (iteratee(row, i) === false) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tget selection(): DTableDataSelection<NODE> {\n\t\treturn this._selection;\n\t}\n\n\tget filter(): DTableDataFilter<NODE> {\n\t\treturn this._filter;\n\t}\n\n\tget sorter(): DTableDataSorter<NODE> {\n\t\treturn this._sorter;\n\t}\n\n\tget mapped(): DTableDataMapped<NODE> {\n\t\treturn this._mapped;\n\t}\n}\n"]}
|