@oneflowui/ui 0.4.4 → 0.5.1
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/README.en.md +1 -1
- package/README.md +70 -0
- package/dist/components/database/DatabaseView.vue.d.ts +171 -0
- package/dist/components/database/DatabaseView.vue.js +7 -0
- package/dist/components/database/DatabaseView.vue2.js +774 -0
- package/dist/components/database/index.d.ts +2 -0
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/useDatabaseView.d.ts +138 -0
- package/dist/composables/useDatabaseView.js +388 -0
- package/dist/composables/useWorkerSort.js +30 -29
- package/dist/index.d.ts +4 -0
- package/dist/index.js +178 -173
- package/dist/style.css +1 -1
- package/dist/tests/database-view.integration.spec.d.ts +1 -0
- package/dist/workers/tableWorkerSource.js +79 -0
- package/package.json +17 -17
- package/dist/assets/tableWorker-CTsbCPPP.js +0 -1
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
import { defineComponent as ot, computed as n, ref as B, watch as y, openBlock as v, createElementBlock as g, mergeProps as nt, createVNode as N, unref as j, createElementVNode as H, Fragment as st, createBlock as k, createCommentVNode as dt } from "vue";
|
|
2
|
+
import { Loader2 as ut, AlertCircle as ct, Database as vt } from "lucide-vue-next";
|
|
3
|
+
import re from "../base/EmptyState.vue.js";
|
|
4
|
+
import ft from "../table/DetailSheet.vue.js";
|
|
5
|
+
import mt from "../table/TableToolbar.vue.js";
|
|
6
|
+
import wt from "../table/DataTable.vue.js";
|
|
7
|
+
import pt from "../kanban/KanbanBoard.vue.js";
|
|
8
|
+
import ht from "../gallery/GalleryView.vue.js";
|
|
9
|
+
import bt from "../timeline/GanttTimeline.vue.js";
|
|
10
|
+
import { useDatabaseView as yt } from "../../composables/useDatabaseView.js";
|
|
11
|
+
import { buildGanttItems as gt } from "../../types/index.js";
|
|
12
|
+
const Vt = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "of-database-view__state of-database-view__state--loading",
|
|
15
|
+
"data-role": "loading-state"
|
|
16
|
+
}, _t = {
|
|
17
|
+
key: 1,
|
|
18
|
+
class: "of-database-view__state",
|
|
19
|
+
"data-role": "error-state"
|
|
20
|
+
}, It = {
|
|
21
|
+
key: 1,
|
|
22
|
+
class: "of-database-view__state of-database-view__state--empty",
|
|
23
|
+
"data-role": "empty-state"
|
|
24
|
+
}, Ct = ["data-view"], Ft = {
|
|
25
|
+
key: 4,
|
|
26
|
+
class: "of-database-view__detail-anchor"
|
|
27
|
+
}, p = "detail", xt = /* @__PURE__ */ ot({
|
|
28
|
+
name: "DatabaseView",
|
|
29
|
+
inheritAttrs: !1,
|
|
30
|
+
__name: "DatabaseView",
|
|
31
|
+
props: {
|
|
32
|
+
tableId: { default: "database-view" },
|
|
33
|
+
mode: { default: "local" },
|
|
34
|
+
schema: { default: null },
|
|
35
|
+
records: { default: () => [] },
|
|
36
|
+
views: { default: () => [] },
|
|
37
|
+
provider: { default: void 0 },
|
|
38
|
+
defaultView: { default: void 0 },
|
|
39
|
+
currentViewId: { default: "" },
|
|
40
|
+
initialViewId: { default: "" },
|
|
41
|
+
selectedRecordId: { default: void 0 },
|
|
42
|
+
initialSelectedRecordId: { default: void 0 },
|
|
43
|
+
searchKeyword: { default: "" },
|
|
44
|
+
loading: { type: Boolean, default: void 0 },
|
|
45
|
+
error: { default: void 0 },
|
|
46
|
+
viewTabs: { default: void 0 },
|
|
47
|
+
actions: { default: void 0 },
|
|
48
|
+
ui: { default: void 0 },
|
|
49
|
+
showToolbar: { type: Boolean, default: !0 },
|
|
50
|
+
showViewSwitch: { type: Boolean, default: !0 },
|
|
51
|
+
showFilter: { type: Boolean, default: !0 },
|
|
52
|
+
showSort: { type: Boolean, default: !0 },
|
|
53
|
+
showGroup: { type: Boolean, default: !0 },
|
|
54
|
+
showColumns: { type: Boolean, default: !0 },
|
|
55
|
+
showSearch: { type: Boolean, default: !0 },
|
|
56
|
+
readonly: { type: Boolean, default: !1 },
|
|
57
|
+
pageSize: { default: 20 },
|
|
58
|
+
autoLoad: { type: Boolean, default: !0 }
|
|
59
|
+
},
|
|
60
|
+
emits: ["update:currentViewId", "update:selectedRecordId", "update:searchKeyword", "update:columns", "update:filterLogic", "update:records", "cell-edit", "select-record", "schema-add-field", "schema-rename-field", "schema-change-field-type", "schema-hide-field", "schema-delete-field", "schema-duplicate-field", "row-click", "card-click", "add", "add-column", "record-change", "load-view", "save-view", "sort", "group", "refresh"],
|
|
61
|
+
setup(T, { emit: oe }) {
|
|
62
|
+
var ie, le;
|
|
63
|
+
const l = T, d = oe;
|
|
64
|
+
function M(e) {
|
|
65
|
+
var t, a, i, r;
|
|
66
|
+
return {
|
|
67
|
+
...e,
|
|
68
|
+
visibleFields: [...e.visibleFields],
|
|
69
|
+
sorts: (t = e.sorts) == null ? void 0 : t.map((o) => ({ ...o })),
|
|
70
|
+
groups: (a = e.groups) == null ? void 0 : a.map((o) => ({ ...o })),
|
|
71
|
+
filters: (i = e.filters) == null ? void 0 : i.map((o) => ({ ...o })),
|
|
72
|
+
aggregations: (r = e.aggregations) == null ? void 0 : r.map((o) => ({ ...o })),
|
|
73
|
+
fixedColumns: e.fixedColumns ? [...e.fixedColumns] : void 0,
|
|
74
|
+
galleryCardFields: e.galleryCardFields ? [...e.galleryCardFields] : void 0
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function ne(e) {
|
|
78
|
+
const t = e[0];
|
|
79
|
+
return t ? Object.keys(t.fields) : [];
|
|
80
|
+
}
|
|
81
|
+
function O(e) {
|
|
82
|
+
switch (e) {
|
|
83
|
+
case "kanban":
|
|
84
|
+
return "columns-3";
|
|
85
|
+
case "gallery":
|
|
86
|
+
return "image";
|
|
87
|
+
case "timeline":
|
|
88
|
+
return "calendar-range";
|
|
89
|
+
case "detail":
|
|
90
|
+
return "file-text";
|
|
91
|
+
case "table":
|
|
92
|
+
default:
|
|
93
|
+
return "table-2";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function se(e, t = []) {
|
|
97
|
+
const a = V(e, t);
|
|
98
|
+
return {
|
|
99
|
+
viewId: "table",
|
|
100
|
+
viewType: "table",
|
|
101
|
+
name: (e == null ? void 0 : e.name) || "表格",
|
|
102
|
+
visibleFields: a,
|
|
103
|
+
sorts: [],
|
|
104
|
+
groups: [],
|
|
105
|
+
filters: [],
|
|
106
|
+
fixedColumns: []
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function de(e, t = []) {
|
|
110
|
+
const a = V(e, t);
|
|
111
|
+
return {
|
|
112
|
+
viewId: p,
|
|
113
|
+
viewType: "detail",
|
|
114
|
+
name: "详情",
|
|
115
|
+
visibleFields: a,
|
|
116
|
+
sorts: [],
|
|
117
|
+
groups: [],
|
|
118
|
+
filters: [],
|
|
119
|
+
fixedColumns: []
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function U(e, t) {
|
|
123
|
+
var a;
|
|
124
|
+
return ((a = t == null ? void 0 : t.fields.find((i) => i.id === e)) == null ? void 0 : a.name) ?? e;
|
|
125
|
+
}
|
|
126
|
+
function P(e) {
|
|
127
|
+
switch (e == null ? void 0 : e.type) {
|
|
128
|
+
case "number":
|
|
129
|
+
case "currency":
|
|
130
|
+
case "progress":
|
|
131
|
+
return "number";
|
|
132
|
+
case "date":
|
|
133
|
+
case "datetime":
|
|
134
|
+
return "date";
|
|
135
|
+
case "select":
|
|
136
|
+
case "multi_select":
|
|
137
|
+
return "status";
|
|
138
|
+
default:
|
|
139
|
+
return "string";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function ue(e) {
|
|
143
|
+
switch (e == null ? void 0 : e.type) {
|
|
144
|
+
case "number":
|
|
145
|
+
return "number";
|
|
146
|
+
case "select":
|
|
147
|
+
return "select";
|
|
148
|
+
case "multi_select":
|
|
149
|
+
return "multiselect";
|
|
150
|
+
case "date":
|
|
151
|
+
return "date";
|
|
152
|
+
case "datetime":
|
|
153
|
+
return "datetime";
|
|
154
|
+
case "checkbox":
|
|
155
|
+
return "checkbox";
|
|
156
|
+
case "url":
|
|
157
|
+
return "url";
|
|
158
|
+
case "email":
|
|
159
|
+
return "email";
|
|
160
|
+
case "phone":
|
|
161
|
+
return "phone";
|
|
162
|
+
case "rating":
|
|
163
|
+
return "rating";
|
|
164
|
+
case "attachment":
|
|
165
|
+
return "attachment";
|
|
166
|
+
case "relation":
|
|
167
|
+
return "relation";
|
|
168
|
+
case "formula":
|
|
169
|
+
return "text";
|
|
170
|
+
case "currency":
|
|
171
|
+
return "currency";
|
|
172
|
+
case "richtext":
|
|
173
|
+
return "richtext";
|
|
174
|
+
case "auto_number":
|
|
175
|
+
return "auto_number";
|
|
176
|
+
case "creator":
|
|
177
|
+
return "creator";
|
|
178
|
+
case "progress":
|
|
179
|
+
return "progress";
|
|
180
|
+
case "text":
|
|
181
|
+
default:
|
|
182
|
+
return "text";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function ce(e, t, a = []) {
|
|
186
|
+
var r;
|
|
187
|
+
return ((((r = e.visibleFields) == null ? void 0 : r.length) ?? 0) > 0 ? e.visibleFields : V(t, a)).map((o) => {
|
|
188
|
+
var S;
|
|
189
|
+
const u = (S = t == null ? void 0 : t.fields) == null ? void 0 : S.find((rt) => rt.id === o);
|
|
190
|
+
return {
|
|
191
|
+
key: o,
|
|
192
|
+
label: U(o, t),
|
|
193
|
+
type: P(u),
|
|
194
|
+
hidden: (u == null ? void 0 : u.hidden) ?? !1,
|
|
195
|
+
width: u == null ? void 0 : u.width
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function ve(e, t = []) {
|
|
200
|
+
return V(e, t).map((i) => {
|
|
201
|
+
var o;
|
|
202
|
+
const r = (o = e == null ? void 0 : e.fields) == null ? void 0 : o.find((u) => u.id === i);
|
|
203
|
+
return {
|
|
204
|
+
key: i,
|
|
205
|
+
label: U(i, e),
|
|
206
|
+
type: P(r),
|
|
207
|
+
hidden: (r == null ? void 0 : r.hidden) ?? !1,
|
|
208
|
+
width: r == null ? void 0 : r.width
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function fe(e, t = []) {
|
|
213
|
+
return V(e, t).map((i) => {
|
|
214
|
+
var o;
|
|
215
|
+
const r = (o = e == null ? void 0 : e.fields) == null ? void 0 : o.find((u) => u.id === i);
|
|
216
|
+
return {
|
|
217
|
+
id: i,
|
|
218
|
+
type: ue(r),
|
|
219
|
+
label: U(i, e)
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function R(e) {
|
|
224
|
+
return e == null ? "" : Array.isArray(e) ? e.map((t) => String(t)).join(", ") : String(e);
|
|
225
|
+
}
|
|
226
|
+
function F(e, t) {
|
|
227
|
+
if (e == null && t == null) return 0;
|
|
228
|
+
if (e == null) return -1;
|
|
229
|
+
if (t == null) return 1;
|
|
230
|
+
const a = Number(e), i = Number(t), r = Number.isFinite(a) && `${e}`.trim() !== "", o = Number.isFinite(i) && `${t}`.trim() !== "";
|
|
231
|
+
if (r && o) return a - i;
|
|
232
|
+
const u = Date.parse(String(e)), S = Date.parse(String(t));
|
|
233
|
+
return Number.isFinite(u) && Number.isFinite(S) ? u - S : R(e).localeCompare(R(t), "zh-Hans-CN");
|
|
234
|
+
}
|
|
235
|
+
function me(e, t) {
|
|
236
|
+
const a = R(e).trim(), i = (t.value ?? "").trim(), r = a.toLowerCase(), o = i.toLowerCase();
|
|
237
|
+
switch (t.operator) {
|
|
238
|
+
case "equals":
|
|
239
|
+
return r === o;
|
|
240
|
+
case "not_equals":
|
|
241
|
+
return r !== o;
|
|
242
|
+
case "contains":
|
|
243
|
+
return r.includes(o);
|
|
244
|
+
case "not_contains":
|
|
245
|
+
return !r.includes(o);
|
|
246
|
+
case "starts_with":
|
|
247
|
+
return r.startsWith(o);
|
|
248
|
+
case "ends_with":
|
|
249
|
+
return r.endsWith(o);
|
|
250
|
+
case "gt":
|
|
251
|
+
return F(e, i) > 0;
|
|
252
|
+
case "gte":
|
|
253
|
+
return F(e, i) >= 0;
|
|
254
|
+
case "lt":
|
|
255
|
+
return F(e, i) < 0;
|
|
256
|
+
case "lte":
|
|
257
|
+
return F(e, i) <= 0;
|
|
258
|
+
case "is_empty":
|
|
259
|
+
return a === "";
|
|
260
|
+
case "is_not_empty":
|
|
261
|
+
return a !== "";
|
|
262
|
+
default:
|
|
263
|
+
return !0;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function we(e) {
|
|
267
|
+
return {
|
|
268
|
+
id: `f_${Math.random().toString(36).slice(2, 8)}`,
|
|
269
|
+
field: e,
|
|
270
|
+
operator: "contains",
|
|
271
|
+
value: ""
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function pe(e = []) {
|
|
275
|
+
return e.map((t, a) => ({
|
|
276
|
+
id: `f_${t.fieldId}_${a}`,
|
|
277
|
+
field: t.fieldId,
|
|
278
|
+
operator: (() => {
|
|
279
|
+
switch (t.operator) {
|
|
280
|
+
case "eq":
|
|
281
|
+
return "equals";
|
|
282
|
+
case "neq":
|
|
283
|
+
return "not_equals";
|
|
284
|
+
case "gt":
|
|
285
|
+
return "gt";
|
|
286
|
+
case "lt":
|
|
287
|
+
return "lt";
|
|
288
|
+
case "is_empty":
|
|
289
|
+
return "is_empty";
|
|
290
|
+
case "is_not_empty":
|
|
291
|
+
return "is_not_empty";
|
|
292
|
+
case "contains":
|
|
293
|
+
default:
|
|
294
|
+
return "contains";
|
|
295
|
+
}
|
|
296
|
+
})(),
|
|
297
|
+
value: t.value == null ? "" : String(t.value)
|
|
298
|
+
}));
|
|
299
|
+
}
|
|
300
|
+
function he(e) {
|
|
301
|
+
return e.filter((t) => t.field).map((t) => {
|
|
302
|
+
let a;
|
|
303
|
+
switch (t.operator) {
|
|
304
|
+
case "equals":
|
|
305
|
+
a = "eq";
|
|
306
|
+
break;
|
|
307
|
+
case "not_equals":
|
|
308
|
+
a = "neq";
|
|
309
|
+
break;
|
|
310
|
+
case "gt":
|
|
311
|
+
case "gte":
|
|
312
|
+
a = "gt";
|
|
313
|
+
break;
|
|
314
|
+
case "lt":
|
|
315
|
+
case "lte":
|
|
316
|
+
a = "lt";
|
|
317
|
+
break;
|
|
318
|
+
case "is_empty":
|
|
319
|
+
a = "is_empty";
|
|
320
|
+
break;
|
|
321
|
+
case "is_not_empty":
|
|
322
|
+
a = "is_not_empty";
|
|
323
|
+
break;
|
|
324
|
+
case "contains":
|
|
325
|
+
case "not_contains":
|
|
326
|
+
case "starts_with":
|
|
327
|
+
case "ends_with":
|
|
328
|
+
default:
|
|
329
|
+
a = "contains";
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
fieldId: t.field,
|
|
334
|
+
operator: a,
|
|
335
|
+
value: t.value == null ? "" : t.value
|
|
336
|
+
};
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
function V(e, t = []) {
|
|
340
|
+
var i;
|
|
341
|
+
const a = (i = e == null ? void 0 : e.fields) == null ? void 0 : i.filter((r) => !r.hidden).map((r) => r.id);
|
|
342
|
+
return a != null && a.length ? a : ne(t);
|
|
343
|
+
}
|
|
344
|
+
function be(e) {
|
|
345
|
+
return e ? {
|
|
346
|
+
id: e.id,
|
|
347
|
+
...e.fields
|
|
348
|
+
} : { id: "__detail-empty__" };
|
|
349
|
+
}
|
|
350
|
+
function ye(e) {
|
|
351
|
+
if (e)
|
|
352
|
+
return {
|
|
353
|
+
label: "返回列表",
|
|
354
|
+
onClick: () => ee(e)
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const J = n(() => l.schema ?? null), ge = n(() => l.records ?? []), Q = n(() => {
|
|
358
|
+
var i, r;
|
|
359
|
+
const e = (l.views ?? []).map((o) => M(o)), t = e.some((o) => o.viewType === "table") || (((i = l.schema) == null ? void 0 : i.views) ?? []).some((o) => o.viewType === "table"), a = e.some((o) => o.viewType === "detail") || (((r = l.schema) == null ? void 0 : r.views) ?? []).some((o) => o.viewType === "detail");
|
|
360
|
+
return t || e.unshift(se(l.schema, l.records ?? [])), a || e.push(de(l.schema, l.records ?? [])), e;
|
|
361
|
+
}), s = yt({
|
|
362
|
+
tableId: l.tableId,
|
|
363
|
+
mode: l.mode,
|
|
364
|
+
schema: J,
|
|
365
|
+
records: ge,
|
|
366
|
+
views: Q,
|
|
367
|
+
provider: l.provider,
|
|
368
|
+
defaultView: l.defaultView,
|
|
369
|
+
initialViewId: l.currentViewId || l.initialViewId || ((ie = l.defaultView) == null ? void 0 : ie.viewId) || ((le = Q.value[0]) == null ? void 0 : le.viewId) || "",
|
|
370
|
+
initialSelectedRecordId: l.selectedRecordId ?? l.initialSelectedRecordId,
|
|
371
|
+
pageSize: l.pageSize,
|
|
372
|
+
autoLoad: l.autoLoad,
|
|
373
|
+
actions: {
|
|
374
|
+
onCellEdit: async (e) => {
|
|
375
|
+
var t, a;
|
|
376
|
+
d("cell-edit", e), await ((a = (t = l.actions) == null ? void 0 : t.onCellEdit) == null ? void 0 : a.call(t, e));
|
|
377
|
+
},
|
|
378
|
+
onSelectRecord: async (e) => {
|
|
379
|
+
var t, a;
|
|
380
|
+
await ((a = (t = l.actions) == null ? void 0 : t.onSelectRecord) == null ? void 0 : a.call(t, e));
|
|
381
|
+
},
|
|
382
|
+
onSchemaEvent: async (e) => {
|
|
383
|
+
var t, a;
|
|
384
|
+
switch (e.type) {
|
|
385
|
+
case "schema-add-field":
|
|
386
|
+
d("schema-add-field", e.fieldType);
|
|
387
|
+
break;
|
|
388
|
+
case "schema-rename-field":
|
|
389
|
+
d("schema-rename-field", { fieldId: e.fieldId, newName: e.newName });
|
|
390
|
+
break;
|
|
391
|
+
case "schema-change-field-type":
|
|
392
|
+
d("schema-change-field-type", { fieldId: e.fieldId, newType: e.newType });
|
|
393
|
+
break;
|
|
394
|
+
case "schema-hide-field":
|
|
395
|
+
d("schema-hide-field", e.fieldId);
|
|
396
|
+
break;
|
|
397
|
+
case "schema-delete-field":
|
|
398
|
+
d("schema-delete-field", e.fieldId);
|
|
399
|
+
break;
|
|
400
|
+
case "schema-duplicate-field":
|
|
401
|
+
d("schema-duplicate-field", e.fieldId);
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
await ((a = (t = l.actions) == null ? void 0 : t.onSchemaEvent) == null ? void 0 : a.call(t, e));
|
|
405
|
+
},
|
|
406
|
+
onSaveView: async (e) => {
|
|
407
|
+
var t, a;
|
|
408
|
+
d("save-view", e.name), await ((a = (t = l.actions) == null ? void 0 : t.onViewSave) == null ? void 0 : a.call(t, { tableId: l.tableId, viewId: e.viewId, name: e.name }));
|
|
409
|
+
},
|
|
410
|
+
onRefresh: async () => {
|
|
411
|
+
var e, t;
|
|
412
|
+
d("refresh"), await ((t = (e = l.actions) == null ? void 0 : e.onRefresh) == null ? void 0 : t.call(e));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}), f = n(() => s.activeView.value), x = n(() => s.activeViewId.value), q = n(() => s.selectedRecord.value), Ve = n(() => s.selectedRecordId.value), b = n(() => s.schema.value ?? J.value), h = n(() => [...s.records.value]), c = n(() => f.value.viewType || "table"), _ = B(l.searchKeyword ?? ""), K = B("and"), m = B([]), w = B(
|
|
416
|
+
l.currentViewId === p || l.initialViewId === p || l.selectedRecordId != null || l.initialSelectedRecordId != null
|
|
417
|
+
);
|
|
418
|
+
y(
|
|
419
|
+
() => l.searchKeyword,
|
|
420
|
+
(e) => {
|
|
421
|
+
_.value = e ?? "";
|
|
422
|
+
},
|
|
423
|
+
{ immediate: !0 }
|
|
424
|
+
), y(_, (e) => {
|
|
425
|
+
d("update:searchKeyword", e);
|
|
426
|
+
}), y(
|
|
427
|
+
f,
|
|
428
|
+
(e) => {
|
|
429
|
+
m.value = pe(e.filters ?? []);
|
|
430
|
+
},
|
|
431
|
+
{ immediate: !0 }
|
|
432
|
+
), y(
|
|
433
|
+
() => l.currentViewId,
|
|
434
|
+
(e) => {
|
|
435
|
+
!e || e === x.value || (s.setActiveViewId(e), e === p && (w.value = !0));
|
|
436
|
+
},
|
|
437
|
+
{ immediate: !0 }
|
|
438
|
+
), y(
|
|
439
|
+
() => l.selectedRecordId,
|
|
440
|
+
(e) => {
|
|
441
|
+
if (e !== void 0) {
|
|
442
|
+
if (!e) {
|
|
443
|
+
w.value = !1, s.clearSelectedRecord();
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
w.value = !0, s.setSelectedRecord(e);
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
{ immediate: !0 }
|
|
450
|
+
), y(
|
|
451
|
+
x,
|
|
452
|
+
(e, t) => {
|
|
453
|
+
var a, i;
|
|
454
|
+
d("update:currentViewId", e), e === p && (w.value = !0), t !== void 0 && e !== t && ((i = (a = l.actions) == null ? void 0 : a.onViewChange) == null || i.call(a, { tableId: l.tableId, view: M(f.value) }));
|
|
455
|
+
},
|
|
456
|
+
{ immediate: !0 }
|
|
457
|
+
), y(
|
|
458
|
+
Ve,
|
|
459
|
+
(e, t) => {
|
|
460
|
+
d("update:selectedRecordId", e), t !== void 0 && e !== t && d("select-record", q.value ?? null);
|
|
461
|
+
},
|
|
462
|
+
{ immediate: !0 }
|
|
463
|
+
);
|
|
464
|
+
const G = n(() => {
|
|
465
|
+
const e = l.viewTabs && l.viewTabs.length > 0 ? l.viewTabs.map((i) => ({ ...i })) : s.viewList.value.map((i) => ({
|
|
466
|
+
value: i.id,
|
|
467
|
+
label: i.name,
|
|
468
|
+
icon: O(i.type)
|
|
469
|
+
})), t = [], a = /* @__PURE__ */ new Set();
|
|
470
|
+
for (const i of e)
|
|
471
|
+
a.has(i.value) || (a.add(i.value), t.push(i));
|
|
472
|
+
return a.has(p) || t.push({ value: p, label: "详情", icon: O("detail") }), t;
|
|
473
|
+
}), _e = n(
|
|
474
|
+
() => s.viewList.value.map((e) => ({
|
|
475
|
+
id: e.id,
|
|
476
|
+
name: e.name
|
|
477
|
+
}))
|
|
478
|
+
), z = n(() => ce(f.value, b.value, h.value)), Ie = n(() => ve(b.value, h.value)), Ce = n(() => fe(b.value, h.value)), Fe = n(() => be(q.value)), Se = n(() => V(b.value, h.value)), X = n(() => {
|
|
479
|
+
var t;
|
|
480
|
+
const e = (t = f.value.sorts) == null ? void 0 : t[0];
|
|
481
|
+
return {
|
|
482
|
+
field: (e == null ? void 0 : e.fieldId) ?? null,
|
|
483
|
+
order: (e == null ? void 0 : e.direction) ?? null
|
|
484
|
+
};
|
|
485
|
+
}), ke = n(() => {
|
|
486
|
+
var e, t;
|
|
487
|
+
return ((t = (e = f.value.groups) == null ? void 0 : e[0]) == null ? void 0 : t.fieldId) ?? void 0;
|
|
488
|
+
}), D = n(() => m.value), Te = n(() => D.value.length > 0), Re = n(() => l.showToolbar !== !1), De = n(() => l.showViewSwitch !== !1 && G.value.length > 1), Le = n(() => l.showFilter !== !1), Ee = n(() => l.showSort !== !1), Ae = n(() => l.showGroup !== !1), Be = n(() => l.showColumns !== !1), Ne = n(() => l.showSearch !== !1), Y = n(() => w.value && !!q.value), Ue = n(() => l.loading ?? s.loading.value), L = n(() => l.error ?? s.error.value), I = n(() => {
|
|
489
|
+
let e = [...h.value];
|
|
490
|
+
if (_.value.trim()) {
|
|
491
|
+
const a = _.value.trim().toLowerCase();
|
|
492
|
+
e = e.filter(
|
|
493
|
+
(i) => Se.value.some(
|
|
494
|
+
(r) => R(i.fields[r]).toLowerCase().includes(a)
|
|
495
|
+
)
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
D.value.length > 0 && (e = e.filter((a) => {
|
|
499
|
+
const i = D.value.map((r) => {
|
|
500
|
+
const o = a.fields[r.field];
|
|
501
|
+
return me(o, r);
|
|
502
|
+
});
|
|
503
|
+
return K.value === "and" ? i.every(Boolean) : i.some(Boolean);
|
|
504
|
+
}));
|
|
505
|
+
const t = X.value;
|
|
506
|
+
return t.field && t.order && e.sort((a, i) => {
|
|
507
|
+
const r = F(
|
|
508
|
+
a.fields[t.field],
|
|
509
|
+
i.fields[t.field]
|
|
510
|
+
);
|
|
511
|
+
return t.order === "desc" ? -r : r;
|
|
512
|
+
}), e;
|
|
513
|
+
}), xe = n(
|
|
514
|
+
() => gt(I.value, {
|
|
515
|
+
startFieldId: c.value === "timeline" ? "startDate" : void 0,
|
|
516
|
+
endFieldId: c.value === "timeline" ? "endDate" : void 0,
|
|
517
|
+
labelFieldId: "title"
|
|
518
|
+
})
|
|
519
|
+
), $ = n(() => Ue.value ? "loading" : L.value ? "error" : c.value === "detail" ? Y.value ? "normal" : "empty" : c.value === "timeline" ? xe.value.length > 0 ? "normal" : "empty" : I.value.length > 0 ? "normal" : "empty"), qe = n(() => {
|
|
520
|
+
var a;
|
|
521
|
+
if (c.value !== "detail") return;
|
|
522
|
+
const e = h.value[0];
|
|
523
|
+
if (e)
|
|
524
|
+
return {
|
|
525
|
+
label: "打开第一条记录",
|
|
526
|
+
onClick: () => E(e)
|
|
527
|
+
};
|
|
528
|
+
const t = ((a = G.value.find((i) => i.value !== p)) == null ? void 0 : a.value) ?? null;
|
|
529
|
+
return ye(t);
|
|
530
|
+
});
|
|
531
|
+
function W(e) {
|
|
532
|
+
s.setRecords(e), d("update:records", e);
|
|
533
|
+
}
|
|
534
|
+
function E(e) {
|
|
535
|
+
e && (w.value = !0, s.setSelectedRecord(e));
|
|
536
|
+
}
|
|
537
|
+
function Z(e) {
|
|
538
|
+
return e ? h.value.find((t) => t.id === e) ?? null : null;
|
|
539
|
+
}
|
|
540
|
+
function ee(e) {
|
|
541
|
+
s.viewList.value.some((t) => t.id === e) && (e === p && (w.value = !0), s.switchView(e));
|
|
542
|
+
}
|
|
543
|
+
function Ke(e) {
|
|
544
|
+
ee(e);
|
|
545
|
+
}
|
|
546
|
+
function Ge(e) {
|
|
547
|
+
var t, a;
|
|
548
|
+
s.viewList.value.some((i) => i.id === e) && (e === p && (w.value = !0), s.switchView(e), d("load-view", e), (a = (t = l.actions) == null ? void 0 : t.onViewLoad) == null || a.call(t, { tableId: l.tableId, viewId: e }));
|
|
549
|
+
}
|
|
550
|
+
function ze(e) {
|
|
551
|
+
s.saveView({ name: e });
|
|
552
|
+
}
|
|
553
|
+
function A() {
|
|
554
|
+
s.updateActiveView({
|
|
555
|
+
filters: he(m.value)
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
function $e() {
|
|
559
|
+
var t;
|
|
560
|
+
const e = ((t = z.value.find((a) => !a.hidden)) == null ? void 0 : t.key) ?? "";
|
|
561
|
+
e && (m.value = [...m.value, we(e)], A());
|
|
562
|
+
}
|
|
563
|
+
function We(e) {
|
|
564
|
+
m.value = m.value.filter((t) => t.id !== e), A();
|
|
565
|
+
}
|
|
566
|
+
function je(e, t) {
|
|
567
|
+
m.value = m.value.map(
|
|
568
|
+
(a) => a.id === e ? { ...a, ...t } : a
|
|
569
|
+
), A();
|
|
570
|
+
}
|
|
571
|
+
function He() {
|
|
572
|
+
m.value = [], A();
|
|
573
|
+
}
|
|
574
|
+
function Me(e) {
|
|
575
|
+
K.value = e, d("update:filterLogic", e);
|
|
576
|
+
}
|
|
577
|
+
function Oe(e) {
|
|
578
|
+
d("update:columns", e), s.updateActiveView({
|
|
579
|
+
visibleFields: e.filter((t) => !t.hidden).map((t) => t.key)
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
function Pe(e) {
|
|
583
|
+
var i;
|
|
584
|
+
if (!e) {
|
|
585
|
+
s.updateActiveView({ sorts: [] }), d("sort", e);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
const t = (i = f.value.sorts) == null ? void 0 : i[0], a = (t == null ? void 0 : t.fieldId) === e && t.direction === "asc" ? "desc" : "asc";
|
|
589
|
+
s.updateActiveView({
|
|
590
|
+
sorts: [{ fieldId: e, direction: a }]
|
|
591
|
+
}), d("sort", e);
|
|
592
|
+
}
|
|
593
|
+
function Je(e) {
|
|
594
|
+
s.updateActiveView({
|
|
595
|
+
groups: e ? [{ fieldId: e }] : []
|
|
596
|
+
}), d("group", e);
|
|
597
|
+
}
|
|
598
|
+
function Qe(e) {
|
|
599
|
+
_.value = e, d("update:searchKeyword", e);
|
|
600
|
+
}
|
|
601
|
+
function C(e) {
|
|
602
|
+
s.emitSchemaEvent(e);
|
|
603
|
+
}
|
|
604
|
+
function Xe(e, t, a) {
|
|
605
|
+
const i = h.value.map((r) => r.id !== e ? r : {
|
|
606
|
+
...r,
|
|
607
|
+
fields: {
|
|
608
|
+
...r.fields,
|
|
609
|
+
[t]: a
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
W(i);
|
|
613
|
+
}
|
|
614
|
+
function te(e) {
|
|
615
|
+
Xe(e.rowId, e.fieldId, e.value), s.emitCellEdit(e);
|
|
616
|
+
}
|
|
617
|
+
function Ye(e) {
|
|
618
|
+
var t, a;
|
|
619
|
+
d("record-change", e), (a = (t = l.actions) == null ? void 0 : t.onRecordChange) == null || a.call(t, { tableId: l.tableId, ...e });
|
|
620
|
+
}
|
|
621
|
+
function Ze(e) {
|
|
622
|
+
W(e);
|
|
623
|
+
}
|
|
624
|
+
function et(e) {
|
|
625
|
+
E(e);
|
|
626
|
+
}
|
|
627
|
+
function tt(e) {
|
|
628
|
+
d("row-click", e);
|
|
629
|
+
}
|
|
630
|
+
function ae(e) {
|
|
631
|
+
d("card-click", e), E(Z(e.id));
|
|
632
|
+
}
|
|
633
|
+
function at(e) {
|
|
634
|
+
d("row-click", e), E(Z(e.sourceRecordId ?? e.id));
|
|
635
|
+
}
|
|
636
|
+
function it() {
|
|
637
|
+
w.value = !1, s.clearSelectedRecord();
|
|
638
|
+
}
|
|
639
|
+
function lt(e) {
|
|
640
|
+
const t = h.value.filter((a) => a.id !== e);
|
|
641
|
+
W(t), w.value = !1, s.clearSelectedRecord();
|
|
642
|
+
}
|
|
643
|
+
return (e, t) => {
|
|
644
|
+
var a;
|
|
645
|
+
return v(), g("section", nt({
|
|
646
|
+
class: "of-database-view",
|
|
647
|
+
"data-role": "database-view"
|
|
648
|
+
}, e.$attrs), [
|
|
649
|
+
$.value === "loading" ? (v(), g("div", Vt, [
|
|
650
|
+
N(j(ut), {
|
|
651
|
+
class: "of-database-view__spinner",
|
|
652
|
+
size: 20
|
|
653
|
+
}),
|
|
654
|
+
t[9] || (t[9] = H("div", { class: "of-database-view__state-text" }, [
|
|
655
|
+
H("div", { class: "of-database-view__state-title" }, "正在加载数据视图"),
|
|
656
|
+
H("div", { class: "of-database-view__state-description" }, "请稍候,页面级编排器正在准备当前视图。")
|
|
657
|
+
], -1))
|
|
658
|
+
])) : $.value === "error" ? (v(), g("div", _t, [
|
|
659
|
+
N(re, {
|
|
660
|
+
icon: j(ct),
|
|
661
|
+
title: "数据视图加载失败",
|
|
662
|
+
description: L.value instanceof Error ? L.value.message : String(L.value)
|
|
663
|
+
}, null, 8, ["icon", "description"])
|
|
664
|
+
])) : (v(), g(st, { key: 2 }, [
|
|
665
|
+
Re.value ? (v(), k(mt, {
|
|
666
|
+
key: 0,
|
|
667
|
+
class: "of-database-view__toolbar",
|
|
668
|
+
"current-view": x.value,
|
|
669
|
+
"view-tabs": G.value,
|
|
670
|
+
columns: z.value,
|
|
671
|
+
"filter-conditions": D.value,
|
|
672
|
+
"filter-logic": K.value,
|
|
673
|
+
"filter-active": Te.value,
|
|
674
|
+
"current-sort": X.value,
|
|
675
|
+
"current-group": ke.value,
|
|
676
|
+
"search-keyword": _.value,
|
|
677
|
+
"show-view-switch": De.value,
|
|
678
|
+
"show-filter": Le.value,
|
|
679
|
+
"show-sort": Ee.value,
|
|
680
|
+
"show-group": Ae.value,
|
|
681
|
+
"show-columns": Be.value,
|
|
682
|
+
"show-search": Ne.value,
|
|
683
|
+
"saved-views": _e.value,
|
|
684
|
+
"onUpdate:currentView": Ke,
|
|
685
|
+
"onUpdate:columns": Oe,
|
|
686
|
+
"onUpdate:searchKeyword": Qe,
|
|
687
|
+
onAddFilter: $e,
|
|
688
|
+
onRemoveFilter: We,
|
|
689
|
+
onUpdateFilter: je,
|
|
690
|
+
onClearFilters: He,
|
|
691
|
+
"onUpdate:filterLogic": Me,
|
|
692
|
+
onSort: Pe,
|
|
693
|
+
onGroup: Je,
|
|
694
|
+
onSaveView: ze,
|
|
695
|
+
onLoadView: Ge
|
|
696
|
+
}, null, 8, ["current-view", "view-tabs", "columns", "filter-conditions", "filter-logic", "filter-active", "current-sort", "current-group", "search-keyword", "show-view-switch", "show-filter", "show-sort", "show-group", "show-columns", "show-search", "saved-views"])) : dt("", !0),
|
|
697
|
+
$.value === "empty" ? (v(), g("div", It, [
|
|
698
|
+
N(re, {
|
|
699
|
+
icon: j(vt),
|
|
700
|
+
title: "暂无记录",
|
|
701
|
+
description: c.value === "detail" ? "请选择一条记录,详情工作区会在这里打开。" : c.value === "timeline" ? "当前时间线没有可渲染的起止日期。" : "当前视图没有匹配的数据,或者被筛选条件过滤为空。",
|
|
702
|
+
action: qe.value
|
|
703
|
+
}, null, 8, ["icon", "description", "action"])
|
|
704
|
+
])) : (v(), g("div", {
|
|
705
|
+
key: 2,
|
|
706
|
+
class: "of-database-view__content",
|
|
707
|
+
"data-view": c.value
|
|
708
|
+
}, [
|
|
709
|
+
c.value === "table" ? (v(), k(wt, {
|
|
710
|
+
key: 0,
|
|
711
|
+
class: "of-database-view__view of-database-view__view--table",
|
|
712
|
+
records: I.value,
|
|
713
|
+
schema: b.value ?? void 0,
|
|
714
|
+
view: f.value,
|
|
715
|
+
columns: z.value,
|
|
716
|
+
readonly: T.readonly,
|
|
717
|
+
"enable-field-management": ((a = T.ui) == null ? void 0 : a.enableFieldManagement) ?? !1,
|
|
718
|
+
onCellEdit: te,
|
|
719
|
+
onSchemaAddField: t[0] || (t[0] = (i) => C({ type: "schema-add-field", fieldType: i })),
|
|
720
|
+
onSchemaRenameField: t[1] || (t[1] = ({ fieldId: i, newName: r }) => C({ type: "schema-rename-field", fieldId: i, newName: r })),
|
|
721
|
+
onSchemaChangeFieldType: t[2] || (t[2] = ({ fieldId: i, newType: r }) => C({ type: "schema-change-field-type", fieldId: i, newType: r })),
|
|
722
|
+
onSchemaHideField: t[3] || (t[3] = (i) => C({ type: "schema-hide-field", fieldId: i })),
|
|
723
|
+
onSchemaDeleteField: t[4] || (t[4] = (i) => C({ type: "schema-delete-field", fieldId: i })),
|
|
724
|
+
onSchemaDuplicateField: t[5] || (t[5] = (i) => C({ type: "schema-duplicate-field", fieldId: i })),
|
|
725
|
+
onRowClick: tt,
|
|
726
|
+
onRowClickRecord: et
|
|
727
|
+
}, null, 8, ["records", "schema", "view", "columns", "readonly", "enable-field-management"])) : c.value === "kanban" ? (v(), k(pt, {
|
|
728
|
+
key: 1,
|
|
729
|
+
class: "of-database-view__view of-database-view__view--kanban",
|
|
730
|
+
records: I.value,
|
|
731
|
+
schema: b.value ?? void 0,
|
|
732
|
+
view: f.value,
|
|
733
|
+
onCardClick: ae,
|
|
734
|
+
"onUpdate:columns": t[6] || (t[6] = () => {
|
|
735
|
+
}),
|
|
736
|
+
onAddColumn: t[7] || (t[7] = () => d("add-column"))
|
|
737
|
+
}, null, 8, ["records", "schema", "view"])) : c.value === "gallery" ? (v(), k(ht, {
|
|
738
|
+
key: 2,
|
|
739
|
+
class: "of-database-view__view of-database-view__view--gallery",
|
|
740
|
+
records: I.value,
|
|
741
|
+
schema: b.value ?? void 0,
|
|
742
|
+
view: f.value,
|
|
743
|
+
onCardClick: ae,
|
|
744
|
+
onAdd: t[8] || (t[8] = () => d("add"))
|
|
745
|
+
}, null, 8, ["records", "schema", "view"])) : c.value === "timeline" ? (v(), k(bt, {
|
|
746
|
+
key: 3,
|
|
747
|
+
class: "of-database-view__view of-database-view__view--timeline",
|
|
748
|
+
records: I.value,
|
|
749
|
+
schema: b.value ?? void 0,
|
|
750
|
+
"view-config": f.value,
|
|
751
|
+
onRowClick: at,
|
|
752
|
+
onRecordChange: Ye,
|
|
753
|
+
"onUpdate:records": Ze
|
|
754
|
+
}, null, 8, ["records", "schema", "view-config"])) : (v(), g("div", Ft))
|
|
755
|
+
], 8, Ct))
|
|
756
|
+
], 64)),
|
|
757
|
+
N(ft, {
|
|
758
|
+
visible: Y.value,
|
|
759
|
+
row: Fe.value,
|
|
760
|
+
columns: Ie.value,
|
|
761
|
+
"field-defs": Ce.value,
|
|
762
|
+
"full-page": c.value === "detail",
|
|
763
|
+
readonly: T.readonly,
|
|
764
|
+
onClose: it,
|
|
765
|
+
onDelete: lt,
|
|
766
|
+
onCellEdit: te
|
|
767
|
+
}, null, 8, ["visible", "row", "columns", "field-defs", "full-page", "readonly"])
|
|
768
|
+
], 16);
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
export {
|
|
773
|
+
xt as default
|
|
774
|
+
};
|