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.
Files changed (3) hide show
  1. package/index.d.ts +14 -12
  2. package/index.js +5 -5
  3. 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 I_EntityClass<T> = {
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 I_rowResult<T> = {
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
- params: I_EntityClass<T>;
201
+ map: I_EntityMap<T>;
204
202
  getData: () => T[];
205
203
  setData: (v: T[]) => void;
206
- constructor(p: I_EntityClass<T>);
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 | I_rowResult<T>;
234
- getFilteredTree: (data: T[], filter: (row: T, detail: I_rowResult<T>) => boolean | undefined) => T[];
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: I_rowResult<T>) => false | undefined) => void;
253
+ traverse: (rows: T[], callback: (row: T, detail: I_EntityRowDetail<T>) => false | undefined) => void;
252
254
  };
253
255
  dataActions: {
254
- getRowDetailById: (rowId: any) => false | I_rowResult<T>;
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: I_rowResult<T>) => boolean | undefined) => T[];
272
- traverse: (callback: (row: T, detail: I_rowResult<T>) => false | undefined) => void;
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.params.getId(row);
1505
- this.setId = (row) => this.params.setId(row);
1506
- this.getChilds = (row) => this.params.getChilds(row);
1507
- this.setChilds = (row, childs) => this.params.setChilds(row, childs);
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.params = p;
1925
+ this.map = p.map;
1926
1926
  if (p.getData) {
1927
1927
  this.getData = p.getData;
1928
1928
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-class",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/mohammadFeiz/aio-class#readme",
6
6
  "bugs": {