UNPKG

@react-form-builder/core

Version:

React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required

90 lines (89 loc) 3.56 kB
import { observer as f } from "mobx-react"; import { getComponentFeature as g } from "./ComponentFeature.js"; import { cfComponentRole as T } from "./integratedComponentFeatures.js"; class b { /** * Creates component metadata for the form viewer. * @param component the React component. * @param name the component name. * @param actionsInitializer the function to initialize actions in the component. * @param valued the name of the component property where the component value is stored. * @param valueType the type of the component value. * @param defaultProps the component's default property values. * @param css the component's CSS values. * @param wrapperCss the component's wrapper CSS values. * @param typeName the component type name. * @param kind the component kind. * @param readOnly the name of the component property that stores the read-only flag. * @param propsBindingTypes the component property binding types. * @param uncontrolledValue the value for the uncontrolled (undefined) state. * @param disabled the name of the component property that stores the disabled flag. * @param dataBindingType the type of component data binding. * @param features the component features that provide additional information about component's characteristic. * @template T the type of React component properties. */ constructor(e, i, t, s, n, a, r, o, p, l = "component", u, h = {}, d, m, c = "none", y = {}) { this.actionsInitializer = t, this.valued = s, this.valueType = n, this.defaultProps = a, this.css = r, this.wrapperCss = o, this.typeName = p, this.kind = l, this.readOnly = u, this.propsBindingTypes = h, this.uncontrolledValue = d, this.disabled = m, this.dataBindingType = c, this.features = y, this.valued && this.dataBindingType === "none" && (this.dataBindingType = "twoWay"), this.component = f(e), this.#e = i; } actionsInitializer; valued; valueType; defaultProps; css; wrapperCss; typeName; kind; readOnly; propsBindingTypes; uncontrolledValue; disabled; dataBindingType; features; #e; /** * The React component. */ component; /** * @returns the component name, or type if there is no component name. */ get name() { return this.#e ?? this.type; } /** * @returns the component type name. */ get type() { return this.typeName || this.component.displayName || this.component.name; } /** * Returns true if feature is present in the component feature set and equals value, false otherwise. * @param name the feature name. * @param value the feature value. * @returns true if feature is present in the component feature set and equals value, false otherwise. */ hasFeatureValue(e, i) { const t = this.features[e]; return t ? g(e).allowMultiple ? Array.isArray(t) ? t.indexOf(i) >= 0 : !1 : t === i : !1; } /** * Returns true if feature is present in the component feature set and equals `true`, false otherwise. * @param name the feature name. * @returns true if feature is present in the component feature set and equals `true`, false otherwise. */ isFeatureEnabled(e) { return this.features[e] === !0; } /** * Returns true if the role is defined in the component's roles, false otherwise. * @param value the component role. * @returns true if the role is defined in the component's roles, false otherwise. */ hasComponentRole(e) { return this.hasFeatureValue(T, e); } } export { b as Model }; //# sourceMappingURL=Model.js.map