lkt-table 1.2.6 → 1.2.8

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/build.js CHANGED
@@ -1,6 +1,6 @@
1
- import { reactive as H, defineComponent as G, ref as C, watch as U, nextTick as de, computed as f, resolveComponent as $, openBlock as s, createBlock as b, withCtx as F, createTextVNode as le, toDisplayString as j, unref as I, createElementBlock as m, Fragment as A, withModifiers as at, resolveDynamicComponent as Z, createCommentVNode as y, normalizeClass as te, createElementVNode as E, createVNode as X, renderList as P, renderSlot as N, withDirectives as x, vShow as ee, useSlots as nt, onMounted as st, createSlots as Be } from "vue";
2
- import { httpCall as ut } from "lkt-http-client";
3
- import { __ as q } from "lkt-i18n";
1
+ import { reactive as H, defineComponent as q, ref as C, watch as U, nextTick as de, computed as f, resolveComponent as $, openBlock as u, createBlock as b, withCtx as N, createTextVNode as le, toDisplayString as j, unref as I, createElementBlock as m, Fragment as A, withModifiers as at, resolveDynamicComponent as Z, createCommentVNode as y, normalizeClass as te, createElementVNode as E, createVNode as X, renderList as P, renderSlot as F, withDirectives as x, vShow as ee, useSlots as nt, onMounted as ut, createSlots as Ee } from "vue";
2
+ import { httpCall as st } from "lkt-http-client";
3
+ import { __ as z } from "lkt-i18n";
4
4
  import { createLktEvent as ce } from "lkt-events";
5
5
  import { generateRandomString as it, replaceAll as rt } from "lkt-string-tools";
6
6
  import { DataState as dt } from "lkt-data-state";
@@ -102,7 +102,7 @@ class K {
102
102
  if (!this.resource) return this;
103
103
  try {
104
104
  this.isLoading = !0;
105
- const t = await ut(this.resource, this.resourceData);
105
+ const t = await st(this.resource, this.resourceData);
106
106
  this.options = t.data, this.isLoading = !1, this.resourceLoaded = !0;
107
107
  } catch {
108
108
  this.isLoading = !1;
@@ -155,33 +155,33 @@ class K {
155
155
  return this.isForRowKey = t, this;
156
156
  }
157
157
  }
158
- const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n = !0) => H(new K(l, t).setIsSortable(n).defineAsLink(r)), Dl = (l, t, r, n = !0) => H(new K(l, t).setIsSortable(n).defineAsAction(r)), wl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsText()), Tl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsEmail()), Bl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsTel()), El = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsCheck()), Il = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsSwitch()), Ll = (l, t, r, n = !0) => H(new K(l, t).setIsSortable(n).defineAsSelect(r)), Ml = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).setIsHidden(!0)), Ee = (l, t, r, n) => {
158
+ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n = !0) => H(new K(l, t).setIsSortable(n).defineAsLink(r)), Dl = (l, t, r, n = !0) => H(new K(l, t).setIsSortable(n).defineAsAction(r)), wl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsText()), Tl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsEmail()), Bl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsTel()), El = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsCheck()), Il = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).defineAsSwitch()), Ll = (l, t, r, n = !0) => H(new K(l, t).setIsSortable(n).defineAsSelect(r)), Ml = (l, t, r = !0) => H(new K(l, t).setIsSortable(r).setIsHidden(!0)), Ie = (l, t, r, n) => {
159
159
  if (!r) return 0;
160
- let u = l[r.key], o = t[r.key];
160
+ let s = l[r.key], o = t[r.key];
161
161
  if (n === "asc") {
162
- if (u > o) return 1;
163
- if (o > u) return -1;
162
+ if (s > o) return 1;
163
+ if (o > s) return -1;
164
164
  } else {
165
- if (u > o) return -1;
166
- if (o > u) return 1;
165
+ if (s > o) return -1;
166
+ if (o > s) return 1;
167
167
  }
168
168
  return 0;
169
169
  }, Y = (l, t, r, n = []) => {
170
170
  if (l.extractTitleFromColumn) {
171
- let u = n.find((o) => o.key === l.extractTitleFromColumn);
172
- if (u)
173
- return Y(u, t, r, n);
171
+ let s = n.find((o) => o.key === l.extractTitleFromColumn);
172
+ if (s)
173
+ return Y(s, t, r, n);
174
174
  }
175
175
  if (l.formatter && typeof l.formatter == "function") {
176
- let u = l.formatter(t[l.key], t, l, r);
177
- return u.startsWith("__:") ? q(u.substring(3)) : u;
176
+ let s = l.formatter(t[l.key], t, l, r);
177
+ return s.startsWith("__:") ? z(s.substring(3)) : s;
178
178
  }
179
179
  return t[l.key];
180
180
  }, gt = (l, t, r) => {
181
181
  if (!l.colspan) return -1;
182
182
  let n = t;
183
- return r.forEach((u) => {
184
- let o = me(l, u);
183
+ return r.forEach((s) => {
184
+ let o = me(l, s);
185
185
  o > 0 && o < n && (n = o);
186
186
  }), n;
187
187
  }, me = (l, t) => l.colspan === !1 ? !1 : typeof l.colspan == "function" ? l.colspan(t) : l.colspan, Ct = (l, t, r) => {
@@ -200,7 +200,7 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
200
200
  if (l[r].key === t) return l[r];
201
201
  }
202
202
  return null;
203
- }, Le = /* @__PURE__ */ G({
203
+ }, Me = /* @__PURE__ */ q({
204
204
  __name: "LktTableCell",
205
205
  props: {
206
206
  modelValue: { default: () => ({}) },
@@ -211,31 +211,31 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
211
211
  },
212
212
  emits: ["update:modelValue"],
213
213
  setup(l, { emit: t }) {
214
- const r = t, n = l, u = C(n.modelValue), o = C(u.value[n.column.key]), h = C(null), g = C(n.column.showLoading());
214
+ const r = t, n = l, s = C(n.modelValue), o = C(s.value[n.column.key]), h = C(null), g = C(n.column.showLoading());
215
215
  U(o, (a) => {
216
- const i = JSON.parse(JSON.stringify(u.value));
216
+ const i = JSON.parse(JSON.stringify(s.value));
217
217
  i[n.column.key] = a, r("update:modelValue", i);
218
218
  }), U(() => n.modelValue, (a) => {
219
- u.value = a, o.value = u.value[n.column.key];
219
+ s.value = a, o.value = s.value[n.column.key];
220
220
  }), U(() => n.column, () => {
221
221
  n.column.resourceLoaded && de(() => g.value = !1);
222
222
  }, { deep: !0 }), n.column.hasToLoadResource() && n.column.loadResource();
223
- const v = f(() => ({ ...n.column.slotData, item: u.value }));
223
+ const v = f(() => ({ ...n.column.slotData, item: s.value }));
224
224
  return (a, i) => {
225
225
  const W = $("lkt-anchor"), J = $("lkt-field-text"), d = $("lkt-field-switch"), L = $("lkt-field-file"), S = $("lkt-loader"), V = $("lkt-field-select");
226
- return a.column.type === "link" ? (s(), b(W, {
226
+ return a.column.type === "link" ? (u(), b(W, {
227
227
  key: 0,
228
- to: a.column.getHref(u.value)
228
+ to: a.column.getHref(s.value)
229
229
  }, {
230
- default: F(() => [
231
- le(j(I(Y)(a.column, u.value, a.i)), 1)
230
+ default: N(() => [
231
+ le(j(I(Y)(a.column, s.value, a.i)), 1)
232
232
  ]),
233
233
  _: 1
234
- }, 8, ["to"])) : a.column.type === "action" ? (s(), m("a", {
234
+ }, 8, ["to"])) : a.column.type === "action" ? (u(), m("a", {
235
235
  key: 1,
236
236
  href: "#",
237
- onClick: i[0] || (i[0] = (p) => a.column.doAction(u.value))
238
- }, j(I(Y)(a.column, u.value, a.i)), 1)) : a.column.type === "text" ? (s(), b(J, {
237
+ onClick: i[0] || (i[0] = (p) => a.column.doAction(s.value))
238
+ }, j(I(Y)(a.column, s.value, a.i)), 1)) : a.column.type === "text" ? (u(), b(J, {
239
239
  key: 2,
240
240
  "read-mode": !a.column.editable || !a.editModeEnabled,
241
241
  ref: (p) => h.value = p,
@@ -244,7 +244,7 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
244
244
  "slot-data": v.value,
245
245
  modelValue: o.value,
246
246
  "onUpdate:modelValue": i[1] || (i[1] = (p) => o.value = p)
247
- }, null, 8, ["read-mode", "edit-slot", "value-slot", "slot-data", "modelValue"])) : a.column.type === "email" ? (s(), b(J, {
247
+ }, null, 8, ["read-mode", "edit-slot", "value-slot", "slot-data", "modelValue"])) : a.column.type === "email" ? (u(), b(J, {
248
248
  key: 3,
249
249
  "read-mode": !a.column.editable || !a.editModeEnabled,
250
250
  ref: (p) => h.value = p,
@@ -254,7 +254,7 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
254
254
  "is-email": "",
255
255
  modelValue: o.value,
256
256
  "onUpdate:modelValue": i[2] || (i[2] = (p) => o.value = p)
257
- }, null, 8, ["read-mode", "edit-slot", "value-slot", "slot-data", "modelValue"])) : a.column.type === "tel" ? (s(), b(J, {
257
+ }, null, 8, ["read-mode", "edit-slot", "value-slot", "slot-data", "modelValue"])) : a.column.type === "tel" ? (u(), b(J, {
258
258
  key: 4,
259
259
  "read-mode": !a.column.editable || !a.editModeEnabled,
260
260
  ref: (p) => h.value = p,
@@ -264,27 +264,27 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
264
264
  "is-tel": "",
265
265
  modelValue: o.value,
266
266
  "onUpdate:modelValue": i[3] || (i[3] = (p) => o.value = p)
267
- }, null, 8, ["read-mode", "edit-slot", "value-slot", "slot-data", "modelValue"])) : a.column.type === "check" ? (s(), b(d, {
267
+ }, null, 8, ["read-mode", "edit-slot", "value-slot", "slot-data", "modelValue"])) : a.column.type === "check" ? (u(), b(d, {
268
268
  key: 5,
269
269
  "is-check": "",
270
270
  "read-mode": !a.column.editable || !a.editModeEnabled,
271
271
  ref: (p) => h.value = p,
272
272
  modelValue: o.value,
273
273
  "onUpdate:modelValue": i[4] || (i[4] = (p) => o.value = p)
274
- }, null, 8, ["read-mode", "modelValue"])) : a.column.type === "switch" ? (s(), b(d, {
274
+ }, null, 8, ["read-mode", "modelValue"])) : a.column.type === "switch" ? (u(), b(d, {
275
275
  key: 6,
276
276
  "read-mode": !a.column.editable || !a.editModeEnabled,
277
277
  ref: (p) => h.value = p,
278
278
  modelValue: o.value,
279
279
  "onUpdate:modelValue": i[5] || (i[5] = (p) => o.value = p)
280
- }, null, 8, ["read-mode", "modelValue"])) : a.column.type === "file" ? (s(), b(L, {
280
+ }, null, 8, ["read-mode", "modelValue"])) : a.column.type === "file" ? (u(), b(L, {
281
281
  key: 7,
282
282
  "read-mode": !a.column.editable || !a.editModeEnabled,
283
283
  ref: (p) => h.value = p,
284
284
  modelValue: o.value,
285
285
  "onUpdate:modelValue": i[6] || (i[6] = (p) => o.value = p)
286
- }, null, 8, ["read-mode", "modelValue"])) : a.column.type === "select" ? (s(), m(A, { key: 8 }, [
287
- g.value ? (s(), b(S, { key: 0 })) : (s(), b(V, {
286
+ }, null, 8, ["read-mode", "modelValue"])) : a.column.type === "select" ? (u(), m(A, { key: 8 }, [
287
+ g.value ? (u(), b(S, { key: 0 })) : (u(), b(V, {
288
288
  key: 1,
289
289
  "read-mode": !a.column.editable || !a.editModeEnabled,
290
290
  ref: (p) => h.value = p,
@@ -300,8 +300,8 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
300
300
  "multiple-display": a.column.multipleDisplay,
301
301
  "multiple-display-edition": a.column.multipleDisplayEdition
302
302
  }, null, 8, ["read-mode", "modelValue", "slot-data", "resource", "use-resource-slot", "resource-data", "options", "multiple", "tags", "multiple-display", "multiple-display-edition"]))
303
- ], 64)) : (s(), m(A, { key: 9 }, [
304
- le(j(I(Y)(a.column, u.value, a.i, a.columns)), 1)
303
+ ], 64)) : (u(), m(A, { key: 9 }, [
304
+ le(j(I(Y)(a.column, s.value, a.i, a.columns)), 1)
305
305
  ], 64));
306
306
  };
307
307
  }
@@ -309,7 +309,7 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
309
309
  navButtonSlot: "",
310
310
  dropButtonSlot: "",
311
311
  createButtonSlot: ""
312
- }, Dt = /* @__PURE__ */ G({
312
+ }, Dt = /* @__PURE__ */ q({
313
313
  __name: "DropButton",
314
314
  props: {
315
315
  disabled: { type: Boolean, default: !1 },
@@ -321,21 +321,21 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
321
321
  },
322
322
  emits: ["click"],
323
323
  setup(l, { emit: t }) {
324
- const r = t, n = l, u = f(() => R.dropButtonSlot !== ""), o = f(() => R.dropButtonSlot), h = f(() => n.text.startsWith("__:") ? q(n.text.substring(3)) : n.text);
324
+ const r = t, n = l, s = f(() => R.dropButtonSlot !== ""), o = f(() => R.dropButtonSlot), h = f(() => n.text.startsWith("__:") ? z(n.text.substring(3)) : n.text);
325
325
  return (g, v) => {
326
326
  const a = $("lkt-button");
327
- return s(), b(a, {
327
+ return u(), b(a, {
328
328
  palette: "table-delete",
329
- icon: u.value ? "" : g.icon,
330
- text: u.value ? "" : h.value,
329
+ icon: s.value ? "" : g.icon,
330
+ text: s.value ? "" : h.value,
331
331
  resource: g.resource,
332
332
  "resource-data": g.resourceData,
333
333
  "confirm-modal": g.confirm,
334
334
  disabled: g.disabled,
335
335
  onClick: v[0] || (v[0] = at((i) => r("click"), ["prevent", "stop"]))
336
336
  }, {
337
- default: F(() => [
338
- u.value ? (s(), b(Z(o.value), { key: 0 })) : y("", !0)
337
+ default: N(() => [
338
+ s.value ? (u(), b(Z(o.value), { key: 0 })) : y("", !0)
339
339
  ]),
340
340
  _: 1
341
341
  }, 8, ["icon", "text", "resource", "resource-data", "confirm-modal", "disabled"]);
@@ -350,7 +350,7 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
350
350
  }, Et = { class: "lkt-table-nav-container" }, It = /* @__PURE__ */ E("i", { class: "" }, null, -1), Lt = /* @__PURE__ */ E("i", { class: "" }, null, -1), Mt = ["data-column", "colspan", "title", "onClick"], $t = {
351
351
  key: 4,
352
352
  class: "lkt-table-col-drop"
353
- }, At = /* @__PURE__ */ G({
353
+ }, At = /* @__PURE__ */ q({
354
354
  __name: "LktTableRow",
355
355
  props: {
356
356
  modelValue: { default: () => ({}) },
@@ -372,7 +372,7 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
372
372
  },
373
373
  emits: ["update:modelValue", "click", "show", "item-up", "item-down", "item-drop"],
374
374
  setup(l, { emit: t }) {
375
- const r = t, n = l, u = C(n.modelValue), o = (d, L, S) => {
375
+ const r = t, n = l, s = C(n.modelValue), o = (d, L, S) => {
376
376
  r("click", d, ce("", { item: L, column: S }));
377
377
  }, h = (d, L) => {
378
378
  r("show", d, ce("", { i: L }));
@@ -388,31 +388,31 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
388
388
  }, J = () => {
389
389
  r("item-drop", n.i);
390
390
  };
391
- return U(() => n.modelValue, (d) => u.value = d), U(u, (d) => {
391
+ return U(() => n.modelValue, (d) => s.value = d), U(s, (d) => {
392
392
  r("update:modelValue", d, n.i);
393
393
  }, { deep: !0 }), (d, L) => {
394
394
  const S = $("lkt-button");
395
- return s(), m("tr", {
395
+ return u(), m("tr", {
396
396
  "data-i": d.i,
397
397
  "data-draggable": d.isDraggable
398
398
  }, [
399
- d.sortable && d.isDraggable && d.editModeEnabled ? (s(), m("td", {
399
+ d.sortable && d.isDraggable && d.editModeEnabled ? (u(), m("td", {
400
400
  key: 0,
401
401
  "data-role": "drag-indicator",
402
402
  class: te(g.value)
403
- }, null, 2)) : d.sortable && d.editModeEnabled ? (s(), m("td", Tt)) : y("", !0),
404
- d.addNavigation && d.editModeEnabled ? (s(), m("td", Bt, [
403
+ }, null, 2)) : d.sortable && d.editModeEnabled ? (u(), m("td", Tt)) : y("", !0),
404
+ d.addNavigation && d.editModeEnabled ? (u(), m("td", Bt, [
405
405
  E("div", Et, [
406
406
  X(S, {
407
407
  palette: "table-nav",
408
408
  disabled: d.i === 0,
409
409
  onClick: i
410
410
  }, {
411
- default: F(() => [
412
- v.value ? (s(), b(Z(a.value), {
411
+ default: N(() => [
412
+ v.value ? (u(), b(Z(a.value), {
413
413
  key: 0,
414
414
  direction: "up"
415
- })) : (s(), m(A, { key: 1 }, [
415
+ })) : (u(), m(A, { key: 1 }, [
416
416
  It,
417
417
  le(" UP ")
418
418
  ], 64))
@@ -424,11 +424,11 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
424
424
  disabled: d.latestRow,
425
425
  onClick: W
426
426
  }, {
427
- default: F(() => [
428
- v.value ? (s(), b(Z(a.value), {
427
+ default: N(() => [
428
+ v.value ? (u(), b(Z(a.value), {
429
429
  key: 0,
430
430
  direction: "down"
431
- })) : (s(), m(A, { key: 1 }, [
431
+ })) : (u(), m(A, { key: 1 }, [
432
432
  Lt,
433
433
  le(" DOWN ")
434
434
  ], 64))
@@ -437,30 +437,30 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
437
437
  }, 8, ["disabled"])
438
438
  ])
439
439
  ])) : y("", !0),
440
- d.displayHiddenColumnsIndicator ? (s(), m("td", {
440
+ d.displayHiddenColumnsIndicator ? (u(), m("td", {
441
441
  key: 3,
442
442
  onClick: L[0] || (L[0] = (V) => h(V, d.i)),
443
443
  "data-role": "show-more",
444
444
  class: te(d.hiddenIsVisible ? "state-open" : "")
445
445
  }, null, 2)) : y("", !0),
446
- (s(!0), m(A, null, P(d.visibleColumns, (V) => (s(), m(A, null, [
447
- I(Ct)(V, d.emptyColumns, u.value) ? (s(), m("td", {
446
+ (u(!0), m(A, null, P(d.visibleColumns, (V) => (u(), m(A, null, [
447
+ I(Ct)(V, d.emptyColumns, s.value) ? (u(), m("td", {
448
448
  key: 0,
449
449
  "data-column": V.key,
450
- colspan: I(me)(V, u.value),
451
- title: I(Y)(V, u.value, d.i, d.visibleColumns),
452
- onClick: (p) => o(p, u.value, V)
450
+ colspan: I(me)(V, s.value),
451
+ title: I(Y)(V, s.value, d.i, d.visibleColumns),
452
+ onClick: (p) => o(p, s.value, V)
453
453
  }, [
454
- d.$slots[V.key] ? N(d.$slots, V.key, {
454
+ d.$slots[V.key] ? F(d.$slots, V.key, {
455
455
  key: 0,
456
- value: u.value[V.key],
457
- item: u.value,
456
+ value: s.value[V.key],
457
+ item: s.value,
458
458
  column: V,
459
459
  i: d.i
460
- }) : u.value ? (s(), b(Le, {
460
+ }) : s.value ? (u(), b(Me, {
461
461
  key: 1,
462
- modelValue: u.value,
463
- "onUpdate:modelValue": L[1] || (L[1] = (p) => u.value = p),
462
+ modelValue: s.value,
463
+ "onUpdate:modelValue": L[1] || (L[1] = (p) => s.value = p),
464
464
  column: V,
465
465
  columns: d.visibleColumns,
466
466
  "edit-mode-enabled": d.editModeEnabled,
@@ -468,10 +468,10 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
468
468
  }, null, 8, ["modelValue", "column", "columns", "edit-mode-enabled", "i"])) : y("", !0)
469
469
  ], 8, Mt)) : y("", !0)
470
470
  ], 64))), 256)),
471
- d.canDrop && d.editModeEnabled ? (s(), m("td", $t, [
471
+ d.canDrop && d.editModeEnabled ? (u(), m("td", $t, [
472
472
  X(Dt, {
473
473
  resource: d.dropResource,
474
- "resource-data": u.value,
474
+ "resource-data": s.value,
475
475
  confirm: d.dropConfirm,
476
476
  text: d.dropText,
477
477
  icon: d.dropIcon,
@@ -481,7 +481,7 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
481
481
  ], 8, wt);
482
482
  };
483
483
  }
484
- }), Rt = { "data-role": "hidden-row" }, Ot = ["colspan"], Nt = ["data-column"], Ft = ["data-i"], Ut = ["data-column", "title", "onClick"], Ht = /* @__PURE__ */ G({
484
+ }), Rt = { "data-role": "hidden-row" }, Ot = ["colspan"], Ft = ["data-column"], Nt = ["data-i"], Ut = ["data-column", "title", "onClick"], Ht = /* @__PURE__ */ q({
485
485
  __name: "LktHiddenRow",
486
486
  props: {
487
487
  modelValue: { default: () => ({}) },
@@ -496,48 +496,48 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
496
496
  },
497
497
  emits: ["update:modelValue", "click"],
498
498
  setup(l, { emit: t }) {
499
- const r = t, n = l, u = C(n.modelValue), o = (h, g, v) => {
499
+ const r = t, n = l, s = C(n.modelValue), o = (h, g, v) => {
500
500
  r("click", h, ce("", { item: g, column: v }));
501
501
  };
502
- return U(() => n.modelValue, (h) => u.value = h), U(u, () => r("update:modelValue", u.value)), (h, g) => x((s(), m("tr", Rt, [
502
+ return U(() => n.modelValue, (h) => s.value = h), U(s, () => r("update:modelValue", s.value)), (h, g) => x((u(), m("tr", Rt, [
503
503
  E("td", { colspan: h.hiddenColumnsColSpan }, [
504
504
  E("table", null, [
505
505
  E("tr", null, [
506
- (s(!0), m(A, null, P(h.hiddenColumns, (v) => (s(), m("th", {
506
+ (u(!0), m(A, null, P(h.hiddenColumns, (v) => (u(), m("th", {
507
507
  "data-column": v.key
508
508
  }, [
509
509
  E("div", null, j(v.label), 1)
510
- ], 8, Nt))), 256))
510
+ ], 8, Ft))), 256))
511
511
  ]),
512
512
  E("tr", { "data-i": h.i }, [
513
- (s(!0), m(A, null, P(h.hiddenColumns, (v, a) => (s(), m("td", {
513
+ (u(!0), m(A, null, P(h.hiddenColumns, (v, a) => (u(), m("td", {
514
514
  "data-column": v.key,
515
- title: I(Y)(v, u.value, a, h.hiddenColumns),
516
- onClick: (i) => o(i, u.value, v)
515
+ title: I(Y)(v, s.value, a, h.hiddenColumns),
516
+ onClick: (i) => o(i, s.value, v)
517
517
  }, [
518
- h.$slots[v.key] ? N(h.$slots, v.key, {
518
+ h.$slots[v.key] ? F(h.$slots, v.key, {
519
519
  key: 0,
520
- value: u.value[v.key],
521
- item: u.value,
520
+ value: s.value[v.key],
521
+ item: s.value,
522
522
  column: v,
523
523
  i: a
524
- }) : (s(), b(Le, {
524
+ }) : (u(), b(Me, {
525
525
  key: 1,
526
526
  column: v,
527
527
  columns: h.hiddenColumns,
528
- modelValue: u.value,
529
- "onUpdate:modelValue": g[0] || (g[0] = (i) => u.value = i),
528
+ modelValue: s.value,
529
+ "onUpdate:modelValue": g[0] || (g[0] = (i) => s.value = i),
530
530
  i: a
531
531
  }, null, 8, ["column", "columns", "modelValue", "i"]))
532
532
  ], 8, Ut))), 256))
533
- ], 8, Ft)
533
+ ], 8, Nt)
534
534
  ])
535
535
  ], 8, Ot)
536
536
  ], 512)), [
537
537
  [ee, h.hiddenIsVisible]
538
538
  ]);
539
539
  }
540
- }), Ie = /* @__PURE__ */ G({
540
+ }), Le = /* @__PURE__ */ q({
541
541
  __name: "CreateButton",
542
542
  props: {
543
543
  disabled: { type: Boolean, default: !1 },
@@ -546,24 +546,24 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
546
546
  },
547
547
  emits: ["click"],
548
548
  setup(l, { emit: t }) {
549
- const r = t, n = l, u = f(() => R.createButtonSlot !== ""), o = f(() => R.createButtonSlot), h = f(() => n.text.startsWith("__:") ? q(n.text.substring(3)) : n.text);
549
+ const r = t, n = l, s = f(() => R.createButtonSlot !== ""), o = f(() => R.createButtonSlot), h = f(() => n.text.startsWith("__:") ? z(n.text.substring(3)) : n.text);
550
550
  return (g, v) => {
551
551
  const a = $("lkt-button");
552
- return s(), b(a, {
552
+ return u(), b(a, {
553
553
  palette: "table-create",
554
554
  disabled: g.disabled,
555
- icon: u.value ? "" : g.icon,
556
- text: u.value ? "" : h.value,
555
+ icon: s.value ? "" : g.icon,
556
+ text: s.value ? "" : h.value,
557
557
  onClick: v[0] || (v[0] = (i) => r("click"))
558
558
  }, {
559
- default: F(() => [
560
- u.value ? (s(), b(Z(o.value), { key: 0 })) : y("", !0)
559
+ default: N(() => [
560
+ s.value ? (u(), b(Z(o.value), { key: 0 })) : y("", !0)
561
561
  ]),
562
562
  _: 1
563
563
  }, 8, ["disabled", "icon", "text"]);
564
564
  };
565
565
  }
566
- }), Kt = ["data-column", "data-sortable", "data-sort", "colspan", "title"], _t = /* @__PURE__ */ G({
566
+ }), Kt = ["data-column", "data-sortable", "data-sort", "colspan", "title"], _t = /* @__PURE__ */ q({
567
567
  __name: "TableHeader",
568
568
  props: {
569
569
  column: { default: () => ({}) },
@@ -574,24 +574,24 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
574
574
  },
575
575
  emits: ["click"],
576
576
  setup(l, { emit: t }) {
577
- const r = t, n = l, u = f(() => gt(n.column, n.amountOfColumns, n.items)), o = f(() => n.column.sortable === !0), h = f(() => o.value && n.sortBy === n.column.key ? n.sortDirection : ""), g = f(() => n.column.label.startsWith("__:") ? q(n.column.label.substring(3)) : n.column.label), v = () => {
577
+ const r = t, n = l, s = f(() => gt(n.column, n.amountOfColumns, n.items)), o = f(() => n.column.sortable === !0), h = f(() => o.value && n.sortBy === n.column.key ? n.sortDirection : ""), g = f(() => n.column.label.startsWith("__:") ? z(n.column.label.substring(3)) : n.column.label), v = () => {
578
578
  r("click", n.column);
579
579
  };
580
- return (a, i) => (s(), m("th", {
580
+ return (a, i) => (u(), m("th", {
581
581
  "data-column": a.column.key,
582
582
  "data-sortable": o.value,
583
583
  "data-sort": h.value,
584
- colspan: u.value,
584
+ colspan: s.value,
585
585
  title: g.value,
586
586
  onClick: v
587
587
  }, [
588
588
  E("div", null, j(g.value), 1)
589
589
  ], 8, Kt));
590
590
  }
591
- }), Pt = ["id"], Wt = { key: 0 }, jt = { class: "lkt-table-page-buttons" }, Jt = { key: 1 }, zt = { class: "switch-edition-mode" }, qt = {
591
+ }), Pt = ["id"], Wt = { key: 0 }, jt = { class: "lkt-table-page-buttons" }, Jt = { key: 1 }, Gt = { class: "switch-edition-mode" }, zt = {
592
592
  key: 0,
593
593
  class: "lkt-table-page-buttons"
594
- }, Gt = {
594
+ }, qt = {
595
595
  key: 1,
596
596
  class: "lkt-table-page-filters"
597
597
  }, Qt = ["data-sortable"], Xt = { key: 0 }, Yt = {
@@ -609,12 +609,12 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
609
609
  }, nl = {
610
610
  key: 5,
611
611
  class: "lkt-table-page-buttons lkt-table-page-buttons-bottom"
612
- }, sl = /* @__PURE__ */ G({
612
+ }, ul = /* @__PURE__ */ q({
613
613
  __name: "LktTable",
614
614
  props: {
615
615
  modelValue: { default: () => [] },
616
616
  columns: { default: () => [] },
617
- sorter: { type: Function, default: Ee },
617
+ sorter: { type: Function, default: Ie },
618
618
  draggableChecker: { type: Function, default: (l) => !0 },
619
619
  checkValidDrag: { type: Function, default: void 0 },
620
620
  sortable: { type: Boolean, default: !1 },
@@ -653,17 +653,18 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
653
653
  dropResource: { default: "" },
654
654
  addNavigation: { type: Boolean, default: !1 },
655
655
  itemMode: { type: Boolean, default: !1 },
656
- createEnabledValidator: { type: Function, default: void 0 }
656
+ createEnabledValidator: { type: Function, default: void 0 },
657
+ newValueGenerator: { type: Function, default: void 0 }
657
658
  },
658
659
  emits: ["update:modelValue", "sort", "click", "save", "error", "before-save"],
659
660
  setup(l, { expose: t, emit: r }) {
660
- const n = r, u = nt(), o = l, h = {}, g = C(typeof o.sorter == "function" ? o.sorter : Ee), v = C(St(o.columns)), a = C("asc"), i = C(o.modelValue), W = C(h), J = C(null), d = C(o.columns), L = C(o.page), S = C(!1), V = C(!1), p = C(o.perms), fe = C(null), Me = C({}), Q = C(new dt({ items: i.value }, o.dataStateConfig)), M = C(o.editMode), $e = (e) => {
661
+ const n = r, s = nt(), o = l, h = {}, g = C(typeof o.sorter == "function" ? o.sorter : Ie), v = C(St(o.columns)), a = C("asc"), i = C(o.modelValue), W = C(h), J = C(null), d = C(o.columns), L = C(o.page), S = C(!1), V = C(!1), p = C(o.perms), fe = C(null), $e = C({}), Q = C(new dt({ items: i.value }, o.dataStateConfig)), M = C(o.editMode), Ae = (e) => {
661
662
  Array.isArray(e) && (i.value = e), S.value = !1, V.value = !0, Q.value.store({ items: i.value }).turnStoredIntoOriginal();
662
- }, Ae = (e) => {
663
+ }, Re = (e) => {
663
664
  p.value = e;
664
- }, Re = () => de(() => S.value = !0), Oe = () => {
665
+ }, Oe = () => de(() => S.value = !0), Fe = () => {
665
666
  fe.value.doRefresh();
666
- }, oe = it(12), se = f(() => {
667
+ }, oe = it(12), ue = f(() => {
667
668
  if (!o.hideEmptyColumns) return [];
668
669
  let e = [];
669
670
  return d.value.forEach((c) => {
@@ -674,17 +675,17 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
674
675
  D[k] && (T = !0);
675
676
  }), T || e.push(k);
676
677
  }), e;
677
- }), ae = f(() => d.value.filter((e) => !e.hidden)), ue = f(() => d.value.filter((e) => e.hidden)), Ne = f(() => {
678
+ }), ae = f(() => d.value.filter((e) => !e.hidden)), se = f(() => d.value.filter((e) => e.hidden)), Ne = f(() => {
678
679
  let e = ae.value.length + 1;
679
680
  return o.sortable && ++e, e;
680
- }), Fe = f(() => d.value.filter((e) => e.isForRowKey)), pe = f(() => ue.value.length > 0 && !o.sortable), Ue = f(() => d.value.map((e) => e.key)), ve = f(() => {
681
+ }), Ue = f(() => d.value.filter((e) => e.isForRowKey)), pe = f(() => se.value.length > 0 && !o.sortable), He = f(() => d.value.map((e) => e.key)), ve = f(() => {
681
682
  let e = [];
682
- for (let c in u) Ue.value.indexOf(c) !== -1 && e.push(c);
683
+ for (let c in s) He.value.indexOf(c) !== -1 && e.push(c);
683
684
  return e;
684
- }), he = f(() => o.hiddenSave || S.value || !o.saveResource ? !1 : M.value && Q.value.changed() ? !0 : M.value), He = f(() => o.switchEditionEnabled ? !0 : he.value || M.value && o.canCreate), Ke = f(() => o.saveDisabled || typeof o.saveValidator == "function" && !o.saveValidator(i.value) ? !1 : Q.value.changed()), _e = f(() => i.value.length), Pe = f(() => ({
685
+ }), he = f(() => o.hiddenSave || S.value || !o.saveResource ? !1 : M.value && Q.value.changed() ? !0 : M.value), Ke = f(() => o.switchEditionEnabled ? !0 : he.value || M.value && o.canCreate), _e = f(() => o.saveDisabled || typeof o.saveValidator == "function" && !o.saveValidator(i.value) ? !1 : Q.value.changed()), Pe = f(() => i.value.length), We = f(() => ({
685
686
  items: i.value,
686
687
  ...o.saveResourceData
687
- })), We = f(() => o.titleTag === "" ? "h2" : o.titleTag), je = f(() => o.wrapContentTag === "" ? "div" : o.wrapContentTag), ie = f(() => o.title.startsWith("__:") ? q(o.title.substring(3)) : o.title), Je = f(() => o.saveText.startsWith("__:") ? q(o.saveText.substring(3)) : o.saveText), ze = f(() => o.editModeText.startsWith("__:") ? q(o.editModeText.substring(3)) : o.editModeText), ne = f(() => p.value.includes("create")), qe = f(() => p.value.includes("read")), Ge = f(() => p.value.includes("update")), re = f(() => p.value.includes("drop")), Qe = (e) => {
688
+ })), je = f(() => o.titleTag === "" ? "h2" : o.titleTag), Je = f(() => o.wrapContentTag === "" ? "div" : o.wrapContentTag), ie = f(() => o.title.startsWith("__:") ? z(o.title.substring(3)) : o.title), Ge = f(() => o.saveText.startsWith("__:") ? z(o.saveText.substring(3)) : o.saveText), ze = f(() => o.editModeText.startsWith("__:") ? z(o.editModeText.substring(3)) : o.editModeText), ne = f(() => p.value.includes("create")), qe = f(() => p.value.includes("read")), Qe = f(() => p.value.includes("update")), re = f(() => p.value.includes("drop")), Xe = (e) => {
688
689
  let c = e.target;
689
690
  if (typeof c.dataset.column > "u")
690
691
  do
@@ -712,13 +713,20 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
712
713
  }), e.setOptions(k);
713
714
  }
714
715
  });
715
- }, Xe = (e) => typeof o.checkValidDrag == "function" ? o.checkValidDrag(e) : !0, Se = (e) => typeof o.draggableChecker == "function" ? o.draggableChecker(e) : !0, Ve = () => {
716
+ }, Ye = (e) => typeof o.checkValidDrag == "function" ? o.checkValidDrag(e) : !0, Se = (e) => typeof o.draggableChecker == "function" ? o.draggableChecker(e) : !0, Ve = () => {
717
+ if (typeof o.newValueGenerator == "function") {
718
+ let e = o.newValueGenerator();
719
+ if (typeof e == "object") {
720
+ i.value.push(e);
721
+ return;
722
+ }
723
+ }
716
724
  i.value.push({});
717
- }, Ye = () => {
718
- S.value = !0;
719
725
  }, Ze = () => {
726
+ S.value = !0;
727
+ }, xe = () => {
720
728
  S.value = !1;
721
- }, xe = (e, c) => {
729
+ }, et = (e, c) => {
722
730
  if (n("before-save"), o.saveResource && (S.value = !1, !c.success)) {
723
731
  n("error", c.httpStatus);
724
732
  return;
@@ -730,15 +738,15 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
730
738
  for (; T--; ) e.push(void 0);
731
739
  }
732
740
  return e.splice(k, 0, e.splice(c, 1)[0]), e;
733
- }, et = (e) => {
734
- De(i.value, e, e - 1);
735
741
  }, tt = (e) => {
736
- De(i.value, e, e + 1);
742
+ De(i.value, e, e - 1);
737
743
  }, lt = (e) => {
744
+ De(i.value, e, e + 1);
745
+ }, we = (e) => {
738
746
  i.value.splice(e, 1);
739
747
  }, ot = () => {
740
748
  let e = document.getElementById("lkt-table-body-" + oe);
741
- Me.value = new ct(e, {
749
+ $e.value = new ct(e, {
742
750
  direction: "vertical",
743
751
  handle: ".handle",
744
752
  animation: 150,
@@ -747,35 +755,35 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
747
755
  i.value.splice(k, 1, D[T]), i.value.splice(T, 1, D[k]);
748
756
  },
749
757
  onMove: function(c, k) {
750
- return Xe(c);
758
+ return Ye(c);
751
759
  }
752
760
  });
753
- }, we = (e, c, k = !1) => {
761
+ }, Te = (e, c, k = !1) => {
754
762
  let T = [oe, "row", c];
755
- return k && T.push("hidden"), Fe.value.forEach((D) => {
763
+ return k && T.push("hidden"), Ue.value.forEach((D) => {
756
764
  let O = String(e[D.key]).toLowerCase();
757
765
  O.length > 50 && (O = O.substring(0, 50)), O = rt(O, " ", "-"), T.push(O);
758
766
  }), T.join("-");
759
- }, Te = f(() => typeof o.createEnabledValidator == "function" ? o.createEnabledValidator({ items: i.value }) : !0);
760
- return st(() => {
767
+ }, Be = f(() => typeof o.createEnabledValidator == "function" ? o.createEnabledValidator({ items: i.value }) : !0);
768
+ return ut(() => {
761
769
  Ce(), ke(Vt(o.columns, v.value)), Q.value.store({ items: i.value }).turnStoredIntoOriginal(), o.sortable && de(() => {
762
770
  ot();
763
771
  });
764
772
  }), U(() => o.columns, (e) => d.value = e), U(() => o.modelValue, (e) => i.value = e), U(i, (e) => {
765
773
  Ce(), Q.value.increment({ items: e }), n("update:modelValue", e);
766
774
  }, { deep: !0 }), t({
767
- getItemByEvent: Qe,
768
- doRefresh: Oe
775
+ getItemByEvent: Xe,
776
+ doRefresh: Fe
769
777
  }), (e, c) => {
770
778
  const k = $("lkt-button"), T = $("lkt-field-switch"), D = $("lkt-loader"), O = $("lkt-paginator");
771
- return s(), m("section", {
779
+ return u(), m("section", {
772
780
  class: "lkt-table-page",
773
781
  id: "lkt-table-page-" + I(oe)
774
782
  }, [
775
- ie.value || I(u).title ? (s(), m("header", Wt, [
776
- ie.value ? (s(), b(Z(We.value), { key: 0 }, {
777
- default: F(() => [
778
- e.titleIcon ? (s(), m("i", {
783
+ ie.value || I(s).title ? (u(), m("header", Wt, [
784
+ ie.value ? (u(), b(Z(je.value), { key: 0 }, {
785
+ default: N(() => [
786
+ e.titleIcon ? (u(), m("i", {
779
787
  key: 0,
780
788
  class: te(e.titleIcon)
781
789
  }, null, 2)) : y("", !0),
@@ -783,45 +791,45 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
783
791
  ]),
784
792
  _: 1
785
793
  })) : y("", !0),
786
- I(u).title ? N(e.$slots, "title", { key: 1 }) : y("", !0)
794
+ I(s).title ? F(e.$slots, "title", { key: 1 }) : y("", !0)
787
795
  ])) : y("", !0),
788
- (s(), b(Z(je.value), {
796
+ (u(), b(Z(Je.value), {
789
797
  class: te(["lkt-table-page-content-wrapper", e.wrapContentClass])
790
798
  }, {
791
- default: F(() => [
799
+ default: N(() => [
792
800
  x(E("div", jt, [
793
801
  x(X(k, {
794
802
  ref: "saveButton",
795
803
  palette: "success",
796
- disabled: !Ke.value,
804
+ disabled: !_e.value,
797
805
  "confirm-modal": e.saveConfirm,
798
806
  "confirm-data": e.confirmData,
799
807
  resource: e.saveResource,
800
- "resource-data": Pe.value,
801
- onLoading: Ye,
802
- onLoaded: Ze,
803
- onClick: xe
808
+ "resource-data": We.value,
809
+ onLoading: Ze,
810
+ onLoaded: xe,
811
+ onClick: et
804
812
  }, {
805
- default: F(() => [
806
- I(u)["button-save"] ? N(e.$slots, "button-save", {
813
+ default: N(() => [
814
+ I(s)["button-save"] ? F(e.$slots, "button-save", {
807
815
  key: 0,
808
816
  items: i.value,
809
817
  editMode: e.editMode,
810
818
  canUpdate: !e.saveDisabled
811
- }) : (s(), m("span", Jt, j(Je.value), 1))
819
+ }) : (u(), m("span", Jt, j(Ge.value), 1))
812
820
  ]),
813
821
  _: 3
814
822
  }, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"]), [
815
823
  [ee, he.value]
816
824
  ]),
817
- e.canCreate && ne.value && M.value ? (s(), b(Ie, {
825
+ e.canCreate && ne.value && M.value ? (u(), b(Le, {
818
826
  key: 0,
819
- disabled: !Te.value,
827
+ disabled: !Be.value,
820
828
  text: e.createText,
821
829
  icon: e.createIcon,
822
830
  onClick: Ve
823
831
  }, null, 8, ["disabled", "text", "icon"])) : y("", !0),
824
- E("div", zt, [
832
+ E("div", Gt, [
825
833
  x(X(T, {
826
834
  modelValue: M.value,
827
835
  "onUpdate:modelValue": c[0] || (c[0] = (w) => M.value = w),
@@ -831,45 +839,46 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
831
839
  ])
832
840
  ])
833
841
  ], 512), [
834
- [ee, He.value]
842
+ [ee, Ke.value]
835
843
  ]),
836
- I(u).buttons ? (s(), m("div", qt, [
837
- N(e.$slots, "buttons")
844
+ I(s).buttons ? (u(), m("div", zt, [
845
+ F(e.$slots, "buttons")
838
846
  ])) : y("", !0),
839
- V.value && I(u).filters ? (s(), m("div", Gt, [
840
- N(e.$slots, "filters", {
847
+ V.value && I(s).filters ? (u(), m("div", qt, [
848
+ F(e.$slots, "filters", {
841
849
  items: i.value,
842
850
  isLoading: S.value
843
851
  })
844
852
  ])) : y("", !0),
845
- S.value ? (s(), b(D, { key: 2 })) : y("", !0),
853
+ S.value ? (u(), b(D, { key: 2 })) : y("", !0),
846
854
  x(E("div", {
847
855
  class: "lkt-table",
848
856
  "data-sortable": e.sortable
849
857
  }, [
850
- e.itemMode ? (s(), m("div", {
858
+ e.itemMode ? (u(), m("div", {
851
859
  key: 1,
852
860
  class: te(["lkt-table-items-container", e.itemsContainerClass])
853
861
  }, [
854
- (s(!0), m(A, null, P(i.value, (w, B) => (s(), m("div", ll, [
855
- N(e.$slots, "item", {
862
+ (u(!0), m(A, null, P(i.value, (w, B) => (u(), m("div", ll, [
863
+ F(e.$slots, "item", {
856
864
  item: w,
857
865
  index: B,
858
866
  canCreate: ne.value,
859
867
  canRead: qe.value,
860
- canUpdate: Ge.value,
868
+ canUpdate: Qe.value,
861
869
  canDrop: re.value,
862
- isLoading: S.value
870
+ isLoading: S.value,
871
+ doDrop: () => we(B)
863
872
  })
864
873
  ]))), 256))
865
- ], 2)) : (s(), m("table", Xt, [
874
+ ], 2)) : (u(), m("table", Xt, [
866
875
  E("thead", null, [
867
876
  E("tr", null, [
868
- e.sortable && M.value ? (s(), m("th", Yt)) : y("", !0),
869
- e.addNavigation && M.value ? (s(), m("th", Zt)) : y("", !0),
870
- pe.value ? (s(), m("th", xt)) : y("", !0),
871
- (s(!0), m(A, null, P(ae.value, (w) => (s(), m(A, null, [
872
- se.value.indexOf(w.key) === -1 ? (s(), b(_t, {
877
+ e.sortable && M.value ? (u(), m("th", Yt)) : y("", !0),
878
+ e.addNavigation && M.value ? (u(), m("th", Zt)) : y("", !0),
879
+ pe.value ? (u(), m("th", xt)) : y("", !0),
880
+ (u(!0), m(A, null, P(ae.value, (w) => (u(), m(A, null, [
881
+ ue.value.indexOf(w.key) === -1 ? (u(), b(_t, {
873
882
  key: 0,
874
883
  column: w,
875
884
  "sort-by": v.value,
@@ -879,26 +888,26 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
879
888
  onClick: (B) => ke(w)
880
889
  }, null, 8, ["column", "sort-by", "sort-direction", "amount-of-columns", "items", "onClick"])) : y("", !0)
881
890
  ], 64))), 256)),
882
- e.canDrop && re.value && M.value ? (s(), m("th", el)) : y("", !0)
891
+ e.canDrop && re.value && M.value ? (u(), m("th", el)) : y("", !0)
883
892
  ])
884
893
  ]),
885
894
  E("tbody", {
886
895
  ref: (w) => J.value = w,
887
896
  id: "lkt-table-body-" + I(oe)
888
897
  }, [
889
- (s(!0), m(A, null, P(i.value, (w, B) => (s(), b(At, {
898
+ (u(!0), m(A, null, P(i.value, (w, B) => (u(), b(At, {
890
899
  modelValue: i.value[B],
891
900
  "onUpdate:modelValue": (_) => i.value[B] = _,
892
- key: we(w, B),
901
+ key: Te(w, B),
893
902
  i: B,
894
903
  "display-hidden-columns-indicator": pe.value,
895
904
  "is-draggable": Se(w),
896
905
  sortable: e.sortable,
897
906
  "visible-columns": ae.value,
898
- "empty-columns": se.value,
907
+ "empty-columns": ue.value,
899
908
  "add-navigation": e.addNavigation,
900
909
  "hidden-is-visible": ye(B),
901
- "latest-row": B + 1 === _e.value,
910
+ "latest-row": B + 1 === Pe.value,
902
911
  "can-drop": e.canDrop && re.value && M.value,
903
912
  "drop-confirm": e.dropConfirm,
904
913
  "drop-resource": e.dropResource,
@@ -907,43 +916,43 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
907
916
  "edit-mode-enabled": M.value,
908
917
  onClick: be,
909
918
  onShow: ge,
910
- onItemUp: et,
911
- onItemDown: tt,
912
- onItemDrop: lt
913
- }, Be({ _: 2 }, [
919
+ onItemUp: tt,
920
+ onItemDown: lt,
921
+ onItemDrop: we
922
+ }, Ee({ _: 2 }, [
914
923
  P(ve.value, (_) => ({
915
924
  name: _,
916
- fn: F((z) => [
917
- N(e.$slots, _, {
918
- item: z.item,
919
- value: z.value,
920
- column: z.column
925
+ fn: N((G) => [
926
+ F(e.$slots, _, {
927
+ item: G.item,
928
+ value: G.value,
929
+ column: G.column
921
930
  })
922
931
  ])
923
932
  }))
924
933
  ]), 1032, ["modelValue", "onUpdate:modelValue", "i", "display-hidden-columns-indicator", "is-draggable", "sortable", "visible-columns", "empty-columns", "add-navigation", "hidden-is-visible", "latest-row", "can-drop", "drop-confirm", "drop-resource", "drop-text", "drop-icon", "edit-mode-enabled"]))), 128)),
925
- ue.value.length > 0 ? (s(!0), m(A, { key: 0 }, P(i.value, (w, B) => (s(), b(Ht, {
934
+ se.value.length > 0 ? (u(!0), m(A, { key: 0 }, P(i.value, (w, B) => (u(), b(Ht, {
926
935
  modelValue: i.value[B],
927
936
  "onUpdate:modelValue": (_) => i.value[B] = _,
928
- key: we(w, B, !0),
937
+ key: Te(w, B, !0),
929
938
  i: B,
930
- "hidden-columns": ue.value,
939
+ "hidden-columns": se.value,
931
940
  "hidden-columns-col-span": Ne.value,
932
941
  "is-draggable": Se(w),
933
942
  sortable: e.sortable,
934
943
  "visible-columns": ae.value,
935
- "empty-columns": se.value,
944
+ "empty-columns": ue.value,
936
945
  "hidden-is-visible": ye(B),
937
946
  onClick: be,
938
947
  onShow: ge
939
- }, Be({ _: 2 }, [
948
+ }, Ee({ _: 2 }, [
940
949
  P(ve.value, (_) => ({
941
950
  name: _,
942
- fn: F((z) => [
943
- N(e.$slots, _, {
944
- item: z.item,
945
- value: z.value,
946
- column: z.column
951
+ fn: N((G) => [
952
+ F(e.$slots, _, {
953
+ item: G.item,
954
+ value: G.value,
955
+ column: G.column
947
956
  })
948
957
  ])
949
958
  }))
@@ -953,14 +962,14 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
953
962
  ], 8, Qt), [
954
963
  [ee, !S.value && i.value.length > 0]
955
964
  ]),
956
- e.$slots["no-items"] ? (s(), m("div", ol, [
957
- N(e.$slots, "no-items")
965
+ e.$slots["no-items"] ? (u(), m("div", ol, [
966
+ F(e.$slots, "no-items")
958
967
  ])) : y("", !0),
959
- !S.value && i.value.length === 0 ? (s(), m("div", al, j(e.noResultsText), 1)) : y("", !0),
960
- e.canCreate && ne.value && M.value ? (s(), m("div", nl, [
961
- e.canCreate && ne.value && M.value ? (s(), b(Ie, {
968
+ !S.value && i.value.length === 0 ? (u(), m("div", al, j(e.noResultsText), 1)) : y("", !0),
969
+ e.canCreate && ne.value && M.value ? (u(), m("div", nl, [
970
+ e.canCreate && ne.value && M.value ? (u(), b(Le, {
962
971
  key: 0,
963
- disabled: !Te.value,
972
+ disabled: !Be.value,
964
973
  text: e.createText,
965
974
  icon: e.createIcon,
966
975
  onClick: Ve
@@ -973,9 +982,9 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
973
982
  "onUpdate:modelValue": c[1] || (c[1] = (w) => L.value = w),
974
983
  resource: e.resource,
975
984
  filters: e.filters,
976
- onResults: $e,
977
- onLoading: Re,
978
- onPerms: Ae
985
+ onResults: Ae,
986
+ onLoading: Oe,
987
+ onPerms: Re
979
988
  }, null, 8, ["modelValue", "resource", "filters"])
980
989
  ]),
981
990
  _: 3
@@ -985,7 +994,7 @@ const Sl = (l, t, r = !0) => H(new K(l, t).setIsSortable(r)), Vl = (l, t, r, n =
985
994
  }
986
995
  }), $l = {
987
996
  install: (l) => {
988
- l.component("lkt-loader") === void 0 && l.use(mt), l.component("lkt-button") === void 0 && l.use(ft), l.component("lkt-paginator") === void 0 && l.use(pt), l.component("lkt-field-text") === void 0 && l.use(vt), l.component("lkt-field-textarea") === void 0 && l.use(ht), l.component("lkt-field-select") === void 0 && l.use(yt), l.component("lkt-field-switch") === void 0 && l.use(kt), l.component("lkt-field-file") === void 0 && l.use(bt), l.component("lkt-table") === void 0 && l.component("lkt-table", sl);
997
+ l.component("lkt-loader") === void 0 && l.use(mt), l.component("lkt-button") === void 0 && l.use(ft), l.component("lkt-paginator") === void 0 && l.use(pt), l.component("lkt-field-text") === void 0 && l.use(vt), l.component("lkt-field-textarea") === void 0 && l.use(ht), l.component("lkt-field-select") === void 0 && l.use(yt), l.component("lkt-field-switch") === void 0 && l.use(kt), l.component("lkt-field-file") === void 0 && l.use(bt), l.component("lkt-table") === void 0 && l.component("lkt-table", ul);
989
998
  }
990
999
  }, Al = (l) => (R.navButtonSlot = l, !0), Rl = (l) => (R.dropButtonSlot = l, !0), Ol = (l) => (R.createButtonSlot = l, !0);
991
1000
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-table",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -64,6 +64,7 @@ const props = withDefaults(defineProps<{
64
64
  addNavigation?: boolean
65
65
  itemMode?: boolean
66
66
  createEnabledValidator?: Function
67
+ newValueGenerator?: Function
67
68
  }>(), {
68
69
  modelValue: () => [],
69
70
  columns: () => [],
@@ -109,6 +110,7 @@ const props = withDefaults(defineProps<{
109
110
  addNavigation: false,
110
111
  itemMode: false,
111
112
  createEnabledValidator: undefined,
113
+ newValueGenerator: undefined,
112
114
  });
113
115
 
114
116
  const hiddenColumnsStack: LktObject = {};
@@ -325,6 +327,14 @@ const getItemByEvent = (e: any) => {
325
327
  return true;
326
328
  },
327
329
  onClickAddItem = () => {
330
+ if (typeof props.newValueGenerator === 'function') {
331
+ let newValue = props.newValueGenerator();
332
+
333
+ if (typeof newValue === 'object') {
334
+ Items.value.push(newValue);
335
+ return;
336
+ }
337
+ }
328
338
  Items.value.push({});
329
339
  },
330
340
  onButtonLoading = () => {
@@ -603,6 +613,7 @@ defineExpose({
603
613
  v-bind:can-update="hasUpdatePerm"
604
614
  v-bind:can-drop="hasDropPerm"
605
615
  v-bind:is-loading="loading"
616
+ v-bind:do-drop="() => onItemDrop(i)"
606
617
  />
607
618
  </div>
608
619
  </div>