@open-xamu-co/ui-common-types 3.0.0-next.8 → 3.0.0
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 +12 -14
- package/src/form/class.ts +93 -0
- package/src/form/index.ts +2 -0
- package/src/{form.ts → form/types.ts} +20 -24
- package/src/index.ts +1 -1
- package/src/locale.ts +13 -17
- package/src/plugin.ts +9 -3
- package/src/swal.ts +12 -5
- package/src/values.ts +36 -6
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@open-xamu-co/ui-common-types",
|
|
3
|
-
"version": "3.0.0-next.8",
|
|
4
|
-
"description": "Xamu shared types",
|
|
5
2
|
"author": "@xamu-co",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"browserslist": [
|
|
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
|
+
},
|
|
14
|
+
"description": "Xamu shared types",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18",
|
|
17
|
+
"yarn": ">=1.22.4"
|
|
18
|
+
},
|
|
9
19
|
"files": [
|
|
10
20
|
"src/*"
|
|
11
21
|
],
|
|
12
|
-
"
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/xamu-co/ui.git"
|
|
15
|
-
},
|
|
22
|
+
"homepage": "https://github.com/xamu-co/ui#readme",
|
|
16
23
|
"keywords": [
|
|
17
24
|
"ts",
|
|
18
25
|
"js",
|
|
19
26
|
"types"
|
|
20
27
|
],
|
|
21
28
|
"license": "MIT",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
"homepage": "https://github.com/xamu-co/ui#readme",
|
|
29
|
+
"main": "src/index.ts",
|
|
30
|
+
"name": "@open-xamu-co/ui-common-types",
|
|
26
31
|
"publishConfig": {
|
|
27
32
|
"access": "public"
|
|
28
33
|
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/xamu-co/ui.git"
|
|
37
|
+
},
|
|
29
38
|
"scripts": {
|
|
30
39
|
"build": "node -e \"console.log('Build step not required')\"",
|
|
31
40
|
"build:legacy": "rimraf dist && tsc --outDir dist --declaration --emitDeclarationOnly"
|
|
32
41
|
},
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"sweetalert2": "^11.7.5"
|
|
37
|
-
},
|
|
38
|
-
"engines": {
|
|
39
|
-
"node": ">=18",
|
|
40
|
-
"yarn": ">=1.22.4"
|
|
41
|
-
},
|
|
42
|
-
"browserslist": [
|
|
43
|
-
"defaults"
|
|
44
|
-
]
|
|
42
|
+
"type": "module",
|
|
43
|
+
"types": "src/index.ts",
|
|
44
|
+
"version": "3.0.0"
|
|
45
45
|
}
|
package/src/fetch.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type tOrder = "desc" | "asc";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Order using column or property
|
|
5
|
+
*
|
|
6
|
+
* @example [["id", "asc" ]], order ascendente de id
|
|
7
|
+
* @example [["id", "desc" ]] or [["id"]], order descendente de id
|
|
8
|
+
*/
|
|
9
|
+
export type tOrderBy = [string, tOrder?];
|
|
2
10
|
|
|
3
11
|
export interface iPageEdge<T, C extends string | number = string> {
|
|
4
12
|
cursor: C;
|
|
@@ -19,7 +27,7 @@ export interface iPage<T, C extends string | number = string> {
|
|
|
19
27
|
totalCount: number;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
export interface iPagination
|
|
30
|
+
export interface iPagination {
|
|
23
31
|
/**
|
|
24
32
|
* Identificador del elemento donde empieza la paginacion
|
|
25
33
|
*
|
|
@@ -30,19 +38,9 @@ export interface iPagination<O = tOrderBy> {
|
|
|
30
38
|
* Cantidad de elementos (limite)
|
|
31
39
|
*/
|
|
32
40
|
first?: number;
|
|
33
|
-
|
|
34
|
-
* Ordenar segun columna o propiedad
|
|
35
|
-
* ej: ["id", "asc" ], order ascendente de id
|
|
36
|
-
* ej: ["id", "desc" ], order descendente de id
|
|
37
|
-
*/
|
|
38
|
-
orderBy?: O;
|
|
41
|
+
orderBy?: tOrderBy[];
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
/**
|
|
42
|
-
* Hydrate fetch ref (no refresh)
|
|
43
|
-
*/
|
|
44
|
-
export type tHydrate<T> = (c: T, e?: unknown) => void;
|
|
45
|
-
|
|
46
44
|
export type iGetPage<T, C extends string | number = string> = (
|
|
47
45
|
params?: iPagination
|
|
48
|
-
) => Promise<iPage<T, C
|
|
46
|
+
) => Promise<iPage<T, C> | undefined>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
eFormTypeBase,
|
|
3
|
+
eFormTypeSimple,
|
|
4
|
+
eFormTypeComplex,
|
|
5
|
+
} from "@open-xamu-co/ui-common-enums";
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
iFormInput,
|
|
9
|
+
iFormInputDefault,
|
|
10
|
+
iFormValue,
|
|
11
|
+
tFormAutocomplete,
|
|
12
|
+
tFormIcon,
|
|
13
|
+
} from "./types";
|
|
14
|
+
import type { iSelectOption } from "../values.js";
|
|
15
|
+
|
|
16
|
+
export declare abstract class tFormInputDefault<
|
|
17
|
+
T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex = eFormTypeSimple.TEXT,
|
|
18
|
+
> implements iFormInputDefault<T>
|
|
19
|
+
{
|
|
20
|
+
// public
|
|
21
|
+
public type: T;
|
|
22
|
+
// public readonly
|
|
23
|
+
public readonly required: boolean;
|
|
24
|
+
public readonly placeholder: string;
|
|
25
|
+
public readonly icon?: tFormIcon;
|
|
26
|
+
public readonly autocomplete?: tFormAutocomplete;
|
|
27
|
+
|
|
28
|
+
/** Rerender component */
|
|
29
|
+
public rerender(): void;
|
|
30
|
+
|
|
31
|
+
/** Set rerender function */
|
|
32
|
+
public setRerender(rerender: (fi?: Partial<iFormInputDefault<T>>) => void): this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export declare class tFormInput<V extends iFormValue = iFormValue, Vk extends V | V[] = V | V[]>
|
|
36
|
+
extends tFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex>
|
|
37
|
+
implements iFormInput<V, Vk>
|
|
38
|
+
{
|
|
39
|
+
// public readonly
|
|
40
|
+
public readonly name: string;
|
|
41
|
+
public readonly title?: string;
|
|
42
|
+
public readonly multiple: boolean;
|
|
43
|
+
public readonly min: number;
|
|
44
|
+
public readonly max: number;
|
|
45
|
+
// public
|
|
46
|
+
public options: iSelectOption[];
|
|
47
|
+
public values: Vk[];
|
|
48
|
+
public defaults?: [iFormInputDefault, iFormInputDefault, ...iFormInputDefault[]];
|
|
49
|
+
/**
|
|
50
|
+
* set rerender function
|
|
51
|
+
*
|
|
52
|
+
* @override
|
|
53
|
+
*/
|
|
54
|
+
public setRerender(rerender: (fi?: Partial<iFormInput<V>>) => void): this;
|
|
55
|
+
/**
|
|
56
|
+
* add new model to the models
|
|
57
|
+
*/
|
|
58
|
+
public addValue(newValue?: Vk): this;
|
|
59
|
+
/**
|
|
60
|
+
* remove the given value from the values
|
|
61
|
+
*/
|
|
62
|
+
public removeValue(index: number): this;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Clone this object
|
|
66
|
+
*/
|
|
67
|
+
public clone(
|
|
68
|
+
overrides?: Omit<iFormInput<V, Vk>, "name"> & { name?: string },
|
|
69
|
+
onUpdatedValues?: (updatedValues: Vk[]) => Vk[] | undefined | void
|
|
70
|
+
): tFormInput<V, Vk>;
|
|
71
|
+
/**
|
|
72
|
+
* Get simple object
|
|
73
|
+
*/
|
|
74
|
+
public getObject<Vi extends iFormValue = iFormValue, Vik extends Vi | Vi[] = Vi>(
|
|
75
|
+
input: iFormInput<Vi, Vik>
|
|
76
|
+
): iFormInput<Vi, Vik>;
|
|
77
|
+
|
|
78
|
+
public isEqual(other: tFormInput): boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface iForm {
|
|
82
|
+
/**
|
|
83
|
+
* Optional form key
|
|
84
|
+
*/
|
|
85
|
+
key?: string;
|
|
86
|
+
title?: string;
|
|
87
|
+
inputs: tFormInput[];
|
|
88
|
+
listen?: boolean;
|
|
89
|
+
/** Make all inputs read only by disabling them */
|
|
90
|
+
readonly?: boolean;
|
|
91
|
+
/** Message when no valid inputs are rendered */
|
|
92
|
+
emptyMessage?: string;
|
|
93
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IconName } from "@fortawesome/fontawesome-common-types";
|
|
2
2
|
|
|
3
|
-
import { eFormTypeComplex, eFormTypeSimple } from "@open-xamu-co/ui-common-enums";
|
|
3
|
+
import { eFormTypeBase, eFormTypeComplex, eFormTypeSimple } from "@open-xamu-co/ui-common-enums";
|
|
4
4
|
|
|
5
|
-
import type { iSelectOption } from "
|
|
5
|
+
import type { iSelectOption } from "../values.js";
|
|
6
6
|
|
|
7
7
|
export interface iFormOption extends iSelectOption {
|
|
8
8
|
/**
|
|
@@ -95,43 +95,37 @@ export type iFormIconProps = { brand?: boolean; regular?: boolean };
|
|
|
95
95
|
|
|
96
96
|
export type tFormIcon = [IconName | undefined, iFormIconProps];
|
|
97
97
|
|
|
98
|
-
export type iFormValue = string | number | boolean | File;
|
|
98
|
+
export type iFormValue = string | number | boolean | File | Date;
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Simple input
|
|
102
102
|
*/
|
|
103
|
-
export interface iFormInputDefault<
|
|
104
|
-
|
|
103
|
+
export interface iFormInputDefault<
|
|
104
|
+
T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex = eFormTypeSimple.TEXT,
|
|
105
|
+
> {
|
|
105
106
|
type?: T;
|
|
106
|
-
|
|
107
|
+
required?: boolean;
|
|
107
108
|
/**
|
|
108
109
|
* String without the dots
|
|
109
110
|
*/
|
|
110
111
|
placeholder?: string;
|
|
111
112
|
icon?: IconName | tFormIcon;
|
|
112
113
|
autocomplete?: tFormAutocomplete;
|
|
113
|
-
/**
|
|
114
|
-
* if muliple is set to true this optional value would be the required minimun amount of values
|
|
115
|
-
*/
|
|
116
|
-
min?: number;
|
|
117
|
-
/**
|
|
118
|
-
* if multiple is set to true this optional value would be the mandatory maximun amount of values
|
|
119
|
-
*/
|
|
120
|
-
max?: number;
|
|
121
114
|
}
|
|
122
115
|
|
|
123
116
|
/**
|
|
124
117
|
* Complex input, sub input support
|
|
125
118
|
*/
|
|
126
|
-
export interface iFormInput<V extends iFormValue = iFormValue>
|
|
127
|
-
extends iFormInputDefault<eFormTypeSimple | eFormTypeComplex> {
|
|
119
|
+
export interface iFormInput<V extends iFormValue = iFormValue, Vk extends V | V[] = V | V[]>
|
|
120
|
+
extends iFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex> {
|
|
128
121
|
name: string;
|
|
122
|
+
options?: (string | number | iFormOption)[];
|
|
129
123
|
/**
|
|
130
124
|
* An array of values to simplify validation
|
|
131
125
|
*
|
|
132
126
|
* @old value
|
|
133
127
|
*/
|
|
134
|
-
values?:
|
|
128
|
+
values?: Vk[];
|
|
135
129
|
defaults?: [iFormInputDefault, iFormInputDefault, ...iFormInputDefault[]];
|
|
136
130
|
/**
|
|
137
131
|
* Visible over the field, should describe it
|
|
@@ -144,12 +138,20 @@ export interface iFormInput<V extends iFormValue = iFormValue>
|
|
|
144
138
|
* Ex: { multiple: true, min:3, max:3 } would make 3 values a requirement
|
|
145
139
|
*/
|
|
146
140
|
multiple?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* if muliple is set to true this optional value would be the required minimun amount of values
|
|
143
|
+
*/
|
|
144
|
+
min?: number;
|
|
145
|
+
/**
|
|
146
|
+
* if multiple is set to true this optional value would be the mandatory maximun amount of values
|
|
147
|
+
*/
|
|
148
|
+
max?: number;
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
/**
|
|
150
152
|
* Sended form values
|
|
151
153
|
*/
|
|
152
|
-
export interface iFormResponse<R = any
|
|
154
|
+
export interface iFormResponse<R = any> {
|
|
153
155
|
response?: R;
|
|
154
156
|
invalidInputs: iInvalidInput[];
|
|
155
157
|
/**
|
|
@@ -169,12 +171,6 @@ export interface iFormResponse<R = any, T = any> {
|
|
|
169
171
|
* 401 will be reported but not failed
|
|
170
172
|
*/
|
|
171
173
|
errors?: any;
|
|
172
|
-
/**
|
|
173
|
-
* Swal target
|
|
174
|
-
*
|
|
175
|
-
* If the swal was triggered from a modal, then use it as render target
|
|
176
|
-
*/
|
|
177
|
-
modalTarget?: T;
|
|
178
174
|
}
|
|
179
175
|
|
|
180
176
|
export interface iFetchResponse<R = any> {
|
package/src/index.ts
CHANGED
package/src/locale.ts
CHANGED
|
@@ -53,7 +53,11 @@ export type tLocaleBase = {
|
|
|
53
53
|
cancel: string;
|
|
54
54
|
/** @example "Continue" */
|
|
55
55
|
continue: string;
|
|
56
|
-
/** @example "
|
|
56
|
+
/** @example "Error!" */
|
|
57
|
+
error: string;
|
|
58
|
+
/** @example "Something went wrong!" */
|
|
59
|
+
error_message: string;
|
|
60
|
+
/** @example "Connection error!" */
|
|
57
61
|
connection_error: string;
|
|
58
62
|
/** @example "The server is not responding. Please check your network or try again later" */
|
|
59
63
|
connection_error_message: string;
|
|
@@ -188,6 +192,10 @@ export type tLocaleForm = {
|
|
|
188
192
|
form_unmatching_passwords: string;
|
|
189
193
|
/** @example "Invalid data" */
|
|
190
194
|
form_invalid_data: string;
|
|
195
|
+
/** @example "No values" */
|
|
196
|
+
form_no_values: string;
|
|
197
|
+
/** @example "New value" */
|
|
198
|
+
form_new_value: string;
|
|
191
199
|
// swal: {};
|
|
192
200
|
};
|
|
193
201
|
|
|
@@ -201,8 +209,12 @@ export type tLocaleTable = {
|
|
|
201
209
|
table_see_values: string;
|
|
202
210
|
/** @example "See: \"{name}\"" */
|
|
203
211
|
table_see_name: string;
|
|
212
|
+
/** @example "Hide: \"{name}\"" */
|
|
213
|
+
table_hide_name: string;
|
|
204
214
|
/** @example "Create new" */
|
|
205
215
|
table_create_new: string;
|
|
216
|
+
/** @example "Crear nuevo" */
|
|
217
|
+
table_create_new_name: string;
|
|
206
218
|
/** @example "Quantity: {count} */
|
|
207
219
|
table_quantity: string;
|
|
208
220
|
/** @example "Modify" */
|
|
@@ -271,22 +283,6 @@ export type tLocalePagination = {
|
|
|
271
283
|
pagination_items: string;
|
|
272
284
|
/** @example "No pages | Single page | {count} pages" */
|
|
273
285
|
pagination_pages: string;
|
|
274
|
-
/** @example "Order: relevance" */
|
|
275
|
-
pagination_order_relevance: string;
|
|
276
|
-
/** @example "Order: more recent" */
|
|
277
|
-
pagination_order_recent: string;
|
|
278
|
-
/** @example "Order: more older" */
|
|
279
|
-
pagination_order_older: string;
|
|
280
|
-
/** @example "Order: lower price" */
|
|
281
|
-
pagination_order_expensive: string;
|
|
282
|
-
/** @example "Order: high price" */
|
|
283
|
-
pagination_order_cheaper: string;
|
|
284
|
-
/** @example "Order: alphabetically (Asc.)" */
|
|
285
|
-
pagination_order_az: string;
|
|
286
|
-
/** @example "Order: alphabetically (Desc.)" */
|
|
287
|
-
pagination_order_za: string;
|
|
288
|
-
/** @example "Filter by:" */
|
|
289
|
-
pagination_filter_by: string;
|
|
290
286
|
// swal: {};
|
|
291
287
|
};
|
|
292
288
|
|
package/src/plugin.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { tPluginLocale } from "./locale.js";
|
|
|
4
4
|
import type { SweetAlertOptions } from "sweetalert2";
|
|
5
5
|
|
|
6
6
|
export type tComponent = (typeof componentNames)[number];
|
|
7
|
+
export type tLogger = (at: string, ...logs: unknown[]) => any;
|
|
7
8
|
|
|
8
9
|
export type tSupportedLangs =
|
|
9
10
|
| "kr"
|
|
@@ -98,6 +99,7 @@ export interface iPluginOptions<ComponentType = unknown> {
|
|
|
98
99
|
overrides?: SweetAlertOptions;
|
|
99
100
|
preventOverrides?: SweetAlertOptions;
|
|
100
101
|
loaderOverrides?: SweetAlertOptions;
|
|
102
|
+
toastOverrides?: SweetAlertOptions;
|
|
101
103
|
};
|
|
102
104
|
/**
|
|
103
105
|
* Iso2 code for the default country
|
|
@@ -106,13 +108,11 @@ export interface iPluginOptions<ComponentType = unknown> {
|
|
|
106
108
|
*/
|
|
107
109
|
country?: string;
|
|
108
110
|
/**
|
|
109
|
-
* Countries API base endpoint
|
|
111
|
+
* Countries API base endpoint (full URL)
|
|
110
112
|
*
|
|
111
113
|
* If using nuxt, get better performance with the module
|
|
112
114
|
* @see https://www.npmjs.com/package/nuxt-countries-api
|
|
113
115
|
*
|
|
114
|
-
* Using an absolute path will enable the module
|
|
115
|
-
*
|
|
116
116
|
* @default "https://countries.xamu.com.co/api/v1"
|
|
117
117
|
*/
|
|
118
118
|
countriesUrl?: string;
|
|
@@ -134,4 +134,10 @@ export interface iPluginOptions<ComponentType = unknown> {
|
|
|
134
134
|
* @default 10
|
|
135
135
|
*/
|
|
136
136
|
first?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Logger function for debugging purposes
|
|
139
|
+
*
|
|
140
|
+
* @default console.log
|
|
141
|
+
*/
|
|
142
|
+
logger?: tLogger;
|
|
137
143
|
}
|
package/src/swal.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import DefaultSwal, { type SweetAlertOptions, type SweetAlertResult } from "sweetalert2";
|
|
2
2
|
|
|
3
|
+
export type tSwalOptions = Omit<SweetAlertOptions, "target"> & {
|
|
4
|
+
target?: SweetAlertOptions["target"] | Event;
|
|
5
|
+
};
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* Extended SweetAlert2 class
|
|
5
9
|
*
|
|
10
|
+
* Defaults should use Event as target
|
|
11
|
+
*
|
|
6
12
|
* Do not deestructure this
|
|
7
13
|
*/
|
|
8
|
-
export type tSwal = typeof DefaultSwal & {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
) => Promise<SweetAlertResult<Awaited<T>>>;
|
|
14
|
+
export type tSwal = Omit<typeof DefaultSwal, "fire"> & {
|
|
15
|
+
fire: <T = any>(options?: tSwalOptions) => Promise<SweetAlertResult<Awaited<T>>>;
|
|
16
|
+
firePrevent: <T = any>(options?: tSwalOptions) => Promise<SweetAlertResult<Awaited<T>>>;
|
|
17
|
+
fireLoader: <T = any>(options?: tSwalOptions) => Promise<SweetAlertResult<Awaited<T>>>;
|
|
18
|
+
fireToast: <T = any>(options?: tSwalOptions) => Promise<SweetAlertResult<Awaited<T>>>;
|
|
12
19
|
firePreventDefaults: SweetAlertOptions;
|
|
13
|
-
fireLoader: <T = unknown>(options?: SweetAlertOptions) => Promise<SweetAlertResult<Awaited<T>>>;
|
|
14
20
|
fireLoaderDefaults: SweetAlertOptions;
|
|
21
|
+
fireToastDefaults: SweetAlertOptions;
|
|
15
22
|
};
|
package/src/values.ts
CHANGED
|
@@ -2,24 +2,54 @@ export interface iSelectOption {
|
|
|
2
2
|
value: string | number;
|
|
3
3
|
alias?: string;
|
|
4
4
|
selected?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
hidden?: boolean;
|
|
5
7
|
}
|
|
6
8
|
|
|
9
|
+
export type iNodeFnResponse = [boolean?, Event?, (() => void)?];
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* Funtions that uses a node and perform some action
|
|
9
13
|
*
|
|
10
14
|
* Useful for table actions like creating, updating and deleting nodes
|
|
11
15
|
*/
|
|
12
|
-
export type iNodeFn<T extends Record<string, any
|
|
13
|
-
|
|
14
|
-
) => boolean | undefined | Promise<boolean | undefined>;
|
|
16
|
+
export type iNodeFn<T extends Record<string, any>, Ta extends [T?, ...any[]] = [T]> = (
|
|
17
|
+
...args: Ta
|
|
18
|
+
) => boolean | undefined | iNodeFnResponse | Promise<boolean | undefined | iNodeFnResponse>;
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* used on FactoryTable and related components
|
|
18
22
|
*/
|
|
19
|
-
export interface iProperty<
|
|
20
|
-
extends
|
|
23
|
+
export interface iProperty<
|
|
24
|
+
T extends Record<string, any> = Record<string, any>,
|
|
25
|
+
P extends Record<string, any> = Record<string, any>,
|
|
26
|
+
ComponentType = unknown,
|
|
27
|
+
> extends iSelectOption {
|
|
21
28
|
/**
|
|
22
29
|
* Function to create a node within the relation
|
|
30
|
+
* The parent is given since the node doesn't exist yet
|
|
31
|
+
*/
|
|
32
|
+
createNode?: iNodeFn<P, [P?]>;
|
|
33
|
+
/**
|
|
34
|
+
* Conditionally disable creating children for this particular property
|
|
35
|
+
*/
|
|
36
|
+
disableCreateNode?: (p: P) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Function to clone a node within the relation
|
|
39
|
+
*/
|
|
40
|
+
cloneNode?: iNodeFn<T, [T?]>;
|
|
41
|
+
/**
|
|
42
|
+
* Function to update a node within the relation
|
|
43
|
+
*/
|
|
44
|
+
updateNode?: iNodeFn<T, [T?, P?]>;
|
|
45
|
+
/**
|
|
46
|
+
* Function to delete a node within the relation
|
|
23
47
|
*/
|
|
24
|
-
|
|
48
|
+
deleteNode?: iNodeFn<T, [T?]>;
|
|
49
|
+
/**
|
|
50
|
+
* Render using this component instead
|
|
51
|
+
*/
|
|
52
|
+
component?: ComponentType;
|
|
25
53
|
}
|
|
54
|
+
|
|
55
|
+
export type tPropertyOrderFn = (a: [string, any], b: [string, any]) => -1 | 0 | 1;
|