@industream/flowmaker-flowbox-ui-components 0.0.12 → 0.0.14
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/DCCatalogEntryPicker/DCCatalogEntryPicker.svelte +113 -0
- package/dist/DCCatalogEntryPicker/DCCatalogEntryPicker.svelte.d.ts +15 -0
- package/dist/DCCatalogEntryPicker/SelectedTags.svelte +150 -0
- package/dist/DCCatalogEntryPicker/SelectedTags.svelte.d.ts +18 -0
- package/dist/DCCatalogEntryPicker/TagBrowser.svelte +210 -0
- package/dist/DCCatalogEntryPicker/TagBrowser.svelte.d.ts +24 -0
- package/dist/DCCatalogEntryPicker/picker-column-helpers.d.ts +74 -0
- package/dist/DCCatalogEntryPicker/picker-column-helpers.js +105 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/package.json +10 -1
- package/src/DCCatalogEntryPicker/DCCatalogEntryPicker.svelte +113 -0
- package/src/DCCatalogEntryPicker/SelectedTags.svelte +150 -0
- package/src/DCCatalogEntryPicker/TagBrowser.svelte +210 -0
- package/src/DCCatalogEntryPicker/picker-column-helpers.ts +126 -0
- package/src/index.ts +3 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog entry column system.
|
|
3
|
+
*
|
|
4
|
+
* Declarative column definitions that drive both the TagBrowser table
|
|
5
|
+
* and the SelectedTags panel. Consumers pass an array of column keys
|
|
6
|
+
* (e.g. ['name', 'sourceParams.nodeId', 'dataType']) to control display.
|
|
7
|
+
*
|
|
8
|
+
* ── Static column keys ──────────────────────────────────────────────
|
|
9
|
+
*
|
|
10
|
+
* Key | Label | Source | Render
|
|
11
|
+
* -----------|-------------|-----------------------|--------
|
|
12
|
+
* 'name' | Name | CatalogEntry.name | text
|
|
13
|
+
* 'dataType' | Data Type | CatalogEntry.dataType | pill
|
|
14
|
+
* 'labels' | Labels | CatalogEntry.labels[] | labels
|
|
15
|
+
*
|
|
16
|
+
* ── Dynamic column keys (dot-path) ──────────────────────────────────
|
|
17
|
+
*
|
|
18
|
+
* Any key starting with 'sourceParams.' or 'metadata.' resolves the
|
|
19
|
+
* corresponding sub-property at runtime. No pre-registration needed.
|
|
20
|
+
*
|
|
21
|
+
* Key | Label | Source | Render
|
|
22
|
+
* -------------------------|------------|----------------------------------|--------
|
|
23
|
+
* 'sourceParams.nodeId' | Node ID | CatalogEntry.sourceParams.nodeId | code
|
|
24
|
+
* 'sourceParams.topic' | Topic | CatalogEntry.sourceParams.topic | code
|
|
25
|
+
* 'metadata.unit' | Unit | CatalogEntry.metadata.unit | pill
|
|
26
|
+
* 'metadata.description' | Description| CatalogEntry.metadata.description | text
|
|
27
|
+
* ... any other sub-key | (auto) | ... | (auto)
|
|
28
|
+
*
|
|
29
|
+
* Render types:
|
|
30
|
+
* - 'text' : plain text cell (truncated, with title tooltip)
|
|
31
|
+
* - 'code' : monospace <code> cell
|
|
32
|
+
* - 'pill' : small badge/pill (only rendered when value is truthy)
|
|
33
|
+
* - 'labels' : iterates Label[] array, renders each as a pill
|
|
34
|
+
*
|
|
35
|
+
* sourceParams.* keys default to 'code' rendering.
|
|
36
|
+
* metadata.* keys default to 'pill' rendering.
|
|
37
|
+
* Override by adding an explicit entry in COLUMN_DEFS.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import type { CatalogEntry, Label } from '@industream/datacatalog-client/dto';
|
|
41
|
+
|
|
42
|
+
/** How a cell should be rendered */
|
|
43
|
+
export type ColumnType = 'text' | 'code' | 'pill' | 'labels';
|
|
44
|
+
|
|
45
|
+
export interface ColumnDef {
|
|
46
|
+
label: string;
|
|
47
|
+
resolve: (entry: CatalogEntry) => unknown;
|
|
48
|
+
type: ColumnType;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Static column definitions for top-level CatalogEntry fields.
|
|
53
|
+
* For sourceParams / metadata sub-properties, use dot-path keys instead
|
|
54
|
+
* (see {@link resolveColumn}).
|
|
55
|
+
*/
|
|
56
|
+
export const COLUMN_DEFS: Record<string, ColumnDef> = {
|
|
57
|
+
name: { label: 'Name', resolve: (e) => e.name, type: 'text' },
|
|
58
|
+
dataType: { label: 'Data Type', resolve: (e) => e.dataType, type: 'pill' },
|
|
59
|
+
labels: { label: 'Labels', resolve: (e) => e.labels ?? [], type: 'labels' },
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** Default columns for the tag browser table */
|
|
63
|
+
export const DEFAULT_COLUMNS: string[] = ['name', 'dataType', 'labels'];
|
|
64
|
+
|
|
65
|
+
/** Default columns for the selected tags display panel */
|
|
66
|
+
export const DEFAULT_SELECTED_COLUMNS_DISPLAY: string[] = ['name', 'dataType', 'labels'];
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Capitalize a dot-path sub-key into a human-readable label.
|
|
70
|
+
* e.g. 'nodeId' → 'Node Id', 'pollInterval' → 'Poll Interval'
|
|
71
|
+
*/
|
|
72
|
+
const humanize = (key: string): string =>
|
|
73
|
+
key.replace(/([A-Z])/g, ' $1').replace(/^./, (c) => c.toUpperCase()).trim();
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Resolve a column definition for any key — static or dot-path.
|
|
77
|
+
*
|
|
78
|
+
* Static keys are looked up in COLUMN_DEFS.
|
|
79
|
+
* Dot-path keys (sourceParams.*, metadata.*) are resolved dynamically:
|
|
80
|
+
* - sourceParams.* → renders as 'code'
|
|
81
|
+
* - metadata.* → renders as 'pill'
|
|
82
|
+
*/
|
|
83
|
+
export const resolveColumn = (key: string): ColumnDef | undefined => {
|
|
84
|
+
if (COLUMN_DEFS[key]) return COLUMN_DEFS[key];
|
|
85
|
+
|
|
86
|
+
if (key.startsWith('sourceParams.')) {
|
|
87
|
+
const prop = key.slice('sourceParams.'.length);
|
|
88
|
+
return {
|
|
89
|
+
label: humanize(prop),
|
|
90
|
+
resolve: (e) => (e.sourceParams as Record<string, unknown>)?.[prop],
|
|
91
|
+
type: 'code',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (key.startsWith('metadata.')) {
|
|
96
|
+
const prop = key.slice('metadata.'.length);
|
|
97
|
+
return {
|
|
98
|
+
label: humanize(prop),
|
|
99
|
+
resolve: (e) => (e.metadata as Record<string, unknown>)?.[prop],
|
|
100
|
+
type: 'pill',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return undefined;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Resolve a single column value from a catalog entry.
|
|
109
|
+
*/
|
|
110
|
+
export const resolveValue = (entry: CatalogEntry, key: string): unknown =>
|
|
111
|
+
resolveColumn(key)?.resolve(entry);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Build a lowercase search string from all active column values.
|
|
115
|
+
* Used by TagBrowser's search filter.
|
|
116
|
+
*/
|
|
117
|
+
export const resolveSearchText = (entry: CatalogEntry, keys: string[]): string =>
|
|
118
|
+
keys
|
|
119
|
+
.map((key) => {
|
|
120
|
+
const val = resolveValue(entry, key);
|
|
121
|
+
if (val == null) return '';
|
|
122
|
+
if (Array.isArray(val)) return val.map((v: Label) => v.name ?? v).join(' ');
|
|
123
|
+
return String(val);
|
|
124
|
+
})
|
|
125
|
+
.join(' ')
|
|
126
|
+
.toLowerCase();
|
package/src/index.ts
CHANGED
|
@@ -4,5 +4,7 @@ export type { SourceConnection } from './DCSourceConnection.svelte';
|
|
|
4
4
|
export { default as DCCatalogEntry } from './DCCatalogEntry.svelte';
|
|
5
5
|
export type { CatalogEntry, DataType, SourceType } from '@industream/datacatalog-client/dto';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export { default as DCCatalogEntryPicker } from './DCCatalogEntryPicker/DCCatalogEntryPicker.svelte';
|
|
8
|
+
export type { ColumnDef, ColumnType } from './DCCatalogEntryPicker/picker-column-helpers';
|
|
9
|
+
export { COLUMN_DEFS, DEFAULT_COLUMNS, DEFAULT_SELECTED_COLUMNS_DISPLAY, resolveColumn, resolveValue, resolveSearchText } from './DCCatalogEntryPicker/picker-column-helpers';
|
|
8
10
|
|