@amodx/schemas 0.0.1 → 0.0.2
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 +20 -184
- package/Inputs/DefaultInputs.js +94 -348
- 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 +37 -26
- package/Properties.js +14 -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
|
@@ -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>;
|
|
@@ -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,46 @@ 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 ColorProp: PropertyFC<string, import("./Inputs").PropertyInputBase<string, import("./Inputs").PropertyInputBaseProperties>>;
|
|
31
|
+
export declare const SelectProp: PropertyFC<string | number, import("./Inputs").PropertyInputBase<string | number, import("./Inputs").PropertyInputBaseProperties & {
|
|
32
|
+
options: string[] | [string, string | number][];
|
|
33
|
+
mode?: string;
|
|
34
|
+
}>>;
|
|
30
35
|
export declare const Vec2Prop: PropertyFC<{
|
|
31
36
|
x: number;
|
|
32
37
|
y: number;
|
|
33
|
-
},
|
|
38
|
+
}, import("./Inputs").PropertyInputBase<{
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}, import("./Inputs").PropertyInputBaseProperties & {
|
|
42
|
+
valueType: "position" | "dimension";
|
|
43
|
+
}>>;
|
|
34
44
|
export declare const Vec3Prop: PropertyFC<{
|
|
35
45
|
x: number;
|
|
36
46
|
y: number;
|
|
37
47
|
z: number;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
}, import("./Inputs").PropertyInputBase<{
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
z: number;
|
|
52
|
+
}, import("./Inputs").PropertyInputBaseProperties & {
|
|
53
|
+
valueType: "position" | "dimension";
|
|
54
|
+
}>>;
|
|
55
|
+
export declare const BooleanProp: PropertyFC<boolean, import("./Inputs").PropertyInputBase<boolean, import("./Inputs").PropertyInputBaseProperties>>;
|
package/Properties.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorPropertyInput,
|
|
1
|
+
import { ColorPropertyInput, 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,16 @@ 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
|
-
export const PasswordProp = (id, data = {}) => {
|
|
46
|
-
return Property.Create({
|
|
47
|
-
id,
|
|
48
|
-
name: data.name,
|
|
49
|
-
value: data.value ? data.value : "",
|
|
50
|
-
initialize: data.initialize,
|
|
51
|
-
input: PasswordPropertyInput.Create({
|
|
52
|
-
validator: data.validator,
|
|
53
|
-
properties: {
|
|
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 ColorProp = ColorPropertyInput.createPropertyFC("#ffffff");
|
|
35
|
+
export const SelectProp = SelectPropertyInput.createPropertyFC("");
|
|
36
|
+
export const Vec2Prop = Vec2PropertyInput.createPropertyFC({ x: 0, y: 0 });
|
|
37
|
+
export const Vec3Prop = Vec3PropertyInput.createPropertyFC({
|
|
38
|
+
x: 0,
|
|
39
|
+
y: 0,
|
|
40
|
+
z: 0,
|
|
41
|
+
});
|
|
42
|
+
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;
|