aio-class 2.1.2 → 2.1.4
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/index.d.ts +14 -12
- package/index.js +5 -5
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -176,15 +176,13 @@ type I_sort<T> = {
|
|
|
176
176
|
getValue: (row: T, dir: 'inc' | 'dec') => any;
|
|
177
177
|
};
|
|
178
178
|
type I_id = string | number;
|
|
179
|
-
type
|
|
179
|
+
export type I_EntityMap<T> = {
|
|
180
180
|
getChilds: (row: T) => T[] | undefined;
|
|
181
181
|
setChilds: (row: T, childs: T[] | undefined) => T;
|
|
182
182
|
getId: (row: T) => I_id;
|
|
183
183
|
setId: (row: T) => T;
|
|
184
|
-
getData?: () => T[];
|
|
185
|
-
setData?: (v: T[]) => void;
|
|
186
184
|
};
|
|
187
|
-
type
|
|
185
|
+
type I_EntityRowDetail<T> = {
|
|
188
186
|
row: T;
|
|
189
187
|
parentRows: T[];
|
|
190
188
|
parentRow: T | false;
|
|
@@ -200,10 +198,14 @@ type I_rowResult<T> = {
|
|
|
200
198
|
isLastChild: boolean;
|
|
201
199
|
};
|
|
202
200
|
export declare class EntityClass<T> {
|
|
203
|
-
|
|
201
|
+
map: I_EntityMap<T>;
|
|
204
202
|
getData: () => T[];
|
|
205
203
|
setData: (v: T[]) => void;
|
|
206
|
-
constructor(p:
|
|
204
|
+
constructor(p: {
|
|
205
|
+
map: I_EntityMap<T>;
|
|
206
|
+
getData?: () => T[];
|
|
207
|
+
setData?: (v: T[]) => void;
|
|
208
|
+
});
|
|
207
209
|
private getId;
|
|
208
210
|
private setId;
|
|
209
211
|
private getChilds;
|
|
@@ -230,8 +232,8 @@ export declare class EntityClass<T> {
|
|
|
230
232
|
setId: (row: T) => T;
|
|
231
233
|
getChilds: (row: T) => T[];
|
|
232
234
|
setChilds: (row: T, childs: T[] | undefined) => T;
|
|
233
|
-
getRowDetailById: (data: T[], rowId: I_id) => false |
|
|
234
|
-
getFilteredTree: (data: T[], filter: (row: T, detail:
|
|
235
|
+
getRowDetailById: (data: T[], rowId: I_id) => false | I_EntityRowDetail<T>;
|
|
236
|
+
getFilteredTree: (data: T[], filter: (row: T, detail: I_EntityRowDetail<T>) => boolean | undefined) => T[];
|
|
235
237
|
getSortedTree: (rows: T[], sorts: I_sort<T>[]) => T[];
|
|
236
238
|
addRow: (data: T[], row: T, p: {
|
|
237
239
|
parentId?: I_id;
|
|
@@ -248,10 +250,10 @@ export declare class EntityClass<T> {
|
|
|
248
250
|
reOrderByDir: (data: T[], rowId: I_id, dir: 1 | -1) => T[];
|
|
249
251
|
moveTo: (data: T[], fromIds: I_id[], toId: I_id) => T[];
|
|
250
252
|
editByTraverse: (rows: T[], callback: (row: T) => T | false) => T[];
|
|
251
|
-
traverse: (rows: T[], callback: (row: T, detail:
|
|
253
|
+
traverse: (rows: T[], callback: (row: T, detail: I_EntityRowDetail<T>) => false | undefined) => void;
|
|
252
254
|
};
|
|
253
255
|
dataActions: {
|
|
254
|
-
getRowDetailById: (rowId: any) => false |
|
|
256
|
+
getRowDetailById: (rowId: any) => false | I_EntityRowDetail<T>;
|
|
255
257
|
addRow: (row: T, p: {
|
|
256
258
|
parentId?: I_id;
|
|
257
259
|
index?: number;
|
|
@@ -268,8 +270,8 @@ export declare class EntityClass<T> {
|
|
|
268
270
|
moveTo: (fromIds: I_id[], toId: I_id) => T[];
|
|
269
271
|
editByTraverse: (callback: (row: T) => T | false) => T[];
|
|
270
272
|
getSortedTree: (sorts: I_sort<T>[]) => T[];
|
|
271
|
-
getFilteredTree: (filter: (row: T, detail:
|
|
272
|
-
traverse: (callback: (row: T, detail:
|
|
273
|
+
getFilteredTree: (filter: (row: T, detail: I_EntityRowDetail<T>) => boolean | undefined) => T[];
|
|
274
|
+
traverse: (callback: (row: T, detail: I_EntityRowDetail<T>) => false | undefined) => void;
|
|
273
275
|
};
|
|
274
276
|
}
|
|
275
277
|
type I_color = any;
|
package/index.js
CHANGED
|
@@ -1501,10 +1501,10 @@ export class EntityClass {
|
|
|
1501
1501
|
constructor(p) {
|
|
1502
1502
|
this.getData = () => [];
|
|
1503
1503
|
this.setData = () => { };
|
|
1504
|
-
this.getId = (row) => this.
|
|
1505
|
-
this.setId = (row) => this.
|
|
1506
|
-
this.getChilds = (row) => this.
|
|
1507
|
-
this.setChilds = (row, childs) => this.
|
|
1504
|
+
this.getId = (row) => this.map.getId(row);
|
|
1505
|
+
this.setId = (row) => this.map.setId(row);
|
|
1506
|
+
this.getChilds = (row) => this.map.getChilds(row);
|
|
1507
|
+
this.setChilds = (row, childs) => this.map.setChilds(row, childs);
|
|
1508
1508
|
this.getRowDetailsByIds = (data, rowIds) => {
|
|
1509
1509
|
const fn = (data, parents, temp) => {
|
|
1510
1510
|
const isFoundAll = () => Object.keys(temp).filter((rowId) => temp[rowId] === false).length === 0;
|
|
@@ -1922,7 +1922,7 @@ export class EntityClass {
|
|
|
1922
1922
|
this.traverse(data, callback);
|
|
1923
1923
|
}
|
|
1924
1924
|
};
|
|
1925
|
-
this.
|
|
1925
|
+
this.map = p.map;
|
|
1926
1926
|
if (p.getData) {
|
|
1927
1927
|
this.getData = p.getData;
|
|
1928
1928
|
}
|