@agile-team/mach-report 2.11.0 → 2.11.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.
@@ -1,287 +0,0 @@
1
- import { ref as _, computed as k, watch as H, onBeforeUnmount as J, defineComponent as Q, openBlock as f, createElementBlock as b, unref as a, createElementVNode as o, toDisplayString as c, Fragment as z, renderList as W, normalizeClass as X, createVNode as Y, createCommentVNode as I, nextTick as G } from "vue";
2
- import { a as Z, R as ee } from "./config-B612mw0x.js";
3
- import { validateReportParams as j } from "@agile-team/mach-report";
4
- import { i as te, r as ae } from "./batch-mRqhhhjt.js";
5
- import { REPORT_BATCH_MESSAGES as ne } from "./designer.js";
6
- import { _ as le } from "./_plugin-vue_export-helper-8SL1F89S.js";
7
- function se(n) {
8
- const d = {};
9
- return !n || typeof n != "object" || (typeof n.instanceId == "string" && n.instanceId.length > 0 && n.instanceId.length <= 512 && (d.instanceId = n.instanceId), typeof n.label == "string" && (d.label = n.label.slice(0, 512))), d;
10
- }
11
- function ie(n) {
12
- return Object.fromEntries((Array.isArray(n) ? n : []).filter((d) => d && typeof d.field == "string").map((d) => [d.field, d.defaultValue ?? ""]));
13
- }
14
- function q(n) {
15
- return (n instanceof Error ? n.message : String(n)).slice(0, 1e3);
16
- }
17
- function re(n) {
18
- try {
19
- return { cases: te(n.initialCases ?? [], n.maxCases ?? 100), error: "" };
20
- } catch (d) {
21
- return { cases: [], error: q(d) };
22
- }
23
- }
24
- function ce(n) {
25
- let d = 0;
26
- const P = (t) => ({ key: ++d, item: { id: t.id, params: { ...t.params } }, status: "pending" }), M = re(n), u = _(M.cases.map(P)), l = _(!1), m = _(!1), A = _(!1), v = _(M.error), $ = _(), E = _({ completed: 0, total: 0, failed: 0, cancelled: 0 }), x = k(() => ({ ...ne, ...n.messages })), y = k(() => u.value.map((t) => j(n.paramDefs, t.item.params))), V = k(() => u.value.filter((t) => t.status === "failed").length), C = k(() => n.maxCases ?? 100);
27
- let g, i = 0;
28
- function S(t = ie(n.paramDefs)) {
29
- let e = d + 1;
30
- for (; u.value.some((s) => s.item.id === `case-${e}`); ) e++;
31
- return { id: `case-${e}`, params: { ...t } };
32
- }
33
- function R(t) {
34
- if (!(n.readonly || l.value)) {
35
- if (u.value.length >= C.value) {
36
- v.value = x.value.batchLimit.replace("{count}", String(C.value));
37
- return;
38
- }
39
- u.value.push(P(S(t?.item.params))), v.value = "";
40
- }
41
- }
42
- function K(t) {
43
- !l.value && !n.readonly && (u.value = u.value.filter((e) => e.key !== t));
44
- }
45
- function L(t, e) {
46
- if (l.value || n.readonly) return;
47
- const s = u.value.find((r) => r.key === t);
48
- s && (s.item.params = { ...e }, s.status = "pending", delete s.receipt, delete s.error);
49
- }
50
- function N() {
51
- l.value && (m.value = !0, g?.abort());
52
- }
53
- function T(t) {
54
- return u.value.filter((e) => !t || e.status === "failed");
55
- }
56
- function U(t) {
57
- const e = t.map((r) => j(n.paramDefs, r.item.params)), s = e.findIndex((r) => !r.ok);
58
- if (s >= 0) {
59
- $.value = t[s].key, v.value = x.value.batchInvalid;
60
- return;
61
- }
62
- return t.map((r, D) => ({ id: r.item.id, params: { ...e[D].values } }));
63
- }
64
- function O(t, e) {
65
- t.status = e.status, e.status === "completed" && (t.receipt = e.value), e.status === "failed" && (t.error = e.error.message.slice(0, 1e3));
66
- }
67
- async function w(t, e, s, r, D) {
68
- r === i && (t.status = "running");
69
- try {
70
- const h = se(await D(e, s));
71
- return r === i && (t.receipt = h, t.status = "completed"), h;
72
- } catch (h) {
73
- throw r === i && (t.status = s.signal.aborted ? "cancelled" : "failed", t.error = q(h)), h;
74
- }
75
- }
76
- async function p(t = !1) {
77
- if (n.readonly || l.value) return;
78
- const e = T(t);
79
- if (!e.length) return;
80
- A.value = !0, v.value = "", $.value = void 0;
81
- const s = U(e);
82
- if (!s) return;
83
- const r = ++i, D = n.execute;
84
- g = new AbortController(), l.value = !0, m.value = !1, E.value = { completed: 0, total: e.length, failed: 0, cancelled: 0 };
85
- for (const h of e)
86
- h.status = "pending", delete h.receipt, delete h.error;
87
- try {
88
- const h = await ae(s, (B, F) => w(e[F.index], B, F, r, D), {
89
- concurrency: n.concurrency,
90
- maxCases: C.value,
91
- signal: g.signal,
92
- onProgress: (B) => {
93
- r === i && (E.value = B);
94
- }
95
- });
96
- r === i && h.forEach((B, F) => O(e[F], B));
97
- } catch (h) {
98
- r === i && (v.value = q(h));
99
- } finally {
100
- r === i && (l.value = !1, m.value = !1, g = void 0);
101
- }
102
- }
103
- return H(() => [JSON.stringify(n.paramDefs), n.execute, n.readonly, n.concurrency, n.maxCases], () => {
104
- l.value && (N(), v.value = x.value.batchChanged);
105
- }), J(() => {
106
- i++, g?.abort();
107
- }), { m: x, rows: u, validations: y, running: l, cancelling: m, attempted: A, error: v, progress: E, failures: V, maximum: C, invalidKey: $, add: R, remove: K, setParams: L, cancel: N, run: p };
108
- }
109
- const oe = ["aria-label", "aria-busy"], ue = { class: "mr-batch__heading" }, de = ["disabled"], me = {
110
- key: 0,
111
- class: "mr-batch__empty"
112
- }, ve = {
113
- key: 1,
114
- class: "mr-batch__rows"
115
- }, fe = {
116
- class: "mr-batch__status",
117
- role: "status"
118
- }, be = { class: "mr-batch__row-actions" }, he = ["aria-label", "disabled", "onClick"], pe = ["aria-label", "disabled", "onClick"], ye = {
119
- key: 0,
120
- class: "mr-batch__row-error",
121
- role: "alert"
122
- }, ge = {
123
- key: 1,
124
- class: "mr-batch__receipt"
125
- }, _e = ["onClick"], ke = {
126
- key: 2,
127
- class: "mr-batch__error",
128
- role: "alert"
129
- }, Ce = {
130
- class: "mr-batch__progress",
131
- "aria-live": "polite"
132
- }, xe = ["value", "max", "aria-label"], Se = { key: 1 }, Re = { class: "mr-batch__actions" }, $e = ["disabled"], Ie = ["disabled"], Pe = ["disabled"], Ee = ["aria-label"], De = ["disabled"], Be = ["disabled"], Me = /* @__PURE__ */ Q({
133
- __name: "ReportBatchPanel",
134
- props: {
135
- paramDefs: {},
136
- execute: { type: Function },
137
- initialCases: {},
138
- readonly: { type: Boolean },
139
- concurrency: {},
140
- maxCases: {},
141
- messages: {},
142
- paramMessages: {}
143
- },
144
- emits: ["open-instance"],
145
- setup(n, { emit: d }) {
146
- const P = n, M = d, u = ce(P), { m: l, rows: m, validations: A, running: v, cancelling: $, attempted: E, error: x, progress: y, failures: V, maximum: C } = u, g = _(), i = _(1), S = 10, R = k(() => Math.max(1, Math.ceil(m.value.length / S))), K = k(() => m.value.slice((i.value - 1) * S, i.value * S).map((p, t) => ({ row: p, index: (i.value - 1) * S + t }))), L = k(() => l.value.batchPage.replace("{page}", String(i.value)).replace("{pages}", String(R.value)).replace("{total}", String(m.value.length)));
147
- H(R, (p) => {
148
- i.value = Math.min(i.value, p);
149
- });
150
- const N = k(() => ({ ...Z, ...P.paramMessages })), T = k(() => l.value.batchProgress.replace("{completed}", String(y.value.completed)).replace("{total}", String(y.value.total)).replace("{failed}", String(y.value.failed)).replace("{cancelled}", String(y.value.cancelled)));
151
- function U(p) {
152
- return { pending: l.value.batchPending, running: l.value.batchRunning, completed: l.value.batchCompleted, failed: l.value.batchFailed, cancelled: l.value.batchCancelled }[p.status];
153
- }
154
- async function O(p) {
155
- const t = m.value.length;
156
- u.add(p), m.value.length !== t && (i.value = R.value, await G(), g.value?.querySelector(".mr-batch__row:last-child .mrp-param-input")?.focus());
157
- }
158
- async function w(p = !1) {
159
- const t = u.run(p);
160
- if (u.invalidKey.value !== void 0) {
161
- const e = m.value.findIndex((s) => s.key === u.invalidKey.value);
162
- i.value = Math.max(1, Math.floor(e / S) + 1), await G(), g.value?.querySelector('[aria-invalid="true"]')?.focus();
163
- }
164
- await t;
165
- }
166
- return (p, t) => (f(), b("section", {
167
- ref_key: "root",
168
- ref: g,
169
- class: "mr-batch",
170
- "aria-label": a(l).batchTitle,
171
- "aria-busy": a(v)
172
- }, [
173
- o("header", ue, [
174
- o("div", null, [
175
- o("strong", null, c(a(l).batchTitle), 1),
176
- o("p", null, c(a(l).batchDescription), 1)
177
- ]),
178
- o("button", {
179
- type: "button",
180
- disabled: n.readonly || a(v) || a(m).length >= a(C),
181
- onClick: t[0] || (t[0] = (e) => O())
182
- }, "+ " + c(a(l).batchAdd), 9, de)
183
- ]),
184
- a(m).length ? (f(), b("div", ve, [
185
- (f(!0), b(z, null, W(K.value, ({ row: e, index: s }) => (f(), b("article", {
186
- key: e.key,
187
- class: X(["mr-batch__row", `is-${e.status}`])
188
- }, [
189
- o("header", null, [
190
- o("div", null, [
191
- o("strong", null, c(a(l).batchCase) + " " + c(s + 1), 1),
192
- o("span", fe, c(U(e)), 1)
193
- ]),
194
- o("div", be, [
195
- o("button", {
196
- type: "button",
197
- "aria-label": `${a(l).batchDuplicate} ${s + 1}`,
198
- disabled: n.readonly || a(v) || a(m).length >= a(C),
199
- onClick: (r) => O(e)
200
- }, c(a(l).batchDuplicate), 9, he),
201
- o("button", {
202
- type: "button",
203
- "aria-label": `${a(l).batchRemove} ${s + 1}`,
204
- disabled: n.readonly || a(v),
205
- onClick: (r) => a(u).remove(e.key)
206
- }, "×", 8, pe)
207
- ])
208
- ]),
209
- Y(ee, {
210
- defs: n.paramDefs,
211
- "model-value": e.item.params,
212
- messages: N.value,
213
- attempted: a(E),
214
- issues: a(A)[s]?.issues,
215
- "show-actions": !1,
216
- "show-title": !1,
217
- disabled: n.readonly || a(v),
218
- "onUpdate:modelValue": (r) => a(u).setParams(e.key, r)
219
- }, null, 8, ["defs", "model-value", "messages", "attempted", "issues", "disabled", "onUpdate:modelValue"]),
220
- e.status === "failed" && e.error ? (f(), b("p", ye, c(e.error), 1)) : I("", !0),
221
- e.status === "completed" ? (f(), b("div", ge, [
222
- o("span", null, c(e.receipt?.label || (e.receipt?.instanceId ? e.receipt.instanceId : a(l).batchNoInstance)), 1),
223
- e.receipt?.instanceId ? (f(), b("button", {
224
- key: 0,
225
- type: "button",
226
- onClick: (r) => M("open-instance", { ...e.receipt })
227
- }, c(a(l).batchOpen) + " ↗", 9, _e)) : I("", !0)
228
- ])) : I("", !0)
229
- ], 2))), 128))
230
- ])) : (f(), b("div", me, c(a(l).batchEmpty), 1)),
231
- a(x) ? (f(), b("p", ke, c(a(x)), 1)) : I("", !0),
232
- o("footer", null, [
233
- o("div", Ce, [
234
- a(y).total ? (f(), b(z, { key: 0 }, [
235
- o("progress", {
236
- value: a(y).completed,
237
- max: a(y).total,
238
- "aria-label": T.value
239
- }, null, 8, xe),
240
- o("span", null, c(T.value), 1)
241
- ], 64)) : (f(), b("span", Se, c(a(m).length) + " / " + c(a(C)), 1))
242
- ]),
243
- o("div", Re, [
244
- a(V) && !a(v) ? (f(), b("button", {
245
- key: 0,
246
- type: "button",
247
- disabled: n.readonly,
248
- onClick: t[1] || (t[1] = (e) => w(!0))
249
- }, c(a(l).batchRetry) + " (" + c(a(V)) + ")", 9, $e)) : I("", !0),
250
- a(v) ? (f(), b("button", {
251
- key: 1,
252
- type: "button",
253
- disabled: a($),
254
- onClick: t[2] || (t[2] = //@ts-ignore
255
- (...e) => a(u).cancel && a(u).cancel(...e))
256
- }, c(a($) ? a(l).batchCancelling : a(l).batchCancel), 9, Ie)) : (f(), b("button", {
257
- key: 2,
258
- type: "button",
259
- class: "is-primary",
260
- disabled: n.readonly || !a(m).length,
261
- onClick: t[3] || (t[3] = (e) => w())
262
- }, c(a(l).batchRun), 9, Pe))
263
- ]),
264
- R.value > 1 ? (f(), b("nav", {
265
- key: 0,
266
- class: "mr-batch__pagination",
267
- "aria-label": a(l).batchPages
268
- }, [
269
- o("span", null, c(L.value), 1),
270
- o("button", {
271
- type: "button",
272
- disabled: i.value <= 1,
273
- onClick: t[4] || (t[4] = (e) => i.value--)
274
- }, c(a(l).batchPrevious), 9, De),
275
- o("button", {
276
- type: "button",
277
- disabled: i.value >= R.value,
278
- onClick: t[5] || (t[5] = (e) => i.value++)
279
- }, c(a(l).batchNext), 9, Be)
280
- ], 8, Ee)) : I("", !0)
281
- ])
282
- ], 8, oe));
283
- }
284
- }), Fe = /* @__PURE__ */ le(Me, [["__scopeId", "data-v-eea7fd86"]]);
285
- export {
286
- Fe as default
287
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),T=require("@agile-team/mach-report"),A=require("./designer.cjs"),M=require("./_plugin-vue_export-helper-BLmdZLlg.cjs");function L(l){if(!l||!Array.isArray(l.items)||l.items.length>100||l.next!==void 0&&(typeof l.next!="string"||!l.next||l.next.length>4096))throw new Error("invalid");const k=new Set;for(const i of l.items){if(!i||typeof i.id!="string"||!i.id.trim()||typeof i.name!="string"||!i.name.trim()||k.has(i.id))throw new Error("invalid");k.add(i.id)}if(l.categories!==void 0&&(!Array.isArray(l.categories)||l.categories.length>1e3||l.categories.some(i=>!i||typeof i.id!="string"||!i.id||typeof i.label!="string")))throw new Error("invalid")}function I(l,k){const i=e.computed(()=>({...A.TEMPLATE_LIBRARY_MESSAGES,...l.messages})),D=e.ref(""),n=e.ref(""),E=e.shallowRef([]),S=e.shallowRef([]),a=e.ref([void 0]),m=e.ref(),_=e.ref(!1),h=e.ref(!1),s=e.ref(""),u=e.shallowRef(),B=e.ref(""),b=e.ref("");let f=0,d=0,c,v,w;function x(o,y,p,g){if(L(o),o.next!==void 0&&(o.next===y||!g&&a.value.includes(o.next)))throw new Error(i.value.stale);E.value=o.items,m.value=o.next,g?a.value=a.value.slice(0,-1):p&&(a.value=[...a.value,y]),o.categories&&(S.value=o.categories)}function r(o){return o instanceof Error?o.message==="invalid"?i.value.invalid:o.message:String(o)}async function t(o=!1,y=!1){if(o&&!m.value||y&&a.value.length<2)return;clearTimeout(w),c?.abort();const p=++f;c=new AbortController,_.value=!0,s.value="";const g=y?a.value.at(-2):o?m.value:void 0;!o&&!y&&(E.value=[],m.value=void 0,a.value=[void 0]);try{const C=await l.provider.search({query:D.value.trim(),category:n.value||void 0,cursor:g,limit:30,signal:c.signal});if(p!==f)return;x(C,g,o,y)}catch(C){p===f&&!c.signal.aborted&&(s.value=r(C))}finally{p===f&&(_.value=!1)}}async function V(o,y=!1){if(h.value)return;const p=++d,g=l.create,C={id:B.value.trim(),name:b.value.trim()};v=new AbortController,h.value=!0,s.value="";try{const N=await l.provider.get(o.id,{signal:v.signal});if(p!==d)return;if(!N||N.id!==o.id)throw new Error(i.value.missing);const R=T.parseReportTemplate(N);if(y){if(!g)return;const $=T.cloneReportTemplate(R,C),q=T.parseReportTemplate(await g($,{signal:v.signal}));if(p!==d)return;if(q.id!==$.id)throw new Error(i.value.invalid);u.value=void 0,k(q),t()}else k(R)}catch(N){p===d&&!v.signal.aborted&&(s.value=N instanceof Error?N.message:String(N))}finally{p===d&&(h.value=!1)}}return e.watch([D,n],()=>{f++,c?.abort(),E.value=[],m.value=void 0,a.value=[void 0],_.value=!0,clearTimeout(w),w=setTimeout(()=>{t()},180)}),e.watch([()=>l.provider,()=>l.create],()=>{d++,v?.abort(),h.value=!1,u.value=void 0,t()}),e.onBeforeUnmount(()=>{f++,d++,clearTimeout(w),c?.abort(),v?.abort()}),t(),{m:i,cursors:a,query:D,category:n,entries:E,categories:S,next:m,loading:_,busy:h,error:s,copying:u,newId:B,newName:b,search:t,load:V,beginCopy:o=>{u.value=o,B.value="",b.value=o.name}}}const U=["aria-label","aria-busy"],F=["disabled"],P={class:"mr-library-search"},H=["placeholder","aria-label"],K=["aria-label"],j={value:""},G=["value"],O={key:0,role:"alert",class:"mr-library-error"},Y=["disabled"],z=["disabled"],J=["disabled"],Q=["disabled"],W=["disabled"],X={key:2},Z=["disabled","onClick"],ee={key:0},te={key:0},ne={key:1,class:"mr-library-tags"},re={class:"mr-library-actions"},oe=["disabled","onClick"],le=["disabled","onClick"],ie={key:3,class:"mr-library-empty",role:"status"},ae={key:0},se=["disabled"],ue=["disabled"],de=e.defineComponent({__name:"ReportTemplateLibrary",props:{provider:{},messages:{},create:{type:Function}},emits:["open"],setup(l,{emit:k}){const i=l,D=k,{m:n,cursors:E,query:S,category:a,entries:m,categories:_,next:h,loading:s,busy:u,error:B,copying:b,newId:f,newName:d,search:c,load:v,beginCopy:w}=I(i,x=>D("open",x));return(x,r)=>(e.openBlock(),e.createElementBlock("section",{class:"mr-library","aria-label":e.unref(n).title,"aria-busy":e.unref(s)||e.unref(u)},[e.createElementVNode("header",null,[e.createElementVNode("div",null,[e.createElementVNode("h2",null,e.toDisplayString(e.unref(n).title),1),e.createElementVNode("p",null,e.toDisplayString(e.unref(n).subtitle),1)]),e.createElementVNode("button",{type:"button",disabled:e.unref(s),onClick:r[0]||(r[0]=t=>e.unref(c)())},e.toDisplayString(e.unref(n).refresh),9,F)]),e.createElementVNode("div",P,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":r[1]||(r[1]=t=>e.isRef(S)?S.value=t:null),type:"search",placeholder:e.unref(n).search,"aria-label":e.unref(n).search,onKeydown:r[2]||(r[2]=e.withKeys(t=>e.unref(c)(),["enter"]))},null,40,H),[[e.vModelText,e.unref(S)]]),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":r[3]||(r[3]=t=>e.isRef(a)?a.value=t:null),"aria-label":e.unref(n).all},[e.createElementVNode("option",j,e.toDisplayString(e.unref(n).all),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),t=>(e.openBlock(),e.createElementBlock("option",{key:t.id,value:t.id},e.toDisplayString(t.label)+e.toDisplayString(t.count===void 0?"":` (${t.count})`),9,G))),128))],8,K),[[e.vModelSelect,e.unref(a)]])]),e.unref(B)?(e.openBlock(),e.createElementBlock("div",O,[e.createTextVNode(e.toDisplayString(e.unref(B))+" ",1),e.createElementVNode("button",{type:"button",disabled:e.unref(s),onClick:r[4]||(r[4]=t=>e.unref(c)())},e.toDisplayString(e.unref(n).retry),9,Y)])):e.createCommentVNode("",!0),e.unref(b)?(e.openBlock(),e.createElementBlock("form",{key:1,class:"mr-library-copy",onSubmit:r[8]||(r[8]=e.withModifiers(t=>e.unref(v)(e.unref(b),!0),["prevent"]))},[e.createElementVNode("strong",null,e.toDisplayString(e.unref(n).copyTitle)+" · "+e.toDisplayString(e.unref(b).name),1),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(n).newId),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":r[5]||(r[5]=t=>e.isRef(f)?f.value=t:null),required:"",maxlength:"256",disabled:e.unref(u)},null,8,z),[[e.vModelText,e.unref(f)]])]),e.createElementVNode("label",null,[e.createTextVNode(e.toDisplayString(e.unref(n).newName),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":r[6]||(r[6]=t=>e.isRef(d)?d.value=t:null),required:"",maxlength:"256",disabled:e.unref(u)},null,8,J),[[e.vModelText,e.unref(d)]])]),e.createElementVNode("div",null,[e.createElementVNode("button",{type:"button",disabled:e.unref(u),onClick:r[7]||(r[7]=t=>b.value=void 0)},e.toDisplayString(e.unref(n).cancel),9,Q),e.createElementVNode("button",{type:"submit",disabled:e.unref(u)||!e.unref(f).trim()||!e.unref(d).trim()},e.toDisplayString(e.unref(u)?e.unref(n).loading:e.unref(n).create),9,W)])],32)):e.createCommentVNode("",!0),e.unref(m).length?(e.openBlock(),e.createElementBlock("ul",X,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(m),t=>(e.openBlock(),e.createElementBlock("li",{key:t.id},[e.createElementVNode("div",null,[e.createElementVNode("button",{class:"mr-library-name",type:"button",disabled:e.unref(u),onClick:V=>e.unref(v)(t)},e.toDisplayString(t.name),9,Z),e.createElementVNode("small",null,[e.createTextVNode(e.toDisplayString(t.id),1),t.revision?(e.openBlock(),e.createElementBlock("span",ee," · "+e.toDisplayString(e.unref(n).revision)+" "+e.toDisplayString(t.revision),1)):e.createCommentVNode("",!0)]),t.description?(e.openBlock(),e.createElementBlock("p",te,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),t.tags?.length?(e.openBlock(),e.createElementBlock("div",ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.tags,V=>(e.openBlock(),e.createElementBlock("span",{key:V},e.toDisplayString(V),1))),128))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",re,[l.create?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",disabled:e.unref(u),onClick:V=>e.unref(w)(t)},e.toDisplayString(e.unref(n).copy),9,oe)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",disabled:e.unref(u),onClick:V=>e.unref(v)(t)},e.toDisplayString(e.unref(n).open),9,le)])]))),128))])):(e.openBlock(),e.createElementBlock("div",ie,[e.createElementVNode("strong",null,e.toDisplayString(e.unref(s)?e.unref(n).loading:e.unref(n).empty),1),e.unref(s)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",ae,e.toDisplayString(e.unref(n).emptyHint),1))])),e.createElementVNode("footer",null,[e.createElementVNode("span",null,e.toDisplayString(e.unref(E).length)+" "+e.toDisplayString(e.unref(n).page)+" · "+e.toDisplayString(e.unref(m).length)+" "+e.toDisplayString(e.unref(n).count),1),e.createElementVNode("div",null,[e.unref(E).length>1?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",disabled:e.unref(s),onClick:r[9]||(r[9]=t=>e.unref(c)(!1,!0))},e.toDisplayString(e.unref(n).previous),9,se)):e.createCommentVNode("",!0),e.unref(h)?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",disabled:e.unref(s),onClick:r[10]||(r[10]=t=>e.unref(c)(!0))},e.toDisplayString(e.unref(s)?e.unref(n).loading:e.unref(n).loadMore),9,ue)):e.createCommentVNode("",!0)])])],8,U))}}),ce=M._export_sfc(de,[["__scopeId","data-v-ea353b1c"]]);exports.default=ce;
@@ -1,260 +0,0 @@
1
- import { computed as O, ref as w, shallowRef as D, watch as z, onBeforeUnmount as Q, defineComponent as W, openBlock as d, createElementBlock as u, unref as e, createElementVNode as n, toDisplayString as i, withDirectives as U, withKeys as X, isRef as B, vModelText as F, Fragment as K, renderList as G, vModelSelect as Z, createTextVNode as P, createCommentVNode as k, withModifiers as ee } from "vue";
2
- import { parseReportTemplate as J, cloneReportTemplate as te } from "@agile-team/mach-report";
3
- import { TEMPLATE_LIBRARY_MESSAGES as le } from "./designer.js";
4
- import { _ as ie } from "./_plugin-vue_export-helper-8SL1F89S.js";
5
- function ne(a) {
6
- if (!a || !Array.isArray(a.items) || a.items.length > 100 || a.next !== void 0 && (typeof a.next != "string" || !a.next || a.next.length > 4096)) throw new Error("invalid");
7
- const E = /* @__PURE__ */ new Set();
8
- for (const s of a.items) {
9
- if (!s || typeof s.id != "string" || !s.id.trim() || typeof s.name != "string" || !s.name.trim() || E.has(s.id)) throw new Error("invalid");
10
- E.add(s.id);
11
- }
12
- if (a.categories !== void 0 && (!Array.isArray(a.categories) || a.categories.length > 1e3 || a.categories.some((s) => !s || typeof s.id != "string" || !s.id || typeof s.label != "string"))) throw new Error("invalid");
13
- }
14
- function oe(a, E) {
15
- const s = O(() => ({ ...le, ...a.messages })), N = w(""), l = w(""), T = D([]), R = D([]), c = w([void 0]), p = w(), V = w(!1), $ = w(!1), v = w(""), b = D(), L = w(""), C = w("");
16
- let y = 0, m = 0, f, g, M;
17
- function I(r, _, h, x) {
18
- if (ne(r), r.next !== void 0 && (r.next === _ || !x && c.value.includes(r.next))) throw new Error(s.value.stale);
19
- T.value = r.items, p.value = r.next, x ? c.value = c.value.slice(0, -1) : h && (c.value = [...c.value, _]), r.categories && (R.value = r.categories);
20
- }
21
- function o(r) {
22
- return r instanceof Error ? r.message === "invalid" ? s.value.invalid : r.message : String(r);
23
- }
24
- async function t(r = !1, _ = !1) {
25
- if (r && !p.value || _ && c.value.length < 2) return;
26
- clearTimeout(M), f?.abort();
27
- const h = ++y;
28
- f = new AbortController(), V.value = !0, v.value = "";
29
- const x = _ ? c.value.at(-2) : r ? p.value : void 0;
30
- !r && !_ && (T.value = [], p.value = void 0, c.value = [void 0]);
31
- try {
32
- const q = await a.provider.search({ query: N.value.trim(), category: l.value || void 0, cursor: x, limit: 30, signal: f.signal });
33
- if (h !== y) return;
34
- I(q, x, r, _);
35
- } catch (q) {
36
- h === y && !f.signal.aborted && (v.value = o(q));
37
- } finally {
38
- h === y && (V.value = !1);
39
- }
40
- }
41
- async function A(r, _ = !1) {
42
- if ($.value) return;
43
- const h = ++m, x = a.create, q = { id: L.value.trim(), name: C.value.trim() };
44
- g = new AbortController(), $.value = !0, v.value = "";
45
- try {
46
- const S = await a.provider.get(r.id, { signal: g.signal });
47
- if (h !== m) return;
48
- if (!S || S.id !== r.id) throw new Error(s.value.missing);
49
- const H = J(S);
50
- if (_) {
51
- if (!x) return;
52
- const Y = te(H, q), j = J(await x(Y, { signal: g.signal }));
53
- if (h !== m) return;
54
- if (j.id !== Y.id) throw new Error(s.value.invalid);
55
- b.value = void 0, E(j), t();
56
- } else E(H);
57
- } catch (S) {
58
- h === m && !g.signal.aborted && (v.value = S instanceof Error ? S.message : String(S));
59
- } finally {
60
- h === m && ($.value = !1);
61
- }
62
- }
63
- return z([N, l], () => {
64
- y++, f?.abort(), T.value = [], p.value = void 0, c.value = [void 0], V.value = !0, clearTimeout(M), M = setTimeout(() => {
65
- t();
66
- }, 180);
67
- }), z([() => a.provider, () => a.create], () => {
68
- m++, g?.abort(), $.value = !1, b.value = void 0, t();
69
- }), Q(() => {
70
- y++, m++, clearTimeout(M), f?.abort(), g?.abort();
71
- }), t(), {
72
- m: s,
73
- cursors: c,
74
- query: N,
75
- category: l,
76
- entries: T,
77
- categories: R,
78
- next: p,
79
- loading: V,
80
- busy: $,
81
- error: v,
82
- copying: b,
83
- newId: L,
84
- newName: C,
85
- search: t,
86
- load: A,
87
- beginCopy: (r) => {
88
- b.value = r, L.value = "", C.value = r.name;
89
- }
90
- };
91
- }
92
- const re = ["aria-label", "aria-busy"], ae = ["disabled"], se = { class: "mr-library-search" }, de = ["placeholder", "aria-label"], ue = ["aria-label"], ce = { value: "" }, ve = ["value"], be = {
93
- key: 0,
94
- role: "alert",
95
- class: "mr-library-error"
96
- }, me = ["disabled"], fe = ["disabled"], ye = ["disabled"], pe = ["disabled"], ge = ["disabled"], he = { key: 2 }, _e = ["disabled", "onClick"], we = { key: 0 }, ke = { key: 0 }, Ce = {
97
- key: 1,
98
- class: "mr-library-tags"
99
- }, xe = { class: "mr-library-actions" }, Ee = ["disabled", "onClick"], Te = ["disabled", "onClick"], $e = {
100
- key: 3,
101
- class: "mr-library-empty",
102
- role: "status"
103
- }, Ae = { key: 0 }, Se = ["disabled"], Re = ["disabled"], Ve = /* @__PURE__ */ W({
104
- __name: "ReportTemplateLibrary",
105
- props: {
106
- provider: {},
107
- messages: {},
108
- create: { type: Function }
109
- },
110
- emits: ["open"],
111
- setup(a, { emit: E }) {
112
- const s = a, N = E, { m: l, cursors: T, query: R, category: c, entries: p, categories: V, next: $, loading: v, busy: b, error: L, copying: C, newId: y, newName: m, search: f, load: g, beginCopy: M } = oe(s, (I) => N("open", I));
113
- return (I, o) => (d(), u("section", {
114
- class: "mr-library",
115
- "aria-label": e(l).title,
116
- "aria-busy": e(v) || e(b)
117
- }, [
118
- n("header", null, [
119
- n("div", null, [
120
- n("h2", null, i(e(l).title), 1),
121
- n("p", null, i(e(l).subtitle), 1)
122
- ]),
123
- n("button", {
124
- type: "button",
125
- disabled: e(v),
126
- onClick: o[0] || (o[0] = (t) => e(f)())
127
- }, i(e(l).refresh), 9, ae)
128
- ]),
129
- n("div", se, [
130
- U(n("input", {
131
- "onUpdate:modelValue": o[1] || (o[1] = (t) => B(R) ? R.value = t : null),
132
- type: "search",
133
- placeholder: e(l).search,
134
- "aria-label": e(l).search,
135
- onKeydown: o[2] || (o[2] = X((t) => e(f)(), ["enter"]))
136
- }, null, 40, de), [
137
- [F, e(R)]
138
- ]),
139
- U(n("select", {
140
- "onUpdate:modelValue": o[3] || (o[3] = (t) => B(c) ? c.value = t : null),
141
- "aria-label": e(l).all
142
- }, [
143
- n("option", ce, i(e(l).all), 1),
144
- (d(!0), u(K, null, G(e(V), (t) => (d(), u("option", {
145
- key: t.id,
146
- value: t.id
147
- }, i(t.label) + i(t.count === void 0 ? "" : ` (${t.count})`), 9, ve))), 128))
148
- ], 8, ue), [
149
- [Z, e(c)]
150
- ])
151
- ]),
152
- e(L) ? (d(), u("div", be, [
153
- P(i(e(L)) + " ", 1),
154
- n("button", {
155
- type: "button",
156
- disabled: e(v),
157
- onClick: o[4] || (o[4] = (t) => e(f)())
158
- }, i(e(l).retry), 9, me)
159
- ])) : k("", !0),
160
- e(C) ? (d(), u("form", {
161
- key: 1,
162
- class: "mr-library-copy",
163
- onSubmit: o[8] || (o[8] = ee((t) => e(g)(e(C), !0), ["prevent"]))
164
- }, [
165
- n("strong", null, i(e(l).copyTitle) + " · " + i(e(C).name), 1),
166
- n("label", null, [
167
- P(i(e(l).newId), 1),
168
- U(n("input", {
169
- "onUpdate:modelValue": o[5] || (o[5] = (t) => B(y) ? y.value = t : null),
170
- required: "",
171
- maxlength: "256",
172
- disabled: e(b)
173
- }, null, 8, fe), [
174
- [F, e(y)]
175
- ])
176
- ]),
177
- n("label", null, [
178
- P(i(e(l).newName), 1),
179
- U(n("input", {
180
- "onUpdate:modelValue": o[6] || (o[6] = (t) => B(m) ? m.value = t : null),
181
- required: "",
182
- maxlength: "256",
183
- disabled: e(b)
184
- }, null, 8, ye), [
185
- [F, e(m)]
186
- ])
187
- ]),
188
- n("div", null, [
189
- n("button", {
190
- type: "button",
191
- disabled: e(b),
192
- onClick: o[7] || (o[7] = (t) => C.value = void 0)
193
- }, i(e(l).cancel), 9, pe),
194
- n("button", {
195
- type: "submit",
196
- disabled: e(b) || !e(y).trim() || !e(m).trim()
197
- }, i(e(b) ? e(l).loading : e(l).create), 9, ge)
198
- ])
199
- ], 32)) : k("", !0),
200
- e(p).length ? (d(), u("ul", he, [
201
- (d(!0), u(K, null, G(e(p), (t) => (d(), u("li", {
202
- key: t.id
203
- }, [
204
- n("div", null, [
205
- n("button", {
206
- class: "mr-library-name",
207
- type: "button",
208
- disabled: e(b),
209
- onClick: (A) => e(g)(t)
210
- }, i(t.name), 9, _e),
211
- n("small", null, [
212
- P(i(t.id), 1),
213
- t.revision ? (d(), u("span", we, " · " + i(e(l).revision) + " " + i(t.revision), 1)) : k("", !0)
214
- ]),
215
- t.description ? (d(), u("p", ke, i(t.description), 1)) : k("", !0),
216
- t.tags?.length ? (d(), u("div", Ce, [
217
- (d(!0), u(K, null, G(t.tags, (A) => (d(), u("span", { key: A }, i(A), 1))), 128))
218
- ])) : k("", !0)
219
- ]),
220
- n("div", xe, [
221
- a.create ? (d(), u("button", {
222
- key: 0,
223
- type: "button",
224
- disabled: e(b),
225
- onClick: (A) => e(M)(t)
226
- }, i(e(l).copy), 9, Ee)) : k("", !0),
227
- n("button", {
228
- type: "button",
229
- disabled: e(b),
230
- onClick: (A) => e(g)(t)
231
- }, i(e(l).open), 9, Te)
232
- ])
233
- ]))), 128))
234
- ])) : (d(), u("div", $e, [
235
- n("strong", null, i(e(v) ? e(l).loading : e(l).empty), 1),
236
- e(v) ? k("", !0) : (d(), u("p", Ae, i(e(l).emptyHint), 1))
237
- ])),
238
- n("footer", null, [
239
- n("span", null, i(e(T).length) + " " + i(e(l).page) + " · " + i(e(p).length) + " " + i(e(l).count), 1),
240
- n("div", null, [
241
- e(T).length > 1 ? (d(), u("button", {
242
- key: 0,
243
- type: "button",
244
- disabled: e(v),
245
- onClick: o[9] || (o[9] = (t) => e(f)(!1, !0))
246
- }, i(e(l).previous), 9, Se)) : k("", !0),
247
- e($) ? (d(), u("button", {
248
- key: 1,
249
- type: "button",
250
- disabled: e(v),
251
- onClick: o[10] || (o[10] = (t) => e(f)(!0))
252
- }, i(e(v) ? e(l).loading : e(l).loadMore), 9, Re)) : k("", !0)
253
- ])
254
- ])
255
- ], 8, re));
256
- }
257
- }), Ie = /* @__PURE__ */ ie(Ve, [["__scopeId", "data-v-ea353b1c"]]);
258
- export {
259
- Ie as default
260
- };