lkt-item-crud 1.2.6 → 2.0.0

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