foggy-data-viewer 1.0.1-beta.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.
Files changed (34) hide show
  1. package/README.md +273 -0
  2. package/dist/favicon.svg +4 -0
  3. package/dist/index.js +1531 -0
  4. package/dist/index.umd +1 -0
  5. package/dist/style.css +1 -0
  6. package/package.json +51 -0
  7. package/src/App.vue +469 -0
  8. package/src/api/viewer.ts +163 -0
  9. package/src/components/DataTable.test.ts +533 -0
  10. package/src/components/DataTable.vue +810 -0
  11. package/src/components/DataTableWithSearch.test.ts +628 -0
  12. package/src/components/DataTableWithSearch.vue +277 -0
  13. package/src/components/DataViewer.vue +310 -0
  14. package/src/components/SearchToolbar.test.ts +521 -0
  15. package/src/components/SearchToolbar.vue +406 -0
  16. package/src/components/composables/index.ts +2 -0
  17. package/src/components/composables/useTableSelection.test.ts +248 -0
  18. package/src/components/composables/useTableSelection.ts +44 -0
  19. package/src/components/composables/useTableSummary.test.ts +341 -0
  20. package/src/components/composables/useTableSummary.ts +129 -0
  21. package/src/components/filters/BoolFilter.vue +103 -0
  22. package/src/components/filters/DateRangeFilter.vue +194 -0
  23. package/src/components/filters/NumberRangeFilter.vue +160 -0
  24. package/src/components/filters/SelectFilter.vue +464 -0
  25. package/src/components/filters/TextFilter.vue +230 -0
  26. package/src/components/filters/index.ts +5 -0
  27. package/src/examples/EnhancedTableExample.vue +136 -0
  28. package/src/index.ts +32 -0
  29. package/src/main.ts +14 -0
  30. package/src/types/index.ts +159 -0
  31. package/src/utils/README.md +140 -0
  32. package/src/utils/schemaHelper.test.ts +215 -0
  33. package/src/utils/schemaHelper.ts +44 -0
  34. package/src/vite-env.d.ts +7 -0
@@ -0,0 +1,44 @@
1
+ import type { ColumnSchema, EnhancedColumnSchema, TableConfig } from '@/types'
2
+
3
+ /**
4
+ * 构建表格列配置
5
+ *
6
+ * @param qmSchema - 从后台获取的 QM schema
7
+ * @param config - 表格配置(如果 visibleColumns 为空或未指定,默认显示所有列)
8
+ * @returns 增强的列配置数组
9
+ */
10
+ export function buildTableColumns(
11
+ qmSchema: ColumnSchema[],
12
+ config: TableConfig
13
+ ): EnhancedColumnSchema[] {
14
+ const schemaMap = new Map(qmSchema.map(s => [s.name, s]))
15
+ const customMap = new Map(config.customizations?.map(c => [c.name, c]) || [])
16
+
17
+ // 确定要显示的列及顺序
18
+ // 如果 visibleColumns 为空数组或未定义,且 showAll 未设置,则默认显示所有列
19
+ const shouldShowAll = config.showAll || !config.visibleColumns || config.visibleColumns.length === 0
20
+ const columnNames = shouldShowAll
21
+ ? qmSchema.map(s => s.name)
22
+ : config.visibleColumns
23
+
24
+ return columnNames
25
+ .map(name => {
26
+ const schema = schemaMap.get(name)
27
+ if (!schema) {
28
+ console.warn(`Column "${name}" not found in QM schema`)
29
+ return null
30
+ }
31
+
32
+ const custom = customMap.get(name)
33
+ return {
34
+ ...schema,
35
+ width: custom?.width,
36
+ minWidth: custom?.minWidth ?? 120,
37
+ fixed: custom?.fixed,
38
+ customRender: custom?.render,
39
+ customFilterComponent: custom?.filterComponent,
40
+ customFormatter: custom?.formatter
41
+ }
42
+ })
43
+ .filter((col): col is EnhancedColumnSchema => col !== null)
44
+ }
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module '*.vue' {
4
+ import type { DefineComponent } from 'vue'
5
+ const component: DefineComponent<{}, {}, any>
6
+ export default component
7
+ }