@open-xamu-co/ui-common-types 3.0.0 → 3.0.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 CHANGED
@@ -41,5 +41,5 @@
41
41
  },
42
42
  "type": "module",
43
43
  "types": "src/index.ts",
44
- "version": "3.0.0"
44
+ "version": "3.0.1"
45
45
  }
package/src/form/class.ts CHANGED
@@ -14,7 +14,7 @@ import type {
14
14
  import type { iSelectOption } from "../values.js";
15
15
 
16
16
  export declare abstract class tFormInputDefault<
17
- T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex = eFormTypeSimple.TEXT,
17
+ T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex = eFormTypeSimple,
18
18
  > implements iFormInputDefault<T>
19
19
  {
20
20
  // public
@@ -32,9 +32,15 @@ export declare abstract class tFormInputDefault<
32
32
  public setRerender(rerender: (fi?: Partial<iFormInputDefault<T>>) => void): this;
33
33
  }
34
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>
35
+ export declare class tFormInput<
36
+ V extends iFormValue | iFormValue[] = iFormValue | iFormValue[],
37
+ T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex =
38
+ | eFormTypeBase
39
+ | eFormTypeSimple
40
+ | eFormTypeComplex,
41
+ >
42
+ extends tFormInputDefault<T>
43
+ implements iFormInput<V, T>
38
44
  {
39
45
  // public readonly
40
46
  public readonly name: string;
@@ -44,38 +50,45 @@ export declare class tFormInput<V extends iFormValue = iFormValue, Vk extends V
44
50
  public readonly max: number;
45
51
  // public
46
52
  public options: iSelectOption[];
47
- public values: Vk[];
48
- public defaults?: [iFormInputDefault, iFormInputDefault, ...iFormInputDefault[]];
53
+ public values: V[];
54
+ public defaults?: [
55
+ iFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex>,
56
+ iFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex>,
57
+ ...iFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex>[],
58
+ ];
49
59
  /**
50
60
  * set rerender function
51
61
  *
52
62
  * @override
53
63
  */
54
- public setRerender(rerender: (fi?: Partial<iFormInput<V>>) => void): this;
64
+ public setRerender(rerender: (fi?: Partial<iFormInput<V, T>>) => void): this;
55
65
  /**
56
66
  * add new model to the models
57
67
  */
58
- public addValue(newValue?: Vk): this;
68
+ public addValue(newValue?: V): this;
59
69
  /**
60
70
  * remove the given value from the values
61
71
  */
62
72
  public removeValue(index: number): this;
63
-
64
73
  /**
65
74
  * Clone this object
66
75
  */
67
76
  public clone(
68
- overrides?: Omit<iFormInput<V, Vk>, "name"> & { name?: string },
69
- onUpdatedValues?: (updatedValues: Vk[]) => Vk[] | undefined | void
70
- ): tFormInput<V, Vk>;
77
+ overrides?: Omit<iFormInput<V, T>, "name"> & { name?: string },
78
+ onUpdatedValues?: (updatedValues: V[]) => V[] | undefined | void
79
+ ): tFormInput<V, T>;
71
80
  /**
72
- * Get simple object
81
+ * Check if this object is equal to another
73
82
  */
74
- public getObject<Vi extends iFormValue = iFormValue, Vik extends Vi | Vi[] = Vi>(
75
- input: iFormInput<Vi, Vik>
76
- ): iFormInput<Vi, Vik>;
77
-
78
83
  public isEqual(other: tFormInput): boolean;
84
+
85
+ /**
86
+ * Get simple object
87
+ */
88
+ static getObject<
89
+ Vi extends iFormValue | iFormValue[],
90
+ Ti extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex = eFormTypeSimple,
91
+ >(input: iFormInput<Vi, Ti>): iFormInput<Vi, Ti>;
79
92
  }
80
93
 
81
94
  export interface iForm {
package/src/form/types.ts CHANGED
@@ -101,7 +101,7 @@ 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.TEXT,
104
+ T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex = eFormTypeSimple,
105
105
  > {
106
106
  type?: T;
107
107
  required?: boolean;
@@ -116,8 +116,10 @@ export interface iFormInputDefault<
116
116
  /**
117
117
  * Complex input, sub input support
118
118
  */
119
- export interface iFormInput<V extends iFormValue = iFormValue, Vk extends V | V[] = V | V[]>
120
- extends iFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex> {
119
+ export interface iFormInput<
120
+ V extends iFormValue | iFormValue[],
121
+ T extends eFormTypeBase | eFormTypeSimple | eFormTypeComplex,
122
+ > extends iFormInputDefault<T> {
121
123
  name: string;
122
124
  options?: (string | number | iFormOption)[];
123
125
  /**
@@ -125,8 +127,12 @@ export interface iFormInput<V extends iFormValue = iFormValue, Vk extends V | V[
125
127
  *
126
128
  * @old value
127
129
  */
128
- values?: Vk[];
129
- defaults?: [iFormInputDefault, iFormInputDefault, ...iFormInputDefault[]];
130
+ values?: V[];
131
+ defaults?: [
132
+ iFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex>,
133
+ iFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex>,
134
+ ...iFormInputDefault<eFormTypeBase | eFormTypeSimple | eFormTypeComplex>[],
135
+ ];
130
136
  /**
131
137
  * Visible over the field, should describe it
132
138
  */