UNPKG

@chief-editor/brick-control

Version:

Control Brick for chief editor

1 lines 1.4 kB
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},__rest=this&&this.__rest||function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}return r};import React from"react";import{IFlexItemType}from"./type";var pixelStyleKeys=["paddingTop","paddingBottom","paddingLeft","paddingRight"];export function FlexBrick(e){var t=e.styles,r=e.layout,i=e.dispatchEvent,n=e.creator,a=e.renderPart,o=e.config.itemConfigs,l=void 0===o?[]:o;return React.createElement("div",{"data-id":n,style:__assign(__assign({display:"flex",width:"100%"},t),r),onClick:i},l.map((function(e){return React.createElement(FlexBrickItem,__assign({},e,{key:e.key}),a(e.key))})))}function FlexBrickItem(e){var t=e.widthType,r=e.widthFlex,i=e.width,n=e.children,a=__rest(e,["widthType","widthFlex","width","children"]),o={};return t===IFlexItemType.Flex?o.flex=r:o.flex="0 0 "+i,pixelStyleKeys.forEach((function(e){var t=a[e];o[e]=t&&t+"px"})),React.createElement("div",{style:o},n)}