* dip * dip * scroll * fixes * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * dip * solve for canvas glitches * dip * dip * dip * adjust scroll speed * dip * dip(code clean up) * dip * dip * ---dip * dip * dip * dip * middle ware for dropping multiple widgets. * adding scroll to drag for canvas selection. * fixing drag disabled and modal widget(detach from layout) drops * firefox and safari fixes * rebase conflicts. * fixing broken specs. * fixing specs and adding jest tests. * show border and disable resize when multiple widgets are selected. * selection box grab cursor * merge conflicts. * code clean up * fixing specs. * fixed a bug and failed specs. * fixing rerenders. * code clean up * code review comments * always have the drag point inside the widget. * fetching snap spaces instead of calculating. * remove widget_move action * fixing bugs with add widget parent height updation. * fixing specs. * List widget conflict fixes. * fixing canvas drop persistence. * Adding click to drag for modals and fixing few issues.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { makeFactory } from "factory.ts";
|
|
import { WidgetProps } from "widgets/BaseWidget";
|
|
import { ContainerWidgetProps } from "widgets/ContainerWidget";
|
|
import defaultTemplate from "../../src/templates/default";
|
|
import { WidgetTypeFactories } from "./Widgets/WidgetTypeFactories";
|
|
const defaultMainContainer: ContainerWidgetProps<WidgetProps> = {
|
|
...(defaultTemplate as any),
|
|
canExtend: true,
|
|
renderMode: "PAGE",
|
|
version: 1,
|
|
isLoading: false,
|
|
};
|
|
|
|
export const mainContainerFactory = makeFactory({ ...defaultMainContainer });
|
|
export const widgetCanvasFactory = makeFactory(mainContainerFactory.build());
|
|
const buildChild = (child: Partial<WidgetProps>): WidgetProps => {
|
|
return WidgetTypeFactories[child.type || "CANVAS_WIDGET"].build({
|
|
...child,
|
|
});
|
|
};
|
|
export const buildChildren = (children: Partial<WidgetProps>[]) => {
|
|
try {
|
|
return children.map((child) => {
|
|
return buildChild(child);
|
|
});
|
|
} catch (error) {
|
|
console.error("Check if child widget data provided");
|
|
}
|
|
};
|
|
|
|
export const buildDslWithChildren = (childData: Partial<WidgetProps>[]) => {
|
|
const children: any = buildChildren(childData);
|
|
return widgetCanvasFactory.build({
|
|
children,
|
|
});
|
|
};
|