@oneflowui/ui 0.8.4 → 0.8.5

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.
Files changed (33) hide show
  1. package/README.en.md +219 -0
  2. package/README.md +219 -0
  3. package/dist/components/ai/AiMessageList.vue.js +1 -1
  4. package/dist/components/ai/AiMessageList.vue2.js +28 -27
  5. package/dist/components/common/ThemeScope.vue.d.ts +24 -0
  6. package/dist/components/common/ThemeScope.vue.js +24 -0
  7. package/dist/components/common/ThemeScope.vue2.js +4 -0
  8. package/dist/components/common/index.d.ts +1 -0
  9. package/dist/components/database/DatabaseView.vue.d.ts +4 -4
  10. package/dist/components/database/DatabaseView.vue.js +4 -4
  11. package/dist/components/database/DatabaseView.vue2.js +135 -134
  12. package/dist/components/database/index.d.ts +1 -1
  13. package/dist/components/kanban/KanbanColumn.vue.js +3 -3
  14. package/dist/components/kanban/KanbanColumn.vue2.js +31 -30
  15. package/dist/components/table/DataTable.vue.js +2 -2
  16. package/dist/components/table/DataTable.vue2.js +251 -249
  17. package/dist/composables/index.d.ts +5 -3
  18. package/dist/composables/useDataTableLayout.d.ts +1 -0
  19. package/dist/composables/useDataTableLayout.js +29 -26
  20. package/dist/composables/useDatabaseView.d.ts +1 -1
  21. package/dist/composables/useDatabaseView.js +311 -284
  22. package/dist/composables/useDatabaseViewMiddleware.d.ts +33 -0
  23. package/dist/composables/useDatabaseViewMiddleware.js +131 -0
  24. package/dist/composables/useVirtualList.d.ts +11 -0
  25. package/dist/composables/useVirtualList.js +146 -104
  26. package/dist/composables.js +71 -0
  27. package/dist/contracts/database.d.ts +23 -0
  28. package/dist/index.d.ts +6 -3
  29. package/dist/index.js +259 -250
  30. package/dist/style.css +1 -1
  31. package/dist/theme.d.ts +1 -0
  32. package/dist/theme.js +4 -0
  33. package/package.json +16 -2
@@ -1,56 +1,56 @@
1
- import { computed as s, ref as I, shallowRef as De, watch as N } from "vue";
2
- function Le(l) {
3
- return !!(l && typeof l == "object" && "value" in l);
1
+ import { computed as f, ref as I, shallowRef as Be, watch as W } from "vue";
2
+ function ke(t) {
3
+ return !!(t && typeof t == "object" && "value" in t);
4
4
  }
5
- function G(l) {
6
- if (l !== void 0)
7
- return Le(l) ? l.value : l;
5
+ function G(t) {
6
+ if (t !== void 0)
7
+ return ke(t) ? t.value : t;
8
8
  }
9
- function _e(l) {
10
- if (l)
11
- return { ...l };
9
+ function Pe(t) {
10
+ if (t)
11
+ return { ...t };
12
12
  }
13
- function z(l) {
14
- var r, v, a, S;
13
+ function z(t) {
14
+ var i, v, a, h;
15
15
  return {
16
- ...l,
17
- visibleFields: [...l.visibleFields],
18
- sorts: (r = l.sorts) == null ? void 0 : r.map(_e).filter((w) => w !== void 0),
19
- groups: (v = l.groups) == null ? void 0 : v.map((w) => ({ ...w })),
20
- filters: (a = l.filters) == null ? void 0 : a.map((w) => ({ ...w })),
21
- aggregations: (S = l.aggregations) == null ? void 0 : S.map((w) => ({ ...w })),
22
- fixedColumns: l.fixedColumns ? [...l.fixedColumns] : void 0,
23
- galleryCardFields: l.galleryCardFields ? [...l.galleryCardFields] : void 0
16
+ ...t,
17
+ visibleFields: [...t.visibleFields],
18
+ sorts: (i = t.sorts) == null ? void 0 : i.map(Pe).filter((w) => w !== void 0),
19
+ groups: (v = t.groups) == null ? void 0 : v.map((w) => ({ ...w })),
20
+ filters: (a = t.filters) == null ? void 0 : a.map((w) => ({ ...w })),
21
+ aggregations: (h = t.aggregations) == null ? void 0 : h.map((w) => ({ ...w })),
22
+ fixedColumns: t.fixedColumns ? [...t.fixedColumns] : void 0,
23
+ galleryCardFields: t.galleryCardFields ? [...t.galleryCardFields] : void 0
24
24
  };
25
25
  }
26
- function ue(l) {
27
- return l ? {
28
- ...l,
29
- fields: l.fields.map((r) => ({ ...r })),
30
- views: (l.views ?? []).map(z)
26
+ function de(t) {
27
+ return t ? {
28
+ ...t,
29
+ fields: t.fields.map((i) => ({ ...i })),
30
+ views: (t.views ?? []).map(z)
31
31
  } : null;
32
32
  }
33
- function H(l) {
34
- return l ? l.map((r) => ({
35
- ...r,
36
- fields: { ...r.fields }
33
+ function H(t) {
34
+ return t ? t.map((i) => ({
35
+ ...i,
36
+ fields: { ...i.fields }
37
37
  })) : [];
38
38
  }
39
- function J(l) {
40
- if (!l) return [];
41
- const r = /* @__PURE__ */ new Set(), v = [];
42
- for (const a of l)
43
- !(a != null && a.viewId) || r.has(a.viewId) || (r.add(a.viewId), v.push(z(a)));
39
+ function J(t) {
40
+ if (!t) return [];
41
+ const i = /* @__PURE__ */ new Set(), v = [];
42
+ for (const a of t)
43
+ !(a != null && a.viewId) || i.has(a.viewId) || (i.add(a.viewId), v.push(z(a)));
44
44
  return v;
45
45
  }
46
- function K(l, r, v = (r == null ? void 0 : r.viewId) ?? "__default__") {
46
+ function K(t, i, v = (i == null ? void 0 : i.viewId) ?? "__default__") {
47
47
  var w;
48
- const a = r ? z(r) : void 0, S = (w = a == null ? void 0 : a.visibleFields) != null && w.length ? [...a.visibleFields] : (l == null ? void 0 : l.fields.map((p) => p.id)) ?? [];
48
+ const a = i ? z(i) : void 0, h = (w = a == null ? void 0 : a.visibleFields) != null && w.length ? [...a.visibleFields] : (t == null ? void 0 : t.fields.map((x) => x.id)) ?? [];
49
49
  return {
50
50
  viewId: v,
51
51
  viewType: (a == null ? void 0 : a.viewType) ?? "table",
52
- name: (a == null ? void 0 : a.name) ?? (l == null ? void 0 : l.name) ?? "全部记录",
53
- visibleFields: S,
52
+ name: (a == null ? void 0 : a.name) ?? (t == null ? void 0 : t.name) ?? "全部记录",
53
+ visibleFields: h,
54
54
  sorts: a == null ? void 0 : a.sorts,
55
55
  groups: a == null ? void 0 : a.groups,
56
56
  filters: a == null ? void 0 : a.filters,
@@ -59,330 +59,357 @@ function K(l, r, v = (r == null ? void 0 : r.viewId) ?? "__default__") {
59
59
  galleryCardFields: a == null ? void 0 : a.galleryCardFields
60
60
  };
61
61
  }
62
- function Ee(l, r, v, a) {
63
- const S = l.filter((n) => !a.has(n.viewId)), w = /* @__PURE__ */ new Map();
64
- for (const n of S)
65
- w.set(n.viewId, n);
66
- const p = /* @__PURE__ */ new Map();
67
- for (const n of r)
68
- a.has(n.viewId) || p.set(n.viewId, n);
69
- const V = /* @__PURE__ */ new Map();
70
- for (const n of v)
71
- a.has(n.viewId) || V.set(n.viewId, n);
72
- const y = [], d = /* @__PURE__ */ new Set();
73
- for (const n of S) {
74
- const D = V.get(n.viewId) ?? p.get(n.viewId) ?? n;
75
- y.push(D), d.add(D.viewId);
76
- }
77
- for (const n of r)
78
- a.has(n.viewId) || d.has(n.viewId) || (y.push(n), d.add(n.viewId));
79
- for (const n of v)
80
- a.has(n.viewId) || d.has(n.viewId) || (y.push(n), d.add(n.viewId));
81
- return y;
62
+ function qe(t, i, v, a) {
63
+ const h = t.filter((r) => !a.has(r.viewId)), w = /* @__PURE__ */ new Map();
64
+ for (const r of h)
65
+ w.set(r.viewId, r);
66
+ const x = /* @__PURE__ */ new Map();
67
+ for (const r of i)
68
+ a.has(r.viewId) || x.set(r.viewId, r);
69
+ const y = /* @__PURE__ */ new Map();
70
+ for (const r of v)
71
+ a.has(r.viewId) || y.set(r.viewId, r);
72
+ const S = [], d = /* @__PURE__ */ new Set();
73
+ for (const r of h) {
74
+ const A = y.get(r.viewId) ?? x.get(r.viewId) ?? r;
75
+ S.push(A), d.add(A.viewId);
76
+ }
77
+ for (const r of i)
78
+ a.has(r.viewId) || d.has(r.viewId) || (S.push(r), d.add(r.viewId));
79
+ for (const r of v)
80
+ a.has(r.viewId) || d.has(r.viewId) || (S.push(r), d.add(r.viewId));
81
+ return S;
82
82
  }
83
- function Be(l) {
83
+ function Oe(t) {
84
84
  var v;
85
- const r = (v = l == null ? void 0 : l.sorts) == null ? void 0 : v[0];
86
- return r ? {
87
- field: r.fieldId,
88
- order: r.direction
85
+ const i = (v = t == null ? void 0 : t.sorts) == null ? void 0 : v[0];
86
+ return i ? {
87
+ field: i.fieldId,
88
+ order: i.direction
89
89
  } : { field: null, order: null };
90
90
  }
91
- function Q(l, r) {
92
- return l.some((v) => v.viewId === r);
91
+ function Q(t, i) {
92
+ return t.some((v) => v.viewId === i);
93
93
  }
94
- function Ae(l) {
95
- var ie;
96
- const r = s(() => {
97
- var e, t;
98
- return l.mode ? l.mode : (e = l.provider) != null && e.mode ? l.provider.mode : (t = l.provider) != null && t.onFetch ? "provider" : "local";
99
- }), v = s(() => ue(G(l.schema) ?? null)), a = s(() => H(G(l.records))), S = s(() => J(G(l.views))), w = I(null), p = I([]), V = I([]), y = I(/* @__PURE__ */ new Set()), d = De(a.value), n = I(!1), D = I(null), E = I(d.value.length), L = I(1), k = I(l.pageSize ?? 20), f = I(
100
- l.initialSelectedRecordId !== void 0 ? l.initialSelectedRecordId : ((ie = d.value[0]) == null ? void 0 : ie.id) ?? null
101
- ), m = I(l.initialViewId ?? ""), $ = I(!1), B = I(0), F = I(l.initialSelectedRecordId === void 0), q = s(() => w.value ?? v.value), b = s(() => {
102
- var i;
103
- const e = [...((i = v.value) == null ? void 0 : i.views) ?? [], ...S.value], t = J(e);
104
- return t.length > 0 ? t : [K(v.value, l.defaultView)];
105
- }), g = s(
106
- () => Ee(b.value, p.value, V.value, y.value)
107
- ), C = s(() => g.value.find((t) => t.viewId === m.value) ?? g.value[0] ?? K(q.value, l.defaultView, m.value || "__default__")), O = s(() => f.value ? d.value.find((e) => e.id === f.value) ?? null : null), T = s(() => f.value ? d.value.findIndex((e) => e.id === f.value) : -1), U = s(() => T.value >= 0), re = s(
108
- () => U.value ? T.value + 1 : null
109
- ), h = I(!!(l.initialDetailOpen ?? l.initialSelectedRecordId)), ce = s(() => h.value ? O.value : null), de = s(
94
+ function Te(t) {
95
+ return t ? Array.isArray(t) ? t.filter(
96
+ (i) => !!i
97
+ ) : [t] : [];
98
+ }
99
+ function je(t) {
100
+ var ce, oe;
101
+ const i = f(() => {
102
+ var e, l;
103
+ return t.mode ? t.mode : (e = t.provider) != null && e.mode ? t.provider.mode : (l = t.provider) != null && l.onFetch ? "provider" : "local";
104
+ }), v = f(() => de(G(t.schema) ?? null)), a = f(() => H(G(t.records))), h = f(() => J(G(t.views))), w = I(null), x = I([]), y = I([]), S = I(/* @__PURE__ */ new Set()), d = Be(a.value), r = I(!1), A = I(null), E = I(d.value.length), M = I(1), B = I(t.pageSize ?? 20), s = I(
105
+ t.initialSelectedRecordId !== void 0 ? t.initialSelectedRecordId : ((ce = d.value[0]) == null ? void 0 : ce.id) ?? null
106
+ ), m = I(t.initialViewId ?? ""), T = I(!1), k = I(0), p = I(t.initialSelectedRecordId === void 0), P = f(() => w.value ?? v.value), $ = f(() => {
107
+ var n;
108
+ const e = [...((n = v.value) == null ? void 0 : n.views) ?? [], ...h.value], l = J(e);
109
+ return l.length > 0 ? l : [K(v.value, t.defaultView)];
110
+ }), j = Te((oe = t.actions) == null ? void 0 : oe.middleware), g = f(
111
+ () => qe($.value, x.value, y.value, S.value)
112
+ ), V = f(() => g.value.find((l) => l.viewId === m.value) ?? g.value[0] ?? K(P.value, t.defaultView, m.value || "__default__")), D = f(() => s.value ? d.value.find((e) => e.id === s.value) ?? null : null), q = f(() => s.value ? d.value.findIndex((e) => e.id === s.value) : -1), U = f(() => q.value >= 0), ve = f(
113
+ () => U.value ? q.value + 1 : null
114
+ ), R = I(!!(t.initialDetailOpen ?? t.initialSelectedRecordId)), se = f(() => R.value ? D.value : null), fe = f(
110
115
  () => g.value.map((e) => ({
111
116
  id: e.viewId,
112
117
  name: e.name,
113
118
  type: e.viewType
114
119
  }))
115
- ), M = s(() => {
120
+ ), C = f(() => {
116
121
  var e;
117
- return r.value === "provider" && !!((e = l.provider) != null && e.onFetch);
118
- }), oe = s(() => !M.value);
119
- function x(e) {
120
- D.value = e instanceof Error ? e : new Error(String(e));
122
+ return i.value === "provider" && !!((e = t.provider) != null && e.onFetch);
123
+ }), we = f(() => !C.value);
124
+ function X(e) {
125
+ A.value = e instanceof Error ? e : new Error(String(e));
126
+ }
127
+ function Ie(e, l) {
128
+ return {
129
+ action: e,
130
+ payload: l,
131
+ tableId: t.tableId,
132
+ mode: i.value,
133
+ view: V.value,
134
+ activeViewId: m.value,
135
+ selectedRecordId: s.value,
136
+ selectedRecord: D.value,
137
+ page: M.value,
138
+ pageSize: B.value,
139
+ totalCount: E.value
140
+ };
141
+ }
142
+ async function Y(e, l) {
143
+ const n = e === "before" ? j : [...j].reverse();
144
+ for (const u of n) {
145
+ const c = u[e];
146
+ c && await c(l);
147
+ }
121
148
  }
122
- function W(e) {
123
- return d.value.findIndex((t) => t.id === e);
149
+ async function me(e, l) {
150
+ const n = {
151
+ ...e,
152
+ error: l
153
+ };
154
+ for (const u of [...j].reverse())
155
+ u.error && await u.error(n);
124
156
  }
125
- function ve(e) {
126
- return d.value.find((t) => t.id === e) ?? null;
157
+ async function F(e, l, n) {
158
+ const u = Ie(e, l);
159
+ try {
160
+ await Y("before", u), await (n == null ? void 0 : n()), await Y("after", u);
161
+ } catch (c) {
162
+ try {
163
+ await me(u, c);
164
+ } catch (o) {
165
+ X(o);
166
+ return;
167
+ }
168
+ X(c);
169
+ }
127
170
  }
128
- function fe(e) {
129
- return W(e) >= 0;
171
+ function Z(e) {
172
+ return d.value.findIndex((l) => l.id === e);
130
173
  }
131
- function X(e) {
174
+ function ge(e) {
175
+ return d.value.find((l) => l.id === e) ?? null;
176
+ }
177
+ function Re(e) {
178
+ return Z(e) >= 0;
179
+ }
180
+ function ee(e) {
132
181
  return e == null ? null : typeof e == "string" ? e : e.id;
133
182
  }
134
- function _() {
183
+ function L() {
135
184
  var e;
136
- Q(g.value, m.value) || (m.value = ((e = g.value[0]) == null ? void 0 : e.viewId) ?? K(q.value, l.defaultView).viewId);
185
+ Q(g.value, m.value) || (m.value = ((e = g.value[0]) == null ? void 0 : e.viewId) ?? K(P.value, t.defaultView).viewId);
137
186
  }
138
- function P() {
187
+ function _() {
139
188
  var e;
140
- F.value && (!f.value || !fe(f.value)) && (f.value = ((e = d.value[0]) == null ? void 0 : e.id) ?? null);
189
+ p.value && (!s.value || !Re(s.value)) && (s.value = ((e = d.value[0]) == null ? void 0 : e.id) ?? null);
141
190
  }
142
- function Y(e) {
143
- F.value = !1, f.value = X(e);
191
+ function te(e) {
192
+ p.value = !1, s.value = ee(e);
144
193
  }
145
- function Z(e) {
146
- F.value = !1, e !== void 0 && (f.value = X(e)), h.value = !0;
194
+ function le(e) {
195
+ p.value = !1, e !== void 0 && (s.value = ee(e)), R.value = !0;
147
196
  }
148
- function ee(e) {
149
- h.value = !1, e != null && e.clearSelection && (F.value = !1, f.value = null);
197
+ function ae(e) {
198
+ R.value = !1, e != null && e.clearSelection && (p.value = !1, s.value = null);
150
199
  }
151
- function se(e) {
152
- if (h.value) {
153
- ee();
200
+ function he(e) {
201
+ if (R.value) {
202
+ ae();
154
203
  return;
155
204
  }
156
- Z(e);
157
- }
158
- function le(e, t) {
159
- const i = d.value.length;
160
- if (i <= 0) return;
161
- const c = T.value;
162
- let o = c >= 0 ? c + e : e > 0 ? 0 : i - 1;
163
- if (t != null && t.wrap)
164
- o = (o + i) % i;
165
- else if (o < 0 || o >= i)
205
+ le(e);
206
+ }
207
+ function ne(e, l) {
208
+ const n = d.value.length;
209
+ if (n <= 0) return;
210
+ const u = q.value;
211
+ let c = u >= 0 ? u + e : e > 0 ? 0 : n - 1;
212
+ if (l != null && l.wrap)
213
+ c = (c + n) % n;
214
+ else if (c < 0 || c >= n)
166
215
  return;
167
- const u = d.value[o];
168
- u && (F.value = !1, f.value = u.id, ((t == null ? void 0 : t.openDetail) ?? h.value) && (h.value = !0));
216
+ const o = d.value[c];
217
+ o && (p.value = !1, s.value = o.id, ((l == null ? void 0 : l.openDetail) ?? R.value) && (R.value = !0));
169
218
  }
170
- function we(e) {
171
- le(1, e);
219
+ function Se(e) {
220
+ ne(1, e);
172
221
  }
173
- function Ie(e) {
174
- le(-1, e);
222
+ function ye(e) {
223
+ ne(-1, e);
175
224
  }
176
- function j(e) {
177
- const t = z(e);
178
- V.value = [...V.value.filter((i) => i.viewId !== t.viewId), t], y.value.delete(t.viewId), _();
225
+ function N(e) {
226
+ const l = z(e);
227
+ y.value = [...y.value.filter((n) => n.viewId !== l.viewId), l], S.value.delete(l.viewId), L();
179
228
  }
180
- function te(e) {
181
- V.value = V.value.filter((t) => t.viewId !== e);
229
+ function ie(e) {
230
+ y.value = y.value.filter((l) => l.viewId !== e);
182
231
  }
183
- function me(e) {
184
- y.value = /* @__PURE__ */ new Set([...y.value, e]), te(e);
232
+ function Ve(e) {
233
+ S.value = /* @__PURE__ */ new Set([...S.value, e]), ie(e);
185
234
  }
186
- async function A() {
187
- var i, c, o;
235
+ async function b() {
188
236
  const e = {
189
- tableId: l.tableId,
190
- schema: q.value,
191
- view: C.value,
192
- page: L.value,
193
- pageSize: k.value,
194
- sort: Be(C.value),
195
- selectedRecordId: f.value
237
+ tableId: t.tableId,
238
+ schema: P.value,
239
+ view: V.value,
240
+ page: M.value,
241
+ pageSize: B.value,
242
+ sort: Oe(V.value),
243
+ selectedRecordId: s.value
196
244
  };
197
- if (D.value = null, (i = l.actions) != null && i.onRefresh)
198
- try {
199
- await l.actions.onRefresh();
200
- } catch (u) {
201
- x(u);
245
+ await F("refresh", e, async () => {
246
+ var n, u, c;
247
+ if (A.value = null, (n = t.actions) != null && n.onRefresh && await t.actions.onRefresh(), (u = t.provider) != null && u.onRefresh && await t.provider.onRefresh(e), !C.value || !((c = t.provider) != null && c.onFetch)) {
248
+ d.value = a.value, E.value = d.value.length, _(), L(), T.value = !1;
202
249
  return;
203
250
  }
204
- if ((c = l.provider) != null && c.onRefresh)
251
+ const l = k.value + 1;
252
+ k.value = l, r.value = !0;
205
253
  try {
206
- await l.provider.onRefresh(e);
207
- } catch (u) {
208
- x(u);
209
- return;
254
+ const o = await t.provider.onFetch(e);
255
+ if (k.value !== l) return;
256
+ const O = H(o.records ?? o.data);
257
+ d.value = O, E.value = o.total ?? O.length, o.schema !== void 0 && (w.value = de(o.schema)), o.views !== void 0 && o.views !== null && (x.value = J(o.views)), o.activeViewId && (m.value = o.activeViewId), o.selectedRecordId !== void 0 && (p.value = !1, s.value = o.selectedRecordId, o.selectedRecordId === null && (R.value = !1)), T.value = !0, L(), _();
258
+ } finally {
259
+ k.value === l && (r.value = !1);
210
260
  }
211
- if (!M.value || !((o = l.provider) != null && o.onFetch)) {
212
- d.value = a.value, E.value = d.value.length, P(), _(), $.value = !1;
213
- return;
214
- }
215
- const t = B.value + 1;
216
- B.value = t, n.value = !0;
217
- try {
218
- const u = await l.provider.onFetch(e);
219
- if (B.value !== t) return;
220
- const R = H(u.records ?? u.data);
221
- d.value = R, E.value = u.total ?? R.length, u.schema !== void 0 && (w.value = ue(u.schema)), u.views !== void 0 && u.views !== null && (p.value = J(u.views)), u.activeViewId && (m.value = u.activeViewId), u.selectedRecordId !== void 0 && (F.value = !1, f.value = u.selectedRecordId, u.selectedRecordId === null && (h.value = !1)), $.value = !0, _(), P();
222
- } catch (u) {
223
- B.value === t && x(u);
224
- } finally {
225
- B.value === t && (n.value = !1);
226
- }
261
+ });
227
262
  }
228
- function ae(e) {
229
- Q(g.value, e) && (m.value = e, L.value = 1, M.value && A());
263
+ function re(e) {
264
+ Q(g.value, e) && (m.value = e, M.value = 1, C.value && b());
230
265
  }
231
- function ge(e) {
232
- ae(e);
266
+ function xe(e) {
267
+ re(e);
233
268
  }
234
- async function he(e) {
235
- var c, o;
236
- const t = C.value, i = z({
237
- ...t,
269
+ async function Me(e) {
270
+ const l = V.value, n = z({
271
+ ...l,
238
272
  ...e,
239
- viewId: t.viewId
273
+ viewId: l.viewId
274
+ });
275
+ await F("save-view", n, async () => {
276
+ var u, c;
277
+ N(n), await ((c = (u = t.actions) == null ? void 0 : u.onSaveView) == null ? void 0 : c.call(u, n));
240
278
  });
241
- j(i);
242
- try {
243
- await ((o = (c = l.actions) == null ? void 0 : c.onSaveView) == null ? void 0 : o.call(c, i));
244
- } catch (u) {
245
- x(u);
246
- }
247
279
  }
248
- async function ne(e, t) {
249
- var o, u;
250
- const i = `view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`, c = z({
251
- ...C.value,
252
- ...t,
253
- viewId: i,
280
+ async function ue(e, l) {
281
+ const n = `view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`, u = z({
282
+ ...V.value,
283
+ ...l,
284
+ viewId: n,
254
285
  name: e
255
286
  });
256
- j(c), m.value = i, L.value = 1;
257
- try {
258
- await ((u = (o = l.actions) == null ? void 0 : o.onSaveView) == null ? void 0 : u.call(o, c));
259
- } catch (R) {
260
- x(R);
261
- }
262
- return i;
287
+ return await F("save-view", u, async () => {
288
+ var c, o;
289
+ N(u), m.value = n, M.value = 1, await ((o = (c = t.actions) == null ? void 0 : c.onSaveView) == null ? void 0 : o.call(c, u));
290
+ }), n;
263
291
  }
264
- async function Re(e) {
265
- var c, o, u;
292
+ async function pe(e) {
266
293
  if (!Q(g.value, e)) return;
267
- const t = m.value === e;
268
- b.value.some((R) => R.viewId === e) ? me(e) : te(e), t && (m.value = ((c = g.value.find((R) => R.viewId !== e)) == null ? void 0 : c.viewId) ?? "", _());
269
- try {
270
- await ((u = (o = l.actions) == null ? void 0 : o.onDeleteView) == null ? void 0 : u.call(o, e));
271
- } catch (R) {
272
- x(R);
273
- }
294
+ const l = m.value === e, n = $.value.some((u) => u.viewId === e);
295
+ await F("delete-view", e, async () => {
296
+ var u, c, o;
297
+ n ? Ve(e) : ie(e), l && (m.value = ((u = g.value.find((O) => O.viewId !== e)) == null ? void 0 : u.viewId) ?? "", L()), await ((o = (c = t.actions) == null ? void 0 : c.onDeleteView) == null ? void 0 : o.call(c, e));
298
+ });
274
299
  }
275
- async function Se(e, t) {
276
- const i = g.value.find((c) => c.viewId === e);
277
- return i ? ne(t, { ...i }) : "";
300
+ async function Ce(e, l) {
301
+ const n = g.value.find((u) => u.viewId === e);
302
+ return n ? ue(l, { ...n }) : "";
278
303
  }
279
- function ye(e) {
280
- const t = z({
281
- ...C.value,
304
+ function Fe(e) {
305
+ const l = z({
306
+ ...V.value,
282
307
  ...e,
283
- viewId: C.value.viewId
308
+ viewId: V.value.viewId
284
309
  });
285
- j(t);
310
+ N(l);
286
311
  }
287
- function Ve(e) {
288
- Y(e), f.value === null && (h.value = !1);
312
+ function ze(e) {
313
+ te(e), s.value === null && (R.value = !1);
289
314
  }
290
- function xe() {
291
- F.value = !1, f.value = null, h.value = !1;
315
+ function Ae() {
316
+ p.value = !1, s.value = null, R.value = !1;
292
317
  }
293
- function pe(e) {
294
- L.value = Math.max(1, Math.floor(e) || 1), M.value && A();
318
+ function Ee(e) {
319
+ M.value = Math.max(1, Math.floor(e) || 1), C.value && b();
295
320
  }
296
- function Fe(e) {
297
- k.value = Math.max(1, Math.floor(e) || 1), L.value = 1, M.value && A();
321
+ function De(e) {
322
+ B.value = Math.max(1, Math.floor(e) || 1), M.value = 1, C.value && b();
298
323
  }
299
- async function Ce(e) {
300
- var t, i;
301
- try {
302
- await ((i = (t = l.actions) == null ? void 0 : t.onCellEdit) == null ? void 0 : i.call(t, e));
303
- } catch (c) {
304
- x(c);
305
- }
324
+ async function Le(e) {
325
+ await F("cell-edit", e, () => {
326
+ var l, n;
327
+ return (n = (l = t.actions) == null ? void 0 : l.onCellEdit) == null ? void 0 : n.call(l, e);
328
+ });
306
329
  }
307
- async function Me(e) {
308
- var t, i;
309
- try {
310
- await ((i = (t = l.actions) == null ? void 0 : t.onSchemaEvent) == null ? void 0 : i.call(t, e));
311
- } catch (c) {
312
- x(c);
313
- }
330
+ async function _e(e) {
331
+ await F("schema-event", e, () => {
332
+ var l, n;
333
+ return (n = (l = t.actions) == null ? void 0 : l.onSchemaEvent) == null ? void 0 : n.call(l, e);
334
+ });
314
335
  }
315
- function ze(e) {
316
- const t = H(e);
317
- d.value = t, E.value = t.length, P();
336
+ function be(e) {
337
+ const l = H(e);
338
+ d.value = l, E.value = l.length, _();
318
339
  }
319
- return N(
340
+ return W(
320
341
  a,
321
342
  (e) => {
322
- M.value && $.value || (d.value = e, E.value = e.length, P());
343
+ C.value && T.value || (d.value = e, E.value = e.length, _());
323
344
  },
324
345
  { immediate: !0 }
325
- ), N(
326
- b,
346
+ ), W(
347
+ $,
327
348
  () => {
328
- _();
349
+ L();
329
350
  },
330
351
  { immediate: !0, deep: !0 }
331
- ), N(
332
- O,
352
+ ), W(
353
+ D,
333
354
  () => {
334
- var e, t;
335
- (t = (e = l.actions) == null ? void 0 : e.onSelectRecord) == null || t.call(e, O.value);
355
+ F(
356
+ "select-record",
357
+ D.value,
358
+ () => {
359
+ var e, l;
360
+ return (l = (e = t.actions) == null ? void 0 : e.onSelectRecord) == null ? void 0 : l.call(e, D.value);
361
+ }
362
+ );
336
363
  },
337
364
  { immediate: !0, deep: !1, flush: "sync" }
338
- ), l.autoLoad !== !1 ? A() : (_(), P()), {
339
- tableId: l.tableId,
340
- mode: r,
341
- schema: q,
365
+ ), t.autoLoad !== !1 ? b() : (L(), _()), {
366
+ tableId: t.tableId,
367
+ mode: i,
368
+ schema: P,
342
369
  records: d,
343
370
  views: g,
344
371
  activeViewId: m,
345
- activeView: C,
346
- selectedRecordId: f,
347
- selectedRecord: O,
348
- selectedRecordIndex: T,
349
- selectedRecordOrdinal: re,
372
+ activeView: V,
373
+ selectedRecordId: s,
374
+ selectedRecord: D,
375
+ selectedRecordIndex: q,
376
+ selectedRecordOrdinal: ve,
350
377
  hasSelectedRecord: U,
351
- detailOpen: h,
352
- detailRecord: ce,
353
- loading: n,
354
- error: D,
355
- page: L,
356
- pageSize: k,
378
+ detailOpen: R,
379
+ detailRecord: se,
380
+ loading: r,
381
+ error: A,
382
+ page: M,
383
+ pageSize: B,
357
384
  totalCount: E,
358
- viewList: de,
359
- isProviderMode: M,
360
- isLocalMode: oe,
361
- refresh: A,
362
- getRecordById: ve,
363
- getRecordIndex: W,
364
- selectRecord: Y,
365
- openRecordDetail: Z,
366
- closeRecordDetail: ee,
367
- toggleRecordDetail: se,
368
- selectNextRecord: we,
369
- selectPreviousRecord: Ie,
370
- switchView: ae,
371
- setActiveViewId: ge,
372
- createView: ne,
373
- saveView: he,
374
- deleteView: Re,
375
- duplicateView: Se,
376
- updateActiveView: ye,
377
- setSelectedRecord: Ve,
378
- clearSelectedRecord: xe,
379
- setPage: pe,
380
- setPageSize: Fe,
381
- emitCellEdit: Ce,
382
- emitSchemaEvent: Me,
383
- setRecords: ze
385
+ viewList: fe,
386
+ isProviderMode: C,
387
+ isLocalMode: we,
388
+ refresh: b,
389
+ getRecordById: ge,
390
+ getRecordIndex: Z,
391
+ selectRecord: te,
392
+ openRecordDetail: le,
393
+ closeRecordDetail: ae,
394
+ toggleRecordDetail: he,
395
+ selectNextRecord: Se,
396
+ selectPreviousRecord: ye,
397
+ switchView: re,
398
+ setActiveViewId: xe,
399
+ createView: ue,
400
+ saveView: Me,
401
+ deleteView: pe,
402
+ duplicateView: Ce,
403
+ updateActiveView: Fe,
404
+ setSelectedRecord: ze,
405
+ clearSelectedRecord: Ae,
406
+ setPage: Ee,
407
+ setPageSize: De,
408
+ emitCellEdit: Le,
409
+ emitSchemaEvent: _e,
410
+ setRecords: be
384
411
  };
385
412
  }
386
413
  export {
387
- Ae as useDatabaseView
414
+ je as useDatabaseView
388
415
  };