@amodx/schemas 0.0.1 → 0.0.21
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/Inputs/DefaultInputs.d.ts +31 -184
- package/Inputs/DefaultInputs.js +115 -342
- package/Inputs/PropertyInput.d.ts +27 -29
- package/Inputs/PropertyInput.js +22 -18
- package/Inputs/PropertyInputRegister.d.ts +4 -4
- package/Inputs/PropertyInputRegister.js +2 -2
- package/Inputs/index.d.ts +2 -0
- package/Inputs/index.js +2 -0
- package/Inputs/registerInput.d.ts +18 -0
- package/Inputs/registerInput.js +32 -0
- package/Properties/Property.d.ts +1 -1
- package/Properties.d.ts +57 -26
- package/Properties.js +25 -211
- package/Property.types.d.ts +13 -0
- package/Property.types.js +1 -0
- package/Schema/Node.d.ts +0 -0
- package/Schema/Node.js +1 -0
- package/Schema/Object.d.ts +0 -0
- package/Schema/Object.js +1 -0
- package/Schema/Property.d.ts +0 -0
- package/Schema/Property.js +1 -0
- package/Schema/Schema.d.ts +2 -0
- package/Schema/Schema.js +2 -0
- package/Schemas/SchemaNode.d.ts +13 -8
- package/Schemas/SchemaNode.js +24 -15
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PropertyInputRegister } from "./PropertyInputRegister";
|
|
2
|
+
import { Property } from "../Properties/Property";
|
|
3
|
+
export function registerInput(data) {
|
|
4
|
+
PropertyInputRegister.regsiterProperty(data);
|
|
5
|
+
const Create = (initalProperties = {}) => {
|
|
6
|
+
return {
|
|
7
|
+
type: data.id,
|
|
8
|
+
properties: data.createProperties(initalProperties),
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
return Object.assign(Create, {
|
|
12
|
+
id: data.id,
|
|
13
|
+
meta: {
|
|
14
|
+
name: data.name,
|
|
15
|
+
},
|
|
16
|
+
createPropertyFC(defaultValue) {
|
|
17
|
+
const fc = (id, data = {}) => {
|
|
18
|
+
return Property.Create({
|
|
19
|
+
id,
|
|
20
|
+
name: data.name,
|
|
21
|
+
value: data.value ? data.value : defaultValue,
|
|
22
|
+
initialize: data.initialize,
|
|
23
|
+
input: Create(data),
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
return fc;
|
|
27
|
+
},
|
|
28
|
+
createPropertyRenderFC(fn) {
|
|
29
|
+
return fn;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
package/Properties/Property.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class Property<Value = any, Input extends PropertyInputData | nul
|
|
|
17
17
|
input?: Input | undefined;
|
|
18
18
|
editable?: boolean | undefined;
|
|
19
19
|
conditions?: PropertyConditionAction[] | undefined;
|
|
20
|
-
children?: Property<any>[] | undefined;
|
|
20
|
+
children?: Property<any, any>[] | undefined;
|
|
21
21
|
static Create<Value = any, Input extends PropertyInputData | null = null>(data: Partial<Property<Value, Input>>): Property<Value, Input>;
|
|
22
22
|
private constructor();
|
|
23
23
|
}
|
package/Properties.d.ts
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ColorPropertyInput, FilePathPropertyInput, FloatPropertyInput, IntPropertyInput, PasswordPropertyInput, RangePropertyInput, SelectPropertyInput, StringPropertyInput, Vec2PropertyInput, Vec3PropertyInput, CheckboxPropertyInput, DatePropertyInput, TextareaPropertyInput, EmailPropertyInput, UrlPropertyInput } from "./Inputs/DefaultInputs";
|
|
1
|
+
import { PropertyFC } from "./Property.types";
|
|
3
2
|
import { ObjectPath } from "./Properties/ObjectPath";
|
|
4
3
|
import { Property } from "./Properties/Property";
|
|
5
4
|
import { PropertyCondition } from "./Properties/PropertyCondition";
|
|
6
5
|
import { PropertyConditionAction } from "./Properties/PropertyConditionAction";
|
|
7
|
-
import { SchemaNode } from "./Schemas/SchemaNode";
|
|
8
|
-
type PropertyCreateData<Value extends any, Input extends PropertyInputData> = {
|
|
9
|
-
name?: string;
|
|
10
|
-
value?: Value;
|
|
11
|
-
validator?: string;
|
|
12
|
-
initialize?: (node: SchemaNode) => void;
|
|
13
|
-
} & Partial<Input["properties"]>;
|
|
14
|
-
type PropertyFC<Value extends any, Input extends PropertyInputBase> = (id: string, data?: Exclude<PropertyCreateData<Value, Input["data"]>, "id">) => Property<Value, Input["data"]>;
|
|
15
6
|
export declare const PropConditions: ((data: Property<any, any>, ...conditions: PropertyConditionAction[]) => Property<any, any>) & {
|
|
16
7
|
Action: typeof PropertyConditionAction.Create;
|
|
17
8
|
Condition: typeof PropertyCondition.Create;
|
|
@@ -19,26 +10,66 @@ export declare const PropConditions: ((data: Property<any, any>, ...conditions:
|
|
|
19
10
|
};
|
|
20
11
|
export declare const ObjectProp: (id: string, name: string, ...properties: Property<any, any>[]) => Property<any, null>;
|
|
21
12
|
export declare const AnyProp: PropertyFC<any, any>;
|
|
22
|
-
export declare const StringProp: PropertyFC<string,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export declare const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
export declare const StringProp: PropertyFC<string, import("./Inputs").PropertyInputBase<string, import("./Inputs").PropertyInputBaseProperties & {
|
|
14
|
+
min: number;
|
|
15
|
+
max: number;
|
|
16
|
+
}>>;
|
|
17
|
+
export declare const FloatProp: PropertyFC<number, import("./Inputs").PropertyInputBase<number, import("./Inputs").PropertyInputBaseProperties & {
|
|
18
|
+
min: number;
|
|
19
|
+
max: number;
|
|
20
|
+
}>>;
|
|
21
|
+
export declare const IntProp: PropertyFC<number, import("./Inputs").PropertyInputBase<number, import("./Inputs").PropertyInputBaseProperties & {
|
|
22
|
+
min: number;
|
|
23
|
+
max: number;
|
|
24
|
+
}>>;
|
|
25
|
+
export declare const RangeProp: PropertyFC<number, import("./Inputs").PropertyInputBase<number, import("./Inputs").PropertyInputBaseProperties & {
|
|
26
|
+
min: number;
|
|
27
|
+
max: number;
|
|
28
|
+
step: number;
|
|
29
|
+
}>>;
|
|
30
|
+
export declare const HexColorProp: PropertyFC<string, import("./Inputs").PropertyInputBase<string, import("./Inputs").PropertyInputBaseProperties>>;
|
|
31
|
+
export declare const Color3Prop: PropertyFC<{
|
|
32
|
+
r: number;
|
|
33
|
+
g: number;
|
|
34
|
+
b: number;
|
|
35
|
+
}, import("./Inputs").PropertyInputBase<{
|
|
36
|
+
r: number;
|
|
37
|
+
g: number;
|
|
38
|
+
b: number;
|
|
39
|
+
}, import("./Inputs").PropertyInputBaseProperties>>;
|
|
40
|
+
export declare const Color4Prop: PropertyFC<{
|
|
41
|
+
r: number;
|
|
42
|
+
g: number;
|
|
43
|
+
b: number;
|
|
44
|
+
a: number;
|
|
45
|
+
}, import("./Inputs").PropertyInputBase<{
|
|
46
|
+
r: number;
|
|
47
|
+
g: number;
|
|
48
|
+
b: number;
|
|
49
|
+
a: number;
|
|
50
|
+
}, import("./Inputs").PropertyInputBaseProperties>>;
|
|
51
|
+
export declare const SelectProp: PropertyFC<string | number, import("./Inputs").PropertyInputBase<string | number, import("./Inputs").PropertyInputBaseProperties & {
|
|
52
|
+
options: string[] | [string, string | number][];
|
|
53
|
+
mode?: string;
|
|
54
|
+
}>>;
|
|
30
55
|
export declare const Vec2Prop: PropertyFC<{
|
|
31
56
|
x: number;
|
|
32
57
|
y: number;
|
|
33
|
-
},
|
|
58
|
+
}, import("./Inputs").PropertyInputBase<{
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
}, import("./Inputs").PropertyInputBaseProperties & {
|
|
62
|
+
valueType: "position" | "dimension";
|
|
63
|
+
}>>;
|
|
34
64
|
export declare const Vec3Prop: PropertyFC<{
|
|
35
65
|
x: number;
|
|
36
66
|
y: number;
|
|
37
67
|
z: number;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
}, import("./Inputs").PropertyInputBase<{
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
z: number;
|
|
72
|
+
}, import("./Inputs").PropertyInputBaseProperties & {
|
|
73
|
+
valueType: "position" | "dimension";
|
|
74
|
+
}>>;
|
|
75
|
+
export declare const BooleanProp: PropertyFC<boolean, import("./Inputs").PropertyInputBase<boolean, import("./Inputs").PropertyInputBaseProperties>>;
|
package/Properties.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Color3PropertyInput, Color4PropertyInput, HexColorPropertyInput, FloatPropertyInput, IntPropertyInput, RangePropertyInput, SelectPropertyInput, StringPropertyInput, Vec2PropertyInput, Vec3PropertyInput, BooleanPropertyInput, } from "./Inputs/DefaultInputs";
|
|
2
2
|
import { ObjectPath } from "./Properties/ObjectPath";
|
|
3
3
|
import { Property } from "./Properties/Property";
|
|
4
4
|
import { PropertyCondition } from "./Properties/PropertyCondition";
|
|
@@ -27,213 +27,27 @@ export const AnyProp = (id, data = {}) => {
|
|
|
27
27
|
input: null,
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
export const StringProp = (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
min: data.min ? data.min : 0,
|
|
55
|
-
max: data.max ? data.max : Number.MAX_SAFE_INTEGER,
|
|
56
|
-
},
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
export const FloatProp = (id, data = {}) => {
|
|
61
|
-
return Property.Create({
|
|
62
|
-
id,
|
|
63
|
-
name: data.name,
|
|
64
|
-
value: data.value ? data.value : 0,
|
|
65
|
-
initialize: data.initialize,
|
|
66
|
-
input: FloatPropertyInput.Create({
|
|
67
|
-
validator: data.validator,
|
|
68
|
-
properties: {
|
|
69
|
-
min: data.min ? data.min : 0,
|
|
70
|
-
max: data.max ? data.max : Number.MAX_VALUE,
|
|
71
|
-
},
|
|
72
|
-
}),
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
export const IntProp = (id, data = {}) => {
|
|
76
|
-
return Property.Create({
|
|
77
|
-
id,
|
|
78
|
-
name: data.name,
|
|
79
|
-
value: data.value ? data.value : 0,
|
|
80
|
-
initialize: data.initialize,
|
|
81
|
-
input: IntPropertyInput.Create({
|
|
82
|
-
validator: data.validator,
|
|
83
|
-
properties: {
|
|
84
|
-
min: data.min ? data.min : 0,
|
|
85
|
-
max: data.max ? data.max : Number.MAX_SAFE_INTEGER,
|
|
86
|
-
},
|
|
87
|
-
}),
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
export const RangeProp = (id, data = {}) => {
|
|
91
|
-
return Property.Create({
|
|
92
|
-
id,
|
|
93
|
-
name: data.name,
|
|
94
|
-
value: data.value ? data.value : 0,
|
|
95
|
-
initialize: data.initialize,
|
|
96
|
-
input: RangePropertyInput.Create({
|
|
97
|
-
validator: data.validator,
|
|
98
|
-
properties: {
|
|
99
|
-
min: data.min ? data.min : 0,
|
|
100
|
-
max: data.max ? data.max : Number.MAX_VALUE,
|
|
101
|
-
step: data.step ? data.step : 0.1,
|
|
102
|
-
},
|
|
103
|
-
}),
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
export const ColorProp = (id, data = {}) => {
|
|
107
|
-
return Property.Create({
|
|
108
|
-
id,
|
|
109
|
-
name: data.name,
|
|
110
|
-
value: data.value ? data.value : "#ffffff",
|
|
111
|
-
initialize: data.initialize,
|
|
112
|
-
input: ColorPropertyInput.Create({
|
|
113
|
-
validator: data.validator,
|
|
114
|
-
properties: {},
|
|
115
|
-
}),
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
export const SelectProp = (id, data = {}) => {
|
|
119
|
-
return Property.Create({
|
|
120
|
-
id,
|
|
121
|
-
name: data.name,
|
|
122
|
-
value: data.value ? data.value : "",
|
|
123
|
-
initialize: data.initialize,
|
|
124
|
-
input: SelectPropertyInput.Create({
|
|
125
|
-
validator: data.validator,
|
|
126
|
-
properties: {
|
|
127
|
-
options: data.options ? data.options : [],
|
|
128
|
-
mode: data.mode,
|
|
129
|
-
},
|
|
130
|
-
}),
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
export const FilePathProp = (id, data = {}) => {
|
|
134
|
-
return Property.Create({
|
|
135
|
-
id,
|
|
136
|
-
name: data.name,
|
|
137
|
-
value: data.value ? data.value : "#ffffff",
|
|
138
|
-
initialize: data.initialize,
|
|
139
|
-
input: FilePathPropertyInput.Create({
|
|
140
|
-
validator: data.validator,
|
|
141
|
-
properties: {
|
|
142
|
-
acceptedFileExtensions: data.acceptedFileExtensions
|
|
143
|
-
? data.acceptedFileExtensions
|
|
144
|
-
: [],
|
|
145
|
-
},
|
|
146
|
-
}),
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
export const Vec2Prop = (id, data = {}) => {
|
|
150
|
-
return Property.Create({
|
|
151
|
-
id,
|
|
152
|
-
name: data.name,
|
|
153
|
-
value: data.value ? data.value : { x: 0, y: 0 },
|
|
154
|
-
initialize: data.initialize,
|
|
155
|
-
input: Vec2PropertyInput.Create({
|
|
156
|
-
validator: data.validator,
|
|
157
|
-
properties: {
|
|
158
|
-
valueType: data.valueType ? data.valueType : "position",
|
|
159
|
-
},
|
|
160
|
-
}),
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
export const Vec3Prop = (id, data = {}) => {
|
|
164
|
-
return Property.Create({
|
|
165
|
-
id,
|
|
166
|
-
name: data.name,
|
|
167
|
-
value: data.value ? data.value : { x: 0, y: 0, z: 0 },
|
|
168
|
-
initialize: data.initialize,
|
|
169
|
-
input: Vec3PropertyInput.Create({
|
|
170
|
-
validator: data.validator,
|
|
171
|
-
properties: {
|
|
172
|
-
valueType: data.valueType ? data.valueType : "position",
|
|
173
|
-
},
|
|
174
|
-
}),
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
export const CheckboxProp = (id, data = {}) => {
|
|
178
|
-
return Property.Create({
|
|
179
|
-
id,
|
|
180
|
-
name: data.name,
|
|
181
|
-
value: data.value ? data.value : false,
|
|
182
|
-
initialize: data.initialize,
|
|
183
|
-
input: CheckboxPropertyInput.Create({
|
|
184
|
-
validator: data.validator,
|
|
185
|
-
properties: {},
|
|
186
|
-
}),
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
export const DateProp = (id, data = {}) => {
|
|
190
|
-
return Property.Create({
|
|
191
|
-
id,
|
|
192
|
-
name: data.name,
|
|
193
|
-
value: data.value ? data.value : "",
|
|
194
|
-
initialize: data.initialize,
|
|
195
|
-
input: DatePropertyInput.Create({
|
|
196
|
-
validator: data.validator,
|
|
197
|
-
properties: {},
|
|
198
|
-
}),
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
export const TextareaProp = (id, data = {}) => {
|
|
202
|
-
return Property.Create({
|
|
203
|
-
id,
|
|
204
|
-
name: data.name,
|
|
205
|
-
value: data.value ? data.value : "",
|
|
206
|
-
initialize: data.initialize,
|
|
207
|
-
input: TextareaPropertyInput.Create({
|
|
208
|
-
validator: data.validator,
|
|
209
|
-
properties: {
|
|
210
|
-
rows: data.rows ? data.rows : 4,
|
|
211
|
-
cols: data.cols ? data.cols : 10,
|
|
212
|
-
},
|
|
213
|
-
}),
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
export const EmailProp = (id, data = {}) => {
|
|
217
|
-
return Property.Create({
|
|
218
|
-
id,
|
|
219
|
-
name: data.name,
|
|
220
|
-
value: data.value ? data.value : "",
|
|
221
|
-
initialize: data.initialize,
|
|
222
|
-
input: EmailPropertyInput.Create({
|
|
223
|
-
validator: data.validator,
|
|
224
|
-
properties: {},
|
|
225
|
-
}),
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
export const UrlProp = (id, data = {}) => {
|
|
229
|
-
return Property.Create({
|
|
230
|
-
id,
|
|
231
|
-
name: data.name,
|
|
232
|
-
value: data.value ? data.value : "",
|
|
233
|
-
initialize: data.initialize,
|
|
234
|
-
input: UrlPropertyInput.Create({
|
|
235
|
-
validator: data.validator,
|
|
236
|
-
properties: {},
|
|
237
|
-
}),
|
|
238
|
-
});
|
|
239
|
-
};
|
|
30
|
+
export const StringProp = StringPropertyInput.createPropertyFC("");
|
|
31
|
+
export const FloatProp = FloatPropertyInput.createPropertyFC(0);
|
|
32
|
+
export const IntProp = IntPropertyInput.createPropertyFC(0);
|
|
33
|
+
export const RangeProp = RangePropertyInput.createPropertyFC(0);
|
|
34
|
+
export const HexColorProp = HexColorPropertyInput.createPropertyFC("#ffffff");
|
|
35
|
+
export const Color3Prop = Color3PropertyInput.createPropertyFC({
|
|
36
|
+
r: 255,
|
|
37
|
+
g: 255,
|
|
38
|
+
b: 255,
|
|
39
|
+
});
|
|
40
|
+
export const Color4Prop = Color4PropertyInput.createPropertyFC({
|
|
41
|
+
r: 255,
|
|
42
|
+
g: 255,
|
|
43
|
+
b: 255,
|
|
44
|
+
a: 255,
|
|
45
|
+
});
|
|
46
|
+
export const SelectProp = SelectPropertyInput.createPropertyFC("");
|
|
47
|
+
export const Vec2Prop = Vec2PropertyInput.createPropertyFC({ x: 0, y: 0 });
|
|
48
|
+
export const Vec3Prop = Vec3PropertyInput.createPropertyFC({
|
|
49
|
+
x: 0,
|
|
50
|
+
y: 0,
|
|
51
|
+
z: 0,
|
|
52
|
+
});
|
|
53
|
+
export const BooleanProp = BooleanPropertyInput.createPropertyFC(false);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SchemaNode } from "./Schemas/SchemaNode";
|
|
2
|
+
import { PropertyInputBase, PropertyInputData } from "./Inputs/PropertyInput";
|
|
3
|
+
import { Property } from "./Properties/Property";
|
|
4
|
+
export type PropertyCreateData<Value extends any, Input extends PropertyInputData> = {
|
|
5
|
+
name?: string;
|
|
6
|
+
value?: Value;
|
|
7
|
+
initialize?: (node: SchemaNode) => void;
|
|
8
|
+
} & Partial<Input["properties"]>;
|
|
9
|
+
export type PropertyFC<Value extends any, Input extends PropertyInputBase> = (id: string, data?: Exclude<PropertyCreateData<Value, Input["data"]>, "id">) => Property<Value, Input["data"]>;
|
|
10
|
+
export type PropertyRenderFCDefaultProps<Value extends any, Input extends PropertyInputBase> = {
|
|
11
|
+
node: SchemaNode<Value, Input>;
|
|
12
|
+
};
|
|
13
|
+
export type PropertyRenderFC<RenderedType extends any, Value extends any, Input extends PropertyInputBase, Props extends any = {}> = (props: Props & PropertyRenderFCDefaultProps<Value, Input>) => RenderedType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/Schema/Node.d.ts
ADDED
|
File without changes
|
package/Schema/Node.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
package/Schema/Object.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/Schema/Schema.js
ADDED
package/Schemas/SchemaNode.d.ts
CHANGED
|
@@ -13,25 +13,30 @@ export declare class TemplateNode {
|
|
|
13
13
|
declare class SchemaNodeObservers<Value = any, Input extends PropertyInputBase<any, any> = any> {
|
|
14
14
|
stateUpdated: Observable<SchemaNode<Value, Input>>;
|
|
15
15
|
updated: Observable<SchemaNode<Value, Input>>;
|
|
16
|
+
set: Observable<SchemaNode<Value, Input>>;
|
|
16
17
|
loadedIn: Observable<SchemaNode<Value, Input>>;
|
|
17
18
|
updatedOrLoadedIn: Observable<SchemaNode<Value, Input>>;
|
|
18
19
|
evaluate: Observable<void>;
|
|
19
20
|
validate: Observable<void>;
|
|
20
21
|
}
|
|
22
|
+
type UpdatedPipelineData<Value = any, Input extends PropertyInputBase<any, any> = any> = {
|
|
23
|
+
newValue: any;
|
|
24
|
+
node: SchemaNode<Value, Input>;
|
|
25
|
+
};
|
|
26
|
+
type LoadInPipelineData<Value = any, Input extends PropertyInputBase<any, any> = any> = {
|
|
27
|
+
value: any;
|
|
28
|
+
node: SchemaNode<Value, Input>;
|
|
29
|
+
};
|
|
21
30
|
declare class SchemaNodePipelines<Value = any, Input extends PropertyInputBase<any, any> = any> {
|
|
22
31
|
onStore: Pipeline<Property<Value, Input["data"]>>;
|
|
23
|
-
updated: Pipeline<
|
|
24
|
-
|
|
25
|
-
node: SchemaNode<Value, Input>;
|
|
26
|
-
}>;
|
|
27
|
-
loadedIn: Pipeline<{
|
|
28
|
-
value: any;
|
|
29
|
-
node: SchemaNode<Value, Input>;
|
|
30
|
-
}>;
|
|
32
|
+
updated: Pipeline<UpdatedPipelineData<any, any>>;
|
|
33
|
+
loadedIn: Pipeline<LoadInPipelineData<any, any>>;
|
|
31
34
|
}
|
|
32
35
|
export declare class SchemaNode<Value = any, Input extends PropertyInputBase<any, any> = any> {
|
|
33
36
|
property: Property<Value, Input["data"]>;
|
|
34
37
|
root: any;
|
|
38
|
+
private _updateData;
|
|
39
|
+
private _loadInData;
|
|
35
40
|
children: SchemaNode[] | null;
|
|
36
41
|
conditions: PropertyConditionAction[];
|
|
37
42
|
input: Input | null;
|
package/Schemas/SchemaNode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Property } from "../Properties/Property";
|
|
2
|
+
import { PropertyInputBase } from "../Inputs/PropertyInput";
|
|
2
3
|
import { PropertyInputRegister } from "../Inputs/PropertyInputRegister";
|
|
3
4
|
import { Observable } from "@amodx/core/Observers/index";
|
|
4
5
|
import { Pipeline } from "@amodx/core/Pipelines";
|
|
@@ -13,6 +14,7 @@ export class TemplateNode {
|
|
|
13
14
|
class SchemaNodeObservers {
|
|
14
15
|
stateUpdated = new Observable();
|
|
15
16
|
updated = new Observable();
|
|
17
|
+
set = new Observable();
|
|
16
18
|
loadedIn = new Observable();
|
|
17
19
|
updatedOrLoadedIn = new Observable();
|
|
18
20
|
evaluate = new Observable();
|
|
@@ -34,6 +36,8 @@ class SchemaNodeProxy {
|
|
|
34
36
|
export class SchemaNode {
|
|
35
37
|
property;
|
|
36
38
|
root;
|
|
39
|
+
_updateData;
|
|
40
|
+
_loadInData;
|
|
37
41
|
children = null;
|
|
38
42
|
conditions = [];
|
|
39
43
|
input;
|
|
@@ -43,9 +47,17 @@ export class SchemaNode {
|
|
|
43
47
|
constructor(property, root) {
|
|
44
48
|
this.property = property;
|
|
45
49
|
this.root = root;
|
|
50
|
+
this._updateData = {
|
|
51
|
+
node: this,
|
|
52
|
+
newValue: this.getValue(),
|
|
53
|
+
};
|
|
54
|
+
this._loadInData = {
|
|
55
|
+
node: this,
|
|
56
|
+
value: this.getValue(),
|
|
57
|
+
};
|
|
46
58
|
if (property.input) {
|
|
47
|
-
const
|
|
48
|
-
this.input = new
|
|
59
|
+
const abstractInput = PropertyInputRegister.getProperty(property.input.type);
|
|
60
|
+
this.input = new PropertyInputBase(abstractInput, property.input, this);
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
63
|
proxy = null;
|
|
@@ -81,8 +93,8 @@ export class SchemaNode {
|
|
|
81
93
|
this.conditions.push(action);
|
|
82
94
|
}
|
|
83
95
|
}
|
|
84
|
-
if (property.input?.validator) {
|
|
85
|
-
const validator = ObjectPropertyValidatorRegister.getValidator(property.input.validator);
|
|
96
|
+
if (property.input?.properties.validator) {
|
|
97
|
+
const validator = ObjectPropertyValidatorRegister.getValidator(property.input.properties.validator);
|
|
86
98
|
this.observers.updatedOrLoadedIn.subscribe(this, () => {
|
|
87
99
|
const response = validator.validate(this.get(), this);
|
|
88
100
|
this.validatorResponse = response;
|
|
@@ -128,10 +140,8 @@ export class SchemaNode {
|
|
|
128
140
|
return this.pipelines.onStore.pipe(Property.Create(this.property)).value;
|
|
129
141
|
}
|
|
130
142
|
loadIn(value) {
|
|
131
|
-
this.
|
|
132
|
-
|
|
133
|
-
value,
|
|
134
|
-
}).value);
|
|
143
|
+
this._loadInData.value = value;
|
|
144
|
+
this.setValue(this.pipelines.loadedIn.pipe(this._loadInData).value);
|
|
135
145
|
this.observers.loadedIn.notify(this);
|
|
136
146
|
this.observers.updatedOrLoadedIn.notify(this);
|
|
137
147
|
}
|
|
@@ -140,19 +150,18 @@ export class SchemaNode {
|
|
|
140
150
|
}
|
|
141
151
|
update(newValue) {
|
|
142
152
|
const oldValue = this.getValue();
|
|
143
|
-
this.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const newFinalValue = this.getValue();
|
|
153
|
+
this._updateData.newValue = newValue;
|
|
154
|
+
const finalNewValue = this.pipelines.updated.pipe(this._updateData).newValue;
|
|
155
|
+
this.setValue(finalNewValue);
|
|
156
|
+
this.observers.set.notify(this);
|
|
148
157
|
if (this.input) {
|
|
149
|
-
if (!this.input.compare(oldValue,
|
|
158
|
+
if (!this.input.compare(oldValue, finalNewValue)) {
|
|
150
159
|
this.observers.updated.notify(this);
|
|
151
160
|
this.observers.updatedOrLoadedIn.notify(this);
|
|
152
161
|
}
|
|
153
162
|
return;
|
|
154
163
|
}
|
|
155
|
-
if (oldValue !=
|
|
164
|
+
if (oldValue != finalNewValue) {
|
|
156
165
|
this.observers.updated.notify(this);
|
|
157
166
|
this.observers.updatedOrLoadedIn.notify(this);
|
|
158
167
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED