@open-xamu-co/ui-common-types 4.0.0-next.1 → 4.0.0-next.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.
- package/package.json +2 -2
- package/src/fetch.ts +24 -2
- package/src/files.ts +3 -0
- package/src/locale.ts +7 -3
- package/src/values.ts +32 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xamu-co/ui-common-types",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.3",
|
|
4
4
|
"description": "Xamu shared types",
|
|
5
5
|
"author": "@xamu-co",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build:legacy": "rimraf dist && tsc --outDir dist --declaration --emitDeclarationOnly"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@open-xamu-co/ui-common-enums": "^
|
|
34
|
+
"@open-xamu-co/ui-common-enums": "^4.0.0-next.1",
|
|
35
35
|
"@fortawesome/fontawesome-common-types": "^6.4.0",
|
|
36
36
|
"sweetalert2": "^11.11.1"
|
|
37
37
|
},
|
package/src/fetch.ts
CHANGED
|
@@ -3,28 +3,44 @@ export type tOrder = "desc" | "asc";
|
|
|
3
3
|
/**
|
|
4
4
|
* Order using column or property
|
|
5
5
|
*
|
|
6
|
-
* @example [
|
|
7
|
-
* @example [
|
|
6
|
+
* @example ["id", "asc" ], order ascendente de id
|
|
7
|
+
* @example ["id", "desc" ] or ["id"], order descendente de id
|
|
8
8
|
*/
|
|
9
9
|
export type tOrderBy = [string, tOrder?];
|
|
10
10
|
|
|
11
11
|
export interface iPageEdge<T, C extends string | number = string> {
|
|
12
12
|
cursor: C;
|
|
13
|
+
/** Node data */
|
|
13
14
|
node: T;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface iPageInfo<C extends string | number = string> {
|
|
17
18
|
nextCursor?: C;
|
|
18
19
|
previousCursor?: C;
|
|
20
|
+
/**
|
|
21
|
+
* Current page number
|
|
22
|
+
* According to the "at" and "first" parameters
|
|
23
|
+
*/
|
|
19
24
|
pageNumber?: number;
|
|
25
|
+
/** There is a next page */
|
|
20
26
|
hasNextPage: boolean;
|
|
27
|
+
/** There is a previous page */
|
|
21
28
|
hasPreviousPage: boolean;
|
|
29
|
+
/** Current page path */
|
|
22
30
|
path?: string;
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
export interface iPage<T, C extends string | number = string> {
|
|
34
|
+
/**
|
|
35
|
+
* List of nodes with cursor data for the current page
|
|
36
|
+
* Amount of nodes is limited by the "first" parameter
|
|
37
|
+
*/
|
|
26
38
|
edges: iPageEdge<T, C>[];
|
|
27
39
|
pageInfo: iPageInfo<C>;
|
|
40
|
+
/**
|
|
41
|
+
* Count of nodes matching the path
|
|
42
|
+
* Independent of pagination
|
|
43
|
+
*/
|
|
28
44
|
totalCount: number;
|
|
29
45
|
}
|
|
30
46
|
|
|
@@ -39,6 +55,12 @@ export interface iPagination {
|
|
|
39
55
|
* Cantidad de elementos por pagina (limite)
|
|
40
56
|
*/
|
|
41
57
|
first?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Order using column or property
|
|
60
|
+
*
|
|
61
|
+
* @example [["id", "asc" ]], order ascendente de id
|
|
62
|
+
* @example [["id", "desc" ]] or [["id"]], order descendente de id
|
|
63
|
+
*/
|
|
42
64
|
orderBy?: tOrderBy[];
|
|
43
65
|
}
|
|
44
66
|
|
package/src/files.ts
CHANGED
package/src/locale.ts
CHANGED
|
@@ -109,10 +109,14 @@ export type tLocaleInput = {
|
|
|
109
109
|
file_limit: string;
|
|
110
110
|
/** @example "This field only allows {amount} file | This field only allows {amount} files" */
|
|
111
111
|
file_limit_text: string;
|
|
112
|
+
/** @example "Unsupported format" */
|
|
113
|
+
file_unsupported_format: string;
|
|
114
|
+
/** @example "This field only does not allow that file type" */
|
|
115
|
+
file_unsupported_format_text: string;
|
|
112
116
|
/** @example "Wrong format" */
|
|
113
|
-
|
|
114
|
-
/** @example "This field only allows
|
|
115
|
-
|
|
117
|
+
file_wrong_format: string;
|
|
118
|
+
/** @example "This field only allows "{types}" files" */
|
|
119
|
+
file_wrong_format_text: string;
|
|
116
120
|
/** @example "File too big" */
|
|
117
121
|
file_too_big: string;
|
|
118
122
|
/** @example "The file exceeds the allowed size" */
|
package/src/values.ts
CHANGED
|
@@ -17,6 +17,18 @@ export type iNodeFnResponse<T extends Record<string, any> = never> = [
|
|
|
17
17
|
(() => void)?,
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Stream like response from node functions
|
|
22
|
+
*
|
|
23
|
+
* Action result, event and callback
|
|
24
|
+
* Can accept an stream like array for multiple updates (hydration)
|
|
25
|
+
*/
|
|
26
|
+
export type iNodeFnResponseStream<T extends Record<string, any> = never> = [
|
|
27
|
+
(boolean | T | [boolean | T, ...Promise<boolean | T>[]])?,
|
|
28
|
+
Event?,
|
|
29
|
+
(() => void)?,
|
|
30
|
+
];
|
|
31
|
+
|
|
20
32
|
/**
|
|
21
33
|
* Funtions that uses a node and perform some action
|
|
22
34
|
*
|
|
@@ -30,6 +42,23 @@ export type iNodeFn<T extends Record<string, any>, Ta extends [T?, ...any[]] = [
|
|
|
30
42
|
...args: Ta
|
|
31
43
|
) => boolean | undefined | iNodeFnResponse<T> | Promise<boolean | undefined | iNodeFnResponse<T>>;
|
|
32
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Funtions that uses a node and perform some action
|
|
47
|
+
*
|
|
48
|
+
* Useful for table actions like creating, updating and deleting nodes
|
|
49
|
+
*
|
|
50
|
+
* Undefined would mean no action was performed
|
|
51
|
+
* True or an T type object would mean action was performed successfully
|
|
52
|
+
* False would mean action failed
|
|
53
|
+
*/
|
|
54
|
+
export type iNodeStreamFn<T extends Record<string, any>, Ta extends [T?, ...any[]] = [T]> = (
|
|
55
|
+
...args: Ta
|
|
56
|
+
) =>
|
|
57
|
+
| boolean
|
|
58
|
+
| undefined
|
|
59
|
+
| iNodeFnResponseStream<T>
|
|
60
|
+
| Promise<boolean | undefined | iNodeFnResponseStream<T>>;
|
|
61
|
+
|
|
33
62
|
/**
|
|
34
63
|
* Used on Table and related components
|
|
35
64
|
*
|
|
@@ -88,4 +117,7 @@ export interface iProperty<
|
|
|
88
117
|
onImageError?: (data?: any) => void;
|
|
89
118
|
}
|
|
90
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Function to order properties
|
|
122
|
+
*/
|
|
91
123
|
export type tPropertyOrderFn = (a: [string, any], b: [string, any]) => -1 | 0 | 1;
|