lkt-item-crud 1.1.25 → 1.1.27

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare function Oe(l?: boolean): void;
2
- declare namespace Te {
3
- function install(l: any, f?: {}): void;
1
+ declare function Je(l?: boolean): void;
2
+ declare namespace Ke {
3
+ function install(l: any, h?: {}): void;
4
4
  }
5
- export { Oe as debugLktItemCrud, Te as default };
5
+ export { Je as debugLktItemCrud, Ke as default };
package/dist/build.js CHANGED
@@ -1,41 +1,51 @@
1
- import { defineComponent as ce, useSlots as ve, ref as i, computed as s, watch as m, nextTick as fe, resolveComponent as V, openBlock as h, createElementBlock as N, createElementVNode as x, toDisplayString as pe, renderSlot as L, createCommentVNode as y, withDirectives as O, createBlock as T, unref as _, withCtx as Y, vShow as $, createVNode as Z } from "vue";
2
- import { httpCall as me } from "lkt-http-client";
1
+ import { defineComponent as ve, useSlots as ce, ref as s, computed as n, watch as b, nextTick as fe, resolveComponent as L, openBlock as v, createElementBlock as M, unref as C, renderSlot as U, createCommentVNode as p, toDisplayString as pe, withDirectives as O, createElementVNode as me, createBlock as T, withCtx as Y, vShow as $, createVNode as Z } from "vue";
2
+ import { httpCall as he } from "lkt-http-client";
3
3
  import { DataState as ee } from "lkt-data-state";
4
- import { execModal as he, refreshModal as be, closeModal as ke, openModal as Ce, reOpenModal as De } from "lkt-modal";
4
+ import { execModal as ke, refreshModal as be, closeModal as Ce, openModal as De, reOpenModal as Se } from "lkt-modal";
5
+ import { __ as ye } from "lkt-i18n";
5
6
  const q = class q {
6
7
  };
7
8
  q.debugEnabled = !1;
8
9
  let F = q;
9
10
  const u = (...l) => {
10
11
  F.debugEnabled && console.info("[LktItemCrud] ", ...l);
11
- }, Oe = (l = !0) => {
12
+ }, Je = (l = !0) => {
12
13
  F.debugEnabled = l;
13
14
  }, j = (l) => {
14
15
  u("runModalCallback -> init", l);
15
- let f = l.modalKey ? l.modalKey : "_", g = l.args ? l.args : {};
16
+ let h = l.modalKey ? l.modalKey : "_", _ = l.args ? l.args : {};
16
17
  switch (l.action) {
17
18
  case "reOpen":
18
- return De(l.modalName, f, g);
19
+ return Se(l.modalName, h, _);
19
20
  case "open":
20
- return Ce(l.modalName, f, g);
21
+ return De(l.modalName, h, _);
21
22
  case "close":
22
- return ke(l.modalName, f);
23
+ return Ce(l.modalName, h);
23
24
  case "refresh":
24
- return be(l.modalName, f, g);
25
+ return be(l.modalName, h, _);
25
26
  case "exec":
26
27
  let e = l.method;
27
- return e ? he(l.modalName, f, e, g) : void 0;
28
+ return e ? ke(l.modalName, h, e, _) : void 0;
28
29
  }
29
- }, Se = { class: "lkt-item-crud" }, ye = {
30
+ }, ge = { class: "lkt-item-crud" }, Me = {
30
31
  key: 0,
31
32
  class: "lkt-item-crud_header"
32
- }, ge = { class: "lkt-item-crud_header-title" }, Me = { class: "lkt-item-crud_header-slot" }, Be = { class: "lkt-item-crud-buttons" }, _e = {
33
+ }, _e = {
34
+ key: 0,
35
+ class: "lkt-item-crud_header-slot"
36
+ }, Be = {
33
37
  key: 1,
34
- class: "lkt-item-crud_content"
38
+ class: "lkt-item-crud_header-title"
35
39
  }, we = {
40
+ key: 2,
41
+ class: "lkt-item-crud_header-slot"
42
+ }, Ie = { class: "lkt-item-crud-buttons" }, Ee = {
43
+ key: 1,
44
+ class: "lkt-item-crud_content"
45
+ }, Ue = {
36
46
  key: 0,
37
47
  class: "lkt-grid-1"
38
- }, Ie = /* @__PURE__ */ ce({
48
+ }, Re = /* @__PURE__ */ ve({
39
49
  __name: "LktItemCrud",
40
50
  props: {
41
51
  modelValue: { default: () => ({}) },
@@ -79,192 +89,198 @@ const u = (...l) => {
79
89
  editing: { type: Boolean, default: !1 }
80
90
  },
81
91
  emits: ["update:modelValue", "update:isCreate", "update:editing", "read", "create", "update", "drop", "before-save", "perms", "error", "modified-data"],
82
- setup(l, { expose: f, emit: g }) {
83
- const e = l, b = ve(), n = g;
92
+ setup(l, { expose: h, emit: _ }) {
93
+ const e = l, m = ce(), i = _;
84
94
  let ae = [];
85
- const d = i(!0), r = i(e.modelValue), w = i(ae), c = i(e.editing), p = i(!1), k = i(!1), v = i(200), E = i(null), U = i(null), M = i(new ee(r.value, e.dataStateConfig)), J = i(new ee(e.readData)), o = i(e.isCreate), K = i(!1), te = s(() => o.value ? e.createConfirm : e.updateConfirm), le = s(() => o.value ? e.createConfirmData : e.updateConfirmData), H = s(() => o.value ? e.createResource : e.updateResource), oe = s(() => o.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), ue = s(() => o.value ? e.createDisabled : e.updateDisabled), C = s(() => !o.value && w.value.includes("update")), D = s(() => !o.value && w.value.includes("drop")), R = async () => {
86
- u("fetchItem"), d.value = !0, v.value = -1, k.value = !1;
95
+ const d = s(!0), r = s(e.modelValue), I = s(ae), c = s(e.editing), k = s(!1), D = s(!1), f = s(200), R = s(null), V = s(null), B = s(new ee(r.value, e.dataStateConfig)), J = s(new ee(e.readData)), o = s(e.isCreate), K = s(!1), te = n(() => o.value ? e.createConfirm : e.updateConfirm), le = n(() => o.value ? e.createConfirmData : e.updateConfirmData), H = n(() => o.value ? e.createResource : e.updateResource), oe = n(() => o.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), ue = n(() => o.value ? e.createDisabled : e.updateDisabled), S = n(() => !o.value && I.value.includes("update")), y = n(() => !o.value && I.value.includes("drop")), N = async () => {
96
+ u("fetchItem"), d.value = !0, f.value = -1, D.value = !1;
87
97
  try {
88
- const a = await me(e.readResource, e.readData);
89
- if (u("fetchItem -> response", a), d.value = !1, v.value = a.httpStatus, !a.success) {
90
- p.value = !1, v.value = a.httpStatus, n("error", a.httpStatus);
98
+ const a = await he(e.readResource, e.readData);
99
+ if (u("fetchItem -> response", a), d.value = !1, f.value = a.httpStatus, !a.success) {
100
+ k.value = !1, f.value = a.httpStatus, i("error", a.httpStatus);
91
101
  return;
92
102
  }
93
- p.value = !0, r.value = a.data, w.value = a.perms, M.value.increment(r.value).turnStoredIntoOriginal(), J.value.turnStoredIntoOriginal(), n("read", a);
103
+ k.value = !0, r.value = a.data, I.value = a.perms, B.value.increment(r.value).turnStoredIntoOriginal(), J.value.turnStoredIntoOriginal(), i("read", a);
94
104
  } catch {
95
- d.value = !1, p.value = !1, v.value = 404, n("error", 404);
105
+ d.value = !1, k.value = !1, f.value = 404, i("error", 404);
96
106
  return;
97
107
  }
98
- }, de = s(() => d.value ? !1 : e.title || !!b["post-title"]);
99
- m(() => e.modelValue, (a) => {
100
- r.value = a, M.value.increment(a);
101
- }, { deep: !0 }), m(r, (a) => {
108
+ };
109
+ b(() => e.modelValue, (a) => {
110
+ r.value = a, B.value.increment(a);
111
+ }, { deep: !0 }), b(r, (a) => {
102
112
  if (K.value = !0, u("item updated ->", r.value), typeof e.beforeEmitUpdate == "function") {
103
113
  u("item updated -> has beforeEmitUpdate");
104
114
  let t = e.beforeEmitUpdate(r.value);
105
115
  u("item updated -> override with: ", t), typeof t == "object" && (r.value = t);
106
116
  }
107
- n("update:modelValue", r.value), u("item updated -> update dataState"), M.value.increment(a), fe(() => K.value = !1);
108
- }, { deep: !0 }), m(w, () => n("perms", w.value));
109
- const P = s(() => ue.value || !o.value && !C.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : M.value.changed());
110
- m(P, (a) => n("modified-data", a)), m(o, (a) => n("update:isCreate", a)), m(() => e.readData, (a) => {
111
- J.value.increment(a), J.value.changed() && R();
112
- }), m(() => e.editing, (a) => {
117
+ i("update:modelValue", r.value), u("item updated -> update dataState"), B.value.increment(a), fe(() => K.value = !1);
118
+ }, { deep: !0 }), b(I, () => i("perms", I.value));
119
+ const P = n(() => ue.value || !o.value && !S.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : B.value.changed());
120
+ b(P, (a) => i("modified-data", a)), b(o, (a) => i("update:isCreate", a)), b(() => e.readData, (a) => {
121
+ J.value.increment(a), J.value.changed() && N();
122
+ }), b(() => e.editing, (a) => {
113
123
  u("editing updated -> updating editMode", a), c.value = a;
114
- }), m(c, (a) => {
115
- u("editMode updated -> emit update", a), n("update:editing", a);
116
- }), e.readResource && !o.value ? R() : o.value && (p.value = !0, c.value = !0, d.value = !1);
117
- const re = (a, t) => {
118
- if (d.value = !1, v.value = t.httpStatus, !t.success) {
119
- k.value = !0, n("error", t.httpStatus);
124
+ }), b(c, (a) => {
125
+ u("editMode updated -> emit update", a), i("update:editing", a);
126
+ }), e.readResource && !o.value ? N() : o.value && (k.value = !0, c.value = !0, d.value = !1);
127
+ const de = (a, t) => {
128
+ if (d.value = !1, f.value = t.httpStatus, !t.success) {
129
+ D.value = !0, i("error", t.httpStatus);
120
130
  return;
121
131
  }
122
- k.value = !0, e.onDropModalCallbacks.length > 0 && (u("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach((S) => {
123
- j(S);
124
- })), n("drop", t);
125
- }, ne = (a, t) => {
126
- if (u("onSave -> received response:", t), n("before-save"), H.value) {
127
- if (d.value = !1, v.value = t.httpStatus, !t.success) {
128
- k.value = !0, n("error", t.httpStatus);
132
+ D.value = !0, e.onDropModalCallbacks.length > 0 && (u("onDrop -> has onDropModalCallbacks"), e.onDropModalCallbacks.forEach((g) => {
133
+ j(g);
134
+ })), i("drop", t);
135
+ }, re = (a, t) => {
136
+ if (u("onSave -> received response:", t), i("before-save"), H.value) {
137
+ if (d.value = !1, f.value = t.httpStatus, !t.success) {
138
+ D.value = !0, i("error", t.httpStatus);
129
139
  return;
130
140
  }
131
- k.value = !0;
141
+ D.value = !0;
132
142
  }
133
- let S = o.value ? "create" : "update";
134
- o.value || (u("onSave -> turn stored data into original"), M.value.turnStoredIntoOriginal()), S === "create" ? typeof e.onCreate == "function" && (u("onSave -> trigger onCreate callback"), e.onCreate(t), e.onCreateModalCallbacks.length > 0 && (u("onSave -> has onCreateModalCallbacks"), e.onCreateModalCallbacks.forEach((I) => {
135
- j(I);
136
- }))) : typeof e.onUpdate == "function" && (u("onSave -> trigger onUpdate callback"), e.onUpdate(t), e.onUpdateModalCallbacks.length > 0 && (u("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((I) => {
137
- j(I);
138
- }))), !e.insideModal && t.autoReloadId && (u("onSave -> autoReloadId detected: ", t.autoReloadId), e.readData.id = t.autoReloadId, u("onSave -> turning off create mode"), o.value = !1, R()), n(S, t);
143
+ let g = o.value ? "create" : "update";
144
+ o.value || (u("onSave -> turn stored data into original"), B.value.turnStoredIntoOriginal()), g === "create" ? typeof e.onCreate == "function" && (u("onSave -> trigger onCreate callback"), e.onCreate(t), e.onCreateModalCallbacks.length > 0 && (u("onSave -> has onCreateModalCallbacks"), e.onCreateModalCallbacks.forEach((E) => {
145
+ j(E);
146
+ }))) : typeof e.onUpdate == "function" && (u("onSave -> trigger onUpdate callback"), e.onUpdate(t), e.onUpdateModalCallbacks.length > 0 && (u("onSave -> has onUpdateModalCallbacks"), e.onUpdateModalCallbacks.forEach((E) => {
147
+ j(E);
148
+ }))), !e.insideModal && t.autoReloadId && (u("onSave -> autoReloadId detected: ", t.autoReloadId), e.readData.id = t.autoReloadId, u("onSave -> turning off create mode"), o.value = !1, N()), i(g, t);
149
+ }, W = () => {
150
+ d.value = !0, f.value = -1;
139
151
  }, z = () => {
140
- d.value = !0, v.value = -1;
141
- }, A = () => {
142
152
  d.value = !1;
143
153
  };
144
- f({
154
+ h({
145
155
  doDrop: () => {
146
- U.value && typeof U.value.click == "function" && U.value.click();
156
+ V.value && typeof V.value.click == "function" && V.value.click();
147
157
  },
148
- doRefresh: R,
158
+ doRefresh: N,
149
159
  doSave: () => {
150
- E.value && typeof E.value.click == "function" && E.value.click();
160
+ R.value && typeof R.value.click == "function" && R.value.click();
151
161
  }
152
162
  });
153
- const G = s(() => !C.value && D.value ? !0 : !e.hiddenDrop && !d.value && c.value && p.value), Q = s(() => M.value.changed() ? !0 : d.value ? !1 : o.value ? !0 : !e.hiddenSave && c.value && p.value), W = s(() => e.hideSwitchEdition || !C.value && !D.value || !C.value && D.value ? !1 : !d.value && !o.value && p.value && !(e.dropDisabled && e.updateDisabled)), ie = s(() => !e.hiddenButtons && (Q.value || G.value || W.value));
163
+ const A = n(() => !S.value && y.value ? !0 : !e.hiddenDrop && !d.value && c.value && k.value), G = n(() => B.value.changed() ? !0 : d.value ? !1 : o.value ? !0 : !e.hiddenSave && c.value && k.value), Q = n(() => e.hideSwitchEdition || !S.value && !y.value || !S.value && y.value ? !1 : !d.value && !o.value && k.value && !(e.dropDisabled && e.updateDisabled)), ne = n(() => !e.hiddenButtons && (G.value || A.value || Q.value)), x = n(() => e.title.startsWith("__:") ? String(ye(e.title.substring(3))) : e.title), ie = n(() => d.value ? !1 : x.value.length > 0 || !!m["post-title"]);
154
164
  return (a, t) => {
155
- const S = V("lkt-button"), I = V("lkt-field-switch"), X = V("lkt-http-info"), se = V("lkt-loader");
156
- return h(), N("article", Se, [
157
- de.value ? (h(), N("header", ye, [
158
- x("h1", ge, pe(a.title), 1),
159
- x("div", Me, [
160
- L(a.$slots, "post-title", {
165
+ const g = L("lkt-button"), E = L("lkt-field-switch"), X = L("lkt-http-info"), se = L("lkt-loader");
166
+ return v(), M("article", ge, [
167
+ ie.value ? (v(), M("header", Me, [
168
+ C(m)["pre-title"] ? (v(), M("div", _e, [
169
+ U(a.$slots, "pre-title", {
161
170
  item: r.value,
162
171
  loading: d.value
163
172
  })
164
- ])
165
- ])) : y("", !0),
166
- O(x("div", Be, [
167
- o.value ? y("", !0) : O((h(), T(S, {
173
+ ])) : p("", !0),
174
+ x.value.length > 0 ? (v(), M("h1", Be, pe(x.value), 1)) : p("", !0),
175
+ C(m)["post-title"] ? (v(), M("div", we, [
176
+ U(a.$slots, "post-title", {
177
+ item: r.value,
178
+ loading: d.value
179
+ })
180
+ ])) : p("", !0)
181
+ ])) : p("", !0),
182
+ O(me("div", Ie, [
183
+ o.value ? p("", !0) : O((v(), T(g, {
168
184
  key: 0,
169
- ref: (B) => U.value = B,
185
+ ref: (w) => V.value = w,
170
186
  palette: "danger",
171
- disabled: a.dropDisabled || !D.value,
187
+ disabled: a.dropDisabled || !y.value,
172
188
  "confirm-modal": a.dropConfirm,
173
189
  "confirm-data": a.dropConfirmData,
174
190
  resource: a.dropResource,
175
191
  "resource-data": a.dropData,
176
- text: _(b)["button-drop"] ? "" : a.dropText,
177
- icon: _(b)["button-drop"] ? "" : a.dropIcon,
178
- onLoading: z,
179
- onLoaded: A,
180
- onClick: re
192
+ text: C(m)["button-drop"] ? "" : a.dropText,
193
+ icon: C(m)["button-drop"] ? "" : a.dropIcon,
194
+ onLoading: W,
195
+ onLoaded: z,
196
+ onClick: de
181
197
  }, {
182
198
  default: Y(() => [
183
- _(b)["button-drop"] ? L(a.$slots, "button-drop", {
199
+ C(m)["button-drop"] ? U(a.$slots, "button-drop", {
184
200
  key: 0,
185
201
  item: r.value,
186
202
  editMode: c.value,
187
203
  isCreate: o.value,
188
- canUpdate: C.value,
189
- canDrop: D.value
190
- }) : y("", !0)
204
+ canUpdate: S.value,
205
+ canDrop: y.value
206
+ }) : p("", !0)
191
207
  ]),
192
208
  _: 3
193
209
  }, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"])), [
194
- [$, G.value]
210
+ [$, A.value]
195
211
  ]),
196
- O(Z(S, {
197
- ref: (B) => E.value = B,
212
+ O(Z(g, {
213
+ ref: (w) => R.value = w,
198
214
  palette: "success",
199
215
  disabled: !P.value,
200
216
  "confirm-modal": te.value,
201
217
  "confirm-data": le.value,
202
218
  resource: H.value,
203
219
  "resource-data": oe.value,
204
- text: _(b)["button-save"] ? "" : a.saveText,
205
- icon: _(b)["button-save"] ? "" : a.saveIcon,
206
- onLoading: z,
207
- onLoaded: A,
208
- onClick: ne
220
+ text: C(m)["button-save"] ? "" : a.saveText,
221
+ icon: C(m)["button-save"] ? "" : a.saveIcon,
222
+ onLoading: W,
223
+ onLoaded: z,
224
+ onClick: re
209
225
  }, {
210
226
  default: Y(() => [
211
- _(b)["button-save"] ? L(a.$slots, "button-save", {
227
+ C(m)["button-save"] ? U(a.$slots, "button-save", {
212
228
  key: 0,
213
229
  item: r.value,
214
230
  editMode: c.value,
215
231
  isCreate: o.value,
216
- canUpdate: C.value,
217
- canDrop: D.value
218
- }) : y("", !0)
232
+ canUpdate: S.value,
233
+ canDrop: y.value
234
+ }) : p("", !0)
219
235
  ]),
220
236
  _: 3
221
237
  }, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data", "text", "icon"]), [
222
- [$, Q.value]
238
+ [$, G.value]
223
239
  ]),
224
- O(Z(I, {
240
+ O(Z(E, {
225
241
  modelValue: c.value,
226
- "onUpdate:modelValue": t[0] || (t[0] = (B) => c.value = B),
242
+ "onUpdate:modelValue": t[0] || (t[0] = (w) => c.value = w),
227
243
  label: a.editModeText
228
244
  }, null, 8, ["modelValue", "label"]), [
229
- [$, W.value]
245
+ [$, Q.value]
230
246
  ])
231
247
  ], 512), [
232
- [$, ie.value]
248
+ [$, ne.value]
233
249
  ]),
234
- d.value ? y("", !0) : (h(), N("div", _e, [
235
- p.value ? (h(), N("div", we, [
236
- k.value ? (h(), T(X, {
250
+ d.value ? p("", !0) : (v(), M("div", Ee, [
251
+ k.value ? (v(), M("div", Ue, [
252
+ D.value ? (v(), T(X, {
237
253
  key: 0,
238
- code: v.value,
254
+ code: f.value,
239
255
  quick: "",
240
- palette: v.value === 200 ? "success" : "danger",
256
+ palette: f.value === 200 ? "success" : "danger",
241
257
  "can-close": "",
242
- onClose: t[1] || (t[1] = (B) => k.value = !1)
243
- }, null, 8, ["code", "palette"])) : y("", !0),
244
- L(a.$slots, "item", {
258
+ onClose: t[1] || (t[1] = (w) => D.value = !1)
259
+ }, null, 8, ["code", "palette"])) : p("", !0),
260
+ U(a.$slots, "item", {
245
261
  item: r.value,
246
262
  loading: d.value,
247
263
  editMode: c.value,
248
264
  isCreate: o.value,
249
- canUpdate: C.value,
250
- canDrop: D.value,
265
+ canUpdate: S.value,
266
+ canDrop: y.value,
251
267
  itemBeingEdited: K.value
252
268
  })
253
- ])) : (h(), T(X, {
269
+ ])) : (v(), T(X, {
254
270
  key: 1,
255
- code: v.value
271
+ code: f.value
256
272
  }, null, 8, ["code"]))
257
273
  ])),
258
- d.value ? (h(), T(se, { key: 2 })) : y("", !0)
274
+ d.value ? (v(), T(se, { key: 2 })) : p("", !0)
259
275
  ]);
260
276
  };
261
277
  }
262
- }), Te = {
263
- install: (l, f = {}) => {
264
- l.component("lkt-item-crud") === void 0 && l.component("lkt-item-crud", Ie);
278
+ }), Ke = {
279
+ install: (l, h = {}) => {
280
+ l.component("lkt-item-crud") === void 0 && l.component("lkt-item-crud", Re);
265
281
  }
266
282
  };
267
283
  export {
268
- Oe as debugLktItemCrud,
269
- Te as default
284
+ Je as debugLktItemCrud,
285
+ Ke as default
270
286
  };
@@ -223,6 +223,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
223
223
  onDropModalCallbacks: ModalCallbackConfig[];
224
224
  editing: boolean;
225
225
  }, {}>, {
226
+ "pre-title"?(_: {
227
+ item: LktObject;
228
+ loading: boolean;
229
+ }): any;
226
230
  "post-title"?(_: {
227
231
  item: LktObject;
228
232
  loading: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-item-crud",
3
- "version": "1.1.25",
3
+ "version": "1.1.27",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -18,7 +18,8 @@
18
18
  "license": "MIT",
19
19
  "sideEffects": false,
20
20
  "scripts": {
21
- "build": "rm -rf dist/*; vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/"
21
+ "build": "vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/",
22
+ "rebuild": "rm -rf dist/*; vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/"
22
23
  },
23
24
  "author": "Antonio Ibáñez",
24
25
  "devDependencies": {
@@ -42,6 +43,7 @@
42
43
  "lkt-field-switch": "^1.0.0",
43
44
  "lkt-http-client": "^1.0.12",
44
45
  "lkt-http-info": "^1.0.2",
46
+ "lkt-i18n": "^1.0.4",
45
47
  "lkt-loader": "^1.0.2",
46
48
  "lkt-modal": "^1.1.1",
47
49
  "lkt-string-tools": "^1.0.2",
@@ -6,6 +6,7 @@ import {debug} from "../functions/debug";
6
6
  import {LktObject} from "lkt-ts-interfaces";
7
7
  import {ModalCallbackConfig} from "../types/ModalCallbackConfig";
8
8
  import {runModalCallback} from "../functions/modalCallbacks";
9
+ import {__} from "lkt-i18n";
9
10
 
10
11
  const props = withDefaults(defineProps<{
11
12
  modelValue: LktObject
@@ -37,9 +38,9 @@ const props = withDefaults(defineProps<{
37
38
  updateDisabled: boolean
38
39
  dropDisabled: boolean
39
40
  saveValidator: Function
40
- beforeEmitUpdate: Function|undefined
41
- onCreate: Function|undefined
42
- onUpdate: Function|undefined
41
+ beforeEmitUpdate: Function | undefined
42
+ onCreate: Function | undefined
43
+ onUpdate: Function | undefined
43
44
  insideModal: boolean
44
45
  hideSwitchEdition: boolean
45
46
  dataStateConfig: LktObject
@@ -167,11 +168,6 @@ const fetchItem = async () => {
167
168
  }
168
169
  }
169
170
 
170
- const displayHeader = computed(() => {
171
- if (isLoading.value) return false;
172
-
173
- return props.title || !!slots['post-title'];
174
- })
175
171
 
176
172
  watch(() => props.modelValue, v => {
177
173
  item.value = v;
@@ -350,14 +346,28 @@ const showDropButton = computed(() => {
350
346
  }),
351
347
  showButtons = computed(() => {
352
348
  return !props.hiddenButtons && (showSaveButton.value || showDropButton.value || showSwitchButton.value);
349
+ }),
350
+ computedTitle = computed(() => {
351
+ if (props.title.startsWith('__:')) {
352
+ return String(__(props.title.substring(3)));
353
+ }
354
+ return props.title;
355
+ }),
356
+ displayHeader = computed(() => {
357
+ if (isLoading.value) return false;
358
+
359
+ return computedTitle.value.length > 0 || !!slots['post-title'];
353
360
  });
354
361
  </script>
355
362
 
356
363
  <template>
357
364
  <article class="lkt-item-crud">
358
365
  <header class="lkt-item-crud_header" v-if="displayHeader">
359
- <h1 class="lkt-item-crud_header-title">{{ title }}</h1>
360
- <div class="lkt-item-crud_header-slot">
366
+ <div class="lkt-item-crud_header-slot" v-if="slots['pre-title']">
367
+ <slot name="pre-title" v-bind:item="item" v-bind:loading="isLoading"></slot>
368
+ </div>
369
+ <h1 class="lkt-item-crud_header-title" v-if="computedTitle.length > 0">{{ computedTitle }}</h1>
370
+ <div class="lkt-item-crud_header-slot" v-if="slots['post-title']">
361
371
  <slot name="post-title" v-bind:item="item" v-bind:loading="isLoading"></slot>
362
372
  </div>
363
373
  </header>