lkt-item-crud 1.1.7 → 1.1.8

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,4 +1,4 @@
1
- import { defineComponent as ne, useSlots as se, ref as s, computed as d, watch as b, resolveComponent as w, openBlock as c, createElementBlock as h, createElementVNode as j, toDisplayString as N, renderSlot as O, createCommentVNode as D, withDirectives as V, createBlock as q, withCtx as G, unref as K, vShow as I, createVNode as Q } from "vue";
1
+ import { defineComponent as ne, useSlots as se, ref as s, computed as d, watch as D, resolveComponent as w, openBlock as c, createElementBlock as h, createElementVNode as j, toDisplayString as N, renderSlot as O, createCommentVNode as g, withDirectives as V, createBlock as q, withCtx as G, unref as K, vShow as I, createVNode as Q } from "vue";
2
2
  import { httpCall as ie } from "lkt-http-client";
3
3
  import { DataState as ce } from "lkt-data-state";
4
4
  const T = class T {
@@ -55,7 +55,7 @@ const p = (...u) => {
55
55
  setup(u, { expose: $, emit: W }) {
56
56
  const e = u, M = se(), n = W;
57
57
  let X = [];
58
- const o = s(!0), r = s(e.modelValue), S = s(X), v = s(!1), f = s(!1), m = s(!1), i = s(200), g = s(null), C = s(null), k = s(new ce(r.value)), a = s(e.isCreate), Y = d(() => a.value ? e.createConfirm : e.updateConfirm), Z = d(() => a.value ? e.createConfirmData : e.updateConfirmData), x = d(() => a.value ? e.createResource : e.updateResource), ee = d(() => a.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), te = d(() => a.value ? e.createDisabled : e.updateDisabled), B = d(() => !a.value && S.value.includes("update")), _ = d(() => !a.value && S.value.includes("drop")), U = async () => {
58
+ const o = s(!0), r = s(e.modelValue), S = s(X), v = s(!1), f = s(!1), m = s(!1), i = s(200), C = s(null), B = s(null), k = s(new ce(r.value)), a = s(e.isCreate), Y = d(() => a.value ? e.createConfirm : e.updateConfirm), Z = d(() => a.value ? e.createConfirmData : e.updateConfirmData), x = d(() => a.value ? e.createResource : e.updateResource), ee = d(() => a.value ? { ...e.createData, ...JSON.parse(JSON.stringify(r.value)) } : { ...e.updateData, ...JSON.parse(JSON.stringify(r.value)) }), te = d(() => a.value ? e.createDisabled : e.updateDisabled), _ = d(() => !a.value && S.value.includes("update")), R = d(() => !a.value && S.value.includes("drop")), U = async () => {
59
59
  p("fetchItem"), o.value = !0, i.value = -1, m.value = !1;
60
60
  try {
61
61
  const t = await ie(e.readResource, e.readData);
@@ -69,13 +69,13 @@ const p = (...u) => {
69
69
  return;
70
70
  }
71
71
  }, ae = d(() => o.value ? !1 : e.title || !!M["post-title"]);
72
- b(() => e.modelValue, (t) => {
72
+ D(() => e.modelValue, (t) => {
73
73
  r.value = t, k.value.increment(t);
74
- }, { deep: !0 }), b(r, (t) => {
74
+ }, { deep: !0 }), D(r, (t) => {
75
75
  n("update:modelValue", r.value), k.value.increment(t);
76
- }, { deep: !0 }), b(S, () => n("perms", S.value));
77
- const E = d(() => te.value || !a.value && !B.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : k.value.changed());
78
- b(E, (t) => n("modified-data", t)), b(a, (t) => n("update:isCreate", t)), e.readResource && !a.value ? U() : a.value && (f.value = !0, v.value = !0, o.value = !1);
76
+ }, { deep: !0 }), D(S, () => n("perms", S.value));
77
+ const E = d(() => te.value || !a.value && !_.value || typeof e.saveValidator == "function" && !e.saveValidator(r.value) ? !1 : k.value.changed());
78
+ D(E, (t) => n("modified-data", t)), D(a, (t) => n("update:isCreate", t)), e.readResource && !a.value ? U() : a.value && (f.value = !0, v.value = !0, o.value = !1);
79
79
  const le = (t, l) => {
80
80
  if (o.value = !1, i.value = l.httpStatus, !l.success) {
81
81
  m.value = !0, n("error", l.httpStatus);
@@ -90,8 +90,8 @@ const p = (...u) => {
90
90
  }
91
91
  m.value = !0;
92
92
  }
93
- let R = a.value ? "create" : "update";
94
- a.value || (p("onSave -> turn stored data into original"), k.value.turnStoredIntoOriginal()), l.autoReloadId && (p("onSave -> autoReloadId detected: ", l.autoReloadId), e.readData.id = l.autoReloadId, p("onSave -> turning off create mode"), a.value = !1, U()), a.value ? typeof e.onCreate == "function" && (p("onSave -> trigger onCreate callback"), e.onCreate()) : typeof e.onUpdate == "function" && (p("onSave -> trigger onUpdate callback"), e.onUpdate()), n(R, l);
93
+ let b = a.value ? "create" : "update";
94
+ a.value || (p("onSave -> turn stored data into original"), k.value.turnStoredIntoOriginal()), l.autoReloadId && (p("onSave -> autoReloadId detected: ", l.autoReloadId), e.readData.id = l.autoReloadId, p("onSave -> turning off create mode"), a.value = !1, U()), b === "create" ? typeof e.onCreate == "function" && (p("onSave -> trigger onCreate callback"), e.onCreate()) : typeof e.onUpdate == "function" && (p("onSave -> trigger onUpdate callback"), e.onUpdate()), n(b, l);
95
95
  }, J = () => {
96
96
  o.value = !0, i.value = -1;
97
97
  }, F = () => {
@@ -99,16 +99,16 @@ const p = (...u) => {
99
99
  };
100
100
  $({
101
101
  doDrop: () => {
102
- C.value && typeof C.value.click == "function" && C.value.click();
102
+ B.value && typeof B.value.click == "function" && B.value.click();
103
103
  },
104
104
  doRefresh: U,
105
105
  doSave: () => {
106
- g.value && typeof g.value.click == "function" && g.value.click();
106
+ C.value && typeof C.value.click == "function" && C.value.click();
107
107
  }
108
108
  });
109
109
  const H = d(() => !e.hiddenDrop && !o.value && v.value && f.value), A = d(() => o.value ? !1 : a.value ? !0 : !e.hiddenSave && v.value && f.value), P = d(() => !o.value && !a.value && f.value), oe = d(() => !e.hiddenButtons && (A.value || H.value || P.value));
110
110
  return (t, l) => {
111
- const R = w("lkt-button"), re = w("lkt-field-switch"), z = w("lkt-http-info"), de = w("lkt-loader");
111
+ const b = w("lkt-button"), re = w("lkt-field-switch"), z = w("lkt-http-info"), de = w("lkt-loader");
112
112
  return c(), h("article", ve, [
113
113
  ae.value ? (c(), h("header", fe, [
114
114
  j("h1", pe, N(u.title), 1),
@@ -118,13 +118,13 @@ const p = (...u) => {
118
118
  loading: o.value
119
119
  })
120
120
  ])
121
- ])) : D("", !0),
121
+ ])) : g("", !0),
122
122
  V(j("div", ye, [
123
- a.value ? D("", !0) : V((c(), q(R, {
123
+ a.value ? g("", !0) : V((c(), q(b, {
124
124
  key: 0,
125
- ref: (y) => C.value = y,
125
+ ref: (y) => B.value = y,
126
126
  palette: "danger",
127
- disabled: u.dropDisabled || !_.value,
127
+ disabled: u.dropDisabled || !R.value,
128
128
  "confirm-modal": u.dropConfirm,
129
129
  "confirm-data": u.dropConfirmData,
130
130
  resource: u.dropResource,
@@ -139,16 +139,16 @@ const p = (...u) => {
139
139
  item: r.value,
140
140
  editMode: v.value,
141
141
  isCreate: a.value,
142
- canUpdate: B.value,
143
- canDrop: _.value
142
+ canUpdate: _.value,
143
+ canDrop: R.value
144
144
  }) : (c(), h("span", he, N(u.dropText), 1))
145
145
  ]),
146
146
  _: 3
147
147
  }, 8, ["disabled", "confirm-modal", "confirm-data", "resource", "resource-data"])), [
148
148
  [I, H.value]
149
149
  ]),
150
- V(Q(R, {
151
- ref: (y) => g.value = y,
150
+ V(Q(b, {
151
+ ref: (y) => C.value = y,
152
152
  palette: "success",
153
153
  disabled: !E.value,
154
154
  "confirm-modal": Y.value,
@@ -165,8 +165,8 @@ const p = (...u) => {
165
165
  item: r.value,
166
166
  editMode: v.value,
167
167
  isCreate: a.value,
168
- canUpdate: B.value,
169
- canDrop: _.value
168
+ canUpdate: _.value,
169
+ canDrop: R.value
170
170
  }) : (c(), h("span", Se, N(u.saveText), 1))
171
171
  ]),
172
172
  _: 3
@@ -183,7 +183,7 @@ const p = (...u) => {
183
183
  ], 512), [
184
184
  [I, oe.value]
185
185
  ]),
186
- o.value ? D("", !0) : (c(), h("div", ke, [
186
+ o.value ? g("", !0) : (c(), h("div", ke, [
187
187
  f.value ? (c(), h("div", be, [
188
188
  m.value ? (c(), q(z, {
189
189
  key: 0,
@@ -192,21 +192,21 @@ const p = (...u) => {
192
192
  palette: i.value === 200 ? "success" : "danger",
193
193
  "can-close": "",
194
194
  onClose: l[1] || (l[1] = (y) => m.value = !1)
195
- }, null, 8, ["code", "palette"])) : D("", !0),
195
+ }, null, 8, ["code", "palette"])) : g("", !0),
196
196
  O(t.$slots, "item", {
197
197
  item: r.value,
198
198
  loading: o.value,
199
199
  editMode: v.value,
200
200
  isCreate: a.value,
201
- canUpdate: B.value,
202
- canDrop: _.value
201
+ canUpdate: _.value,
202
+ canDrop: R.value
203
203
  })
204
204
  ])) : (c(), q(z, {
205
205
  key: 1,
206
206
  code: i.value
207
207
  }, null, 8, ["code"]))
208
208
  ])),
209
- o.value ? (c(), q(de, { key: 2 })) : D("", !0)
209
+ o.value ? (c(), q(de, { key: 2 })) : g("", !0)
210
210
  ]);
211
211
  };
212
212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-item-crud",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -199,7 +199,7 @@ const onDrop = ($event: PointerEvent, r: HTTPResponse) => {
199
199
  createMode.value = false;
200
200
  fetchItem();
201
201
  }
202
- if (createMode.value) {
202
+ if (emits === 'create') {
203
203
  if (typeof props.onCreate === 'function') {
204
204
  debug('onSave -> trigger onCreate callback');
205
205
  props.onCreate();