lkt-item-crud 2.0.5 → 2.0.7

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,31 +1,31 @@
1
- import { defineComponent as me, ref as i, watch as k, useSlots as be, computed as y, resolveComponent as de, createElementBlock as U, createCommentVNode as v, openBlock as s, withDirectives as Y, createBlock as w, unref as p, renderSlot as D, vShow as Z, mergeProps as x, withCtx as V, mergeDefaults as Be, nextTick as De, onMounted as Se, resolveDynamicComponent as Ie, normalizeProps as Ue, guardReactiveProps as we, createElementVNode as Te, toDisplayString as Me, createSlots as se } from "vue";
2
- import { httpCall as Re } from "lkt-http-client";
3
- import { DataState as ve } from "lkt-data-state";
4
- import { ensureButtonConfig as E, LktSettings as n, ItemCrudMode as $, ItemCrudButtonNavVisibility as ue, TablePermission as ne, ItemCrudView as pe, ItemCrudButtonNavPosition as ce, NotificationType as N, getDefaultValues as Ee, ItemCrud as Ne, ToastPositionX as O } from "lkt-vue-kernel";
5
- import { closeModal as $e } from "lkt-modal";
6
- import { __ as Ve } from "lkt-i18n";
7
- import { openToast as j } from "lkt-toast";
1
+ import { defineComponent as ge, ref as l, watch as h, useSlots as ye, computed as y, resolveComponent as le, createElementBlock as T, createCommentVNode as p, openBlock as s, withDirectives as _, createBlock as M, unref as c, renderSlot as D, vShow as x, mergeProps as ee, withCtx as $, mergeDefaults as De, nextTick as Se, onMounted as Ue, resolveDynamicComponent as Ie, normalizeProps as we, guardReactiveProps as Te, createElementVNode as Me, toDisplayString as Re, createSlots as ve } from "vue";
2
+ import { httpCall as Ee } from "lkt-http-client";
3
+ import { DataState as ce } from "lkt-data-state";
4
+ import { ensureButtonConfig as E, LktSettings as n, ItemCrudMode as w, ItemCrudButtonNavVisibility as re, TablePermission as ie, ItemCrudView as fe, ItemCrudButtonNavPosition as me, NotificationType as N, getDefaultValues as Ne, ItemCrud as $e, ToastPositionX as q } from "lkt-vue-kernel";
5
+ import { closeModal as Ve } from "lkt-modal";
6
+ import { __ as Le } from "lkt-i18n";
7
+ import { openToast as z } from "lkt-toast";
8
8
  const G = class G {
9
9
  };
10
10
  G.debugEnabled = !1, G.defaultSaveIcon = "", G.defaultDropIcon = "";
11
- let q = G;
12
- const g = (...C) => {
13
- q.debugEnabled && console.info("[LktItemCrud] ", ...C);
14
- }, et = (C = !0) => {
15
- q.debugEnabled = C;
16
- }, Le = {
11
+ let F = G;
12
+ const g = (...B) => {
13
+ F.debugEnabled && console.info("[LktItemCrud] ", ...B);
14
+ }, tt = (B = !0) => {
15
+ F.debugEnabled = B;
16
+ }, Oe = {
17
17
  key: 0,
18
18
  class: "lkt-item-crud-buttons"
19
19
  }, Ae = {
20
20
  key: 0,
21
21
  class: "lkt-item-crud-buttons"
22
- }, Pe = {
22
+ }, je = {
23
23
  key: 1,
24
24
  class: "lkt-item-crud-buttons"
25
- }, Xe = {
25
+ }, Pe = {
26
26
  key: 5,
27
27
  class: "lkt-item-crud-buttons"
28
- }, fe = /* @__PURE__ */ me({
28
+ }, be = /* @__PURE__ */ ge({
29
29
  __name: "ButtonNav",
30
30
  props: {
31
31
  item: { default: () => ({}) },
@@ -33,14 +33,15 @@ const g = (...C) => {
33
33
  loading: { type: Boolean },
34
34
  view: {},
35
35
  mode: {},
36
- createButton: {},
37
- updateButton: {},
38
- dropButton: {},
39
- editModeButton: {},
36
+ createButton: { type: [Object, Boolean] },
37
+ updateButton: { type: [Object, Boolean] },
38
+ dropButton: { type: [Object, Boolean] },
39
+ editModeButton: { type: [Object, Boolean] },
40
40
  dataChanged: { type: Boolean },
41
41
  canUpdate: { type: Boolean },
42
42
  canDrop: { type: Boolean },
43
43
  canSwitchEditMode: { type: Boolean },
44
+ perms: {},
44
45
  httpSuccessRead: { type: Boolean },
45
46
  buttonNavVisibility: {}
46
47
  },
@@ -51,172 +52,181 @@ const g = (...C) => {
51
52
  "save",
52
53
  "drop"
53
54
  ],
54
- setup(C, { expose: J, emit: ee }) {
55
- const o = ee, a = C, c = i(E(a.createButton, n.defaultCreateButton)), M = i(E(a.updateButton, n.defaultUpdateButton)), d = i(E(a.dropButton, n.defaultDropButton)), r = i(E(a.editModeButton, n.defaultEditModeButton));
56
- k(() => a.createButton, (t) => {
57
- c.value = E(t, n.defaultCreateButton);
58
- }, { deep: !0 }), k(() => a.updateButton, (t) => {
59
- M.value = E(t, n.defaultUpdateButton);
60
- }, { deep: !0 }), k(() => a.dropButton, (t) => {
55
+ setup(B, { expose: J, emit: te }) {
56
+ const o = te, a = B, f = l(E(a.createButton, n.defaultCreateButton)), r = l(E(a.updateButton, n.defaultUpdateButton)), d = l(E(a.dropButton, n.defaultDropButton)), C = l(E(a.editModeButton, n.defaultEditModeButton));
57
+ h(() => a.createButton, (t) => {
58
+ f.value = E(t, n.defaultCreateButton);
59
+ }, { deep: !0 }), h(() => a.updateButton, (t) => {
60
+ r.value = E(t, n.defaultUpdateButton);
61
+ }, { deep: !0 }), h(() => a.dropButton, (t) => {
61
62
  d.value = E(t, n.defaultDropButton);
62
- }, { deep: !0 }), k(() => a.editModeButton, (t) => {
63
- r.value = E(t, n.defaultEditModeButton);
63
+ }, { deep: !0 }), h(() => a.editModeButton, (t) => {
64
+ C.value = E(t, n.defaultEditModeButton);
64
65
  }, { deep: !0 });
65
- const m = be(), B = i(null), S = i(null), b = i(a.loading);
66
- k(() => a.loading, (t) => b.value = t), k(b, (t) => o("update:loading", t));
67
- const f = i(a.editing);
68
- k(() => a.editing, (t) => f.value = t), k(f, (t) => o("update:editing", t));
69
- const h = () => {
70
- b.value = !0;
71
- }, I = () => {
72
- b.value = !1;
73
- }, z = (t, l) => {
74
- typeof t > "u" || o("create", t, l);
75
- }, T = (t, l) => {
76
- typeof t > "u" || o("save", t, l);
77
- }, F = (t, l) => {
78
- typeof t > "u" || o("drop", t, l);
66
+ const b = ye(), k = l(null), I = l(null), v = l(a.loading);
67
+ h(() => a.loading, (t) => v.value = t), h(v, (t) => o("update:loading", t));
68
+ const i = l(a.editing);
69
+ h(() => a.editing, (t) => i.value = t), h(i, (t) => o("update:editing", t));
70
+ const U = () => {
71
+ v.value = !0;
72
+ }, V = () => {
73
+ v.value = !1;
74
+ }, R = (t, m) => {
75
+ typeof t > "u" || o("create", t, m);
76
+ }, H = (t, m) => {
77
+ typeof t > "u" || o("save", t, m);
78
+ }, Q = (t, m) => {
79
+ typeof t > "u" || o("drop", t, m);
79
80
  };
80
81
  J({
81
82
  doSave: () => {
82
- B.value && typeof B.value.click == "function" && B.value.click();
83
+ k.value && typeof k.value.click == "function" && k.value.click();
83
84
  },
84
85
  doDrop: () => {
85
- S.value && typeof S.value.click == "function" && S.value.click();
86
+ I.value && typeof I.value.click == "function" && I.value.click();
86
87
  }
87
88
  });
88
- const X = y(() => {
89
- var t, l;
90
- return a.mode !== $.Create && !a.canUpdate || !a.dataChanged ? !1 : typeof ((t = M.value) == null ? void 0 : t.disabled) == "function" ? !M.value.disabled(a.item) : typeof ((l = M.value) == null ? void 0 : l.disabled) == "boolean" ? !M.value.disabled : !0;
91
- }), _ = y(() => {
92
- var t, l;
93
- return a.mode !== $.Create || !a.dataChanged ? !1 : typeof ((t = c.value) == null ? void 0 : t.disabled) == "function" ? !c.value.disabled(a.item) : typeof ((l = c.value) == null ? void 0 : l.disabled) == "boolean" ? !c.value.disabled : !0;
94
- }), H = y(() => {
95
- var t, l;
96
- return a.canDrop ? typeof ((t = d.value) == null ? void 0 : t.disabled) == "function" ? !d.value.disabled(a.item) : typeof ((l = d.value) == null ? void 0 : l.disabled) == "boolean" ? !d.value.disabled : !0 : !1;
97
- }), A = y(() => a.canDrop ? !a.canUpdate && a.canDrop ? !0 : !b.value && a.editing && a.httpSuccessRead : !1), P = y(() => a.dataChanged ? !0 : b.value ? !1 : a.mode === $.Create ? !0 : a.buttonNavVisibility === ue.Never ? !1 : a.editing && a.httpSuccessRead), K = y(() => !a.canSwitchEditMode || !a.canUpdate && !a.canDrop || !a.canUpdate && a.canDrop ? !1 : !b.value && a.mode !== $.Create && a.httpSuccessRead), Q = y(() => a.buttonNavVisibility === ue.Always && (X.value || _.value || H.value) || m["prev-buttons-ever"] ? !0 : a.buttonNavVisibility === ue.Never ? !1 : P.value || A.value || K.value);
98
- return (t, l) => {
99
- const W = de("lkt-button");
100
- return Q.value ? (s(), U("div", Le, [
101
- p(m)["prev-buttons-ever"] ? Y((s(), U("div", Ae, [
102
- D(t.$slots, "prev-buttons-ever")
89
+ const O = y(() => {
90
+ var t, m;
91
+ return a.mode !== w.Update || !a.canUpdate || !a.dataChanged ? !1 : typeof ((t = r.value) == null ? void 0 : t.disabled) == "function" ? !r.value.disabled(a.item) : typeof ((m = r.value) == null ? void 0 : m.disabled) == "boolean" ? !r.value.disabled : !0;
92
+ }), j = y(() => {
93
+ var t, m;
94
+ return a.mode !== w.Create || !a.dataChanged ? !1 : typeof ((t = f.value) == null ? void 0 : t.disabled) == "function" ? !f.value.disabled(a.item) : typeof ((m = f.value) == null ? void 0 : m.disabled) == "boolean" ? !f.value.disabled : !0;
95
+ }), A = y(() => {
96
+ var t, m;
97
+ return a.canDrop ? typeof ((t = d.value) == null ? void 0 : t.disabled) == "function" ? !d.value.disabled(a.item) : typeof ((m = d.value) == null ? void 0 : m.disabled) == "boolean" ? !d.value.disabled : !0 : !1;
98
+ }), P = y(() => !a.canDrop || a.dropButton === !1 ? !1 : !a.canUpdate && a.canDrop ? !0 : !v.value && a.editing && a.httpSuccessRead), X = y(() => a.mode === w.Create && a.createButton === !1 || a.mode === w.Update && a.updateButton === !1 ? !1 : a.dataChanged ? O.value || j.value : v.value ? !1 : a.mode === w.Create ? !0 : a.buttonNavVisibility === re.Never ? !1 : a.editing && a.httpSuccessRead), K = y(() => a.editModeButton === !1 || !a.canSwitchEditMode || !a.canUpdate && !a.canDrop || !a.canUpdate && a.canDrop ? !1 : !v.value && a.mode !== w.Create && a.httpSuccessRead), Z = y(() => a.buttonNavVisibility === re.Always && (O.value || j.value || A.value) || b["prev-buttons-ever"] ? !0 : a.buttonNavVisibility === re.Never ? !1 : X.value || P.value || K.value);
99
+ return (t, m) => {
100
+ const W = le("lkt-button");
101
+ return Z.value ? (s(), T("div", Oe, [
102
+ c(b)["prev-buttons-ever"] ? _((s(), T("div", Ae, [
103
+ D(t.$slots, "prev-buttons-ever", {
104
+ canUpdate: t.canUpdate,
105
+ canDrop: t.canDrop,
106
+ perms: t.perms
107
+ })
103
108
  ], 512)), [
104
- [Z, !b.value]
105
- ]) : v("", !0),
106
- p(m)["prev-buttons"] ? Y((s(), U("div", Pe, [
107
- D(t.$slots, "prev-buttons")
109
+ [x, !v.value]
110
+ ]) : p("", !0),
111
+ c(b)["prev-buttons"] ? _((s(), T("div", je, [
112
+ D(t.$slots, "prev-buttons", {
113
+ canUpdate: t.canUpdate,
114
+ canDrop: t.canDrop,
115
+ perms: t.perms
116
+ })
108
117
  ], 512)), [
109
- [Z, f.value && !b.value]
110
- ]) : v("", !0),
111
- t.mode === p($).Update && P.value ? (s(), w(W, x({
118
+ [x, i.value && !v.value]
119
+ ]) : p("", !0),
120
+ t.mode === c(w).Update && X.value ? (s(), M(W, ee({
112
121
  key: 2,
113
122
  ref_key: "saveButtonRef",
114
- ref: B
115
- }, M.value, {
116
- disabled: !X.value,
117
- onLoading: h,
118
- onLoaded: I,
119
- onClick: T
123
+ ref: k
124
+ }, r.value, {
125
+ disabled: !O.value,
126
+ onLoading: U,
127
+ onLoaded: V,
128
+ onClick: H
120
129
  }), {
121
- default: V(() => [
122
- p(m)["button-save"] ? D(t.$slots, "button-save", {
130
+ default: $(() => [
131
+ c(b)["button-save"] ? D(t.$slots, "button-save", {
123
132
  key: 0,
124
133
  item: t.item,
125
- editMode: f.value,
134
+ editMode: i.value,
126
135
  isCreate: !1,
127
136
  canUpdate: t.canUpdate,
128
137
  canDrop: t.canDrop
129
- }) : v("", !0)
138
+ }) : p("", !0)
130
139
  ]),
131
140
  _: 3
132
- }, 16, ["disabled"])) : t.mode === p($).Create && P.value ? (s(), w(W, x({
141
+ }, 16, ["disabled"])) : t.mode === c(w).Create && X.value ? (s(), M(W, ee({
133
142
  key: 3,
134
143
  ref_key: "saveButtonRef",
135
- ref: B
136
- }, c.value, {
137
- disabled: !_.value,
138
- onLoading: h,
139
- onLoaded: I,
140
- onClick: z
144
+ ref: k
145
+ }, f.value, {
146
+ disabled: !j.value,
147
+ onLoading: U,
148
+ onLoaded: V,
149
+ onClick: R
141
150
  }), {
142
- default: V(() => [
143
- p(m)["button-save"] ? D(t.$slots, "button-save", {
151
+ default: $(() => [
152
+ c(b)["button-save"] ? D(t.$slots, "button-save", {
144
153
  key: 0,
145
154
  item: t.item,
146
- editMode: f.value,
155
+ editMode: i.value,
147
156
  isCreate: !0,
148
157
  canUpdate: t.canUpdate,
149
158
  canDrop: t.canDrop
150
- }) : v("", !0)
159
+ }) : p("", !0)
151
160
  ]),
152
161
  _: 3
153
- }, 16, ["disabled"])) : v("", !0),
154
- t.mode !== p($).Create ? Y((s(), w(W, x({
162
+ }, 16, ["disabled"])) : p("", !0),
163
+ t.mode !== c(w).Create ? _((s(), M(W, ee({
155
164
  key: 4,
156
165
  ref_key: "dropButtonRef",
157
- ref: S
166
+ ref: I
158
167
  }, d.value, {
159
- disabled: !H.value,
160
- onLoading: h,
161
- onLoaded: I,
162
- onClick: F
168
+ disabled: !A.value,
169
+ onLoading: U,
170
+ onLoaded: V,
171
+ onClick: Q
163
172
  }), {
164
- default: V(() => [
165
- p(m)["button-drop"] ? D(t.$slots, "button-drop", {
173
+ default: $(() => [
174
+ c(b)["button-drop"] ? D(t.$slots, "button-drop", {
166
175
  key: 0,
167
176
  item: t.item,
168
- editMode: f.value,
177
+ editMode: i.value,
169
178
  isCreate: !1,
170
179
  canUpdate: t.canUpdate,
171
180
  canDrop: t.canDrop
172
- }) : v("", !0)
181
+ }) : p("", !0)
173
182
  ]),
174
183
  _: 3
175
184
  }, 16, ["disabled"])), [
176
- [Z, A.value]
177
- ]) : v("", !0),
178
- p(m).buttons ? Y((s(), U("div", Xe, [
185
+ [x, P.value]
186
+ ]) : p("", !0),
187
+ c(b).buttons ? _((s(), T("div", Pe, [
179
188
  D(t.$slots, "buttons")
180
189
  ], 512)), [
181
- [Z, f.value && !b.value]
182
- ]) : v("", !0),
183
- K.value ? (s(), w(W, x({ key: 6 }, r.value, {
184
- checked: f.value,
185
- "onUpdate:checked": l[0] || (l[0] = (ie) => f.value = ie),
190
+ [x, i.value && !v.value]
191
+ ]) : p("", !0),
192
+ K.value ? (s(), M(W, ee({ key: 6 }, C.value, {
193
+ checked: i.value,
194
+ "onUpdate:checked": m[0] || (m[0] = (ae) => i.value = ae),
186
195
  class: "lkt-item-crud--switch-mode-button"
187
- }), null, 16, ["checked"])) : v("", !0)
188
- ])) : v("", !0);
196
+ }), null, 16, ["checked"])) : p("", !0)
197
+ ])) : p("", !0);
189
198
  };
190
199
  }
191
- }), _e = { class: "lkt-item-crud" }, Oe = {
200
+ }), Xe = { class: "lkt-item-crud" }, qe = {
192
201
  key: 0,
193
202
  class: "lkt-item-crud_header"
194
- }, je = {
203
+ }, ze = {
195
204
  key: 0,
196
205
  class: "lkt-item-crud_header-slot"
197
- }, qe = {
206
+ }, Fe = {
198
207
  key: 1,
199
208
  class: "lkt-item-crud_header-title"
200
- }, ze = {
209
+ }, He = {
201
210
  key: 2,
202
211
  class: "lkt-item-crud_header-slot"
203
- }, Fe = {
212
+ }, Ke = {
204
213
  key: 2,
205
214
  class: "lkt-item-crud_content"
206
- }, He = {
215
+ }, We = {
207
216
  key: 0,
208
217
  class: "lkt-grid-1"
209
- }, Ke = /* @__PURE__ */ me({
218
+ }, Ge = /* @__PURE__ */ ge({
210
219
  __name: "LktItemCrud",
211
- props: /* @__PURE__ */ Be({
220
+ props: /* @__PURE__ */ De({
212
221
  modelValue: {},
213
222
  editing: { type: Boolean },
223
+ perms: {},
214
224
  mode: {},
215
225
  view: {},
216
- editModeButton: {},
217
- dropButton: {},
218
- createButton: {},
219
- updateButton: {},
226
+ editModeButton: { type: [Object, Boolean] },
227
+ dropButton: { type: [Object, Boolean] },
228
+ createButton: { type: [Object, Boolean] },
229
+ updateButton: { type: [Object, Boolean] },
220
230
  buttonNavPosition: {},
221
231
  buttonNavVisibility: {},
222
232
  modalConfig: {},
@@ -227,7 +237,7 @@ const g = (...C) => {
227
237
  title: {},
228
238
  beforeEmitUpdate: { type: Function },
229
239
  notificationType: {}
230
- }, Ee(Ne)),
240
+ }, Ne($e)),
231
241
  emits: [
232
242
  "update:modelValue",
233
243
  "update:editing",
@@ -240,100 +250,98 @@ const g = (...C) => {
240
250
  "error",
241
251
  "modified-data"
242
252
  ],
243
- setup(C, { expose: J, emit: ee }) {
244
- const o = C, a = be(), c = ee;
245
- let M = [];
246
- const d = i(!0), r = i(o.modelValue), m = i(M), B = i(o.editing), S = i(!1), b = i(!1), f = i(200), h = i(new ve(r.value, o.dataStateConfig)), I = i(!1), z = i(new ve(o.readData)), T = i(o.mode === $.Create), F = i(!1), te = i(!1), L = i(null), X = y(() => !T.value && Array.isArray(m.value) && m.value.includes(ne.Update)), _ = y(() => !T.value && Array.isArray(m.value) && m.value.includes(ne.Drop)), H = y(() => !T.value && Array.isArray(m.value) && m.value.includes(ne.SwitchEditMode)), A = async () => {
247
- g("fetchItem"), d.value = !0, f.value = -1, b.value = !1;
253
+ setup(B, { expose: J, emit: te }) {
254
+ const o = B, a = ye(), f = te, r = l(!0), d = l(o.modelValue), C = l(o.perms), b = l(o.editing), k = l(!1), I = l(!1), v = l(200), i = l(new ce(d.value, o.dataStateConfig)), U = l(!1), V = l(new ce(o.readData)), R = l(o.mode === w.Create), H = l(!1), Q = l(!1), L = l(null), Y = y(() => !R.value && Array.isArray(C.value) && C.value.includes(ie.Update)), O = y(() => !R.value && Array.isArray(C.value) && C.value.includes(ie.Drop)), j = y(() => !R.value && Array.isArray(C.value) && C.value.includes(ie.SwitchEditMode)), A = async () => {
255
+ g("fetchItem"), r.value = !0, v.value = -1, I.value = !1;
248
256
  try {
249
- const e = await Re(o.readResource, o.readData);
250
- if (g("fetchItem -> response", e), d.value = !1, f.value = e.httpStatus, !e.success) {
251
- S.value = !1, f.value = e.httpStatus, c("error", e.httpStatus);
257
+ const e = await Ee(o.readResource, o.readData);
258
+ if (g("fetchItem -> response", e), r.value = !1, v.value = e.httpStatus, !e.success) {
259
+ k.value = !1, v.value = e.httpStatus, f("error", e.httpStatus);
252
260
  return;
253
261
  }
254
- S.value = !0, r.value = e.data, m.value = e.perms, h.value.increment(r.value).turnStoredIntoOriginal(), I.value = h.value.changed(), z.value.turnStoredIntoOriginal(), c("read", e);
262
+ k.value = !0, d.value = e.data, C.value = e.perms, i.value.increment(d.value).turnStoredIntoOriginal(), U.value = i.value.changed(), V.value.turnStoredIntoOriginal(), f("read", e);
255
263
  } catch {
256
- d.value = !1, S.value = !1, f.value = 404, c("error", 404);
264
+ r.value = !1, k.value = !1, v.value = 404, f("error", 404);
257
265
  return;
258
266
  }
259
267
  };
260
- k(() => o.modelValue, (e) => {
261
- r.value = e, h.value.increment(e);
262
- }, { deep: !0 }), k(r, (e) => {
263
- if (F.value = !0, g("item updated ->", r.value), typeof o.beforeEmitUpdate == "function") {
268
+ h(() => o.modelValue, (e) => {
269
+ d.value = e, i.value.increment(e);
270
+ }, { deep: !0 }), h(d, (e) => {
271
+ if (H.value = !0, g("item updated ->", d.value), typeof o.beforeEmitUpdate == "function") {
264
272
  g("item updated -> has beforeEmitUpdate");
265
- let u = o.beforeEmitUpdate(r.value);
266
- g("item updated -> override with: ", u), typeof u == "object" && (r.value = u);
273
+ let u = o.beforeEmitUpdate(d.value);
274
+ g("item updated -> override with: ", u), typeof u == "object" && (d.value = u);
267
275
  }
268
- c("update:modelValue", r.value), g("item updated -> update dataState"), h.value.increment(e), I.value = h.value.changed(), De(() => F.value = !1);
269
- }, { deep: !0 }), k(m, () => c("perms", m.value)), k(I, (e) => {
270
- c("modified-data", e);
271
- }), k(() => o.readData, (e) => {
272
- z.value.increment(e), z.value.changed() && A();
273
- }), k(() => o.editing, (e) => {
274
- g("editing updated -> updating editMode", e), B.value = e;
275
- }), k(B, (e) => {
276
- g("editMode updated -> emit update", e), c("update:editing", e);
277
- }), Se(() => {
278
- o.readResource && !T.value ? A() : T.value && (S.value = !0, B.value = !0, d.value = !1, h.value.increment(r.value).turnStoredIntoOriginal(), I.value = h.value.changed());
276
+ f("update:modelValue", d.value), g("item updated -> update dataState"), i.value.increment(e), U.value = i.value.changed(), Se(() => H.value = !1);
277
+ }, { deep: !0 }), h(C, () => f("perms", C.value)), h(U, (e) => {
278
+ f("modified-data", e);
279
+ }), h(() => o.readData, (e) => {
280
+ V.value.increment(e), V.value.changed() && A();
281
+ }), h(() => o.editing, (e) => {
282
+ g("editing updated -> updating editMode", e), b.value = e;
283
+ }), h(b, (e) => {
284
+ g("editMode updated -> emit update", e), f("update:editing", e);
285
+ }), Ue(() => {
286
+ o.readResource && !R.value ? A() : (R.value, k.value = !0, b.value = !0, r.value = !1, i.value.increment(d.value).turnStoredIntoOriginal(), U.value = i.value.changed());
279
287
  });
280
288
  const P = (e, u) => {
281
289
  if (u) {
282
- if (d.value = !1, typeof e < "u" && (f.value = e.httpStatus, !e.success))
283
- return b.value = !0, c("error", e.httpStatus), !1;
284
- b.value = !0;
290
+ if (r.value = !1, typeof e < "u" && (v.value = e.httpStatus, !e.success))
291
+ return I.value = !0, f("error", e.httpStatus), !1;
292
+ I.value = !0;
285
293
  }
286
294
  return !0;
287
- }, K = (e) => {
288
- !oe.value && e.autoReloadId && (g("doAutoReloadId -> autoReloadId detected: ", e.autoReloadId), o.readData.id = e.autoReloadId, g("doAutoReloadId -> turning off create mode"), T.value = !1, A());
289
- }, Q = (e, u) => {
295
+ }, X = (e) => {
296
+ !ue.value && e.autoReloadId && (g("doAutoReloadId -> autoReloadId detected: ", e.autoReloadId), o.readData.id = e.autoReloadId, g("doAutoReloadId -> turning off create mode"), R.value = !1, A());
297
+ }, K = (e, u) => {
290
298
  if (g("onCreate"), !P(u, o.createButton.resource)) {
291
- o.notificationType === N.Toast && j({
299
+ o.notificationType === N.Toast && z({
292
300
  text: n.defaultCreateErrorText,
293
301
  details: n.defaultCreateErrorDetails,
294
302
  icon: n.defaultCreateErrorIcon,
295
- positionX: O.Right
303
+ positionX: q.Right
296
304
  });
297
305
  return;
298
306
  }
299
- te.value = !0, g("onCreate -> turn stored data into original"), h.value.increment(r.value).turnStoredIntoOriginal(), o.notificationType === N.Toast && j({
307
+ Q.value = !0, g("onCreate -> turn stored data into original"), i.value.increment(d.value).turnStoredIntoOriginal(), o.notificationType === N.Toast && z({
300
308
  text: n.defaultCreateSuccessText,
301
309
  details: n.defaultCreateSuccessDetails,
302
310
  icon: n.defaultCreateSuccessIcon,
303
- positionX: O.Right
304
- }), K(u), c("create", u);
305
- }, t = (e, u) => {
311
+ positionX: q.Right
312
+ }), X(u), f("create", u);
313
+ }, Z = (e, u) => {
306
314
  if (g("onUpdate"), !P(u, o.updateButton.resource)) {
307
- o.notificationType === N.Toast && j({
315
+ o.notificationType === N.Toast && z({
308
316
  text: n.defaultUpdateErrorText,
309
317
  details: n.defaultUpdateErrorDetails,
310
318
  icon: n.defaultUpdateErrorIcon,
311
- positionX: O.Right
319
+ positionX: q.Right
312
320
  });
313
321
  return;
314
322
  }
315
- g("onUpdate -> turn stored data into original"), h.value.turnStoredIntoOriginal(), o.notificationType === N.Toast && j({
323
+ g("onUpdate -> turn stored data into original"), i.value.turnStoredIntoOriginal(), o.notificationType === N.Toast && z({
316
324
  text: n.defaultUpdateSuccessText,
317
325
  details: n.defaultUpdateSuccessDetails,
318
326
  icon: n.defaultUpdateSuccessIcon,
319
- positionX: O.Right
320
- }), K(u), c("update", u);
321
- }, l = (e, u) => {
327
+ positionX: q.Right
328
+ }), X(u), f("update", u);
329
+ }, t = (e, u) => {
322
330
  if (g("onDrop"), !P(u, o.dropButton.resource)) {
323
- o.notificationType === N.Toast && j({
331
+ o.notificationType === N.Toast && z({
324
332
  text: n.defaultDropErrorText,
325
333
  details: n.defaultDropErrorDetails,
326
334
  icon: n.defaultDropErrorIcon,
327
- positionX: O.Right
335
+ positionX: q.Right
328
336
  });
329
337
  return;
330
338
  }
331
- o.notificationType === N.Toast && j({
339
+ o.notificationType === N.Toast && z({
332
340
  text: n.defaultDropSuccessText,
333
341
  details: n.defaultDropSuccessDetails,
334
342
  icon: n.defaultDropSuccessIcon,
335
- positionX: O.Right
336
- }), c("drop", u), o.view === pe.Modal && (g("onDrop -> close modal"), $e(o.modalConfig.modalName, o.modalConfig.modalKey));
343
+ positionX: q.Right
344
+ }), f("drop", u), o.view === fe.Modal && (g("onDrop -> close modal"), Ve(o.modalConfig.modalName, o.modalConfig.modalKey));
337
345
  };
338
346
  J({
339
347
  doDrop: () => {
@@ -343,54 +351,54 @@ const g = (...C) => {
343
351
  doSave: () => {
344
352
  L.value && L.value.doSave();
345
353
  },
346
- hasModifiedData: () => h.value.changed()
354
+ hasModifiedData: () => i.value.changed()
347
355
  });
348
- const ge = y(() => {
356
+ const ae = y(() => {
349
357
  var e;
350
- return h.value.changed() ? (e = o.modalConfig) == null ? void 0 : e.closeConfirm : "";
351
- }), ye = (e) => {
358
+ return i.value.changed() ? (e = o.modalConfig) == null ? void 0 : e.closeConfirm : "";
359
+ }), he = (e) => {
352
360
  var u;
353
361
  if (typeof ((u = o.modalConfig) == null ? void 0 : u.beforeClose) == "function")
354
362
  return o.modalConfig.beforeClose({
355
363
  ...e,
356
- itemCreated: te.value
364
+ itemCreated: Q.value
357
365
  });
358
- }, ae = y(() => o.title.startsWith("__:") ? String(Ve(o.title.substring(3))) : o.title), he = y(() => d.value ? !1 : ae.value.length > 0 || !!a["post-title"]), oe = y(() => o.view === pe.Modal), re = y(() => oe.value ? "lkt-modal" : "section"), ke = y(() => re.value === "lkt-modal" ? {
366
+ }, oe = y(() => o.title.startsWith("__:") ? String(Le(o.title.substring(3))) : o.title), Be = y(() => r.value ? !1 : oe.value.length > 0 || !!a["post-title"]), ue = y(() => o.view === fe.Modal), se = y(() => ue.value ? "lkt-modal" : "section"), ke = y(() => se.value === "lkt-modal" ? {
359
367
  title: o.title,
360
- item: r.value,
368
+ item: d.value,
361
369
  ...o.modalConfig,
362
- "before-close": ye,
363
- "close-confirm": ge.value
370
+ beforeClose: he,
371
+ closeConfirm: ae.value
364
372
  } : {});
365
373
  return (e, u) => {
366
- const le = de("lkt-http-info"), Ce = de("lkt-loader");
367
- return s(), w(Ie(re.value), Ue(we(ke.value)), {
368
- default: V(() => [
369
- Te("article", _e, [
370
- !oe.value && he.value ? (s(), U("header", Oe, [
371
- p(a)["pre-title"] ? (s(), U("div", je, [
374
+ const pe = le("lkt-http-info"), Ce = le("lkt-loader");
375
+ return s(), M(Ie(se.value), we(Te(ke.value)), {
376
+ default: $(() => [
377
+ Me("article", Xe, [
378
+ !ue.value && Be.value ? (s(), T("header", qe, [
379
+ c(a)["pre-title"] ? (s(), T("div", ze, [
372
380
  D(e.$slots, "pre-title", {
373
- item: r.value,
374
- loading: d.value
381
+ item: d.value,
382
+ loading: r.value
375
383
  })
376
- ])) : v("", !0),
377
- ae.value.length > 0 ? (s(), U("h1", qe, Me(ae.value), 1)) : v("", !0),
378
- p(a)["post-title"] ? (s(), U("div", ze, [
384
+ ])) : p("", !0),
385
+ oe.value.length > 0 ? (s(), T("h1", Fe, Re(oe.value), 1)) : p("", !0),
386
+ c(a)["post-title"] ? (s(), T("div", He, [
379
387
  D(e.$slots, "post-title", {
380
- item: r.value,
381
- loading: d.value
388
+ item: d.value,
389
+ loading: r.value
382
390
  })
383
- ])) : v("", !0)
384
- ])) : v("", !0),
385
- e.buttonNavPosition === p(ce).Top ? (s(), w(fe, {
391
+ ])) : p("", !0)
392
+ ])) : p("", !0),
393
+ e.buttonNavPosition === c(me).Top ? (s(), M(be, {
386
394
  key: 1,
387
395
  ref_key: "buttonNav",
388
396
  ref: L,
389
- loading: d.value,
390
- "onUpdate:loading": u[0] || (u[0] = (R) => d.value = R),
391
- editing: B.value,
392
- "onUpdate:editing": u[1] || (u[1] = (R) => B.value = R),
393
- item: r.value,
397
+ loading: r.value,
398
+ "onUpdate:loading": u[0] || (u[0] = (S) => r.value = S),
399
+ editing: b.value,
400
+ "onUpdate:editing": u[1] || (u[1] = (S) => b.value = S),
401
+ item: d.value,
394
402
  mode: e.mode,
395
403
  view: e.view,
396
404
  "button-nav-visibility": e.buttonNavVisibility,
@@ -398,64 +406,73 @@ const g = (...C) => {
398
406
  "update-button": e.updateButton,
399
407
  "drop-button": e.dropButton,
400
408
  "edit-mode-button": e.editModeButton,
401
- "data-changed": I.value,
402
- "http-success-read": S.value,
403
- "can-update": X.value,
404
- "can-drop": _.value,
405
- "can-switch-edit-mode": H.value,
406
- onCreate: Q,
407
- onSave: t,
408
- onDrop: l
409
- }, se({ _: 2 }, [
410
- p(a)["prev-buttons-ever"] ? {
409
+ "data-changed": U.value,
410
+ "http-success-read": k.value,
411
+ "can-update": Y.value,
412
+ "can-drop": O.value,
413
+ "can-switch-edit-mode": j.value,
414
+ perms: C.value,
415
+ onCreate: K,
416
+ onSave: Z,
417
+ onDrop: t
418
+ }, ve({ _: 2 }, [
419
+ c(a)["prev-buttons-ever"] ? {
411
420
  name: "prev-buttons-ever",
412
- fn: V(() => [
413
- D(e.$slots, "prev-buttons-ever")
421
+ fn: $(({ canUpdate: S, canDrop: ne, perms: de }) => [
422
+ D(e.$slots, "prev-buttons-ever", {
423
+ canUpdate: S,
424
+ canDrop: ne,
425
+ perms: de
426
+ })
414
427
  ]),
415
428
  key: "0"
416
429
  } : void 0,
417
- p(a)["prev-buttons"] ? {
430
+ c(a)["prev-buttons"] ? {
418
431
  name: "prev-buttons-ever",
419
- fn: V(() => [
420
- D(e.$slots, "prev-buttons")
432
+ fn: $(({ canUpdate: S, canDrop: ne, perms: de }) => [
433
+ D(e.$slots, "prev-buttons", {
434
+ canUpdate: S,
435
+ canDrop: ne,
436
+ perms: de
437
+ })
421
438
  ]),
422
439
  key: "1"
423
440
  } : void 0
424
- ]), 1032, ["loading", "editing", "item", "mode", "view", "button-nav-visibility", "create-button", "update-button", "drop-button", "edit-mode-button", "data-changed", "http-success-read", "can-update", "can-drop", "can-switch-edit-mode"])) : v("", !0),
425
- d.value ? v("", !0) : (s(), U("div", Fe, [
426
- S.value ? (s(), U("div", He, [
427
- b.value && e.notificationType === p(N).Inline ? (s(), w(le, {
441
+ ]), 1032, ["loading", "editing", "item", "mode", "view", "button-nav-visibility", "create-button", "update-button", "drop-button", "edit-mode-button", "data-changed", "http-success-read", "can-update", "can-drop", "can-switch-edit-mode", "perms"])) : p("", !0),
442
+ r.value ? p("", !0) : (s(), T("div", Ke, [
443
+ k.value ? (s(), T("div", We, [
444
+ I.value && e.notificationType === c(N).Inline ? (s(), M(pe, {
428
445
  key: 0,
429
- code: f.value,
430
- palette: f.value === 200 ? "success" : "danger",
446
+ code: v.value,
447
+ palette: v.value === 200 ? "success" : "danger",
431
448
  quick: "",
432
449
  "can-close": "",
433
- onClose: u[2] || (u[2] = (R) => b.value = !1)
434
- }, null, 8, ["code", "palette"])) : v("", !0),
450
+ onClose: u[2] || (u[2] = (S) => I.value = !1)
451
+ }, null, 8, ["code", "palette"])) : p("", !0),
435
452
  D(e.$slots, "item", {
436
- item: r.value,
437
- loading: d.value,
438
- editMode: B.value,
439
- isCreate: T.value,
440
- canUpdate: X.value,
441
- canDrop: _.value,
442
- itemBeingEdited: F.value
453
+ item: d.value,
454
+ loading: r.value,
455
+ editMode: b.value,
456
+ isCreate: R.value,
457
+ canUpdate: Y.value,
458
+ canDrop: O.value,
459
+ itemBeingEdited: H.value
443
460
  })
444
- ])) : e.notificationType === p(N).Inline ? (s(), w(le, {
461
+ ])) : e.notificationType === c(N).Inline ? (s(), M(pe, {
445
462
  key: 1,
446
- code: f.value
447
- }, null, 8, ["code"])) : v("", !0)
463
+ code: v.value
464
+ }, null, 8, ["code"])) : p("", !0)
448
465
  ])),
449
- d.value ? (s(), w(Ce, { key: 3 })) : v("", !0),
450
- e.buttonNavPosition === p(ce).Bottom ? (s(), w(fe, {
466
+ r.value ? (s(), M(Ce, { key: 3 })) : p("", !0),
467
+ e.buttonNavPosition === c(me).Bottom ? (s(), M(be, {
451
468
  key: 4,
452
469
  ref_key: "buttonNav",
453
470
  ref: L,
454
- loading: d.value,
455
- "onUpdate:loading": u[3] || (u[3] = (R) => d.value = R),
456
- editing: B.value,
457
- "onUpdate:editing": u[4] || (u[4] = (R) => B.value = R),
458
- item: r.value,
471
+ loading: r.value,
472
+ "onUpdate:loading": u[3] || (u[3] = (S) => r.value = S),
473
+ editing: b.value,
474
+ "onUpdate:editing": u[4] || (u[4] = (S) => b.value = S),
475
+ item: d.value,
459
476
  mode: e.mode,
460
477
  view: e.view,
461
478
  "button-nav-visibility": e.buttonNavVisibility,
@@ -463,48 +480,48 @@ const g = (...C) => {
463
480
  "update-button": e.updateButton,
464
481
  "drop-button": e.dropButton,
465
482
  "edit-mode-button": e.editModeButton,
466
- "data-changed": I.value,
467
- "http-success-read": S.value,
468
- "can-update": X.value,
469
- "can-drop": _.value,
470
- "can-switch-edit-mode": H.value,
471
- onCreate: Q,
472
- onSave: t,
473
- onDrop: l
474
- }, se({ _: 2 }, [
475
- p(a)["prev-buttons-ever"] ? {
483
+ "data-changed": U.value,
484
+ "http-success-read": k.value,
485
+ "can-update": Y.value,
486
+ "can-drop": O.value,
487
+ "can-switch-edit-mode": j.value,
488
+ onCreate: K,
489
+ onSave: Z,
490
+ onDrop: t
491
+ }, ve({ _: 2 }, [
492
+ c(a)["prev-buttons-ever"] ? {
476
493
  name: "prev-buttons-ever",
477
- fn: V(() => [
494
+ fn: $(() => [
478
495
  D(e.$slots, "prev-buttons-ever")
479
496
  ]),
480
497
  key: "0"
481
498
  } : void 0,
482
- p(a)["prev-buttons"] ? {
499
+ c(a)["prev-buttons"] ? {
483
500
  name: "prev-buttons-ever",
484
- fn: V(() => [
501
+ fn: $(() => [
485
502
  D(e.$slots, "prev-buttons")
486
503
  ]),
487
504
  key: "1"
488
505
  } : void 0
489
- ]), 1032, ["loading", "editing", "item", "mode", "view", "button-nav-visibility", "create-button", "update-button", "drop-button", "edit-mode-button", "data-changed", "http-success-read", "can-update", "can-drop", "can-switch-edit-mode"])) : v("", !0)
506
+ ]), 1032, ["loading", "editing", "item", "mode", "view", "button-nav-visibility", "create-button", "update-button", "drop-button", "edit-mode-button", "data-changed", "http-success-read", "can-update", "can-drop", "can-switch-edit-mode"])) : p("", !0)
490
507
  ])
491
508
  ]),
492
509
  _: 3
493
510
  }, 16);
494
511
  };
495
512
  }
496
- }), tt = {
497
- install: (C, J = {}) => {
498
- C.component("lkt-item-crud") === void 0 && C.component("lkt-item-crud", Ke);
513
+ }), at = {
514
+ install: (B, J = {}) => {
515
+ B.component("lkt-item-crud") === void 0 && B.component("lkt-item-crud", Ge);
499
516
  }
500
- }, at = (C) => {
501
- q.defaultSaveIcon = C;
502
- }, ot = (C) => {
503
- q.defaultDropIcon = C;
517
+ }, ot = (B) => {
518
+ F.defaultSaveIcon = B;
519
+ }, ut = (B) => {
520
+ F.defaultDropIcon = B;
504
521
  };
505
522
  export {
506
- et as debugLktItemCrud,
507
- tt as default,
508
- ot as setItemCrudDefaultDropIcon,
509
- at as setItemCrudDefaultSaveIcon
523
+ tt as debugLktItemCrud,
524
+ at as default,
525
+ ut as setItemCrudDefaultDropIcon,
526
+ ot as setItemCrudDefaultSaveIcon
510
527
  };