@agile-team/mach-report 2.8.0 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/designer.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),F=require("@agile-team/mach-report/vue"),p=require("@agile-team/mach-report"),K=require("./_plugin-vue_export-helper-BHFhmbuH.cjs");function Q(u,S,i,f){const d=e.ref(0),l=e.ref(""),h=e.ref([]),R=e.computed(()=>u.value.template.pages.flatMap((a,r)=>a.components.flatMap((o,c)=>o.kind==="list"?[{component:o,pageIndex:r,componentIndex:c}]:[]))),b=e.computed(()=>R.value[d.value]?.component),V=e.computed(()=>{const a=b.value;if(!a)return[];const r=a.columns.map(o=>o.headerStyle?.align??o.headerAlign??a.headerStyle?.align??a.headerAlign??o.style?.align??"center");if(a.headerGrid&&S())for(const o of p.resolveGridLayout(a.headerGrid,a.widthMm,100).cells)for(let c=o.ci;c<o.ci+(o.cell.colSpan??1);c++)r[c]=o.cell.style?.align??"left";return r}),E=e.computed(()=>{const a=l.value.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);return(b.value?.columns??[]).flatMap((r,o)=>{const c=`${r.header} ${r.field}`.toLocaleLowerCase();return a.every(y=>c.includes(y))?[{column:r,index:o}]:[]})});function v(a,r){h.value=r?[...new Set([...h.value,a])]:h.value.filter(o=>o!==a)}function N(a){for(const r of E.value)v(r.index,a)}function m(){h.value=[]}function M(a,r,o){if(!i())return;const c=b.value?.columns[a];c&&(Object.assign(c,{[r]:r==="widthMm"?Number(o):o}),r==="header"&&A(a,String(o)),r==="headerAlign"&&D(a,o),r==="widthMm"&&G(),f())}function G(){const a=R.value[d.value];if(!a)return;const r=a.component,o=u.value.template.pages[a.pageIndex],c=r.columns.map(y=>y.widthMm);r.headerGrid&&(r.headerGrid.colWidthsMm=c),o.layout==="wide"&&c.every(y=>Number.isFinite(y)&&y>0)&&(r.widthMm=c.reduce((y,t)=>y+t,0),o.widthMm=Math.max(...o.components.map(y=>y.leftMm+y.widthMm))+(o.marginRightMm??0))}function A(a,r){const o=b.value;if(!o?.headerGrid)return;const y=p.resolveGridLayout(o.headerGrid,o.widthMm,100).cells.filter(({ci:t,cell:T})=>t<=a&&t+(T.colSpan??1)>a).slice(-1)[0];y&&(Object.assign(y.cell,{text:r,rawText:r,value:r}),o.columns.slice(y.ci,y.ci+(y.cell.colSpan??1)).forEach(t=>{t.header=r}))}function D(a,r){const o=b.value,c=o?.columns[a];if(c?.headerStyle?.align!==void 0&&(c.headerStyle={...c.headerStyle,align:r}),!o?.headerGrid)return;const t=p.resolveGridLayout(o.headerGrid,o.widthMm,100).cells.filter(({ci:T,cell:L})=>T<=a&&T+(L.colSpan??1)>a).slice(-1)[0];t&&(t.cell.style={...t.cell.style,align:r},o.columns.slice(t.ci,t.ci+(t.cell.colSpan??1)).forEach(T=>{T.headerAlign=r,T.headerStyle?.align!==void 0&&(T.headerStyle={...T.headerStyle,align:r})}))}function j(a,r){if(!(!i()||a==="headerAlign"&&r==="auto")){for(const o of h.value){const c=b.value?.columns[o];c&&(Object.assign(c,{[a]:r}),a==="headerAlign"&&D(o,r))}f()}}return{selected:d,query:l,selectedColumns:h,lists:R,activeList:b,headerAlignments:V,visibleColumns:E,toggleColumn:v,selectVisible:N,clearSelection:m,setColumn:M,alignColumns:j}}function X(u,S={entries:100,bytes:16*1024*1024}){const i=e.ref([u]),f=e.ref(0),d=e.computed(()=>f.value>0),l=e.computed(()=>f.value+1<i.value.length),h=e.computed(()=>i.value[f.value]);function R(E){i.value=[E],f.value=0}function b(E){if(i.value[f.value]===E)return;const v=i.value.slice(0,f.value+1);v.push(E);let N=v.reduce((m,M)=>m+M.length*2,0);for(;v.length>1&&(v.length>S.entries||N>S.bytes);)N-=v.shift().length*2;i.value=v,f.value=i.value.length-1}function V(E){if(!(E<0?!d.value:!l.value))return f.value+=E,i.value[f.value]}return{canUndo:d,canRedo:l,current:h,reset:R,record:b,move:V}}function Y(u){const S=e.shallowRef(null),i=e.ref(!1);let f,d=0;function l(b){f?.(b),f=void 0,S.value=null}function h(){d++,l(!1),i.value=!1}async function R(b){h();const V=d,E=u();i.value=!0;try{const v=await new Promise((N,m)=>{if(f=N,!E){S.value=b;return}Promise.resolve().then(()=>d===V?E(b):!1).then(M=>{d===V&&l(M===!0)},M=>{d===V&&(f=void 0,S.value=null,m(M))})});return d===V&&v===!0}finally{d===V&&(i.value=!1)}}return e.onBeforeUnmount(h),{confirmation:S,pending:i,decide:l,request:R,cancel:h}}const Z={title:"报表模板属性编辑器",heading:"模板属性",unpublished:"未发布",dirty:"有未保存修改",reset:"恢复草稿",saving:"正在保存…",save:"保存草稿",name:"模板名称",description:"说明",area:"明细区域",page:"页",header:"表头",field:"业务字段",width:"列宽(mm)",semantic:"字段语义",identifier:"编号",dimension:"分类",measure:"数值",date:"日期",text:"文本",bodyAlign:"正文对齐",headerAlign:"表头对齐",auto:"按字段语义",left:"居左",center:"居中",right:"居右",justify:"两端对齐",editable:"允许编辑",json:"完整模板 JSON",applyJson:"校验并应用 JSON",note:"字段映射应与数据源契约一致。此编辑器维护模板属性;保存由接入方提供的版本服务处理。",invalid:"请先修正模板错误,再预览或保存。"},ee={undo:"撤销",redo:"重做",columnsSearch:"搜索列名或字段",columnsSelected:"已选列",selectVisible:"选择当前结果",clearSelection:"清除选择",noColumns:"没有匹配的列",batchBody:"批量正文对齐",batchHeader:"批量表头对齐",chooseAlignment:"选择对齐方式",discardTitle:"保留当前修改?",discardDescription:"当前包含未保存的属性或尚未应用的 JSON,继续将丢弃这些修改。",keepEditing:"继续编辑",discard:"丢弃修改并继续",jsonPending:"JSON 尚未应用。请先校验并应用,或撤销 JSON 修改后继续属性编辑与保存。"},H={...Z,...ee};function te(u,S){const i=e.ref(p.parseReportTemplate(u.modelValue)),f=e.ref(p.serializeReportTemplate(i.value)),d=e.ref(p.serializeReportTemplate(i.value)),l=e.ref(""),h=e.ref(!1),R=e.computed(()=>({...H,...u.messages})),b=e.computed(()=>({showExport:!1,showPrint:!1,showPdfWindow:!1,...u.preview,theme:{shellBg:"#f1f5f9",shellFg:"#334155",toolbarBg:"#ffffff",toolbarBorder:"#e2e8f0",toolbarFg:"#334155",btnFg:"#475569",btnBorder:"#cbd5e1",btnHoverBg:"#eff6ff",btnHoverFg:"#1d4ed8",btnActiveBg:"#2563eb",...u.preview?.theme}}));F.provideMachReportConfig({get defaults(){return b.value}});let V,E=0;const v=e.computed(()=>p.validateReportTemplateDocument(i.value)),N=e.computed(()=>{try{return p.serializeReportTemplate(i.value)!==f.value}catch{return!0}}),m=e.ref(d.value),M=e.computed(()=>d.value!==m.value),G=e.computed(()=>N.value||d.value!==m.value),A=()=>JSON.stringify({document:i.value,json:d.value,appliedJson:m.value}),D=X(A()),j=Y(()=>u.beforeDiscard),a=e.computed(()=>h.value||j.pending.value),r=()=>!u.readonly&&!a.value&&!M.value,o=Q(i,()=>v.value.ok,r,n),{selected:c,lists:y,activeList:t,headerAlignments:T,setColumn:L}=o;e.watch(c,()=>o.clearSelection());const x=e.computed(()=>v.value.ok?F.createLocalFetcher({draft:{template:i.value.template,datasets:u.datasets??{},params:[]}}):void 0);function P(){E++,V?.abort(),V=void 0,h.value=!1}let J=0;async function w(g="replace",B){if(!G.value)return!0;const _=A();try{return await j.request({reason:g,document:JSON.parse(JSON.stringify(i.value)),replacement:B?p.parseReportTemplate(B):void 0,pendingLocalChanges:!0})&&_===A()}catch(O){return l.value=O instanceof Error?O.message:String(O),!1}}function s(g){P(),i.value=g,f.value=p.serializeReportTemplate(g),d.value=f.value,m.value=d.value,l.value="",c.value=0,o.clearSelection(),D.reset(A())}e.watch(()=>u.modelValue,async g=>{let B;try{B=p.parseReportTemplate(g)}catch(O){l.value=O instanceof Error?O.message:String(O);return}try{if(p.serializeReportTemplate(B)===p.serializeReportTemplate(i.value))return}catch{}const _=++J;if(P(),!await w("replace",B)){_===J&&v.value.ok&&S("update:modelValue",p.parseReportTemplate(i.value));return}_===J&&s(B)}),e.onBeforeUnmount(()=>{J++,P()});function n(){j.cancel(),l.value="",v.value.ok&&(d.value=p.serializeReportTemplate(i.value),m.value=d.value,S("update:modelValue",p.parseReportTemplate(i.value))),D.record(A())}function k(g){r()&&(i.value.name=g,n())}function C(g){r()&&(i.value.description=g,n())}function U(){if(!(u.readonly||a.value))try{const g=p.parseReportTemplate(d.value);if(g.id!==i.value.id)throw new Error("属性编辑不允许更换模板 ID,请另存为新模板");if(g.revision!==i.value.revision)throw new Error("修订号由保存服务管理,不能在 JSON 中修改");i.value=g,c.value=0,o.clearSelection(),n()}catch(g){l.value=g instanceof Error?g.message:String(g)}}async function q(){a.value||u.readonly||!await w("reset")||(s(p.parseReportTemplate(f.value)),S("update:modelValue",p.parseReportTemplate(i.value)))}function I(g){if(a.value||u.readonly)return;D.record(A());const B=D.move(g);if(!B)return;j.cancel();const _=JSON.parse(B);i.value=_.document,d.value=_.json,m.value=_.appliedJson,l.value="",c.value=0,o.clearSelection(),v.value.ok&&S("update:modelValue",p.parseReportTemplate(i.value))}async function z(){if(!u.save||!r()||!v.value.ok)return;const g=++E;V=new AbortController,h.value=!0,l.value="";const B=p.parseReportTemplate(i.value);try{const _=p.parseReportTemplate(await u.save(B,{expectedRevision:B.revision,signal:V.signal}));if(g!==E)return;if(_.id!==B.id)throw new Error("保存服务返回了其他模板的文档");i.value=_,f.value=p.serializeReportTemplate(_),d.value=f.value,m.value=d.value,D.reset(A()),S("saved",p.parseReportTemplate(_)),S("update:modelValue",p.parseReportTemplate(_))}catch(_){g===E&&(l.value=_ instanceof Error?_.message:String(_))}finally{g===E&&(h.value=!1,V=void 0)}}const $=e.computed(()=>D.canUndo.value||A()!==D.current.value),W=e.computed(()=>D.canRedo.value&&A()===D.current.value);return{...o,canUndo:$,canRedo:W,undo:()=>I(-1),redo:()=>I(1),pendingLocalChanges:G,jsonPending:M,blocked:a,confirmation:j.confirmation,decideDiscard:j.decide,guardChanges:w,draft:i,json:d,selected:c,error:l,saving:h,dirty:N,validation:v,lists:y,activeList:t,headerAlignments:T,previewOptions:b,fetcher:x,messages:R,setName:k,setDescription:C,setColumn:L,applyJson:U,reset:q,save:z}}const ne=["aria-label"],le={class:"mr-designer-bar"},oe={key:0},re=["disabled"],ae=["disabled"],ie=["disabled"],se=["disabled"],ue=["aria-label"],ce={class:"mr-designer-body"},de={class:"mr-designer-panel"},fe=["value","disabled"],me=["value","disabled"],pe={key:0},ve=["value"],ge={key:1,class:"mr-designer-columns"},he={class:"mr-designer-column-tools"},ye=["disabled"],be=["disabled"],Ee={role:"status"},Se={key:0,class:"mr-designer-batch"},Ve=["aria-label","disabled"],Ne={value:""},_e={value:"auto"},De={value:"left"},ke={value:"center"},Ce={value:"right"},Te={value:"justify"},we=["aria-label","disabled"],Be={value:""},Re={value:"left"},Me={value:"center"},Ae={value:"right"},je={value:"justify"},xe={key:1,role:"status"},Le=["disabled"],Oe={class:"mr-designer-select-column"},Je=["checked","onChange"],Ge=["value","onInput"],Pe=["value","onChange"],Fe=["value","onChange"],Ie=["value","onChange"],He={value:"identifier"},Ue={value:"dimension"},qe={value:"measure"},ze={value:"date"},$e={value:"text"},We=["value","onChange"],Ke={value:"auto"},Qe={value:"left"},Xe={value:"center"},Ye={value:"right"},Ze={value:"justify"},et=["value","onChange"],tt={value:"left"},nt={value:"center"},lt={value:"right"},ot={value:"justify"},rt={class:"mr-designer-toggle"},at=["checked","onChange"],it=["aria-label","disabled"],st=["disabled"],ut={key:2,role:"status",class:"mr-designer-note"},ct={class:"mr-designer-note"},dt={class:"mr-designer-preview"},ft={key:0,role:"alert",class:"mr-designer-error"},mt={key:1,role:"alert",class:"mr-designer-error"},pt={key:3,class:"mr-designer-note"},vt=e.defineComponent({__name:"ReportTemplateEditor",props:{modelValue:{},datasets:{},readonly:{type:Boolean},messages:{},preview:{},beforeDiscard:{type:Function},save:{type:Function}},emits:["update:modelValue","saved"],setup(u,{expose:S,emit:i}){const f=u,d=i,l=te(f,(w,s)=>{d(w==="saved"?"saved":"update:modelValue",s)}),{draft:h,json:R,selected:b,error:V,saving:E,pendingLocalChanges:v,jsonPending:N,blocked:m,confirmation:M,canUndo:G,canRedo:A,validation:D,lists:j,activeList:a,visibleColumns:r,query:o,selectedColumns:c,fetcher:y,messages:t}=l,T=e.ref(null);let L=null;e.watch(M,async w=>{w?(L=document.activeElement,await e.nextTick(),T.value?.focus()):(await e.nextTick(),L?.isConnected&&L.focus(),L=null)}),S({get pendingLocalChanges(){return v.value},guardChanges:l.guardChanges,reset:l.reset,save:l.save});function x(w){return w.target.value}function P(w){return w.target.checked}function J(w,s){const n=w.target;l.alignColumns(s,n.value),n.value=""}return(w,s)=>(e.openBlock(),e.createElementBlock("section",{class:"mr-designer","aria-label":e.unref(t).title},[e.createElementVNode("header",le,[e.createElementVNode("div",null,[e.createElementVNode("strong",null,e.toDisplayString(e.unref(t).heading),1),e.createElementVNode("span",null,[e.createTextVNode(e.toDisplayString(e.unref(h).id)+" · "+e.toDisplayString(e.unref(h).revision||e.unref(t).unpublished),1),e.unref(v)?(e.openBlock(),e.createElementBlock("b",oe," · "+e.toDisplayString(e.unref(t).dirty),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",null,[e.createElementVNode("button",{type:"button",disabled:u.readonly||e.unref(m)||!e.unref(G),onClick:s[0]||(s[0]=(...n)=>e.unref(l).undo&&e.unref(l).undo(...n))},e.toDisplayString(e.unref(t).undo),9,re),e.createElementVNode("button",{type:"button",disabled:u.readonly||e.unref(m)||!e.unref(A),onClick:s[1]||(s[1]=(...n)=>e.unref(l).redo&&e.unref(l).redo(...n))},e.toDisplayString(e.unref(t).redo),9,ae),e.createElementVNode("button",{type:"button",disabled:u.readonly||e.unref(m)||!e.unref(v),onClick:s[2]||(s[2]=(...n)=>e.unref(l).reset&&e.unref(l).reset(...n))},e.toDisplayString(e.unref(t).reset),9,ie),u.save?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",disabled:u.readonly||e.unref(m)||e.unref(N)||!e.unref(D).ok||!e.unref(v),onClick:s[3]||(s[3]=(...n)=>e.unref(l).save&&e.unref(l).save(...n))},e.toDisplayString(e.unref(E)?e.unref(t).saving:e.unref(t).save),9,se)):e.createCommentVNode("",!0)])]),e.unref(M)?(e.openBlock(),e.createElementBlock("div",{key:0,role:"alertdialog","aria-label":e.unref(t).discardTitle,class:"mr-designer-confirm",onKeydown:s[6]||(s[6]=e.withKeys(e.withModifiers(n=>e.unref(l).decideDiscard(!1),["prevent"]),["esc"]))},[e.createElementVNode("strong",null,e.toDisplayString(e.unref(t).discardTitle),1),e.createElementVNode("p",null,e.toDisplayString(e.unref(t).discardDescription),1),e.createElementVNode("button",{ref_key:"keepButton",ref:T,type:"button",onClick:s[4]||(s[4]=n=>e.unref(l).decideDiscard(!1))},e.toDisplayString(e.unref(t).keepEditing),513),e.createElementVNode("button",{type:"button",onClick:s[5]||(s[5]=n=>e.unref(l).decideDiscard(!0))},e.toDisplayString(e.unref(t).discard),1)],40,ue)):e.createCommentVNode("",!0),e.createElementVNode("div",ce,[e.createElementVNode("aside",de,[e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).name),1),e.createElementVNode("input",{value:e.unref(h).name,disabled:u.readonly||e.unref(m)||e.unref(N),onInput:s[7]||(s[7]=n=>e.unref(l).setName(x(n)))},null,40,fe)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).description),1),e.createElementVNode("textarea",{value:e.unref(h).description,disabled:u.readonly||e.unref(m)||e.unref(N),onInput:s[8]||(s[8]=n=>e.unref(l).setDescription(x(n)))},null,40,me)]),e.unref(j).length?(e.openBlock(),e.createElementBlock("label",pe,[e.createTextVNode(e.toDisplayString(e.unref(t).area),1),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":s[9]||(s[9]=n=>e.isRef(b)?b.value=n:null)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(j),(n,k)=>(e.openBlock(),e.createElementBlock("option",{key:k,value:k},e.toDisplayString(n.pageIndex+1)+" "+e.toDisplayString(e.unref(t).page)+" · "+e.toDisplayString(n.component.title||n.component.dataset),9,ve))),128))],512),[[e.vModelSelect,e.unref(b)]])])):e.createCommentVNode("",!0),e.unref(a)?(e.openBlock(),e.createElementBlock("div",ge,[e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).columnsSearch),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":s[10]||(s[10]=n=>e.isRef(o)?o.value=n:null),type:"search"},null,512),[[e.vModelText,e.unref(o)]])]),e.createElementVNode("div",he,[e.createElementVNode("button",{type:"button",disabled:u.readonly||e.unref(m)||e.unref(N)||!e.unref(r).length,onClick:s[11]||(s[11]=n=>e.unref(l).selectVisible(!0))},e.toDisplayString(e.unref(t).selectVisible),9,ye),e.createElementVNode("button",{type:"button",disabled:!e.unref(c).length,onClick:s[12]||(s[12]=(...n)=>e.unref(l).clearSelection&&e.unref(l).clearSelection(...n))},e.toDisplayString(e.unref(t).clearSelection),9,be),e.createElementVNode("span",Ee,e.toDisplayString(e.unref(t).columnsSelected)+" "+e.toDisplayString(e.unref(c).length)+" / "+e.toDisplayString(e.unref(a).columns.length),1)]),e.unref(c).length?(e.openBlock(),e.createElementBlock("div",Se,[e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).batchBody),1),e.createElementVNode("select",{"aria-label":e.unref(t).batchBody,disabled:u.readonly||e.unref(m)||e.unref(N),onChange:s[13]||(s[13]=n=>J(n,"align"))},[e.createElementVNode("option",Ne,e.toDisplayString(e.unref(t).chooseAlignment),1),e.createElementVNode("option",_e,e.toDisplayString(e.unref(t).auto),1),e.createElementVNode("option",De,e.toDisplayString(e.unref(t).left),1),e.createElementVNode("option",ke,e.toDisplayString(e.unref(t).center),1),e.createElementVNode("option",Ce,e.toDisplayString(e.unref(t).right),1),e.createElementVNode("option",Te,e.toDisplayString(e.unref(t).justify),1)],40,Ve)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).batchHeader),1),e.createElementVNode("select",{"aria-label":e.unref(t).batchHeader,disabled:u.readonly||e.unref(m)||e.unref(N),onChange:s[14]||(s[14]=n=>J(n,"headerAlign"))},[e.createElementVNode("option",Be,e.toDisplayString(e.unref(t).chooseAlignment),1),e.createElementVNode("option",Re,e.toDisplayString(e.unref(t).left),1),e.createElementVNode("option",Me,e.toDisplayString(e.unref(t).center),1),e.createElementVNode("option",Ae,e.toDisplayString(e.unref(t).right),1),e.createElementVNode("option",je,e.toDisplayString(e.unref(t).justify),1)],40,we)])])):e.createCommentVNode("",!0),e.unref(r).length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",xe,e.toDisplayString(e.unref(t).noColumns),1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),({column:n,index:k})=>(e.openBlock(),e.createElementBlock("fieldset",{key:k,disabled:u.readonly||e.unref(m)||e.unref(N)},[e.createElementVNode("legend",null,[e.createElementVNode("label",Oe,[e.createElementVNode("input",{type:"checkbox",checked:e.unref(c).includes(k),onChange:C=>e.unref(l).toggleColumn(k,P(C))},null,40,Je),e.createTextVNode(e.toDisplayString(k+1)+" · "+e.toDisplayString(n.header),1)])]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).header),1),e.createElementVNode("input",{value:n.header,onInput:C=>e.unref(l).setColumn(k,"header",x(C))},null,40,Ge)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).field),1),e.createElementVNode("input",{value:n.field,onChange:C=>e.unref(l).setColumn(k,"field",x(C))},null,40,Pe)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).width),1),e.createElementVNode("input",{type:"number",min:"0.1",step:"0.5",value:n.widthMm,onChange:C=>e.unref(l).setColumn(k,"widthMm",x(C))},null,40,Fe)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).semantic),1),e.createElementVNode("select",{value:n.semanticRole||"text",onChange:C=>e.unref(l).setColumn(k,"semanticRole",x(C))},[e.createElementVNode("option",He,e.toDisplayString(e.unref(t).identifier),1),e.createElementVNode("option",Ue,e.toDisplayString(e.unref(t).dimension),1),e.createElementVNode("option",qe,e.toDisplayString(e.unref(t).measure),1),e.createElementVNode("option",ze,e.toDisplayString(e.unref(t).date),1),e.createElementVNode("option",$e,e.toDisplayString(e.unref(t).text),1)],40,Ie)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).bodyAlign),1),e.createElementVNode("select",{value:n.align??n.style?.align??e.unref(a).align??"left",onChange:C=>e.unref(l).setColumn(k,"align",x(C))},[e.createElementVNode("option",Ke,e.toDisplayString(e.unref(t).auto),1),e.createElementVNode("option",Qe,e.toDisplayString(e.unref(t).left),1),e.createElementVNode("option",Xe,e.toDisplayString(e.unref(t).center),1),e.createElementVNode("option",Ye,e.toDisplayString(e.unref(t).right),1),e.createElementVNode("option",Ze,e.toDisplayString(e.unref(t).justify),1)],40,We)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).headerAlign),1),e.createElementVNode("select",{value:e.unref(l).headerAlignments.value[k],onChange:C=>e.unref(l).setColumn(k,"headerAlign",x(C))},[e.createElementVNode("option",tt,e.toDisplayString(e.unref(t).left),1),e.createElementVNode("option",nt,e.toDisplayString(e.unref(t).center),1),e.createElementVNode("option",lt,e.toDisplayString(e.unref(t).right),1),e.createElementVNode("option",ot,e.toDisplayString(e.unref(t).justify),1)],40,et)]),e.createElementVNode("label",rt,[e.createTextVNode(e.toDisplayString(e.unref(t).editable),1),e.createElementVNode("input",{type:"checkbox",checked:n.editable===!0,onChange:C=>e.unref(l).setColumn(k,"editable",P(C))},null,40,at)])],8,Le))),128))])):e.createCommentVNode("",!0),e.createElementVNode("details",null,[e.createElementVNode("summary",null,e.toDisplayString(e.unref(t).json),1),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":s[15]||(s[15]=n=>e.isRef(R)?R.value=n:null),class:"mr-designer-json","aria-label":e.unref(t).json,disabled:u.readonly||e.unref(m),spellcheck:"false"},null,8,it),[[e.vModelText,e.unref(R)]]),e.createElementVNode("button",{type:"button",disabled:u.readonly||e.unref(m),onClick:s[16]||(s[16]=(...n)=>e.unref(l).applyJson&&e.unref(l).applyJson(...n))},e.toDisplayString(e.unref(t).applyJson),9,st)]),e.unref(N)?(e.openBlock(),e.createElementBlock("p",ut,e.toDisplayString(e.unref(t).jsonPending),1)):e.createCommentVNode("",!0),e.createElementVNode("p",ct,e.toDisplayString(e.unref(t).note),1)]),e.createElementVNode("div",dt,[e.unref(V)?(e.openBlock(),e.createElementBlock("div",ft,e.toDisplayString(e.unref(V)),1)):e.createCommentVNode("",!0),e.unref(D).ok?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("ul",mt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(D).errors,n=>(e.openBlock(),e.createElementBlock("li",{key:n.path},e.toDisplayString(n.path)+":"+e.toDisplayString(n.message),1))),128))])),e.unref(y)&&e.unref(D).ok?(e.openBlock(),e.createBlock(e.unref(F.ReportPreview),{key:2,"report-id":"draft",fetcher:e.unref(y),"show-params":!1,editable:!1,"excel-import":!1},null,8,["fetcher"])):(e.openBlock(),e.createElementBlock("p",pt,e.toDisplayString(e.unref(t).invalid),1))])])],8,ne))}}),gt=K._export_sfc(vt,[["__scopeId","data-v-e2d0e1d5"]]);exports.ReportTemplateEditor=gt;exports.TEMPLATE_EDITOR_MESSAGES=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),W=require("@agile-team/mach-report/vue"),I=require("./_plugin-vue_export-helper-BLmdZLlg.cjs"),b=require("@agile-team/mach-report");function Y(u,k,s,g){const m=e.ref(0),o=e.ref(""),h=e.ref([]),T=e.computed(()=>u.value.template.pages.flatMap((i,a)=>i.components.flatMap((r,d)=>r.kind==="list"?[{component:r,pageIndex:a,componentIndex:d}]:[]))),E=e.computed(()=>T.value[m.value]?.component),v=e.computed(()=>{const i=E.value;if(!i)return[];const a=i.columns.map(r=>r.headerStyle?.align??r.headerAlign??i.headerStyle?.align??i.headerAlign??r.style?.align??"center");if(i.headerGrid&&k())for(const r of b.resolveGridLayout(i.headerGrid,i.widthMm,100).cells)for(let d=r.ci;d<r.ci+(r.cell.colSpan??1);d++)a[d]=r.cell.style?.align??"left";return a}),f=e.computed(()=>{const i=o.value.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);return(E.value?.columns??[]).flatMap((a,r)=>{const d=`${a.header} ${a.field}`.toLocaleLowerCase();return i.every(V=>d.includes(V))?[{column:a,index:r}]:[]})});function y(i,a){h.value=a?[...new Set([...h.value,i])]:h.value.filter(r=>r!==i)}function _(i){for(const a of f.value)y(a.index,i)}function p(){h.value=[]}function w(i,a,r){if(!s())return;const d=E.value?.columns[i];d&&(Object.assign(d,{[a]:a==="widthMm"?Number(r):r}),a==="header"&&R(i,String(r)),a==="headerAlign"&&C(i,r),a==="widthMm"&&J(),g())}function J(){const i=T.value[m.value];if(!i)return;const a=i.component,r=u.value.template.pages[i.pageIndex],d=a.columns.map(V=>V.widthMm);a.headerGrid&&(a.headerGrid.colWidthsMm=d),r.layout==="wide"&&d.every(V=>Number.isFinite(V)&&V>0)&&(a.widthMm=d.reduce((V,t)=>V+t,0),r.widthMm=Math.max(...r.components.map(V=>V.leftMm+V.widthMm))+(r.marginRightMm??0))}function R(i,a){const r=E.value;if(!r?.headerGrid)return;const V=b.resolveGridLayout(r.headerGrid,r.widthMm,100).cells.filter(({ci:t,cell:B})=>t<=i&&t+(B.colSpan??1)>i).slice(-1)[0];V&&(Object.assign(V.cell,{text:a,rawText:a,value:a}),r.columns.slice(V.ci,V.ci+(V.cell.colSpan??1)).forEach(t=>{t.header=a}))}function C(i,a){const r=E.value,d=r?.columns[i];if(d?.headerStyle?.align!==void 0&&(d.headerStyle={...d.headerStyle,align:a}),!r?.headerGrid)return;const t=b.resolveGridLayout(r.headerGrid,r.widthMm,100).cells.filter(({ci:B,cell:x})=>B<=i&&B+(x.colSpan??1)>i).slice(-1)[0];t&&(t.cell.style={...t.cell.style,align:a},r.columns.slice(t.ci,t.ci+(t.cell.colSpan??1)).forEach(B=>{B.headerAlign=a,B.headerStyle?.align!==void 0&&(B.headerStyle={...B.headerStyle,align:a})}))}function A(i,a){if(!(!s()||i==="headerAlign"&&a==="auto")){for(const r of h.value){const d=E.value?.columns[r];d&&(Object.assign(d,{[i]:a}),i==="headerAlign"&&C(r,a))}g()}}return{selected:m,query:o,selectedColumns:h,lists:T,activeList:E,headerAlignments:v,visibleColumns:f,toggleColumn:y,selectVisible:_,clearSelection:p,setColumn:w,alignColumns:A}}function Z(u,k={entries:100,bytes:16*1024*1024}){const s=e.ref([u]),g=e.ref(0),m=e.computed(()=>g.value>0),o=e.computed(()=>g.value+1<s.value.length),h=e.computed(()=>s.value[g.value]);function T(f){s.value=[f],g.value=0}function E(f){if(s.value[g.value]===f)return;const y=s.value.slice(0,g.value+1);y.push(f);let _=y.reduce((p,w)=>p+w.length*2,0);for(;y.length>1&&(y.length>k.entries||_>k.bytes);)_-=y.shift().length*2;s.value=y,g.value=s.value.length-1}function v(f){if(!(f<0?!m.value:!o.value))return g.value+=f,s.value[g.value]}return{canUndo:m,canRedo:o,current:h,reset:T,record:E,move:v}}function ee(u){const k=e.shallowRef(null),s=e.ref(!1);let g,m=0;function o(E){g?.(E),g=void 0,k.value=null}function h(){m++,o(!1),s.value=!1}async function T(E){h();const v=m,f=u();s.value=!0;try{const y=await new Promise((_,p)=>{if(g=_,!f){k.value=E;return}Promise.resolve().then(()=>m===v?f(E):!1).then(w=>{m===v&&o(w===!0)},w=>{m===v&&(g=void 0,k.value=null,p(w))})});return m===v&&y===!0}finally{m===v&&(s.value=!1)}}return e.onBeforeUnmount(h),{confirmation:k,pending:s,decide:o,request:T,cancel:h}}const te={title:"报表模板属性编辑器",heading:"模板属性",unpublished:"未发布",dirty:"有未保存修改",reset:"恢复草稿",saving:"正在保存…",save:"保存草稿",name:"模板名称",description:"说明",area:"明细区域",page:"页",header:"表头",field:"业务字段",width:"列宽(mm)",semantic:"字段语义",identifier:"编号",dimension:"分类",measure:"数值",date:"日期",text:"文本",bodyAlign:"正文对齐",headerAlign:"表头对齐",auto:"按字段语义",left:"居左",center:"居中",right:"居右",justify:"两端对齐",editable:"允许编辑",json:"完整模板 JSON",applyJson:"校验并应用 JSON",note:"字段映射应与数据源契约一致。此编辑器维护模板属性;保存由接入方提供的版本服务处理。",invalid:"请先修正模板错误,再预览或保存。"},ne={undo:"撤销",redo:"重做",columnsSearch:"搜索列名或字段",columnsSelected:"已选列",selectVisible:"选择当前结果",clearSelection:"清除选择",noColumns:"没有匹配的列",batchBody:"批量正文对齐",batchHeader:"批量表头对齐",chooseAlignment:"选择对齐方式",discardTitle:"保留当前修改?",discardDescription:"当前包含未保存的属性或尚未应用的 JSON,继续将丢弃这些修改。",keepEditing:"继续编辑",discard:"丢弃修改并继续",jsonPending:"JSON 尚未应用。请先校验并应用,或撤销 JSON 修改后继续属性编辑与保存。",fieldsSection:"字段",templateSection:"模板",advancedSection:"高级",sectionsLabel:"模板设置分区",columnDirectory:"字段目录",columnProperties:"字段属性",selectColumn:"选择字段",clearSearch:"清除搜索",fieldsCount:"个字段",templateDetails:"模板信息",advancedTitle:"完整配置",advancedDescription:"用于批量迁移或配置复杂模板。应用前会校验;未应用的内容会受到草稿保护。",templateIdentity:"模板标识",templateRevision:"当前修订",readonly:"只读",ready:"可编辑",previewTitle:"实时预览"},X={...te,...ne};function le(u,k){const s=e.ref(b.parseReportTemplate(u.modelValue)),g=e.ref(b.serializeReportTemplate(s.value)),m=e.ref(b.serializeReportTemplate(s.value)),o=e.ref(""),h=e.ref(!1),T=e.computed(()=>({...X,...u.messages})),E=e.computed(()=>({showExport:!1,showPrint:!1,showPdfWindow:!1,...u.preview,theme:{shellBg:"#f1f5f9",shellFg:"#334155",toolbarBg:"#ffffff",toolbarBorder:"#e2e8f0",toolbarFg:"#334155",btnFg:"#475569",btnBorder:"#cbd5e1",btnHoverBg:"#eff6ff",btnHoverFg:"#1d4ed8",btnActiveBg:"#2563eb",...u.preview?.theme}}));W.provideMachReportConfig({get defaults(){return E.value}});let v,f=0;const y=e.computed(()=>b.validateReportTemplateDocument(s.value)),_=e.computed(()=>{try{return b.serializeReportTemplate(s.value)!==g.value}catch{return!0}}),p=e.ref(m.value),w=e.computed(()=>m.value!==p.value),J=e.computed(()=>_.value||m.value!==p.value),R=()=>JSON.stringify({document:s.value,json:m.value,appliedJson:p.value}),C=Z(R()),A=ee(()=>u.beforeDiscard),i=e.computed(()=>h.value||A.pending.value),a=()=>!u.readonly&&!i.value&&!w.value,r=Y(s,()=>y.value.ok,a,O),{selected:d,lists:V,activeList:t,headerAlignments:B,setColumn:x}=r;e.watch(d,()=>r.clearSelection());const $=e.computed(()=>y.value.ok?W.createLocalFetcher({draft:{template:s.value.template,datasets:u.datasets??{},params:[]}}):void 0);function N(){f++,v?.abort(),v=void 0,h.value=!1}let j=0;async function M(n="replace",l){if(!J.value)return!0;const c=R();try{return await A.request({reason:n,document:JSON.parse(JSON.stringify(s.value)),replacement:l?b.parseReportTemplate(l):void 0,pendingLocalChanges:!0})&&c===R()}catch(D){return o.value=D instanceof Error?D.message:String(D),!1}}function G(n){N(),s.value=n,g.value=b.serializeReportTemplate(n),m.value=g.value,p.value=m.value,o.value="",d.value=0,r.clearSelection(),C.reset(R())}e.watch(()=>u.modelValue,async n=>{let l;try{l=b.parseReportTemplate(n)}catch(D){o.value=D instanceof Error?D.message:String(D);return}try{if(b.serializeReportTemplate(l)===b.serializeReportTemplate(s.value))return}catch{}const c=++j;if(N(),!await M("replace",l)){c===j&&y.value.ok&&k("update:modelValue",b.parseReportTemplate(s.value));return}c===j&&G(l)}),e.onBeforeUnmount(()=>{j++,N()});function O(){A.cancel(),o.value="",y.value.ok&&(m.value=b.serializeReportTemplate(s.value),p.value=m.value,k("update:modelValue",b.parseReportTemplate(s.value))),C.record(R())}function H(n){a()&&(s.value.name=n,O())}function P(n){a()&&(s.value.description=n,O())}function L(){if(!(u.readonly||i.value))try{const n=b.parseReportTemplate(m.value);if(n.id!==s.value.id)throw new Error("属性编辑不允许更换模板 ID,请另存为新模板");if(n.revision!==s.value.revision)throw new Error("修订号由保存服务管理,不能在 JSON 中修改");s.value=n,d.value=0,r.clearSelection(),O()}catch(n){o.value=n instanceof Error?n.message:String(n)}}async function q(){i.value||u.readonly||!await M("reset")||(G(b.parseReportTemplate(g.value)),k("update:modelValue",b.parseReportTemplate(s.value)))}function z(n){if(i.value||u.readonly)return;C.record(R());const l=C.move(n);if(!l)return;A.cancel();const c=JSON.parse(l);s.value=c.document,m.value=c.json,p.value=c.appliedJson,o.value="",d.value=0,r.clearSelection(),y.value.ok&&k("update:modelValue",b.parseReportTemplate(s.value))}async function U(){if(!u.save||!a()||!y.value.ok)return;const n=++f;v=new AbortController,h.value=!0,o.value="";const l=b.parseReportTemplate(s.value);try{const c=b.parseReportTemplate(await u.save(l,{expectedRevision:l.revision,signal:v.signal}));if(n!==f)return;if(c.id!==l.id)throw new Error("保存服务返回了其他模板的文档");s.value=c,g.value=b.serializeReportTemplate(c),m.value=g.value,p.value=m.value,C.reset(R()),k("saved",b.parseReportTemplate(c)),k("update:modelValue",b.parseReportTemplate(c))}catch(c){n===f&&(o.value=c instanceof Error?c.message:String(c))}finally{n===f&&(h.value=!1,v=void 0)}}const K=e.computed(()=>C.canUndo.value||R()!==C.current.value),S=e.computed(()=>C.canRedo.value&&R()===C.current.value);return{...r,canUndo:K,canRedo:S,undo:()=>z(-1),redo:()=>z(1),pendingLocalChanges:J,jsonPending:w,blocked:i,confirmation:A.confirmation,decideDiscard:A.decide,guardChanges:M,draft:s,json:m,selected:d,error:o,saving:h,dirty:_,validation:y,lists:V,activeList:t,headerAlignments:B,previewOptions:E,fetcher:$,messages:T,setName:H,setDescription:P,setColumn:x,applyJson:L,reset:q,save:U}}function oe(u,k,s,g){const m=e.ref("fields"),o=e.ref(u.value[0]?.index??-1),h=e.computed(()=>{const v=s.value?.columns[o.value];return v?{column:v,index:o.value}:void 0});e.watch(g,()=>{u.value.some(v=>v.index===o.value)||(o.value=u.value[0]?.index??-1)}),e.watch(k,()=>{o.value=u.value[0]?.index??-1}),e.watch(s,v=>{v?.columns[o.value]||(o.value=u.value[0]?.index??-1)});function T(v){u.value.some(f=>f.index===v)&&(o.value=v)}function E(v){const f=u.value;if(!f.length)return;const y=Math.max(0,f.findIndex(w=>w.index===o.value)),p={ArrowDown:Math.min(y+1,f.length-1),ArrowUp:Math.max(y-1,0),Home:0,End:f.length-1}[v];if(p!==void 0)return o.value=f[p].index,o.value}return{section:m,activeIndex:o,activeColumn:h,activate:T,moveColumn:E}}const re=["aria-label","aria-busy"],ae={class:"mr-designer-bar"},ie={class:"mr-designer-heading"},se={class:"mr-designer-actions"},ue={class:"mr-designer-history"},ce=["aria-label","title","disabled"],de=["aria-label","title","disabled"],me=["disabled"],fe=["disabled"],pe=["aria-label"],ve={class:"mr-designer-body"},ge={class:"mr-designer-inspector"},ye=["aria-label"],he=["id","aria-selected","aria-controls","tabindex","onClick"],be=["id","aria-labelledby"],Ee={key:0,class:"mr-designer-area"},Se=["value"],Ve={key:1,class:"mr-designer-columns"},Ne={class:"mr-designer-directory-heading"},ke={class:"mr-designer-search"},_e=["aria-label","placeholder"],De=["aria-label","title"],Ce={class:"mr-designer-column-tools"},Te=["disabled"],we={key:1,role:"status"},Be={key:2},xe=["aria-label"],Re=["aria-label","checked","disabled","onChange"],Me=["data-column-index","aria-pressed","tabindex","onClick"],Ae={class:"mr-designer-column-number"},je={class:"mr-designer-column-name"},Le={key:0,role:"status",class:"mr-designer-empty"},$e={key:0,class:"mr-designer-batch"},Oe=["aria-label","disabled"],Ie={value:""},Je={value:"auto"},Pe={value:"left"},ze={value:"center"},Fe={value:"right"},Ge={value:"justify"},He=["aria-label","disabled"],qe={value:""},Ue={value:"left"},Ke={value:"center"},We={value:"right"},Qe={value:"justify"},Xe=["disabled"],Ye=["value"],Ze=["value"],et=["value"],tt=["value"],nt={value:"identifier"},lt={value:"dimension"},ot={value:"measure"},rt={value:"date"},at={value:"text"},it=["value"],st={value:"auto"},ut={value:"left"},ct={value:"center"},dt={value:"right"},mt={value:"justify"},ft=["value"],pt={value:"left"},vt={value:"center"},gt={value:"right"},yt={value:"justify"},ht={class:"mr-designer-toggle"},bt=["checked"],Et={key:2,role:"status",class:"mr-designer-empty"},St={class:"mr-designer-stacked"},Vt=["value","disabled"],Nt={class:"mr-designer-stacked"},kt=["value","disabled"],_t={class:"mr-designer-identity"},Dt={class:"mr-designer-note"},Ct={class:"mr-designer-note"},Tt={class:"mr-designer-stacked"},wt=["aria-label","disabled"],Bt=["disabled"],xt={key:3,role:"status",class:"mr-designer-note mr-designer-pending"},Rt=["aria-label"],Mt={key:0,role:"alert",class:"mr-designer-error"},At={key:1,role:"alert",class:"mr-designer-error"},jt={key:3,class:"mr-designer-note mr-designer-invalid"},Lt=e.defineComponent({__name:"ReportTemplateEditor",props:{modelValue:{},datasets:{},readonly:{type:Boolean},messages:{},preview:{},beforeDiscard:{type:Function},save:{type:Function}},emits:["update:modelValue","saved"],setup(u,{expose:k,emit:s}){const g=u,m=s,o=le(g,(S,n)=>{m(S==="saved"?"saved":"update:modelValue",n)}),{draft:h,json:T,selected:E,error:v,saving:f,pendingLocalChanges:y,jsonPending:_,blocked:p,confirmation:w,canUndo:J,canRedo:R,validation:C,lists:A,activeList:i,visibleColumns:a,query:r,selectedColumns:d,fetcher:V,messages:t}=o,B=oe(a,E,i,r),{section:x,activeIndex:$,activeColumn:N}=B,j=`mr-designer-${e.getCurrentInstance()?.uid??0}`,M=["fields","template","advanced"],G=e.computed(()=>f.value?t.value.saving:g.readonly?t.value.readonly:y.value?t.value.dirty:t.value.ready),O=e.ref(null),H=e.ref(null);e.watch(x,async S=>{if(S!=="fields")return;await e.nextTick();const n=H.value,l=n?.querySelector(`button[data-column-index="${$.value}"]`);if(!n||!l)return;const c=n.getBoundingClientRect(),D=l.getBoundingClientRect(),F=c.top+n.clientTop,Q=F+n.clientHeight;D.top<F?n.scrollTop+=D.top-F:D.bottom>Q&&(n.scrollTop+=D.bottom-Q)});let P=null;e.watch(w,async S=>{S?(P=document.activeElement,await e.nextTick(),O.value?.focus()):(await e.nextTick(),P?.isConnected&&P.focus(),P=null)}),k({get pendingLocalChanges(){return y.value},get saving(){return f.value},get blocked(){return p.value},guardChanges:o.guardChanges,reset:o.reset,save:o.save});function L(S){return S.target.value}function q(S){return S.target.checked}function z(S,n){const l=S.target;o.alignColumns(n,l.value),l.value=""}async function U(S){const n=B.moveColumn(S.key);if(n===void 0)return;S.preventDefault();const l=S.currentTarget.closest(".mr-designer-column-list");await e.nextTick();const c=l?.querySelector(`button[data-column-index="${n}"]`);c?.focus({preventScroll:!0}),c?.scrollIntoView({block:"nearest"})}async function K(S){const l={ArrowRight:1,ArrowLeft:-1,Home:-M.length,End:M.length}[S.key];if(l===void 0)return;S.preventDefault();const c=M.indexOf(x.value),D=S.key==="Home"?0:S.key==="End"?M.length-1:(c+l+M.length)%M.length;x.value=M[D];const F=S.currentTarget.parentElement;await e.nextTick(),F?.querySelector(`#${j}-tab-${x.value}`)?.focus()}return(S,n)=>(e.openBlock(),e.createElementBlock("section",{class:"mr-designer","aria-label":e.unref(t).title,"aria-busy":e.unref(f)},[e.createElementVNode("header",ae,[e.createElementVNode("div",ie,[e.createVNode(I._sfc_main,{name:"columns",size:18}),e.createElementVNode("div",null,[e.createElementVNode("strong",null,e.toDisplayString(e.unref(t).heading),1),e.createElementVNode("span",{class:e.normalizeClass({"mr-designer-dirty":e.unref(y)})},e.toDisplayString(G.value),3)])]),e.createElementVNode("div",se,[e.createElementVNode("div",ue,[e.createElementVNode("button",{type:"button",class:"mr-designer-icon-button","aria-label":e.unref(t).undo,title:e.unref(t).undo,disabled:u.readonly||e.unref(p)||!e.unref(J),onClick:n[0]||(n[0]=(...l)=>e.unref(o).undo&&e.unref(o).undo(...l))},[...n[25]||(n[25]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 10h10a6 6 0 0 1 0 12M4 10l5-5M4 10l5 5"})],-1)])],8,ce),e.createElementVNode("button",{type:"button",class:"mr-designer-icon-button","aria-label":e.unref(t).redo,title:e.unref(t).redo,disabled:u.readonly||e.unref(p)||!e.unref(R),onClick:n[1]||(n[1]=(...l)=>e.unref(o).redo&&e.unref(o).redo(...l))},[...n[26]||(n[26]=[e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M20 10H10a6 6 0 0 0 0 12m10-12-5-5m5 5-5 5"})],-1)])],8,de)]),e.createElementVNode("button",{type:"button",class:"mr-designer-reset",disabled:u.readonly||e.unref(p)||!e.unref(y),onClick:n[2]||(n[2]=(...l)=>e.unref(o).reset&&e.unref(o).reset(...l))},e.toDisplayString(e.unref(t).reset),9,me),u.save?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mr-designer-save",disabled:u.readonly||e.unref(p)||e.unref(_)||!e.unref(C).ok||!e.unref(y),onClick:n[3]||(n[3]=(...l)=>e.unref(o).save&&e.unref(o).save(...l))},[e.createVNode(I._sfc_main,{name:"file",size:14}),e.createTextVNode(e.toDisplayString(e.unref(f)?e.unref(t).saving:e.unref(t).save),1)],8,fe)):e.createCommentVNode("",!0)])]),e.unref(w)?(e.openBlock(),e.createElementBlock("div",{key:0,role:"alertdialog","aria-label":e.unref(t).discardTitle,class:"mr-designer-confirm",onKeydown:n[6]||(n[6]=e.withKeys(e.withModifiers(l=>e.unref(o).decideDiscard(!1),["prevent"]),["esc"]))},[e.createElementVNode("div",null,[e.createElementVNode("strong",null,e.toDisplayString(e.unref(t).discardTitle),1),e.createElementVNode("p",null,e.toDisplayString(e.unref(t).discardDescription),1)]),e.createElementVNode("div",null,[e.createElementVNode("button",{ref_key:"keepButton",ref:O,type:"button",onClick:n[4]||(n[4]=l=>e.unref(o).decideDiscard(!1))},e.toDisplayString(e.unref(t).keepEditing),513),e.createElementVNode("button",{type:"button",onClick:n[5]||(n[5]=l=>e.unref(o).decideDiscard(!0))},e.toDisplayString(e.unref(t).discard),1)])],40,pe)):e.createCommentVNode("",!0),e.createElementVNode("div",ve,[e.createElementVNode("aside",ge,[e.createElementVNode("nav",{class:"mr-designer-tabs",role:"tablist","aria-label":e.unref(t).sectionsLabel},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(M,l=>e.createElementVNode("button",{id:`${j}-tab-${l}`,key:l,type:"button",role:"tab","aria-selected":e.unref(x)===l,"aria-controls":`${j}-panel-${l}`,tabindex:e.unref(x)===l?0:-1,onClick:c=>x.value=l,onKeydown:K},e.toDisplayString(e.unref(t)[`${l}Section`]),41,he)),64))],8,ye),e.createElementVNode("div",{id:`${j}-panel-${e.unref(x)}`,class:"mr-designer-panel",role:"tabpanel","aria-labelledby":`${j}-tab-${e.unref(x)}`},[e.unref(x)==="fields"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.unref(A).length>1?(e.openBlock(),e.createElementBlock("label",Ee,[e.createTextVNode(e.toDisplayString(e.unref(t).area),1),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":n[7]||(n[7]=l=>e.isRef(E)?E.value=l:null)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(A),(l,c)=>(e.openBlock(),e.createElementBlock("option",{key:c,value:c},e.toDisplayString(l.pageIndex+1)+" "+e.toDisplayString(e.unref(t).page)+" · "+e.toDisplayString(l.component.title||l.component.dataset),9,Se))),128))],512),[[e.vModelSelect,e.unref(E)]])])):e.createCommentVNode("",!0),e.unref(i)?(e.openBlock(),e.createElementBlock("div",Ve,[e.createElementVNode("div",Ne,[e.createElementVNode("strong",null,e.toDisplayString(e.unref(t).columnDirectory),1),e.createElementVNode("span",null,e.toDisplayString(e.unref(i).columns.length)+" "+e.toDisplayString(e.unref(t).fieldsCount),1)]),e.createElementVNode("div",ke,[e.createVNode(I._sfc_main,{name:"search",size:15}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":n[8]||(n[8]=l=>e.isRef(r)?r.value=l:null),type:"search","aria-label":e.unref(t).columnsSearch,placeholder:e.unref(t).columnsSearch},null,8,_e),[[e.vModelText,e.unref(r)]]),e.unref(r)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"mr-designer-icon-button","aria-label":e.unref(t).clearSearch,title:e.unref(t).clearSearch,onClick:n[9]||(n[9]=l=>r.value="")},[e.createVNode(I._sfc_main,{name:"close",size:14})],8,De)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Ce,[e.createElementVNode("button",{type:"button",disabled:u.readonly||e.unref(p)||e.unref(_)||!e.unref(a).length,onClick:n[10]||(n[10]=l=>e.unref(o).selectVisible(!0))},e.toDisplayString(e.unref(t).selectVisible),9,Te),e.unref(d).length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",onClick:n[11]||(n[11]=(...l)=>e.unref(o).clearSelection&&e.unref(o).clearSelection(...l))},e.toDisplayString(e.unref(t).clearSelection),1)):e.createCommentVNode("",!0),e.unref(d).length?(e.openBlock(),e.createElementBlock("span",we,e.toDisplayString(e.unref(t).columnsSelected)+" "+e.toDisplayString(e.unref(d).length),1)):(e.openBlock(),e.createElementBlock("span",Be,e.toDisplayString(e.unref(a).length)+" / "+e.toDisplayString(e.unref(i).columns.length),1))]),e.createElementVNode("div",{ref_key:"columnList",ref:H,class:"mr-designer-column-list","aria-label":e.unref(t).columnDirectory,role:"group"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a),({column:l,index:c})=>(e.openBlock(),e.createElementBlock("div",{key:c,class:e.normalizeClass(["mr-designer-column-row",{"is-active":e.unref($)===c}])},[e.createElementVNode("input",{type:"checkbox","aria-label":`${e.unref(t).selectColumn} ${l.header}`,checked:e.unref(d).includes(c),disabled:u.readonly||e.unref(p)||e.unref(_),onChange:D=>e.unref(o).toggleColumn(c,q(D))},null,40,Re),e.createElementVNode("button",{type:"button","data-column-index":c,"aria-pressed":e.unref($)===c,tabindex:e.unref($)===c?0:-1,onClick:D=>e.unref(B).activate(c),onKeydown:U},[e.createElementVNode("span",Ae,e.toDisplayString(c+1),1),e.createElementVNode("span",je,[e.createElementVNode("strong",null,e.toDisplayString(l.header),1),e.createElementVNode("small",null,e.toDisplayString(l.field),1)]),e.unref($)===c?(e.openBlock(),e.createBlock(I._sfc_main,{key:0,name:"chevron-right",size:14})):e.createCommentVNode("",!0)],40,Me)],2))),128)),e.unref(a).length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",Le,[e.createVNode(I._sfc_main,{name:"search",size:20}),e.createTextVNode(e.toDisplayString(e.unref(t).noColumns),1)]))],8,xe),e.unref(d).length?(e.openBlock(),e.createElementBlock("div",$e,[e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).batchBody),1),e.createElementVNode("select",{"aria-label":e.unref(t).batchBody,disabled:u.readonly||e.unref(p)||e.unref(_),onChange:n[12]||(n[12]=l=>z(l,"align"))},[e.createElementVNode("option",Ie,e.toDisplayString(e.unref(t).chooseAlignment),1),e.createElementVNode("option",Je,e.toDisplayString(e.unref(t).auto),1),e.createElementVNode("option",Pe,e.toDisplayString(e.unref(t).left),1),e.createElementVNode("option",ze,e.toDisplayString(e.unref(t).center),1),e.createElementVNode("option",Fe,e.toDisplayString(e.unref(t).right),1),e.createElementVNode("option",Ge,e.toDisplayString(e.unref(t).justify),1)],40,Oe)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).batchHeader),1),e.createElementVNode("select",{"aria-label":e.unref(t).batchHeader,disabled:u.readonly||e.unref(p)||e.unref(_),onChange:n[13]||(n[13]=l=>z(l,"headerAlign"))},[e.createElementVNode("option",qe,e.toDisplayString(e.unref(t).chooseAlignment),1),e.createElementVNode("option",Ue,e.toDisplayString(e.unref(t).left),1),e.createElementVNode("option",Ke,e.toDisplayString(e.unref(t).center),1),e.createElementVNode("option",We,e.toDisplayString(e.unref(t).right),1),e.createElementVNode("option",Qe,e.toDisplayString(e.unref(t).justify),1)],40,He)])])):e.createCommentVNode("",!0),e.unref(N)?(e.openBlock(),e.createElementBlock("fieldset",{key:1,class:"mr-designer-properties",disabled:u.readonly||e.unref(p)||e.unref(_)},[e.createElementVNode("legend",null,[e.createTextVNode(e.toDisplayString(e.unref(t).columnProperties)+" ",1),e.createElementVNode("span",null,e.toDisplayString(e.unref(N).index+1)+" · "+e.toDisplayString(e.unref(N).column.header),1)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).header),1),e.createElementVNode("input",{value:e.unref(N).column.header,onInput:n[14]||(n[14]=l=>e.unref(o).setColumn(e.unref(N).index,"header",L(l)))},null,40,Ye)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).field),1),e.createElementVNode("input",{value:e.unref(N).column.field,onChange:n[15]||(n[15]=l=>e.unref(o).setColumn(e.unref(N).index,"field",L(l)))},null,40,Ze)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).width),1),e.createElementVNode("input",{type:"number",min:"0.1",step:"0.5",value:e.unref(N).column.widthMm,onChange:n[16]||(n[16]=l=>e.unref(o).setColumn(e.unref(N).index,"widthMm",L(l)))},null,40,et)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).semantic),1),e.createElementVNode("select",{value:e.unref(N).column.semanticRole||"text",onChange:n[17]||(n[17]=l=>e.unref(o).setColumn(e.unref(N).index,"semanticRole",L(l)))},[e.createElementVNode("option",nt,e.toDisplayString(e.unref(t).identifier),1),e.createElementVNode("option",lt,e.toDisplayString(e.unref(t).dimension),1),e.createElementVNode("option",ot,e.toDisplayString(e.unref(t).measure),1),e.createElementVNode("option",rt,e.toDisplayString(e.unref(t).date),1),e.createElementVNode("option",at,e.toDisplayString(e.unref(t).text),1)],40,tt)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).bodyAlign),1),e.createElementVNode("select",{value:e.unref(N).column.align??e.unref(N).column.style?.align??e.unref(i).align??"left",onChange:n[18]||(n[18]=l=>e.unref(o).setColumn(e.unref(N).index,"align",L(l)))},[e.createElementVNode("option",st,e.toDisplayString(e.unref(t).auto),1),e.createElementVNode("option",ut,e.toDisplayString(e.unref(t).left),1),e.createElementVNode("option",ct,e.toDisplayString(e.unref(t).center),1),e.createElementVNode("option",dt,e.toDisplayString(e.unref(t).right),1),e.createElementVNode("option",mt,e.toDisplayString(e.unref(t).justify),1)],40,it)]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(t).headerAlign),1),e.createElementVNode("select",{value:e.unref(o).headerAlignments.value[e.unref(N).index],onChange:n[19]||(n[19]=l=>e.unref(o).setColumn(e.unref(N).index,"headerAlign",L(l)))},[e.createElementVNode("option",pt,e.toDisplayString(e.unref(t).left),1),e.createElementVNode("option",vt,e.toDisplayString(e.unref(t).center),1),e.createElementVNode("option",gt,e.toDisplayString(e.unref(t).right),1),e.createElementVNode("option",yt,e.toDisplayString(e.unref(t).justify),1)],40,ft)]),e.createElementVNode("label",ht,[e.createTextVNode(e.toDisplayString(e.unref(t).editable),1),e.createElementVNode("input",{type:"checkbox",checked:e.unref(N).column.editable===!0,onChange:n[20]||(n[20]=l=>e.unref(o).setColumn(e.unref(N).index,"editable",q(l)))},null,40,bt)])],8,Xe)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("p",Et,e.toDisplayString(e.unref(t).noColumns),1))],64)):e.unref(x)==="template"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("h3",null,e.toDisplayString(e.unref(t).templateDetails),1),e.createElementVNode("label",St,[e.createTextVNode(e.toDisplayString(e.unref(t).name),1),e.createElementVNode("input",{value:e.unref(h).name,disabled:u.readonly||e.unref(p)||e.unref(_),onInput:n[21]||(n[21]=l=>e.unref(o).setName(L(l)))},null,40,Vt)]),e.createElementVNode("label",Nt,[e.createTextVNode(e.toDisplayString(e.unref(t).description),1),e.createElementVNode("textarea",{rows:"4",value:e.unref(h).description,disabled:u.readonly||e.unref(p)||e.unref(_),onInput:n[22]||(n[22]=l=>e.unref(o).setDescription(L(l)))},null,40,kt)]),e.createElementVNode("dl",_t,[e.createElementVNode("dt",null,e.toDisplayString(e.unref(t).templateIdentity),1),e.createElementVNode("dd",null,e.toDisplayString(e.unref(h).id),1),e.createElementVNode("dt",null,e.toDisplayString(e.unref(t).templateRevision),1),e.createElementVNode("dd",null,e.toDisplayString(e.unref(h).revision||e.unref(t).unpublished),1)]),e.createElementVNode("p",Dt,e.toDisplayString(e.unref(t).note),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("h3",null,e.toDisplayString(e.unref(t).advancedTitle),1),e.createElementVNode("p",Ct,e.toDisplayString(e.unref(t).advancedDescription),1),e.createElementVNode("label",Tt,[e.createTextVNode(e.toDisplayString(e.unref(t).json),1),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":n[23]||(n[23]=l=>e.isRef(T)?T.value=l:null),class:"mr-designer-json","aria-label":e.unref(t).json,disabled:u.readonly||e.unref(p),spellcheck:"false"},null,8,wt),[[e.vModelText,e.unref(T)]])]),e.createElementVNode("button",{type:"button",class:"mr-designer-apply-json",disabled:u.readonly||e.unref(p),onClick:n[24]||(n[24]=(...l)=>e.unref(o).applyJson&&e.unref(o).applyJson(...l))},e.toDisplayString(e.unref(t).applyJson),9,Bt)],64)),e.unref(_)?(e.openBlock(),e.createElementBlock("p",xt,e.toDisplayString(e.unref(t).jsonPending),1)):e.createCommentVNode("",!0)],8,be)]),e.createElementVNode("div",{class:"mr-designer-preview","aria-label":e.unref(t).previewTitle},[e.unref(v)?(e.openBlock(),e.createElementBlock("div",Mt,e.toDisplayString(e.unref(v)),1)):e.createCommentVNode("",!0),e.unref(C).ok?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("ul",At,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(C).errors,l=>(e.openBlock(),e.createElementBlock("li",{key:l.path},e.toDisplayString(l.path)+":"+e.toDisplayString(l.message),1))),128))])),e.unref(V)&&e.unref(C).ok?(e.openBlock(),e.createBlock(e.unref(W.ReportPreview),{key:2,"report-id":"draft",fetcher:e.unref(V),"show-params":!1,editable:!1,"excel-import":!1,height:"100%"},null,8,["fetcher"])):(e.openBlock(),e.createElementBlock("p",jt,e.toDisplayString(e.unref(t).invalid),1))],8,Rt)])],8,re))}}),$t=I._export_sfc(Lt,[["__scopeId","data-v-8bbff75e"]]);exports.ReportTemplateEditor=$t;exports.TEMPLATE_EDITOR_MESSAGES=X;
@@ -552,6 +552,23 @@ declare const PRODUCT_TEMPLATE_EDITOR_MESSAGES: {
552
552
  keepEditing: string;
553
553
  discard: string;
554
554
  jsonPending: string;
555
+ fieldsSection: string;
556
+ templateSection: string;
557
+ advancedSection: string;
558
+ sectionsLabel: string;
559
+ columnDirectory: string;
560
+ columnProperties: string;
561
+ selectColumn: string;
562
+ clearSearch: string;
563
+ fieldsCount: string;
564
+ templateDetails: string;
565
+ advancedTitle: string;
566
+ advancedDescription: string;
567
+ templateIdentity: string;
568
+ templateRevision: string;
569
+ readonly: string;
570
+ ready: string;
571
+ previewTitle: string;
555
572
  };
556
573
  /** Return false to keep the current report. Without a hook the preview asks inline. */
557
574
  declare type ReportBeforeDiscard = (context: Readonly<ReportBeforeDiscardContext>) => boolean | Promise<boolean>;
@@ -774,6 +791,8 @@ declare interface ReportTemplateDocument {
774
791
  }
775
792
  export declare const ReportTemplateEditor: DefineComponent<TemplateEditorOptions, {
776
793
  pendingLocalChanges: boolean;
794
+ saving: boolean;
795
+ blocked: boolean;
777
796
  guardChanges: (reason?: TemplateEditorBeforeDiscardContext["reason"], replacement?: ReportTemplateDocument) => Promise<boolean>;
778
797
  reset: () => Promise<void>;
779
798
  save: () => Promise<void>;
@@ -824,6 +843,23 @@ export declare const TEMPLATE_EDITOR_MESSAGES: {
824
843
  keepEditing: string;
825
844
  discard: string;
826
845
  jsonPending: string;
846
+ fieldsSection: string;
847
+ templateSection: string;
848
+ advancedSection: string;
849
+ sectionsLabel: string;
850
+ columnDirectory: string;
851
+ columnProperties: string;
852
+ selectColumn: string;
853
+ clearSearch: string;
854
+ fieldsCount: string;
855
+ templateDetails: string;
856
+ advancedTitle: string;
857
+ advancedDescription: string;
858
+ templateIdentity: string;
859
+ templateRevision: string;
860
+ readonly: string;
861
+ ready: string;
862
+ previewTitle: string;
827
863
  title: string;
828
864
  heading: string;
829
865
  unpublished: string;
@@ -868,6 +904,8 @@ export declare interface TemplateEditorBeforeDiscardContext {
868
904
  }
869
905
  export declare interface TemplateEditorController {
870
906
  readonly pendingLocalChanges: boolean;
907
+ readonly saving?: boolean;
908
+ readonly blocked?: boolean;
871
909
  guardChanges(reason?: TemplateEditorBeforeDiscardContext["reason"], replacement?: ReportTemplateDocument): Promise<boolean>;
872
910
  reset(): Promise<void>;
873
911
  save(): Promise<void>;
@@ -552,6 +552,23 @@ declare const PRODUCT_TEMPLATE_EDITOR_MESSAGES: {
552
552
  keepEditing: string;
553
553
  discard: string;
554
554
  jsonPending: string;
555
+ fieldsSection: string;
556
+ templateSection: string;
557
+ advancedSection: string;
558
+ sectionsLabel: string;
559
+ columnDirectory: string;
560
+ columnProperties: string;
561
+ selectColumn: string;
562
+ clearSearch: string;
563
+ fieldsCount: string;
564
+ templateDetails: string;
565
+ advancedTitle: string;
566
+ advancedDescription: string;
567
+ templateIdentity: string;
568
+ templateRevision: string;
569
+ readonly: string;
570
+ ready: string;
571
+ previewTitle: string;
555
572
  };
556
573
  /** Return false to keep the current report. Without a hook the preview asks inline. */
557
574
  declare type ReportBeforeDiscard = (context: Readonly<ReportBeforeDiscardContext>) => boolean | Promise<boolean>;
@@ -774,6 +791,8 @@ declare interface ReportTemplateDocument {
774
791
  }
775
792
  export declare const ReportTemplateEditor: DefineComponent<TemplateEditorOptions, {
776
793
  pendingLocalChanges: boolean;
794
+ saving: boolean;
795
+ blocked: boolean;
777
796
  guardChanges: (reason?: TemplateEditorBeforeDiscardContext["reason"], replacement?: ReportTemplateDocument) => Promise<boolean>;
778
797
  reset: () => Promise<void>;
779
798
  save: () => Promise<void>;
@@ -824,6 +843,23 @@ export declare const TEMPLATE_EDITOR_MESSAGES: {
824
843
  keepEditing: string;
825
844
  discard: string;
826
845
  jsonPending: string;
846
+ fieldsSection: string;
847
+ templateSection: string;
848
+ advancedSection: string;
849
+ sectionsLabel: string;
850
+ columnDirectory: string;
851
+ columnProperties: string;
852
+ selectColumn: string;
853
+ clearSearch: string;
854
+ fieldsCount: string;
855
+ templateDetails: string;
856
+ advancedTitle: string;
857
+ advancedDescription: string;
858
+ templateIdentity: string;
859
+ templateRevision: string;
860
+ readonly: string;
861
+ ready: string;
862
+ previewTitle: string;
827
863
  title: string;
828
864
  heading: string;
829
865
  unpublished: string;
@@ -868,6 +904,8 @@ export declare interface TemplateEditorBeforeDiscardContext {
868
904
  }
869
905
  export declare interface TemplateEditorController {
870
906
  readonly pendingLocalChanges: boolean;
907
+ readonly saving?: boolean;
908
+ readonly blocked?: boolean;
871
909
  guardChanges(reason?: TemplateEditorBeforeDiscardContext["reason"], replacement?: ReportTemplateDocument): Promise<boolean>;
872
910
  reset(): Promise<void>;
873
911
  save(): Promise<void>;