@svadmin/ui 0.117.0 → 0.118.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 +153 -0
- package/dist/app.theme.css +153 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/ApprovalTimeline.svelte +170 -0
- package/dist/components/ApprovalTimeline.svelte.d.ts +26 -0
- package/dist/components/ExcelExportButton.svelte +142 -0
- package/dist/components/ExcelExportButton.svelte.d.ts +21 -0
- package/dist/components/ExcelImportWizard.svelte +571 -0
- package/dist/components/ExcelImportWizard.svelte.d.ts +26 -0
- package/dist/components/FloatButtonGroup.svelte +162 -0
- package/dist/components/FloatButtonGroup.svelte.d.ts +34 -0
- package/dist/components/OrgTreePicker.svelte +325 -0
- package/dist/components/OrgTreePicker.svelte.d.ts +32 -0
- package/dist/components/PivotDrilldownModal.svelte +228 -0
- package/dist/components/PivotDrilldownModal.svelte.d.ts +22 -0
- package/dist/components/ProSkeleton.svelte +186 -0
- package/dist/components/ProSkeleton.svelte.d.ts +20 -0
- package/dist/components/Ribbon.svelte +97 -0
- package/dist/components/Ribbon.svelte.d.ts +19 -0
- package/dist/components/TreeTransfer.svelte +288 -0
- package/dist/components/TreeTransfer.svelte.d.ts +25 -0
- package/dist/components/WorkflowProcessCard.svelte +93 -0
- package/dist/components/WorkflowProcessCard.svelte.d.ts +21 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +13 -0
- package/package.json +4 -4
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
import { Check, X, Clock, Loader2 } from '@lucide/svelte';
|
|
5
|
+
|
|
6
|
+
export type ApprovalStatus = 'approved' | 'rejected' | 'pending' | 'running';
|
|
7
|
+
|
|
8
|
+
export interface ApprovalStep {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
approverName?: string;
|
|
12
|
+
approverRole?: string;
|
|
13
|
+
approverAvatar?: string;
|
|
14
|
+
status: ApprovalStatus;
|
|
15
|
+
time?: string;
|
|
16
|
+
comment?: string;
|
|
17
|
+
extra?: Snippet;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ApprovalTimelineProps {
|
|
21
|
+
/** List of approval workflow steps */
|
|
22
|
+
steps: ApprovalStep[];
|
|
23
|
+
/** Whether to render step comments in bordered cards */
|
|
24
|
+
cardMode?: boolean;
|
|
25
|
+
/** Current active step index (0-based) */
|
|
26
|
+
current?: number;
|
|
27
|
+
/** Additional CSS classes */
|
|
28
|
+
class?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
steps = [],
|
|
33
|
+
cardMode = true,
|
|
34
|
+
current,
|
|
35
|
+
class: className = '',
|
|
36
|
+
}: ApprovalTimelineProps = $props();
|
|
37
|
+
|
|
38
|
+
function getStatusIcon(status: ApprovalStatus) {
|
|
39
|
+
switch (status) {
|
|
40
|
+
case 'approved':
|
|
41
|
+
return Check;
|
|
42
|
+
case 'rejected':
|
|
43
|
+
return X;
|
|
44
|
+
case 'running':
|
|
45
|
+
return Loader2;
|
|
46
|
+
case 'pending':
|
|
47
|
+
default:
|
|
48
|
+
return Clock;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getStatusColorClasses(status: ApprovalStatus) {
|
|
53
|
+
switch (status) {
|
|
54
|
+
case 'approved':
|
|
55
|
+
return {
|
|
56
|
+
iconBg: 'bg-success text-success-foreground',
|
|
57
|
+
badge: 'bg-success/10 text-success border-success/20',
|
|
58
|
+
line: 'border-success',
|
|
59
|
+
};
|
|
60
|
+
case 'rejected':
|
|
61
|
+
return {
|
|
62
|
+
iconBg: 'bg-destructive text-destructive-foreground',
|
|
63
|
+
badge: 'bg-destructive/10 text-destructive border-destructive/20',
|
|
64
|
+
line: 'border-destructive',
|
|
65
|
+
};
|
|
66
|
+
case 'running':
|
|
67
|
+
return {
|
|
68
|
+
iconBg: 'bg-primary text-primary-foreground',
|
|
69
|
+
badge: 'bg-primary/10 text-primary border-primary/20',
|
|
70
|
+
line: 'border-primary',
|
|
71
|
+
};
|
|
72
|
+
case 'pending':
|
|
73
|
+
default:
|
|
74
|
+
return {
|
|
75
|
+
iconBg: 'bg-muted text-muted-foreground',
|
|
76
|
+
badge: 'bg-muted text-muted-foreground border-border',
|
|
77
|
+
line: 'border-border',
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<div
|
|
84
|
+
data-svadmin-component="ApprovalTimeline"
|
|
85
|
+
class={cn('w-full relative', className)}
|
|
86
|
+
>
|
|
87
|
+
<div class="relative flex flex-col space-y-6">
|
|
88
|
+
{#each steps as step, index (step.id)}
|
|
89
|
+
{@const colors = getStatusColorClasses(step.status)}
|
|
90
|
+
{@const Icon = getStatusIcon(step.status)}
|
|
91
|
+
{@const isLast = index === steps.length - 1}
|
|
92
|
+
{@const isCurrent = current !== undefined ? index === current : step.status === 'running'}
|
|
93
|
+
|
|
94
|
+
<div class="relative flex items-start gap-4">
|
|
95
|
+
<!-- Connecting Line & Status Icon Node -->
|
|
96
|
+
<div class="relative flex flex-col items-center">
|
|
97
|
+
<div
|
|
98
|
+
class={cn(
|
|
99
|
+
'flex h-7 w-7 shrink-0 items-center justify-center rounded-full shadow-xs ring-4 ring-background transition-colors',
|
|
100
|
+
colors.iconBg,
|
|
101
|
+
isCurrent && 'ring-primary/30',
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
<Icon class={cn('h-3.5 w-3.5 stroke-[2.5]', step.status === 'running' && 'animate-spin')} />
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
{#if !isLast}
|
|
108
|
+
<div
|
|
109
|
+
class={cn(
|
|
110
|
+
'w-0.5 flex-1 min-h-[44px] my-1 border-l-2 transition-colors',
|
|
111
|
+
colors.line,
|
|
112
|
+
)}
|
|
113
|
+
></div>
|
|
114
|
+
{/if}
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<!-- Step Detail Content -->
|
|
118
|
+
<div class="flex-1 pb-4">
|
|
119
|
+
<div class="flex flex-wrap items-center justify-between gap-2">
|
|
120
|
+
<div class="flex items-center gap-2">
|
|
121
|
+
<h4 class="text-sm font-semibold tracking-tight text-foreground">{step.title}</h4>
|
|
122
|
+
<span
|
|
123
|
+
class={cn(
|
|
124
|
+
'inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase tracking-wider',
|
|
125
|
+
colors.badge,
|
|
126
|
+
)}
|
|
127
|
+
>
|
|
128
|
+
{step.status}
|
|
129
|
+
</span>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
{#if step.time}
|
|
133
|
+
<time class="text-xs text-muted-foreground font-mono">{step.time}</time>
|
|
134
|
+
{/if}
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
{#if step.approverName || step.approverRole}
|
|
138
|
+
<div class="mt-1 flex items-center gap-2 text-xs text-muted-foreground">
|
|
139
|
+
{#if step.approverName}
|
|
140
|
+
<span class="font-medium text-foreground">{step.approverName}</span>
|
|
141
|
+
{/if}
|
|
142
|
+
{#if step.approverRole}
|
|
143
|
+
<span>({step.approverRole})</span>
|
|
144
|
+
{/if}
|
|
145
|
+
</div>
|
|
146
|
+
{/if}
|
|
147
|
+
|
|
148
|
+
{#if step.comment}
|
|
149
|
+
<div
|
|
150
|
+
class={cn(
|
|
151
|
+
'mt-2 text-xs text-foreground',
|
|
152
|
+
cardMode
|
|
153
|
+
? 'rounded-lg border border-border bg-card p-3 shadow-2xs'
|
|
154
|
+
: 'text-muted-foreground italic',
|
|
155
|
+
)}
|
|
156
|
+
>
|
|
157
|
+
<p>{step.comment}</p>
|
|
158
|
+
</div>
|
|
159
|
+
{/if}
|
|
160
|
+
|
|
161
|
+
{#if step.extra}
|
|
162
|
+
<div class="mt-2">
|
|
163
|
+
{@render step.extra()}
|
|
164
|
+
</div>
|
|
165
|
+
{/if}
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
{/each}
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type ApprovalStatus = 'approved' | 'rejected' | 'pending' | 'running';
|
|
3
|
+
export interface ApprovalStep {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
approverName?: string;
|
|
7
|
+
approverRole?: string;
|
|
8
|
+
approverAvatar?: string;
|
|
9
|
+
status: ApprovalStatus;
|
|
10
|
+
time?: string;
|
|
11
|
+
comment?: string;
|
|
12
|
+
extra?: Snippet;
|
|
13
|
+
}
|
|
14
|
+
export interface ApprovalTimelineProps {
|
|
15
|
+
/** List of approval workflow steps */
|
|
16
|
+
steps: ApprovalStep[];
|
|
17
|
+
/** Whether to render step comments in bordered cards */
|
|
18
|
+
cardMode?: boolean;
|
|
19
|
+
/** Current active step index (0-based) */
|
|
20
|
+
current?: number;
|
|
21
|
+
/** Additional CSS classes */
|
|
22
|
+
class?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const ApprovalTimeline: import("svelte").Component<ApprovalTimelineProps, {}, "">;
|
|
25
|
+
type ApprovalTimeline = ReturnType<typeof ApprovalTimeline>;
|
|
26
|
+
export default ApprovalTimeline;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { Download, Loader2 } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
import { useTranslation } from '@svadmin/core';
|
|
6
|
+
|
|
7
|
+
export interface ExcelExportColumn {
|
|
8
|
+
key: string;
|
|
9
|
+
label: string;
|
|
10
|
+
formatter?: ((value: unknown, record: Record<string, unknown>) => string) | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ExcelExportButtonProps {
|
|
14
|
+
columns: ExcelExportColumn[];
|
|
15
|
+
dataSource: Record<string, unknown>[] | (() => Promise<Record<string, unknown>[]>);
|
|
16
|
+
filename?: string | undefined;
|
|
17
|
+
format?: 'csv' | 'tsv' | undefined;
|
|
18
|
+
disabled?: boolean | undefined;
|
|
19
|
+
variant?: 'default' | 'outline' | 'secondary' | 'ghost' | undefined;
|
|
20
|
+
size?: 'default' | 'sm' | 'lg' | undefined;
|
|
21
|
+
class?: string | undefined;
|
|
22
|
+
children?: Snippet | undefined;
|
|
23
|
+
onexport?: ((count: number) => void) | undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let {
|
|
27
|
+
columns = [],
|
|
28
|
+
dataSource,
|
|
29
|
+
filename = 'export',
|
|
30
|
+
format = 'csv',
|
|
31
|
+
disabled = false,
|
|
32
|
+
variant = 'outline',
|
|
33
|
+
size = 'default',
|
|
34
|
+
class: className = '',
|
|
35
|
+
children,
|
|
36
|
+
onexport,
|
|
37
|
+
}: ExcelExportButtonProps = $props();
|
|
38
|
+
|
|
39
|
+
const i18n = useTranslation();
|
|
40
|
+
let loading = $state(false);
|
|
41
|
+
|
|
42
|
+
// 转义 CSV/TSV 字段值
|
|
43
|
+
function formatCell(val: unknown, delimiter: string): string {
|
|
44
|
+
if (val === null || val === undefined) return '';
|
|
45
|
+
const rawText = String(val);
|
|
46
|
+
const text = /^[=+\-@]/.test(rawText) ? `'${rawText}` : rawText;
|
|
47
|
+
if (text.includes(delimiter) || text.includes('"') || text.includes('\n') || text.includes('\r')) {
|
|
48
|
+
return `"${text.replace(/"/g, '""')}"`;
|
|
49
|
+
}
|
|
50
|
+
return text;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function handleExport() {
|
|
54
|
+
if (disabled || loading) return;
|
|
55
|
+
loading = true;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
let records: Record<string, unknown>[] = [];
|
|
59
|
+
if (typeof dataSource === 'function') {
|
|
60
|
+
records = await dataSource();
|
|
61
|
+
} else if (Array.isArray(dataSource)) {
|
|
62
|
+
records = dataSource;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const delimiter = format === 'tsv' ? '\t' : ',';
|
|
66
|
+
const ext = format === 'tsv' ? 'tsv' : 'csv';
|
|
67
|
+
|
|
68
|
+
// 构建表头
|
|
69
|
+
const headerRow = columns.map((col) => formatCell(col.label, delimiter)).join(delimiter);
|
|
70
|
+
|
|
71
|
+
// 构建数据行
|
|
72
|
+
const bodyRows = records.map((record) => {
|
|
73
|
+
return columns
|
|
74
|
+
.map((col) => {
|
|
75
|
+
const rawVal = record[col.key];
|
|
76
|
+
const displayVal = col.formatter ? col.formatter(rawVal, record) : rawVal;
|
|
77
|
+
return formatCell(displayVal, delimiter);
|
|
78
|
+
})
|
|
79
|
+
.join(delimiter);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// UTF-8 BOM 确保 Windows Excel 识别中文字符
|
|
83
|
+
const csvContent = '\uFEFF' + [headerRow, ...bodyRows].join('\r\n');
|
|
84
|
+
const blob = new Blob([csvContent], {
|
|
85
|
+
type: format === 'tsv' ? 'text/tab-separated-values;charset=utf-8' : 'text/csv;charset=utf-8',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// 触发下载
|
|
89
|
+
const safeFilename = filename.endsWith(`.${ext}`) ? filename : `${filename}.${ext}`;
|
|
90
|
+
const url = URL.createObjectURL(blob);
|
|
91
|
+
const a = document.createElement('a');
|
|
92
|
+
a.href = url;
|
|
93
|
+
a.download = safeFilename;
|
|
94
|
+
document.body.appendChild(a);
|
|
95
|
+
a.click();
|
|
96
|
+
document.body.removeChild(a);
|
|
97
|
+
URL.revokeObjectURL(url);
|
|
98
|
+
|
|
99
|
+
onexport?.(records.length);
|
|
100
|
+
} finally {
|
|
101
|
+
loading = false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const variantClasses = {
|
|
106
|
+
default: 'bg-primary text-primary-foreground hover:bg-primary/90 shadow-2xs',
|
|
107
|
+
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground shadow-2xs',
|
|
108
|
+
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80 shadow-2xs',
|
|
109
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const sizeClasses = {
|
|
113
|
+
default: 'h-9 px-3.5 py-2 text-xs',
|
|
114
|
+
sm: 'h-8 px-2.5 text-xs',
|
|
115
|
+
lg: 'h-10 px-4 text-sm',
|
|
116
|
+
};
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<button
|
|
120
|
+
type="button"
|
|
121
|
+
data-svadmin-component="ExcelExportButton"
|
|
122
|
+
disabled={disabled || loading}
|
|
123
|
+
class={cn(
|
|
124
|
+
'inline-flex items-center justify-center gap-1.5 font-medium rounded-lg transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 cursor-pointer select-none',
|
|
125
|
+
variantClasses[variant] ?? variantClasses.outline,
|
|
126
|
+
sizeClasses[size] ?? sizeClasses.default,
|
|
127
|
+
className,
|
|
128
|
+
)}
|
|
129
|
+
onclick={handleExport}
|
|
130
|
+
>
|
|
131
|
+
{#if loading}
|
|
132
|
+
<Loader2 size={14} class="animate-spin" />
|
|
133
|
+
{:else}
|
|
134
|
+
<Download size={14} />
|
|
135
|
+
{/if}
|
|
136
|
+
|
|
137
|
+
{#if children}
|
|
138
|
+
{@render children()}
|
|
139
|
+
{:else}
|
|
140
|
+
<span>{loading ? '正在导出...' : i18n.t('excel.export')}</span>
|
|
141
|
+
{/if}
|
|
142
|
+
</button>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface ExcelExportColumn {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
formatter?: ((value: unknown, record: Record<string, unknown>) => string) | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface ExcelExportButtonProps {
|
|
8
|
+
columns: ExcelExportColumn[];
|
|
9
|
+
dataSource: Record<string, unknown>[] | (() => Promise<Record<string, unknown>[]>);
|
|
10
|
+
filename?: string | undefined;
|
|
11
|
+
format?: 'csv' | 'tsv' | undefined;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
13
|
+
variant?: 'default' | 'outline' | 'secondary' | 'ghost' | undefined;
|
|
14
|
+
size?: 'default' | 'sm' | 'lg' | undefined;
|
|
15
|
+
class?: string | undefined;
|
|
16
|
+
children?: Snippet | undefined;
|
|
17
|
+
onexport?: ((count: number) => void) | undefined;
|
|
18
|
+
}
|
|
19
|
+
declare const ExcelExportButton: import("svelte").Component<ExcelExportButtonProps, {}, "">;
|
|
20
|
+
type ExcelExportButton = ReturnType<typeof ExcelExportButton>;
|
|
21
|
+
export default ExcelExportButton;
|