@open-xamu-co/ui-common-types 3.0.0-next.22 → 3.0.0-next.24
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/form/class.ts +93 -0
- package/src/form/index.ts +2 -0
- package/src/{form.ts → form/types.ts} +3 -3
- package/src/index.ts +1 -1
- package/src/locale.ts +2 -0
package/package.json
CHANGED
|
@@ -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
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { IconName } from "@fortawesome/fontawesome-common-types";
|
|
|
2
2
|
|
|
3
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
|
/**
|
|
@@ -101,10 +101,10 @@ export type iFormValue = string | number | boolean | File | Date;
|
|
|
101
101
|
* Simple input
|
|
102
102
|
*/
|
|
103
103
|
export interface iFormInputDefault<
|
|
104
|
-
T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex = eFormTypeSimple,
|
|
104
|
+
T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex = eFormTypeSimple.TEXT,
|
|
105
105
|
> {
|
|
106
|
-
required?: boolean;
|
|
107
106
|
type?: T;
|
|
107
|
+
required?: boolean;
|
|
108
108
|
/**
|
|
109
109
|
* String without the dots
|
|
110
110
|
*/
|
package/src/index.ts
CHANGED
package/src/locale.ts
CHANGED
|
@@ -209,6 +209,8 @@ export type tLocaleTable = {
|
|
|
209
209
|
table_see_values: string;
|
|
210
210
|
/** @example "See: \"{name}\"" */
|
|
211
211
|
table_see_name: string;
|
|
212
|
+
/** @example "Hide: \"{name}\"" */
|
|
213
|
+
table_hide_name: string;
|
|
212
214
|
/** @example "Create new" */
|
|
213
215
|
table_create_new: string;
|
|
214
216
|
/** @example "Crear nuevo" */
|