lula2 0.3.1 → 0.3.2-nightly.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.
- package/dist/_app/immutable/assets/0.CLKu6Q8_.css +1 -0
- package/dist/_app/immutable/chunks/0xMSlW4Y.js +65 -0
- package/dist/_app/immutable/chunks/{BtOhWAVU.js → 152nb-LI.js} +2 -2
- package/dist/_app/immutable/chunks/{C5zWTfmV.js → 1spjHGNy.js} +1 -1
- package/dist/_app/immutable/chunks/{DnJ0bPgj.js → BtuEtkd3.js} +1 -1
- package/dist/_app/immutable/chunks/C113Bo4B.js +2 -0
- package/dist/_app/immutable/chunks/{CoF2vljD.js → CNOPXlDW.js} +1 -1
- package/dist/_app/immutable/chunks/{DqsOU3kV.js → DY3-lqhI.js} +1 -1
- package/dist/_app/immutable/chunks/{Ds14DLx0.js → DrOkR2YZ.js} +3 -3
- package/dist/_app/immutable/chunks/rsJnd9Tf.js +1 -0
- package/dist/_app/immutable/entry/{app.XLGRlmCF.js → app.CqP__jbe.js} +2 -2
- package/dist/_app/immutable/entry/start.C1hW6Z_g.js +1 -0
- package/dist/_app/immutable/nodes/{0.B6W16O68.js → 0.BWuQSqPo.js} +1 -1
- package/dist/_app/immutable/nodes/{1.wIilWkgu.js → 1.COMBeJ1R.js} +1 -1
- package/dist/_app/immutable/nodes/{2.CG53uQH9.js → 2.6bQMjmMR.js} +1 -1
- package/dist/_app/immutable/nodes/{3.D4uH9LCp.js → 3.BBPnkpxM.js} +1 -1
- package/dist/_app/immutable/nodes/{4.sYW2-VhJ.js → 4.CGIAObAE.js} +1 -1
- package/dist/_app/version.json +1 -1
- package/dist/cli/commands/ui.js +6 -6
- package/dist/cli/server/index.js +6 -6
- package/dist/cli/server/server.js +6 -6
- package/dist/cli/server/serverState.js +2 -2
- package/dist/cli/server/spreadsheetRoutes.js +4 -4
- package/dist/cli/server/websocketServer.js +6 -6
- package/dist/index.html +10 -10
- package/dist/index.js +6 -6
- package/package.json +21 -21
- package/src/lib/actions/clickOutside.ts +24 -0
- package/src/lib/components/controls/ControlsList.svelte +101 -75
- package/src/lib/components/controls/tabs/CustomFieldsTab.svelte +1 -1
- package/src/lib/components/controls/tabs/TimelineTab.svelte +1 -1
- package/src/lib/components/controls/utils/ProcessedTextRenderer.svelte +1 -1
- package/src/lib/components/forms/DynamicControlForm.svelte +2 -2
- package/src/lib/components/setup/ExistingControlSets.svelte +0 -1
- package/src/lib/components/setup/SpreadsheetImport.svelte +10 -10
- package/src/lib/components/ui/CustomDropdown.svelte +96 -0
- package/src/lib/components/ui/FilterBuilder.svelte +415 -0
- package/src/stores/compliance.ts +149 -39
- package/dist/_app/immutable/assets/0.Dv98laBw.css +0 -1
- package/dist/_app/immutable/chunks/BW28MavF.js +0 -1
- package/dist/_app/immutable/chunks/Cby0Z7eP.js +0 -2
- package/dist/_app/immutable/chunks/DQAmyY_z.js +0 -66
- package/dist/_app/immutable/entry/start.68S9ad6U.js +0 -1
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
<script lang="ts">
|
|
5
5
|
import { goto } from '$app/navigation';
|
|
6
6
|
import { page } from '$app/stores';
|
|
7
|
-
import {
|
|
7
|
+
import { SearchBar, Tooltip } from '$components/ui';
|
|
8
|
+
import FilterBuilder from '$components/ui/FilterBuilder.svelte';
|
|
8
9
|
import type { Control, FieldSchema } from '$lib/types';
|
|
9
10
|
import { appState } from '$lib/websocket';
|
|
10
|
-
import { complianceStore, searchTerm,
|
|
11
|
-
import {
|
|
11
|
+
import { complianceStore, searchTerm, activeFilters, getOperatorLabel } from '$stores/compliance';
|
|
12
|
+
import { Information } from 'carbon-icons-svelte';
|
|
12
13
|
import { derived } from 'svelte/store';
|
|
13
14
|
|
|
14
|
-
// Derive controls
|
|
15
|
+
// Derive controls from appState
|
|
15
16
|
const controls = derived(appState, ($state) => $state.controls || []);
|
|
16
|
-
const families = derived(appState, ($state) => $state.families || []);
|
|
17
17
|
const loading = derived(appState, ($state) => !$state.isConnected);
|
|
18
18
|
|
|
19
19
|
// Derive controls with mappings
|
|
@@ -104,26 +104,64 @@
|
|
|
104
104
|
|
|
105
105
|
// Create filtered controls with mappings
|
|
106
106
|
const filteredControlsWithMappings = derived(
|
|
107
|
-
[controlsWithMappings,
|
|
108
|
-
([$controlsWithMappings, $
|
|
107
|
+
[controlsWithMappings, searchTerm, activeFilters],
|
|
108
|
+
([$controlsWithMappings, $searchTerm, $activeFilters]) => {
|
|
109
109
|
let results = $controlsWithMappings;
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
results = results.filter((c) => {
|
|
113
|
-
const family =
|
|
114
|
-
(c as any)?._metadata?.family ||
|
|
115
|
-
(c as any)?.family ||
|
|
116
|
-
(c as any)?.['control-acronym']?.split('-')[0] ||
|
|
117
|
-
'';
|
|
118
|
-
return family === $selectedFamily;
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
111
|
+
// Apply search term
|
|
122
112
|
if ($searchTerm) {
|
|
123
113
|
const term = $searchTerm.toLowerCase();
|
|
124
114
|
results = results.filter((c) => JSON.stringify(c).toLowerCase().includes(term));
|
|
125
115
|
}
|
|
126
116
|
|
|
117
|
+
// Apply advanced filters
|
|
118
|
+
if ($activeFilters.length > 0) {
|
|
119
|
+
results = results.filter((control) => {
|
|
120
|
+
// Control must match all filters
|
|
121
|
+
return $activeFilters.every(filter => {
|
|
122
|
+
const dynamicControl = control as Record<string, unknown>;
|
|
123
|
+
const fieldValue = dynamicControl[filter.fieldName];
|
|
124
|
+
|
|
125
|
+
switch (filter.operator) {
|
|
126
|
+
case 'equals':
|
|
127
|
+
return fieldValue === filter.value;
|
|
128
|
+
|
|
129
|
+
case 'not_equals':
|
|
130
|
+
return fieldValue !== filter.value;
|
|
131
|
+
|
|
132
|
+
case 'exists':
|
|
133
|
+
return fieldValue !== undefined && fieldValue !== null && fieldValue !== '';
|
|
134
|
+
|
|
135
|
+
case 'not_exists':
|
|
136
|
+
return fieldValue === undefined || fieldValue === null || fieldValue === '';
|
|
137
|
+
|
|
138
|
+
case 'includes':
|
|
139
|
+
if (typeof fieldValue === 'string') {
|
|
140
|
+
return fieldValue.toLowerCase().includes(String(filter.value).toLowerCase());
|
|
141
|
+
} else if (Array.isArray(fieldValue)) {
|
|
142
|
+
return fieldValue.some(item =>
|
|
143
|
+
String(item).toLowerCase().includes(String(filter.value).toLowerCase())
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
|
|
148
|
+
case 'not_includes':
|
|
149
|
+
if (typeof fieldValue === 'string') {
|
|
150
|
+
return !fieldValue.toLowerCase().includes(String(filter.value).toLowerCase());
|
|
151
|
+
} else if (Array.isArray(fieldValue)) {
|
|
152
|
+
return !fieldValue.some(item =>
|
|
153
|
+
String(item).toLowerCase().includes(String(filter.value).toLowerCase())
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
|
|
158
|
+
default:
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
127
165
|
return results;
|
|
128
166
|
}
|
|
129
167
|
);
|
|
@@ -243,64 +281,53 @@
|
|
|
243
281
|
</span>
|
|
244
282
|
</div>
|
|
245
283
|
|
|
246
|
-
<!-- Search Bar,
|
|
284
|
+
<!-- Search Bar, Filter, and Export -->
|
|
247
285
|
<div class="flex gap-3">
|
|
248
286
|
<div class="flex-1">
|
|
249
287
|
<SearchBar />
|
|
250
288
|
</div>
|
|
289
|
+
|
|
290
|
+
<!-- Filter Builder -->
|
|
251
291
|
<div class="flex-shrink-0">
|
|
252
|
-
<
|
|
253
|
-
buttonLabel={$selectedFamily || 'All Families'}
|
|
254
|
-
buttonIcon={Filter}
|
|
255
|
-
buttonClass="bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"
|
|
256
|
-
dropdownClass="w-64"
|
|
257
|
-
>
|
|
258
|
-
{#snippet children()}
|
|
259
|
-
<div class="space-y-1">
|
|
260
|
-
<button
|
|
261
|
-
onclick={() => {
|
|
262
|
-
complianceStore.setSelectedFamily(null);
|
|
263
|
-
}}
|
|
264
|
-
class="w-full text-left px-3 py-2 text-sm rounded-md transition-colors duration-200 flex items-center justify-between {$selectedFamily ===
|
|
265
|
-
null
|
|
266
|
-
? 'bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200'
|
|
267
|
-
: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700'}"
|
|
268
|
-
>
|
|
269
|
-
<span>All Families</span>
|
|
270
|
-
<span class="text-xs bg-gray-200 dark:bg-gray-600 px-2 py-1 rounded-full">
|
|
271
|
-
{$controls.length}
|
|
272
|
-
</span>
|
|
273
|
-
</button>
|
|
274
|
-
|
|
275
|
-
{#each $families as family}
|
|
276
|
-
{@const familyCount = $controls.filter((c) => {
|
|
277
|
-
const controlFamily =
|
|
278
|
-
(c as any)?._metadata?.family ||
|
|
279
|
-
(c as any)?.family ||
|
|
280
|
-
(c as any)?.['control-acronym']?.split('-')[0] ||
|
|
281
|
-
'';
|
|
282
|
-
return controlFamily === family;
|
|
283
|
-
}).length}
|
|
284
|
-
<button
|
|
285
|
-
onclick={() => {
|
|
286
|
-
complianceStore.setSelectedFamily(family);
|
|
287
|
-
}}
|
|
288
|
-
class="w-full text-left px-3 py-2 text-sm rounded-md transition-colors duration-200 flex items-center justify-between {$selectedFamily ===
|
|
289
|
-
family
|
|
290
|
-
? 'bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200'
|
|
291
|
-
: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700'}"
|
|
292
|
-
>
|
|
293
|
-
<span>{family}</span>
|
|
294
|
-
<span class="text-xs bg-gray-200 dark:bg-gray-600 px-2 py-1 rounded-full">
|
|
295
|
-
{familyCount}
|
|
296
|
-
</span>
|
|
297
|
-
</button>
|
|
298
|
-
{/each}
|
|
299
|
-
</div>
|
|
300
|
-
{/snippet}
|
|
301
|
-
</Dropdown>
|
|
292
|
+
<FilterBuilder />
|
|
302
293
|
</div>
|
|
303
294
|
</div>
|
|
295
|
+
|
|
296
|
+
<!-- Active Filters Summary -->
|
|
297
|
+
{#if $activeFilters.length > 0}
|
|
298
|
+
<div class="mt-2 flex flex-wrap gap-2">
|
|
299
|
+
{#each $activeFilters as filter, index}
|
|
300
|
+
<div class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300">
|
|
301
|
+
<span>{filter.fieldName}: </span>
|
|
302
|
+
{#if filter.operator === 'exists' || filter.operator === 'not_exists'}
|
|
303
|
+
<span>{getOperatorLabel(filter.operator).toLowerCase()}</span>
|
|
304
|
+
{:else if filter.operator === 'equals'}
|
|
305
|
+
<span>= {filter.value}</span>
|
|
306
|
+
{:else if filter.operator === 'not_equals'}
|
|
307
|
+
<span>≠ {filter.value}</span>
|
|
308
|
+
{:else}
|
|
309
|
+
<span>{getOperatorLabel(filter.operator).toLowerCase()} "{filter.value}"</span>
|
|
310
|
+
{/if}
|
|
311
|
+
<button
|
|
312
|
+
onclick={() => complianceStore.removeFilter(index)}
|
|
313
|
+
class="ml-1 text-blue-700 dark:text-blue-300 hover:text-blue-900 dark:hover:text-blue-100"
|
|
314
|
+
aria-label="Remove filter"
|
|
315
|
+
>
|
|
316
|
+
×
|
|
317
|
+
</button>
|
|
318
|
+
</div>
|
|
319
|
+
{/each}
|
|
320
|
+
|
|
321
|
+
{#if $activeFilters.length > 1}
|
|
322
|
+
<button
|
|
323
|
+
onclick={() => complianceStore.clearFilters()}
|
|
324
|
+
class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"
|
|
325
|
+
>
|
|
326
|
+
Clear all
|
|
327
|
+
</button>
|
|
328
|
+
{/if}
|
|
329
|
+
</div>
|
|
330
|
+
{/if}
|
|
304
331
|
</div>
|
|
305
332
|
|
|
306
333
|
<!-- Controls Table -->
|
|
@@ -582,15 +609,14 @@
|
|
|
582
609
|
</svg>
|
|
583
610
|
<h3 class="mt-4 text-lg font-medium text-gray-900 dark:text-white">No controls found</h3>
|
|
584
611
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400 max-w-sm mx-auto">
|
|
585
|
-
{#if $
|
|
586
|
-
No controls match your
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
No controls available in this family. Select a different family or check your data.
|
|
612
|
+
{#if $activeFilters.length > 0}
|
|
613
|
+
No controls match your filter criteria. Try adjusting or removing some filters.
|
|
614
|
+
{:else if $searchTerm}
|
|
615
|
+
No controls match your search criteria. Try adjusting your search terms.
|
|
590
616
|
{:else if $controls.length === 0}
|
|
591
617
|
No controls have been imported yet.
|
|
592
618
|
{:else}
|
|
593
|
-
No controls available.
|
|
619
|
+
No controls available. Check your data.
|
|
594
620
|
{/if}
|
|
595
621
|
</p>
|
|
596
622
|
{#if $controls.length === 0}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<div class="overflow-x-auto">
|
|
24
24
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
|
25
25
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
|
|
26
|
-
{#each section.data.rows as row,
|
|
26
|
+
{#each section.data.rows as row, _i}
|
|
27
27
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors">
|
|
28
28
|
{#each row.columns as column, j}
|
|
29
29
|
<td class="px-3 py-2 text-sm {j === 0 ? 'font-medium text-gray-900 dark:text-gray-100' : 'text-gray-600 dark:text-gray-400'}">
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
{#if readonly}
|
|
129
129
|
<!-- View Mode: Clean minimal layout -->
|
|
130
130
|
<div class="space-y-6">
|
|
131
|
-
{#each Object.entries(fieldGroups) as [
|
|
131
|
+
{#each Object.entries(fieldGroups) as [_groupName, fields]}
|
|
132
132
|
{#each [fields] as fieldList}
|
|
133
133
|
{@const importantFields = fieldList.filter((f) =>
|
|
134
134
|
['id', 'title', 'priority', 'status'].includes(f.id)
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
</span>
|
|
227
227
|
</h3>
|
|
228
228
|
<div class="space-y-3">
|
|
229
|
-
{#each value as item,
|
|
229
|
+
{#each value as item, _index}
|
|
230
230
|
<div
|
|
231
231
|
class="bg-gray-50 dark:bg-gray-800 rounded-lg p-4 border border-gray-200 dark:border-gray-700"
|
|
232
232
|
>
|
|
@@ -784,8 +784,8 @@
|
|
|
784
784
|
aria-label="Overview tab drop zone"
|
|
785
785
|
>
|
|
786
786
|
{#each Array.from(fieldConfigs.entries())
|
|
787
|
-
.filter(([
|
|
788
|
-
.sort((a, b) => a[1].displayOrder - b[1].displayOrder) as [field,
|
|
787
|
+
.filter(([_field, config]) => config.tab === 'overview')
|
|
788
|
+
.sort((a, b) => a[1].displayOrder - b[1].displayOrder) as [field, _config], _index (field)}
|
|
789
789
|
<div
|
|
790
790
|
draggable="true"
|
|
791
791
|
on:dragstart={(e) => handleFieldDragStart(e, field)}
|
|
@@ -805,7 +805,7 @@
|
|
|
805
805
|
<span class="truncate">{field}</span>
|
|
806
806
|
</div>
|
|
807
807
|
{/each}
|
|
808
|
-
{#if Array.from(fieldConfigs.entries()).filter(([
|
|
808
|
+
{#if Array.from(fieldConfigs.entries()).filter(([_field, config]) => config.tab === 'overview').length === 0}
|
|
809
809
|
<p class="text-xs text-gray-400 dark:text-gray-500 text-center py-4">
|
|
810
810
|
Drop fields here
|
|
811
811
|
</p>
|
|
@@ -835,8 +835,8 @@
|
|
|
835
835
|
aria-label="Implementation tab drop zone"
|
|
836
836
|
>
|
|
837
837
|
{#each Array.from(fieldConfigs.entries())
|
|
838
|
-
.filter(([
|
|
839
|
-
.sort((a, b) => a[1].displayOrder - b[1].displayOrder) as [field,
|
|
838
|
+
.filter(([_field, config]) => config.tab === 'implementation')
|
|
839
|
+
.sort((a, b) => a[1].displayOrder - b[1].displayOrder) as [field, _config], index (field)}
|
|
840
840
|
<div
|
|
841
841
|
draggable="true"
|
|
842
842
|
on:dragstart={(e) => handleFieldDragStart(e, field)}
|
|
@@ -856,7 +856,7 @@
|
|
|
856
856
|
<span class="truncate">{field}</span>
|
|
857
857
|
</div>
|
|
858
858
|
{/each}
|
|
859
|
-
{#if Array.from(fieldConfigs.entries()).filter(([
|
|
859
|
+
{#if Array.from(fieldConfigs.entries()).filter(([_field, config]) => config.tab === 'implementation').length === 0}
|
|
860
860
|
<p class="text-xs text-gray-400 dark:text-gray-500 text-center py-4">
|
|
861
861
|
Drop fields here
|
|
862
862
|
</p>
|
|
@@ -889,7 +889,7 @@
|
|
|
889
889
|
<div class="space-y-2">
|
|
890
890
|
{#if justificationFields.length > 0}
|
|
891
891
|
<!-- Display justification fields -->
|
|
892
|
-
{#each justificationFields as field,
|
|
892
|
+
{#each justificationFields as field, _index}
|
|
893
893
|
<div
|
|
894
894
|
draggable="true"
|
|
895
895
|
on:dragstart={(e) => handleFieldDragStart(e, field)}
|
|
@@ -966,8 +966,8 @@
|
|
|
966
966
|
aria-label="Custom fields drop zone"
|
|
967
967
|
>
|
|
968
968
|
{#each Array.from(fieldConfigs.entries())
|
|
969
|
-
.filter(([
|
|
970
|
-
.sort((a, b) => a[1].displayOrder - b[1].displayOrder) as [field,
|
|
969
|
+
.filter(([_field, config]) => config.tab === 'custom')
|
|
970
|
+
.sort((a, b) => a[1].displayOrder - b[1].displayOrder) as [field, _config], _index (field)}
|
|
971
971
|
<div
|
|
972
972
|
draggable="true"
|
|
973
973
|
on:dragstart={(e) => handleFieldDragStart(e, field)}
|
|
@@ -987,7 +987,7 @@
|
|
|
987
987
|
<span class="truncate">{field}</span>
|
|
988
988
|
</div>
|
|
989
989
|
{/each}
|
|
990
|
-
{#if Array.from(fieldConfigs.entries()).filter(([
|
|
990
|
+
{#if Array.from(fieldConfigs.entries()).filter(([_field, config]) => config.tab === 'custom').length === 0}
|
|
991
991
|
<p class="text-xs text-gray-400 dark:text-gray-500 text-center py-4">
|
|
992
992
|
Drop fields here
|
|
993
993
|
</p>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2023-Present The Lula Authors -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts" generics="T">
|
|
5
|
+
import { clickOutside } from '$lib/actions/clickOutside';
|
|
6
|
+
import { fade } from 'svelte/transition';
|
|
7
|
+
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { ChevronDown, ChevronUp } from 'carbon-icons-svelte';
|
|
9
|
+
|
|
10
|
+
// Props
|
|
11
|
+
export let value: T = undefined as unknown as T;
|
|
12
|
+
export let options: Array<{ value: T; label: string }> = [];
|
|
13
|
+
export let placeholder: string = 'Select an option';
|
|
14
|
+
export let label: string | undefined = undefined;
|
|
15
|
+
export let labelId: string | undefined = undefined;
|
|
16
|
+
export let getDisplayValue: (value: T) => string = (val) => {
|
|
17
|
+
const option = options.find((opt) => opt.value === val);
|
|
18
|
+
return option ? option.label : String(val);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// State
|
|
22
|
+
let isOpen = false;
|
|
23
|
+
|
|
24
|
+
// Handle selection
|
|
25
|
+
function selectOption(optionValue: T) {
|
|
26
|
+
value = optionValue;
|
|
27
|
+
isOpen = false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Handle toggle
|
|
31
|
+
function toggle() {
|
|
32
|
+
isOpen = !isOpen;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Handle close
|
|
36
|
+
function close() {
|
|
37
|
+
isOpen = false;
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<div>
|
|
42
|
+
{#if label}
|
|
43
|
+
<label for={labelId} class="block text-xs text-gray-600 dark:text-gray-400 mb-1">{label}</label>
|
|
44
|
+
{/if}
|
|
45
|
+
<div class="relative" use:clickOutside={close}>
|
|
46
|
+
<!-- Dropdown Trigger -->
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
id={labelId}
|
|
50
|
+
on:click={toggle}
|
|
51
|
+
class={twMerge(
|
|
52
|
+
'w-full flex items-center justify-between px-3 py-2 text-sm rounded-md border transition-colors',
|
|
53
|
+
isOpen
|
|
54
|
+
? 'border-blue-500 dark:border-blue-400 ring-2 ring-blue-200 dark:ring-blue-900'
|
|
55
|
+
: 'border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500',
|
|
56
|
+
'bg-white dark:bg-gray-700 text-gray-900 dark:text-white'
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
<span class="truncate">
|
|
60
|
+
{value ? getDisplayValue(value) : placeholder}
|
|
61
|
+
</span>
|
|
62
|
+
{#if isOpen}
|
|
63
|
+
<ChevronUp class="h-4 w-4 text-gray-500 dark:text-gray-400" />
|
|
64
|
+
{:else}
|
|
65
|
+
<ChevronDown class="h-4 w-4 text-gray-500 dark:text-gray-400" />
|
|
66
|
+
{/if}
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
<!-- Dropdown Menu -->
|
|
70
|
+
{#if isOpen}
|
|
71
|
+
<div
|
|
72
|
+
class="absolute z-50 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-md shadow-lg max-h-60 overflow-y-auto"
|
|
73
|
+
transition:fade={{ duration: 100 }}
|
|
74
|
+
>
|
|
75
|
+
<slot name="header" />
|
|
76
|
+
|
|
77
|
+
{#each options as option}
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
class={twMerge(
|
|
81
|
+
'w-full text-left px-3 py-2 text-sm',
|
|
82
|
+
value === option.value
|
|
83
|
+
? 'bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300'
|
|
84
|
+
: 'hover:bg-gray-100 dark:hover:bg-gray-700/50'
|
|
85
|
+
)}
|
|
86
|
+
on:click={() => selectOption(option.value)}
|
|
87
|
+
>
|
|
88
|
+
{option.label}
|
|
89
|
+
</button>
|
|
90
|
+
{/each}
|
|
91
|
+
|
|
92
|
+
<slot name="footer" />
|
|
93
|
+
</div>
|
|
94
|
+
{/if}
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|