Localisation updates from https://translatewiki.net.
[mediawiki.git] / resources / lib / codex / modules / CdxAccordion.cjs
blob9d31664ceba859c66ef502b1028ff45f29e556c9
1 "use strict";const o=require("vue"),d=require("./Icon.js"),u=require("./CdxButton.cjs"),p=require("./_plugin-vue_export-helper.js"),m=o.defineComponent({name:"CdxAccordion",components:{CdxButton:u,CdxIcon:d.CdxIcon},props:{actionAlwaysVisible:{type:Boolean,default:!1},actionIcon:{type:[String,Object],default:null},actionButtonLabel:{type:String,default:""},headingLevel:{type:String,default:"h3"}},emits:["action-button-click"],setup(e,{attrs:t,emit:s}){const c=o.ref("open"in t),a=()=>{s("action-button-click")},r=l=>{c.value=l.newState==="open"},n=o.computed(()=>e.actionIcon&&(c.value||e.actionAlwaysVisible)),i=o.computed(()=>({"cdx-accordion--has-icon":n.value}));return{emitActionButtonClick:a,rootClasses:i,shouldShowActionButton:n,onToggle:r}}}),C={class:"cdx-accordion__header__title"},_={class:"cdx-accordion__header__description"};function f(e,t,s,c,a,r){const n=o.resolveComponent("cdx-icon"),i=o.resolveComponent("cdx-button");return o.openBlock(),o.createElementBlock("details",{class:o.normalizeClass(["cdx-accordion",e.rootClasses]),onToggle:t[1]||(t[1]=(...l)=>e.onToggle&&e.onToggle(...l))},[o.createElementVNode("summary",null,[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(e.headingLevel),{class:"cdx-accordion__header"},{default:o.withCtx(()=>[o.createElementVNode("span",C,[o.renderSlot(e.$slots,"title")]),o.createElementVNode("span",_,[o.renderSlot(e.$slots,"description")])]),_:3})),e.shouldShowActionButton?(o.openBlock(),o.createBlock(i,{key:0,class:"cdx-accordion__action","aria-label":e.actionButtonLabel,type:"button",weight:"quiet",onClick:o.withModifiers(e.emitActionButtonClick,["stop"])},{default:o.withCtx(()=>[o.createVNode(n,{icon:e.actionIcon,"icon-label":e.actionButtonLabel,size:"medium"},null,8,["icon","icon-label"])]),_:1},8,["aria-label","onClick"])):o.createCommentVNode("v-if",!0)]),o.createElementVNode("div",{class:"cdx-accordion__content",onClick:t[0]||(t[0]=o.withModifiers(()=>{},["stop"]))},[o.renderSlot(e.$slots,"default")])],34)}const b=p._export_sfc(m,[["render",f]]);module.exports=b;