@oneflowui/ui 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/components/Dashboard/charts/BarChart.vue.js +2 -2
  2. package/dist/components/Dashboard/charts/BarChart.vue2.js +9 -9
  3. package/dist/components/Dashboard/charts/NumberCard.vue.js +2 -2
  4. package/dist/components/Dashboard/charts/PieChart.vue.js +1 -1
  5. package/dist/components/Dashboard/charts/PieChart.vue2.js +3 -3
  6. package/dist/components/Dashboard/charts/TableChart.vue.js +2 -2
  7. package/dist/components/Dashboard/index.vue.js +2 -2
  8. package/dist/components/base/InfoCard.vue.js +1 -1
  9. package/dist/components/base/InfoCard.vue2.js +40 -40
  10. package/dist/components/base/StatisticCard.vue.js +3 -3
  11. package/dist/components/base/StatusSummary.vue.js +1 -1
  12. package/dist/components/base/StatusSummary.vue2.js +5 -5
  13. package/dist/components/database/DatabaseDetailPresenter.vue.d.ts +41 -0
  14. package/dist/components/database/DatabaseDetailPresenter.vue.js +76 -0
  15. package/dist/components/database/DatabaseDetailPresenter.vue2.js +4 -0
  16. package/dist/components/database/DatabaseDetailWorkspace.vue.d.ts +37 -0
  17. package/dist/components/database/DatabaseDetailWorkspace.vue.js +7 -0
  18. package/dist/components/database/DatabaseDetailWorkspace.vue2.js +103 -0
  19. package/dist/components/database/DatabaseView.vue.d.ts +13 -76
  20. package/dist/components/database/DatabaseView.vue.js +2 -2
  21. package/dist/components/database/DatabaseView.vue2.js +322 -921
  22. package/dist/components/database/DatabaseViewContent.vue.d.ts +74 -0
  23. package/dist/components/database/DatabaseViewContent.vue.js +79 -0
  24. package/dist/components/database/DatabaseViewContent.vue2.js +4 -0
  25. package/dist/components/database/DatabaseViewDetailHost.vue.d.ts +43 -0
  26. package/dist/components/database/DatabaseViewDetailHost.vue.js +59 -0
  27. package/dist/components/database/DatabaseViewDetailHost.vue2.js +4 -0
  28. package/dist/components/database/DatabaseViewShell.vue.d.ts +35 -0
  29. package/dist/components/database/DatabaseViewShell.vue.js +7 -0
  30. package/dist/components/database/DatabaseViewShell.vue2.js +71 -0
  31. package/dist/components/database/DatabaseViewToolbar.vue.d.ts +77 -0
  32. package/dist/components/database/DatabaseViewToolbar.vue.js +62 -0
  33. package/dist/components/database/DatabaseViewToolbar.vue2.js +4 -0
  34. package/dist/components/database/databaseViewUtils.d.ts +91 -0
  35. package/dist/components/database/databaseViewUtils.js +266 -0
  36. package/dist/components/database/index.d.ts +1 -1
  37. package/dist/components/kanban/KanbanColumn.vue.d.ts +2 -2
  38. package/dist/components/layout/AppLayout.vue.js +1 -1
  39. package/dist/components/layout/Navbar.vue.js +1 -1
  40. package/dist/components/layout/Sidebar.vue.js +2 -2
  41. package/dist/components/layout/StatusBar.vue.js +2 -2
  42. package/dist/components/overlay/Dialog.vue.d.ts +1 -1
  43. package/dist/components/table/ColumnHeaderMenu.vue.js +3 -3
  44. package/dist/components/table/DataTable.vue.d.ts +6 -17
  45. package/dist/components/table/DataTable.vue.js +2 -2
  46. package/dist/components/table/DataTable.vue2.js +781 -872
  47. package/dist/components/table/DataTableDesktopFixedRegion.vue.d.ts +56 -0
  48. package/dist/components/table/DataTableDesktopFixedRegion.vue.js +7 -0
  49. package/dist/components/table/DataTableDesktopFixedRegion.vue2.js +67 -0
  50. package/dist/components/table/DataTableDesktopFrame.vue.d.ts +127 -0
  51. package/dist/components/table/DataTableDesktopFrame.vue.js +7 -0
  52. package/dist/components/table/DataTableDesktopFrame.vue2.js +196 -0
  53. package/dist/components/table/DataTableDesktopScrollRegion.vue.d.ts +55 -0
  54. package/dist/components/table/DataTableDesktopScrollRegion.vue.js +7 -0
  55. package/dist/components/table/DataTableDesktopScrollRegion.vue2.js +66 -0
  56. package/dist/components/table/DataTableDesktopStandardRegion.vue.d.ts +54 -0
  57. package/dist/components/table/DataTableDesktopStandardRegion.vue.js +7 -0
  58. package/dist/components/table/DataTableDesktopStandardRegion.vue2.js +65 -0
  59. package/dist/components/table/DataTableDraftToolbar.vue.d.ts +11 -0
  60. package/dist/components/table/DataTableDraftToolbar.vue.js +7 -0
  61. package/dist/components/table/DataTableDraftToolbar.vue2.js +25 -0
  62. package/dist/components/table/DataTableMobilePanel.vue.d.ts +79 -0
  63. package/dist/components/table/DataTableMobilePanel.vue.js +60 -0
  64. package/dist/components/table/DataTableMobilePanel.vue2.js +4 -0
  65. package/dist/components/table/DataTableSelectionBar.vue.d.ts +11 -0
  66. package/dist/components/table/DataTableSelectionBar.vue.js +7 -0
  67. package/dist/components/table/DataTableSelectionBar.vue2.js +33 -0
  68. package/dist/components/table/DetailSheet.vue.js +1 -1
  69. package/dist/components/table/DetailSheet.vue2.js +160 -187
  70. package/dist/components/table/FieldTypePicker.vue.js +3 -3
  71. package/dist/components/table/MobileListView.vue.js +1 -1
  72. package/dist/components/table/TableColumnManager.vue.js +3 -3
  73. package/dist/components/table/TableDataRow.vue.js +4 -4
  74. package/dist/components/table/TableFilterPanel.vue.js +1 -1
  75. package/dist/components/table/TableGroupRow.vue.js +2 -2
  76. package/dist/components/table/TableHeaderRow.vue.js +3 -3
  77. package/dist/components/table/TableToolbar.vue.js +2 -2
  78. package/dist/components/table/TableToolbar.vue2.js +126 -138
  79. package/dist/components/table/dataTableUtils.d.ts +26 -0
  80. package/dist/components/table/dataTableUtils.js +60 -0
  81. package/dist/composables/databaseDetailWorkspaceUtils.d.ts +59 -0
  82. package/dist/composables/databaseDetailWorkspaceUtils.js +160 -0
  83. package/dist/composables/index.d.ts +5 -0
  84. package/dist/composables/useDataTableDetailSheet.d.ts +47 -0
  85. package/dist/composables/useDataTableDetailSheet.js +58 -0
  86. package/dist/composables/useDataTableLayout.d.ts +16 -0
  87. package/dist/composables/useDataTableLayout.js +38 -0
  88. package/dist/composables/useDataTableSelection.d.ts +41 -0
  89. package/dist/composables/useDataTableSelection.js +73 -0
  90. package/dist/composables/useDatabaseDetailWorkspace.d.ts +67 -0
  91. package/dist/composables/useDatabaseDetailWorkspace.js +150 -0
  92. package/dist/composables/useDatabaseView.d.ts +3 -137
  93. package/dist/composables/useDatabaseWorkspace.d.ts +31 -0
  94. package/dist/composables/useDatabaseWorkspace.js +89 -0
  95. package/dist/composables/useTableToolbarPanels.d.ts +19 -0
  96. package/dist/composables/useTableToolbarPanels.js +53 -0
  97. package/dist/contracts/database.d.ts +252 -0
  98. package/dist/index.d.ts +6 -0
  99. package/dist/index.js +261 -248
  100. package/dist/plugin.d.ts +2 -0
  101. package/dist/plugin.js +10 -261
  102. package/dist/registry/plugin-components.d.ts +291 -0
  103. package/dist/registry/plugin-components.js +114 -0
  104. package/dist/style.css +1 -1
  105. package/dist/types/data-table.d.ts +27 -0
  106. package/dist/types/data-table.js +29 -0
  107. package/package.json +1 -1
@@ -0,0 +1,160 @@
1
+ function o(e) {
2
+ const t = e[0];
3
+ return t ? Object.keys(t.fields) : [];
4
+ }
5
+ function s(e, t = []) {
6
+ var r;
7
+ const n = (r = e == null ? void 0 : e.fields) == null ? void 0 : r.filter((u) => !u.hidden).map((u) => u.id);
8
+ return n != null && n.length ? n : o(t);
9
+ }
10
+ function c(e, t) {
11
+ var n;
12
+ return ((n = t == null ? void 0 : t.fields.find((r) => r.id === e)) == null ? void 0 : n.name) ?? e;
13
+ }
14
+ function d(e) {
15
+ switch (e == null ? void 0 : e.type) {
16
+ case "number":
17
+ case "currency":
18
+ case "progress":
19
+ return "number";
20
+ case "date":
21
+ case "datetime":
22
+ return "date";
23
+ case "select":
24
+ case "multi_select":
25
+ return "status";
26
+ default:
27
+ return "string";
28
+ }
29
+ }
30
+ function f(e) {
31
+ switch (e == null ? void 0 : e.type) {
32
+ case "number":
33
+ return "number";
34
+ case "select":
35
+ return "select";
36
+ case "multi_select":
37
+ return "multiselect";
38
+ case "date":
39
+ return "date";
40
+ case "datetime":
41
+ return "datetime";
42
+ case "checkbox":
43
+ return "checkbox";
44
+ case "url":
45
+ return "url";
46
+ case "email":
47
+ return "email";
48
+ case "phone":
49
+ return "phone";
50
+ case "rating":
51
+ return "rating";
52
+ case "attachment":
53
+ return "attachment";
54
+ case "relation":
55
+ return "relation";
56
+ case "formula":
57
+ return "text";
58
+ case "currency":
59
+ return "currency";
60
+ case "richtext":
61
+ return "richtext";
62
+ case "auto_number":
63
+ return "auto_number";
64
+ case "creator":
65
+ return "creator";
66
+ case "progress":
67
+ return "progress";
68
+ case "text":
69
+ default:
70
+ return "text";
71
+ }
72
+ }
73
+ function a(e) {
74
+ return e == null ? "" : Array.isArray(e) ? e.map((t) => String(t)).join(", ") : String(e);
75
+ }
76
+ function p(e, t = []) {
77
+ return s(e, t).map((r) => {
78
+ var i;
79
+ const u = (i = e == null ? void 0 : e.fields) == null ? void 0 : i.find((l) => l.id === r);
80
+ return {
81
+ key: r,
82
+ label: c(r, e),
83
+ type: d(u),
84
+ hidden: (u == null ? void 0 : u.hidden) ?? !1,
85
+ width: u == null ? void 0 : u.width
86
+ };
87
+ });
88
+ }
89
+ function b(e, t = []) {
90
+ return s(e, t).map((r) => {
91
+ var i;
92
+ const u = (i = e == null ? void 0 : e.fields) == null ? void 0 : i.find((l) => l.id === r);
93
+ return {
94
+ id: r,
95
+ type: f(u),
96
+ label: c(r, e)
97
+ };
98
+ });
99
+ }
100
+ function y(e) {
101
+ return e ? {
102
+ id: e.id,
103
+ ...e.fields
104
+ } : { id: "__detail-empty__" };
105
+ }
106
+ function k(e) {
107
+ const t = e == null ? void 0 : e.fields;
108
+ return a(
109
+ (t == null ? void 0 : t.title) ?? (t == null ? void 0 : t.name) ?? (t == null ? void 0 : t.subject) ?? (e == null ? void 0 : e.id) ?? "记录详情"
110
+ ) || "记录详情";
111
+ }
112
+ function g(e, t) {
113
+ const n = new Set(
114
+ t.filter((r) => r.type === "richtext").map((r) => r.id)
115
+ );
116
+ return {
117
+ propertyColumns: e.filter((r) => !n.has(r.key)),
118
+ contentColumns: e.filter((r) => n.has(r.key))
119
+ };
120
+ }
121
+ function m(e, t) {
122
+ return e.map((n) => {
123
+ const r = a(t[n.key]).trim();
124
+ return r ? `## ${n.label}
125
+
126
+ ${r}` : "";
127
+ }).filter((n) => n.length > 0).join(`
128
+
129
+ `);
130
+ }
131
+ function x(e) {
132
+ return e.columns.map((t) => {
133
+ const n = e.fieldDefs.find((i) => i.id === t.key) ?? null, r = e.row[t.key], u = a(r).trim() || "—";
134
+ return {
135
+ key: t.key,
136
+ label: t.label,
137
+ field: n,
138
+ value: r,
139
+ fallbackText: u
140
+ };
141
+ });
142
+ }
143
+ function D(e) {
144
+ return e.requested !== "auto" ? e.requested : e.preferred ? e.preferred === "side-panel" && e.isMobileViewport ? "sheet" : e.preferred : e.isMobileViewport ? "sheet" : "side-panel";
145
+ }
146
+ function F(e) {
147
+ const t = [];
148
+ return e || t.push({ value: "side-panel", label: "右侧工作区" }), t.push({ value: "sheet", label: "抽屉" }), t.push({ value: "full-page", label: "全页" }), t;
149
+ }
150
+ export {
151
+ p as buildDetailColumns,
152
+ b as buildDetailFieldDefs,
153
+ x as buildDetailPropertyItems,
154
+ m as buildDetailWorkspaceDescription,
155
+ k as buildDetailWorkspaceTitle,
156
+ F as buildWorkspaceModes,
157
+ g as partitionDetailColumns,
158
+ D as resolveDetailPresentation,
159
+ y as toDetailRow
160
+ };
@@ -34,6 +34,10 @@ export type { RowReorderPayload, RowGroupChangePayload } from './useRowDrag';
34
34
  export { useDraftRows } from './useDraftRows';
35
35
  export type { UseDraftRowsOptions } from './useDraftRows';
36
36
  export { useWorkerSort } from './useWorkerSort';
37
+ export { useDataTableSelection } from './useDataTableSelection';
38
+ export type { UseDataTableSelectionOptions, UseDataTableSelectionReturn, } from './useDataTableSelection';
39
+ export { useDataTableDetailSheet, buildDetailSheetCellEditPayloads } from './useDataTableDetailSheet';
40
+ export type { DataTableDetailSheetBaseRow, DataTableDetailSheetRow, DataTableCellEditPayload, DataTableDetailSavePayload, DataTableRowClickResult, } from './useDataTableDetailSheet';
37
41
  export { useSchemaEngine } from './useSchemaEngine';
38
42
  export type { ValidationRule, FilterFieldConfig, FilterPanelConfig, UseSchemaEngineOptions, } from './useSchemaEngine';
39
43
  export { useSupabaseProvider } from './useSupabaseProvider';
@@ -42,5 +46,6 @@ export { useViewPersistence, createLocalStorageBackend, createSupabaseBackend, }
42
46
  export type { ViewStorageBackend, SupabaseViewBackendOptions, UseViewPersistenceOptions, } from './useViewPersistence';
43
47
  export { useDatabaseView } from './useDatabaseView';
44
48
  export type { DatabaseViewMode, DatabaseViewFetchParams, DatabaseViewFetchResult, DatabaseViewProvider, DatabaseSchemaEvent, DatabaseViewActions, DatabaseViewDetailOptions, DatabaseViewNavigationOptions, UseDatabaseViewOptions, UseDatabaseViewResult, } from './useDatabaseView';
49
+ export { useDatabaseViewport, useDatabaseWorkspaceState } from './useDatabaseWorkspace';
45
50
  export { useSearch } from './useSearch';
46
51
  export type { UseSearchOptions, SearchHighlight } from './useSearch';
@@ -0,0 +1,47 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { DataRecord } from '../types';
3
+ export type DataTableDetailSheetBaseRow = {
4
+ id: string;
5
+ } & Record<string, unknown>;
6
+ export type DataTableDetailSheetRow<TTableRow, TRecord = DataRecord> = TTableRow & {
7
+ __record?: TRecord;
8
+ };
9
+ export interface DataTableCellEditPayload {
10
+ rowId: string;
11
+ fieldId: string;
12
+ value: unknown;
13
+ }
14
+ export interface DataTableDetailSavePayload {
15
+ rowId: string;
16
+ fields: Record<string, unknown>;
17
+ }
18
+ export type DataTableRowClickResult<TTableRow, TRecord = DataRecord> = {
19
+ type: "open-detail-sheet";
20
+ row: DataTableDetailSheetRow<TTableRow, TRecord>;
21
+ } | {
22
+ type: "emit-record";
23
+ row: TRecord;
24
+ } | {
25
+ type: "emit-row";
26
+ row: TTableRow;
27
+ };
28
+ export declare function buildDetailSheetCellEditPayloads(payload: DataTableDetailSavePayload): DataTableCellEditPayload[];
29
+ export interface UseDataTableDetailSheetReturn<TTableRow extends DataTableDetailSheetBaseRow, TRecord = DataRecord> {
30
+ detailSheetVisible: Ref<boolean>;
31
+ detailSheetTableRow: ComputedRef<(Record<string, unknown> & {
32
+ id: string;
33
+ }) | null>;
34
+ openDetailSheet: (row: DataTableDetailSheetRow<TTableRow, TRecord>) => DataTableDetailSheetRow<TTableRow, TRecord>;
35
+ closeDetailSheet: () => void;
36
+ clearDetailSheet: () => void;
37
+ handleRowClick: (params: {
38
+ row: DataTableDetailSheetRow<TTableRow, TRecord>;
39
+ isMobile: boolean;
40
+ }) => DataTableRowClickResult<TTableRow, TRecord>;
41
+ handleMobileRowClick: (row: DataTableDetailSheetRow<TTableRow, TRecord>) => {
42
+ type: "open-detail-sheet";
43
+ row: DataTableDetailSheetRow<TTableRow, TRecord>;
44
+ };
45
+ buildDetailSavePayloads: (payload: DataTableDetailSavePayload) => DataTableCellEditPayload[];
46
+ }
47
+ export declare function useDataTableDetailSheet<TTableRow extends DataTableDetailSheetBaseRow, TRecord = DataRecord>(): UseDataTableDetailSheetReturn<TTableRow, TRecord>;
@@ -0,0 +1,58 @@
1
+ import { ref as u, computed as S } from "vue";
2
+ function b(t) {
3
+ return Object.entries(t.fields).map(([l, n]) => ({
4
+ rowId: t.rowId,
5
+ fieldId: l,
6
+ value: n
7
+ }));
8
+ }
9
+ function v() {
10
+ const t = u(!1), l = u(null), n = S(
11
+ () => l.value
12
+ );
13
+ function o(e) {
14
+ return l.value = e, t.value = !0, e;
15
+ }
16
+ function c() {
17
+ t.value = !1;
18
+ }
19
+ function d() {
20
+ t.value = !1, l.value = null;
21
+ }
22
+ function r(e) {
23
+ return o(e), {
24
+ type: "open-detail-sheet",
25
+ row: e
26
+ };
27
+ }
28
+ function s(e) {
29
+ const { row: i, isMobile: h } = e;
30
+ if (h)
31
+ return r(i);
32
+ const a = i.__record;
33
+ return a ? {
34
+ type: "emit-record",
35
+ row: a
36
+ } : {
37
+ type: "emit-row",
38
+ row: i
39
+ };
40
+ }
41
+ function f(e) {
42
+ return b(e);
43
+ }
44
+ return {
45
+ detailSheetVisible: t,
46
+ detailSheetTableRow: n,
47
+ openDetailSheet: o,
48
+ closeDetailSheet: c,
49
+ clearDetailSheet: d,
50
+ handleRowClick: s,
51
+ handleMobileRowClick: r,
52
+ buildDetailSavePayloads: f
53
+ };
54
+ }
55
+ export {
56
+ b as buildDetailSheetCellEditPayloads,
57
+ v as useDataTableDetailSheet
58
+ };
@@ -0,0 +1,16 @@
1
+ import { CSSProperties, Ref } from 'vue';
2
+ import { Density } from '../types';
3
+ export declare function useDataTableLayout(params: {
4
+ tableContainerRef: Ref<HTMLElement | null>;
5
+ density: Ref<Density>;
6
+ containerResponsive: Ref<boolean>;
7
+ isMobile: Ref<boolean>;
8
+ }): {
9
+ tableContainerWidth: Ref<number, number>;
10
+ containerDensity: import('vue').ComputedRef<Density>;
11
+ densityMetrics: import('vue').ComputedRef<import('../types/data-table').DataTableDensityMetrics>;
12
+ densityClass: import('vue').ComputedRef<string>;
13
+ containerWidthClass: import('vue').ComputedRef<"of-data-table--container-tight" | "of-data-table--container-medium" | "of-data-table--container-wide">;
14
+ densityStyle: import('vue').ComputedRef<CSSProperties>;
15
+ syncTableContainerWidth: () => void;
16
+ };
@@ -0,0 +1,38 @@
1
+ import { ref as m, onMounted as g, onBeforeUnmount as y, computed as n } from "vue";
2
+ import { TABLE_DENSITY_METRICS as h } from "../types/data-table.js";
3
+ function x(c) {
4
+ const { tableContainerRef: o, density: l, containerResponsive: f, isMobile: v } = c, e = m(0);
5
+ let t = null;
6
+ function d() {
7
+ var i;
8
+ e.value = ((i = o.value) == null ? void 0 : i.clientWidth) ?? 0;
9
+ }
10
+ g(() => {
11
+ d(), !(typeof ResizeObserver > "u" || !o.value) && (t = new ResizeObserver((i) => {
12
+ const u = i[0];
13
+ u && (e.value = u.contentRect.width);
14
+ }), t.observe(o.value));
15
+ }), y(() => {
16
+ t == null || t.disconnect(), t = null;
17
+ });
18
+ const r = n(() => !f.value || v.value ? l.value : e.value > 0 && e.value <= 860 ? "compact" : e.value > 0 && e.value <= 1080 && l.value === "comfortable" ? "standard" : l.value), a = n(() => h[r.value]), s = n(() => `of-data-table--${r.value}`), b = n(() => e.value > 0 && e.value <= 860 ? "of-data-table--container-tight" : e.value > 0 && e.value <= 1080 ? "of-data-table--container-medium" : "of-data-table--container-wide"), p = n(() => ({
19
+ "--of-data-table-group-row-height": `${a.value.groupRowHeight}px`,
20
+ "--of-data-table-mobile-card-padding-x": `${a.value.mobileCardPaddingX}px`,
21
+ "--of-data-table-mobile-card-padding-y": `${a.value.mobileCardPaddingY}px`,
22
+ "--of-data-table-new-row-padding-x": `${a.value.mobileCardPaddingX}px`,
23
+ "--of-data-table-new-row-padding-y": `${a.value.mobileCardPaddingY}px`,
24
+ "--of-data-table-fill-min-width": `${a.value.fillMinWidth}px`
25
+ }));
26
+ return {
27
+ tableContainerWidth: e,
28
+ containerDensity: r,
29
+ densityMetrics: a,
30
+ densityClass: s,
31
+ containerWidthClass: b,
32
+ densityStyle: p,
33
+ syncTableContainerWidth: d
34
+ };
35
+ }
36
+ export {
37
+ x as useDataTableLayout
38
+ };
@@ -0,0 +1,41 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { BulkActionContext, BulkActionItem, ResolvedBulkActionItem } from '../types/data-table';
3
+ type ValueRef<T> = Ref<T> | ComputedRef<T>;
4
+ export interface UseDataTableSelectionOptions<TRecord extends Record<string, unknown>> {
5
+ rows: ValueRef<TRecord[]>;
6
+ selectedRows: ValueRef<ReadonlySet<string | number>>;
7
+ rowKey: ValueRef<string>;
8
+ selectable: ValueRef<boolean>;
9
+ bulkActionItems: ValueRef<BulkActionItem[] | undefined>;
10
+ showSelectionBar: ValueRef<boolean>;
11
+ emitSelectionChange?: (ids: (string | number)[]) => void;
12
+ }
13
+ export interface UseDataTableSelectionReturn<TRecord extends Record<string, unknown>> {
14
+ selectedIdsArray: ComputedRef<(string | number)[]>;
15
+ indeterminate: ComputedRef<boolean>;
16
+ selectedDataRows: ComputedRef<TRecord[]>;
17
+ bulkActionContext: ComputedRef<BulkActionContext<TRecord>>;
18
+ resolvedBulkActionItems: ComputedRef<ResolvedBulkActionItem[]>;
19
+ hasSelectionBar: ComputedRef<boolean>;
20
+ handleSelectAll: () => void;
21
+ handleSelect: (id: string | number) => void;
22
+ handleBulkAction: (action: BulkActionItem | ResolvedBulkActionItem) => void;
23
+ }
24
+ export declare function useDataTableSelection<TRecord extends Record<string, unknown>>(options: {
25
+ rows: ValueRef<TRecord[]>;
26
+ selectedRows: ValueRef<ReadonlySet<string | number>>;
27
+ rowKey: ValueRef<string>;
28
+ selectable: ValueRef<boolean>;
29
+ bulkActionItems: ValueRef<BulkActionItem[] | undefined>;
30
+ showSelectionBar: ValueRef<boolean>;
31
+ emitSelectionChange?: (ids: (string | number)[]) => void;
32
+ toggleSelectAll: (rows: TRecord[]) => void;
33
+ toggleRowSelection: (row: TRecord, index?: number) => void;
34
+ clearSelection: () => void;
35
+ emitBulkAction?: (payload: {
36
+ actionKey: string;
37
+ rowIds: string[];
38
+ rows: TRecord[];
39
+ }) => void;
40
+ }): UseDataTableSelectionReturn<TRecord>;
41
+ export {};
@@ -0,0 +1,73 @@
1
+ import { computed as c, watch as S } from "vue";
2
+ function y(e) {
3
+ const r = c(() => Array.from(e.selectedRows.value)), u = c(
4
+ () => e.rows.value.filter(
5
+ (a) => e.selectedRows.value.has(d(a, e.rowKey.value))
6
+ )
7
+ ), l = c(
8
+ () => e.selectedRows.value.size > 0 && e.selectedRows.value.size < e.rows.value.length
9
+ ), s = c(() => ({
10
+ selectionCount: u.value.length,
11
+ rowIds: u.value.map((a) => d(a, e.rowKey.value)),
12
+ rows: [...u.value]
13
+ })), v = c(
14
+ () => m(e.bulkActionItems.value, s.value)
15
+ ), n = c(
16
+ () => e.showSelectionBar.value && e.selectable.value && e.selectedRows.value.size > 0
17
+ );
18
+ function f() {
19
+ e.toggleSelectAll(e.rows.value);
20
+ }
21
+ function w(a) {
22
+ const t = e.rows.value.find(
23
+ (b) => d(b, e.rowKey.value) === String(a)
24
+ );
25
+ t && e.toggleRowSelection(t, 0);
26
+ }
27
+ function i(a) {
28
+ var t;
29
+ (t = e.emitBulkAction) == null || t.call(e, {
30
+ actionKey: a.key,
31
+ rowIds: s.value.rowIds,
32
+ rows: s.value.rows
33
+ }), (a.clearSelectionAfter || a.key === "clear-selection") && e.clearSelection();
34
+ }
35
+ return S(
36
+ r,
37
+ (a) => {
38
+ var t;
39
+ (t = e.emitSelectionChange) == null || t.call(e, a);
40
+ },
41
+ { immediate: !1 }
42
+ ), {
43
+ selectedIdsArray: r,
44
+ indeterminate: l,
45
+ selectedDataRows: u,
46
+ bulkActionContext: s,
47
+ resolvedBulkActionItems: v,
48
+ hasSelectionBar: n,
49
+ handleSelectAll: f,
50
+ handleSelect: w,
51
+ handleBulkAction: i
52
+ };
53
+ }
54
+ function d(e, r) {
55
+ const u = e[r];
56
+ return u != null ? String(u) : "";
57
+ }
58
+ function m(e, r) {
59
+ return [...[
60
+ {
61
+ key: "clear-selection",
62
+ label: "清空选择",
63
+ clearSelectionAfter: !0
64
+ }
65
+ ], ...e ?? []].filter((l) => typeof l.visible == "function" ? l.visible(r) : l.visible ?? !0).map((l) => ({
66
+ ...l,
67
+ resolvedLabel: typeof l.label == "function" ? l.label(r) : l.label,
68
+ resolvedDisabled: typeof l.disabled == "function" ? l.disabled(r) : l.disabled ?? !1
69
+ }));
70
+ }
71
+ export {
72
+ y as useDataTableSelection
73
+ };
@@ -0,0 +1,67 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { DatabaseViewDetailPresentation, DatabaseViewResolvedDetailPresentation, DatabaseViewViewTab } from '../contracts/database';
3
+ import { DataRecord, TableSchema } from '../types';
4
+ interface DetailEmptyAction {
5
+ label: string;
6
+ onClick: () => void;
7
+ }
8
+ interface UseDatabaseDetailWorkspaceOptions {
9
+ tableId: Readonly<Ref<string | undefined>>;
10
+ activeViewId: Readonly<ComputedRef<string>>;
11
+ currentViewId: Readonly<Ref<string>>;
12
+ selectedRecordId: Readonly<Ref<string | null | undefined>>;
13
+ selectedRecord: Readonly<ComputedRef<DataRecord | null>>;
14
+ resolvedSchema: Readonly<ComputedRef<TableSchema | null | undefined>>;
15
+ resolvedRecords: Readonly<ComputedRef<DataRecord[]>>;
16
+ viewTabs: Readonly<ComputedRef<DatabaseViewViewTab[]>>;
17
+ detailPresentation: Readonly<Ref<DatabaseViewDetailPresentation>>;
18
+ initialSearchKeyword?: string;
19
+ initialDetailPresentation?: DatabaseViewResolvedDetailPresentation | null;
20
+ initialSidePanelWidth?: number;
21
+ initialDrawerWidth?: number;
22
+ initialWorkspaceActive?: boolean;
23
+ onSelectRecord: (record: DataRecord | string | null) => void;
24
+ onClearSelectedRecord: () => void;
25
+ onSetRecords: (next: DataRecord[]) => void;
26
+ onCellEdit: (payload: {
27
+ rowId: string;
28
+ fieldId: string;
29
+ value: unknown;
30
+ }) => void;
31
+ onSwitchView: (viewId: string) => void;
32
+ }
33
+ export declare function useDatabaseDetailWorkspace(options: UseDatabaseDetailWorkspaceOptions): {
34
+ searchKeyword: Ref<string, string>;
35
+ sidePanelWidth: Ref<number, number>;
36
+ drawerWidth: Ref<number, number>;
37
+ detailWorkspaceRow: ComputedRef<{
38
+ [x: string]: unknown;
39
+ id: string;
40
+ }>;
41
+ detailWorkspaceTitle: ComputedRef<string>;
42
+ detailWorkspaceDescription: ComputedRef<string>;
43
+ detailPropertyItems: ComputedRef<import('./databaseDetailWorkspaceUtils').DatabaseDetailPropertyItem[]>;
44
+ hasDetailDraftChanges: ComputedRef<boolean>;
45
+ showDetailWorkspace: ComputedRef<boolean>;
46
+ resolvedDetailPresentation: ComputedRef<DatabaseViewResolvedDetailPresentation>;
47
+ workspaceModes: ComputedRef<import('./databaseDetailWorkspaceUtils').DatabaseWorkspaceModeOption[]>;
48
+ canSwitchDetailPresentation: ComputedRef<boolean>;
49
+ detailEmptyAction: ComputedRef<DetailEmptyAction | undefined>;
50
+ setPreferredDetailPresentation: (mode: DatabaseViewResolvedDetailPresentation) => void;
51
+ activateDetailWorkspace: () => void;
52
+ handleRowSelect: (record: DataRecord) => void;
53
+ handleCardClick: (payload: {
54
+ id?: string;
55
+ } | Record<string, unknown> | null | undefined) => void;
56
+ handleTimelineRowClick: (payload: {
57
+ id?: string;
58
+ sourceRecordId?: string;
59
+ }) => void;
60
+ handleDetailClose: () => void;
61
+ handleDetailDelete: (rowId: string) => void;
62
+ handleDetailWorkspaceCommit: (_rowId: string, fieldId: string, value: unknown) => void;
63
+ handleDetailWorkspaceSave: () => void;
64
+ handleSidePanelWidthUpdate: (width: number) => void;
65
+ handleDrawerWidthUpdate: (width: number) => void;
66
+ };
67
+ export {};
@@ -0,0 +1,150 @@
1
+ import { ref as b, computed as t } from "vue";
2
+ import { useDatabaseViewport as O, useDatabaseWorkspaceState as q, clampWorkspaceWidth as P, DEFAULT_SIDE_PANEL_WIDTH as N, DEFAULT_DRAWER_WIDTH as z } from "./useDatabaseWorkspace.js";
3
+ import { buildDetailColumns as G, buildDetailFieldDefs as J, toDetailRow as Q, buildDetailWorkspaceTitle as X, partitionDetailColumns as Y, buildDetailWorkspaceDescription as Z, buildDetailPropertyItems as $, resolveDetailPresentation as ee, buildWorkspaceModes as le } from "./databaseDetailWorkspaceUtils.js";
4
+ function re(l) {
5
+ const { isMobileViewport: s } = O(), {
6
+ preferredDetailPresentation: v,
7
+ sidePanelWidth: f,
8
+ drawerWidth: D,
9
+ searchKeyword: C
10
+ } = q({
11
+ tableId: l.tableId,
12
+ activeViewId: l.activeViewId,
13
+ initialSearchKeyword: l.initialSearchKeyword ?? "",
14
+ initialDetailPresentation: l.initialDetailPresentation ?? null,
15
+ initialSidePanelWidth: l.initialSidePanelWidth,
16
+ initialDrawerWidth: l.initialDrawerWidth
17
+ }), r = b({}), d = b(!!l.initialWorkspaceActive), S = t(
18
+ () => G(l.resolvedSchema.value, l.resolvedRecords.value)
19
+ ), h = t(
20
+ () => J(l.resolvedSchema.value, l.resolvedRecords.value)
21
+ ), I = t(() => Q(l.selectedRecord.value)), c = t(() => ({
22
+ ...I.value,
23
+ ...r.value
24
+ })), T = t(
25
+ () => X(l.selectedRecord.value)
26
+ ), w = t(
27
+ () => Y(S.value, h.value)
28
+ ), V = t(
29
+ () => Z(
30
+ w.value.contentColumns,
31
+ c.value
32
+ )
33
+ ), p = t(
34
+ () => $({
35
+ columns: w.value.propertyColumns,
36
+ fieldDefs: h.value,
37
+ row: c.value
38
+ })
39
+ ), A = t(
40
+ () => Object.keys(r.value).length > 0
41
+ ), E = t(
42
+ () => d.value && !!l.selectedRecord.value
43
+ ), F = t(
44
+ () => ee({
45
+ requested: l.detailPresentation.value,
46
+ preferred: v.value,
47
+ isMobileViewport: s.value
48
+ })
49
+ ), _ = t(
50
+ () => le(s.value)
51
+ ), W = t(
52
+ () => l.detailPresentation.value === "auto"
53
+ );
54
+ function R() {
55
+ r.value = {};
56
+ }
57
+ function m() {
58
+ d.value = !0;
59
+ }
60
+ function n(e) {
61
+ e && (m(), R(), l.onSelectRecord(e));
62
+ }
63
+ function k(e) {
64
+ return e ? l.resolvedRecords.value.find((a) => a.id === e) ?? null : null;
65
+ }
66
+ const y = t(() => {
67
+ var i;
68
+ if (l.activeViewId.value !== "detail") return;
69
+ const e = l.resolvedRecords.value[0];
70
+ if (e)
71
+ return {
72
+ label: "打开第一条记录",
73
+ onClick: () => n(e)
74
+ };
75
+ const a = ((i = l.viewTabs.value.find((u) => u.value !== "detail")) == null ? void 0 : i.value) ?? null;
76
+ if (a)
77
+ return {
78
+ label: "返回列表",
79
+ onClick: () => l.onSwitchView(a)
80
+ };
81
+ });
82
+ function M(e) {
83
+ W.value && (v.value = e);
84
+ }
85
+ function U(e) {
86
+ n(e);
87
+ }
88
+ function B(e) {
89
+ n(k(e == null ? void 0 : e.id));
90
+ }
91
+ function K(e) {
92
+ n(k(e.sourceRecordId ?? e.id));
93
+ }
94
+ function o() {
95
+ d.value = !1, R(), l.onClearSelectedRecord();
96
+ }
97
+ function L(e) {
98
+ const a = l.resolvedRecords.value.filter((i) => i.id !== e);
99
+ l.onSetRecords(a), o();
100
+ }
101
+ function g(e, a, i) {
102
+ r.value = {
103
+ ...r.value,
104
+ [a]: i
105
+ };
106
+ }
107
+ function j() {
108
+ const e = l.selectedRecord.value;
109
+ if (!e) return;
110
+ const a = { ...r.value };
111
+ for (const [i, u] of Object.entries(a))
112
+ l.onCellEdit({ rowId: e.id, fieldId: i, value: u });
113
+ o();
114
+ }
115
+ function x(e) {
116
+ f.value = P(e, N);
117
+ }
118
+ function H(e) {
119
+ D.value = P(e, z);
120
+ }
121
+ return {
122
+ searchKeyword: C,
123
+ sidePanelWidth: f,
124
+ drawerWidth: D,
125
+ detailWorkspaceRow: c,
126
+ detailWorkspaceTitle: T,
127
+ detailWorkspaceDescription: V,
128
+ detailPropertyItems: p,
129
+ hasDetailDraftChanges: A,
130
+ showDetailWorkspace: E,
131
+ resolvedDetailPresentation: F,
132
+ workspaceModes: _,
133
+ canSwitchDetailPresentation: W,
134
+ detailEmptyAction: y,
135
+ setPreferredDetailPresentation: M,
136
+ activateDetailWorkspace: m,
137
+ handleRowSelect: U,
138
+ handleCardClick: B,
139
+ handleTimelineRowClick: K,
140
+ handleDetailClose: o,
141
+ handleDetailDelete: L,
142
+ handleDetailWorkspaceCommit: g,
143
+ handleDetailWorkspaceSave: j,
144
+ handleSidePanelWidthUpdate: x,
145
+ handleDrawerWidthUpdate: H
146
+ };
147
+ }
148
+ export {
149
+ re as useDatabaseDetailWorkspace
150
+ };