slightning-coco-widget
Version:
SLIGHTNING 的 CoCo 控件框架。
104 lines (103 loc) • 2.75 kB
JavaScript
import { betterToString, XMLEscape } from "../../utils";
import { TypeValidateError } from "./type-validate-error";
import { typeToString } from "./utils";
export class InstanceOfClassType {
constructor(props) {
var _a;
if (typeof props == "function") {
props = { theClass: props };
}
this.theClass = props.theClass;
this.defaultValue = (_a = props.defaultValue) !== null && _a !== void 0 ? _a : `实例<${props.theClass.name}>`;
}
validate(value) {
if (!(value instanceof this.theClass)) {
throw new TypeValidateError(`不能将 ${betterToString(value)} 分配给 ${typeToString(this)}`, value, this);
}
return true;
}
getSameDirectionChildren() {
return [];
}
getReverseDirectionChildren() {
return [];
}
isVoid() {
return false;
}
typeToString() {
return `实例<${this.theClass.name}>`;
}
inlineTypeToString() {
return this.typeToString();
}
toCoCoPropertyValueTypes() {
return {
valueType: ["string", "object"],
checkType: "string",
defaultValue: XMLEscape(this.defaultValue)
};
}
toCoCoMethodParamValueTypes() {
return {
valueType: ["string", "object"],
checkType: "string",
defaultValue: XMLEscape(this.defaultValue)
};
}
toCoCoMethodValueTypes() {
return {
valueType: "object"
};
}
toCoCoEventParamValueTypes() {
return {
valueType: "object"
};
}
toCreationProject1PropValueTypes() {
return {
valueType: "object",
defaultValue: this.defaultValue
};
}
toCreationProject1MethodParamValueTypes() {
return {
valueType: "object",
defaultValue: this.defaultValue
};
}
toCreationProject1MethodValueTypes() {
return {
valueType: "object"
};
}
toCreationProject1EmitParamValueTypes() {
return {
valueType: "object"
};
}
toCreationProject2PropValueTypes() {
return {
valueType: "object",
defaultValue: this.defaultValue
};
}
toCreationProject2MethodParamValueTypes() {
return {
valueType: "object",
defaultValue: this.defaultValue
};
}
toCreationProject2MethodValueTypes() {
return {
valueType: "object"
};
}
toCreationProject2EmitParamValueTypes() {
return {
valueType: "object"
};
}
}
export { InstanceOfClassType as InstanceType };