@react-form-builder/core
Version:
React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required
181 lines (164 loc) • 4.5 kB
JavaScript
import { isNumber as p, isUndefined as f } from "../../../utils/tools.js";
import { createDataProxy as r } from "./createComponentDataProxy.js";
class g {
/**
* Creates arguments for the event handler.
* @param type the event type.
* @param sender the component that triggered the event.
* @param store the form viewer settings.
* @param args the event arguments.
* @param renderedProps the component properties that were used to render the sender component.
* @param cellInfo the information about the current table cell.
*/
constructor(e, t, n, a, s, i) {
this.type = e, this.sender = t, this.store = n, this.args = a, this.renderedProps = s, this.cellInfo = i, this.index = t.nearestIndex;
const d = p(this.index), o = t.dataRoot;
if (this.
const h = o.parent?.dataRoot ?? this.store.formData;
this.
}
this.
}
type;
sender;
store;
args;
renderedProps;
cellInfo;
/**
* The index of the component in the array, if the component is in the array.
*/
index;
/**
* The user-defined context passed from the form viewer props.
*/
userContext;
/**
* The ref value, if available.
*/
refValue;
/**
* @returns user-defined properties for the React component that override other properties of the component.
*/
get userDefinedProps() {
return { ...this.sender.userDefinedProps };
}
/**
* Sets user-defined properties for the React component that override other properties of the component.
* @param props the component properties.
*/
setUserDefinedProps = (e) => {
this.sender.userDefinedProps = e;
};
/**
* @returns the event handled by the event handler.
*/
get event() {
return this.args.find(this.
}
/**
* @returns the first element of the event argument array, which is treated as a value.
*/
get value() {
return this.args.filter((e) => !f(e)).find(this.
}
/**
* @returns the object for reading and changing form data.
*/
get data() {
return this.
}
/**
* @returns the object to read and modify parent data (available for array elements).
*/
get parentData() {
return this.
}
/**
* @returns the object to read and modify root form data.
*/
get rootData() {
return this.
}
}
const m = `
/**
* Arguments passed to the event handler.
*/
declare class ActionEventArgs {
/**
* The event type.
*/
readonly type: string
/**
* The component that triggered the event.
*/
readonly sender: ComponentData
/**
* The component properties that were used to render the sender component.
*/
readonly renderedProps: Record<string, any>
/**
* The index of the component in the array, if the component is in the array.
*/
readonly index?: number
/**
* @returns user-defined properties for the React component that override other properties of the component.
*/
get userDefinedProps(): Record<string, any>
/**
* Sets current props of component.
*/
readonly setUserDefinedProps: (props: Record<string, any>) => void
/**
* The form viewer settings.
*/
readonly store: Store
/**
* The event arguments.
*/
readonly args: any[]
/**
* @returns the event handled by the event handler.
*/
get event(): SyntheticEvent | null
/**
* @returns the first element of the event argument array, which is treated as a value.
*/
get value(): any
/**
* @returns the object for reading and changing form data.
*/
get data(): Record<string, unknown>
/**
* @returns the object to read and modify parent data (available for array elements).
*/
get parentData(): Record<string, unknown> | undefined
/**
* @returns the object to read and modify root form data.
*/
get rootData(): Record<string, unknown>
/**
* The information about the current cell.
*/
readonly cellInfo?: CellInfo
/**
* The user-defined context passed from the form viewer props.
*/
readonly userContext?: unknown
/**
* The ref value, if available.
*/
readonly refValue?: any
}
`;
export {
g as ActionEventArgs,
m as ActionEventArgsDeclaration
};
//# sourceMappingURL=ActionEventArgs.js.map