import{registerTemplate as t,freezeTemplate as e,registerDecorators as n,registerComponent as i}from"@kdcloudjs/kwc";import s from"./menuItem.js";import o from"./menuDivider.js";import a from"./buttonMenu.js";import"../observable-tloG64m6.js";import"../i18n-B98kiI7M.js";import{G as c}from"../utilsPrivate-CI3EeA5x.js";import"../classSet-DY6Qvt6E.js";import{f as r}from"../labelUtils-DAuN2uUV.js";import l from"./shadowBaseClassPrivate.js";import{b as d}from"../label-CY8Q8HAO.js";import"./icon.js";import"../client-Ddi3i8XR.js";import"../ssr-C2pjZzfv.js";import"../empty_html-CjXB8rB4.js";import"./iso8601Utils.js";import"../colorValid-qIPgkqGp.js";import"./button.js";import"./positionLibrary.js";import"./tooltipLibrary.js";import"./primitiveBubble.js";import"../kddsCommon-CucK_w70.js";import"./ariaObserver.js";var u=[[[function(t,e,n){var i=t?"["+t+"]":"",s=t?"["+t+"-host]":"";return(e?":host .kdds-th__action-button":s+" .kdds-th__action-button")+i+" {position: absolute;transform: translateY(-50%);top: 50%;inset-inline-end: var(--kdds-g-spacing-1);}"+(e?":host .kdds-th__action-button":s+" .kdds-th__action-button")+i+" .kdds-button"+i+" {color: var(--kdds-g-color-on-surface-3);}"+(e?":host .kdds-th__action-button":s+" .kdds-th__action-button")+i+" .kdds-button:hover"+i+" {background: transparent;}"+(e?":host .kdds-th__action-button":s+" .kdds-th__action-button")+i+" {inset-inline-end: var(--kdds-g-spacing-3);}"}]]];const m={"kdds-th__action-button":!0},h=[["z-index","1",!1]],p={key:2};function b(t,e,n,i){const{gid:c,b:r,k:l,c:d,i:u,f:b}=t,{_m0:_}=i;return[e.hasActions?d("kd-button-menu",a,{classMap:m,styleDecls:h,ref:"buttonMenu",props:{id:c("primitive-header-action-button-menu-id"),iconSize:"x-small",menuAlignment:e._actionMenuAlignment,title:e.alternativeText,alternativeText:e.alternativeText,variant:"text",iconName:"kdfont-xiala",tabIndex:"-1"},key:0,on:_||(i._m0={open:r(e.handleMenuOpen),close:r(e.handleMenuClose),select:r(e.handleActionSelect)})},b([u(e._internalActions,function(t,e){return d("kd-menu-item",s,{props:{value:t,label:t.label,iconName:t.iconName,disabled:t.disabled,checked:t.checked},key:l(1,t.label)})}),e.hasActionsDivider?d("kd-menu-divider",o,p):null,u(e._customerActions,function(t,e){return d("kd-menu-item",s,{props:{value:t,label:t.label,iconName:t.iconName,disabled:t.disabled,checked:t.checked},key:l(3,t.label)})})])):null]}var _=t(b);b.hasRefs=!0,b.stylesheets=[],b.stylesheetToken="kwc-2nknfkpqdkl",b.legacyStylesheetToken="D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\primitiveHeaderActions-undefined_primitiveHeaderActions",u&&b.stylesheets.push.apply(b.stylesheets,u),e(b);const k={clipText:d.clipText,showActions:d.showActions,wrapText:d.wrapText};class v extends l{constructor(...t){super(...t),this.containerRect=void 0,this._internalActions=[],this._customerActions=[],this._actionMenuAlignment=void 0,this.colKeyValue=void 0,this.columnHeader=void 0}get actions(){return this._actions}set actions(t){this._actions=t,this.updateActions()}focus(){const t=this.refs.buttonMenu;t&&t.focus()}get i18n(){return k}get hasActions(){return this._internalActions.length>0||this._customerActions.length>0}get hasActionsDivider(){return this._internalActions.length>0&&this._customerActions.length>0}handleMenuOpen(t){t.preventDefault(),t.stopPropagation(),this.elementRect=this.refs.buttonMenu.getBoundingClientRect(),this.dispatchEvent(new CustomEvent("privatecellheaderactionmenuopening",{bubbles:!0,composed:!0,cancelable:!0,detail:{actionsCount:this._internalActions.length+this._customerActions.length,dividersCount:this.hasActionsDivider?1:0,saveContainerPosition:t=>{this.containerRect=t}}}))}handleMenuClose(){this.dispatchEvent(new CustomEvent("privatecellheaderactionmenuclosed",{bubbles:!0,composed:!0,cancelable:!0}))}handleActionSelect(t){const e=t.detail.value;this.dispatchEvent(new CustomEvent("privatecellheaderactiontriggered",{composed:!0,bubbles:!0,cancelable:!0,detail:{action:c(e._action),actionType:e._type,colKeyValue:this.colKeyValue}}))}updateActions(){const t=t=>(e,n)=>{const i={_type:t,_action:n};return e.push(Object.assign({},n,i)),e};this._internalActions=this.getActionsByType("internalActions").reduce(t("internal"),[]),this._customerActions=this.getActionsByType("customerActions").reduce(t("customer"),[]),this._actionMenuAlignment=this._actions.menuAlignment&&this._actions.menuAlignment.replace("auto-","")}getActionsByType(t){return Array.isArray(this._actions[t])?this._actions[t]:[]}get alternativeText(){return r(k.showActions,this.columnHeader||"")}}v.delegatesFocus=!0,n(v,{publicProps:{colKeyValue:{config:0},actions:{config:3},columnHeader:{config:0}},publicMethods:["focus"],track:{containerRect:1,_internalActions:1,_customerActions:1},fields:["_actionMenuAlignment"]});const g=i(v,{tmpl:_,sel:"D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\primitiveHeaderActions-",apiVersion:63});export{g as default};
