@oneflowui/ui 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +19 -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/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 +28 -4
- package/dist/index.js +264 -216
- package/dist/style.css +1 -1
- 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 +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { ref as v, computed as y, readonly as w } from "vue";
|
|
2
|
+
const f = "oneui-views:";
|
|
3
|
+
function E() {
|
|
4
|
+
return {
|
|
5
|
+
async load(t) {
|
|
6
|
+
try {
|
|
7
|
+
const l = localStorage.getItem(`${f}${t}`);
|
|
8
|
+
return l ? JSON.parse(l) : [];
|
|
9
|
+
} catch {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
async save(t, l) {
|
|
14
|
+
const e = await this.load(t), i = e.findIndex((c) => c.viewId === l.viewId);
|
|
15
|
+
i >= 0 ? e[i] = l : e.push(l), localStorage.setItem(`${f}${t}`, JSON.stringify(e));
|
|
16
|
+
},
|
|
17
|
+
async remove(t, l) {
|
|
18
|
+
const i = (await this.load(t)).filter((c) => c.viewId !== l);
|
|
19
|
+
localStorage.setItem(`${f}${t}`, JSON.stringify(i));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function O(t) {
|
|
24
|
+
const l = t.tableName ?? "view_configs";
|
|
25
|
+
return {
|
|
26
|
+
async load(e) {
|
|
27
|
+
const { data: i, error: c } = await t.client.from(l).select("config").eq("table_id", e).order("created_at", { ascending: !0 });
|
|
28
|
+
if (c) throw new Error(c.message);
|
|
29
|
+
return (i ?? []).map((u) => u.config);
|
|
30
|
+
},
|
|
31
|
+
async save(e, i) {
|
|
32
|
+
const { error: c } = await t.client.from(l).upsert(
|
|
33
|
+
{
|
|
34
|
+
table_id: e,
|
|
35
|
+
view_id: i.viewId,
|
|
36
|
+
config: i,
|
|
37
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
38
|
+
},
|
|
39
|
+
{ onConflict: "table_id,view_id" }
|
|
40
|
+
);
|
|
41
|
+
if (c) throw new Error(c.message);
|
|
42
|
+
},
|
|
43
|
+
async remove(e, i) {
|
|
44
|
+
const { error: c } = await t.client.from(l).delete().eq("table_id", e).eq("view_id", i);
|
|
45
|
+
if (c) throw new Error(c.message);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function p() {
|
|
50
|
+
return `view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
|
|
51
|
+
}
|
|
52
|
+
const g = {
|
|
53
|
+
viewId: "__default__",
|
|
54
|
+
viewType: "table",
|
|
55
|
+
name: "全部记录",
|
|
56
|
+
visibleFields: []
|
|
57
|
+
};
|
|
58
|
+
function k(t) {
|
|
59
|
+
var m;
|
|
60
|
+
const l = t.backend ?? E(), e = v([]), i = v(((m = t.defaultView) == null ? void 0 : m.viewId) ?? "__default__"), c = v(!1), u = v(null), o = y(() => e.value.find((a) => a.viewId === i.value) ?? t.defaultView ?? g), V = y(
|
|
61
|
+
() => e.value.map((a) => ({ id: a.viewId, name: a.name, type: a.viewType }))
|
|
62
|
+
);
|
|
63
|
+
async function _() {
|
|
64
|
+
var a;
|
|
65
|
+
c.value = !0, u.value = null;
|
|
66
|
+
try {
|
|
67
|
+
const r = await l.load(t.tableId);
|
|
68
|
+
e.value = r.length > 0 ? r : t.defaultView ? [t.defaultView] : [{ ...g }], e.value.find((n) => n.viewId === i.value) || (i.value = ((a = e.value[0]) == null ? void 0 : a.viewId) ?? "__default__");
|
|
69
|
+
} catch (r) {
|
|
70
|
+
u.value = r;
|
|
71
|
+
} finally {
|
|
72
|
+
c.value = !1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function h(a) {
|
|
76
|
+
const n = { ...o.value, ...a }, d = e.value.findIndex((s) => s.viewId === n.viewId);
|
|
77
|
+
d >= 0 ? e.value[d] = n : e.value.push(n);
|
|
78
|
+
try {
|
|
79
|
+
await l.save(t.tableId, n);
|
|
80
|
+
} catch (s) {
|
|
81
|
+
u.value = s;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function I(a, r) {
|
|
85
|
+
const n = p(), d = {
|
|
86
|
+
...o.value,
|
|
87
|
+
...r,
|
|
88
|
+
viewId: n,
|
|
89
|
+
name: a
|
|
90
|
+
};
|
|
91
|
+
e.value.push(d), i.value = n;
|
|
92
|
+
try {
|
|
93
|
+
await l.save(t.tableId, d);
|
|
94
|
+
} catch (s) {
|
|
95
|
+
u.value = s;
|
|
96
|
+
}
|
|
97
|
+
return n;
|
|
98
|
+
}
|
|
99
|
+
async function b(a) {
|
|
100
|
+
var r;
|
|
101
|
+
if (a !== "__default__") {
|
|
102
|
+
e.value = e.value.filter((n) => n.viewId !== a), i.value === a && (i.value = ((r = e.value[0]) == null ? void 0 : r.viewId) ?? "__default__");
|
|
103
|
+
try {
|
|
104
|
+
await l.remove(t.tableId, a);
|
|
105
|
+
} catch (n) {
|
|
106
|
+
u.value = n;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function S(a) {
|
|
111
|
+
e.value.find((r) => r.viewId === a) && (i.value = a);
|
|
112
|
+
}
|
|
113
|
+
async function $(a, r) {
|
|
114
|
+
const n = e.value.find((d) => d.viewId === a);
|
|
115
|
+
return n ? I(r, { ...n }) : "";
|
|
116
|
+
}
|
|
117
|
+
function x(a) {
|
|
118
|
+
const r = e.value.findIndex((n) => n.viewId === i.value);
|
|
119
|
+
r >= 0 && (e.value[r] = { ...e.value[r], ...a });
|
|
120
|
+
}
|
|
121
|
+
return t.autoLoad !== !1 && _(), {
|
|
122
|
+
views: w(e),
|
|
123
|
+
activeView: o,
|
|
124
|
+
activeViewId: i,
|
|
125
|
+
viewList: V,
|
|
126
|
+
loading: w(c),
|
|
127
|
+
error: w(u),
|
|
128
|
+
loadViews: _,
|
|
129
|
+
saveView: h,
|
|
130
|
+
createView: I,
|
|
131
|
+
deleteView: b,
|
|
132
|
+
switchView: S,
|
|
133
|
+
duplicateView: $,
|
|
134
|
+
updateActiveView: x
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
E as createLocalStorageBackend,
|
|
139
|
+
O as createSupabaseBackend,
|
|
140
|
+
k as useViewPersistence
|
|
141
|
+
};
|
|
@@ -4,15 +4,18 @@ export interface UseVirtualListOptions<T> {
|
|
|
4
4
|
itemHeight: number | ((index: number) => number);
|
|
5
5
|
overscan?: number;
|
|
6
6
|
containerRef: Ref<HTMLElement | null>;
|
|
7
|
+
/** Optional callback to measure actual row height after render. When provided, measured heights override itemHeight. */
|
|
8
|
+
measureRow?: boolean;
|
|
7
9
|
}
|
|
8
10
|
export type VirtualItem<T> = {
|
|
9
11
|
data: T;
|
|
10
12
|
index: number;
|
|
11
13
|
};
|
|
12
|
-
export declare function useVirtualList<T>(
|
|
14
|
+
export declare function useVirtualList<T>(options: UseVirtualListOptions<T>): {
|
|
13
15
|
visibleItems: ComputedRef<VirtualItem<T>[]>;
|
|
14
16
|
totalHeight: ComputedRef<number>;
|
|
15
17
|
offsetY: ComputedRef<number>;
|
|
16
18
|
scrollToIndex: (index: number) => void;
|
|
17
19
|
scrollToBottom: () => void;
|
|
20
|
+
observeRow: (el: HTMLElement | null, index: number) => void;
|
|
18
21
|
};
|
|
@@ -1,117 +1,140 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
itemHeight:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const o = O(0), s = O(0), h = typeof i == "number", v = Math.max(0, E);
|
|
9
|
-
let c = null, a = null;
|
|
10
|
-
const d = f(() => {
|
|
11
|
-
if (h) return [];
|
|
12
|
-
const t = new Array(l.value.length + 1).fill(0), n = i;
|
|
13
|
-
for (let e = 0; e < l.value.length; e += 1)
|
|
14
|
-
t[e + 1] = t[e] + Math.max(0, n(e));
|
|
15
|
-
return t;
|
|
16
|
-
}), M = f(() => h ? l.value.length * i : d.value[l.value.length] ?? 0);
|
|
17
|
-
function m(t) {
|
|
18
|
-
const n = Math.max(0, Math.min(t, l.value.length));
|
|
19
|
-
return h ? n * i : d.value[n] ?? 0;
|
|
1
|
+
import { ref as w, computed as M, watch as L, onUnmounted as N } from "vue";
|
|
2
|
+
function W(I) {
|
|
3
|
+
var S;
|
|
4
|
+
const { items: n, itemHeight: c, overscan: V = 5, containerRef: B } = I, u = w(0), v = w(0), f = typeof c == "number", m = Math.max(0, V), a = /* @__PURE__ */ new Map(), T = w(0);
|
|
5
|
+
let d = null, h = null, r = null;
|
|
6
|
+
function U(e) {
|
|
7
|
+
return a.has(e) ? a.get(e) : f ? c : c(e);
|
|
20
8
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
9
|
+
function A() {
|
|
10
|
+
!I.measureRow || typeof ResizeObserver > "u" || (h = new ResizeObserver((e) => {
|
|
11
|
+
let t = !1;
|
|
12
|
+
for (const l of e) {
|
|
13
|
+
const i = l.target.dataset.virtualIndex;
|
|
14
|
+
if (i == null) continue;
|
|
15
|
+
const s = parseInt(i, 10), g = l.contentRect.height;
|
|
16
|
+
a.get(s) !== g && (a.set(s, g), t = !0);
|
|
17
|
+
}
|
|
18
|
+
t && T.value++;
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
A();
|
|
22
|
+
function P(e, t) {
|
|
23
|
+
!e || !h || (e.dataset.virtualIndex = String(t), h.observe(e));
|
|
24
|
+
}
|
|
25
|
+
const p = M(() => {
|
|
26
|
+
if (T.value, f && a.size === 0) return [];
|
|
27
|
+
const e = new Array(n.value.length + 1).fill(0);
|
|
28
|
+
for (let t = 0; t < n.value.length; t += 1)
|
|
29
|
+
e[t + 1] = e[t] + Math.max(0, U(t));
|
|
30
|
+
return e;
|
|
31
|
+
}), x = M(() => f && a.size === 0 ? n.value.length * c : p.value[n.value.length] ?? 0);
|
|
32
|
+
function H(e) {
|
|
33
|
+
const t = Math.max(0, Math.min(e, n.value.length));
|
|
34
|
+
return f && a.size === 0 ? t * c : p.value[t] ?? 0;
|
|
35
|
+
}
|
|
36
|
+
function R(e) {
|
|
37
|
+
if (n.value.length === 0) return 0;
|
|
38
|
+
if (f && a.size === 0) {
|
|
39
|
+
const i = c;
|
|
25
40
|
return Math.max(
|
|
26
41
|
0,
|
|
27
|
-
Math.min(
|
|
42
|
+
Math.min(n.value.length - 1, Math.floor(Math.max(0, e) / i))
|
|
28
43
|
);
|
|
29
44
|
}
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
for (;
|
|
33
|
-
const
|
|
34
|
-
|
|
45
|
+
const t = p.value;
|
|
46
|
+
let l = 0, o = n.value.length;
|
|
47
|
+
for (; l < o; ) {
|
|
48
|
+
const i = Math.floor((l + o) / 2);
|
|
49
|
+
t[i + 1] <= e ? l = i + 1 : o = i;
|
|
35
50
|
}
|
|
36
|
-
return Math.max(0, Math.min(
|
|
51
|
+
return Math.max(0, Math.min(l, n.value.length - 1));
|
|
37
52
|
}
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
53
|
+
const z = M(() => {
|
|
54
|
+
const e = n.value.length;
|
|
55
|
+
if (e === 0)
|
|
41
56
|
return { start: 0, end: 0 };
|
|
42
|
-
if (
|
|
43
|
-
return { start: 0, end: Math.min(
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
return { start:
|
|
57
|
+
if (v.value <= 0)
|
|
58
|
+
return { start: 0, end: Math.min(e, m * 2 + 1) };
|
|
59
|
+
if (f && a.size === 0) {
|
|
60
|
+
const s = c, g = Math.floor(u.value / s), G = Math.ceil(v.value / s), J = Math.max(0, g - m), K = Math.min(e, g + G + m);
|
|
61
|
+
return { start: J, end: K };
|
|
47
62
|
}
|
|
48
|
-
const
|
|
63
|
+
const t = Math.max(0, u.value), l = t + v.value, o = R(t), i = Math.min(e - 1, R(l));
|
|
49
64
|
return {
|
|
50
|
-
start: Math.max(0,
|
|
51
|
-
end: Math.min(
|
|
65
|
+
start: Math.max(0, o - m),
|
|
66
|
+
end: Math.min(e, i + m + 1)
|
|
52
67
|
};
|
|
53
|
-
}),
|
|
54
|
-
const { start:
|
|
55
|
-
return
|
|
56
|
-
data:
|
|
57
|
-
index:
|
|
68
|
+
}), Y = M(() => H(z.value.start)), j = M(() => {
|
|
69
|
+
const { start: e, end: t } = z.value;
|
|
70
|
+
return n.value.slice(e, t).map((l, o) => ({
|
|
71
|
+
data: l,
|
|
72
|
+
index: e + o
|
|
58
73
|
}));
|
|
59
74
|
});
|
|
60
|
-
function
|
|
61
|
-
if (!
|
|
62
|
-
|
|
75
|
+
function b(e) {
|
|
76
|
+
if (!e) {
|
|
77
|
+
u.value = 0, v.value = 0;
|
|
63
78
|
return;
|
|
64
79
|
}
|
|
65
|
-
|
|
80
|
+
u.value = e.scrollTop, v.value = e.clientHeight;
|
|
66
81
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
82
|
+
function C() {
|
|
83
|
+
r && (u.value = r.scrollTop);
|
|
69
84
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
85
|
+
function y() {
|
|
86
|
+
d == null || d.disconnect(), d = null;
|
|
72
87
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
88
|
+
function O(e) {
|
|
89
|
+
e && e.removeEventListener("scroll", C);
|
|
75
90
|
}
|
|
76
|
-
function
|
|
77
|
-
if (!
|
|
78
|
-
|
|
91
|
+
function k(e) {
|
|
92
|
+
if (!e) {
|
|
93
|
+
r = null, b(null);
|
|
79
94
|
return;
|
|
80
95
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}),
|
|
96
|
+
r = e, e.addEventListener("scroll", C, { passive: !0 }), b(e), typeof ResizeObserver < "u" && (d = new ResizeObserver(() => {
|
|
97
|
+
b(e);
|
|
98
|
+
}), d.observe(e));
|
|
84
99
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
(
|
|
88
|
-
|
|
100
|
+
L(
|
|
101
|
+
B,
|
|
102
|
+
(e, t) => {
|
|
103
|
+
O(t), y(), k(e);
|
|
89
104
|
},
|
|
90
105
|
{ immediate: !0 }
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
);
|
|
107
|
+
let E = n.value.length, F = n.value.length > 0 ? (S = n.value[0]) == null ? void 0 : S.id : void 0;
|
|
108
|
+
L(n, (e) => {
|
|
109
|
+
var s;
|
|
110
|
+
const t = e.length, l = t > 0 ? (s = e[0]) == null ? void 0 : s.id : void 0, o = t === E && l === F;
|
|
111
|
+
if (E = t, F = l, o)
|
|
112
|
+
return;
|
|
113
|
+
a.clear();
|
|
114
|
+
const i = Math.max(0, x.value - v.value);
|
|
115
|
+
u.value > i && (u.value = i, r && (r.scrollTop = i));
|
|
94
116
|
});
|
|
95
|
-
function
|
|
96
|
-
if (!
|
|
97
|
-
const
|
|
98
|
-
|
|
117
|
+
function q(e) {
|
|
118
|
+
if (!r || n.value.length === 0) return;
|
|
119
|
+
const t = Math.max(0, Math.min(e, n.value.length - 1)), l = H(t);
|
|
120
|
+
r.scrollTop = l, u.value = l;
|
|
99
121
|
}
|
|
100
|
-
function
|
|
101
|
-
if (!
|
|
102
|
-
const
|
|
103
|
-
|
|
122
|
+
function D() {
|
|
123
|
+
if (!r) return;
|
|
124
|
+
const e = Math.max(0, x.value - r.clientHeight);
|
|
125
|
+
r.scrollTop = e, u.value = e;
|
|
104
126
|
}
|
|
105
|
-
return
|
|
106
|
-
|
|
127
|
+
return N(() => {
|
|
128
|
+
O(r), y(), h == null || h.disconnect(), h = null, r = null;
|
|
107
129
|
}), {
|
|
108
|
-
visibleItems:
|
|
109
|
-
totalHeight:
|
|
110
|
-
offsetY:
|
|
111
|
-
scrollToIndex:
|
|
112
|
-
scrollToBottom:
|
|
130
|
+
visibleItems: j,
|
|
131
|
+
totalHeight: x,
|
|
132
|
+
offsetY: Y,
|
|
133
|
+
scrollToIndex: q,
|
|
134
|
+
scrollToBottom: D,
|
|
135
|
+
observeRow: P
|
|
113
136
|
};
|
|
114
137
|
}
|
|
115
138
|
export {
|
|
116
|
-
|
|
139
|
+
W as useVirtualList
|
|
117
140
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
export interface UseWorkerSortOptions {
|
|
3
|
+
/** Whether to enable worker offloading (default: auto based on threshold) */
|
|
4
|
+
enabled?: Ref<boolean>;
|
|
5
|
+
}
|
|
6
|
+
export declare function useWorkerSort<T extends Record<string, unknown>>(options?: UseWorkerSortOptions): {
|
|
7
|
+
requestSort: (data: T[], field: string, order: "asc" | "desc") => Promise<T[]>;
|
|
8
|
+
requestFilter: (data: T[], conditions: Array<{
|
|
9
|
+
field: string;
|
|
10
|
+
operator: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}>, logic?: "and" | "or") => Promise<T[]>;
|
|
13
|
+
processing: Readonly<Ref<boolean, boolean>>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ref as v, onUnmounted as y, readonly as P } from "vue";
|
|
2
|
+
const S = 5e3;
|
|
3
|
+
function d(c = {}) {
|
|
4
|
+
const i = v(!1);
|
|
5
|
+
let n = null;
|
|
6
|
+
function f() {
|
|
7
|
+
if (n) return n;
|
|
8
|
+
try {
|
|
9
|
+
return n = new Worker(new URL(
|
|
10
|
+
/* @vite-ignore */
|
|
11
|
+
"/assets/tableWorker-CTsbCPPP.js",
|
|
12
|
+
import.meta.url
|
|
13
|
+
), {
|
|
14
|
+
type: "module"
|
|
15
|
+
}), n;
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function m(e) {
|
|
21
|
+
var s;
|
|
22
|
+
return ((s = c.enabled) == null ? void 0 : s.value) === !1 ? !1 : e >= S;
|
|
23
|
+
}
|
|
24
|
+
function p(e, s, a) {
|
|
25
|
+
if (!m(e.length))
|
|
26
|
+
return Promise.resolve(
|
|
27
|
+
[...e].sort((o, u) => {
|
|
28
|
+
const r = o[s], l = u[s];
|
|
29
|
+
return r == null && l == null ? 0 : r == null ? 1 : l == null ? -1 : typeof r == "number" && typeof l == "number" ? a === "asc" ? r - l : l - r : a === "asc" ? String(r).localeCompare(String(l)) : String(l).localeCompare(String(r));
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
const t = f();
|
|
33
|
+
return t ? (i.value = !0, new Promise((o) => {
|
|
34
|
+
const u = (r) => {
|
|
35
|
+
t.removeEventListener("message", u), i.value = !1, r.data.type === "sort-result" ? o(r.data.data) : o([...e]);
|
|
36
|
+
};
|
|
37
|
+
t.addEventListener("message", u), t.postMessage({ type: "sort", data: e, field: s, order: a });
|
|
38
|
+
})) : Promise.resolve([...e]);
|
|
39
|
+
}
|
|
40
|
+
function g(e, s, a = "and") {
|
|
41
|
+
if (!m(e.length))
|
|
42
|
+
return Promise.resolve(e);
|
|
43
|
+
const t = f();
|
|
44
|
+
return t ? (i.value = !0, new Promise((o) => {
|
|
45
|
+
const u = (r) => {
|
|
46
|
+
t.removeEventListener("message", u), i.value = !1, r.data.type === "filter-result" ? o(r.data.data) : o(e);
|
|
47
|
+
};
|
|
48
|
+
t.addEventListener("message", u), t.postMessage({ type: "filter", data: e, conditions: s, logic: a });
|
|
49
|
+
})) : Promise.resolve(e);
|
|
50
|
+
}
|
|
51
|
+
return y(() => {
|
|
52
|
+
n == null || n.terminate(), n = null;
|
|
53
|
+
}), {
|
|
54
|
+
requestSort: p,
|
|
55
|
+
requestFilter: g,
|
|
56
|
+
processing: P(i)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
d as useWorkerSort
|
|
61
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
|
-
export { ViewTab, ToolbarBtn, AddViewBtn, Badge, RangeSlider, ProgressBar, ButtonGroup, EmptyState, StatisticCard, DropdownMenu, StatusIndicator, Switch, Stepper, Accordion, Avatar, RefTag, DescBlock, ViewModeGroup, ViewSwitcher, SelectBadge, ChainItem, SectionBlock, MonitorItem, StatusSummary, InfoCard, PersonaCard, } from './components/base';
|
|
2
|
+
export { ViewTab, ToolbarBtn, AddViewBtn, Badge, RangeSlider, ProgressBar, ButtonGroup, EmptyState, StatisticCard, DropdownMenu, StatusIndicator, Switch, Stepper, Accordion, Avatar, RefTag, DescBlock, ViewModeGroup, ViewSwitcher, SelectBadge, ChainItem, SectionBlock, MonitorItem, StatusSummary, InfoCard, PersonaCard, SearchHighlight, } from './components/base';
|
|
3
3
|
export type { ButtonOption, EmptyStateAction, MenuItem, StepItem, StepperProps, StepStatus, AvatarProps, RefTagProps, ViewModeOption, ViewModeGroupProps, ViewSwitcherTab, ViewSwitcherProps, SelectBadgeProps, ChainItemProps, SectionBlockProps, MonitorItemProps, StatusSummaryProps, StatusSummaryItem, InfoCardProps, PersonaCardProps, } from './components/base';
|
|
4
4
|
export { AppLayout, Navbar, Sidebar, StatusBar } from './components/layout';
|
|
5
|
-
export {
|
|
5
|
+
export { default as FieldMarkdownPreview } from './components/field/FieldMarkdownPreview.vue';
|
|
6
|
+
export { DataTable, TableHeaderRow, TableDataRow, TableGroupRow, NewRowBtn, TableFilterPanel, TableColumnManager, TableToolbar, FieldCell, FieldTypePicker, ColumnHeaderMenu, } from './components/table';
|
|
6
7
|
export { GalleryView, GalleryCard } from './components/gallery';
|
|
7
8
|
export { ActivityTimeline, GanttTimeline, GanttRow } from './components/timeline';
|
|
8
9
|
export type { ActivityTimelineProps, ActivityTimelineStatus, TimelineItem, } from './components/timeline';
|
|
@@ -23,8 +24,10 @@ export { MermaidChart } from './components/mermaid';
|
|
|
23
24
|
export { SplitPane } from './components/split';
|
|
24
25
|
export { default as ContextMenu } from './components/ContextMenu/index.vue';
|
|
25
26
|
export type { ContextMenuItem } from './components/ContextMenu/index.vue';
|
|
26
|
-
export type { Task, Priority, TaskStatus, ViewType, FieldType, FieldDefBase, FieldDef, TextFieldDef, NumberFieldDef, SelectFieldDef, DateFieldDef, CheckboxFieldDef, ContactFieldDef, RatingFieldDef, UserFieldDef, AttachmentFieldDef, RelationFieldDef, FormulaFieldDef, SelectOption, CellValue, DataRecord, SortConfig, GroupConfig, FilterCondition as SchemaFilterCondition, ViewConfig, TableSchema, ViewTabItem, TableColumn, KanbanColumnData, GalleryItem, GanttItem, PropItem, CommentData, SidebarItem, BadgeConfig, ColorMap, } from './types';
|
|
27
|
-
export { isSelectField, isFormulaField, taskToDataRecord, dataRecordToTask, buildKanbanColumns, buildGalleryItems, } from './types';
|
|
27
|
+
export type { Task, Priority, TaskStatus, ViewType, FieldType, FieldDefBase, FieldDef, TextFieldDef, NumberFieldDef, SelectFieldDef, DateFieldDef, CheckboxFieldDef, ContactFieldDef, RatingFieldDef, UserFieldDef, AttachmentFieldDef, RelationFieldDef, FormulaFieldDef, SelectOption, CellValue, ActiveCell, AggregationFn, AggregationConfig, DraftRowState, DataRecord, SortConfig, GroupConfig, FilterCondition as SchemaFilterCondition, ViewConfig, TableSchema, CurrencyFieldDef, RichTextFieldDef, AutoNumberFieldDef, CreatorFieldDef, ProgressFieldDef, ViewTabItem, TableColumn, KanbanColumnData, GalleryItem, GanttItem, PropItem, CommentData, SidebarItem, BadgeConfig, ColorMap, } from './types';
|
|
28
|
+
export { isSelectField, isFormulaField, taskToDataRecord, dataRecordToTask, buildKanbanColumns, buildGalleryItems, buildGanttItems, } from './types';
|
|
29
|
+
export { rowToDataRecord, rowsToDataRecords, dataRecordToRow, fieldsToRow, useSupabaseAdapter, } from './utils/supabaseAdapter';
|
|
30
|
+
export type { RowAdapterOptions, UseSupabaseAdapterOptions } from './utils/supabaseAdapter';
|
|
28
31
|
export type { ChatMessage, UseAiChatOptions } from './composables/useAiChat';
|
|
29
32
|
export type { UseStreamOptions, StreamMode, RetryOptions } from './composables/useStream';
|
|
30
33
|
export type { UseTypewriterOptions } from './composables/useTypewriter';
|
|
@@ -34,6 +37,14 @@ export type { UseMarkdownOptions } from './composables/useMarkdown';
|
|
|
34
37
|
export type { ToastType, ToastItem as ToastItemData, UseToastOptions, } from './composables/useToast';
|
|
35
38
|
export type { UseVirtualListOptions } from './composables/useVirtualList';
|
|
36
39
|
export type { EditingCell } from './composables/useInlineEdit';
|
|
40
|
+
export type { UseColumnResizeOptions } from './composables/useColumnResize';
|
|
41
|
+
export type { UseFixedColumnsOptions } from './composables/useFixedColumns';
|
|
42
|
+
export type { UseKeyboardNavigationOptions } from './composables/useKeyboardNavigation';
|
|
43
|
+
export type { RowReorderPayload, RowGroupChangePayload } from './composables/useRowDrag';
|
|
44
|
+
export type { UseDraftRowsOptions } from './composables/useDraftRows';
|
|
45
|
+
export type { ValidationRule, FilterFieldConfig, FilterPanelConfig, UseSchemaEngineOptions, } from './composables/useSchemaEngine';
|
|
46
|
+
export { inferSchema, fetchSchemaFromSupabase, humanizeColumnName } from './utils/supabaseSchema';
|
|
47
|
+
export type { PgColumnInfo, InferSchemaOptions } from './utils/supabaseSchema';
|
|
37
48
|
export { useBadge, resolveBadge, mergeColorMap, DEFAULT_PRIORITY_MAP, DEFAULT_STATUS_MAP, } from './composables';
|
|
38
49
|
export { useStream } from './composables/useStream';
|
|
39
50
|
export { useTypewriter } from './composables/useTypewriter';
|
|
@@ -44,6 +55,19 @@ export { useMarkdown } from './composables/useMarkdown';
|
|
|
44
55
|
export { useToast } from './composables/useToast';
|
|
45
56
|
export { useVirtualList } from './composables/useVirtualList';
|
|
46
57
|
export { useInlineEdit } from './composables/useInlineEdit';
|
|
58
|
+
export { useColumnResize } from './composables/useColumnResize';
|
|
59
|
+
export { useFixedColumns } from './composables/useFixedColumns';
|
|
60
|
+
export { useKeyboardNavigation } from './composables/useKeyboardNavigation';
|
|
61
|
+
export { useRowDrag } from './composables/useRowDrag';
|
|
62
|
+
export { useDraftRows } from './composables/useDraftRows';
|
|
63
|
+
export { useWorkerSort } from './composables/useWorkerSort';
|
|
64
|
+
export { useSchemaEngine } from './composables/useSchemaEngine';
|
|
65
|
+
export { useSupabaseProvider } from './composables/useSupabaseProvider';
|
|
66
|
+
export type { SupabaseQueryBuilder, SupabaseFilterBuilder, UseSupabaseProviderOptions, } from './composables/useSupabaseProvider';
|
|
67
|
+
export { useViewPersistence, createLocalStorageBackend, createSupabaseBackend, } from './composables/useViewPersistence';
|
|
68
|
+
export type { ViewStorageBackend, SupabaseViewBackendOptions, UseViewPersistenceOptions, } from './composables/useViewPersistence';
|
|
69
|
+
export { useSearch } from './composables/useSearch';
|
|
70
|
+
export type { UseSearchOptions, SearchHighlight as SearchHighlightSegment, } from './composables/useSearch';
|
|
47
71
|
export declare const OneflowUI: {
|
|
48
72
|
install(app: App): void;
|
|
49
73
|
};
|