lkt-item-crud 1.1.2 → 1.1.4
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
package/dist/build.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as ue, useSlots as re, ref as s, computed as o, watch as B, resolveComponent as w, openBlock as i, createElementBlock as m, createElementVNode as j, toDisplayString as M, renderSlot as O, createCommentVNode as h, withDirectives as R, createBlock as V, withCtx as A, unref as H, vShow as q, createVNode as P } from "vue";
|
|
2
2
|
import { httpCall as oe } from "lkt-http-client";
|
|
3
3
|
import { DataState as de } from "lkt-data-state";
|
|
4
|
-
const
|
|
4
|
+
const ne = { class: "lkt-item-crud" }, se = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "lkt-item-crud_header"
|
|
7
|
-
}, ie = { class: "lkt-item-crud_header-title" }, ce = { class: "lkt-item-crud_header-slot" },
|
|
7
|
+
}, ie = { class: "lkt-item-crud_header-title" }, ce = { class: "lkt-item-crud_header-slot" }, fe = { class: "lkt-item-crud-buttons" }, ve = { key: 1 }, pe = { key: 1 }, me = {
|
|
8
8
|
key: 1,
|
|
9
9
|
class: "lkt-item-crud_content"
|
|
10
10
|
}, ye = {
|
|
11
11
|
key: 0,
|
|
12
12
|
class: "lkt-grid-1"
|
|
13
|
-
},
|
|
14
|
-
...
|
|
13
|
+
}, Ce = { name: "LktItemCrud", inheritAttrs: !1 }, he = /* @__PURE__ */ ue({
|
|
14
|
+
...Ce,
|
|
15
15
|
props: {
|
|
16
16
|
modelValue: { type: Object, required: !1, default: () => ({}) },
|
|
17
17
|
title: { type: String, default: "" },
|
|
@@ -33,61 +33,63 @@ const se = { class: "lkt-item-crud" }, ne = {
|
|
|
33
33
|
createConfirm: { type: String, default: "" },
|
|
34
34
|
updateConfirm: { type: String, default: "" },
|
|
35
35
|
dropConfirm: { type: String, default: "" },
|
|
36
|
-
createConfirmData: { type:
|
|
37
|
-
updateConfirmData: { type:
|
|
38
|
-
dropConfirmData: { type:
|
|
36
|
+
createConfirmData: { type: Object, default: () => ({}) },
|
|
37
|
+
updateConfirmData: { type: Object, default: () => ({}) },
|
|
38
|
+
dropConfirmData: { type: Object, default: () => ({}) },
|
|
39
39
|
createDisabled: { type: Boolean, default: !1 },
|
|
40
40
|
updateDisabled: { type: Boolean, default: !1 },
|
|
41
41
|
dropDisabled: { type: Boolean, default: !1 },
|
|
42
|
-
saveValidator: { type: Function, required: !1, default: () => !0 }
|
|
42
|
+
saveValidator: { type: Function, required: !1, default: () => !0 },
|
|
43
|
+
onCreate: { type: Function, required: !1, default: () => !0 },
|
|
44
|
+
onUpdate: { type: Function, required: !1, default: () => !0 }
|
|
43
45
|
},
|
|
44
46
|
emits: ["update:modelValue", "read", "create", "update", "drop", "perms", "error", "modified-data"],
|
|
45
|
-
setup(a, { expose:
|
|
46
|
-
const e = a,
|
|
47
|
+
setup(a, { expose: U, emit: z }) {
|
|
48
|
+
const e = a, _ = re(), d = z;
|
|
47
49
|
let G = [];
|
|
48
|
-
const l =
|
|
49
|
-
l.value = !0,
|
|
50
|
+
const l = s(!0), r = s(e.modelValue), y = s(G), c = s(!1), f = s(!1), v = s(!1), n = s(200), S = s(null), k = s(null), C = s(new de(r.value)), K = o(() => e.isCreate ? e.createConfirm : e.updateConfirm), Q = o(() => e.isCreate ? e.createConfirmData : e.updateConfirmData), I = o(() => e.isCreate ? e.createResource : e.updateResource), W = o(() => e.isCreate ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), X = o(() => e.isCreate ? e.createDisabled : e.updateDisabled), D = o(() => !e.isCreate && y.value.includes("update")), b = o(() => !e.isCreate && y.value.includes("drop")), L = async () => {
|
|
51
|
+
l.value = !0, n.value = -1, v.value = !1;
|
|
50
52
|
try {
|
|
51
53
|
const t = await oe(e.readResource, e.readData);
|
|
52
|
-
if (l.value = !1,
|
|
53
|
-
|
|
54
|
+
if (l.value = !1, n.value = t.httpStatus, !t.success) {
|
|
55
|
+
f.value = !1, n.value = t.httpStatus, d("error", t.httpStatus);
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
f.value = !0, r.value = t.data, y.value = t.perms, C.value.increment(r.value).turnStoredIntoOriginal(), d("read", t);
|
|
57
59
|
} catch {
|
|
58
|
-
l.value = !1,
|
|
60
|
+
l.value = !1, f.value = !1, n.value = 404, d("error", 404);
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
|
-
}, Y = o(() => l.value ? !1 : e.title || !!
|
|
63
|
+
}, Y = o(() => l.value ? !1 : e.title || !!_["post-title"]);
|
|
62
64
|
B(() => e.modelValue, (t) => {
|
|
63
|
-
|
|
64
|
-
}, { deep: !0 }), B(
|
|
65
|
-
d("update:modelValue",
|
|
65
|
+
r.value = t, C.value.increment(t);
|
|
66
|
+
}, { deep: !0 }), B(r, (t) => {
|
|
67
|
+
d("update:modelValue", r.value), C.value.increment(t);
|
|
66
68
|
}, { deep: !0 }), B(y, () => d("perms", y.value));
|
|
67
|
-
const
|
|
68
|
-
B(
|
|
69
|
-
const Z = (t,
|
|
70
|
-
if (l.value = !1,
|
|
71
|
-
|
|
69
|
+
const N = o(() => X.value || !e.isCreate && !D.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : C.value.changed());
|
|
70
|
+
B(N, (t) => d("modified-data", t)), e.readResource && !e.isCreate ? L() : e.isCreate && (f.value = !0, c.value = !0, l.value = !1);
|
|
71
|
+
const Z = (t, u) => {
|
|
72
|
+
if (l.value = !1, n.value = u.httpStatus, !u.success) {
|
|
73
|
+
v.value = !0, d("error", u.httpStatus);
|
|
72
74
|
return;
|
|
73
75
|
}
|
|
74
|
-
|
|
75
|
-
}, ee = (t,
|
|
76
|
-
if (
|
|
77
|
-
if (l.value = !1,
|
|
78
|
-
|
|
76
|
+
v.value = !0, d("drop", u);
|
|
77
|
+
}, ee = (t, u) => {
|
|
78
|
+
if (I.value) {
|
|
79
|
+
if (l.value = !1, n.value = u.httpStatus, !u.success) {
|
|
80
|
+
v.value = !0, d("error", u.httpStatus);
|
|
79
81
|
return;
|
|
80
82
|
}
|
|
81
|
-
|
|
83
|
+
v.value = !0;
|
|
82
84
|
}
|
|
83
|
-
let
|
|
84
|
-
e.isCreate ||
|
|
85
|
-
},
|
|
86
|
-
l.value = !0,
|
|
87
|
-
},
|
|
85
|
+
let g = e.isCreate ? "create" : "update";
|
|
86
|
+
e.isCreate || C.value.turnStoredIntoOriginal(), u.autoReloadId && (e.readData.id = u.autoReloadId, L()), e.isCreate && typeof e.onCreate == "function" && e.onCreate(), !e.isCreate && typeof e.onUpdate == "function" && e.onUpdate(), d(g, u);
|
|
87
|
+
}, T = () => {
|
|
88
|
+
l.value = !0, n.value = -1;
|
|
89
|
+
}, $ = () => {
|
|
88
90
|
l.value = !1;
|
|
89
91
|
};
|
|
90
|
-
|
|
92
|
+
U({
|
|
91
93
|
doDrop: () => {
|
|
92
94
|
k.value && typeof k.value.click == "function" && k.value.click();
|
|
93
95
|
},
|
|
@@ -96,76 +98,76 @@ const se = { class: "lkt-item-crud" }, ne = {
|
|
|
96
98
|
S.value && typeof S.value.click == "function" && S.value.click();
|
|
97
99
|
}
|
|
98
100
|
});
|
|
99
|
-
const
|
|
100
|
-
return (t,
|
|
101
|
-
const
|
|
102
|
-
return i(), m("article",
|
|
103
|
-
Y.value ? (i(), m("header",
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
item:
|
|
101
|
+
const x = o(() => !e.hiddenDrop && !l.value && c.value && f.value), J = o(() => l.value ? !1 : e.isCreate ? !0 : !e.hiddenSave && c.value && f.value), E = o(() => !l.value && !e.isCreate && f.value), te = o(() => !e.hiddenButtons && (J.value || x.value || E.value));
|
|
102
|
+
return (t, u) => {
|
|
103
|
+
const g = w("lkt-button"), ae = w("lkt-field-switch"), F = w("lkt-http-info"), le = w("lkt-loader");
|
|
104
|
+
return i(), m("article", ne, [
|
|
105
|
+
Y.value ? (i(), m("header", se, [
|
|
106
|
+
j("h1", ie, M(a.title), 1),
|
|
107
|
+
j("div", ce, [
|
|
108
|
+
O(t.$slots, "post-title", {
|
|
109
|
+
item: r.value,
|
|
108
110
|
loading: l.value
|
|
109
111
|
})
|
|
110
112
|
])
|
|
111
|
-
])) :
|
|
112
|
-
|
|
113
|
-
a.isCreate ?
|
|
113
|
+
])) : h("", !0),
|
|
114
|
+
R(j("div", fe, [
|
|
115
|
+
a.isCreate ? h("", !0) : R((i(), V(g, {
|
|
114
116
|
key: 0,
|
|
115
117
|
ref: (p) => k.value = p,
|
|
116
118
|
palette: "danger",
|
|
117
|
-
disabled: a.dropDisabled || !
|
|
119
|
+
disabled: a.dropDisabled || !b.value,
|
|
118
120
|
"confirm-modal": a.dropConfirm,
|
|
119
121
|
"confirm-data": a.dropConfirmData,
|
|
120
122
|
resource: a.dropResource,
|
|
121
123
|
"resource-data": a.dropData,
|
|
122
|
-
onLoading:
|
|
123
|
-
onLoaded:
|
|
124
|
+
onLoading: T,
|
|
125
|
+
onLoaded: $,
|
|
124
126
|
onClick: Z
|
|
125
127
|
}, {
|
|
126
|
-
default:
|
|
127
|
-
H(
|
|
128
|
+
default: A(() => [
|
|
129
|
+
H(_)["button-drop"] ? O(t.$slots, "button-drop", {
|
|
128
130
|
key: 0,
|
|
129
|
-
item:
|
|
131
|
+
item: r.value,
|
|
130
132
|
editMode: c.value,
|
|
131
133
|
isCreate: a.isCreate,
|
|
132
134
|
canUpdate: D.value,
|
|
133
|
-
canDrop:
|
|
134
|
-
}) : (i(), m("span",
|
|
135
|
+
canDrop: b.value
|
|
136
|
+
}) : (i(), m("span", ve, M(a.dropText), 1))
|
|
135
137
|
]),
|
|
136
138
|
_: 3
|
|
137
139
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"])), [
|
|
138
|
-
[q,
|
|
140
|
+
[q, x.value]
|
|
139
141
|
]),
|
|
140
|
-
|
|
142
|
+
R(P(g, {
|
|
141
143
|
ref: (p) => S.value = p,
|
|
142
144
|
palette: "success",
|
|
143
|
-
disabled:
|
|
145
|
+
disabled: !N.value,
|
|
144
146
|
"confirm-modal": K.value,
|
|
145
147
|
"confirm-data": Q.value,
|
|
146
|
-
resource:
|
|
148
|
+
resource: I.value,
|
|
147
149
|
"resource-data": W.value,
|
|
148
|
-
onLoading:
|
|
149
|
-
onLoaded:
|
|
150
|
+
onLoading: T,
|
|
151
|
+
onLoaded: $,
|
|
150
152
|
onClick: ee
|
|
151
153
|
}, {
|
|
152
|
-
default:
|
|
153
|
-
H(
|
|
154
|
+
default: A(() => [
|
|
155
|
+
H(_)["button-save"] ? O(t.$slots, "button-save", {
|
|
154
156
|
key: 0,
|
|
155
|
-
item:
|
|
157
|
+
item: r.value,
|
|
156
158
|
editMode: c.value,
|
|
157
159
|
isCreate: a.isCreate,
|
|
158
160
|
canUpdate: D.value,
|
|
159
|
-
canDrop:
|
|
160
|
-
}) : (i(), m("span", pe,
|
|
161
|
+
canDrop: b.value
|
|
162
|
+
}) : (i(), m("span", pe, M(a.saveText), 1))
|
|
161
163
|
]),
|
|
162
164
|
_: 3
|
|
163
165
|
}, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"]), [
|
|
164
166
|
[q, J.value]
|
|
165
167
|
]),
|
|
166
|
-
|
|
168
|
+
R(P(ae, {
|
|
167
169
|
modelValue: c.value,
|
|
168
|
-
"onUpdate:modelValue":
|
|
170
|
+
"onUpdate:modelValue": u[0] || (u[0] = (p) => c.value = p),
|
|
169
171
|
label: a.editModeText
|
|
170
172
|
}, null, 8, ["modelValue", "label"]), [
|
|
171
173
|
[q, E.value]
|
|
@@ -173,36 +175,36 @@ const se = { class: "lkt-item-crud" }, ne = {
|
|
|
173
175
|
], 512), [
|
|
174
176
|
[q, te.value]
|
|
175
177
|
]),
|
|
176
|
-
l.value ?
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
l.value ? h("", !0) : (i(), m("div", me, [
|
|
179
|
+
f.value ? (i(), m("div", ye, [
|
|
180
|
+
v.value ? (i(), V(F, {
|
|
179
181
|
key: 0,
|
|
180
|
-
code:
|
|
182
|
+
code: n.value,
|
|
181
183
|
quick: "",
|
|
182
|
-
palette:
|
|
184
|
+
palette: n.value === 200 ? "success" : "danger",
|
|
183
185
|
"can-close": "",
|
|
184
|
-
onClose:
|
|
185
|
-
}, null, 8, ["code", "palette"])) :
|
|
186
|
-
|
|
187
|
-
item:
|
|
186
|
+
onClose: u[1] || (u[1] = (p) => v.value = !1)
|
|
187
|
+
}, null, 8, ["code", "palette"])) : h("", !0),
|
|
188
|
+
O(t.$slots, "item", {
|
|
189
|
+
item: r.value,
|
|
188
190
|
loading: l.value,
|
|
189
191
|
editMode: c.value,
|
|
190
192
|
isCreate: a.isCreate,
|
|
191
193
|
canUpdate: D.value,
|
|
192
|
-
canDrop:
|
|
194
|
+
canDrop: b.value
|
|
193
195
|
})
|
|
194
|
-
])) : (i(),
|
|
196
|
+
])) : (i(), V(F, {
|
|
195
197
|
key: 1,
|
|
196
|
-
code:
|
|
198
|
+
code: n.value
|
|
197
199
|
}, null, 8, ["code"]))
|
|
198
200
|
])),
|
|
199
|
-
l.value ? (i(),
|
|
201
|
+
l.value ? (i(), V(le, { key: 2 })) : h("", !0)
|
|
200
202
|
]);
|
|
201
203
|
};
|
|
202
204
|
}
|
|
203
205
|
}), Be = {
|
|
204
|
-
install: (a,
|
|
205
|
-
a.component("lkt-item-crud") === void 0 && a.component("lkt-item-crud",
|
|
206
|
+
install: (a, U = {}) => {
|
|
207
|
+
a.component("lkt-item-crud") === void 0 && a.component("lkt-item-crud", he);
|
|
206
208
|
}
|
|
207
209
|
};
|
|
208
210
|
export {
|
|
@@ -85,16 +85,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
85
85
|
default: string;
|
|
86
86
|
};
|
|
87
87
|
createConfirmData: {
|
|
88
|
-
type:
|
|
89
|
-
default:
|
|
88
|
+
type: ObjectConstructor;
|
|
89
|
+
default: () => {};
|
|
90
90
|
};
|
|
91
91
|
updateConfirmData: {
|
|
92
|
-
type:
|
|
93
|
-
default:
|
|
92
|
+
type: ObjectConstructor;
|
|
93
|
+
default: () => {};
|
|
94
94
|
};
|
|
95
95
|
dropConfirmData: {
|
|
96
|
-
type:
|
|
97
|
-
default:
|
|
96
|
+
type: ObjectConstructor;
|
|
97
|
+
default: () => {};
|
|
98
98
|
};
|
|
99
99
|
createDisabled: {
|
|
100
100
|
type: BooleanConstructor;
|
|
@@ -113,6 +113,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
113
113
|
required: false;
|
|
114
114
|
default: () => boolean;
|
|
115
115
|
};
|
|
116
|
+
onCreate: {
|
|
117
|
+
type: FunctionConstructor;
|
|
118
|
+
required: false;
|
|
119
|
+
default: () => boolean;
|
|
120
|
+
};
|
|
121
|
+
onUpdate: {
|
|
122
|
+
type: FunctionConstructor;
|
|
123
|
+
required: false;
|
|
124
|
+
default: () => boolean;
|
|
125
|
+
};
|
|
116
126
|
}, {
|
|
117
127
|
doDrop: () => void;
|
|
118
128
|
doRefresh: () => Promise<void>;
|
|
@@ -213,16 +223,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
213
223
|
default: string;
|
|
214
224
|
};
|
|
215
225
|
createConfirmData: {
|
|
216
|
-
type:
|
|
217
|
-
default:
|
|
226
|
+
type: ObjectConstructor;
|
|
227
|
+
default: () => {};
|
|
218
228
|
};
|
|
219
229
|
updateConfirmData: {
|
|
220
|
-
type:
|
|
221
|
-
default:
|
|
230
|
+
type: ObjectConstructor;
|
|
231
|
+
default: () => {};
|
|
222
232
|
};
|
|
223
233
|
dropConfirmData: {
|
|
224
|
-
type:
|
|
225
|
-
default:
|
|
234
|
+
type: ObjectConstructor;
|
|
235
|
+
default: () => {};
|
|
226
236
|
};
|
|
227
237
|
createDisabled: {
|
|
228
238
|
type: BooleanConstructor;
|
|
@@ -241,6 +251,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
241
251
|
required: false;
|
|
242
252
|
default: () => boolean;
|
|
243
253
|
};
|
|
254
|
+
onCreate: {
|
|
255
|
+
type: FunctionConstructor;
|
|
256
|
+
required: false;
|
|
257
|
+
default: () => boolean;
|
|
258
|
+
};
|
|
259
|
+
onUpdate: {
|
|
260
|
+
type: FunctionConstructor;
|
|
261
|
+
required: false;
|
|
262
|
+
default: () => boolean;
|
|
263
|
+
};
|
|
244
264
|
}>> & {
|
|
245
265
|
onError?: ((...args: any[]) => any) | undefined;
|
|
246
266
|
onDrop?: ((...args: any[]) => any) | undefined;
|
|
@@ -252,6 +272,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
252
272
|
"onModified-data"?: ((...args: any[]) => any) | undefined;
|
|
253
273
|
}, {
|
|
254
274
|
title: string;
|
|
275
|
+
onUpdate: Function;
|
|
276
|
+
onCreate: Function;
|
|
255
277
|
modelValue: Record<string, any>;
|
|
256
278
|
editModeText: string;
|
|
257
279
|
saveText: string;
|
|
@@ -267,9 +289,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
267
289
|
createConfirm: string;
|
|
268
290
|
updateConfirm: string;
|
|
269
291
|
dropConfirm: string;
|
|
270
|
-
createConfirmData: string
|
|
271
|
-
updateConfirmData: string
|
|
272
|
-
dropConfirmData: string
|
|
292
|
+
createConfirmData: Record<string, any>;
|
|
293
|
+
updateConfirmData: Record<string, any>;
|
|
294
|
+
dropConfirmData: Record<string, any>;
|
|
273
295
|
createDisabled: boolean;
|
|
274
296
|
updateDisabled: boolean;
|
|
275
297
|
dropDisabled: boolean;
|
package/package.json
CHANGED
|
@@ -33,15 +33,18 @@ const props = defineProps({
|
|
|
33
33
|
updateConfirm: {type: String, default: ''},
|
|
34
34
|
dropConfirm: {type: String, default: ''},
|
|
35
35
|
|
|
36
|
-
createConfirmData: {type:
|
|
37
|
-
updateConfirmData: {type:
|
|
38
|
-
dropConfirmData: {type:
|
|
36
|
+
createConfirmData: {type: Object, default: () => ({})},
|
|
37
|
+
updateConfirmData: {type: Object, default: () => ({})},
|
|
38
|
+
dropConfirmData: {type: Object, default: () => ({})},
|
|
39
39
|
|
|
40
40
|
createDisabled: {type: Boolean, default: false},
|
|
41
41
|
updateDisabled: {type: Boolean, default: false},
|
|
42
42
|
dropDisabled: {type: Boolean, default: false},
|
|
43
43
|
|
|
44
44
|
saveValidator: {type: Function, required: false, default: () => true},
|
|
45
|
+
|
|
46
|
+
onCreate: {type: Function, required: false, default: () => true},
|
|
47
|
+
onUpdate: {type: Function, required: false, default: () => true},
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
const slots = useSlots();
|
|
@@ -186,8 +189,9 @@ const onDrop = ($event: PointerEvent, r: HTTPResponse) => {
|
|
|
186
189
|
props.readData['id'] = r.autoReloadId;
|
|
187
190
|
fetchItem();
|
|
188
191
|
}
|
|
192
|
+
if (props.isCreate && typeof props.onCreate === 'function') props.onCreate();
|
|
193
|
+
if (!props.isCreate && typeof props.onUpdate === 'function') props.onUpdate();
|
|
189
194
|
emit(emits, r)
|
|
190
|
-
|
|
191
195
|
},
|
|
192
196
|
onButtonLoading = () => {
|
|
193
197
|
isLoading.value = true;
|