vlite3 0.9.3 → 0.9.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.
@@ -1,32 +1,33 @@
1
- import { defineComponent as H, computed as c, shallowRef as q, watch as G, openBlock as o, createElementBlock as n, createElementVNode as g, createBlock as J, withCtx as B, createTextVNode as K, toDisplayString as m, createCommentVNode as i, createVNode as b, Fragment as y, renderList as p, normalizeClass as x, unref as O, isMemoSame as P } from "vue";
2
- import { VueDraggable as Q } from "vue-draggable-plus";
3
- import W from "./FormField.vue.js";
4
- import F from "../Button.vue.js";
5
- import X from "../Label.vue.js";
6
- import Y from "../Icon.vue.js";
1
+ import { defineComponent as Q, computed as c, shallowRef as W, watch as X, openBlock as s, createElementBlock as n, createElementVNode as v, createBlock as B, withCtx as D, createTextVNode as Y, toDisplayString as m, createCommentVNode as u, createVNode as g, Fragment as w, renderList as x, normalizeClass as R, unref as Z, isMemoSame as I } from "vue";
2
+ import { VueDraggable as ee } from "vue-draggable-plus";
3
+ import te from "./FormField.vue.js";
4
+ import $ from "../Button.vue.js";
5
+ import ae from "../Label.vue.js";
6
+ import le from "../Icon.vue.js";
7
7
  import { $t as h } from "../../utils/i18n.js";
8
- const Z = { class: "custom-fields-wrapper" }, ee = { class: "flex justify-between items-center mb-2" }, te = { class: "custom-fields-table border border-border rounded overflow-hidden bg-background" }, ae = {
8
+ import { evaluateConditional as k } from "./utils/form.utils.js";
9
+ const re = { class: "custom-fields-wrapper" }, se = { class: "flex justify-between items-center mb-2" }, oe = { class: "custom-fields-table border border-border rounded overflow-hidden bg-background" }, ne = {
9
10
  key: 0,
10
11
  class: "flex border-b border-border bg-muted/50 text-gray-800 text-xs font-semibold uppercase tracking-wider"
11
- }, le = {
12
+ }, de = {
12
13
  key: 0,
13
14
  class: "w-10 flex-none p-3 border-r border-border"
14
- }, re = {
15
+ }, ie = {
15
16
  key: 1,
16
17
  class: "w-10 flex-none p-3 text-center border-r border-border"
17
- }, se = {
18
+ }, ue = {
18
19
  key: 2,
19
20
  class: "w-10 flex-none p-3"
20
- }, oe = {
21
+ }, ce = {
21
22
  key: 1,
22
23
  class: "w-10 flex-none flex items-center justify-center text-xs text-muted-foreground border-r border-border bg-muted/20"
23
- }, ne = {
24
+ }, me = {
24
25
  key: 2,
25
26
  class: "w-10 flex-none flex items-center justify-center border-l border-border bg-muted/20"
26
- }, de = {
27
+ }, be = {
27
28
  key: 1,
28
29
  class: "flex flex-col items-center justify-center py-6 text-center bg-muted/5"
29
- }, ie = { class: "text-sm font-medium text-foreground" }, ue = { class: "text-xs text-muted-foreground mt-1" }, ye = /* @__PURE__ */ H({
30
+ }, fe = { class: "text-sm font-medium text-foreground" }, ve = { class: "text-xs text-muted-foreground mt-1" }, Ce = /* @__PURE__ */ Q({
30
31
  __name: "CustomFields",
31
32
  props: {
32
33
  modelValue: { default: () => [] },
@@ -48,160 +49,165 @@ const Z = { class: "custom-fields-wrapper" }, ee = { class: "flex justify-betwee
48
49
  isUpdate: { type: Boolean, default: !1 }
49
50
  },
50
51
  emits: ["update:modelValue", "change"],
51
- setup(r, { emit: $ }) {
52
- const t = r, R = $, k = c(() => t.labelI18n ? h(t.labelI18n) : t.label), D = c(() => {
52
+ setup(o, { emit: j }) {
53
+ const a = o, _ = j, C = c(() => a.labelI18n ? h(a.labelI18n) : a.label), z = c(() => {
53
54
  const e = h("vlite.customFields.emptyTitle");
54
55
  return e !== "vlite.customFields.emptyTitle" ? e : "No items added";
55
- }), U = c(() => {
56
+ }), A = c(() => {
56
57
  const e = h("vlite.customFields.emptyDescription");
57
58
  return e !== "vlite.customFields.emptyDescription" ? e : "Add a new item to get started";
58
- }), l = q([]), _ = () => `row_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
59
- G(
60
- () => t.modelValue,
59
+ }), r = W([]), V = () => `row_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
60
+ X(
61
+ () => a.modelValue,
61
62
  (e) => {
62
- Array.isArray(e) ? l.value = e.map((a, d) => {
63
- const s = l.value[d];
63
+ Array.isArray(e) ? r.value = e.map((t, d) => {
64
+ const l = r.value[d];
64
65
  return {
65
- ...a,
66
- _id: s?._id || _()
66
+ ...t,
67
+ _id: l?._id || V()
67
68
  };
68
- }) : l.value = [];
69
+ }) : r.value = [];
69
70
  },
70
71
  { immediate: !0, deep: !0 }
71
72
  );
72
- const j = () => {
73
+ const E = () => {
73
74
  const e = {};
74
- for (const a of t.schema) {
75
- const d = typeof a.value == "function" ? a.value() : a.value;
76
- e[a.name] = d ?? null;
75
+ for (const t of a.schema) {
76
+ const d = typeof t.value == "function" ? t.value() : t.value;
77
+ e[t.name] = d ?? null;
77
78
  }
78
- return { ...e, _id: _() };
79
- }, z = () => {
80
- if (t.disabled || t.maxRows && l.value.length >= t.maxRows) return;
81
- const e = [...l.value, j()];
82
- l.value = e, f(e);
83
- }, A = (e) => {
84
- if (t.disabled || l.value.length <= t.minRows) return;
85
- const a = [...l.value];
86
- a.splice(e, 1), l.value = a, f(a);
87
- }, E = (e, a, d) => {
88
- const s = [...l.value];
89
- s[e] = {
90
- ...s[e],
91
- [a]: d.value
92
- }, l.value = s, f(s);
93
- }, T = (e) => {
94
- l.value = e, f(e);
95
- }, f = (e) => {
96
- const a = e.map(({ _id: d, ...s }) => s);
97
- R("update:modelValue", a), R("change", a);
98
- }, S = (e, a) => l.value[e]?.[a], I = c(() => !(t.disabled || t.maxRows && l.value.length >= t.maxRows)), w = c(() => t.disabled ? !1 : l.value.length > t.minRows), C = c(() => t.headers && t.headers.length > 0 ? t.headers : t.schema.map((e) => e.labelI18n ? h(e.labelI18n) : e.label || e.name));
99
- return (e, a) => (o(), n("div", Z, [
100
- g("div", ee, [
101
- k.value ? (o(), J(X, {
79
+ return { ...e, _id: V() };
80
+ }, T = () => {
81
+ if (a.disabled || a.maxRows && r.value.length >= a.maxRows) return;
82
+ const e = [...r.value, E()];
83
+ r.value = e, b(e);
84
+ }, S = (e) => {
85
+ if (a.disabled || r.value.length <= a.minRows) return;
86
+ const t = [...r.value];
87
+ t.splice(e, 1), r.value = t, b(t);
88
+ }, L = (e, t, d) => {
89
+ const l = [...r.value];
90
+ l[e] = {
91
+ ...l[e],
92
+ [t]: d.value
93
+ }, r.value = l, b(l);
94
+ }, M = (e) => {
95
+ r.value = e, b(e);
96
+ }, b = (e) => {
97
+ const t = e.map(({ _id: d, ...l }) => l);
98
+ _("update:modelValue", t), _("change", t);
99
+ }, H = (e, t) => r.value[e]?.[t], q = c(() => !(a.disabled || a.maxRows && r.value.length >= a.maxRows)), y = c(() => a.disabled ? !1 : r.value.length > a.minRows), F = c(() => a.headers && a.headers.length > 0 ? a.headers : a.schema.map((e) => e.labelI18n ? h(e.labelI18n) : e.label || e.name)), p = (e) => ({
100
+ values: { ...a.values || {}, ...r.value[e] || {} },
101
+ isUpdate: a.isUpdate
102
+ }), G = (e, t) => a.disabled ? !0 : k(t.disabled, p(e)), J = (e, t) => k(t.readonly, p(e)), K = (e, t) => t.when ? k(t.when, p(e)) : !0;
103
+ return (e, t) => (s(), n("div", re, [
104
+ v("div", se, [
105
+ C.value ? (s(), B(ae, {
102
106
  key: 0,
103
107
  class: "text-sm font-medium text-foreground"
104
108
  }, {
105
- default: B(() => [
106
- K(m(k.value), 1)
109
+ default: D(() => [
110
+ Y(m(C.value), 1)
107
111
  ]),
108
112
  _: 1
109
- })) : i("", !0),
110
- b(F, {
113
+ })) : u("", !0),
114
+ g($, {
111
115
  type: "button",
112
116
  variant: "outline",
113
117
  size: "xs",
114
118
  rounded: "full",
115
119
  icon: "lucide:plus",
116
- disabled: !I.value,
117
- onClick: z
120
+ disabled: !q.value,
121
+ onClick: T
118
122
  }, null, 8, ["disabled"])
119
123
  ]),
120
- g("div", te, [
121
- C.value.length > 0 ? (o(), n("div", ae, [
122
- r.draggable ? (o(), n("div", le)) : i("", !0),
123
- r.showRowNumbers ? (o(), n("div", re, " # ")) : i("", !0),
124
- (o(!0), n(y, null, p(C.value, (d, s) => (o(), n("div", {
125
- key: s,
126
- class: x(["flex-1 p-3 min-w-0 truncate", { "border-l border-border": s > 0 }])
124
+ v("div", oe, [
125
+ F.value.length > 0 ? (s(), n("div", ne, [
126
+ o.draggable ? (s(), n("div", de)) : u("", !0),
127
+ o.showRowNumbers ? (s(), n("div", ie, " # ")) : u("", !0),
128
+ (s(!0), n(w, null, x(F.value, (d, l) => (s(), n("div", {
129
+ key: l,
130
+ class: R(["flex-1 p-3 min-w-0 truncate", { "border-l border-border": l > 0 }])
127
131
  }, m(d), 3))), 128)),
128
- w.value ? (o(), n("div", se)) : i("", !0)
129
- ])) : i("", !0),
130
- b(O(Q), {
131
- "model-value": l.value,
132
- "onUpdate:modelValue": T,
133
- disabled: !r.draggable || r.disabled,
132
+ y.value ? (s(), n("div", ue)) : u("", !0)
133
+ ])) : u("", !0),
134
+ g(Z(ee), {
135
+ "model-value": r.value,
136
+ "onUpdate:modelValue": M,
137
+ disabled: !o.draggable || o.disabled,
134
138
  animation: 150,
135
139
  handle: ".drag-handle",
136
140
  "ghost-class": "opacity-50",
137
141
  class: "divide-y divide-border"
138
142
  }, {
139
- default: B(() => [
140
- (o(!0), n(y, null, p(l.value, (d, s, ce, v) => {
141
- const V = [d, r.disabled, r.isUpdate, r.showRowNumbers, w.value, r.draggable, s];
142
- if (v && v.key === d._id && P(v, V)) return v;
143
- const N = (o(), n("div", {
143
+ default: D(() => [
144
+ (s(!0), n(w, null, x(r.value, (d, l, ge, f) => {
145
+ const N = [d, o.disabled, o.isUpdate, o.showRowNumbers, y.value, o.draggable, l];
146
+ if (f && f.key === d._id && I(f, N)) return f;
147
+ const U = (s(), n("div", {
144
148
  key: d._id,
145
149
  class: "flex group bg-white transition-colors"
146
150
  }, [
147
- r.draggable ? (o(), n("div", {
151
+ o.draggable ? (s(), n("div", {
148
152
  key: 0,
149
- class: x(["w-10 flex-none flex items-center justify-center border-r border-border bg-muted/5 drag-handle transition-colors", r.disabled ? "cursor-not-allowed opacity-50" : "cursor-grab active:cursor-grabbing hover:bg-muted/10 text-muted-foreground hover:text-foreground"])
153
+ class: R(["w-10 flex-none flex items-center justify-center border-r border-border bg-muted/5 drag-handle transition-colors", o.disabled ? "cursor-not-allowed opacity-50" : "cursor-grab active:cursor-grabbing hover:bg-muted/10 text-muted-foreground hover:text-foreground"])
150
154
  }, [
151
- b(Y, {
155
+ g(le, {
152
156
  icon: "lucide:grip-vertical",
153
157
  class: "w-4 h-4"
154
158
  })
155
- ], 2)) : i("", !0),
156
- r.showRowNumbers ? (o(), n("div", oe, m(s + 1), 1)) : i("", !0),
157
- (o(!0), n(y, null, p(r.schema, (u, L) => (o(), n("div", {
158
- key: u.name,
159
- class: x(["flex-1 min-w-0 relative", { "border-l border-border": L > 0 }])
159
+ ], 2)) : u("", !0),
160
+ o.showRowNumbers ? (s(), n("div", ce, m(l + 1), 1)) : u("", !0),
161
+ (s(!0), n(w, null, x(o.schema, (i, O) => (s(), n("div", {
162
+ key: i.name,
163
+ class: R(["flex-1 min-w-0 relative", { "border-l border-border": O > 0 }])
160
164
  }, [
161
- b(W, {
165
+ K(l, i) ? (s(), B(te, {
166
+ key: 0,
162
167
  field: {
163
- ...u,
168
+ ...i,
164
169
  props: {
165
- ...u.type === "multiSelect" ? { showControls: !1, wrap: !1 } : {},
166
- ...u.props || {}
170
+ ...i.type === "multiSelect" ? { showControls: !1, wrap: !1 } : {},
171
+ ...i.props || {}
167
172
  },
168
173
  label: void 0
169
174
  },
170
- value: S(s, u.name),
171
- values: r.values || {},
175
+ value: H(l, i.name),
176
+ values: o.values || {},
172
177
  variant: "transparent",
173
178
  size: "sm",
174
179
  rounded: "none",
175
- disabled: r.disabled,
176
- isUpdate: r.isUpdate,
180
+ disabled: G(l, i),
181
+ readonly: J(l, i),
182
+ isUpdate: o.isUpdate,
177
183
  class: "w-full h-full min-h-[40px]",
178
- onChange: (M) => E(s, u.name, M)
179
- }, null, 8, ["field", "value", "values", "disabled", "isUpdate", "onChange"])
184
+ onChange: (P) => L(l, i.name, P)
185
+ }, null, 8, ["field", "value", "values", "disabled", "readonly", "isUpdate", "onChange"])) : u("", !0)
180
186
  ], 2))), 128)),
181
- w.value ? (o(), n("div", ne, [
182
- b(F, {
187
+ y.value ? (s(), n("div", me, [
188
+ g($, {
183
189
  type: "button",
184
190
  variant: "ghost",
185
191
  size: "xs",
186
192
  icon: "lucide:trash-2",
187
- disabled: r.disabled,
188
- onClick: (u) => A(s)
193
+ disabled: o.disabled,
194
+ onClick: (i) => S(l)
189
195
  }, null, 8, ["disabled", "onClick"])
190
- ])) : i("", !0)
196
+ ])) : u("", !0)
191
197
  ]));
192
- return N.memo = V, N;
193
- }, a, 0), 128))
198
+ return U.memo = N, U;
199
+ }, t, 0), 128))
194
200
  ]),
195
201
  _: 1
196
202
  }, 8, ["model-value", "disabled"]),
197
- l.value.length === 0 ? (o(), n("div", de, [
198
- g("p", ie, m(D.value), 1),
199
- g("p", ue, m(U.value), 1)
200
- ])) : i("", !0)
203
+ r.value.length === 0 ? (s(), n("div", be, [
204
+ v("p", fe, m(z.value), 1),
205
+ v("p", ve, m(A.value), 1)
206
+ ])) : u("", !0)
201
207
  ])
202
208
  ]));
203
209
  }
204
210
  });
205
211
  export {
206
- ye as default
212
+ Ce as default
207
213
  };