@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,228 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
X,
|
|
4
|
+
Maximize2,
|
|
5
|
+
Minimize2,
|
|
6
|
+
Search,
|
|
7
|
+
Filter,
|
|
8
|
+
TableProperties,
|
|
9
|
+
} from '@lucide/svelte';
|
|
10
|
+
import { cn } from '../utils.js';
|
|
11
|
+
import { useTranslation } from '@svadmin/core';
|
|
12
|
+
import ExcelExportButton from './ExcelExportButton.svelte';
|
|
13
|
+
|
|
14
|
+
export interface PivotDrilldownFilter {
|
|
15
|
+
dimension: string;
|
|
16
|
+
value: string | number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PivotDrilldownColumn {
|
|
20
|
+
key: string;
|
|
21
|
+
label: string;
|
|
22
|
+
formatter?: ((value: unknown, record: Record<string, unknown>) => string) | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PivotDrilldownModalProps {
|
|
26
|
+
open?: boolean | undefined;
|
|
27
|
+
title?: string | undefined;
|
|
28
|
+
filters?: PivotDrilldownFilter[] | undefined;
|
|
29
|
+
columns: PivotDrilldownColumn[];
|
|
30
|
+
records: Record<string, unknown>[];
|
|
31
|
+
exportable?: boolean | undefined;
|
|
32
|
+
class?: string | undefined;
|
|
33
|
+
onclose?: (() => void) | undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let {
|
|
37
|
+
open = $bindable(false),
|
|
38
|
+
title,
|
|
39
|
+
filters = [],
|
|
40
|
+
columns = [],
|
|
41
|
+
records = [],
|
|
42
|
+
exportable = true,
|
|
43
|
+
class: className = '',
|
|
44
|
+
onclose,
|
|
45
|
+
}: PivotDrilldownModalProps = $props();
|
|
46
|
+
|
|
47
|
+
const i18n = useTranslation();
|
|
48
|
+
let isFullscreen = $state(false);
|
|
49
|
+
let searchQuery = $state('');
|
|
50
|
+
|
|
51
|
+
function handleClose() {
|
|
52
|
+
open = false;
|
|
53
|
+
isFullscreen = false;
|
|
54
|
+
onclose?.();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleKeydown(e: KeyboardEvent) {
|
|
58
|
+
if (e.key === 'Escape' && open) {
|
|
59
|
+
handleClose();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const filteredRecords = $derived.by(() => {
|
|
64
|
+
if (!searchQuery.trim()) return records;
|
|
65
|
+
const q = searchQuery.toLowerCase();
|
|
66
|
+
return records.filter((r) =>
|
|
67
|
+
columns.some((col) => {
|
|
68
|
+
const val = r[col.key];
|
|
69
|
+
return val !== undefined && val !== null && String(val).toLowerCase().includes(q);
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<svelte:window onkeydown={handleKeydown} />
|
|
76
|
+
|
|
77
|
+
{#if open}
|
|
78
|
+
<div
|
|
79
|
+
role="dialog"
|
|
80
|
+
aria-modal="true"
|
|
81
|
+
data-svadmin-component="PivotDrilldownModal"
|
|
82
|
+
class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-background/80 backdrop-blur-xs animate-in fade-in-0 duration-200"
|
|
83
|
+
>
|
|
84
|
+
<div
|
|
85
|
+
class={cn(
|
|
86
|
+
'flex flex-col bg-card border border-border text-card-foreground shadow-2xl transition-all duration-200 overflow-hidden',
|
|
87
|
+
isFullscreen
|
|
88
|
+
? 'fixed inset-2 rounded-xl'
|
|
89
|
+
: 'w-full max-w-4xl max-h-[85vh] rounded-xl',
|
|
90
|
+
className,
|
|
91
|
+
)}
|
|
92
|
+
>
|
|
93
|
+
<!-- 弹窗顶栏 -->
|
|
94
|
+
<div class="flex items-center justify-between border-b border-border px-5 py-4 bg-muted/20">
|
|
95
|
+
<div class="flex items-center gap-2.5">
|
|
96
|
+
<div class="flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10 text-primary">
|
|
97
|
+
<TableProperties size={18} />
|
|
98
|
+
</div>
|
|
99
|
+
<div>
|
|
100
|
+
<h3 class="text-sm font-semibold text-foreground">
|
|
101
|
+
{title ?? i18n.t('pivot.drilldownTitle')}
|
|
102
|
+
</h3>
|
|
103
|
+
<p class="text-xs text-muted-foreground">
|
|
104
|
+
{i18n.t('pivot.totalRecords', { count: records.length })}
|
|
105
|
+
</p>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<div class="flex items-center gap-1.5">
|
|
110
|
+
<button
|
|
111
|
+
type="button"
|
|
112
|
+
class="p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors cursor-pointer"
|
|
113
|
+
onclick={() => { isFullscreen = !isFullscreen; }}
|
|
114
|
+
aria-label={isFullscreen ? 'Restore' : 'Maximize'}
|
|
115
|
+
>
|
|
116
|
+
{#if isFullscreen}
|
|
117
|
+
<Minimize2 size={15} />
|
|
118
|
+
{:else}
|
|
119
|
+
<Maximize2 size={15} />
|
|
120
|
+
{/if}
|
|
121
|
+
</button>
|
|
122
|
+
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
class="p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors cursor-pointer"
|
|
126
|
+
onclick={handleClose}
|
|
127
|
+
aria-label="Close dialog"
|
|
128
|
+
>
|
|
129
|
+
<X size={16} />
|
|
130
|
+
</button>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<!-- 切片过滤条件胶囊栏 -->
|
|
135
|
+
{#if filters.length > 0}
|
|
136
|
+
<div class="px-5 py-2.5 border-b border-border/60 bg-muted/10 flex items-center gap-2 flex-wrap">
|
|
137
|
+
<div class="flex items-center gap-1 text-xs text-muted-foreground font-medium mr-1">
|
|
138
|
+
<Filter size={13} />
|
|
139
|
+
<span>{i18n.t('pivot.filterCriteria')}:</span>
|
|
140
|
+
</div>
|
|
141
|
+
{#each filters as f (f.dimension)}
|
|
142
|
+
<div class="inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs bg-primary/10 text-primary font-medium border border-primary/20">
|
|
143
|
+
<span class="opacity-75">{f.dimension}:</span>
|
|
144
|
+
<span>{f.value}</span>
|
|
145
|
+
</div>
|
|
146
|
+
{/each}
|
|
147
|
+
</div>
|
|
148
|
+
{/if}
|
|
149
|
+
|
|
150
|
+
<!-- 工具栏:关键词检索与导出 -->
|
|
151
|
+
<div class="px-5 py-3 border-b border-border/50 flex items-center justify-between gap-3">
|
|
152
|
+
<div class="relative flex-1 max-w-sm">
|
|
153
|
+
<Search size={14} class="absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground" />
|
|
154
|
+
<input
|
|
155
|
+
type="text"
|
|
156
|
+
bind:value={searchQuery}
|
|
157
|
+
placeholder="搜索明细内容..."
|
|
158
|
+
class="h-8 w-full rounded-md border border-input bg-background pl-8 pr-3 text-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
{#if exportable}
|
|
163
|
+
<ExcelExportButton
|
|
164
|
+
columns={columns.map((c) => ({
|
|
165
|
+
key: c.key,
|
|
166
|
+
label: c.label,
|
|
167
|
+
formatter: c.formatter,
|
|
168
|
+
}))}
|
|
169
|
+
dataSource={filteredRecords}
|
|
170
|
+
filename={`pivot-drilldown-${Date.now()}`}
|
|
171
|
+
size="sm"
|
|
172
|
+
variant="outline"
|
|
173
|
+
/>
|
|
174
|
+
{/if}
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<!-- 明细表格主体 -->
|
|
178
|
+
<div class="flex-1 overflow-auto p-4">
|
|
179
|
+
<div class="rounded-lg border border-border overflow-hidden">
|
|
180
|
+
<table class="w-full text-xs text-left whitespace-nowrap">
|
|
181
|
+
<thead class="bg-muted/40 border-b border-border text-muted-foreground font-semibold sticky top-0">
|
|
182
|
+
<tr>
|
|
183
|
+
<th class="p-2.5 w-12 text-center">#</th>
|
|
184
|
+
{#each columns as col (col.key)}
|
|
185
|
+
<th class="p-2.5">{col.label}</th>
|
|
186
|
+
{/each}
|
|
187
|
+
</tr>
|
|
188
|
+
</thead>
|
|
189
|
+
<tbody class="divide-y divide-border">
|
|
190
|
+
{#each filteredRecords as row, idx (idx)}
|
|
191
|
+
<tr class="hover:bg-muted/20">
|
|
192
|
+
<td class="p-2.5 text-center text-muted-foreground">{idx + 1}</td>
|
|
193
|
+
{#each columns as col (col.key)}
|
|
194
|
+
{@const val = row[col.key]}
|
|
195
|
+
{@const displayVal = col.formatter ? col.formatter(val, row) : val}
|
|
196
|
+
<td class="p-2.5 text-foreground">{displayVal ?? '-'}</td>
|
|
197
|
+
{/each}
|
|
198
|
+
</tr>
|
|
199
|
+
{/each}
|
|
200
|
+
|
|
201
|
+
{#if filteredRecords.length === 0}
|
|
202
|
+
<tr>
|
|
203
|
+
<td colspan={columns.length + 1} class="py-12 text-center text-muted-foreground">
|
|
204
|
+
暂无匹配明细数据
|
|
205
|
+
</td>
|
|
206
|
+
</tr>
|
|
207
|
+
{/if}
|
|
208
|
+
</tbody>
|
|
209
|
+
</table>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<!-- 底部关闭栏 -->
|
|
214
|
+
<div class="border-t border-border px-5 py-3 bg-muted/10 flex items-center justify-between text-xs">
|
|
215
|
+
<span class="text-muted-foreground">
|
|
216
|
+
显示 {filteredRecords.length} / {records.length} 条记录
|
|
217
|
+
</span>
|
|
218
|
+
<button
|
|
219
|
+
type="button"
|
|
220
|
+
class="px-4 py-1.5 rounded-lg border border-border bg-background text-xs font-medium hover:bg-muted transition-colors cursor-pointer"
|
|
221
|
+
onclick={handleClose}
|
|
222
|
+
>
|
|
223
|
+
关闭
|
|
224
|
+
</button>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface PivotDrilldownFilter {
|
|
2
|
+
dimension: string;
|
|
3
|
+
value: string | number;
|
|
4
|
+
}
|
|
5
|
+
export interface PivotDrilldownColumn {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
formatter?: ((value: unknown, record: Record<string, unknown>) => string) | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface PivotDrilldownModalProps {
|
|
11
|
+
open?: boolean | undefined;
|
|
12
|
+
title?: string | undefined;
|
|
13
|
+
filters?: PivotDrilldownFilter[] | undefined;
|
|
14
|
+
columns: PivotDrilldownColumn[];
|
|
15
|
+
records: Record<string, unknown>[];
|
|
16
|
+
exportable?: boolean | undefined;
|
|
17
|
+
class?: string | undefined;
|
|
18
|
+
onclose?: (() => void) | undefined;
|
|
19
|
+
}
|
|
20
|
+
declare const PivotDrilldownModal: import("svelte").Component<PivotDrilldownModalProps, {}, "open">;
|
|
21
|
+
type PivotDrilldownModal = ReturnType<typeof PivotDrilldownModal>;
|
|
22
|
+
export default PivotDrilldownModal;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
export type ProSkeletonType = 'table' | 'descriptions' | 'form' | 'list' | 'result';
|
|
5
|
+
|
|
6
|
+
export interface ProSkeletonProps {
|
|
7
|
+
/** Structural layout template type */
|
|
8
|
+
type?: ProSkeletonType;
|
|
9
|
+
/** Whether skeleton elements have pulsing animation */
|
|
10
|
+
active?: boolean;
|
|
11
|
+
/** Number of rows to render */
|
|
12
|
+
rows?: number;
|
|
13
|
+
/** Number of columns for table or descriptions */
|
|
14
|
+
columns?: number;
|
|
15
|
+
/** Whether to include avatar skeleton in list or result */
|
|
16
|
+
avatar?: boolean;
|
|
17
|
+
/** Number of statistic KPI cards to render at the top */
|
|
18
|
+
statistic?: number;
|
|
19
|
+
/** Additional CSS classes */
|
|
20
|
+
class?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
type = 'table',
|
|
25
|
+
active = true,
|
|
26
|
+
rows = 5,
|
|
27
|
+
columns = 4,
|
|
28
|
+
avatar = false,
|
|
29
|
+
statistic = 0,
|
|
30
|
+
class: className = '',
|
|
31
|
+
}: ProSkeletonProps = $props();
|
|
32
|
+
|
|
33
|
+
const pulseClass = $derived(active ? 'animate-pulse' : '');
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div
|
|
37
|
+
data-svadmin-component="ProSkeleton"
|
|
38
|
+
data-type={type}
|
|
39
|
+
data-active={active}
|
|
40
|
+
class={cn('w-full space-y-4 select-none', pulseClass, className)}
|
|
41
|
+
aria-busy="true"
|
|
42
|
+
aria-live="polite"
|
|
43
|
+
>
|
|
44
|
+
<!-- KPI Statistic Cards Top Section -->
|
|
45
|
+
{#if statistic > 0}
|
|
46
|
+
<div
|
|
47
|
+
class="grid gap-4"
|
|
48
|
+
style={`grid-template-columns: repeat(${statistic}, minmax(0, 1fr));`}
|
|
49
|
+
>
|
|
50
|
+
{#each Array(statistic) as _, idx (idx)}
|
|
51
|
+
<div class="rounded-xl border border-border bg-card p-4 space-y-3">
|
|
52
|
+
<div class="flex items-center justify-between">
|
|
53
|
+
<div class="h-3.5 w-20 rounded-[4px] bg-muted"></div>
|
|
54
|
+
<div class="h-4 w-4 rounded-[4px] bg-muted/70"></div>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="h-7 w-28 rounded-[4px] bg-muted"></div>
|
|
57
|
+
<div class="h-3 w-36 rounded-[4px] bg-muted/60"></div>
|
|
58
|
+
</div>
|
|
59
|
+
{/each}
|
|
60
|
+
</div>
|
|
61
|
+
{/if}
|
|
62
|
+
|
|
63
|
+
<!-- Table Skeleton -->
|
|
64
|
+
{#if type === 'table'}
|
|
65
|
+
<div class="rounded-xl border border-border bg-card overflow-hidden p-4 space-y-4">
|
|
66
|
+
<!-- Table Toolbar -->
|
|
67
|
+
<div class="flex items-center justify-between gap-4 pb-2">
|
|
68
|
+
<div class="h-8 w-48 rounded-[4px] bg-muted"></div>
|
|
69
|
+
<div class="flex items-center gap-2">
|
|
70
|
+
<div class="h-8 w-20 rounded-[4px] bg-muted"></div>
|
|
71
|
+
<div class="h-8 w-20 rounded-[4px] bg-muted"></div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<!-- Table Header -->
|
|
76
|
+
<div
|
|
77
|
+
class="grid gap-4 border-y border-border py-3 bg-muted/30 px-3"
|
|
78
|
+
style={`grid-template-columns: repeat(${columns}, minmax(0, 1fr));`}
|
|
79
|
+
>
|
|
80
|
+
{#each Array(columns) as _, cIdx (cIdx)}
|
|
81
|
+
<div class="h-3.5 w-16 rounded-[4px] bg-muted"></div>
|
|
82
|
+
{/each}
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<!-- Table Body Rows -->
|
|
86
|
+
<div class="divide-y divide-border/60">
|
|
87
|
+
{#each Array(rows) as _, rIdx (rIdx)}
|
|
88
|
+
<div
|
|
89
|
+
class="grid gap-4 py-3.5 px-3 items-center"
|
|
90
|
+
style={`grid-template-columns: repeat(${columns}, minmax(0, 1fr));`}
|
|
91
|
+
>
|
|
92
|
+
{#each Array(columns) as _, cIdx (cIdx)}
|
|
93
|
+
<div
|
|
94
|
+
class="h-3 rounded-[4px] bg-muted/80"
|
|
95
|
+
style={`width: ${50 + ((rIdx * 17 + cIdx * 23) % 40)}%;`}
|
|
96
|
+
></div>
|
|
97
|
+
{/each}
|
|
98
|
+
</div>
|
|
99
|
+
{/each}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<!-- Table Pagination Bar -->
|
|
103
|
+
<div class="flex items-center justify-between pt-3 border-t border-border">
|
|
104
|
+
<div class="h-3 w-28 rounded-[4px] bg-muted/70"></div>
|
|
105
|
+
<div class="flex items-center gap-1.5">
|
|
106
|
+
<div class="h-7 w-7 rounded-[4px] bg-muted"></div>
|
|
107
|
+
<div class="h-7 w-7 rounded-[4px] bg-muted"></div>
|
|
108
|
+
<div class="h-7 w-7 rounded-[4px] bg-muted"></div>
|
|
109
|
+
<div class="h-7 w-7 rounded-[4px] bg-muted"></div>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
<!-- Descriptions Skeleton -->
|
|
115
|
+
{:else if type === 'descriptions'}
|
|
116
|
+
<div class="rounded-xl border border-border bg-card p-5 space-y-5">
|
|
117
|
+
<!-- Title Bar -->
|
|
118
|
+
<div class="flex items-center justify-between border-b border-border pb-3">
|
|
119
|
+
<div class="h-5 w-36 rounded-[4px] bg-muted"></div>
|
|
120
|
+
<div class="h-7 w-16 rounded-[4px] bg-muted/70"></div>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<!-- Descriptions Grid -->
|
|
124
|
+
<div
|
|
125
|
+
class="grid gap-4"
|
|
126
|
+
style={`grid-template-columns: repeat(${columns}, minmax(0, 1fr));`}
|
|
127
|
+
>
|
|
128
|
+
{#each Array(rows * columns) as _, idx (idx)}
|
|
129
|
+
<div class="space-y-1.5">
|
|
130
|
+
<div class="h-3 w-16 rounded-[4px] bg-muted/60"></div>
|
|
131
|
+
<div
|
|
132
|
+
class="h-4 rounded-[4px] bg-muted"
|
|
133
|
+
style={`width: ${60 + (idx % 3) * 15}%;`}
|
|
134
|
+
></div>
|
|
135
|
+
</div>
|
|
136
|
+
{/each}
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<!-- Form Skeleton -->
|
|
141
|
+
{:else if type === 'form'}
|
|
142
|
+
<div class="rounded-xl border border-border bg-card p-6 space-y-5 max-w-2xl">
|
|
143
|
+
{#each Array(rows) as _, rIdx (rIdx)}
|
|
144
|
+
<div class="space-y-2">
|
|
145
|
+
<div class="h-3.5 w-24 rounded-[4px] bg-muted"></div>
|
|
146
|
+
<div class="h-9 w-full rounded-[4px] bg-muted/60"></div>
|
|
147
|
+
</div>
|
|
148
|
+
{/each}
|
|
149
|
+
|
|
150
|
+
<div class="flex items-center gap-3 pt-3">
|
|
151
|
+
<div class="h-9 w-24 rounded-[4px] bg-primary/40"></div>
|
|
152
|
+
<div class="h-9 w-20 rounded-[4px] bg-muted"></div>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<!-- List Skeleton -->
|
|
157
|
+
{:else if type === 'list'}
|
|
158
|
+
<div class="rounded-xl border border-border bg-card divide-y divide-border/60">
|
|
159
|
+
{#each Array(rows) as _, rIdx (rIdx)}
|
|
160
|
+
<div class="flex items-start gap-4 p-4">
|
|
161
|
+
{#if avatar}
|
|
162
|
+
<div class="h-10 w-10 shrink-0 rounded-full bg-muted"></div>
|
|
163
|
+
{/if}
|
|
164
|
+
<div class="flex-1 space-y-2">
|
|
165
|
+
<div class="h-4 w-40 rounded-[4px] bg-muted"></div>
|
|
166
|
+
<div class="h-3 w-full rounded-[4px] bg-muted/70"></div>
|
|
167
|
+
<div class="h-3 w-3/4 rounded-[4px] bg-muted/60"></div>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
{/each}
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
<!-- Result Skeleton -->
|
|
174
|
+
{:else if type === 'result'}
|
|
175
|
+
<div class="rounded-xl border border-border bg-card p-12 flex flex-col items-center justify-center text-center space-y-4">
|
|
176
|
+
<div class="h-18 w-18 rounded-full bg-muted/80"></div>
|
|
177
|
+
<div class="h-6 w-48 rounded-[4px] bg-muted"></div>
|
|
178
|
+
<div class="h-3.5 w-72 rounded-[4px] bg-muted/70"></div>
|
|
179
|
+
<div class="h-3.5 w-56 rounded-[4px] bg-muted/50"></div>
|
|
180
|
+
<div class="flex items-center gap-3 pt-4">
|
|
181
|
+
<div class="h-9 w-24 rounded-[4px] bg-primary/40"></div>
|
|
182
|
+
<div class="h-9 w-20 rounded-[4px] bg-muted"></div>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
{/if}
|
|
186
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ProSkeletonType = 'table' | 'descriptions' | 'form' | 'list' | 'result';
|
|
2
|
+
export interface ProSkeletonProps {
|
|
3
|
+
/** Structural layout template type */
|
|
4
|
+
type?: ProSkeletonType;
|
|
5
|
+
/** Whether skeleton elements have pulsing animation */
|
|
6
|
+
active?: boolean;
|
|
7
|
+
/** Number of rows to render */
|
|
8
|
+
rows?: number;
|
|
9
|
+
/** Number of columns for table or descriptions */
|
|
10
|
+
columns?: number;
|
|
11
|
+
/** Whether to include avatar skeleton in list or result */
|
|
12
|
+
avatar?: boolean;
|
|
13
|
+
/** Number of statistic KPI cards to render at the top */
|
|
14
|
+
statistic?: number;
|
|
15
|
+
/** Additional CSS classes */
|
|
16
|
+
class?: string;
|
|
17
|
+
}
|
|
18
|
+
declare const ProSkeleton: import("svelte").Component<ProSkeletonProps, {}, "">;
|
|
19
|
+
type ProSkeleton = ReturnType<typeof ProSkeleton>;
|
|
20
|
+
export default ProSkeleton;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
export type RibbonPlacement = 'start' | 'end';
|
|
6
|
+
|
|
7
|
+
export interface RibbonProps {
|
|
8
|
+
/** Text or content snippet displayed in the ribbon */
|
|
9
|
+
text?: string | Snippet;
|
|
10
|
+
/** Preset color theme or custom CSS color string */
|
|
11
|
+
color?: 'primary' | 'success' | 'warning' | 'destructive' | 'info' | 'purple' | 'pink' | string;
|
|
12
|
+
/** Placement position of ribbon on container */
|
|
13
|
+
placement?: RibbonPlacement;
|
|
14
|
+
/** Additional CSS classes for root container */
|
|
15
|
+
class?: string;
|
|
16
|
+
/** Additional CSS classes for ribbon badge */
|
|
17
|
+
ribbonClass?: string;
|
|
18
|
+
/** Wrapped child element or card */
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
text,
|
|
24
|
+
color = 'primary',
|
|
25
|
+
placement = 'end',
|
|
26
|
+
class: className = '',
|
|
27
|
+
ribbonClass = '',
|
|
28
|
+
children,
|
|
29
|
+
}: RibbonProps = $props();
|
|
30
|
+
|
|
31
|
+
const isPresetColor = $derived(
|
|
32
|
+
['primary', 'success', 'warning', 'destructive', 'info', 'purple', 'pink'].includes(color),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const presetBgClasses: Record<string, string> = {
|
|
36
|
+
primary: 'bg-primary text-primary-foreground',
|
|
37
|
+
success: 'bg-primary text-primary-foreground',
|
|
38
|
+
warning: 'bg-accent text-accent-foreground',
|
|
39
|
+
destructive: 'bg-destructive text-destructive-foreground',
|
|
40
|
+
info: 'bg-secondary text-secondary-foreground',
|
|
41
|
+
purple: 'bg-chart-4 text-primary-foreground',
|
|
42
|
+
pink: 'bg-chart-5 text-primary-foreground',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const presetCornerClasses: Record<string, string> = {
|
|
46
|
+
primary: 'border-t-primary/80',
|
|
47
|
+
success: 'border-t-primary/70',
|
|
48
|
+
warning: 'border-t-accent/80',
|
|
49
|
+
destructive: 'border-t-destructive/80',
|
|
50
|
+
info: 'border-t-secondary/80',
|
|
51
|
+
purple: 'border-t-chart-4/80',
|
|
52
|
+
pink: 'border-t-chart-5/80',
|
|
53
|
+
};
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div
|
|
57
|
+
data-svadmin-component="Ribbon"
|
|
58
|
+
class={cn('relative inline-block w-full', className)}
|
|
59
|
+
>
|
|
60
|
+
{#if children}
|
|
61
|
+
{@render children()}
|
|
62
|
+
{/if}
|
|
63
|
+
|
|
64
|
+
{#if text}
|
|
65
|
+
<div
|
|
66
|
+
data-placement={placement}
|
|
67
|
+
class={cn(
|
|
68
|
+
'absolute top-2 z-10 flex h-[22px] items-center px-2 text-[11px] font-semibold tracking-wide shadow-xs select-none',
|
|
69
|
+
placement === 'end' ? '-right-2 rounded-l-[3px]' : '-left-2 rounded-r-[3px]',
|
|
70
|
+
isPresetColor ? presetBgClasses[color] : 'text-white',
|
|
71
|
+
ribbonClass,
|
|
72
|
+
)}
|
|
73
|
+
style={!isPresetColor ? `background-color: ${color};` : undefined}
|
|
74
|
+
>
|
|
75
|
+
{#if typeof text === 'string'}
|
|
76
|
+
<span>{text}</span>
|
|
77
|
+
{:else}
|
|
78
|
+
{@render text()}
|
|
79
|
+
{/if}
|
|
80
|
+
|
|
81
|
+
<!-- Corner Fold Shadow Effect -->
|
|
82
|
+
<span
|
|
83
|
+
aria-hidden="true"
|
|
84
|
+
class={cn(
|
|
85
|
+
'absolute top-full border-[4px] border-transparent',
|
|
86
|
+
placement === 'end'
|
|
87
|
+
? 'right-0 border-t-[4px] border-l-[4px] border-l-transparent'
|
|
88
|
+
: 'left-0 border-t-[4px] border-r-[4px] border-r-transparent',
|
|
89
|
+
isPresetColor ? presetCornerClasses[color] : '',
|
|
90
|
+
)}
|
|
91
|
+
style={!isPresetColor
|
|
92
|
+
? `border-top-color: color-mix(in srgb, ${color} 70%, black);`
|
|
93
|
+
: undefined}
|
|
94
|
+
></span>
|
|
95
|
+
</div>
|
|
96
|
+
{/if}
|
|
97
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type RibbonPlacement = 'start' | 'end';
|
|
3
|
+
export interface RibbonProps {
|
|
4
|
+
/** Text or content snippet displayed in the ribbon */
|
|
5
|
+
text?: string | Snippet;
|
|
6
|
+
/** Preset color theme or custom CSS color string */
|
|
7
|
+
color?: 'primary' | 'success' | 'warning' | 'destructive' | 'info' | 'purple' | 'pink' | string;
|
|
8
|
+
/** Placement position of ribbon on container */
|
|
9
|
+
placement?: RibbonPlacement;
|
|
10
|
+
/** Additional CSS classes for root container */
|
|
11
|
+
class?: string;
|
|
12
|
+
/** Additional CSS classes for ribbon badge */
|
|
13
|
+
ribbonClass?: string;
|
|
14
|
+
/** Wrapped child element or card */
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
}
|
|
17
|
+
declare const Ribbon: import("svelte").Component<RibbonProps, {}, "">;
|
|
18
|
+
type Ribbon = ReturnType<typeof Ribbon>;
|
|
19
|
+
export default Ribbon;
|