@industream/flowmaker-flowbox-ui-components 0.0.13 → 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/DCCatalogEntry.svelte +133 -22
- package/dist/DCCatalogEntry.svelte.d.ts +10 -3
- package/package.json +1 -1
- package/src/DCCatalogEntry.svelte +133 -22
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import { DataCatalogClient } from '@industream/datacatalog-client';
|
|
3
3
|
import type { CatalogEntry, DataType, SourceType } from '@industream/datacatalog-client/dto';
|
|
4
4
|
|
|
5
|
+
interface FilterOptions {
|
|
6
|
+
searchtext?: string | null; // Case-insensitive LIKE %text% filter on entry name
|
|
7
|
+
datasetfilter?: string | null; // Filter entries by sourceParams.dataset
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
interface Props {
|
|
6
11
|
id?: string;
|
|
7
12
|
dcapiurl?: string;
|
|
@@ -9,8 +14,9 @@
|
|
|
9
14
|
datatypefilter?: DataType | DataType[] | null;
|
|
10
15
|
namefilter?: string | string[] | null;
|
|
11
16
|
initialselection?: string | null;
|
|
12
|
-
onentryselect?: (entry: CatalogEntry) => void;
|
|
13
|
-
onitemsloaded?: (
|
|
17
|
+
onentryselect?: (entry: CatalogEntry | null) => void;
|
|
18
|
+
onitemsloaded?: (filtered: CatalogEntry[], all: CatalogEntry[]) => void;
|
|
19
|
+
onsearchmiss?: (text: string) => void; // Called when searchtext matches nothing
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
let {
|
|
@@ -21,7 +27,8 @@
|
|
|
21
27
|
namefilter = null,
|
|
22
28
|
initialselection = null,
|
|
23
29
|
onentryselect = null,
|
|
24
|
-
onitemsloaded = null
|
|
30
|
+
onitemsloaded = null,
|
|
31
|
+
onsearchmiss = null
|
|
25
32
|
}: Props = $props();
|
|
26
33
|
|
|
27
34
|
let catalogEntries = $state<CatalogEntry[]>([]);
|
|
@@ -31,6 +38,13 @@
|
|
|
31
38
|
let error = $state<string | null>(null);
|
|
32
39
|
let dropdownRef = $state<HTMLElement | null>(null);
|
|
33
40
|
|
|
41
|
+
// Active dynamic filters (set via setFilters method)
|
|
42
|
+
let activeSearchtext: string | null = null;
|
|
43
|
+
let activeDatasetfilter: string | null = null;
|
|
44
|
+
let autoSelectedId: string | null = null;
|
|
45
|
+
let searchMissText = $state<string | null>(null);
|
|
46
|
+
let multipleMatchText = $state<string | null>(null);
|
|
47
|
+
|
|
34
48
|
// Load catalog entries when component mounts or dcapiurl/sourcetypefilter changes
|
|
35
49
|
$effect(() => {
|
|
36
50
|
// Read sourcetypefilter to establish dependency tracking
|
|
@@ -40,11 +54,6 @@
|
|
|
40
54
|
}
|
|
41
55
|
});
|
|
42
56
|
|
|
43
|
-
// Apply client-side filters when entries or filters change
|
|
44
|
-
$effect(() => {
|
|
45
|
-
filteredEntries = applyFilters(catalogEntries);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
57
|
// Inject styles into shadow DOM to fix trigger-label width
|
|
49
58
|
$effect(() => {
|
|
50
59
|
if (dropdownRef) {
|
|
@@ -60,11 +69,10 @@
|
|
|
60
69
|
}
|
|
61
70
|
});
|
|
62
71
|
|
|
63
|
-
function
|
|
72
|
+
function applyBaseFilters(entries: CatalogEntry[]): CatalogEntry[] {
|
|
64
73
|
let result = entries;
|
|
65
74
|
|
|
66
75
|
// Filter by source type name (from sourceConnection.sourceType.name)
|
|
67
|
-
// Note: Server-side filtering is now done via API, this is just for additional client-side filtering if needed
|
|
68
76
|
if (sourcetypefilter && sourcetypefilter.length > 0) {
|
|
69
77
|
const sourceTypeNames = Array.isArray(sourcetypefilter) ? sourcetypefilter : [sourcetypefilter];
|
|
70
78
|
result = result.filter(entry =>
|
|
@@ -84,6 +92,54 @@
|
|
|
84
92
|
return result;
|
|
85
93
|
}
|
|
86
94
|
|
|
95
|
+
function applyDynamicFilters(entries: CatalogEntry[], { skipSearch = false } = {}): CatalogEntry[] {
|
|
96
|
+
let result = entries;
|
|
97
|
+
|
|
98
|
+
if (activeDatasetfilter) {
|
|
99
|
+
result = result.filter(entry =>
|
|
100
|
+
entry.sourceParams?.dataset === activeDatasetfilter
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!skipSearch && activeSearchtext?.trim()) {
|
|
105
|
+
const needle = activeSearchtext.trim().toLowerCase();
|
|
106
|
+
result = result.filter(entry =>
|
|
107
|
+
entry.name?.toLowerCase().includes(needle)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function runFilters() {
|
|
115
|
+
const base = applyBaseFilters(catalogEntries);
|
|
116
|
+
let result = applyDynamicFilters(base);
|
|
117
|
+
|
|
118
|
+
// Search-miss fallback: drop search filter and notify consumer
|
|
119
|
+
if (result.length === 0 && activeSearchtext?.trim()) {
|
|
120
|
+
searchMissText = activeSearchtext.trim();
|
|
121
|
+
multipleMatchText = null;
|
|
122
|
+
result = applyDynamicFilters(base, { skipSearch: true });
|
|
123
|
+
onsearchmiss?.(activeSearchtext.trim());
|
|
124
|
+
} else {
|
|
125
|
+
searchMissText = null;
|
|
126
|
+
multipleMatchText = (result.length > 1 && activeSearchtext?.trim()) ? activeSearchtext.trim() : null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
filteredEntries = result;
|
|
130
|
+
|
|
131
|
+
// Auto-select / auto-clear only when dynamic filters are active
|
|
132
|
+
if (activeSearchtext?.trim() || activeDatasetfilter) {
|
|
133
|
+
if (result.length === 1 && result[0].id !== autoSelectedId) {
|
|
134
|
+
autoSelectedId = result[0].id;
|
|
135
|
+
select(result[0]);
|
|
136
|
+
} else if (result.length !== 1) {
|
|
137
|
+
autoSelectedId = null;
|
|
138
|
+
select(null);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
87
143
|
async function loadCatalogEntries() {
|
|
88
144
|
loading = true;
|
|
89
145
|
error = null;
|
|
@@ -104,8 +160,13 @@
|
|
|
104
160
|
|
|
105
161
|
const result = await client.catalogEntries.get(filters);
|
|
106
162
|
catalogEntries = result.items || [];
|
|
107
|
-
// Apply filters synchronously so initialselection works
|
|
108
|
-
filteredEntries =
|
|
163
|
+
// Apply base filters synchronously so initialselection works
|
|
164
|
+
filteredEntries = applyBaseFilters(catalogEntries);
|
|
165
|
+
|
|
166
|
+
// Re-apply dynamic filters if any are active
|
|
167
|
+
if (activeSearchtext || activeDatasetfilter) {
|
|
168
|
+
runFilters();
|
|
169
|
+
}
|
|
109
170
|
|
|
110
171
|
// Auto-select initial selection if provided
|
|
111
172
|
if (initialselection) {
|
|
@@ -116,7 +177,7 @@
|
|
|
116
177
|
}
|
|
117
178
|
}
|
|
118
179
|
|
|
119
|
-
onitemsloaded?.(filteredEntries);
|
|
180
|
+
onitemsloaded?.(filteredEntries, catalogEntries);
|
|
120
181
|
} catch (e) {
|
|
121
182
|
console.error('Failed to load catalog entries:', e);
|
|
122
183
|
error = e.message || 'Failed to load catalog entries';
|
|
@@ -138,20 +199,29 @@
|
|
|
138
199
|
}
|
|
139
200
|
}
|
|
140
201
|
|
|
141
|
-
//
|
|
142
|
-
export function
|
|
202
|
+
// Set dynamic filters and re-run filter logic. Call with {} to clear all dynamic filters.
|
|
203
|
+
export function setFilters(opts: FilterOptions) {
|
|
204
|
+
activeSearchtext = opts.searchtext ?? null;
|
|
205
|
+
activeDatasetfilter = opts.datasetfilter ?? null;
|
|
206
|
+
runFilters();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Programmatically select a catalog entry (pass null to clear)
|
|
210
|
+
export function select(idOrEntry: string | CatalogEntry | null) {
|
|
211
|
+
if (!idOrEntry) {
|
|
212
|
+
selectedValue = '';
|
|
213
|
+
if (dropdownRef) dropdownRef.value = '';
|
|
214
|
+
onentryselect?.(null);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
143
217
|
const id = typeof idOrEntry === 'string' ? idOrEntry : idOrEntry?.id;
|
|
144
218
|
if (!id) return;
|
|
145
219
|
|
|
146
220
|
const entry = filteredEntries.find(ce => ce.id === id);
|
|
147
221
|
if (entry) {
|
|
148
222
|
selectedValue = id;
|
|
149
|
-
if (dropdownRef)
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
if (onentryselect) {
|
|
153
|
-
onentryselect(entry);
|
|
154
|
-
}
|
|
223
|
+
if (dropdownRef) dropdownRef.value = id;
|
|
224
|
+
onentryselect?.(entry);
|
|
155
225
|
}
|
|
156
226
|
}
|
|
157
227
|
|
|
@@ -169,6 +239,13 @@
|
|
|
169
239
|
export function getAllEntries(): CatalogEntry[] {
|
|
170
240
|
return catalogEntries;
|
|
171
241
|
}
|
|
242
|
+
|
|
243
|
+
// Reload entries from the API, optionally auto-selecting an entry by ID after reload
|
|
244
|
+
export function reload(selectAfterReload?: string) {
|
|
245
|
+
loadCatalogEntries().then(() => {
|
|
246
|
+
if (selectAfterReload) select(selectAfterReload);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
172
249
|
</script>
|
|
173
250
|
|
|
174
251
|
{#if loading}
|
|
@@ -208,8 +285,42 @@
|
|
|
208
285
|
</cds-dropdown-item>
|
|
209
286
|
{/each}
|
|
210
287
|
</cds-dropdown>
|
|
288
|
+
{#if searchMissText}
|
|
289
|
+
<div class="search-miss search-miss-muted">
|
|
290
|
+
<svg viewBox="0 0 32 32" fill="currentColor" width="14" height="14">
|
|
291
|
+
<path d="M16 2a14 14 0 1014 14A14 14 0 0016 2zm-1.13 5h2.25v12h-2.25zm1.13 17a1.5 1.5 0 111.5-1.5A1.5 1.5 0 0116 24z"/>
|
|
292
|
+
</svg>
|
|
293
|
+
<span>No match for "{searchMissText}" — showing all entries</span>
|
|
294
|
+
</div>
|
|
295
|
+
{/if}
|
|
296
|
+
{#if multipleMatchText}
|
|
297
|
+
<div class="search-miss search-miss-muted">
|
|
298
|
+
<svg viewBox="0 0 32 32" fill="currentColor" width="14" height="14">
|
|
299
|
+
<path d="M16 2a14 14 0 1014 14A14 14 0 0016 2zm-1.13 5h2.25v12h-2.25zm1.13 17a1.5 1.5 0 111.5-1.5A1.5 1.5 0 0116 24z"/>
|
|
300
|
+
</svg>
|
|
301
|
+
<span>Multiple entries found for "{multipleMatchText}" — please make a selection</span>
|
|
302
|
+
</div>
|
|
303
|
+
{/if}
|
|
211
304
|
{/if}
|
|
212
305
|
|
|
213
306
|
<style>
|
|
214
|
-
|
|
307
|
+
.search-miss {
|
|
308
|
+
display: flex;
|
|
309
|
+
align-items: center;
|
|
310
|
+
gap: 0.5rem;
|
|
311
|
+
padding: 0.5rem 0.75rem;
|
|
312
|
+
margin-top: 0.25rem;
|
|
313
|
+
font-size: 0.875rem;
|
|
314
|
+
background: var(--cds-support-warning, #f1c21b);
|
|
315
|
+
color: #161616;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.search-miss-muted {
|
|
319
|
+
background: var(--cds-layer-02, #e0e0e0);
|
|
320
|
+
color: var(--cds-text-secondary, #525252);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.search-miss svg {
|
|
324
|
+
flex-shrink: 0;
|
|
325
|
+
}
|
|
215
326
|
</style>
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { CatalogEntry, DataType } from '@industream/datacatalog-client/dto';
|
|
2
|
+
interface FilterOptions {
|
|
3
|
+
searchtext?: string | null;
|
|
4
|
+
datasetfilter?: string | null;
|
|
5
|
+
}
|
|
2
6
|
interface Props {
|
|
3
7
|
id?: string;
|
|
4
8
|
dcapiurl?: string;
|
|
@@ -6,14 +10,17 @@ interface Props {
|
|
|
6
10
|
datatypefilter?: DataType | DataType[] | null;
|
|
7
11
|
namefilter?: string | string[] | null;
|
|
8
12
|
initialselection?: string | null;
|
|
9
|
-
onentryselect?: (entry: CatalogEntry) => void;
|
|
10
|
-
onitemsloaded?: (
|
|
13
|
+
onentryselect?: (entry: CatalogEntry | null) => void;
|
|
14
|
+
onitemsloaded?: (filtered: CatalogEntry[], all: CatalogEntry[]) => void;
|
|
15
|
+
onsearchmiss?: (text: string) => void;
|
|
11
16
|
}
|
|
12
17
|
declare const DCCatalogEntry: import("svelte").Component<Props, {
|
|
13
|
-
|
|
18
|
+
setFilters: (opts: FilterOptions) => void;
|
|
19
|
+
select: (idOrEntry: string | CatalogEntry | null) => void;
|
|
14
20
|
getSelection: () => CatalogEntry | null;
|
|
15
21
|
getEntries: () => CatalogEntry[];
|
|
16
22
|
getAllEntries: () => CatalogEntry[];
|
|
23
|
+
reload: (selectAfterReload?: string) => void;
|
|
17
24
|
}, "">;
|
|
18
25
|
type DCCatalogEntry = ReturnType<typeof DCCatalogEntry>;
|
|
19
26
|
export default DCCatalogEntry;
|
package/package.json
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import { DataCatalogClient } from '@industream/datacatalog-client';
|
|
3
3
|
import type { CatalogEntry, DataType, SourceType } from '@industream/datacatalog-client/dto';
|
|
4
4
|
|
|
5
|
+
interface FilterOptions {
|
|
6
|
+
searchtext?: string | null; // Case-insensitive LIKE %text% filter on entry name
|
|
7
|
+
datasetfilter?: string | null; // Filter entries by sourceParams.dataset
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
interface Props {
|
|
6
11
|
id?: string;
|
|
7
12
|
dcapiurl?: string;
|
|
@@ -9,8 +14,9 @@
|
|
|
9
14
|
datatypefilter?: DataType | DataType[] | null;
|
|
10
15
|
namefilter?: string | string[] | null;
|
|
11
16
|
initialselection?: string | null;
|
|
12
|
-
onentryselect?: (entry: CatalogEntry) => void;
|
|
13
|
-
onitemsloaded?: (
|
|
17
|
+
onentryselect?: (entry: CatalogEntry | null) => void;
|
|
18
|
+
onitemsloaded?: (filtered: CatalogEntry[], all: CatalogEntry[]) => void;
|
|
19
|
+
onsearchmiss?: (text: string) => void; // Called when searchtext matches nothing
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
let {
|
|
@@ -21,7 +27,8 @@
|
|
|
21
27
|
namefilter = null,
|
|
22
28
|
initialselection = null,
|
|
23
29
|
onentryselect = null,
|
|
24
|
-
onitemsloaded = null
|
|
30
|
+
onitemsloaded = null,
|
|
31
|
+
onsearchmiss = null
|
|
25
32
|
}: Props = $props();
|
|
26
33
|
|
|
27
34
|
let catalogEntries = $state<CatalogEntry[]>([]);
|
|
@@ -31,6 +38,13 @@
|
|
|
31
38
|
let error = $state<string | null>(null);
|
|
32
39
|
let dropdownRef = $state<HTMLElement | null>(null);
|
|
33
40
|
|
|
41
|
+
// Active dynamic filters (set via setFilters method)
|
|
42
|
+
let activeSearchtext: string | null = null;
|
|
43
|
+
let activeDatasetfilter: string | null = null;
|
|
44
|
+
let autoSelectedId: string | null = null;
|
|
45
|
+
let searchMissText = $state<string | null>(null);
|
|
46
|
+
let multipleMatchText = $state<string | null>(null);
|
|
47
|
+
|
|
34
48
|
// Load catalog entries when component mounts or dcapiurl/sourcetypefilter changes
|
|
35
49
|
$effect(() => {
|
|
36
50
|
// Read sourcetypefilter to establish dependency tracking
|
|
@@ -40,11 +54,6 @@
|
|
|
40
54
|
}
|
|
41
55
|
});
|
|
42
56
|
|
|
43
|
-
// Apply client-side filters when entries or filters change
|
|
44
|
-
$effect(() => {
|
|
45
|
-
filteredEntries = applyFilters(catalogEntries);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
57
|
// Inject styles into shadow DOM to fix trigger-label width
|
|
49
58
|
$effect(() => {
|
|
50
59
|
if (dropdownRef) {
|
|
@@ -60,11 +69,10 @@
|
|
|
60
69
|
}
|
|
61
70
|
});
|
|
62
71
|
|
|
63
|
-
function
|
|
72
|
+
function applyBaseFilters(entries: CatalogEntry[]): CatalogEntry[] {
|
|
64
73
|
let result = entries;
|
|
65
74
|
|
|
66
75
|
// Filter by source type name (from sourceConnection.sourceType.name)
|
|
67
|
-
// Note: Server-side filtering is now done via API, this is just for additional client-side filtering if needed
|
|
68
76
|
if (sourcetypefilter && sourcetypefilter.length > 0) {
|
|
69
77
|
const sourceTypeNames = Array.isArray(sourcetypefilter) ? sourcetypefilter : [sourcetypefilter];
|
|
70
78
|
result = result.filter(entry =>
|
|
@@ -84,6 +92,54 @@
|
|
|
84
92
|
return result;
|
|
85
93
|
}
|
|
86
94
|
|
|
95
|
+
function applyDynamicFilters(entries: CatalogEntry[], { skipSearch = false } = {}): CatalogEntry[] {
|
|
96
|
+
let result = entries;
|
|
97
|
+
|
|
98
|
+
if (activeDatasetfilter) {
|
|
99
|
+
result = result.filter(entry =>
|
|
100
|
+
entry.sourceParams?.dataset === activeDatasetfilter
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!skipSearch && activeSearchtext?.trim()) {
|
|
105
|
+
const needle = activeSearchtext.trim().toLowerCase();
|
|
106
|
+
result = result.filter(entry =>
|
|
107
|
+
entry.name?.toLowerCase().includes(needle)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function runFilters() {
|
|
115
|
+
const base = applyBaseFilters(catalogEntries);
|
|
116
|
+
let result = applyDynamicFilters(base);
|
|
117
|
+
|
|
118
|
+
// Search-miss fallback: drop search filter and notify consumer
|
|
119
|
+
if (result.length === 0 && activeSearchtext?.trim()) {
|
|
120
|
+
searchMissText = activeSearchtext.trim();
|
|
121
|
+
multipleMatchText = null;
|
|
122
|
+
result = applyDynamicFilters(base, { skipSearch: true });
|
|
123
|
+
onsearchmiss?.(activeSearchtext.trim());
|
|
124
|
+
} else {
|
|
125
|
+
searchMissText = null;
|
|
126
|
+
multipleMatchText = (result.length > 1 && activeSearchtext?.trim()) ? activeSearchtext.trim() : null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
filteredEntries = result;
|
|
130
|
+
|
|
131
|
+
// Auto-select / auto-clear only when dynamic filters are active
|
|
132
|
+
if (activeSearchtext?.trim() || activeDatasetfilter) {
|
|
133
|
+
if (result.length === 1 && result[0].id !== autoSelectedId) {
|
|
134
|
+
autoSelectedId = result[0].id;
|
|
135
|
+
select(result[0]);
|
|
136
|
+
} else if (result.length !== 1) {
|
|
137
|
+
autoSelectedId = null;
|
|
138
|
+
select(null);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
87
143
|
async function loadCatalogEntries() {
|
|
88
144
|
loading = true;
|
|
89
145
|
error = null;
|
|
@@ -104,8 +160,13 @@
|
|
|
104
160
|
|
|
105
161
|
const result = await client.catalogEntries.get(filters);
|
|
106
162
|
catalogEntries = result.items || [];
|
|
107
|
-
// Apply filters synchronously so initialselection works
|
|
108
|
-
filteredEntries =
|
|
163
|
+
// Apply base filters synchronously so initialselection works
|
|
164
|
+
filteredEntries = applyBaseFilters(catalogEntries);
|
|
165
|
+
|
|
166
|
+
// Re-apply dynamic filters if any are active
|
|
167
|
+
if (activeSearchtext || activeDatasetfilter) {
|
|
168
|
+
runFilters();
|
|
169
|
+
}
|
|
109
170
|
|
|
110
171
|
// Auto-select initial selection if provided
|
|
111
172
|
if (initialselection) {
|
|
@@ -116,7 +177,7 @@
|
|
|
116
177
|
}
|
|
117
178
|
}
|
|
118
179
|
|
|
119
|
-
onitemsloaded?.(filteredEntries);
|
|
180
|
+
onitemsloaded?.(filteredEntries, catalogEntries);
|
|
120
181
|
} catch (e) {
|
|
121
182
|
console.error('Failed to load catalog entries:', e);
|
|
122
183
|
error = e.message || 'Failed to load catalog entries';
|
|
@@ -138,20 +199,29 @@
|
|
|
138
199
|
}
|
|
139
200
|
}
|
|
140
201
|
|
|
141
|
-
//
|
|
142
|
-
export function
|
|
202
|
+
// Set dynamic filters and re-run filter logic. Call with {} to clear all dynamic filters.
|
|
203
|
+
export function setFilters(opts: FilterOptions) {
|
|
204
|
+
activeSearchtext = opts.searchtext ?? null;
|
|
205
|
+
activeDatasetfilter = opts.datasetfilter ?? null;
|
|
206
|
+
runFilters();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Programmatically select a catalog entry (pass null to clear)
|
|
210
|
+
export function select(idOrEntry: string | CatalogEntry | null) {
|
|
211
|
+
if (!idOrEntry) {
|
|
212
|
+
selectedValue = '';
|
|
213
|
+
if (dropdownRef) dropdownRef.value = '';
|
|
214
|
+
onentryselect?.(null);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
143
217
|
const id = typeof idOrEntry === 'string' ? idOrEntry : idOrEntry?.id;
|
|
144
218
|
if (!id) return;
|
|
145
219
|
|
|
146
220
|
const entry = filteredEntries.find(ce => ce.id === id);
|
|
147
221
|
if (entry) {
|
|
148
222
|
selectedValue = id;
|
|
149
|
-
if (dropdownRef)
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
if (onentryselect) {
|
|
153
|
-
onentryselect(entry);
|
|
154
|
-
}
|
|
223
|
+
if (dropdownRef) dropdownRef.value = id;
|
|
224
|
+
onentryselect?.(entry);
|
|
155
225
|
}
|
|
156
226
|
}
|
|
157
227
|
|
|
@@ -169,6 +239,13 @@
|
|
|
169
239
|
export function getAllEntries(): CatalogEntry[] {
|
|
170
240
|
return catalogEntries;
|
|
171
241
|
}
|
|
242
|
+
|
|
243
|
+
// Reload entries from the API, optionally auto-selecting an entry by ID after reload
|
|
244
|
+
export function reload(selectAfterReload?: string) {
|
|
245
|
+
loadCatalogEntries().then(() => {
|
|
246
|
+
if (selectAfterReload) select(selectAfterReload);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
172
249
|
</script>
|
|
173
250
|
|
|
174
251
|
{#if loading}
|
|
@@ -208,8 +285,42 @@
|
|
|
208
285
|
</cds-dropdown-item>
|
|
209
286
|
{/each}
|
|
210
287
|
</cds-dropdown>
|
|
288
|
+
{#if searchMissText}
|
|
289
|
+
<div class="search-miss search-miss-muted">
|
|
290
|
+
<svg viewBox="0 0 32 32" fill="currentColor" width="14" height="14">
|
|
291
|
+
<path d="M16 2a14 14 0 1014 14A14 14 0 0016 2zm-1.13 5h2.25v12h-2.25zm1.13 17a1.5 1.5 0 111.5-1.5A1.5 1.5 0 0116 24z"/>
|
|
292
|
+
</svg>
|
|
293
|
+
<span>No match for "{searchMissText}" — showing all entries</span>
|
|
294
|
+
</div>
|
|
295
|
+
{/if}
|
|
296
|
+
{#if multipleMatchText}
|
|
297
|
+
<div class="search-miss search-miss-muted">
|
|
298
|
+
<svg viewBox="0 0 32 32" fill="currentColor" width="14" height="14">
|
|
299
|
+
<path d="M16 2a14 14 0 1014 14A14 14 0 0016 2zm-1.13 5h2.25v12h-2.25zm1.13 17a1.5 1.5 0 111.5-1.5A1.5 1.5 0 0116 24z"/>
|
|
300
|
+
</svg>
|
|
301
|
+
<span>Multiple entries found for "{multipleMatchText}" — please make a selection</span>
|
|
302
|
+
</div>
|
|
303
|
+
{/if}
|
|
211
304
|
{/if}
|
|
212
305
|
|
|
213
306
|
<style>
|
|
214
|
-
|
|
307
|
+
.search-miss {
|
|
308
|
+
display: flex;
|
|
309
|
+
align-items: center;
|
|
310
|
+
gap: 0.5rem;
|
|
311
|
+
padding: 0.5rem 0.75rem;
|
|
312
|
+
margin-top: 0.25rem;
|
|
313
|
+
font-size: 0.875rem;
|
|
314
|
+
background: var(--cds-support-warning, #f1c21b);
|
|
315
|
+
color: #161616;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.search-miss-muted {
|
|
319
|
+
background: var(--cds-layer-02, #e0e0e0);
|
|
320
|
+
color: var(--cds-text-secondary, #525252);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.search-miss svg {
|
|
324
|
+
flex-shrink: 0;
|
|
325
|
+
}
|
|
215
326
|
</style>
|