UNPKG

@chief-editor/brick-control

Version:

Control Brick for chief editor

1 lines 932 B
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,a=1,r=arguments.length;a<r;a++)for(var l in t=arguments[a])Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l]);return e}).apply(this,arguments)};import React,{useCallback,useMemo}from"react";import{Select}from"@chief-editor/ui";export function SelectBrick(e){var t=e.config.props,a=t.readonly,r=t.disabled,l=t.clearable,n=t.placeholder,i=e.styles,o=e.setValue,c=e.layout,s=e.value,u=e.datasource,d=e.creator,p=useCallback((function(e){return e&&o(e)}),[]),h=useMemo((function(){return parseFloat(String(i.width||c.width)).toString()+"px"}),[i.width,c.width]);return React.createElement(Select,{"data-id":d,style:__assign(__assign({},c),i),value:s,width:h,placeholder:n,clearable:l,onValueChange:p,disabled:r||a},(u||[]).map((function(e){var t=e.value,a=e.label;return React.createElement(Select.Option,{key:t,value:t,label:a})})))}