aio-class 2.2.2 → 2.2.3

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 +31 -5
  2. package/index.js +75 -11
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- /// <reference types="jquery" />
2
- /// <reference types="jquery" />
1
+ /// <reference types="emscripten" />
3
2
  import { AIOGeo } from 'aio-geo';
4
3
  import AIODate from 'aio-date';
5
4
  export { AIOGeo, AIODate };
@@ -78,7 +77,7 @@ export declare const ArrayToObject: <T>(keys: T[], fn: (key: T) => any) => any;
78
77
  export declare const TextFilter: (p: {
79
78
  value: string | number;
80
79
  chars?: {
81
- [key: string]: boolean | undefined;
80
+ [key: string]: boolean;
82
81
  };
83
82
  number?: boolean;
84
83
  symbol?: boolean;
@@ -188,7 +187,7 @@ export type I_EntityRowDetail<T> = {
188
187
  parentRow: T | false;
189
188
  parentChilds?: T[] | false;
190
189
  rowId: I_id;
191
- parentId?: I_id | false;
190
+ parentId: I_id | false;
192
191
  index: number;
193
192
  beforeSibling: false | T;
194
193
  afterSibling: false | T;
@@ -401,7 +400,7 @@ export type I_Swip_tempSelectRect = {
401
400
  left: number;
402
401
  top: number;
403
402
  };
404
- type I_Swip_dom = HTMLElement | JQuery | {
403
+ type I_Swip_dom = HTMLElement | any | {
405
404
  current: HTMLElement | null;
406
405
  } | string;
407
406
  export declare class Swip {
@@ -465,3 +464,30 @@ export declare class Swip {
465
464
  setSelectRect: (width: number, height: number) => void;
466
465
  removeSelectRect: () => void;
467
466
  }
467
+ export type I_logItem = {
468
+ tags: string[];
469
+ id: string;
470
+ repeat?: {
471
+ id: string;
472
+ count: number;
473
+ };
474
+ message: string;
475
+ status: 'error' | 'success' | 'warning' | 'info';
476
+ data?: any;
477
+ date: number;
478
+ expiredInMiliseconds: number;
479
+ };
480
+ export declare class LogsClass {
481
+ logs: I_logItem[];
482
+ load: () => Promise<I_logItem[]>;
483
+ save: (logs: I_logItem[]) => Promise<void>;
484
+ constructor(p: {
485
+ load: () => Promise<I_logItem[]>;
486
+ save: (logs: I_logItem[]) => Promise<void>;
487
+ });
488
+ init: () => Promise<void>;
489
+ changeLogs: (logs: I_logItem[]) => void;
490
+ add: (logItem: Partial<I_logItem>) => void;
491
+ remove: (logItem: I_logItem) => void;
492
+ clear: () => void;
493
+ }
package/index.js CHANGED
@@ -242,7 +242,7 @@ export const EventHandler = (selector, event, action, type = 'bind') => {
242
242
  element.addEventListener(fixedEvent, action);
243
243
  }
244
244
  };
245
- export const Stall = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (stallTime = 3000) { return yield new Promise(resolve => setTimeout(resolve, stallTime)); });
245
+ export const Stall = (stallTime = 3000) => __awaiter(void 0, void 0, void 0, function* () { return yield new Promise(resolve => setTimeout(resolve, stallTime)); });
246
246
  export const DetectOS = () => {
247
247
  const userAgent = window.navigator.userAgent;
248
248
  const platform = window.navigator.platform;
@@ -1852,61 +1852,71 @@ export class EntityClass {
1852
1852
  this.getSortedTree = (p) => {
1853
1853
  const rows = p.rows || this.getData();
1854
1854
  const res = this._getSortedTree(rows, p.sorts);
1855
- this.setData(res);
1855
+ if (!p.rows)
1856
+ this.setData(res);
1856
1857
  return res;
1857
1858
  };
1858
1859
  this.addRow = (p) => {
1859
1860
  const rows = p.rows || this.getData();
1860
1861
  const res = this._addRow(rows, p.row, p);
1861
- this.setData(res.rows);
1862
+ if (!p.rows)
1863
+ this.setData(res.rows);
1862
1864
  return res;
1863
1865
  };
1864
1866
  this.editRow = (p) => {
1865
1867
  const rows = p.rows || this.getData();
1866
1868
  const res = this._editRow(rows, p.row);
1867
- this.setData(res);
1869
+ if (!p.rows)
1870
+ this.setData(res);
1868
1871
  return res;
1869
1872
  };
1870
1873
  this.editById = (p) => {
1871
1874
  const rows = p.rows || this.getData();
1872
1875
  const res = this._editById(rows, p.rowId, p.change);
1873
- this.setData(res);
1876
+ if (!p.rows)
1877
+ this.setData(res);
1874
1878
  return res;
1875
1879
  };
1876
1880
  this.removeRow = (p) => {
1877
1881
  const rows = p.rows || this.getData();
1878
1882
  const res = this._removeRow(rows, p.rowId);
1879
- this.setData(res);
1883
+ if (!p.rows)
1884
+ this.setData(res);
1880
1885
  return res;
1881
1886
  };
1882
1887
  this.removeByRowIds = (p) => {
1883
1888
  const rows = p.rows || this.getData();
1884
1889
  const res = this._removeByRowIds(rows, p.rowIds);
1885
- this.setData(res);
1890
+ if (!p.rows)
1891
+ this.setData(res);
1886
1892
  return res;
1887
1893
  };
1888
1894
  this.reOrder = (p) => {
1889
1895
  const rows = p.rows || this.getData();
1890
1896
  const res = this._reOrder(rows, p.fromId, p.toId);
1891
- this.setData(res);
1897
+ if (!p.rows)
1898
+ this.setData(res);
1892
1899
  return res;
1893
1900
  };
1894
1901
  this.reOrderByDir = (p) => {
1895
1902
  const rows = p.rows || this.getData();
1896
1903
  const res = this._reOrderByDir(rows, p.rowId, p.dir);
1897
- this.setData(res);
1904
+ if (!p.rows)
1905
+ this.setData(res);
1898
1906
  return res;
1899
1907
  };
1900
1908
  this.moveTo = (p) => {
1901
1909
  const rows = p.rows || this.getData();
1902
1910
  const res = this._moveTo(rows, p.fromIds, p.toId);
1903
- this.setData(res);
1911
+ if (!p.rows)
1912
+ this.setData(res);
1904
1913
  return res;
1905
1914
  };
1906
1915
  this.editByTraverse = (p) => {
1907
1916
  const rows = p.rows || this.getData();
1908
1917
  const res = this._editByTraverse(rows, p.callback);
1909
- this.setData(res);
1918
+ if (!p.rows)
1919
+ this.setData(res);
1910
1920
  return res;
1911
1921
  };
1912
1922
  this.traverse = (p) => {
@@ -2498,3 +2508,57 @@ export class Swip {
2498
2508
  this.init();
2499
2509
  }
2500
2510
  }
2511
+ export class LogsClass {
2512
+ constructor(p) {
2513
+ this.logs = [];
2514
+ this.init = () => __awaiter(this, void 0, void 0, function* () {
2515
+ let logs = yield this.load();
2516
+ this.changeLogs(logs);
2517
+ });
2518
+ this.changeLogs = (logs) => {
2519
+ const nowM = Date.now();
2520
+ logs = logs.filter((o) => nowM < o.expiredInMiliseconds + o.date);
2521
+ this.save(logs);
2522
+ this.logs = logs;
2523
+ };
2524
+ this.add = (logItem) => {
2525
+ const getMessage = (message) => {
2526
+ if (message.length > 100) {
2527
+ const start = message.slice(0, 50);
2528
+ const end = message.slice(51, 100);
2529
+ return `${start} ... ${end}`;
2530
+ }
2531
+ return message;
2532
+ };
2533
+ const now = Date.now();
2534
+ logItem.id = GenerateId('string');
2535
+ logItem.message = getMessage(logItem.message || 'no message');
2536
+ logItem.date = now;
2537
+ logItem.status = logItem.status || 'info';
2538
+ logItem.expiredInMiliseconds = logItem.expiredInMiliseconds || 1 * 60 * 60 * 1000;
2539
+ let newLogs = [...this.logs, logItem];
2540
+ if (logItem.repeat) {
2541
+ const res = [];
2542
+ let count = 0;
2543
+ const rev = newLogs.reverse();
2544
+ for (let i = 0; i < rev.length; i++) {
2545
+ const o = rev[i];
2546
+ if (o.repeat && o.repeat.id === logItem.repeat.id) {
2547
+ if (count >= logItem.repeat.count) {
2548
+ continue;
2549
+ }
2550
+ count++;
2551
+ }
2552
+ res.push(o);
2553
+ }
2554
+ newLogs = res.reverse();
2555
+ }
2556
+ this.changeLogs(newLogs);
2557
+ };
2558
+ this.remove = (logItem) => this.changeLogs(this.logs.filter((o) => o.id !== logItem.id));
2559
+ this.clear = () => this.changeLogs([]);
2560
+ this.save = p.save;
2561
+ this.load = p.load;
2562
+ this.init();
2563
+ }
2564
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-class",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/mohammadFeiz/aio-class#readme",
6
6
  "bugs": {