@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
package/Inputs/DefaultInputs.js
CHANGED
|
@@ -1,376 +1,149 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
id: "string",
|
|
6
|
-
name: "string",
|
|
7
|
-
};
|
|
8
|
-
static Create(data) {
|
|
9
|
-
return {
|
|
10
|
-
...PropertyInputBase.CreateBase({}),
|
|
11
|
-
type: StringInput.Meta.id,
|
|
12
|
-
properties: {
|
|
13
|
-
min: 0,
|
|
14
|
-
max: Number.MAX_SAFE_INTEGER,
|
|
15
|
-
},
|
|
16
|
-
...data,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
compare(value1, value2) {
|
|
20
|
-
return value1 == value2;
|
|
21
|
-
}
|
|
22
|
-
getClass() {
|
|
23
|
-
return StringInput;
|
|
24
|
-
}
|
|
25
|
-
getMeta() {
|
|
26
|
-
return StringInput.Meta;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
class ColorInput extends PropertyInputBase {
|
|
30
|
-
static Meta = {
|
|
31
|
-
id: "color",
|
|
32
|
-
name: "Color",
|
|
33
|
-
};
|
|
34
|
-
static Create(data) {
|
|
35
|
-
return {
|
|
36
|
-
...PropertyInputBase.CreateBase({}),
|
|
37
|
-
type: ColorInput.Meta.id,
|
|
38
|
-
properties: {},
|
|
39
|
-
...data,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
compare(value1, value2) {
|
|
43
|
-
return value1 == value2;
|
|
44
|
-
}
|
|
45
|
-
getClass() {
|
|
46
|
-
return ColorInput;
|
|
47
|
-
}
|
|
48
|
-
getMeta() {
|
|
49
|
-
return ColorInput.Meta;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
class RangeInput extends PropertyInputBase {
|
|
53
|
-
static Meta = {
|
|
54
|
-
id: "range",
|
|
55
|
-
name: "Range",
|
|
56
|
-
};
|
|
57
|
-
static Create(data) {
|
|
58
|
-
return {
|
|
59
|
-
...PropertyInputBase.CreateBase({}),
|
|
60
|
-
type: RangeInput.Meta.id,
|
|
61
|
-
properties: {
|
|
62
|
-
min: 0,
|
|
63
|
-
max: Number.MAX_SAFE_INTEGER,
|
|
64
|
-
step: 1,
|
|
65
|
-
},
|
|
66
|
-
...data,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
compare(value1, value2) {
|
|
70
|
-
return value1 == value2;
|
|
71
|
-
}
|
|
72
|
-
getClass() {
|
|
73
|
-
return RangeInput;
|
|
74
|
-
}
|
|
75
|
-
getMeta() {
|
|
76
|
-
return RangeInput.Meta;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
class FloatInput extends PropertyInputBase {
|
|
80
|
-
static Meta = {
|
|
81
|
-
id: "float",
|
|
82
|
-
name: "Float",
|
|
83
|
-
};
|
|
84
|
-
static Create(data) {
|
|
85
|
-
return {
|
|
86
|
-
...PropertyInputBase.CreateBase({}),
|
|
87
|
-
type: FloatInput.Meta.id,
|
|
88
|
-
properties: {
|
|
89
|
-
min: 0,
|
|
90
|
-
max: Number.MAX_SAFE_INTEGER,
|
|
91
|
-
},
|
|
92
|
-
...data,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
1
|
+
import { registerInput } from "./registerInput";
|
|
2
|
+
const StringInput = registerInput({
|
|
3
|
+
id: "string",
|
|
4
|
+
name: "String",
|
|
95
5
|
compare(value1, value2) {
|
|
96
6
|
return value1 == value2;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return FloatInput;
|
|
100
|
-
}
|
|
101
|
-
getMeta() {
|
|
102
|
-
return FloatInput.Meta;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
class Vec2Input extends PropertyInputBase {
|
|
106
|
-
static Meta = {
|
|
107
|
-
id: "vec2",
|
|
108
|
-
name: "Vec2",
|
|
109
|
-
};
|
|
110
|
-
static Create(data) {
|
|
7
|
+
},
|
|
8
|
+
createProperties(properties) {
|
|
111
9
|
return {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
properties
|
|
115
|
-
valueType: "position",
|
|
116
|
-
},
|
|
117
|
-
...data,
|
|
10
|
+
min: 0,
|
|
11
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
12
|
+
...properties,
|
|
118
13
|
};
|
|
119
|
-
}
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
const HEXColorInput = registerInput({
|
|
17
|
+
id: "hex-color",
|
|
18
|
+
name: "Hex Color",
|
|
120
19
|
compare(value1, value2) {
|
|
121
|
-
return value1
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return Vec2Input;
|
|
125
|
-
}
|
|
126
|
-
getMeta() {
|
|
127
|
-
return Vec2Input.Meta;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
class Vec3Input extends PropertyInputBase {
|
|
131
|
-
static Meta = {
|
|
132
|
-
id: "vec3",
|
|
133
|
-
name: "Vec3",
|
|
134
|
-
};
|
|
135
|
-
static Create(data) {
|
|
20
|
+
return value1 === value2;
|
|
21
|
+
},
|
|
22
|
+
createProperties(properties) {
|
|
136
23
|
return {
|
|
137
|
-
...
|
|
138
|
-
type: Vec3Input.Meta.id,
|
|
139
|
-
properties: {
|
|
140
|
-
valueType: "position",
|
|
141
|
-
},
|
|
142
|
-
...data,
|
|
24
|
+
...properties,
|
|
143
25
|
};
|
|
144
|
-
}
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const Color3Input = registerInput({
|
|
29
|
+
id: "color3",
|
|
30
|
+
name: "Color3",
|
|
145
31
|
compare(value1, value2) {
|
|
146
|
-
return value1.
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return Vec3Input;
|
|
150
|
-
}
|
|
151
|
-
getMeta() {
|
|
152
|
-
return Vec3Input.Meta;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
class IntInput extends PropertyInputBase {
|
|
156
|
-
static Meta = {
|
|
157
|
-
id: "int",
|
|
158
|
-
name: "Int",
|
|
159
|
-
};
|
|
160
|
-
static Create(data) {
|
|
32
|
+
return (value1.r === value2.r && value1.g === value2.g && value1.b == value2.b);
|
|
33
|
+
},
|
|
34
|
+
createProperties(properties) {
|
|
161
35
|
return {
|
|
162
|
-
...
|
|
163
|
-
type: IntInput.Meta.id,
|
|
164
|
-
properties: {
|
|
165
|
-
min: 0,
|
|
166
|
-
max: Number.MAX_SAFE_INTEGER,
|
|
167
|
-
},
|
|
168
|
-
...data,
|
|
36
|
+
...properties,
|
|
169
37
|
};
|
|
170
|
-
}
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const Color4Input = registerInput({
|
|
41
|
+
id: "color4",
|
|
42
|
+
name: "Color4",
|
|
171
43
|
compare(value1, value2) {
|
|
172
|
-
return value1
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return IntInput.Meta;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
class SelectInput extends PropertyInputBase {
|
|
182
|
-
static Meta = {
|
|
183
|
-
id: "select",
|
|
184
|
-
name: "Select",
|
|
185
|
-
};
|
|
186
|
-
static Create(data) {
|
|
44
|
+
return (value1.r === value2.r &&
|
|
45
|
+
value1.g === value2.g &&
|
|
46
|
+
value1.b == value2.b &&
|
|
47
|
+
value1.a == value2.a);
|
|
48
|
+
},
|
|
49
|
+
createProperties(properties) {
|
|
187
50
|
return {
|
|
188
|
-
...
|
|
189
|
-
type: SelectInput.Meta.id,
|
|
190
|
-
properties: {
|
|
191
|
-
options: [],
|
|
192
|
-
},
|
|
193
|
-
...data,
|
|
51
|
+
...properties,
|
|
194
52
|
};
|
|
195
|
-
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const RangeInput = registerInput({
|
|
56
|
+
id: "range",
|
|
57
|
+
name: "Range",
|
|
196
58
|
compare(value1, value2) {
|
|
197
|
-
return value1
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return SelectInput;
|
|
201
|
-
}
|
|
202
|
-
getMeta() {
|
|
203
|
-
return SelectInput.Meta;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
class FilePathInput extends PropertyInputBase {
|
|
207
|
-
static Meta = {
|
|
208
|
-
id: "file-path",
|
|
209
|
-
name: "File Path",
|
|
210
|
-
};
|
|
211
|
-
static Create(data) {
|
|
59
|
+
return value1 === value2;
|
|
60
|
+
},
|
|
61
|
+
createProperties(properties) {
|
|
212
62
|
return {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
},
|
|
218
|
-
...data,
|
|
63
|
+
min: 0,
|
|
64
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
65
|
+
step: 1,
|
|
66
|
+
...properties,
|
|
219
67
|
};
|
|
220
|
-
}
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
const FloatInput = registerInput({
|
|
71
|
+
id: "float",
|
|
72
|
+
name: "Float",
|
|
221
73
|
compare(value1, value2) {
|
|
222
|
-
return value1
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return FilePathInput;
|
|
226
|
-
}
|
|
227
|
-
getMeta() {
|
|
228
|
-
return FilePathInput.Meta;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
class PasswordInput extends PropertyInputBase {
|
|
232
|
-
static Meta = {
|
|
233
|
-
id: "password",
|
|
234
|
-
name: "Password",
|
|
235
|
-
};
|
|
236
|
-
static Create(data) {
|
|
74
|
+
return value1 === value2;
|
|
75
|
+
},
|
|
76
|
+
createProperties(properties) {
|
|
237
77
|
return {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
properties
|
|
241
|
-
min: 0,
|
|
242
|
-
max: Number.MAX_SAFE_INTEGER,
|
|
243
|
-
},
|
|
244
|
-
...data,
|
|
78
|
+
min: 0,
|
|
79
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
80
|
+
...properties,
|
|
245
81
|
};
|
|
246
|
-
}
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
const Vec2Input = registerInput({
|
|
85
|
+
id: "vec2",
|
|
86
|
+
name: "Vec2",
|
|
247
87
|
compare(value1, value2) {
|
|
248
|
-
return value1
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return PasswordInput;
|
|
252
|
-
}
|
|
253
|
-
getMeta() {
|
|
254
|
-
return PasswordInput.Meta;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
class CheckboxInput extends PropertyInputBase {
|
|
258
|
-
static Meta = {
|
|
259
|
-
id: "checkbox",
|
|
260
|
-
name: "Checkbox",
|
|
261
|
-
};
|
|
262
|
-
static Create(data) {
|
|
88
|
+
return value1.x === value2.x && value1.y === value2.y;
|
|
89
|
+
},
|
|
90
|
+
createProperties(properties) {
|
|
263
91
|
return {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
properties: {},
|
|
267
|
-
...data,
|
|
92
|
+
valueType: "position",
|
|
93
|
+
...properties,
|
|
268
94
|
};
|
|
269
|
-
}
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const Vec3Input = registerInput({
|
|
98
|
+
id: "vec3",
|
|
99
|
+
name: "Vec3",
|
|
270
100
|
compare(value1, value2) {
|
|
271
|
-
return value1
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return CheckboxInput;
|
|
275
|
-
}
|
|
276
|
-
getMeta() {
|
|
277
|
-
return CheckboxInput.Meta;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
class DateInput extends PropertyInputBase {
|
|
281
|
-
static Meta = {
|
|
282
|
-
id: "date",
|
|
283
|
-
name: "Date",
|
|
284
|
-
};
|
|
285
|
-
static Create(data) {
|
|
101
|
+
return (value1.x === value2.x && value1.y === value2.y && value1.z === value2.z);
|
|
102
|
+
},
|
|
103
|
+
createProperties(properties) {
|
|
286
104
|
return {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
properties: {},
|
|
290
|
-
...data,
|
|
105
|
+
valueType: "position",
|
|
106
|
+
...properties,
|
|
291
107
|
};
|
|
292
|
-
}
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
const IntInput = registerInput({
|
|
111
|
+
id: "int",
|
|
112
|
+
name: "Int",
|
|
293
113
|
compare(value1, value2) {
|
|
294
|
-
return value1
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return DateInput;
|
|
298
|
-
}
|
|
299
|
-
getMeta() {
|
|
300
|
-
return DateInput.Meta;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
class TextareaInput extends PropertyInputBase {
|
|
304
|
-
static Meta = {
|
|
305
|
-
id: "textarea",
|
|
306
|
-
name: "Textarea",
|
|
307
|
-
};
|
|
308
|
-
static Create(data) {
|
|
114
|
+
return value1 === value2;
|
|
115
|
+
},
|
|
116
|
+
createProperties(properties) {
|
|
309
117
|
return {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
properties
|
|
313
|
-
rows: 4,
|
|
314
|
-
cols: 50,
|
|
315
|
-
},
|
|
316
|
-
...data,
|
|
118
|
+
min: 0,
|
|
119
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
120
|
+
...properties,
|
|
317
121
|
};
|
|
318
|
-
}
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
const SelectInput = registerInput({
|
|
125
|
+
id: "select",
|
|
126
|
+
name: "Select",
|
|
319
127
|
compare(value1, value2) {
|
|
320
|
-
return value1
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
return TextareaInput;
|
|
324
|
-
}
|
|
325
|
-
getMeta() {
|
|
326
|
-
return TextareaInput.Meta;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
class EmailInput extends PropertyInputBase {
|
|
330
|
-
static Meta = {
|
|
331
|
-
id: "email",
|
|
332
|
-
name: "Email",
|
|
333
|
-
};
|
|
334
|
-
static Create(data) {
|
|
128
|
+
return value1 === value2;
|
|
129
|
+
},
|
|
130
|
+
createProperties(properties) {
|
|
335
131
|
return {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
properties: {},
|
|
339
|
-
...data,
|
|
132
|
+
options: [],
|
|
133
|
+
...properties,
|
|
340
134
|
};
|
|
341
|
-
}
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const BooleanInput = registerInput({
|
|
138
|
+
id: "boolean",
|
|
139
|
+
name: "Boolean",
|
|
342
140
|
compare(value1, value2) {
|
|
343
|
-
return value1
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return EmailInput;
|
|
347
|
-
}
|
|
348
|
-
getMeta() {
|
|
349
|
-
return EmailInput.Meta;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
class UrlInput extends PropertyInputBase {
|
|
353
|
-
static Meta = {
|
|
354
|
-
id: "url",
|
|
355
|
-
name: "URL",
|
|
356
|
-
};
|
|
357
|
-
static Create(data) {
|
|
141
|
+
return value1 === value2;
|
|
142
|
+
},
|
|
143
|
+
createProperties(properties) {
|
|
358
144
|
return {
|
|
359
|
-
...
|
|
360
|
-
type: UrlInput.Meta.id,
|
|
361
|
-
properties: {},
|
|
362
|
-
...data,
|
|
145
|
+
...properties,
|
|
363
146
|
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
getClass() {
|
|
369
|
-
return UrlInput;
|
|
370
|
-
}
|
|
371
|
-
getMeta() {
|
|
372
|
-
return UrlInput.Meta;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
PropertyInputRegister.regsiterProperty(ColorInput, RangeInput, FloatInput, Vec2Input, Vec3Input, IntInput, StringInput, SelectInput, FilePathInput, PasswordInput, CheckboxInput, DateInput, TextareaInput, EmailInput, UrlInput);
|
|
376
|
-
export { ColorInput as ColorPropertyInput, RangeInput as RangePropertyInput, FloatInput as FloatPropertyInput, Vec2Input as Vec2PropertyInput, Vec3Input as Vec3PropertyInput, IntInput as IntPropertyInput, StringInput as StringPropertyInput, SelectInput as SelectPropertyInput, FilePathInput as FilePathPropertyInput, PasswordInput as PasswordPropertyInput, CheckboxInput as CheckboxPropertyInput, DateInput as DatePropertyInput, TextareaInput as TextareaPropertyInput, EmailInput as EmailPropertyInput, UrlInput as UrlPropertyInput, };
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
export { HEXColorInput as HexColorPropertyInput, Color3Input as Color3PropertyInput, Color4Input as Color4PropertyInput, RangeInput as RangePropertyInput, FloatInput as FloatPropertyInput, Vec2Input as Vec2PropertyInput, Vec3Input as Vec3PropertyInput, IntInput as IntPropertyInput, StringInput as StringPropertyInput, SelectInput as SelectPropertyInput, BooleanInput as BooleanPropertyInput, };
|
|
@@ -1,46 +1,44 @@
|
|
|
1
1
|
import { Pipeline } from "@amodx/core/Pipelines";
|
|
2
2
|
import { SchemaNode } from "../Schemas/SchemaNode";
|
|
3
|
+
type GetPipelineData<Value = any> = {
|
|
4
|
+
value: Value;
|
|
5
|
+
input: PropertyInputBase;
|
|
6
|
+
};
|
|
7
|
+
type SetPipelineData<Value = any> = {
|
|
8
|
+
newValue: Value;
|
|
9
|
+
input: PropertyInputBase;
|
|
10
|
+
};
|
|
3
11
|
declare class PropertyInputPipelines<Value = any> {
|
|
4
|
-
onGet: Pipeline<
|
|
5
|
-
|
|
6
|
-
input: PropertyInputBase;
|
|
7
|
-
}>;
|
|
8
|
-
onSet: Pipeline<{
|
|
9
|
-
newValue: any;
|
|
10
|
-
input: PropertyInputBase;
|
|
11
|
-
}>;
|
|
12
|
+
onGet: Pipeline<GetPipelineData<Value>>;
|
|
13
|
+
onSet: Pipeline<SetPipelineData<Value>>;
|
|
12
14
|
}
|
|
13
|
-
export interface
|
|
14
|
-
type: string;
|
|
15
|
-
properties: Properties;
|
|
15
|
+
export interface PropertyInputBaseProperties {
|
|
16
16
|
disabled?: boolean;
|
|
17
|
-
mode?: string;
|
|
18
17
|
required?: boolean;
|
|
19
18
|
validator?: string;
|
|
19
|
+
variation?: string;
|
|
20
20
|
}
|
|
21
|
-
export interface
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}
|
|
26
|
-
export interface PropertyInputConstructor<Value = any, Properties extends object = any> {
|
|
27
|
-
Meta: PropertyInputMetaData;
|
|
28
|
-
Create(overrides: Partial<PropertyInputData<Value, Properties>>): PropertyInputData<Value, Properties>;
|
|
29
|
-
new (data: PropertyInputData<Value, Properties>, node: SchemaNode): PropertyInputBase<Value, Properties>;
|
|
21
|
+
export interface PropertyInputData<Value = any, Properties extends PropertyInputBaseProperties = PropertyInputBaseProperties> {
|
|
22
|
+
type: string;
|
|
23
|
+
properties: Properties;
|
|
30
24
|
}
|
|
31
|
-
export interface
|
|
32
|
-
|
|
25
|
+
export interface AbstractPropertyInput<Value extends any = any, Properties extends PropertyInputBaseProperties = PropertyInputBaseProperties> {
|
|
26
|
+
id: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
init?(input: PropertyInputBase<Value, Properties>): void;
|
|
29
|
+
createProperties(properties: Partial<Properties>): Properties;
|
|
30
|
+
compare(value1: Value, value2: Value): boolean;
|
|
33
31
|
}
|
|
34
|
-
export declare
|
|
32
|
+
export declare class PropertyInputBase<Value = any, Properties extends PropertyInputBaseProperties = PropertyInputBaseProperties> {
|
|
33
|
+
abstractInput: AbstractPropertyInput<Value>;
|
|
35
34
|
data: PropertyInputData<Value, Properties>;
|
|
36
35
|
node: SchemaNode;
|
|
37
|
-
|
|
36
|
+
private _getData;
|
|
37
|
+
private _setData;
|
|
38
38
|
pipelines: PropertyInputPipelines<any>;
|
|
39
|
-
constructor(data: PropertyInputData<Value, Properties>, node: SchemaNode);
|
|
40
|
-
|
|
39
|
+
constructor(abstractInput: AbstractPropertyInput<Value>, data: PropertyInputData<Value, Properties>, node: SchemaNode);
|
|
40
|
+
compare(value1: Value, value2: Value): boolean;
|
|
41
41
|
get(): any;
|
|
42
42
|
set(newValue: Value): void;
|
|
43
|
-
abstract getClass(): PropertyInputConstructor<Value, Properties>;
|
|
44
|
-
abstract getMeta(): PropertyInputMetaData;
|
|
45
43
|
}
|
|
46
44
|
export {};
|
package/Inputs/PropertyInput.js
CHANGED
|
@@ -4,32 +4,36 @@ class PropertyInputPipelines {
|
|
|
4
4
|
onSet = new Pipeline();
|
|
5
5
|
}
|
|
6
6
|
export class PropertyInputBase {
|
|
7
|
+
abstractInput;
|
|
7
8
|
data;
|
|
8
9
|
node;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type: "",
|
|
12
|
-
properties: {},
|
|
13
|
-
...data,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
10
|
+
_getData;
|
|
11
|
+
_setData;
|
|
16
12
|
pipelines = new PropertyInputPipelines();
|
|
17
|
-
constructor(data, node) {
|
|
13
|
+
constructor(abstractInput, data, node) {
|
|
14
|
+
this.abstractInput = abstractInput;
|
|
18
15
|
this.data = data;
|
|
19
16
|
this.node = node;
|
|
20
|
-
|
|
21
|
-
this.init();
|
|
22
|
-
}
|
|
23
|
-
get() {
|
|
24
|
-
return this.pipelines.onGet.pipe({
|
|
17
|
+
this._getData = {
|
|
25
18
|
input: this,
|
|
26
19
|
value: this.node.get(),
|
|
27
|
-
}
|
|
20
|
+
};
|
|
21
|
+
this._setData = {
|
|
22
|
+
input: this,
|
|
23
|
+
newValue: this.node.get(),
|
|
24
|
+
};
|
|
25
|
+
if (abstractInput.init)
|
|
26
|
+
abstractInput.init(this);
|
|
27
|
+
}
|
|
28
|
+
compare(value1, value2) {
|
|
29
|
+
return this.abstractInput.compare(value1, value2);
|
|
30
|
+
}
|
|
31
|
+
get() {
|
|
32
|
+
this._getData.value = this.node.get();
|
|
33
|
+
return this.pipelines.onGet.pipe(this._getData).value;
|
|
28
34
|
}
|
|
29
35
|
set(newValue) {
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
newValue,
|
|
33
|
-
}).newValue);
|
|
36
|
+
this._setData.newValue = newValue;
|
|
37
|
+
this.node.update(this.pipelines.onSet.pipe(this._setData).newValue);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ArrayMap } from "@amodx/core/DataStructures/ArrayMap";
|
|
2
|
-
import {
|
|
2
|
+
import { AbstractPropertyInput } from "./PropertyInput";
|
|
3
3
|
export declare class PropertyInputRegister {
|
|
4
|
-
static properties: ArrayMap<string,
|
|
5
|
-
static regsiterProperty(
|
|
6
|
-
static getProperty(id: string):
|
|
4
|
+
static properties: ArrayMap<string, AbstractPropertyInput<any, any>>;
|
|
5
|
+
static regsiterProperty(data: AbstractPropertyInput): void;
|
|
6
|
+
static getProperty(id: string): AbstractPropertyInput<any, any>;
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ArrayMap } from "@amodx/core/DataStructures/ArrayMap";
|
|
2
2
|
export class PropertyInputRegister {
|
|
3
3
|
static properties = new ArrayMap();
|
|
4
|
-
static regsiterProperty(
|
|
5
|
-
this.properties.
|
|
4
|
+
static regsiterProperty(data) {
|
|
5
|
+
this.properties.set(data.id, data);
|
|
6
6
|
}
|
|
7
7
|
static getProperty(id) {
|
|
8
8
|
const property = this.properties.get(id);
|
package/Inputs/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PropertyFC, PropertyRenderFC } from "Property.types";
|
|
2
|
+
import { AbstractPropertyInput, PropertyInputBase, PropertyInputBaseProperties, PropertyInputData } from "./PropertyInput";
|
|
3
|
+
import { SchemaNode } from "../Schemas/SchemaNode";
|
|
4
|
+
export type RegisteredInput<Value extends any = any, Properties extends PropertyInputBaseProperties = PropertyInputBaseProperties> = ((initalProperties?: Partial<Properties>) => PropertyInputData<Value, Properties>) & {
|
|
5
|
+
id: string;
|
|
6
|
+
meta: {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
default: PropertyInputBase<Value, Properties>;
|
|
10
|
+
data: PropertyInputData<Value, Properties>;
|
|
11
|
+
properties: Properties;
|
|
12
|
+
value: Value;
|
|
13
|
+
createPropertyFC(defaultValue: Value): PropertyFC<Value, PropertyInputBase<Value, Properties>>;
|
|
14
|
+
createPropertyRenderFC<RenderedData extends any = any, Props extends any = any>(fc: (props: {
|
|
15
|
+
node: SchemaNode<Value, PropertyInputBase<Value, Properties>>;
|
|
16
|
+
} & Props) => RenderedData): PropertyRenderFC<RenderedData, Value, PropertyInputBase<Value, Properties>, Props>;
|
|
17
|
+
};
|
|
18
|
+
export declare function registerInput<Value extends any, InitalProperties extends object = {}>(data: AbstractPropertyInput<Value, InitalProperties>): RegisteredInput<Value, PropertyInputBaseProperties & InitalProperties>;
|