@open-xamu-co/ui-common-types 3.0.2-next.1 → 3.1.0-next.10
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 +26 -26
- package/src/fetch.ts +2 -1
- package/src/form/class.ts +3 -1
- package/src/locale.ts +30 -10
- package/src/plugin.ts +11 -0
- package/src/values.ts +41 -5
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"defaults"
|
|
5
|
-
],
|
|
6
|
-
"bugs": {
|
|
7
|
-
"url": "https://github.com/xamu-co/ui/issues"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@fortawesome/fontawesome-common-types": "^6.4.0",
|
|
11
|
-
"@open-xamu-co/ui-common-enums": "^3.0.0",
|
|
12
|
-
"sweetalert2": "^11.11.1"
|
|
13
|
-
},
|
|
2
|
+
"name": "@open-xamu-co/ui-common-types",
|
|
3
|
+
"version": "3.1.0-next.10",
|
|
14
4
|
"description": "Xamu shared types",
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
"author": "@xamu-co",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"type": "module",
|
|
19
9
|
"files": [
|
|
20
10
|
"src/*"
|
|
21
11
|
],
|
|
22
|
-
"
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/xamu-co/ui.git"
|
|
15
|
+
},
|
|
23
16
|
"keywords": [
|
|
24
17
|
"ts",
|
|
25
18
|
"js",
|
|
26
19
|
"types"
|
|
27
20
|
],
|
|
28
21
|
"license": "MIT",
|
|
29
|
-
"
|
|
30
|
-
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/xamu-co/ui/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/xamu-co/ui#readme",
|
|
31
26
|
"publishConfig": {
|
|
32
27
|
"access": "public"
|
|
33
28
|
},
|
|
34
|
-
"repository": {
|
|
35
|
-
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/xamu-co/ui.git"
|
|
37
|
-
},
|
|
38
29
|
"scripts": {
|
|
39
30
|
"build": "node -e \"console.log('Build step not required')\"",
|
|
40
31
|
"build:legacy": "rimraf dist && tsc --outDir dist --declaration --emitDeclarationOnly"
|
|
41
32
|
},
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@open-xamu-co/ui-common-enums": "^3.1.0-next.1",
|
|
35
|
+
"@fortawesome/fontawesome-common-types": "^6.4.0",
|
|
36
|
+
"sweetalert2": "^11.11.1"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=20.19.3",
|
|
40
|
+
"yarn": ">=1.22.4"
|
|
41
|
+
},
|
|
42
|
+
"browserslist": [
|
|
43
|
+
"defaults"
|
|
44
|
+
]
|
|
45
45
|
}
|
package/src/fetch.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface iPageEdge<T, C extends string | number = string> {
|
|
|
16
16
|
export interface iPageInfo<C extends string | number = string> {
|
|
17
17
|
nextCursor?: C;
|
|
18
18
|
previousCursor?: C;
|
|
19
|
+
pageNumber?: number;
|
|
19
20
|
hasNextPage: boolean;
|
|
20
21
|
hasPreviousPage: boolean;
|
|
21
22
|
path?: string;
|
|
@@ -35,7 +36,7 @@ export interface iPagination {
|
|
|
35
36
|
*/
|
|
36
37
|
at?: string | number;
|
|
37
38
|
/**
|
|
38
|
-
* Cantidad de elementos (limite)
|
|
39
|
+
* Cantidad de elementos por pagina (limite)
|
|
39
40
|
*/
|
|
40
41
|
first?: number;
|
|
41
42
|
orderBy?: tOrderBy[];
|
package/src/form/class.ts
CHANGED
|
@@ -75,7 +75,9 @@ export declare class tFormInput<
|
|
|
75
75
|
*/
|
|
76
76
|
public clone(
|
|
77
77
|
overrides?: Omit<iFormInput<V, T>, "name"> & { name?: string },
|
|
78
|
-
onUpdatedValues?: (
|
|
78
|
+
onUpdatedValues?: (
|
|
79
|
+
updatedValues: V[]
|
|
80
|
+
) => V[] | undefined | void | Promise<V[] | undefined | void>
|
|
79
81
|
): tFormInput<V, T>;
|
|
80
82
|
/**
|
|
81
83
|
* Check if this object is equal to another
|
package/src/locale.ts
CHANGED
|
@@ -152,6 +152,8 @@ export type tLocaleForm = {
|
|
|
152
152
|
form_requires_n_values: string;
|
|
153
153
|
/** @example "Loading countries..." */
|
|
154
154
|
form_loading_countries: string;
|
|
155
|
+
/** @example "Awaiting countries data..." */
|
|
156
|
+
form_awaiting_countries: string;
|
|
155
157
|
/** @example "Look for country" */
|
|
156
158
|
form_country: string;
|
|
157
159
|
/** @example "Look for state" */
|
|
@@ -246,30 +248,46 @@ export type tLocaleTable = {
|
|
|
246
248
|
/** @example "Show all" */
|
|
247
249
|
table_show_all: string;
|
|
248
250
|
swal: {
|
|
249
|
-
/** @example "Are you sure you want to delete this
|
|
251
|
+
/** @example "Are you sure you want to delete this item?" */
|
|
250
252
|
table_delete_node_title: string;
|
|
251
|
-
/** @example "Remember that you wont be able to recover this
|
|
253
|
+
/** @example "Remember that you wont be able to recover this item data and you will lost all of your work" */
|
|
252
254
|
table_delete_node_disclaimer: string;
|
|
253
255
|
/** @example "Successfull deletion" */
|
|
254
256
|
table_deleted: string;
|
|
255
|
-
/** @example "
|
|
257
|
+
/** @example "The item was deleted, the list will refresh automatically" */
|
|
258
|
+
table_deleted_text: string;
|
|
259
|
+
/** @example "Are you sure you want to delete this item? | Are you sure you want to delete these {count} items?" */
|
|
256
260
|
table_delete_nodes_title: string;
|
|
257
|
-
/** @example "Remember that you wont be able to recover these
|
|
261
|
+
/** @example "Remember that you wont be able to recover these items data and you will lost all of your work" */
|
|
258
262
|
table_delete_nodes_disclaimer: string;
|
|
259
|
-
/** @example "
|
|
263
|
+
/** @example "Deletion went wrong" */
|
|
260
264
|
table_possibly_not_deleted: string;
|
|
265
|
+
/** @example "The item may not have been deleted | The items may not have been deleted" */
|
|
266
|
+
table_possibly_not_deleted_text: string;
|
|
261
267
|
/** @example "Successfull update" */
|
|
262
268
|
table_updated: string;
|
|
263
|
-
/** @example "The item
|
|
269
|
+
/** @example "The item was updated, the list will refresh automatically" */
|
|
270
|
+
table_updated_text: string;
|
|
271
|
+
/** @example "Update went wrong" */
|
|
264
272
|
table_possibly_not_updated: string;
|
|
265
|
-
/** @example "
|
|
273
|
+
/** @example "The item may not have been updated | The items may not have been updated" */
|
|
274
|
+
table_possibly_not_updated_text: string;
|
|
275
|
+
/** @example "Successfull creation" */
|
|
266
276
|
table_created: string;
|
|
267
|
-
/** @example "The item
|
|
277
|
+
/** @example "The item was created, you can already find it in the list" */
|
|
278
|
+
table_created_text: string;
|
|
279
|
+
/** @example "Creation went wrong" */
|
|
268
280
|
table_possibly_not_created: string;
|
|
269
|
-
/** @example "
|
|
281
|
+
/** @example "The item may not have been created | The items may not have been created" */
|
|
282
|
+
table_possibly_not_created_text: string;
|
|
283
|
+
/** @example "Successfull clonation" */
|
|
270
284
|
table_cloned: string;
|
|
271
|
-
/** @example "The item
|
|
285
|
+
/** @example "The item was cloned, you can already find it in the list" */
|
|
286
|
+
table_cloned_text: string;
|
|
287
|
+
/** @example "Clonation went wrong" */
|
|
272
288
|
table_possibly_not_cloned: string;
|
|
289
|
+
/** @example "The item may not have been cloned | The items may not have been cloned" */
|
|
290
|
+
table_possibly_not_cloned_text: string;
|
|
273
291
|
};
|
|
274
292
|
};
|
|
275
293
|
|
|
@@ -283,6 +301,8 @@ export type tLocalePagination = {
|
|
|
283
301
|
pagination_items: string;
|
|
284
302
|
/** @example "No pages | Single page | {count} pages" */
|
|
285
303
|
pagination_pages: string;
|
|
304
|
+
/** @example "Page {count} of" */
|
|
305
|
+
pagination_page: string;
|
|
286
306
|
// swal: {};
|
|
287
307
|
};
|
|
288
308
|
|
package/src/plugin.ts
CHANGED
|
@@ -51,6 +51,10 @@ export interface iPluginOptions<ComponentType = unknown> {
|
|
|
51
51
|
* Optional image optimization component
|
|
52
52
|
*/
|
|
53
53
|
imageComponent?: ComponentType | string;
|
|
54
|
+
/**
|
|
55
|
+
* Url to an image to be used as placeholder for images that failed to load
|
|
56
|
+
*/
|
|
57
|
+
imagePlaceholder?: string;
|
|
54
58
|
/**
|
|
55
59
|
* Host that contain images
|
|
56
60
|
* Treat the url within them as images
|
|
@@ -142,4 +146,11 @@ export interface iPluginOptions<ComponentType = unknown> {
|
|
|
142
146
|
* @default console.log
|
|
143
147
|
*/
|
|
144
148
|
logger?: tLogger;
|
|
149
|
+
/**
|
|
150
|
+
* Function used to encode the pagination cursor
|
|
151
|
+
*
|
|
152
|
+
* @default node.id
|
|
153
|
+
*/
|
|
154
|
+
cursorEncoder?: (<T>(node: T) => string) | (<T>(node: T) => number);
|
|
155
|
+
internals?: Record<string, any>;
|
|
145
156
|
}
|
package/src/values.ts
CHANGED
|
@@ -6,19 +6,35 @@ export interface iSelectOption {
|
|
|
6
6
|
hidden?: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Response from node functions
|
|
11
|
+
*
|
|
12
|
+
* Action result, event and callback
|
|
13
|
+
*/
|
|
14
|
+
export type iNodeFnResponse<T extends Record<string, any> = never> = [
|
|
15
|
+
(boolean | T)?,
|
|
16
|
+
Event?,
|
|
17
|
+
(() => void)?,
|
|
18
|
+
];
|
|
10
19
|
|
|
11
20
|
/**
|
|
12
21
|
* Funtions that uses a node and perform some action
|
|
13
22
|
*
|
|
14
23
|
* Useful for table actions like creating, updating and deleting nodes
|
|
24
|
+
*
|
|
25
|
+
* Undefined would mean no action was performed
|
|
26
|
+
* True or an T type object would mean action was performed successfully
|
|
27
|
+
* False would mean action failed
|
|
15
28
|
*/
|
|
16
29
|
export type iNodeFn<T extends Record<string, any>, Ta extends [T?, ...any[]] = [T]> = (
|
|
17
30
|
...args: Ta
|
|
18
|
-
) => boolean | undefined | iNodeFnResponse | Promise<boolean | undefined | iNodeFnResponse
|
|
31
|
+
) => boolean | undefined | iNodeFnResponse<T> | Promise<boolean | undefined | iNodeFnResponse<T>>;
|
|
19
32
|
|
|
20
33
|
/**
|
|
21
|
-
*
|
|
34
|
+
* Used on Table and related components
|
|
35
|
+
*
|
|
36
|
+
* @action Any task performed at each row cell (property)
|
|
37
|
+
* @nested Any task performed at a relation table within a modal
|
|
22
38
|
*/
|
|
23
39
|
export interface iProperty<
|
|
24
40
|
T extends Record<string, any> = Record<string, any>,
|
|
@@ -28,6 +44,9 @@ export interface iProperty<
|
|
|
28
44
|
/**
|
|
29
45
|
* Function to create a node within the relation
|
|
30
46
|
* The parent is given since the node doesn't exist yet
|
|
47
|
+
*
|
|
48
|
+
* @action Showcases an button to create a new node/value within this property/relation
|
|
49
|
+
* @nested Passed down to the related table if any
|
|
31
50
|
*/
|
|
32
51
|
createNode?: iNodeFn<P, [P?]>;
|
|
33
52
|
/**
|
|
@@ -36,20 +55,37 @@ export interface iProperty<
|
|
|
36
55
|
disableCreateNode?: (p: P) => boolean;
|
|
37
56
|
/**
|
|
38
57
|
* Function to clone a node within the relation
|
|
58
|
+
* Set to false to omit cloning this property/relation
|
|
59
|
+
*
|
|
60
|
+
* @action No inline action
|
|
61
|
+
* @nested Passed down to the related table if any
|
|
39
62
|
*/
|
|
40
|
-
cloneNode?: iNodeFn<T, [T?]
|
|
63
|
+
cloneNode?: iNodeFn<T, [T?]> | false;
|
|
41
64
|
/**
|
|
42
65
|
* Function to update a node within the relation
|
|
66
|
+
*
|
|
67
|
+
* @action Showcases an button to update this node/value within this property/relation
|
|
68
|
+
* @nested Passed down to the related table if any
|
|
43
69
|
*/
|
|
44
70
|
updateNode?: iNodeFn<T, [T?, P?]>;
|
|
45
71
|
/**
|
|
46
72
|
* Function to delete a node within the relation
|
|
73
|
+
*
|
|
74
|
+
* @action No inline action
|
|
75
|
+
* @nested Passed down to the related table if any
|
|
47
76
|
*/
|
|
48
77
|
deleteNode?: iNodeFn<T, [T?]>;
|
|
49
78
|
/**
|
|
50
|
-
* Render using this component instead
|
|
79
|
+
* Render row cell (property) using this component instead
|
|
51
80
|
*/
|
|
52
81
|
component?: ComponentType;
|
|
82
|
+
/**
|
|
83
|
+
* Url to an image to be used as placeholder for images that failed to load
|
|
84
|
+
* Overrides the plugin's imagePlaceholder
|
|
85
|
+
*/
|
|
86
|
+
imagePlaceholder?: string;
|
|
87
|
+
/** Event to handle image load errors */
|
|
88
|
+
onImageError?: (data?: any) => void;
|
|
53
89
|
}
|
|
54
90
|
|
|
55
91
|
export type tPropertyOrderFn = (a: [string, any], b: [string, any]) => -1 | 0 | 1;
|