/** * @module dynamic-form-factory-base * * * @see {@link WitnessFactoryBase} */ import { TransformResult } from "@ibgib/ts-gib/dist/types.mjs"; import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs"; import { DynamicForm, FormItemInfo } from "../../common/form/form-items.mjs"; import { WitnessFactoryBase } from "./witness-factory-base.mjs"; import { Witness, WitnessData_V1, WitnessRel8ns_V1 } from "../witness-types.mjs"; /** * The idea is that any model can be injected via this factory provider. * * So when you create a witness that you want to be able to instantiate via * just metadata, you also provide an accompanying factory that knows * how to map from a * * witness(model) -> form data (to generate dynamic forms) * * form data -> witness (to instantiate witness from data) */ export declare abstract class DynamicFormFactoryBase> extends WitnessFactoryBase { protected lc: string; /** * override this with something that maps from the ibgib/model to the form infos. */ abstract witnessToForm({ witness }: { witness: TWitness; }): Promise; /** * override this with specific behavior that will reify an instance based on * the given {@link form}. */ abstract formToWitness({ form }: { form: DynamicForm; }): Promise>; /** * iterates through the given {@link items}. * * If the item has child items, it is considered a grouping (i.e. FormGroup * or FormArray) and this function is called recursively with the * {@link contextPath} adjusted per the {@link pathDelimiter} and * `item.name`. * * If the item does not have child items, it's considered to be a setting at * the current path level and it's value is assigned per its `item.name` as * the key. */ protected patchDataFromItems({ data, contextPath, items, pathDelimiter, }: { /** * ibgib.data object that we are patching/setting from the form items. */ data: any; /** * source items whose values we are patching the {@link data} with. */ items: FormItemInfo[]; /** * Separates sections of pathing into the data object. * * @default @see {@link DEFAULT_DATA_PATH_DELIMITER} */ pathDelimiter: string; /** * we're patching the data object as follows: * * data[contextPath/item.name] = value * * where the '/' is the data path delimiter. * * So if the incoming items are nested deeper, this will look like * * data['mysetting/subsetting/color'] = "red" * * @see {@link pathDelimiter} * @see {@link DEFAULT_DATA_PATH_DELIMITER} */ contextPath?: string; }): void; } //# sourceMappingURL=dynamic-form-factory-base.d.mts.map