@oneflowui/ui 0.4.3 → 0.5.0
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/assets/tableWorker-CTsbCPPP.js +1 -0
- package/dist/components/ContextMenu/index.vue.d.ts +2 -1
- package/dist/components/ContextMenu/index.vue.js +2 -2
- package/dist/components/ContextMenu/index.vue2.js +37 -36
- package/dist/components/base/DropdownMenu.vue.js +2 -2
- package/dist/components/base/DropdownMenu.vue2.js +38 -39
- package/dist/components/base/MonitorItem.vue.d.ts +1 -1
- package/dist/components/base/PersonaCard.vue.d.ts +2 -1
- package/dist/components/base/PersonaCard.vue.js +3 -3
- package/dist/components/base/PersonaCard.vue2.js +51 -39
- package/dist/components/base/RefTag.vue.d.ts +2 -2
- package/dist/components/base/RefTag.vue.js +3 -3
- package/dist/components/base/SearchHighlight.vue.d.ts +6 -0
- package/dist/components/base/SearchHighlight.vue.js +7 -0
- package/dist/components/base/SearchHighlight.vue2.js +21 -0
- package/dist/components/base/ToolbarBtn.vue.d.ts +2 -1
- package/dist/components/base/ToolbarBtn.vue.js +1 -1
- package/dist/components/base/ViewModeGroup.vue.d.ts +2 -1
- package/dist/components/base/ViewModeGroup.vue.js +3 -3
- package/dist/components/base/ViewSwitcher.vue.d.ts +2 -1
- package/dist/components/base/ViewSwitcher.vue.js +2 -2
- package/dist/components/base/index.d.ts +1 -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/components/field/FieldAttachment.vue.d.ts +17 -0
- package/dist/components/field/FieldAttachment.vue.js +7 -0
- package/dist/components/field/FieldAttachment.vue2.js +69 -0
- package/dist/components/field/FieldAutoNumber.vue.d.ts +7 -0
- package/dist/components/field/FieldAutoNumber.vue.js +7 -0
- package/dist/components/field/FieldAutoNumber.vue2.js +15 -0
- package/dist/components/field/FieldCreator.vue.d.ts +7 -0
- package/dist/components/field/FieldCreator.vue.js +7 -0
- package/dist/components/field/FieldCreator.vue2.js +24 -0
- package/dist/components/field/FieldCurrency.vue.d.ts +17 -0
- package/dist/components/field/FieldCurrency.vue.js +7 -0
- package/dist/components/field/FieldCurrency.vue2.js +42 -0
- package/dist/components/field/FieldDate.vue.js +2 -2
- package/dist/components/field/FieldDate.vue2.js +13 -10
- package/dist/components/field/FieldDatetime.vue.js +1 -1
- package/dist/components/field/FieldMarkdownPreview.vue.d.ts +13 -0
- package/dist/components/field/FieldMarkdownPreview.vue.js +7 -0
- package/dist/components/field/FieldMarkdownPreview.vue2.js +37 -0
- package/dist/components/field/FieldMultiSelect.vue.js +2 -2
- package/dist/components/field/FieldPhone.vue.d.ts +17 -0
- package/dist/components/field/FieldPhone.vue.js +7 -0
- package/dist/components/field/FieldPhone.vue2.js +34 -0
- package/dist/components/field/FieldProgress.vue.d.ts +15 -0
- package/dist/components/field/FieldProgress.vue.js +7 -0
- package/dist/components/field/FieldProgress.vue2.js +40 -0
- package/dist/components/field/FieldRelation.vue.d.ts +17 -0
- package/dist/components/field/FieldRelation.vue.js +7 -0
- package/dist/components/field/FieldRelation.vue2.js +67 -0
- package/dist/components/field/FieldRichText.vue.d.ts +17 -0
- package/dist/components/field/FieldRichText.vue.js +7 -0
- package/dist/components/field/FieldRichText.vue2.js +65 -0
- package/dist/components/field/FieldSelect.vue.js +1 -1
- package/dist/components/field/FieldSelect.vue2.js +43 -42
- package/dist/components/form/FormDesigner.vue.js +2 -2
- package/dist/components/form/FormDesigner.vue2.js +62 -52
- package/dist/components/gallery/GalleryCard.vue.js +2 -2
- package/dist/components/gallery/GalleryView.vue.d.ts +6 -2
- package/dist/components/gallery/GalleryView.vue.js +2 -2
- package/dist/components/gallery/GalleryView.vue2.js +30 -20
- package/dist/components/kanban/KanbanBoard.vue.d.ts +5 -1
- package/dist/components/kanban/KanbanBoard.vue.js +4 -4
- package/dist/components/kanban/KanbanBoard.vue2.js +81 -48
- package/dist/components/layout/AppLayout.vue.js +2 -2
- package/dist/components/layout/AppLayout.vue2.js +46 -62
- package/dist/components/overlay/Drawer.vue.js +1 -1
- package/dist/components/overlay/Drawer.vue2.js +52 -68
- package/dist/components/overlay/Modal.vue.js +1 -1
- package/dist/components/overlay/Modal.vue2.js +52 -68
- package/dist/components/overlay/SidePanel.vue.js +2 -2
- package/dist/components/overlay/SidePanel.vue2.js +64 -80
- package/dist/components/table/ColumnHeaderMenu.vue.d.ts +33 -0
- package/dist/components/table/ColumnHeaderMenu.vue.js +7 -0
- package/dist/components/table/ColumnHeaderMenu.vue2.js +153 -0
- package/dist/components/table/DataTable.vue.d.ts +116 -25
- package/dist/components/table/DataTable.vue.js +4 -4
- package/dist/components/table/DataTable.vue2.js +775 -188
- package/dist/components/table/DetailSheet.vue.d.ts +43 -0
- package/dist/components/table/DetailSheet.vue.js +7 -0
- package/dist/components/table/DetailSheet.vue2.js +140 -0
- package/dist/components/table/FieldCell.vue.d.ts +1 -1
- package/dist/components/table/FieldCell.vue.js +1 -1
- package/dist/components/table/FieldCell.vue2.js +59 -44
- package/dist/components/table/FieldTypePicker.vue.d.ts +15 -0
- package/dist/components/table/FieldTypePicker.vue.js +7 -0
- package/dist/components/table/FieldTypePicker.vue2.js +92 -0
- package/dist/components/table/MobileListView.vue.d.ts +24 -0
- package/dist/components/table/MobileListView.vue.js +7 -0
- package/dist/components/table/MobileListView.vue2.js +90 -0
- package/dist/components/table/TableGroupRow.vue.d.ts +5 -0
- package/dist/components/table/TableGroupRow.vue.js +2 -2
- package/dist/components/table/TableGroupRow.vue2.js +33 -23
- package/dist/components/table/TableHeaderRow.vue.d.ts +16 -0
- package/dist/components/table/TableHeaderRow.vue.js +2 -2
- package/dist/components/table/TableHeaderRow.vue2.js +54 -33
- package/dist/components/table/TableToolbar.vue.d.ts +118 -0
- package/dist/components/table/TableToolbar.vue.js +7 -0
- package/dist/components/table/TableToolbar.vue2.js +273 -0
- package/dist/components/table/index.d.ts +5 -0
- package/dist/components/timeline/GanttTimeline.vue.js +1 -1
- package/dist/components/timeline/GanttTimeline.vue2.js +128 -127
- package/dist/components/toast/ToastItem.vue.js +3 -3
- package/dist/composables/index.d.ts +21 -0
- package/dist/composables/useBreakpoint.d.ts +2 -1
- package/dist/composables/useBreakpoint.js +14 -12
- package/dist/composables/useColumnResize.d.ts +19 -0
- package/dist/composables/useColumnResize.js +58 -0
- package/dist/composables/useDatabaseView.d.ts +138 -0
- package/dist/composables/useDatabaseView.js +388 -0
- package/dist/composables/useDraftRows.d.ts +33 -0
- package/dist/composables/useDraftRows.js +103 -0
- package/dist/composables/useFixedColumns.d.ts +25 -0
- package/dist/composables/useFixedColumns.js +61 -0
- package/dist/composables/useFocusTrap.d.ts +10 -0
- package/dist/composables/useFocusTrap.js +37 -0
- package/dist/composables/useInlineEdit.js +3 -3
- package/dist/composables/useKeyboardNavigation.d.ts +45 -0
- package/dist/composables/useKeyboardNavigation.js +140 -0
- package/dist/composables/useRowDrag.d.ts +32 -0
- package/dist/composables/useRowDrag.js +85 -0
- package/dist/composables/useSchemaEngine.d.ts +31 -0
- package/dist/composables/useSchemaEngine.js +129 -0
- package/dist/composables/useSearch.d.ts +30 -0
- package/dist/composables/useSearch.js +59 -0
- package/dist/composables/useSupabaseProvider.d.ts +70 -0
- package/dist/composables/useSupabaseProvider.js +126 -0
- package/dist/composables/useTable.d.ts +3 -0
- package/dist/composables/useTable.js +103 -83
- package/dist/composables/useTableGroup.d.ts +14 -1
- package/dist/composables/useTableGroup.js +57 -33
- package/dist/composables/useViewPersistence.d.ts +98 -0
- package/dist/composables/useViewPersistence.js +141 -0
- package/dist/composables/useVirtualList.d.ts +4 -1
- package/dist/composables/useVirtualList.js +108 -85
- package/dist/composables/useWorkerSort.d.ts +14 -0
- package/dist/composables/useWorkerSort.js +61 -0
- package/dist/index.d.ts +32 -4
- package/dist/index.js +274 -221
- package/dist/style.css +1 -1
- package/dist/tests/database-view.integration.spec.d.ts +1 -0
- package/dist/types/index.d.ts +63 -2
- package/dist/types/index.js +23 -6
- package/dist/types/table-internal.d.ts +64 -0
- package/dist/utils/aggregation.d.ts +5 -0
- package/dist/utils/aggregation.js +38 -0
- package/dist/utils/supabaseAdapter.d.ts +48 -0
- package/dist/utils/supabaseAdapter.js +76 -0
- package/dist/utils/supabaseSchema.d.ts +81 -0
- package/dist/utils/supabaseSchema.js +202 -0
- package/dist/workers/tableWorker.d.ts +31 -0
- package/package.json +17 -17
|
@@ -0,0 +1,388 @@
|
|
|
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);
|
|
4
|
+
}
|
|
5
|
+
function G(l) {
|
|
6
|
+
if (l !== void 0)
|
|
7
|
+
return Le(l) ? l.value : l;
|
|
8
|
+
}
|
|
9
|
+
function _e(l) {
|
|
10
|
+
if (l)
|
|
11
|
+
return { ...l };
|
|
12
|
+
}
|
|
13
|
+
function z(l) {
|
|
14
|
+
var r, v, a, S;
|
|
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
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function ue(l) {
|
|
27
|
+
return l ? {
|
|
28
|
+
...l,
|
|
29
|
+
fields: l.fields.map((r) => ({ ...r })),
|
|
30
|
+
views: (l.views ?? []).map(z)
|
|
31
|
+
} : null;
|
|
32
|
+
}
|
|
33
|
+
function H(l) {
|
|
34
|
+
return l ? l.map((r) => ({
|
|
35
|
+
...r,
|
|
36
|
+
fields: { ...r.fields }
|
|
37
|
+
})) : [];
|
|
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)));
|
|
44
|
+
return v;
|
|
45
|
+
}
|
|
46
|
+
function K(l, r, v = (r == null ? void 0 : r.viewId) ?? "__default__") {
|
|
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)) ?? [];
|
|
49
|
+
return {
|
|
50
|
+
viewId: v,
|
|
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,
|
|
54
|
+
sorts: a == null ? void 0 : a.sorts,
|
|
55
|
+
groups: a == null ? void 0 : a.groups,
|
|
56
|
+
filters: a == null ? void 0 : a.filters,
|
|
57
|
+
aggregations: a == null ? void 0 : a.aggregations,
|
|
58
|
+
fixedColumns: a == null ? void 0 : a.fixedColumns,
|
|
59
|
+
galleryCardFields: a == null ? void 0 : a.galleryCardFields
|
|
60
|
+
};
|
|
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;
|
|
82
|
+
}
|
|
83
|
+
function Be(l) {
|
|
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
|
|
89
|
+
} : { field: null, order: null };
|
|
90
|
+
}
|
|
91
|
+
function Q(l, r) {
|
|
92
|
+
return l.some((v) => v.viewId === r);
|
|
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(
|
|
110
|
+
() => g.value.map((e) => ({
|
|
111
|
+
id: e.viewId,
|
|
112
|
+
name: e.name,
|
|
113
|
+
type: e.viewType
|
|
114
|
+
}))
|
|
115
|
+
), M = s(() => {
|
|
116
|
+
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));
|
|
121
|
+
}
|
|
122
|
+
function W(e) {
|
|
123
|
+
return d.value.findIndex((t) => t.id === e);
|
|
124
|
+
}
|
|
125
|
+
function ve(e) {
|
|
126
|
+
return d.value.find((t) => t.id === e) ?? null;
|
|
127
|
+
}
|
|
128
|
+
function fe(e) {
|
|
129
|
+
return W(e) >= 0;
|
|
130
|
+
}
|
|
131
|
+
function X(e) {
|
|
132
|
+
return e == null ? null : typeof e == "string" ? e : e.id;
|
|
133
|
+
}
|
|
134
|
+
function _() {
|
|
135
|
+
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);
|
|
137
|
+
}
|
|
138
|
+
function P() {
|
|
139
|
+
var e;
|
|
140
|
+
F.value && (!f.value || !fe(f.value)) && (f.value = ((e = d.value[0]) == null ? void 0 : e.id) ?? null);
|
|
141
|
+
}
|
|
142
|
+
function Y(e) {
|
|
143
|
+
F.value = !1, f.value = X(e);
|
|
144
|
+
}
|
|
145
|
+
function Z(e) {
|
|
146
|
+
F.value = !1, e !== void 0 && (f.value = X(e)), h.value = !0;
|
|
147
|
+
}
|
|
148
|
+
function ee(e) {
|
|
149
|
+
h.value = !1, e != null && e.clearSelection && (F.value = !1, f.value = null);
|
|
150
|
+
}
|
|
151
|
+
function se(e) {
|
|
152
|
+
if (h.value) {
|
|
153
|
+
ee();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
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)
|
|
166
|
+
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));
|
|
169
|
+
}
|
|
170
|
+
function we(e) {
|
|
171
|
+
le(1, e);
|
|
172
|
+
}
|
|
173
|
+
function Ie(e) {
|
|
174
|
+
le(-1, e);
|
|
175
|
+
}
|
|
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), _();
|
|
179
|
+
}
|
|
180
|
+
function te(e) {
|
|
181
|
+
V.value = V.value.filter((t) => t.viewId !== e);
|
|
182
|
+
}
|
|
183
|
+
function me(e) {
|
|
184
|
+
y.value = /* @__PURE__ */ new Set([...y.value, e]), te(e);
|
|
185
|
+
}
|
|
186
|
+
async function A() {
|
|
187
|
+
var i, c, o;
|
|
188
|
+
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
|
|
196
|
+
};
|
|
197
|
+
if (D.value = null, (i = l.actions) != null && i.onRefresh)
|
|
198
|
+
try {
|
|
199
|
+
await l.actions.onRefresh();
|
|
200
|
+
} catch (u) {
|
|
201
|
+
x(u);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if ((c = l.provider) != null && c.onRefresh)
|
|
205
|
+
try {
|
|
206
|
+
await l.provider.onRefresh(e);
|
|
207
|
+
} catch (u) {
|
|
208
|
+
x(u);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
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
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function ae(e) {
|
|
229
|
+
Q(g.value, e) && (m.value = e, L.value = 1, M.value && A());
|
|
230
|
+
}
|
|
231
|
+
function ge(e) {
|
|
232
|
+
ae(e);
|
|
233
|
+
}
|
|
234
|
+
async function he(e) {
|
|
235
|
+
var c, o;
|
|
236
|
+
const t = C.value, i = z({
|
|
237
|
+
...t,
|
|
238
|
+
...e,
|
|
239
|
+
viewId: t.viewId
|
|
240
|
+
});
|
|
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
|
+
}
|
|
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,
|
|
254
|
+
name: e
|
|
255
|
+
});
|
|
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;
|
|
263
|
+
}
|
|
264
|
+
async function Re(e) {
|
|
265
|
+
var c, o, u;
|
|
266
|
+
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
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async function Se(e, t) {
|
|
276
|
+
const i = g.value.find((c) => c.viewId === e);
|
|
277
|
+
return i ? ne(t, { ...i }) : "";
|
|
278
|
+
}
|
|
279
|
+
function ye(e) {
|
|
280
|
+
const t = z({
|
|
281
|
+
...C.value,
|
|
282
|
+
...e,
|
|
283
|
+
viewId: C.value.viewId
|
|
284
|
+
});
|
|
285
|
+
j(t);
|
|
286
|
+
}
|
|
287
|
+
function Ve(e) {
|
|
288
|
+
Y(e), f.value === null && (h.value = !1);
|
|
289
|
+
}
|
|
290
|
+
function xe() {
|
|
291
|
+
F.value = !1, f.value = null, h.value = !1;
|
|
292
|
+
}
|
|
293
|
+
function pe(e) {
|
|
294
|
+
L.value = Math.max(1, Math.floor(e) || 1), M.value && A();
|
|
295
|
+
}
|
|
296
|
+
function Fe(e) {
|
|
297
|
+
k.value = Math.max(1, Math.floor(e) || 1), L.value = 1, M.value && A();
|
|
298
|
+
}
|
|
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
|
+
}
|
|
306
|
+
}
|
|
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
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function ze(e) {
|
|
316
|
+
const t = H(e);
|
|
317
|
+
d.value = t, E.value = t.length, P();
|
|
318
|
+
}
|
|
319
|
+
return N(
|
|
320
|
+
a,
|
|
321
|
+
(e) => {
|
|
322
|
+
M.value && $.value || (d.value = e, E.value = e.length, P());
|
|
323
|
+
},
|
|
324
|
+
{ immediate: !0 }
|
|
325
|
+
), N(
|
|
326
|
+
b,
|
|
327
|
+
() => {
|
|
328
|
+
_();
|
|
329
|
+
},
|
|
330
|
+
{ immediate: !0, deep: !0 }
|
|
331
|
+
), N(
|
|
332
|
+
O,
|
|
333
|
+
() => {
|
|
334
|
+
var e, t;
|
|
335
|
+
(t = (e = l.actions) == null ? void 0 : e.onSelectRecord) == null || t.call(e, O.value);
|
|
336
|
+
},
|
|
337
|
+
{ immediate: !0, deep: !1, flush: "sync" }
|
|
338
|
+
), l.autoLoad !== !1 ? A() : (_(), P()), {
|
|
339
|
+
tableId: l.tableId,
|
|
340
|
+
mode: r,
|
|
341
|
+
schema: q,
|
|
342
|
+
records: d,
|
|
343
|
+
views: g,
|
|
344
|
+
activeViewId: m,
|
|
345
|
+
activeView: C,
|
|
346
|
+
selectedRecordId: f,
|
|
347
|
+
selectedRecord: O,
|
|
348
|
+
selectedRecordIndex: T,
|
|
349
|
+
selectedRecordOrdinal: re,
|
|
350
|
+
hasSelectedRecord: U,
|
|
351
|
+
detailOpen: h,
|
|
352
|
+
detailRecord: ce,
|
|
353
|
+
loading: n,
|
|
354
|
+
error: D,
|
|
355
|
+
page: L,
|
|
356
|
+
pageSize: k,
|
|
357
|
+
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
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
export {
|
|
387
|
+
Ae as useDatabaseView
|
|
388
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { CellValue, DataRecord, TableSchema } from '../types';
|
|
3
|
+
export interface UseDraftRowsOptions {
|
|
4
|
+
schema: Ref<TableSchema | undefined>;
|
|
5
|
+
groupFieldId?: Ref<string | undefined>;
|
|
6
|
+
}
|
|
7
|
+
export declare function useDraftRows(options: UseDraftRowsOptions): {
|
|
8
|
+
drafts: Readonly<Ref<ReadonlyMap<string, {
|
|
9
|
+
readonly draftId: string;
|
|
10
|
+
readonly fields: {
|
|
11
|
+
readonly [x: string]: string | number | boolean | readonly string[] | null;
|
|
12
|
+
};
|
|
13
|
+
readonly dirtyFields: ReadonlySet<string>;
|
|
14
|
+
readonly validationErrors: ReadonlyMap<string, string>;
|
|
15
|
+
readonly groupFieldValue?: string | number | boolean | readonly string[] | null | undefined;
|
|
16
|
+
}>, ReadonlyMap<string, {
|
|
17
|
+
readonly draftId: string;
|
|
18
|
+
readonly fields: {
|
|
19
|
+
readonly [x: string]: string | number | boolean | readonly string[] | null;
|
|
20
|
+
};
|
|
21
|
+
readonly dirtyFields: ReadonlySet<string>;
|
|
22
|
+
readonly validationErrors: ReadonlyMap<string, string>;
|
|
23
|
+
readonly groupFieldValue?: string | number | boolean | readonly string[] | null | undefined;
|
|
24
|
+
}>>>;
|
|
25
|
+
addDraft: (groupFieldValue?: CellValue) => string;
|
|
26
|
+
updateDraftField: (draftId: string, fieldId: string, value: CellValue) => void;
|
|
27
|
+
removeDraft: (draftId: string) => void;
|
|
28
|
+
commitDraft: (draftId: string) => DataRecord | null;
|
|
29
|
+
commitAll: () => DataRecord[];
|
|
30
|
+
discardAll: () => void;
|
|
31
|
+
isDraft: (rowId: string) => boolean;
|
|
32
|
+
getDraftErrors: (draftId: string) => Map<string, string>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ref as E, readonly as h } from "vue";
|
|
2
|
+
let g = 0;
|
|
3
|
+
function _() {
|
|
4
|
+
return `__draft__${++g}__${Date.now()}`;
|
|
5
|
+
}
|
|
6
|
+
function y(l) {
|
|
7
|
+
const n = E(/* @__PURE__ */ new Map());
|
|
8
|
+
function d(t) {
|
|
9
|
+
var i;
|
|
10
|
+
const e = _(), o = {}, r = l.schema.value;
|
|
11
|
+
if (r)
|
|
12
|
+
for (const D of r.fields)
|
|
13
|
+
o[D.id] = null;
|
|
14
|
+
const a = (i = l.groupFieldId) == null ? void 0 : i.value;
|
|
15
|
+
a && t !== void 0 && (o[a] = t);
|
|
16
|
+
const s = new Map(n.value);
|
|
17
|
+
return s.set(e, {
|
|
18
|
+
draftId: e,
|
|
19
|
+
fields: o,
|
|
20
|
+
dirtyFields: /* @__PURE__ */ new Set(),
|
|
21
|
+
validationErrors: /* @__PURE__ */ new Map(),
|
|
22
|
+
groupFieldValue: t
|
|
23
|
+
}), n.value = s, e;
|
|
24
|
+
}
|
|
25
|
+
function c(t, e, o) {
|
|
26
|
+
const r = n.value.get(t);
|
|
27
|
+
if (!r) return;
|
|
28
|
+
const a = new Map(n.value), s = {
|
|
29
|
+
...r,
|
|
30
|
+
fields: { ...r.fields, [e]: o },
|
|
31
|
+
dirtyFields: /* @__PURE__ */ new Set([...r.dirtyFields, e])
|
|
32
|
+
};
|
|
33
|
+
if (r.validationErrors.has(e)) {
|
|
34
|
+
const i = new Map(r.validationErrors);
|
|
35
|
+
i.delete(e), s.validationErrors = i;
|
|
36
|
+
}
|
|
37
|
+
a.set(t, s), n.value = a;
|
|
38
|
+
}
|
|
39
|
+
function f(t) {
|
|
40
|
+
const e = new Map(n.value);
|
|
41
|
+
e.delete(t), n.value = e;
|
|
42
|
+
}
|
|
43
|
+
function v(t) {
|
|
44
|
+
const e = n.value.get(t);
|
|
45
|
+
if (!e) return null;
|
|
46
|
+
const o = u(e);
|
|
47
|
+
if (o.size > 0) {
|
|
48
|
+
const a = new Map(n.value);
|
|
49
|
+
return a.set(t, { ...e, validationErrors: o }), n.value = a, null;
|
|
50
|
+
}
|
|
51
|
+
const r = {
|
|
52
|
+
id: t,
|
|
53
|
+
// Consumer should replace with server-generated id
|
|
54
|
+
fields: { ...e.fields }
|
|
55
|
+
};
|
|
56
|
+
return f(t), r;
|
|
57
|
+
}
|
|
58
|
+
function w() {
|
|
59
|
+
const t = [], e = /* @__PURE__ */ new Map();
|
|
60
|
+
for (const [o, r] of n.value) {
|
|
61
|
+
const a = u(r);
|
|
62
|
+
a.size > 0 ? e.set(o, { ...r, validationErrors: a }) : t.push({
|
|
63
|
+
id: o,
|
|
64
|
+
fields: { ...r.fields }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return n.value = e, t;
|
|
68
|
+
}
|
|
69
|
+
function p() {
|
|
70
|
+
n.value = /* @__PURE__ */ new Map();
|
|
71
|
+
}
|
|
72
|
+
function m(t) {
|
|
73
|
+
return n.value.has(t);
|
|
74
|
+
}
|
|
75
|
+
function M(t) {
|
|
76
|
+
var e;
|
|
77
|
+
return ((e = n.value.get(t)) == null ? void 0 : e.validationErrors) ?? /* @__PURE__ */ new Map();
|
|
78
|
+
}
|
|
79
|
+
function u(t) {
|
|
80
|
+
const e = /* @__PURE__ */ new Map(), o = l.schema.value;
|
|
81
|
+
if (!o) return e;
|
|
82
|
+
for (const r of o.fields)
|
|
83
|
+
if (r.required) {
|
|
84
|
+
const a = t.fields[r.id];
|
|
85
|
+
(a == null || a === "") && e.set(r.id, `${r.name} 为必填项`);
|
|
86
|
+
}
|
|
87
|
+
return e;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
drafts: h(n),
|
|
91
|
+
addDraft: d,
|
|
92
|
+
updateDraftField: c,
|
|
93
|
+
removeDraft: f,
|
|
94
|
+
commitDraft: v,
|
|
95
|
+
commitAll: w,
|
|
96
|
+
discardAll: p,
|
|
97
|
+
isDraft: m,
|
|
98
|
+
getDraftErrors: M
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
y as useDraftRows
|
|
103
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
import { TableColumn } from '../types';
|
|
3
|
+
export interface UseFixedColumnsOptions {
|
|
4
|
+
columns: Ref<TableColumn[]>;
|
|
5
|
+
fixedColumnKeys: Ref<string[]>;
|
|
6
|
+
scrollContainerRef: Ref<HTMLElement | null>;
|
|
7
|
+
fixedContainerRef: Ref<HTMLElement | null>;
|
|
8
|
+
/** Width of the selector checkbox column (default 40) */
|
|
9
|
+
selectorWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function useFixedColumns(options: UseFixedColumnsOptions): {
|
|
12
|
+
fixedColumns: ComputedRef<TableColumn[]>;
|
|
13
|
+
scrollableColumns: ComputedRef<TableColumn[]>;
|
|
14
|
+
fixedWidth: ComputedRef<number>;
|
|
15
|
+
handleScroll: (e: Event) => void;
|
|
16
|
+
handleFixedScroll: (e: Event) => void;
|
|
17
|
+
scrollLeft: Readonly<Ref<number, number>>;
|
|
18
|
+
syncHover: (rowId: string | null) => void;
|
|
19
|
+
isRowHovered: (rowId: string) => boolean;
|
|
20
|
+
hoverState: Readonly<Ref<{
|
|
21
|
+
readonly rowId: string | null;
|
|
22
|
+
}, {
|
|
23
|
+
readonly rowId: string | null;
|
|
24
|
+
}>>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ref as f, computed as a, onUnmounted as w, readonly as d } from "vue";
|
|
2
|
+
function A(n) {
|
|
3
|
+
const m = n.selectorWidth ?? 40, i = f(0), u = f({ rowId: null });
|
|
4
|
+
let o = null, r = null, c = null;
|
|
5
|
+
const s = a(() => {
|
|
6
|
+
const e = new Set(n.fixedColumnKeys.value);
|
|
7
|
+
return n.columns.value.filter((l) => e.has(l.key));
|
|
8
|
+
}), v = a(() => {
|
|
9
|
+
const e = new Set(n.fixedColumnKeys.value);
|
|
10
|
+
return n.columns.value.filter((l) => !e.has(l.key));
|
|
11
|
+
}), h = a(() => {
|
|
12
|
+
let e = m;
|
|
13
|
+
for (const l of s.value)
|
|
14
|
+
e += typeof l.width == "number" ? l.width : l.minWidth ?? 200;
|
|
15
|
+
return e;
|
|
16
|
+
});
|
|
17
|
+
function x(e) {
|
|
18
|
+
if (c === "fixed") {
|
|
19
|
+
c = null;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const l = e.target;
|
|
23
|
+
i.value = l.scrollLeft, o !== null && cancelAnimationFrame(o), o = requestAnimationFrame(() => {
|
|
24
|
+
const t = n.fixedContainerRef.value;
|
|
25
|
+
t && t !== l && (c = "scroll", t.scrollTop = l.scrollTop), o = null;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function y(e) {
|
|
29
|
+
if (c === "scroll") {
|
|
30
|
+
c = null;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const l = e.target;
|
|
34
|
+
r !== null && cancelAnimationFrame(r), r = requestAnimationFrame(() => {
|
|
35
|
+
const t = n.scrollContainerRef.value;
|
|
36
|
+
t && t !== l && (c = "fixed", t.scrollTop = l.scrollTop), r = null;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function F(e) {
|
|
40
|
+
u.value = { rowId: e };
|
|
41
|
+
}
|
|
42
|
+
function S(e) {
|
|
43
|
+
return u.value.rowId === e;
|
|
44
|
+
}
|
|
45
|
+
return w(() => {
|
|
46
|
+
o !== null && cancelAnimationFrame(o), r !== null && cancelAnimationFrame(r);
|
|
47
|
+
}), {
|
|
48
|
+
fixedColumns: s,
|
|
49
|
+
scrollableColumns: v,
|
|
50
|
+
fixedWidth: h,
|
|
51
|
+
handleScroll: x,
|
|
52
|
+
handleFixedScroll: y,
|
|
53
|
+
scrollLeft: d(i),
|
|
54
|
+
syncHover: F,
|
|
55
|
+
isRowHovered: S,
|
|
56
|
+
hoverState: d(u)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
A as useFixedColumns
|
|
61
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus trap composable — 管理 dialog/drawer/panel 的焦点陷阱
|
|
3
|
+
*
|
|
4
|
+
* 返回 containerRef(绑到容器元素),activate() 打开时调用,deactivate() 关闭时调用。
|
|
5
|
+
*/
|
|
6
|
+
export declare function useFocusTrap(): {
|
|
7
|
+
containerRef: import('vue').Ref<HTMLElement | null, HTMLElement | null>;
|
|
8
|
+
activate: () => void;
|
|
9
|
+
deactivate: () => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ref as f, onBeforeUnmount as s, nextTick as d } from "vue";
|
|
2
|
+
function v() {
|
|
3
|
+
const o = f(null);
|
|
4
|
+
let t = null;
|
|
5
|
+
function r() {
|
|
6
|
+
return o.value ? Array.from(
|
|
7
|
+
o.value.querySelectorAll(
|
|
8
|
+
'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), a[href]'
|
|
9
|
+
)
|
|
10
|
+
).filter((e) => !e.closest('[aria-hidden="true"]')) : [];
|
|
11
|
+
}
|
|
12
|
+
function u(e) {
|
|
13
|
+
if (e.key !== "Tab") return;
|
|
14
|
+
const n = r();
|
|
15
|
+
if (n.length === 0) {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const c = n[0], i = n[n.length - 1];
|
|
20
|
+
e.shiftKey ? document.activeElement === c && (e.preventDefault(), i.focus()) : document.activeElement === i && (e.preventDefault(), c.focus());
|
|
21
|
+
}
|
|
22
|
+
function l() {
|
|
23
|
+
t = document.activeElement, d(() => {
|
|
24
|
+
const e = r();
|
|
25
|
+
e.length && e[0].focus(), document.addEventListener("keydown", u);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function a() {
|
|
29
|
+
document.removeEventListener("keydown", u), t == null || t.focus(), t = null;
|
|
30
|
+
}
|
|
31
|
+
return s(() => {
|
|
32
|
+
document.removeEventListener("keydown", u);
|
|
33
|
+
}), { containerRef: o, activate: l, deactivate: a };
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
v as useFocusTrap
|
|
37
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const n = f(null);
|
|
1
|
+
import { ref as c, readonly as f } from "vue";
|
|
3
2
|
function I() {
|
|
3
|
+
const n = c(null);
|
|
4
4
|
function o(e, l) {
|
|
5
5
|
n.value = { rowId: e, fieldId: l };
|
|
6
6
|
}
|
|
@@ -16,7 +16,7 @@ function I() {
|
|
|
16
16
|
return ((u = n.value) == null ? void 0 : u.rowId) === e && ((i = n.value) == null ? void 0 : i.fieldId) === l;
|
|
17
17
|
}
|
|
18
18
|
return {
|
|
19
|
-
editingCell:
|
|
19
|
+
editingCell: f(n),
|
|
20
20
|
activate: o,
|
|
21
21
|
commit: r,
|
|
22
22
|
cancel: a,
|