lkt-item-crud 1.1.25 → 1.1.26

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