@react-form-builder/core
Version:
React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required
60 lines (59 loc) • 1.94 kB
JavaScript
import { ArrayBuilder as n } from "./ArrayBuilder.js";
import { BaseBuilder as o } from "./BaseBuilder.js";
import { OneOfBuilder as r } from "./OneOfBuilder.js";
import { SomeOfBuilder as i } from "./SomeOfBuilder.js";
import { TypedBuilder as s } from "./TypedBuilder.js";
class d extends o {
/**
* Creates a component property metadata builder.
* @param editor the property editor type.
* @template T the property type.
*/
constructor(t) {
super(), this.annotation = { editor: t };
}
/**
* Creates a component property metadata builder.
* @param editor the property editor type.
* @template T the property type.
* @returns the component property metadata builder.
*/
static create = (t) => new this(t);
/**
* Sets the property as a "array" property.
* @returns the instance of the metadata property builder.
*/
get array() {
return new n().setup({ ...this.options, ...this.annotation, type: "array" });
}
/**
* Sets the field type for the component property.
* @param type the field type.
* @returns the instance of the metadata property builder.
*/
typed(t) {
return new s().setup({ ...this.options, ...this.annotation, type: t });
}
/**
* Sets the property as a "single select" property.
* @param values the possible values for the property.
* @returns the instance of the metadata property builder.
*/
oneOf(...t) {
const e = new r().setup({ ...this.options, ...this.annotation, type: "enum" });
return e.values = t, e;
}
/**
* Sets the property as a "multiple select" property.
* @param values the possible values for the property.
* @returns the instance of the metadata property builder.
*/
someOf(...t) {
const e = new i().setup({ ...this.options, ...this.annotation, type: "enum" });
return e.values = t, e;
}
}
export {
d as AnnotationBuilder
};
//# sourceMappingURL=AnnotationBuilder.js.map