mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-08 04:55:06 +09:00
27 lines
597 B
TypeScript
27 lines
597 B
TypeScript
import ObjectId from "bson-objectid";
|
|
import {
|
|
type CssRule,
|
|
type Instance,
|
|
components,
|
|
} from "@webstudio-is/react-sdk";
|
|
|
|
export const createInstance = ({
|
|
component,
|
|
id,
|
|
children,
|
|
cssRules,
|
|
}: {
|
|
component: Instance["component"];
|
|
id?: Instance["id"];
|
|
children?: Instance["children"];
|
|
cssRules?: Array<CssRule>;
|
|
}): Instance => {
|
|
const componentMeta = components[component];
|
|
return {
|
|
component,
|
|
id: id === undefined ? ObjectId().toString() : id,
|
|
cssRules: cssRules ?? [],
|
|
children: children === undefined ? componentMeta.children ?? [] : children,
|
|
};
|
|
};
|