@open-xamu-co/ui-common-types 2.0.0 → 3.0.0-next.1
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 +1 -1
- package/src/fetch.ts +13 -9
- package/src/form.ts +44 -6
- package/src/index.ts +2 -0
- package/src/locale.ts +4 -0
- package/src/plugin.ts +8 -0
- package/src/props.ts +2 -0
- package/src/swal.ts +18 -0
- package/src/values.ts +24 -0
package/package.json
CHANGED
package/src/fetch.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { eOrders } from "@open-xamu-co/ui-common-enums";
|
|
2
|
+
|
|
1
3
|
export type tOrderBy = [string, ("desc" | "asc")?];
|
|
2
4
|
|
|
3
5
|
export interface iPageEdge<T, C extends string | number = string> {
|
|
@@ -5,19 +7,21 @@ export interface iPageEdge<T, C extends string | number = string> {
|
|
|
5
7
|
node: T;
|
|
6
8
|
}
|
|
7
9
|
|
|
10
|
+
export interface iPageInfo<C extends string | number = string> {
|
|
11
|
+
nextCursor?: C;
|
|
12
|
+
previousCursor?: C;
|
|
13
|
+
hasNextPage: boolean;
|
|
14
|
+
hasPreviousPage: boolean;
|
|
15
|
+
path?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
export interface iPage<T, C extends string | number = string> {
|
|
9
19
|
edges: iPageEdge<T, C>[];
|
|
10
|
-
pageInfo:
|
|
11
|
-
nextCursor?: C;
|
|
12
|
-
previousCursor?: C;
|
|
13
|
-
hasNextPage: boolean;
|
|
14
|
-
hasPreviousPage: boolean;
|
|
15
|
-
path?: string;
|
|
16
|
-
};
|
|
20
|
+
pageInfo: iPageInfo<C>;
|
|
17
21
|
totalCount: number;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
export interface iPagination {
|
|
24
|
+
export interface iPagination<O extends tOrderBy | Record<string, eOrders> = tOrderBy> {
|
|
21
25
|
/**
|
|
22
26
|
* Identificador del elemento donde empieza la paginacion
|
|
23
27
|
*
|
|
@@ -34,7 +38,7 @@ export interface iPagination {
|
|
|
34
38
|
* ej: ["id", "asc" ], order ascendente de id
|
|
35
39
|
* ej: ["id", "desc" ], order descendente de id
|
|
36
40
|
*/
|
|
37
|
-
orderBy?:
|
|
41
|
+
orderBy?: O;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
/**
|
package/src/form.ts
CHANGED
|
@@ -2,10 +2,9 @@ import type { IconName } from "@fortawesome/fontawesome-common-types";
|
|
|
2
2
|
|
|
3
3
|
import { eFormTypeComplex, eFormTypeSimple } from "@open-xamu-co/ui-common-enums";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
selected?: boolean;
|
|
5
|
+
import type { iSelectOption } from "./values.js";
|
|
6
|
+
|
|
7
|
+
export interface iFormOption extends iSelectOption {
|
|
9
8
|
/**
|
|
10
9
|
* Font awesome icon
|
|
11
10
|
*/
|
|
@@ -17,7 +16,7 @@ export interface iSelectOption {
|
|
|
17
16
|
placeholder?: string;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export interface iIndicative extends
|
|
19
|
+
export interface iIndicative extends iFormOption {
|
|
21
20
|
code: string;
|
|
22
21
|
number: number;
|
|
23
22
|
}
|
|
@@ -104,7 +103,7 @@ export type iFormValue = string | number | boolean | File;
|
|
|
104
103
|
export interface iFormInputDefault<T extends eFormTypeSimple | eFormTypeComplex = eFormTypeSimple> {
|
|
105
104
|
required?: boolean;
|
|
106
105
|
type?: T;
|
|
107
|
-
options?: (string | number |
|
|
106
|
+
options?: (string | number | iFormOption)[];
|
|
108
107
|
/**
|
|
109
108
|
* String without the dots
|
|
110
109
|
*/
|
|
@@ -146,3 +145,42 @@ export interface iFormInput<V extends iFormValue = iFormValue>
|
|
|
146
145
|
*/
|
|
147
146
|
multiple?: boolean;
|
|
148
147
|
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Sended form values
|
|
151
|
+
*/
|
|
152
|
+
export interface iFormResponse<R = any, T = any> {
|
|
153
|
+
response?: R;
|
|
154
|
+
invalidInputs: iInvalidInput[];
|
|
155
|
+
/**
|
|
156
|
+
* If the request had any error (validation/request itself).
|
|
157
|
+
*/
|
|
158
|
+
withErrors: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* If the request had any error.
|
|
161
|
+
*/
|
|
162
|
+
requestHadErrors: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* If the validation had any error.
|
|
165
|
+
*/
|
|
166
|
+
validationHadErrors: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Errors payload,
|
|
169
|
+
* 401 will be reported but not failed
|
|
170
|
+
*/
|
|
171
|
+
errors?: any;
|
|
172
|
+
/**
|
|
173
|
+
* Swal target
|
|
174
|
+
*/
|
|
175
|
+
modalTarget?: T;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface iFetchResponse<R = any> {
|
|
179
|
+
data?: R;
|
|
180
|
+
errors?: any;
|
|
181
|
+
[x: string]: any;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type tResponseFn<T, V extends Record<string, any> = Record<string, any>> = (
|
|
185
|
+
values: V
|
|
186
|
+
) => Promise<iFetchResponse<T>>;
|
package/src/index.ts
CHANGED
package/src/locale.ts
CHANGED
|
@@ -238,6 +238,10 @@ export interface iLocaleTable {
|
|
|
238
238
|
table_updated: string;
|
|
239
239
|
/** @example "The item may not have been updated | The items may not have been updated" */
|
|
240
240
|
table_possibly_not_updated: string;
|
|
241
|
+
/** @example "Successfull update" */
|
|
242
|
+
table_created: string;
|
|
243
|
+
/** @example "The item may not have been created | The items may not have been created" */
|
|
244
|
+
table_possibly_not_created: string;
|
|
241
245
|
/** @example "Successfull cloning" */
|
|
242
246
|
table_cloned: string;
|
|
243
247
|
/** @example "The item may not have been cloned | The items may not have been cloned" */
|
package/src/plugin.ts
CHANGED
|
@@ -23,6 +23,8 @@ export type tSupportedLangs =
|
|
|
23
23
|
export interface iPluginOptions<ComponentType = unknown> {
|
|
24
24
|
/**
|
|
25
25
|
* Use web components
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
26
28
|
*/
|
|
27
29
|
webComponents?: boolean;
|
|
28
30
|
/**
|
|
@@ -105,14 +107,20 @@ export interface iPluginOptions<ComponentType = unknown> {
|
|
|
105
107
|
country?: string;
|
|
106
108
|
/**
|
|
107
109
|
* Disable automatic animations
|
|
110
|
+
*
|
|
111
|
+
* @default false
|
|
108
112
|
*/
|
|
109
113
|
disableAutoAnimate?: boolean;
|
|
110
114
|
/**
|
|
111
115
|
* Use pro Font Awesome icons (regular, light)
|
|
116
|
+
*
|
|
117
|
+
* @default false
|
|
112
118
|
*/
|
|
113
119
|
fontAwesomePro?: boolean;
|
|
114
120
|
/**
|
|
115
121
|
* Default pagination limit
|
|
122
|
+
*
|
|
123
|
+
* @default 10
|
|
116
124
|
*/
|
|
117
125
|
first?: number;
|
|
118
126
|
}
|
package/src/props.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export type tProp<T extends string = string> = T | Record<T, boolean>;
|
|
2
2
|
export type tProps<T extends string = string> = tProp<T> | tProp<T>[];
|
|
3
3
|
export type tPropsModifier<T extends string = string> = boolean | tProps<T>;
|
|
4
|
+
|
|
5
|
+
export type tIndicative = `${string}+${number}`;
|
package/src/swal.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DefaultSwal, {
|
|
2
|
+
type SweetAlertOptions,
|
|
3
|
+
type SweetAlertResult,
|
|
4
|
+
} from "sweetalert2/dist/sweetalert2.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extended SweetAlert2 class
|
|
8
|
+
*
|
|
9
|
+
* Do not deestructure this
|
|
10
|
+
*/
|
|
11
|
+
export type tSwal = typeof DefaultSwal & {
|
|
12
|
+
firePrevent: <T = unknown>(
|
|
13
|
+
options?: SweetAlertOptions
|
|
14
|
+
) => Promise<SweetAlertResult<Awaited<T>>>;
|
|
15
|
+
firePreventDefaults: SweetAlertOptions;
|
|
16
|
+
fireLoader: <T = unknown>(options?: SweetAlertOptions) => Promise<SweetAlertResult<Awaited<T>>>;
|
|
17
|
+
fireLoaderDefaults: SweetAlertOptions;
|
|
18
|
+
};
|
package/src/values.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface iSelectOption {
|
|
2
|
+
value: string | number;
|
|
3
|
+
alias?: string;
|
|
4
|
+
selected?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Funtions that uses a node and perform some action
|
|
9
|
+
*
|
|
10
|
+
* Useful for table actions like creating, updating and deleting nodes
|
|
11
|
+
*/
|
|
12
|
+
export type iNodeFn<T extends Record<string, any>> = (
|
|
13
|
+
n: T
|
|
14
|
+
) => boolean | undefined | Promise<boolean | undefined>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* used on FactoryTable and related components
|
|
18
|
+
*/
|
|
19
|
+
export interface iProperty<T extends Record<string, any>> extends iSelectOption {
|
|
20
|
+
/**
|
|
21
|
+
* Function to create a node within the relation
|
|
22
|
+
*/
|
|
23
|
+
createNode?: (n?: T) => boolean | undefined | Promise<boolean | undefined>;
|
|
24
|
+
}
|