golden-logic-ui 1.3.12 → 1.3.13

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,8 +1,8 @@
1
1
  import M from "../../../node_modules/vue3-print-nb/dist/vue3-print-nb.es.js";
2
- import { resolveComponent as j, resolveDirective as S, createElementBlock as o, openBlock as i, withDirectives as L, createElementVNode as e, createCommentVNode as x, createVNode as k, vModelText as I, withCtx as D, createTextVNode as h, Fragment as v, renderList as w, toDisplayString as f, normalizeClass as P, createBlock as E, resolveDynamicComponent as O, withModifiers as _ } from "vue";
2
+ import { resolveComponent as D, resolveDirective as E, createElementBlock as g, openBlock as d, withDirectives as j, createElementVNode as e, createCommentVNode as v, createVNode as k, vModelText as S, withCtx as L, createTextVNode as f, Fragment as b, renderList as w, toDisplayString as y, normalizeClass as _, createBlock as I, resolveDynamicComponent as O, withModifiers as P } from "vue";
3
3
  /* empty css */
4
- import H from "../../../_virtual/_plugin-vue_export-helper.js";
5
- const V = {
4
+ import B from "../../../_virtual/_plugin-vue_export-helper.js";
5
+ const H = {
6
6
  components: {},
7
7
  props: {
8
8
  data: Array,
@@ -14,6 +14,13 @@ const V = {
14
14
  required: !1,
15
15
  default: () => {
16
16
  }
17
+ },
18
+ // Render plain (non-tdComp) cells as text instead of HTML. Off by default
19
+ // for backward compatibility. A column can opt out either way with
20
+ // `html: false` (always escape) or `html: true` (always render HTML).
21
+ escape_html: {
22
+ type: Boolean,
23
+ default: !1
17
24
  }
18
25
  },
19
26
  data() {
@@ -47,16 +54,16 @@ const V = {
47
54
  // Set the maximum number of displayed pagination buttons
48
55
  };
49
56
  },
50
- emits: ["editAction", "generalAction", "deleteAction"],
57
+ emits: ["editAction", "generalAction", "deleteAction", "cell-action"],
51
58
  computed: {
52
59
  itemLists() {
53
60
  return this.data;
54
61
  },
55
62
  filteredData() {
56
63
  const r = this.search.toLowerCase(), t = this.sortData(this.itemLists);
57
- return r ? t.filter((l) => this.columns.some((u) => {
58
- const a = l[u.field_name];
59
- return a != null && String(a).toLowerCase().includes(r);
64
+ return r ? t.filter((n) => this.columns.some((c) => {
65
+ const l = n[c.field_name];
66
+ return l != null && String(l).toLowerCase().includes(r);
60
67
  })) : t;
61
68
  },
62
69
  totalPages() {
@@ -73,7 +80,7 @@ const V = {
73
80
  ), t = r + this.maxDisplayedPages - 1;
74
81
  return t > this.totalPages && (t = this.totalPages, r = Math.max(t - this.maxDisplayedPages + 1, 1)), Array.from(
75
82
  { length: t - r + 1 },
76
- (l, u) => r + u
83
+ (n, c) => r + c
77
84
  );
78
85
  },
79
86
  firstItemIndex() {
@@ -86,15 +93,15 @@ const V = {
86
93
  },
87
94
  methods: {
88
95
  async exportToExcel() {
89
- const r = await import("xlsx"), t = r.default || r, l = document.querySelector("#table" + this.Random_string), u = Array.from(l.querySelectorAll("thead th")).map((g) => g.innerText), n = ["", ...["action"]], y = u.map((g, m) => n.includes(g) ? m : -1).filter((g) => g !== -1), b = Array.from(l.querySelectorAll("tbody tr")).map((g) => Array.from(g.querySelectorAll("td")).map((A) => A.innerText).filter((A, T) => !y.includes(T))), s = [u.filter((g, m) => !y.includes(m)), ...b], c = t.utils.aoa_to_sheet(s), d = t.utils.book_new();
90
- t.utils.book_append_sheet(d, c, "Sheet1"), t.writeFile(d, "exported-file.xlsx");
96
+ const r = await import("xlsx"), t = r.default || r, n = document.querySelector("#table" + this.Random_string), c = Array.from(n.querySelectorAll("thead th")).map((o) => o.innerText), a = ["", ...["action"]], p = c.map((o, h) => a.includes(o) ? h : -1).filter((o) => o !== -1), x = Array.from(n.querySelectorAll("tbody tr")).map((o) => Array.from(o.querySelectorAll("td")).map((C) => C.innerText).filter((C, T) => !p.includes(T))), s = [c.filter((o, h) => !p.includes(h)), ...x], u = t.utils.aoa_to_sheet(s), i = t.utils.book_new();
97
+ t.utils.book_append_sheet(i, u, "Sheet1"), t.writeFile(i, "exported-file.xlsx");
91
98
  },
92
99
  generateRandomString(r) {
93
100
  let t = "";
94
- const l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", u = l.length;
95
- for (let a = 0; a < r; a++)
96
- t += l.charAt(
97
- Math.floor(Math.random() * u)
101
+ const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", c = n.length;
102
+ for (let l = 0; l < r; l++)
103
+ t += n.charAt(
104
+ Math.floor(Math.random() * c)
98
105
  );
99
106
  return t;
100
107
  },
@@ -112,6 +119,14 @@ const V = {
112
119
  generalAction(r) {
113
120
  this.$emit("generalAction", r);
114
121
  },
122
+ // Every cell event, with whatever the cell sent along. Cells can also emit
123
+ // their own named actions: emit('cellAction', 'restart', payload).
124
+ cellAction(r, t, n, c) {
125
+ this.$emit("cell-action", { action: r, row: t, payload: n, field: c?.field_name });
126
+ },
127
+ isEscapedColumn(r) {
128
+ return r?.html === !1 ? !0 : r?.html === !0 ? !1 : this.escape_html;
129
+ },
115
130
  forDynCompIs(r) {
116
131
  return typeof r == "object" ? r : null;
117
132
  },
@@ -125,7 +140,7 @@ const V = {
125
140
  r === this.sortKey ? this.sortOrder *= -1 : (this.sortKey = r, this.sortOrder = 1);
126
141
  },
127
142
  sortData(r) {
128
- return this.sortKey ? r.slice().sort((t, l) => (t[this.sortKey] < l[this.sortKey] ? -1 : 1) * this.sortOrder) : r;
143
+ return this.sortKey ? r.slice().sort((t, n) => (t[this.sortKey] < n[this.sortKey] ? -1 : 1) * this.sortOrder) : r;
129
144
  },
130
145
  previousPage() {
131
146
  this.currentPage > 1 && this.currentPage--;
@@ -155,31 +170,34 @@ const V = {
155
170
  directives: {
156
171
  print: M
157
172
  }
158
- }, B = { class: "p-0" }, K = {
173
+ }, V = { class: "p-0" }, K = {
159
174
  ref: "hiddenPrintBtn",
160
175
  style: { display: "none" }
161
176
  }, q = { class: "flex flex-col flex-wrap gap-4 pb-4 xl:flex-row xl:items-center xl:justify-between" }, R = { class: "flex items-center gap-2" }, N = { class: "mt-[9px]" }, G = { class: "relative" }, F = { class: "flex flex-wrap mb-3" }, Z = ["id"], z = ["id"], U = { class: "hidden text-sm font-normal text-center text-gray-600 print:table-header-group! lg:table-header-group dark:border-gray-600 bg-gray-50 dark:bg-gray-800 dark:text-gray-400 print:border-[1px]!" }, X = ["onClick"], W = { class: "inline-flex items-center justify-center gap-1" }, J = {
162
177
  key: 0,
163
178
  class: "print:hidden!"
164
- }, Q = { class: "bg-white dark:bg-gray-900" }, Y = { key: 0 }, $ = ["colspan"], ee = ["data-label"], te = ["innerHTML"], re = {
179
+ }, Q = { class: "bg-white dark:bg-gray-900" }, Y = { key: 0 }, $ = ["colspan"], ee = ["data-label"], te = {
180
+ key: 0,
181
+ class: "text-pretty"
182
+ }, re = ["innerHTML"], se = {
165
183
  key: 0,
166
184
  class: "flex items-center justify-between px-4 py-3 bg-white border-gray-200 sm:px-6 dark:text-gray-400 dark:bg-gray-800"
167
- }, se = { class: "flex flex-col items-center w-full gap-2" }, ae = { class: "text-sm text-gray-700 dark:text-gray-400" }, ne = { class: "font-semibold text-gray-900 dark:text-white" }, le = { class: "font-semibold text-gray-900 dark:text-white" }, ie = { class: "font-semibold text-gray-900 dark:text-white" }, oe = { "aria-label": "Page navigation" }, de = { class: "flex items-center h-8 -space-x-px text-sm" }, ge = ["onClick", "aria-current"];
168
- function ue(r, t, l, u, a, n) {
169
- const y = j("dropdown"), b = j("gl-button"), C = S("print");
170
- return i(), o("div", B, [
171
- L(e("button", K, null, 512), [
172
- [C, a.printObj]
185
+ }, ae = { class: "flex flex-col items-center w-full gap-2" }, le = { class: "text-sm text-gray-700 dark:text-gray-400" }, ne = { class: "font-semibold text-gray-900 dark:text-white" }, ie = { class: "font-semibold text-gray-900 dark:text-white" }, oe = { class: "font-semibold text-gray-900 dark:text-white" }, de = { "aria-label": "Page navigation" }, ge = { class: "flex items-center h-8 -space-x-px text-sm" }, ce = ["onClick", "aria-current"];
186
+ function ue(r, t, n, c, l, a) {
187
+ const p = D("dropdown"), x = D("gl-button"), A = E("print");
188
+ return d(), g("div", V, [
189
+ j(e("button", K, null, 512), [
190
+ [A, l.printObj]
173
191
  ]),
174
192
  e("div", q, [
175
193
  e("div", R, [
176
194
  t[4] || (t[4] = e("span", { class: "font-medium" }, " Show ", -1)),
177
195
  e("div", N, [
178
- k(y, {
196
+ k(p, {
179
197
  has_cancel: !1,
180
- options: a.showNoOfEntries,
181
- modelValue: a.itemsPerPage,
182
- "onUpdate:modelValue": t[0] || (t[0] = (s) => a.itemsPerPage = s),
198
+ options: l.showNoOfEntries,
199
+ modelValue: l.itemsPerPage,
200
+ "onUpdate:modelValue": t[0] || (t[0] = (s) => l.itemsPerPage = s),
183
201
  is_required: !1,
184
202
  field_name: "NoOfEntries",
185
203
  label_name: "",
@@ -196,19 +214,19 @@ function ue(r, t, l, u, a, n) {
196
214
  }, "Search", -1)),
197
215
  e("div", G, [
198
216
  t[6] || (t[6] = e("div", { class: "absolute inset-y-0 left-0 flex items-center pointer-events-none rtl:inset-r-0 rtl:right-0 ps-3" }, null, -1)),
199
- L(e("input", {
217
+ j(e("input", {
200
218
  type: "text",
201
- "onUpdate:modelValue": t[1] || (t[1] = (s) => a.search = s),
219
+ "onUpdate:modelValue": t[1] || (t[1] = (s) => l.search = s),
202
220
  class: "gl-input-form",
203
221
  placeholder: "Search ..."
204
222
  }, null, 512), [
205
- [I, a.search]
223
+ [S, l.search]
206
224
  ])
207
225
  ])
208
226
  ]),
209
227
  e("div", F, [
210
- k(b, {
211
- onClick: n.delayedPrint,
228
+ k(x, {
229
+ onClick: a.delayedPrint,
212
230
  tag: "button",
213
231
  is_loading: r.isLoadingPrint,
214
232
  button_type: "light",
@@ -218,13 +236,13 @@ function ue(r, t, l, u, a, n) {
218
236
  <path stroke="currentColor" stroke-linejoin="round" stroke-width="2" d="M16.444 18H19a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h2.556M17 11V5a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v6h10ZM7 15h10v4a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1v-4Z"/>\r
219
237
  </svg>`
220
238
  }, {
221
- default: D(() => t[8] || (t[8] = [
222
- h(" Print ")
239
+ default: L(() => t[8] || (t[8] = [
240
+ f(" Print ")
223
241
  ])),
224
242
  _: 1
225
243
  }, 8, ["onClick", "is_loading"]),
226
- k(b, {
227
- onClick: n.exportToExcel,
244
+ k(x, {
245
+ onClick: a.exportToExcel,
228
246
  tag: "button",
229
247
  button_type: "light",
230
248
  has_border_reduced: !1,
@@ -234,30 +252,30 @@ function ue(r, t, l, u, a, n) {
234
252
  </svg>\r
235
253
  `
236
254
  }, {
237
- default: D(() => t[9] || (t[9] = [
238
- h(" Excel ")
255
+ default: L(() => t[9] || (t[9] = [
256
+ f(" Excel ")
239
257
  ])),
240
258
  _: 1
241
259
  }, 8, ["onClick"])
242
260
  ]),
243
261
  e("div", {
244
- id: "print_" + a.Random_string,
262
+ id: "print_" + l.Random_string,
245
263
  class: "overflow-auto rounded-lg dark:text-gray-400 dark:bg-gray-800"
246
264
  }, [
247
265
  e("table", {
248
- id: "table" + a.Random_string,
266
+ id: "table" + l.Random_string,
249
267
  class: "w-full h-full max-w-full overflow-hidden bg-white border-separate xl:overflow-auto lg:border-collapse print:border-collapse! border-spacing-y-5 lg:border-spacing-y-0 print:border-spacing-y-0! dark:border-gray-800 dark:bg-gray-900"
250
268
  }, [
251
269
  e("thead", U, [
252
270
  e("tr", null, [
253
- (i(!0), o(v, null, w(l.columns, (s, c) => (i(), o("th", {
254
- key: c,
255
- onClick: (d) => n.sort(s.field_name, s.sortable),
271
+ (d(!0), g(b, null, w(n.columns, (s, u) => (d(), g("th", {
272
+ key: u,
273
+ onClick: (i) => a.sort(s.field_name, s.sortable),
256
274
  class: "w-full px-4 py-2 lg:w-2/12 print:w-2/12! print:border!"
257
275
  }, [
258
276
  e("div", W, [
259
- e("span", null, f(s.field_label), 1),
260
- a.sortKey === s.field_name ? (i(), o("span", J, t[10] || (t[10] = [
277
+ e("span", null, y(s.field_label), 1),
278
+ l.sortKey === s.field_name ? (d(), g("span", J, t[10] || (t[10] = [
261
279
  e("svg", {
262
280
  class: "w-4 h-4",
263
281
  "aria-hidden": "true",
@@ -273,15 +291,15 @@ function ue(r, t, l, u, a, n) {
273
291
  d: "M8 20V7m0 13-4-4m4 4 4-4m4-12v13m0-13 4 4m-4-4-4 4"
274
292
  })
275
293
  ], -1)
276
- ]))) : x("", !0)
294
+ ]))) : v("", !0)
277
295
  ])
278
296
  ], 8, X))), 128))
279
297
  ])
280
298
  ]),
281
299
  e("tbody", Q, [
282
- a.isLoading ? (i(), o("tr", Y, [
300
+ l.isLoading ? (d(), g("tr", Y, [
283
301
  e("td", {
284
- colspan: l.columns.length
302
+ colspan: n.columns.length
285
303
  }, t[11] || (t[11] = [
286
304
  e("div", {
287
305
  role: "status",
@@ -325,58 +343,66 @@ function ue(r, t, l, u, a, n) {
325
343
  e("span", { class: "sr-only" }, "Loading...")
326
344
  ], -1)
327
345
  ]), 8, $)
328
- ])) : x("", !0),
329
- a.isLoading ? x("", !0) : (i(!0), o(v, { key: 1 }, w(n.paginatedData, (s, c) => (i(), o("tr", {
330
- key: c,
346
+ ])) : v("", !0),
347
+ l.isLoading ? v("", !0) : (d(!0), g(b, { key: 1 }, w(a.paginatedData, (s, u) => (d(), g("tr", {
348
+ key: u,
331
349
  class: "text-gray-500 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 dark:hover:text-gray-200"
332
350
  }, [
333
- (i(!0), o(v, null, w(l.columns, (d, p) => (i(), o("td", {
334
- key: p,
335
- "data-label": d.field_label,
336
- class: P(["text-pretty before:content-[attr(data-label)] before:font-bold dark:before:text-gray-400 lg:before:content-[''] print:before:content-['']! flex flex-col justify-between gap-2 lg:table-cell print:table-cell! py-4 px-5 lg:py-3 lg:px-4 print:py-3! print:px-4! border-[1px]! dark:border-gray-700", {
337
- "rounded-t-lg lg:rounded-t-none!": p === 0,
338
- "rounded-b-lg lg:rounded-b-none!": p === l.columns.length - 1
351
+ (d(!0), g(b, null, w(n.columns, (i, m) => (d(), g("td", {
352
+ key: m,
353
+ "data-label": i.field_label,
354
+ class: _(["text-pretty before:content-[attr(data-label)] before:font-bold dark:before:text-gray-400 lg:before:content-[''] print:before:content-['']! flex flex-col justify-between gap-2 lg:table-cell print:table-cell! py-4 px-5 lg:py-3 lg:px-4 print:py-3! print:px-4! border-[1px]! dark:border-gray-700", {
355
+ "rounded-t-lg lg:rounded-t-none!": m === 0,
356
+ "rounded-b-lg lg:rounded-b-none!": m === n.columns.length - 1
339
357
  }])
340
358
  }, [
341
359
  e("div", {
342
- class: P([d.field_name === "action" ? "" : "overflow-auto", "td_overflow_auto max-h-40 max-w-100"])
360
+ class: _([i.field_name === "action" ? "" : "overflow-auto", "td_overflow_auto max-h-40 max-w-100"])
343
361
  }, [
344
- d.tdComp ? (i(), E(O(n.forDynCompIs(d.tdComp)), {
362
+ i.tdComp ? (d(), I(O(a.forDynCompIs(i.tdComp)), {
345
363
  key: 0,
346
364
  row: s,
347
- field: d.field_name,
348
- xprops: l.xprops,
349
- tdProps: d.tdProps,
350
- onEditAction: (g) => n.editAction(s),
351
- onGeneralAction: (g) => n.generalAction(s)
352
- }, null, 40, ["row", "field", "xprops", "tdProps", "onEditAction", "onGeneralAction"])) : (i(), o("p", {
353
- key: 1,
354
- class: "text-pretty",
355
- innerHTML: s[d.field_name]
356
- }, null, 8, te))
365
+ field: i.field_name,
366
+ xprops: n.xprops,
367
+ tdProps: i.tdProps,
368
+ onEditAction: (o) => {
369
+ a.editAction(s), a.cellAction("editAction", s, o, i);
370
+ },
371
+ onGeneralAction: (o) => {
372
+ a.generalAction(s), a.cellAction("generalAction", s, o, i);
373
+ },
374
+ onDeleteAction: (o) => a.cellAction("deleteAction", s, o, i),
375
+ onCellAction: (o, h) => a.cellAction(o, s, h, i)
376
+ }, null, 40, ["row", "field", "xprops", "tdProps", "onEditAction", "onGeneralAction", "onDeleteAction", "onCellAction"])) : (d(), g(b, { key: 1 }, [
377
+ a.isEscapedColumn(i) ? (d(), g("p", te, y(s[i.field_name]), 1)) : (d(), g("p", {
378
+ key: 1,
379
+ class: "text-pretty",
380
+ innerHTML: s[i.field_name]
381
+ }, null, 8, re))
382
+ ], 64))
357
383
  ], 2)
358
384
  ], 10, ee))), 128))
359
385
  ]))), 128))
360
386
  ])
361
387
  ], 8, z)
362
388
  ], 8, Z),
363
- n.paginatedData.length > 0 ? (i(), o("div", re, [
364
- e("div", se, [
365
- e("p", ae, [
366
- t[12] || (t[12] = h(" Showing ")),
367
- e("span", ne, f(n.firstItemIndex), 1),
368
- t[13] || (t[13] = h(" to ")),
369
- e("span", le, f(n.lastItemIndex), 1),
370
- t[14] || (t[14] = h(" of ")),
371
- e("span", ie, f(n.filteredData.length), 1),
372
- t[15] || (t[15] = h(" entries "))
389
+ a.paginatedData.length > 0 ? (d(), g("div", se, [
390
+ e("div", ae, [
391
+ e("p", le, [
392
+ t[12] || (t[12] = f(" Showing ")),
393
+ e("span", ne, y(a.firstItemIndex), 1),
394
+ t[13] || (t[13] = f(" to ")),
395
+ e("span", ie, y(a.lastItemIndex), 1),
396
+ t[14] || (t[14] = f(" of ")),
397
+ e("span", oe, y(a.filteredData.length), 1),
398
+ t[15] || (t[15] = f(" entries "))
373
399
  ]),
374
- e("nav", oe, [
375
- e("ul", de, [
400
+ e("nav", de, [
401
+ e("ul", ge, [
376
402
  e("li", null, [
377
403
  e("a", {
378
404
  href: "#",
379
- onClick: t[2] || (t[2] = _((...s) => n.previousPage && n.previousPage(...s), ["prevent"])),
405
+ onClick: t[2] || (t[2] = P((...s) => a.previousPage && a.previousPage(...s), ["prevent"])),
380
406
  class: "flex items-center justify-center h-8 px-3 leading-tight text-gray-500 bg-white border border-gray-300 ms-0 border-e-0 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
381
407
  }, t[16] || (t[16] = [
382
408
  e("span", { class: "sr-only" }, "Previous", -1),
@@ -397,18 +423,18 @@ function ue(r, t, l, u, a, n) {
397
423
  ], -1)
398
424
  ]))
399
425
  ]),
400
- (i(!0), o(v, null, w(n.displayedPageNumbers, (s) => (i(), o("li", { key: s }, [
426
+ (d(!0), g(b, null, w(a.displayedPageNumbers, (s) => (d(), g("li", { key: s }, [
401
427
  e("a", {
402
428
  href: "#",
403
- onClick: _((c) => n.goToPage(s), ["prevent"]),
404
- class: P(a.currentPage === s ? "z-10 flex items-center justify-center h-8 px-3 leading-tight text-blue-600 border border-blue-300 bg-blue-50 hover:bg-blue-100 hover:text-blue-700 dark:border-gray-700 dark:bg-gray-700 dark:text-white" : "flex items-center justify-center h-8 px-3 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"),
405
- "aria-current": a.currentPage === s ? "page" : void 0
406
- }, f(s), 11, ge)
429
+ onClick: P((u) => a.goToPage(s), ["prevent"]),
430
+ class: _(l.currentPage === s ? "z-10 flex items-center justify-center h-8 px-3 leading-tight text-blue-600 border border-blue-300 bg-blue-50 hover:bg-blue-100 hover:text-blue-700 dark:border-gray-700 dark:bg-gray-700 dark:text-white" : "flex items-center justify-center h-8 px-3 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"),
431
+ "aria-current": l.currentPage === s ? "page" : void 0
432
+ }, y(s), 11, ce)
407
433
  ]))), 128)),
408
434
  e("li", null, [
409
435
  e("a", {
410
436
  href: "#",
411
- onClick: t[3] || (t[3] = _((...s) => n.nextPage && n.nextPage(...s), ["prevent"])),
437
+ onClick: t[3] || (t[3] = P((...s) => a.nextPage && a.nextPage(...s), ["prevent"])),
412
438
  class: "flex items-center justify-center h-8 px-3 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
413
439
  }, t[17] || (t[17] = [
414
440
  e("span", { class: "sr-only" }, "Next", -1),
@@ -432,10 +458,10 @@ function ue(r, t, l, u, a, n) {
432
458
  ])
433
459
  ])
434
460
  ])
435
- ])) : x("", !0)
461
+ ])) : v("", !0)
436
462
  ]);
437
463
  }
438
- const be = /* @__PURE__ */ H(V, [["render", ue], ["__scopeId", "data-v-c0e2c944"]]);
464
+ const pe = /* @__PURE__ */ B(H, [["render", ue], ["__scopeId", "data-v-84b2e0a5"]]);
439
465
  export {
440
- be as default
466
+ pe as default
441
467
  };
@@ -1,9 +1,10 @@
1
- import r from "./GLButton.vue.js";
2
- import { resolveComponent as c, createElementBlock as m, createCommentVNode as _, openBlock as u, createElementVNode as e, toDisplayString as o, createVNode as s, withCtx as a, createTextVNode as d } from "vue";
3
- import f from "../../_virtual/_plugin-vue_export-helper.js";
4
- const g = {
1
+ import { ref as d, watch as y, resolveComponent as b, createElementBlock as f, createCommentVNode as u, openBlock as _, createElementVNode as e, toDisplayString as l, withDirectives as h, createTextVNode as c, withKeys as v, withModifiers as k, vModelText as w, createVNode as g, withCtx as x } from "vue";
2
+ import C from "./GLButton.vue.js";
3
+ import { useGlFocusTrap as D, nextGlId as p } from "./useGlFocusTrap.js";
4
+ import I from "../../_virtual/_plugin-vue_export-helper.js";
5
+ const T = {
5
6
  components: {
6
- GlButton: r
7
+ GlButton: C
7
8
  },
8
9
  props: {
9
10
  isOpen: {
@@ -14,76 +15,140 @@ const g = {
14
15
  type: Object,
15
16
  default: () => {
16
17
  }
18
+ },
19
+ // When set, the delete button stays disabled until exactly this text is typed.
20
+ confirm_text: {
21
+ type: String,
22
+ default: ""
23
+ },
24
+ // Escape emits cancel-delete. Set false to only close through the buttons.
25
+ close_on_escape: {
26
+ type: Boolean,
27
+ default: !0
28
+ }
29
+ },
30
+ emits: ["confirm-delete", "cancel-delete"],
31
+ setup(a, { emit: n }) {
32
+ const t = d(null), o = d(null), r = d(null), i = d("");
33
+ return y(() => a.isOpen, (s) => {
34
+ s && (i.value = "");
35
+ }), D(t, () => a.isOpen, {
36
+ closeOnEscape: () => a.close_on_escape,
37
+ onEscape: () => n("cancel-delete"),
38
+ initialFocus: () => o.value || r.value?.$el || null
39
+ }), {
40
+ panel: t,
41
+ confirmInput: o,
42
+ cancelButton: r,
43
+ typedText: i,
44
+ titleId: p("gl-delete-confirmation-title"),
45
+ inputId: p("gl-delete-confirmation-input")
46
+ };
47
+ },
48
+ computed: {
49
+ canConfirm() {
50
+ return !this.confirm_text || this.typedText === this.confirm_text;
17
51
  }
18
52
  },
19
53
  methods: {
20
54
  confirmDeletion() {
21
- this.$emit("confirm-delete");
55
+ this.canConfirm && this.$emit("confirm-delete");
22
56
  },
23
57
  cancelDeletion() {
24
58
  this.$emit("cancel-delete");
25
59
  }
26
60
  }
27
- }, p = {
61
+ }, B = ["aria-labelledby"], O = { class: "flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:p-0" }, V = {
62
+ ref: "panel",
63
+ tabindex: "-1",
64
+ class: "inline-block relative overflow-hidden text-left align-bottom transition-all transform bg-white dark:bg-gray-800 rounded-lg shadow-xl sm:my-8 sm:align-middle sm:max-w-lg sm:w-full focus:outline-hidden"
65
+ }, E = { class: "px-4 pt-5 pb-4 sm:p-6 sm:pb-4" }, N = { class: "sm:flex sm:items-start" }, G = { class: "mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left" }, M = ["id"], j = { class: "mt-2" }, F = { class: "text-sm" }, K = {
28
66
  key: 0,
29
- class: "fixed inset-0 z-99999 overflow-y-auto",
30
- "aria-labelledby": "modal-title",
31
- role: "dialog",
32
- "aria-modal": "true"
33
- }, b = { class: "flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:p-0" }, h = { class: "inline-block relative overflow-hidden text-left align-bottom transition-all transform bg-white dark:bg-gray-800 rounded-lg shadow-xl sm:my-8 sm:align-middle sm:max-w-lg sm:w-full" }, x = { class: "px-4 pt-5 pb-4 sm:p-6 sm:pb-4" }, y = { class: "sm:flex sm:items-start" }, v = { class: "mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left" }, k = {
34
- class: "text-lg font-medium leading-6",
35
- id: "modal-title"
36
- }, C = { class: "mt-2" }, w = { class: "text-sm" }, D = { class: "border-t border-gray-200 rounded-b dark:border-gray-600 px-4 py-3 sm:px-6 flex gap-2" };
37
- function B(N, n, t, V, O, i) {
38
- const l = c("gl-button");
39
- return t.isOpen ? (u(), m("div", p, [
40
- e("div", b, [
41
- n[0] || (n[0] = e("div", {
67
+ class: "mt-4 text-left"
68
+ }, S = ["for"], z = { class: "px-1 py-0.5 font-mono text-red-600 bg-gray-100 rounded-sm dark:bg-gray-900 dark:text-red-300" }, A = ["id"], U = { class: "border-t border-gray-200 rounded-b dark:border-gray-600 px-4 py-3 sm:px-6 flex gap-2" };
69
+ function q(a, n, t, o, r, i) {
70
+ const s = b("gl-button");
71
+ return t.isOpen ? (_(), f("div", {
72
+ key: 0,
73
+ class: "fixed inset-0 z-99999 overflow-y-auto",
74
+ "aria-labelledby": o.titleId,
75
+ role: "dialog",
76
+ "aria-modal": "true"
77
+ }, [
78
+ e("div", O, [
79
+ n[2] || (n[2] = e("div", {
42
80
  class: "fixed inset-0 transition-opacity bg-gray-500/75",
43
81
  "aria-hidden": "true"
44
82
  }, null, -1)),
45
- n[1] || (n[1] = e("span", {
83
+ n[3] || (n[3] = e("span", {
46
84
  class: "hidden sm:inline-block sm:align-middle sm:h-screen",
47
85
  "aria-hidden": "true"
48
86
  }, "​", -1)),
49
- e("div", h, [
50
- e("div", x, [
51
- e("div", y, [
52
- e("div", v, [
53
- e("h3", k, o(t.language?.title_delete_confirmation ?? "Confirm Deletion"), 1),
54
- e("div", C, [
55
- e("p", w, o(t.language?.message_delete_confirmation ?? "Are you sure you want to delete this item? This action cannot be undone."), 1)
56
- ])
87
+ e("div", V, [
88
+ e("div", E, [
89
+ e("div", N, [
90
+ e("div", G, [
91
+ e("h3", {
92
+ class: "text-lg font-medium leading-6",
93
+ id: o.titleId
94
+ }, l(t.language?.title_delete_confirmation ?? "Confirm Deletion"), 9, M),
95
+ e("div", j, [
96
+ e("p", F, l(t.language?.message_delete_confirmation ?? "Are you sure you want to delete this item? This action cannot be undone."), 1)
97
+ ]),
98
+ t.confirm_text ? (_(), f("div", K, [
99
+ e("label", {
100
+ for: o.inputId,
101
+ class: "block mb-1 text-xs font-medium text-gray-600 dark:text-gray-300"
102
+ }, [
103
+ c(l(t.language?.type_to_confirm ?? "Type") + " ", 1),
104
+ e("code", z, l(t.confirm_text), 1),
105
+ c(" " + l(t.language?.to_confirm ?? "to confirm"), 1)
106
+ ], 8, S),
107
+ h(e("input", {
108
+ id: o.inputId,
109
+ ref: "confirmInput",
110
+ "onUpdate:modelValue": n[0] || (n[0] = (m) => o.typedText = m),
111
+ type: "text",
112
+ autocomplete: "off",
113
+ spellcheck: "false",
114
+ class: "gl-input-form",
115
+ onKeydown: n[1] || (n[1] = v(k((...m) => i.confirmDeletion && i.confirmDeletion(...m), ["prevent"]), ["enter"]))
116
+ }, null, 40, A), [
117
+ [w, o.typedText]
118
+ ])
119
+ ])) : u("", !0)
57
120
  ])
58
121
  ])
59
122
  ]),
60
- e("div", D, [
61
- s(l, {
123
+ e("div", U, [
124
+ g(s, {
62
125
  onClick: i.confirmDeletion,
63
126
  tag: "button",
64
- button_type: "red"
127
+ button_type: "red",
128
+ is_disabled: !i.canConfirm
65
129
  }, {
66
- default: a(() => [
67
- d(o(t.language?.okbutton_delete_confirmation ?? "Delete"), 1)
130
+ default: x(() => [
131
+ c(l(t.language?.okbutton_delete_confirmation ?? "Delete"), 1)
68
132
  ]),
69
133
  _: 1
70
- }, 8, ["onClick"]),
71
- s(l, {
134
+ }, 8, ["onClick", "is_disabled"]),
135
+ g(s, {
136
+ ref: "cancelButton",
72
137
  onClick: i.cancelDeletion,
73
138
  tag: "button",
74
139
  button_type: "light"
75
140
  }, {
76
- default: a(() => [
77
- d(o(t.language?.cancelbutton_delete_confirmation ?? "Cancel"), 1)
141
+ default: x(() => [
142
+ c(l(t.language?.cancelbutton_delete_confirmation ?? "Cancel"), 1)
78
143
  ]),
79
144
  _: 1
80
145
  }, 8, ["onClick"])
81
146
  ])
82
- ])
147
+ ], 512)
83
148
  ])
84
- ])) : _("", !0);
149
+ ], 8, B)) : u("", !0);
85
150
  }
86
- const z = /* @__PURE__ */ f(g, [["render", B]]);
151
+ const Q = /* @__PURE__ */ I(T, [["render", q]]);
87
152
  export {
88
- z as default
153
+ Q as default
89
154
  };