aio-class 2.0.2

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 +271 -0
  2. package/index.js +2018 -0
  3. package/package.json +24 -0
package/index.d.ts ADDED
@@ -0,0 +1,271 @@
1
+ import { AIOGeo } from 'aio-geo';
2
+ import AIODate from 'aio-date';
3
+ export { AIOGeo, AIODate };
4
+ export type LocationResult = {
5
+ success: true;
6
+ latitude: number;
7
+ longitude: number;
8
+ errorMessage: '';
9
+ } | {
10
+ success: false;
11
+ errorMessage: string;
12
+ latitude?: never;
13
+ longitude?: never;
14
+ };
15
+ export declare const GetSingleton: <T>(key: string, factory: () => T) => T;
16
+ export declare const Debounce: (fn: any, delay?: number) => void;
17
+ export declare const Ellipsis: (text: string, length: number, position?: 'center' | 'end' | 'start') => string;
18
+ export declare const SplitNumber: (price: number | string, p?: {
19
+ count?: number;
20
+ splitter?: string;
21
+ toFixed?: number;
22
+ }) => string;
23
+ export declare const ShuffleArray: (array: any[]) => any[];
24
+ export declare const UrlToJson: (url: string) => {
25
+ [key: string]: any;
26
+ };
27
+ export declare const Get2Digit: (n: number) => string;
28
+ export declare const GetArray: (count: number, fn?: (index: number) => any, step?: number) => any[];
29
+ export declare const Normalize: (str: string, trim?: boolean) => string;
30
+ export declare const getClockHandleAngle: (p?: {
31
+ hour?: number;
32
+ minute?: number;
33
+ offset?: number;
34
+ }) => number[];
35
+ export declare const GetRandomNumber: (from: number, to: number) => number;
36
+ export declare const ToRadians: (degree: number) => number;
37
+ export declare const LocationDistance: (pos1: number[], pos2: number[], unit: 'km' | 'm', round?: boolean) => number;
38
+ export declare const SortArray: <T>(arr: T[], sorts: {
39
+ getValue?: (v: T, dir: 'inc' | 'dec') => any;
40
+ dir?: "inc" | "dec";
41
+ }[]) => T[];
42
+ export declare const ScoreText: (text: string, query: string) => number;
43
+ export declare const Search: <T>(arr: T[], searchValue: string, getRowValue: (row: T, index: number) => string) => T[];
44
+ export declare const IsTouch: () => boolean;
45
+ export declare const GetClient: (e: any, scroll?: boolean) => {
46
+ x: number;
47
+ y: number;
48
+ };
49
+ export declare const EventHandler: (selector: string | HTMLElement | Window, event: 'mousedown' | 'mousemove' | 'mouseup' | 'click', action: EventListener, type?: 'bind' | 'unbind') => void;
50
+ export declare const Stall: (stallTime?: number) => Promise<unknown>;
51
+ export declare const DetectOS: () => 'Macintosh' | 'MacIntel' | 'MacPPC' | 'Mac68K' | 'Win32' | 'Win64' | 'Windows' | 'WinCE' | 'iPhone' | 'iPad' | 'iPod' | 'macOS' | 'iOS' | 'Windows' | 'Android' | 'Linux' | 'Unknown';
52
+ export declare const FakeName: (p: {
53
+ type: 'firstname' | 'lastname' | 'fullname';
54
+ gender?: 'male' | 'female';
55
+ lang: 'en' | 'fa';
56
+ }) => string;
57
+ export declare const IsEqual: (a: any, b: any) => boolean;
58
+ export declare const AddQueryParamsToUrl: (url: string, params: {
59
+ [key: string]: any;
60
+ }) => string;
61
+ export declare const IsNetworkDisconnected: (errorResponse: any) => Promise<boolean>;
62
+ export declare const ReOrder: <T>(data: T[], dragIndex: number, dropIndex: number) => T[];
63
+ export declare const ClassListToString: (classes: any[]) => string;
64
+ export declare const AddToAttrs: (attrs: {
65
+ [key: string]: any;
66
+ }, p?: {
67
+ className?: string | ((string | undefined | false)[]);
68
+ style?: any;
69
+ attrs?: any;
70
+ }) => any;
71
+ export declare const StyleObjectToString: (styleObject: any) => string;
72
+ export declare const GetValueByField: (data: any, field: string, def?: any) => any;
73
+ export declare const SetValueByField: (data: any, field: string, value: any) => any;
74
+ export declare const DisabledContextMenu: () => void;
75
+ export declare const ArrayToObject: <T>(keys: T[], fn: (key: T) => any) => any;
76
+ export declare const TextFilter: (p: {
77
+ value: string | number;
78
+ chars?: {
79
+ [key: string]: boolean | undefined;
80
+ };
81
+ number?: boolean;
82
+ symbol?: boolean;
83
+ letter?: boolean;
84
+ arabicToPersian?: boolean;
85
+ latinNumbers?: boolean;
86
+ maxLength?: number;
87
+ }) => string;
88
+ export declare const GetErrorByRequired: (p: {
89
+ value: any;
90
+ label: string;
91
+ fa?: boolean;
92
+ required: boolean;
93
+ }) => string | void;
94
+ export declare const GetCurrentLocation: (options?: PositionOptions) => Promise<LocationResult>;
95
+ export declare const PriceToText: (num: number) => string;
96
+ export declare const GenerateId: <T extends string | number>(type: 'string' | 'number') => T;
97
+ export type FileResult<T> = {
98
+ success: boolean;
99
+ result: T;
100
+ message?: string;
101
+ };
102
+ export declare class FileClass {
103
+ isUrl: (input: string) => boolean;
104
+ isDataUrl: (input: string) => boolean;
105
+ toDataUrl: (input: File | Blob | string) => Promise<FileResult<string>>;
106
+ fileToText: (file: File | Blob) => Promise<any>;
107
+ readText: (input: File | Blob | string) => Promise<FileResult<any>>;
108
+ toSrc: (file: File | Blob | string) => string;
109
+ toBase64: (input: File | Blob | string) => Promise<FileResult<string>>;
110
+ GetDurationByUrl: (url: string) => Promise<number | null>;
111
+ GetSizeByUrl: (url: string) => Promise<number | null>;
112
+ GetNameByUrl: (url: string) => string;
113
+ GetFileDetailsByUrl: (url: string) => Promise<{
114
+ name: string;
115
+ size: null | number;
116
+ duration: null | number;
117
+ }>;
118
+ fetchBlob: (url: string) => Promise<FileResult<Blob>>;
119
+ fetchBlob2: () => Promise<void>;
120
+ base64ToBlob: (base64: string) => FileResult<Blob>;
121
+ handleFileName: (selectedName?: string) => string;
122
+ generateFileName: (mimeType?: string) => string;
123
+ private saveWeb;
124
+ dataUrlToBase64: (dataUrl: string) => FileResult<string>;
125
+ toBlob: (input: File | Blob | string | ArrayBuffer | Uint8Array | any) => Promise<FileResult<Blob>>;
126
+ saveText: (text: string, path: string) => Promise<{
127
+ success: boolean;
128
+ message: string;
129
+ }>;
130
+ saveFile: (input: File | Blob | string | ArrayBuffer | Uint8Array | any, path: string) => Promise<{
131
+ success: boolean;
132
+ message: string;
133
+ }>;
134
+ sizeToString: (size: number) => string;
135
+ }
136
+ type I_storage_model = {
137
+ [key: string]: {
138
+ value: any;
139
+ saveTime: number;
140
+ expiredIn: number;
141
+ };
142
+ };
143
+ export declare class StorageClass {
144
+ private model;
145
+ id: string;
146
+ constructor(id: string, context?: any);
147
+ private copy;
148
+ private setModel;
149
+ private getNow;
150
+ init: () => void;
151
+ save: (field: string, value: any, expiredIn?: number) => I_storage_model;
152
+ remove: (field: string) => I_storage_model;
153
+ isExpired: (field: string, model?: I_storage_model) => boolean;
154
+ removeExpireds: (model: I_storage_model) => I_storage_model;
155
+ load: (field: string, def?: any, expiredIn?: number) => any;
156
+ clear: () => I_storage_model;
157
+ getKeys: () => string[];
158
+ getList: () => any[];
159
+ dump: () => {
160
+ __CACHE__: {
161
+ [x: string]: any;
162
+ };
163
+ };
164
+ update: (data: any) => void;
165
+ }
166
+ export declare function Validate(param: {
167
+ value: any;
168
+ label: string;
169
+ validation: string | string[];
170
+ fa?: boolean;
171
+ }): string | void;
172
+ type I_sort<T> = {
173
+ dir: 'dec' | 'inc';
174
+ getValue: (row: T, dir: 'inc' | 'dec') => any;
175
+ };
176
+ type I_id = string | number;
177
+ type I_EntityClass<T> = {
178
+ getChilds: (row: T) => T[] | undefined;
179
+ setChilds: (row: T, childs: T[] | undefined) => T;
180
+ getId: (row: T) => I_id;
181
+ setId: (row: T) => T;
182
+ getData?: () => T[];
183
+ setData?: (v: T[]) => void;
184
+ };
185
+ type I_rowResult<T> = {
186
+ row: T;
187
+ parentRows: T[];
188
+ parentRow: T | false;
189
+ parentChilds?: T[] | false;
190
+ rowId: I_id;
191
+ parentId?: I_id | false;
192
+ index: number;
193
+ beforeSibling: false | T;
194
+ afterSibling: false | T;
195
+ childsLength: number;
196
+ isLeaf: boolean;
197
+ isFirstChild: boolean;
198
+ isLastChild: boolean;
199
+ };
200
+ export declare class EntityClass<T> {
201
+ params: I_EntityClass<T>;
202
+ getData: () => T[];
203
+ setData: (v: T[]) => void;
204
+ constructor(p: I_EntityClass<T>);
205
+ private getId;
206
+ private setId;
207
+ private getChilds;
208
+ private setChilds;
209
+ private getRowDetailsByIds;
210
+ private getRowDetailByRowAndParents;
211
+ getRowByAddChild: (parentRow: T, row: T, index?: number) => T;
212
+ removeChildOfParent: (parentRow: T, rowId: I_id) => T;
213
+ getRowDetailById: (data: T[], rowId: I_id) => false | I_rowResult<T>;
214
+ getFilteredTree: (data: T[], filter: (row: T, detail: I_rowResult<T>) => boolean | undefined) => T[];
215
+ sortData: (rows: T[], sorts: I_sort<T>[]) => T[];
216
+ addRow: (data: T[], row: T, p: {
217
+ parentId?: I_id;
218
+ index?: number;
219
+ }) => {
220
+ rows: T[];
221
+ row: T;
222
+ };
223
+ editRow: (data: T[], newRow: T) => T[];
224
+ editById: (data: T[], rowId: I_id, change: Partial<T>) => T[];
225
+ removeRow: (data: T[], rowId: I_id) => T[];
226
+ removeByRowIds: (data: T[], rowIds: I_id[]) => T[];
227
+ reOrder: (data: T[], fromId: I_id, toId: I_id, pos?: 'before' | 'after') => T[];
228
+ reOrderByDir: (data: T[], rowId: I_id, dir: 1 | -1) => T[];
229
+ moveTo: (data: T[], fromIds: I_id[], toId: I_id) => T[];
230
+ editByTraverse: (rows: T[], callback: (row: T) => T | false) => T[];
231
+ traverse: (rows: T[], callback: (row: T, detail: I_rowResult<T>) => false | undefined) => T[];
232
+ _dataMethods: {
233
+ getChilds: (row: T) => T[];
234
+ getId: (row: T) => I_id;
235
+ traverse: (rows: T[], callback: (row: T, detail: I_rowResult<T>) => false | undefined) => T[];
236
+ getRowDetailById: (data: T[], rowId: I_id) => false | I_rowResult<T>;
237
+ addRow: (row: T, p: {
238
+ parentId?: I_id;
239
+ index?: number;
240
+ }) => {
241
+ rows: T[];
242
+ row: T;
243
+ };
244
+ editRow: (newRow: T) => T[];
245
+ editById: (rowId: I_id, change: Partial<T>) => T[];
246
+ removeRow: (rowId: I_id) => T[];
247
+ removeByRowIds: (rowIds: I_id[]) => T[];
248
+ reOrder: (fromId: I_id, toId: I_id) => T[];
249
+ reOrderByDir: (rowId: I_id, dir: 1 | -1) => T[];
250
+ moveTo: (fromIds: I_id[], toId: I_id) => T[];
251
+ editByTraverse: (callback: (row: T) => T | false) => T[];
252
+ };
253
+ }
254
+ type I_color = any;
255
+ type I_color_type = 'rgb' | 'hex' | 'array';
256
+ export declare class AIOColors {
257
+ number_to_hex: (number: number) => string;
258
+ getType: (c: I_color) => I_color_type;
259
+ to_array: (c: I_color) => number[];
260
+ between: (c1: I_color, c2: I_color, count: number) => string[];
261
+ getBetween: (v: (string | number)[]) => I_color[];
262
+ to_dark: (c: I_color, percent: number) => I_color;
263
+ to_light: (c: I_color, percent: number) => I_color;
264
+ brightness: (c: I_color, percent: number) => I_color;
265
+ to_hex: (c: I_color) => string;
266
+ to_rgb: (c: I_color) => string;
267
+ log: (c: I_color[]) => void;
268
+ getRandomRGB: (c1?: I_color, c2?: I_color) => string;
269
+ reverse: (c: I_color) => I_color;
270
+ constructor();
271
+ }