UNPKG

@chief-editor/preview

Version:

FlowEditor Editor

1 lines 1.21 kB
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},__rest=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r};import React,{memo}from"react";import{useBrickInstance,useRuntime}from"@chief-editor/runtime";import{useTemplate}from"../hooks/useTemplate";import{BrickContainerRender}from"./BrickContainerRender";export var BrickRender=memo((function(e){var t=e.brickId,r=e.brickType,n=e.node,i=useRuntime().Bricks,o=useTemplate().getBrick(t),a=useBrickInstance(o),s=a.layout,c=__rest(a,["layout"]),l=i[r];return l?React.createElement(BrickContainerRender,{brickId:t,style:s,node:n},React.createElement(l,__assign({key:o.id},c,{layout:{width:s.width,height:s.height}}))):(console.warn("Brick: "+r+" is not found"),null)}));