@svadmin/ui 0.120.0 → 0.122.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.css +336 -7
- package/dist/app.theme.css +336 -7
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AnnouncementBanner.svelte +314 -0
- package/dist/components/AnnouncementBanner.svelte.d.ts +45 -0
- package/dist/components/AsyncExportModal.svelte +551 -0
- package/dist/components/AsyncExportModal.svelte.d.ts +50 -0
- package/dist/components/AudioFeedbackProvider.svelte +131 -0
- package/dist/components/AudioFeedbackProvider.svelte.d.ts +11 -0
- package/dist/components/AuditLogViewer.svelte +1 -1
- package/dist/components/CanvasAnnotation.svelte +1 -1
- package/dist/components/ColumnFilterBuilder.svelte +135 -0
- package/dist/components/ColumnFilterBuilder.svelte.d.ts +20 -0
- package/dist/components/ColumnSettings.svelte +1 -1
- package/dist/components/ColumnVisibilityDrawer.svelte +541 -0
- package/dist/components/ColumnVisibilityDrawer.svelte.d.ts +16 -0
- package/dist/components/ConcurrentConflictModal.svelte +7 -7
- package/dist/components/ContextMenu.svelte +268 -0
- package/dist/components/ContextMenu.svelte.d.ts +22 -0
- package/dist/components/ConversionFunnel.svelte +154 -0
- package/dist/components/ConversionFunnel.svelte.d.ts +22 -0
- package/dist/components/CronExpressionBuilder.svelte +1 -1
- package/dist/components/DecisionTable.svelte +1 -1
- package/dist/components/DevTools.svelte +1 -1
- package/dist/components/DraggableRowTable.svelte +1 -1
- package/dist/components/DualApprovalGate.svelte +418 -0
- package/dist/components/DualApprovalGate.svelte.d.ts +39 -0
- package/dist/components/EditableTable.svelte +1 -1
- package/dist/components/ExcelImportWizard.svelte +2 -2
- package/dist/components/GlobalShortcuts.svelte +1 -1
- package/dist/components/ImageCropper.svelte +1 -1
- package/dist/components/ImportWizard.svelte +1 -1
- package/dist/components/JsonSchemaForm.svelte +1 -1
- package/dist/components/JsonViewer.svelte +323 -0
- package/dist/components/JsonViewer.svelte.d.ts +20 -0
- package/dist/components/KeyboardShortcutsModal.svelte +362 -0
- package/dist/components/KeyboardShortcutsModal.svelte.d.ts +22 -0
- package/dist/components/KpiCard.svelte +250 -0
- package/dist/components/KpiCard.svelte.d.ts +44 -0
- package/dist/components/MasterDetailView.svelte +1 -1
- package/dist/components/MetricGrid.svelte +2 -2
- package/dist/components/MicroAppBridge.svelte +59 -0
- package/dist/components/MicroAppBridge.svelte.d.ts +11 -0
- package/dist/components/OfflineSyncBanner.svelte +1 -1
- package/dist/components/OrgChart.svelte +1 -1
- package/dist/components/OrgTreePicker.svelte +1 -1
- package/dist/components/OtpInput.svelte +209 -0
- package/dist/components/OtpInput.svelte.d.ts +17 -0
- package/dist/components/PdfDocumentViewer.svelte +2 -2
- package/dist/components/PivotDrilldownModal.svelte +6 -6
- package/dist/components/PivotTable.svelte +1 -1
- package/dist/components/PricingCard.svelte +1 -1
- package/dist/components/PricingTable.svelte +1 -1
- package/dist/components/PrintableBill.svelte +2 -2
- package/dist/components/PrintableReportLayout.svelte +259 -0
- package/dist/components/PrintableReportLayout.svelte.d.ts +32 -0
- package/dist/components/ProSkeleton.svelte +6 -6
- package/dist/components/RecordCompareModal.svelte +428 -0
- package/dist/components/RecordCompareModal.svelte.d.ts +42 -0
- package/dist/components/ResultPage.svelte +166 -0
- package/dist/components/ResultPage.svelte.d.ts +28 -0
- package/dist/components/SafeDeleteConfirm.svelte +5 -5
- package/dist/components/SankeyChart.svelte +111 -0
- package/dist/components/SankeyChart.svelte.d.ts +22 -0
- package/dist/components/SchemaVisualModeler.svelte +336 -0
- package/dist/components/SchemaVisualModeler.svelte.d.ts +17 -0
- package/dist/components/SensitiveDataMask.svelte +81 -22
- package/dist/components/SensitiveDataMask.svelte.d.ts +15 -10
- package/dist/components/SessionTimeoutGuard.svelte +154 -0
- package/dist/components/SessionTimeoutGuard.svelte.d.ts +25 -0
- package/dist/components/SignaturePad.svelte +231 -67
- package/dist/components/SignaturePad.svelte.d.ts +6 -5
- package/dist/components/SliderCaptcha.svelte +1 -1
- package/dist/components/SplitPaneLayout.svelte +1 -1
- package/dist/components/SpreadsheetView.svelte +1 -1
- package/dist/components/StepForm.svelte +1 -1
- package/dist/components/StepWizard.svelte +513 -0
- package/dist/components/StepWizard.svelte.d.ts +49 -0
- package/dist/components/TableClipboardManager.svelte +307 -0
- package/dist/components/TableClipboardManager.svelte.d.ts +13 -0
- package/dist/components/TaskCenter.svelte +9 -9
- package/dist/components/TextDiffViewer.svelte +613 -0
- package/dist/components/TextDiffViewer.svelte.d.ts +39 -0
- package/dist/components/Tour.svelte +71 -13
- package/dist/components/Tour.svelte.d.ts +1 -1
- package/dist/components/TreeTransfer.svelte +1 -1
- package/dist/components/TrendIndicator.svelte +21 -13
- package/dist/components/TrendIndicator.svelte.d.ts +4 -2
- package/dist/components/UnsavedChangesGuard.svelte +138 -0
- package/dist/components/UnsavedChangesGuard.svelte.d.ts +32 -0
- package/dist/components/UsageCard.svelte +1 -1
- package/dist/components/VersionDiffViewer.svelte +1 -1
- package/dist/components/VirtualTable.svelte +1 -1
- package/dist/components/VirtualTreeSelect.svelte +1 -1
- package/dist/components/WatermarkContainer.svelte +196 -0
- package/dist/components/WatermarkContainer.svelte.d.ts +20 -0
- package/dist/components/WorkflowDesigner.svelte +3 -3
- package/dist/components/WorkflowProcessCard.svelte +1 -1
- package/dist/components/WorkflowStepper.svelte +250 -0
- package/dist/components/WorkflowStepper.svelte.d.ts +27 -0
- package/dist/components/charts/GaugeChart.svelte +1 -1
- package/dist/components/useAudioAlert.d.svelte.ts +1 -0
- package/dist/components/useAudioAlert.svelte.d.ts +13 -0
- package/dist/components/useAudioAlert.svelte.js +90 -0
- package/dist/components/useHotkeys.d.svelte.ts +1 -0
- package/dist/components/useHotkeys.svelte.d.ts +44 -0
- package/dist/components/useHotkeys.svelte.js +190 -0
- package/dist/components/useMicroAppEvent.d.svelte.ts +1 -0
- package/dist/components/useMicroAppEvent.svelte.d.ts +16 -0
- package/dist/components/useMicroAppEvent.svelte.js +61 -0
- package/dist/components/usePrintExport.d.svelte.ts +1 -0
- package/dist/components/usePrintExport.svelte.d.ts +11 -0
- package/dist/components/usePrintExport.svelte.js +45 -0
- package/dist/components/useSessionTimeout.d.svelte.ts +1 -0
- package/dist/components/useSessionTimeout.svelte.d.ts +28 -0
- package/dist/components/useSessionTimeout.svelte.js +182 -0
- package/dist/components/useTableClipboard.d.svelte.ts +1 -0
- package/dist/components/useTableClipboard.svelte.d.ts +28 -0
- package/dist/components/useTableClipboard.svelte.js +116 -0
- package/dist/components/useUnsavedChanges.d.svelte.ts +1 -0
- package/dist/components/useUnsavedChanges.svelte.d.ts +22 -0
- package/dist/components/useUnsavedChanges.svelte.js +105 -0
- package/dist/index.d.ts +47 -28
- package/dist/index.js +49 -2
- package/package.json +1 -1
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
ArrowDown,
|
|
5
|
+
ArrowUp,
|
|
6
|
+
Bookmark,
|
|
7
|
+
GripVertical,
|
|
8
|
+
Lock,
|
|
9
|
+
Pin,
|
|
10
|
+
PinOff,
|
|
11
|
+
Plus,
|
|
12
|
+
RotateCcw,
|
|
13
|
+
Search,
|
|
14
|
+
SlidersHorizontal,
|
|
15
|
+
Trash2,
|
|
16
|
+
X,
|
|
17
|
+
} from '@lucide/svelte';
|
|
18
|
+
import { useTranslation } from '@svadmin/core/i18n';
|
|
19
|
+
import { cn } from '../utils.js';
|
|
20
|
+
import { Button } from './ui/button/index.js';
|
|
21
|
+
import { Checkbox } from './ui/checkbox/index.js';
|
|
22
|
+
import * as Sheet from './ui/sheet/index.js';
|
|
23
|
+
import type { ColumnItem, ColumnPreset } from './ColumnSettings.svelte';
|
|
24
|
+
|
|
25
|
+
export interface ColumnVisibilityDrawerProps {
|
|
26
|
+
open?: boolean | undefined;
|
|
27
|
+
columns: ColumnItem[];
|
|
28
|
+
presets?: ColumnPreset[] | undefined;
|
|
29
|
+
storageKey?: string | undefined;
|
|
30
|
+
title?: string | undefined;
|
|
31
|
+
description?: string | undefined;
|
|
32
|
+
allowCustomPresets?: boolean | undefined;
|
|
33
|
+
class?: string | undefined;
|
|
34
|
+
onchange?: ((columns: ColumnItem[]) => void) | undefined;
|
|
35
|
+
onreset?: (() => void) | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let {
|
|
39
|
+
open = $bindable(false),
|
|
40
|
+
columns = $bindable([]),
|
|
41
|
+
presets = [],
|
|
42
|
+
storageKey,
|
|
43
|
+
title,
|
|
44
|
+
description,
|
|
45
|
+
allowCustomPresets = true,
|
|
46
|
+
class: className = '',
|
|
47
|
+
onchange,
|
|
48
|
+
onreset,
|
|
49
|
+
}: ColumnVisibilityDrawerProps = $props();
|
|
50
|
+
|
|
51
|
+
const i18n = useTranslation();
|
|
52
|
+
const chinese = $derived(i18n.locale.startsWith('zh'));
|
|
53
|
+
|
|
54
|
+
let filterQuery = $state('');
|
|
55
|
+
let initialColumnsSnapshot = $state<ColumnItem[]>([]);
|
|
56
|
+
let customPresets = $state<ColumnPreset[]>([]);
|
|
57
|
+
let newPresetName = $state('');
|
|
58
|
+
let showSavePresetInput = $state(false);
|
|
59
|
+
|
|
60
|
+
let draggedIndex = $state<number | null>(null);
|
|
61
|
+
let dragOverIndex = $state<number | null>(null);
|
|
62
|
+
|
|
63
|
+
let storageHydrated = false;
|
|
64
|
+
|
|
65
|
+
$effect(() => {
|
|
66
|
+
if (initialColumnsSnapshot.length === 0 && columns.length > 0) {
|
|
67
|
+
initialColumnsSnapshot = JSON.parse(JSON.stringify(columns));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
$effect(() => {
|
|
72
|
+
if (storageHydrated || !storageKey || typeof window === 'undefined') return;
|
|
73
|
+
storageHydrated = true;
|
|
74
|
+
try {
|
|
75
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
76
|
+
if (!raw) return;
|
|
77
|
+
const parsed: unknown = JSON.parse(raw);
|
|
78
|
+
if (!parsed || typeof parsed !== 'object') return;
|
|
79
|
+
|
|
80
|
+
const record = parsed as Record<string, unknown>;
|
|
81
|
+
const storedCols = record['columns'];
|
|
82
|
+
const storedPresets = record['customPresets'];
|
|
83
|
+
|
|
84
|
+
if (Array.isArray(storedPresets)) {
|
|
85
|
+
customPresets = storedPresets as ColumnPreset[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (Array.isArray(storedCols)) {
|
|
89
|
+
const storedMap = new Map(
|
|
90
|
+
storedCols
|
|
91
|
+
.filter((c): c is Record<string, unknown> => !!c && typeof c === 'object')
|
|
92
|
+
.filter((c) => typeof c['key'] === 'string')
|
|
93
|
+
.map((c) => [c['key'] as string, c]),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const merged = untrack(() => columns).map((column): ColumnItem => {
|
|
97
|
+
const saved = storedMap.get(column.key);
|
|
98
|
+
if (!saved) return column;
|
|
99
|
+
const fixed =
|
|
100
|
+
saved['fixed'] === 'left' ? 'left' : saved['fixed'] === 'right' ? 'right' : undefined;
|
|
101
|
+
const visible = column.required === true || saved['visible'] !== false;
|
|
102
|
+
if (fixed === undefined) return { ...column, visible };
|
|
103
|
+
return { ...column, visible, fixed };
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const order = storedCols
|
|
107
|
+
.map((c) => (c && typeof c === 'object' ? (c as Record<string, unknown>)['key'] : undefined))
|
|
108
|
+
.filter((k): k is string => typeof k === 'string');
|
|
109
|
+
|
|
110
|
+
merged.sort((a, b) => {
|
|
111
|
+
const idxA = order.indexOf(a.key);
|
|
112
|
+
const idxB = order.indexOf(b.key);
|
|
113
|
+
return (idxA < 0 ? 9999 : idxA) - (idxB < 0 ? 9999 : idxB);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
columns = merged;
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
// Fallback
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
function savePreference(cols: ColumnItem[], userPresets = customPresets) {
|
|
124
|
+
if (!storageKey || typeof window === 'undefined') return;
|
|
125
|
+
try {
|
|
126
|
+
window.localStorage.setItem(
|
|
127
|
+
storageKey,
|
|
128
|
+
JSON.stringify({
|
|
129
|
+
columns: cols,
|
|
130
|
+
customPresets: userPresets,
|
|
131
|
+
updatedAt: new Date().toISOString(),
|
|
132
|
+
}),
|
|
133
|
+
);
|
|
134
|
+
} catch {
|
|
135
|
+
// Ignore
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const filteredColumns = $derived(
|
|
140
|
+
filterQuery.trim()
|
|
141
|
+
? columns.filter(
|
|
142
|
+
(c) =>
|
|
143
|
+
c.label.toLowerCase().includes(filterQuery.toLowerCase()) ||
|
|
144
|
+
c.key.toLowerCase().includes(filterQuery.toLowerCase()),
|
|
145
|
+
)
|
|
146
|
+
: columns,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const visibleCount = $derived(columns.filter((c) => c.visible).length);
|
|
150
|
+
const allVisible = $derived(columns.length > 0 && columns.every((c) => c.visible));
|
|
151
|
+
const someVisible = $derived(visibleCount > 0 && !allVisible);
|
|
152
|
+
|
|
153
|
+
function toggleColumn(key: string) {
|
|
154
|
+
const target = columns.find((c) => c.key === key);
|
|
155
|
+
if (!target || target.required) return;
|
|
156
|
+
if (target.visible && visibleCount <= 1) return;
|
|
157
|
+
columns = columns.map((c) => (c.key === key ? { ...c, visible: !c.visible } : c));
|
|
158
|
+
savePreference(columns);
|
|
159
|
+
onchange?.(columns);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function toggleAll(checked: boolean) {
|
|
163
|
+
const hasRequired = columns.some((c) => c.required);
|
|
164
|
+
if (!checked && !hasRequired) {
|
|
165
|
+
columns = columns.map((c, idx) => ({ ...c, visible: idx === 0 }));
|
|
166
|
+
} else {
|
|
167
|
+
columns = columns.map((c) => (c.required ? { ...c, visible: true } : { ...c, visible: checked }));
|
|
168
|
+
}
|
|
169
|
+
savePreference(columns);
|
|
170
|
+
onchange?.(columns);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function toggleFixed(key: string, side: 'left' | 'right') {
|
|
174
|
+
columns = columns.map((c) => {
|
|
175
|
+
if (c.key !== key) return c;
|
|
176
|
+
if (c.fixed === side) {
|
|
177
|
+
const { fixed: _fixed, ...rest } = c;
|
|
178
|
+
return rest;
|
|
179
|
+
}
|
|
180
|
+
return { ...c, fixed: side };
|
|
181
|
+
});
|
|
182
|
+
savePreference(columns);
|
|
183
|
+
onchange?.(columns);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function moveColumn(fromIndex: number, toIndex: number) {
|
|
187
|
+
if (toIndex < 0 || toIndex >= columns.length || fromIndex === toIndex) return;
|
|
188
|
+
const next = [...columns];
|
|
189
|
+
const [moved] = next.splice(fromIndex, 1);
|
|
190
|
+
if (moved === undefined) return;
|
|
191
|
+
next.splice(toIndex, 0, moved);
|
|
192
|
+
columns = next;
|
|
193
|
+
savePreference(columns);
|
|
194
|
+
onchange?.(columns);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function handleDragStart(event: DragEvent, index: number) {
|
|
198
|
+
draggedIndex = index;
|
|
199
|
+
if (event.dataTransfer) {
|
|
200
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
201
|
+
event.dataTransfer.setData('text/plain', String(index));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function handleDragOver(event: DragEvent, index: number) {
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
if (event.dataTransfer) {
|
|
208
|
+
event.dataTransfer.dropEffect = 'move';
|
|
209
|
+
}
|
|
210
|
+
dragOverIndex = index;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function handleDragLeave(index: number) {
|
|
214
|
+
if (dragOverIndex === index) {
|
|
215
|
+
dragOverIndex = null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function handleDrop(event: DragEvent, targetIndex: number) {
|
|
220
|
+
event.preventDefault();
|
|
221
|
+
if (draggedIndex !== null && draggedIndex !== targetIndex) {
|
|
222
|
+
moveColumn(draggedIndex, targetIndex);
|
|
223
|
+
}
|
|
224
|
+
draggedIndex = null;
|
|
225
|
+
dragOverIndex = null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function handleDragEnd() {
|
|
229
|
+
draggedIndex = null;
|
|
230
|
+
dragOverIndex = null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function applyPreset(preset: ColumnPreset) {
|
|
234
|
+
const visibleKeys = new Set(preset.visibleKeys);
|
|
235
|
+
columns = columns.map((c) => ({
|
|
236
|
+
...c,
|
|
237
|
+
visible: c.required === true || visibleKeys.has(c.key),
|
|
238
|
+
}));
|
|
239
|
+
if (!columns.some((c) => c.visible) && columns[0]) {
|
|
240
|
+
columns = columns.map((c, idx) => ({ ...c, visible: idx === 0 }));
|
|
241
|
+
}
|
|
242
|
+
savePreference(columns);
|
|
243
|
+
onchange?.(columns);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function saveCurrentAsPreset() {
|
|
247
|
+
const name = newPresetName.trim();
|
|
248
|
+
if (!name) return;
|
|
249
|
+
const newPreset: ColumnPreset = {
|
|
250
|
+
id: `custom-preset-${Date.now()}`,
|
|
251
|
+
label: name,
|
|
252
|
+
visibleKeys: columns.filter((c) => c.visible).map((c) => c.key),
|
|
253
|
+
};
|
|
254
|
+
customPresets = [...customPresets, newPreset];
|
|
255
|
+
newPresetName = '';
|
|
256
|
+
showSavePresetInput = false;
|
|
257
|
+
savePreference(columns, customPresets);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function removeCustomPreset(id: string) {
|
|
261
|
+
customPresets = customPresets.filter((p) => p.id !== id);
|
|
262
|
+
savePreference(columns, customPresets);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function handleReset() {
|
|
266
|
+
if (initialColumnsSnapshot.length > 0) {
|
|
267
|
+
columns = JSON.parse(JSON.stringify(initialColumnsSnapshot));
|
|
268
|
+
}
|
|
269
|
+
if (storageKey && typeof window !== 'undefined') {
|
|
270
|
+
try {
|
|
271
|
+
window.localStorage.removeItem(storageKey);
|
|
272
|
+
} catch {
|
|
273
|
+
// Ignore
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
customPresets = [];
|
|
277
|
+
onreset?.();
|
|
278
|
+
onchange?.(columns);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const allPresets = $derived([...presets, ...customPresets]);
|
|
282
|
+
const resolvedTitle = $derived(
|
|
283
|
+
title ?? (chinese ? '高级列管理器与多维视图' : 'Column Visibility & View Manager'),
|
|
284
|
+
);
|
|
285
|
+
const resolvedDesc = $derived(
|
|
286
|
+
description ??
|
|
287
|
+
(chinese
|
|
288
|
+
? '自定义宽表列显隐、左右侧锁列固定与拖拽排序,支持多视图预设与本地持久化'
|
|
289
|
+
: 'Manage column visibility, left/right pinning, and drag-and-drop reordering with view presets'),
|
|
290
|
+
);
|
|
291
|
+
</script>
|
|
292
|
+
|
|
293
|
+
<Sheet.Root bind:open side="right">
|
|
294
|
+
<Sheet.Content class={cn('w-full sm:max-w-md p-0 flex flex-col', className)}>
|
|
295
|
+
<div class="px-6 py-5 border-b border-border/70 bg-card">
|
|
296
|
+
<div class="flex items-center gap-2.5 text-primary">
|
|
297
|
+
<SlidersHorizontal class="h-5 w-5" />
|
|
298
|
+
<Sheet.Title class="text-base font-semibold text-foreground">
|
|
299
|
+
{resolvedTitle}
|
|
300
|
+
</Sheet.Title>
|
|
301
|
+
</div>
|
|
302
|
+
<Sheet.Description class="text-xs text-muted-foreground mt-1 leading-relaxed">
|
|
303
|
+
{resolvedDesc}
|
|
304
|
+
</Sheet.Description>
|
|
305
|
+
|
|
306
|
+
<div class="mt-4 flex items-center justify-between border-t border-border/50 pt-3 text-xs">
|
|
307
|
+
<div class="flex items-center gap-2">
|
|
308
|
+
<Checkbox
|
|
309
|
+
checked={allVisible}
|
|
310
|
+
indeterminate={someVisible}
|
|
311
|
+
onCheckedChange={(checked) => toggleAll(checked === true)}
|
|
312
|
+
aria-label="Select all columns"
|
|
313
|
+
/>
|
|
314
|
+
<span class="font-medium text-foreground">
|
|
315
|
+
{chinese
|
|
316
|
+
? `已显示 ${visibleCount} / ${columns.length} 列`
|
|
317
|
+
: `Showing ${visibleCount} of ${columns.length} columns`}
|
|
318
|
+
</span>
|
|
319
|
+
</div>
|
|
320
|
+
<Button
|
|
321
|
+
type="button"
|
|
322
|
+
variant="ghost"
|
|
323
|
+
size="sm"
|
|
324
|
+
class="h-7 px-2 text-[11px] text-muted-foreground hover:text-foreground gap-1"
|
|
325
|
+
onclick={handleReset}
|
|
326
|
+
>
|
|
327
|
+
<RotateCcw class="h-3 w-3" />
|
|
328
|
+
{chinese ? '恢复默认' : 'Reset'}
|
|
329
|
+
</Button>
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
{#if allPresets.length > 0 || allowCustomPresets}
|
|
334
|
+
<div class="px-6 py-3 border-b border-border/60 bg-muted/20 space-y-2">
|
|
335
|
+
<div class="flex items-center justify-between">
|
|
336
|
+
<span class="text-[11px] font-semibold text-muted-foreground uppercase tracking-wider flex items-center gap-1">
|
|
337
|
+
<Bookmark class="h-3 w-3" />
|
|
338
|
+
{chinese ? '快速视图预设' : 'View Presets'}
|
|
339
|
+
</span>
|
|
340
|
+
{#if allowCustomPresets && !showSavePresetInput}
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
onclick={() => (showSavePresetInput = true)}
|
|
344
|
+
class="inline-flex items-center gap-1 text-[11px] text-primary hover:underline"
|
|
345
|
+
>
|
|
346
|
+
<Plus class="h-3 w-3" />
|
|
347
|
+
{chinese ? '存为新视图' : 'Save as Preset'}
|
|
348
|
+
</button>
|
|
349
|
+
{/if}
|
|
350
|
+
</div>
|
|
351
|
+
|
|
352
|
+
{#if showSavePresetInput}
|
|
353
|
+
<div class="flex items-center gap-1.5 pt-1">
|
|
354
|
+
<input
|
|
355
|
+
type="text"
|
|
356
|
+
bind:value={newPresetName}
|
|
357
|
+
placeholder={chinese ? '输入视图名称 (如: 财务视图)...' : 'Preset name...'}
|
|
358
|
+
class="h-7 flex-1 rounded border border-input bg-background px-2 text-xs focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
|
359
|
+
/>
|
|
360
|
+
<Button size="sm" class="h-7 px-2.5 text-xs" onclick={saveCurrentAsPreset}>
|
|
361
|
+
{chinese ? '保存' : 'Save'}
|
|
362
|
+
</Button>
|
|
363
|
+
<Button
|
|
364
|
+
variant="ghost"
|
|
365
|
+
size="sm"
|
|
366
|
+
class="h-7 px-2 text-xs"
|
|
367
|
+
onclick={() => {
|
|
368
|
+
showSavePresetInput = false;
|
|
369
|
+
newPresetName = '';
|
|
370
|
+
}}
|
|
371
|
+
>
|
|
372
|
+
<X class="h-3.5 w-3.5" />
|
|
373
|
+
</Button>
|
|
374
|
+
</div>
|
|
375
|
+
{/if}
|
|
376
|
+
|
|
377
|
+
<div class="flex flex-wrap gap-1.5 pt-0.5">
|
|
378
|
+
{#each allPresets as preset (preset.id)}
|
|
379
|
+
{@const isCustom = customPresets.some((p) => p.id === preset.id)}
|
|
380
|
+
<div class="inline-flex items-center rounded-md border border-border bg-background shadow-2xs overflow-hidden">
|
|
381
|
+
<button
|
|
382
|
+
type="button"
|
|
383
|
+
onclick={() => applyPreset(preset)}
|
|
384
|
+
class="px-2 py-1 text-xs font-medium text-foreground hover:bg-muted transition-colors"
|
|
385
|
+
>
|
|
386
|
+
{preset.label}
|
|
387
|
+
</button>
|
|
388
|
+
{#if isCustom}
|
|
389
|
+
<button
|
|
390
|
+
type="button"
|
|
391
|
+
onclick={() => removeCustomPreset(preset.id)}
|
|
392
|
+
class="px-1 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors"
|
|
393
|
+
aria-label={`Remove preset ${preset.label}`}
|
|
394
|
+
>
|
|
395
|
+
<Trash2 class="h-3 w-3" />
|
|
396
|
+
</button>
|
|
397
|
+
{/if}
|
|
398
|
+
</div>
|
|
399
|
+
{/each}
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
{/if}
|
|
403
|
+
|
|
404
|
+
<div class="px-6 py-2.5 border-b border-border/50 bg-background">
|
|
405
|
+
<div class="relative flex items-center">
|
|
406
|
+
<Search class="absolute left-2.5 h-3.5 w-3.5 text-muted-foreground pointer-events-none" />
|
|
407
|
+
<input
|
|
408
|
+
type="text"
|
|
409
|
+
bind:value={filterQuery}
|
|
410
|
+
placeholder={chinese ? '快速检索列名或字段 Key...' : 'Search column name or key...'}
|
|
411
|
+
class="h-8 w-full rounded-md border border-input bg-muted/30 pl-8 pr-2.5 text-xs placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
|
412
|
+
/>
|
|
413
|
+
{#if filterQuery}
|
|
414
|
+
<button
|
|
415
|
+
type="button"
|
|
416
|
+
onclick={() => (filterQuery = '')}
|
|
417
|
+
class="absolute right-2 text-muted-foreground hover:text-foreground"
|
|
418
|
+
aria-label="Clear filter"
|
|
419
|
+
>
|
|
420
|
+
<X class="h-3 w-3" />
|
|
421
|
+
</button>
|
|
422
|
+
{/if}
|
|
423
|
+
</div>
|
|
424
|
+
</div>
|
|
425
|
+
|
|
426
|
+
<div class="flex-1 overflow-y-auto px-6 py-3 space-y-1.5" role="list">
|
|
427
|
+
{#each filteredColumns as col (col.key)}
|
|
428
|
+
{@const realIdx = columns.findIndex((c) => c.key === col.key)}
|
|
429
|
+
{@const isDragging = draggedIndex === realIdx}
|
|
430
|
+
{@const isOver = dragOverIndex === realIdx}
|
|
431
|
+
<div
|
|
432
|
+
role="listitem"
|
|
433
|
+
draggable={!col.required}
|
|
434
|
+
ondragstart={(e) => handleDragStart(e, realIdx)}
|
|
435
|
+
ondragover={(e) => handleDragOver(e, realIdx)}
|
|
436
|
+
ondragleave={() => handleDragLeave(realIdx)}
|
|
437
|
+
ondrop={(e) => handleDrop(e, realIdx)}
|
|
438
|
+
ondragend={handleDragEnd}
|
|
439
|
+
class={cn(
|
|
440
|
+
'group flex items-center justify-between rounded-lg border p-2 text-xs transition-all bg-card',
|
|
441
|
+
isDragging && 'opacity-40 border-dashed border-primary',
|
|
442
|
+
isOver && !isDragging && 'border-primary ring-1 ring-primary/30 bg-primary/5',
|
|
443
|
+
!isDragging && !isOver && 'border-border/70 hover:border-border hover:bg-muted/30',
|
|
444
|
+
)}
|
|
445
|
+
data-column-key={col.key}
|
|
446
|
+
data-column-visible={col.visible ? 'true' : 'false'}
|
|
447
|
+
data-column-fixed={col.fixed ?? 'none'}
|
|
448
|
+
>
|
|
449
|
+
<div class="flex items-center gap-2 min-w-0 flex-1 pr-2">
|
|
450
|
+
<span
|
|
451
|
+
class={cn(
|
|
452
|
+
'text-muted-foreground/50 transition-colors',
|
|
453
|
+
col.required ? 'opacity-20 cursor-not-allowed' : 'cursor-grab group-hover:text-foreground',
|
|
454
|
+
)}
|
|
455
|
+
title={chinese ? '拖拽调整顺序' : 'Drag to reorder'}
|
|
456
|
+
>
|
|
457
|
+
<GripVertical class="h-3.5 w-3.5" />
|
|
458
|
+
</span>
|
|
459
|
+
|
|
460
|
+
<Checkbox
|
|
461
|
+
checked={col.visible}
|
|
462
|
+
disabled={col.required}
|
|
463
|
+
onCheckedChange={() => toggleColumn(col.key)}
|
|
464
|
+
aria-label={`Toggle ${col.label}`}
|
|
465
|
+
/>
|
|
466
|
+
|
|
467
|
+
<span
|
|
468
|
+
class={cn(
|
|
469
|
+
'truncate font-medium',
|
|
470
|
+
col.visible ? 'text-foreground' : 'text-muted-foreground line-through opacity-60',
|
|
471
|
+
)}
|
|
472
|
+
>
|
|
473
|
+
{col.label}
|
|
474
|
+
</span>
|
|
475
|
+
|
|
476
|
+
{#if col.required}
|
|
477
|
+
<Lock class="h-3 w-3 text-muted-foreground shrink-0" title={chinese ? '业务必显列' : 'Required column'} />
|
|
478
|
+
{/if}
|
|
479
|
+
|
|
480
|
+
{#if col.fixed}
|
|
481
|
+
<span class="rounded bg-primary/10 px-1.5 py-0.2 text-[10px] font-medium text-primary shrink-0">
|
|
482
|
+
{col.fixed === 'left' ? (chinese ? '左固定' : 'Pin Left') : (chinese ? '右固定' : 'Pin Right')}
|
|
483
|
+
</span>
|
|
484
|
+
{/if}
|
|
485
|
+
</div>
|
|
486
|
+
|
|
487
|
+
<div class="flex items-center gap-1 shrink-0">
|
|
488
|
+
<button
|
|
489
|
+
type="button"
|
|
490
|
+
onclick={() => toggleFixed(col.key, 'left')}
|
|
491
|
+
class={cn(
|
|
492
|
+
'rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground',
|
|
493
|
+
col.fixed === 'left' && 'text-primary bg-primary/10',
|
|
494
|
+
)}
|
|
495
|
+
title={col.fixed === 'left' ? (chinese ? '取消左侧固定' : 'Unpin') : (chinese ? '固定在左侧' : 'Pin Left')}
|
|
496
|
+
aria-label={`Pin ${col.label} left`}
|
|
497
|
+
>
|
|
498
|
+
{#if col.fixed === 'left'}<PinOff class="h-3.5 w-3.5" />{:else}<Pin class="h-3.5 w-3.5" />{/if}
|
|
499
|
+
</button>
|
|
500
|
+
|
|
501
|
+
<button
|
|
502
|
+
type="button"
|
|
503
|
+
disabled={realIdx === 0}
|
|
504
|
+
onclick={() => moveColumn(realIdx, realIdx - 1)}
|
|
505
|
+
class="rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-30 disabled:pointer-events-none"
|
|
506
|
+
title={chinese ? '上移' : 'Move up'}
|
|
507
|
+
aria-label={`Move ${col.label} up`}
|
|
508
|
+
>
|
|
509
|
+
<ArrowUp class="h-3.5 w-3.5" />
|
|
510
|
+
</button>
|
|
511
|
+
<button
|
|
512
|
+
type="button"
|
|
513
|
+
disabled={realIdx === columns.length - 1}
|
|
514
|
+
onclick={() => moveColumn(realIdx, realIdx + 1)}
|
|
515
|
+
class="rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-30 disabled:pointer-events-none"
|
|
516
|
+
title={chinese ? '下移' : 'Move down'}
|
|
517
|
+
aria-label={`Move ${col.label} down`}
|
|
518
|
+
>
|
|
519
|
+
<ArrowDown class="h-3.5 w-3.5" />
|
|
520
|
+
</button>
|
|
521
|
+
</div>
|
|
522
|
+
</div>
|
|
523
|
+
{/each}
|
|
524
|
+
|
|
525
|
+
{#if filteredColumns.length === 0}
|
|
526
|
+
<div class="py-12 text-center text-xs text-muted-foreground">
|
|
527
|
+
{chinese ? '没有找到匹配的列' : 'No matching columns found'}
|
|
528
|
+
</div>
|
|
529
|
+
{/if}
|
|
530
|
+
</div>
|
|
531
|
+
|
|
532
|
+
<div class="px-6 py-4 border-t border-border/70 bg-card flex items-center justify-between">
|
|
533
|
+
<span class="text-[11px] text-muted-foreground">
|
|
534
|
+
{chinese ? '支持拖拽手柄平滑排序与双侧固定' : 'Drag handle to reorder, pin to lock sides'}
|
|
535
|
+
</span>
|
|
536
|
+
<Button size="sm" onclick={() => (open = false)} class="min-w-20">
|
|
537
|
+
{chinese ? '完成' : 'Done'}
|
|
538
|
+
</Button>
|
|
539
|
+
</div>
|
|
540
|
+
</Sheet.Content>
|
|
541
|
+
</Sheet.Root>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ColumnItem, ColumnPreset } from './ColumnSettings.svelte';
|
|
2
|
+
export interface ColumnVisibilityDrawerProps {
|
|
3
|
+
open?: boolean | undefined;
|
|
4
|
+
columns: ColumnItem[];
|
|
5
|
+
presets?: ColumnPreset[] | undefined;
|
|
6
|
+
storageKey?: string | undefined;
|
|
7
|
+
title?: string | undefined;
|
|
8
|
+
description?: string | undefined;
|
|
9
|
+
allowCustomPresets?: boolean | undefined;
|
|
10
|
+
class?: string | undefined;
|
|
11
|
+
onchange?: ((columns: ColumnItem[]) => void) | undefined;
|
|
12
|
+
onreset?: (() => void) | undefined;
|
|
13
|
+
}
|
|
14
|
+
declare const ColumnVisibilityDrawer: import("svelte").Component<ColumnVisibilityDrawerProps, {}, "columns" | "open">;
|
|
15
|
+
type ColumnVisibilityDrawer = ReturnType<typeof ColumnVisibilityDrawer>;
|
|
16
|
+
export default ColumnVisibilityDrawer;
|
|
@@ -138,14 +138,14 @@
|
|
|
138
138
|
>
|
|
139
139
|
<div
|
|
140
140
|
class={cn(
|
|
141
|
-
'relative w-full max-w-2xl rounded-
|
|
141
|
+
'relative w-full max-w-2xl rounded-md border border-warning/30 bg-background shadow-[var(--shadow-overlay)] transition-all duration-200 overflow-hidden flex flex-col max-h-[90vh]',
|
|
142
142
|
className
|
|
143
143
|
)}
|
|
144
144
|
>
|
|
145
145
|
<!-- Header -->
|
|
146
146
|
<div class="flex items-center justify-between border-b px-5 py-4 bg-warning/10">
|
|
147
147
|
<div class="flex items-center gap-3">
|
|
148
|
-
<div class="flex h-10 w-10 items-center justify-center rounded-
|
|
148
|
+
<div class="flex h-10 w-10 items-center justify-center rounded-sm bg-warning/20 text-warning-foreground">
|
|
149
149
|
<AlertTriangle class="h-5 w-5 text-warning" />
|
|
150
150
|
</div>
|
|
151
151
|
<div>
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
</div>
|
|
180
180
|
{/if}
|
|
181
181
|
|
|
182
|
-
<div class="rounded-
|
|
182
|
+
<div class="rounded-md border border-border overflow-hidden">
|
|
183
183
|
<table class="w-full text-xs text-left">
|
|
184
184
|
<thead class="bg-muted text-muted-foreground font-medium border-b border-border">
|
|
185
185
|
<tr>
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
</td>
|
|
199
199
|
<td class="py-2.5 px-3">
|
|
200
200
|
<span class={cn(
|
|
201
|
-
'inline-block px-1.5 py-0.5 rounded font-mono text-
|
|
201
|
+
'inline-block px-1.5 py-0.5 rounded font-mono text-xs',
|
|
202
202
|
currentChoice === 'local' ? 'bg-primary/15 text-primary font-semibold ring-1 ring-primary/30' : 'bg-muted text-muted-foreground'
|
|
203
203
|
)}>
|
|
204
204
|
{formatVal(f.localValue)}
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
</td>
|
|
207
207
|
<td class="py-2.5 px-3">
|
|
208
208
|
<span class={cn(
|
|
209
|
-
'inline-block px-1.5 py-0.5 rounded font-mono text-
|
|
209
|
+
'inline-block px-1.5 py-0.5 rounded font-mono text-xs',
|
|
210
210
|
currentChoice === 'remote' ? 'bg-success/15 text-success font-semibold ring-1 ring-success/30' : 'bg-muted text-muted-foreground'
|
|
211
211
|
)}>
|
|
212
212
|
{formatVal(f.remoteValue)}
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
<button
|
|
218
218
|
type="button"
|
|
219
219
|
class={cn(
|
|
220
|
-
'px-2 py-1 rounded text-
|
|
220
|
+
'px-2 py-1 rounded text-xs font-medium transition-all',
|
|
221
221
|
currentChoice === 'local' ? 'bg-background text-foreground shadow-xs font-semibold' : 'text-muted-foreground hover:text-foreground'
|
|
222
222
|
)}
|
|
223
223
|
onclick={() => handleSelectChoice(f.field, 'local')}
|
|
@@ -228,7 +228,7 @@
|
|
|
228
228
|
<button
|
|
229
229
|
type="button"
|
|
230
230
|
class={cn(
|
|
231
|
-
'px-2 py-1 rounded text-
|
|
231
|
+
'px-2 py-1 rounded text-xs font-medium transition-all',
|
|
232
232
|
currentChoice === 'remote' ? 'bg-background text-foreground shadow-xs font-semibold' : 'text-muted-foreground hover:text-foreground'
|
|
233
233
|
)}
|
|
234
234
|
onclick={() => handleSelectChoice(f.field, 'remote')}
|