import{h}from"../edel-elements.core.js";import{a as ButtonType}from"./chunk-2e00f500.js";var EdelTableComponent=function(){function e(){this.rows=[],this.columns=[],this.actions=[],this.actionMenu=!1}return e.prototype.render=function(){var e=this;return this.rows.length>0&&this.columns.length>0?h("table",{class:"table table--no-border-top"},h("thead",null,h("tr",{class:"table-row table-row--head"},this.renderTableHead(),this.renderActionMenuHead())),h("tbody",null,this.rows.map(function(t){return h("tr",{class:"table-row"},e.renderTableRow(t),e.renderActionMenuButtons(t))}))):null},e.prototype.renderTableHead=function(){return this.columns.map(function(e){return h("th",{class:"table-head"},e.title)})},e.prototype.renderActionMenuButtons=function(e){var t=this;if(this.actionMenu)return h("td",{class:"table-cell"},this.actions.map(function(n){return h("edel-button",{type:ButtonType.default,plain:!0,slim:!0,label:n.label,onClick:function(){return t.handleEvent(n.eventName,e.context.itemOrType)}})}))},e.prototype.renderActionMenuHead=function(){if(this.actionMenu)return h("th",{class:"table-head"})},e.prototype.renderTableRow=function(e){var t=this;return this.columns.map(function(n){return h("td",{class:"table-cell"},t.renderCellContents(n,e))})},e.prototype.handleEvent=function(e,t){this.emit.emit({action:e,data:t})},e.prototype.renderCellContents=function(e,t){return h("concrete-visual",{visual:e.visual,context:t.context,concrete:t.data[e.property||e.title]})},Object.defineProperty(e,"is",{get:function(){return"edel-table"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"properties",{get:function(){return{actionMenu:{type:Boolean,attr:"action-menu"},actions:{type:"Any",attr:"actions"},columns:{type:"Any",attr:"columns"},rows:{type:"Any",attr:"rows"}}},enumerable:!0,configurable:!0}),Object.defineProperty(e,"events",{get:function(){return[{name:"emit",method:"emit",bubbles:!0,cancelable:!0,composed:!0}]},enumerable:!0,configurable:!0}),e}();export{EdelTableComponent as EdelTable};