UNPKG

@jecloud/ui

Version:

JECloud UI库,基于ant-design-vue封装

1 lines 2.14 kB
var t=this&&this.__assign||function(){return t=Object.assign||function(t){for(var r,a=1,e=arguments.length;a<e;a++)for(var l in r=arguments[a])Object.prototype.hasOwnProperty.call(r,l)&&(t[l]=r[l]);return t},t.apply(this,arguments)};import{createVNode as r,Fragment as a}from"vue";import{defineComponent as e,ref as l,computed as n,watch as i}from"vue";import o from"ant-design-vue/es/_util/hooks/useFlexGapSupport";import{filterEmpty as u}from"../../utils/props";var s={small:10,middle:16,large:24};function v(t){return s[t]?s[t]:t||0}export default e({name:"JeToolbar",inheritAttrs:!1,props:{space:{type:[String,Number],default:"small"},direction:{type:String,default:"horizontal",valid:["horizontal","vertical"]},align:{type:String,default:"center",valid:["start","end","center","baseline"]},justify:{type:String,default:"start",valid:["start","end","center","baseline"]},wrap:Boolean},setup:function(e,s){var p=s.slots,d=s.attrs,f="je-toolbar",c=n((function(){var t;return null!==(t=e.space)&&void 0!==t?t:"small"})),m=o(),g=l(),y=l();i(c,(function(){var t;t=(Array.isArray(c.value)?c.value:[c.value,c.value]).map((function(t){return v(t)})),g.value=t[0],y.value=t[1]}),{immediate:!0});var h=n((function(){var r={};return m.value&&(r.columnGap=g.value+"px",r.rowGap=y.value+"px"),[t(t({},r),e.wrap&&{flexWrap:"wrap",marginBottom:-y.value+"px"}),d.style]})),b=n((function(){return"marginRight"}));return function(){var l,n,i,o=e.wrap,s=e.direction,v=void 0===s?"horizontal":s,c=u(null===(i=p.default)||void 0===i?void 0:i.call(p)),j=c.length;if(0===j)return null;var x=g.value,w=j-1;return r("div",{class:[f,"je-toolbar-"+e.direction,(l={},l["je-toolbar-align-"+e.align]=e.align,l),(n={},n["je-toolbar-justify-"+e.justify]=e.justify,n),d.class],style:h.value},[c.map((function(e,l){var n,i,u;if(!e)return null;if(null===(u=null===(i=e.type)||void 0===i?void 0:i.name)||void 0===u?void 0:u.startsWith("JeToolbar"))return e;var s={};return m.value||("vertical"===v?l<w&&(s={marginBottom:x+"px"}):s=t(t({},l<w&&((n={})[b.value]=x+"px",n)),o&&{paddingBottom:y.value+"px"})),r(a,null,[r("div",{class:"je-toolbar-item",style:s},[e])])}))])}}});