@svadmin/ui 0.114.0 → 0.116.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 +93 -0
- package/dist/app.theme.css +93 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AppearanceSettings.svelte +70 -1
- package/dist/components/AuditLogDrawer.svelte +31 -7
- package/dist/components/AuditLogDrawer.svelte.d.ts +4 -0
- package/dist/components/CheckCard.svelte +149 -0
- package/dist/components/CheckCard.svelte.d.ts +31 -0
- package/dist/components/Layout.svelte +48 -4
- package/dist/components/PricingCard.svelte +158 -0
- package/dist/components/PricingCard.svelte.d.ts +42 -0
- package/dist/components/QuotaProgressBar.svelte +139 -0
- package/dist/components/QuotaProgressBar.svelte.d.ts +27 -0
- package/dist/components/StatisticCard.svelte +167 -0
- package/dist/components/StatisticCard.svelte.d.ts +41 -0
- package/dist/components/WorkflowDesigner.svelte +96 -53
- package/dist/components/WorkflowDesigner.svelte.d.ts +3 -0
- package/dist/components/fields/UploadField.svelte +35 -7
- package/dist/components/fields/UploadField.svelte.d.ts +3 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +9 -0
- package/package.json +4 -4
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
export interface StatisticTrendItem {
|
|
6
|
+
/** Label of the trend (e.g. '周同比', '日环比') */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Trend value (e.g. '12.5%', 18.2) */
|
|
9
|
+
value: string | number;
|
|
10
|
+
/** Trend direction */
|
|
11
|
+
direction: 'up' | 'down';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface StatisticCardProps {
|
|
15
|
+
/** Card title */
|
|
16
|
+
title?: string;
|
|
17
|
+
/** Tooltip explanation text */
|
|
18
|
+
tip?: string;
|
|
19
|
+
/** Main numerical value */
|
|
20
|
+
value?: string | number;
|
|
21
|
+
/** Prefix symbol (e.g. '¥', '$') */
|
|
22
|
+
prefix?: string;
|
|
23
|
+
/** Suffix symbol (e.g. '%', '人', '单') */
|
|
24
|
+
suffix?: string;
|
|
25
|
+
/** Decimal precision */
|
|
26
|
+
precision?: number;
|
|
27
|
+
/** Array of trend comparisons (e.g. YoY / MoM) */
|
|
28
|
+
trends?: StatisticTrendItem[];
|
|
29
|
+
/** Custom extra action in header */
|
|
30
|
+
extra?: Snippet;
|
|
31
|
+
/** Embedded chart or sparkline slot */
|
|
32
|
+
chart?: Snippet;
|
|
33
|
+
/** Bottom footer summary slot */
|
|
34
|
+
footer?: Snippet;
|
|
35
|
+
/** Card content slot */
|
|
36
|
+
children?: Snippet;
|
|
37
|
+
/** Card size */
|
|
38
|
+
size?: 'default' | 'small';
|
|
39
|
+
/** Additional CSS classes */
|
|
40
|
+
class?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let {
|
|
45
|
+
title,
|
|
46
|
+
tip,
|
|
47
|
+
value = 0,
|
|
48
|
+
prefix,
|
|
49
|
+
suffix,
|
|
50
|
+
precision,
|
|
51
|
+
trends = [],
|
|
52
|
+
extra,
|
|
53
|
+
chart,
|
|
54
|
+
footer,
|
|
55
|
+
children,
|
|
56
|
+
size = 'default',
|
|
57
|
+
class: className = '',
|
|
58
|
+
...restProps
|
|
59
|
+
}: StatisticCardProps = $props();
|
|
60
|
+
|
|
61
|
+
const formattedValue = $derived.by(() => {
|
|
62
|
+
if (typeof value === 'number' && precision !== undefined) {
|
|
63
|
+
return value.toFixed(precision);
|
|
64
|
+
}
|
|
65
|
+
return String(value);
|
|
66
|
+
});
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<div
|
|
70
|
+
data-svadmin-component="StatisticCard"
|
|
71
|
+
class={cn(
|
|
72
|
+
'svadmin-statistic-card flex flex-col justify-between rounded-[4px] border border-border bg-card text-card-foreground shadow-sm hover:border-primary/40 transition-colors',
|
|
73
|
+
size === 'small' ? 'p-3 text-xs' : 'p-4 text-sm',
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
76
|
+
{...restProps}
|
|
77
|
+
>
|
|
78
|
+
<!-- Card Header -->
|
|
79
|
+
{#if title || extra}
|
|
80
|
+
<div class="flex items-center justify-between pb-2 border-b border-border/60">
|
|
81
|
+
<div class="flex items-center gap-1.5 min-w-0">
|
|
82
|
+
{#if title}
|
|
83
|
+
<span class="font-medium text-xs text-muted-foreground truncate">{title}</span>
|
|
84
|
+
{/if}
|
|
85
|
+
{#if tip}
|
|
86
|
+
<span
|
|
87
|
+
title={tip}
|
|
88
|
+
class="inline-flex items-center justify-center w-3.5 h-3.5 rounded-full bg-muted text-[10px] text-muted-foreground/80 cursor-help"
|
|
89
|
+
>
|
|
90
|
+
?
|
|
91
|
+
</span>
|
|
92
|
+
{/if}
|
|
93
|
+
</div>
|
|
94
|
+
{#if extra}
|
|
95
|
+
<div class="shrink-0 text-xs text-muted-foreground">
|
|
96
|
+
{@render extra()}
|
|
97
|
+
</div>
|
|
98
|
+
{/if}
|
|
99
|
+
</div>
|
|
100
|
+
{/if}
|
|
101
|
+
|
|
102
|
+
<!-- Main Metric Number -->
|
|
103
|
+
<div class="my-2.5">
|
|
104
|
+
<div class="flex items-baseline gap-1">
|
|
105
|
+
{#if prefix}
|
|
106
|
+
<span class="text-sm font-medium text-muted-foreground">{prefix}</span>
|
|
107
|
+
{/if}
|
|
108
|
+
<span class={cn('font-bold tracking-tight text-foreground font-mono leading-none', size === 'small' ? 'text-xl' : 'text-2xl sm:text-3xl')}>
|
|
109
|
+
{formattedValue}
|
|
110
|
+
</span>
|
|
111
|
+
{#if suffix}
|
|
112
|
+
<span class="text-xs text-muted-foreground font-normal ml-0.5">{suffix}</span>
|
|
113
|
+
{/if}
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<!-- Trend Indicators (YoY / MoM) -->
|
|
117
|
+
{#if trends.length > 0}
|
|
118
|
+
<div class="flex flex-wrap items-center gap-3 mt-2 text-xs">
|
|
119
|
+
{#each trends as trend, idx (trend.label ? trend.label + idx : idx)}
|
|
120
|
+
<div class="flex items-center gap-1">
|
|
121
|
+
{#if trend.label}
|
|
122
|
+
<span class="text-muted-foreground text-[11px]">{trend.label}</span>
|
|
123
|
+
{/if}
|
|
124
|
+
<span
|
|
125
|
+
class={cn(
|
|
126
|
+
'inline-flex items-center text-xs font-medium font-mono',
|
|
127
|
+
trend.direction === 'up' ? 'text-success' : 'text-destructive'
|
|
128
|
+
)}
|
|
129
|
+
>
|
|
130
|
+
{#if trend.direction === 'up'}
|
|
131
|
+
<svg class="w-3 h-3 shrink-0 mr-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
132
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 10l7-7m0 0l7 7m-7-7v18" />
|
|
133
|
+
</svg>
|
|
134
|
+
{:else}
|
|
135
|
+
<svg class="w-3 h-3 shrink-0 mr-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
136
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 14l-7 7m0 0l-7-7m7 7V3" />
|
|
137
|
+
</svg>
|
|
138
|
+
{/if}
|
|
139
|
+
{trend.value}
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
{/each}
|
|
143
|
+
</div>
|
|
144
|
+
{/if}
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<!-- Chart / Sparkline Slot -->
|
|
148
|
+
{#if chart}
|
|
149
|
+
<div class="my-1.5 w-full">
|
|
150
|
+
{@render chart()}
|
|
151
|
+
</div>
|
|
152
|
+
{/if}
|
|
153
|
+
|
|
154
|
+
<!-- Body Content -->
|
|
155
|
+
{#if children}
|
|
156
|
+
<div class="mt-1 text-xs text-muted-foreground">
|
|
157
|
+
{@render children()}
|
|
158
|
+
</div>
|
|
159
|
+
{/if}
|
|
160
|
+
|
|
161
|
+
<!-- Footer -->
|
|
162
|
+
{#if footer}
|
|
163
|
+
<div class="mt-3 pt-2.5 border-t border-border/60 text-xs text-muted-foreground">
|
|
164
|
+
{@render footer()}
|
|
165
|
+
</div>
|
|
166
|
+
{/if}
|
|
167
|
+
</div>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface StatisticTrendItem {
|
|
3
|
+
/** Label of the trend (e.g. '周同比', '日环比') */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Trend value (e.g. '12.5%', 18.2) */
|
|
6
|
+
value: string | number;
|
|
7
|
+
/** Trend direction */
|
|
8
|
+
direction: 'up' | 'down';
|
|
9
|
+
}
|
|
10
|
+
export interface StatisticCardProps {
|
|
11
|
+
/** Card title */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** Tooltip explanation text */
|
|
14
|
+
tip?: string;
|
|
15
|
+
/** Main numerical value */
|
|
16
|
+
value?: string | number;
|
|
17
|
+
/** Prefix symbol (e.g. '¥', '$') */
|
|
18
|
+
prefix?: string;
|
|
19
|
+
/** Suffix symbol (e.g. '%', '人', '单') */
|
|
20
|
+
suffix?: string;
|
|
21
|
+
/** Decimal precision */
|
|
22
|
+
precision?: number;
|
|
23
|
+
/** Array of trend comparisons (e.g. YoY / MoM) */
|
|
24
|
+
trends?: StatisticTrendItem[];
|
|
25
|
+
/** Custom extra action in header */
|
|
26
|
+
extra?: Snippet;
|
|
27
|
+
/** Embedded chart or sparkline slot */
|
|
28
|
+
chart?: Snippet;
|
|
29
|
+
/** Bottom footer summary slot */
|
|
30
|
+
footer?: Snippet;
|
|
31
|
+
/** Card content slot */
|
|
32
|
+
children?: Snippet;
|
|
33
|
+
/** Card size */
|
|
34
|
+
size?: 'default' | 'small';
|
|
35
|
+
/** Additional CSS classes */
|
|
36
|
+
class?: string;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
declare const StatisticCard: import("svelte").Component<StatisticCardProps, {}, "">;
|
|
40
|
+
type StatisticCard = ReturnType<typeof StatisticCard>;
|
|
41
|
+
export default StatisticCard;
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
assignees?: string[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export type WorkflowNodeRenderer = Snippet<[WorkflowNode]>;
|
|
16
|
+
|
|
15
17
|
export interface WorkflowDesignerProps {
|
|
16
18
|
/** List of workflow steps in linear or branching order */
|
|
17
19
|
nodes?: WorkflowNode[];
|
|
@@ -23,6 +25,8 @@
|
|
|
23
25
|
onaddnode?: (targetNodeId: string, type: 'approver' | 'condition' | 'notifier') => void;
|
|
24
26
|
/** Callback when a node is removed */
|
|
25
27
|
ondeletenode?: (nodeId: string) => void;
|
|
28
|
+
/** Optional renderer per node type; defaults to the built-in node card. */
|
|
29
|
+
nodeTypes?: Partial<Record<WorkflowNode['type'], WorkflowNodeRenderer>>;
|
|
26
30
|
/** Extra header or toolbar slot */
|
|
27
31
|
extra?: Snippet;
|
|
28
32
|
/** Additional CSS classes */
|
|
@@ -39,6 +43,7 @@
|
|
|
39
43
|
onnodeclick,
|
|
40
44
|
onaddnode,
|
|
41
45
|
ondeletenode,
|
|
46
|
+
nodeTypes,
|
|
42
47
|
extra,
|
|
43
48
|
class: className = '',
|
|
44
49
|
}: WorkflowDesignerProps = $props();
|
|
@@ -116,67 +121,105 @@
|
|
|
116
121
|
<div class="relative flex flex-col items-center gap-0">
|
|
117
122
|
{#each nodes as node, index (node.id)}
|
|
118
123
|
{@const colors = getNodeTypeColor(node.type)}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
{@const customNode = nodeTypes?.[node.type]}
|
|
125
|
+
{#if customNode}
|
|
126
|
+
<div class="group/node relative flex w-72 flex-col rounded-[4px] border border-border bg-card shadow-xs transition-all hover:shadow-md">
|
|
127
|
+
<div
|
|
128
|
+
role="button"
|
|
129
|
+
tabindex="0"
|
|
130
|
+
class="w-full text-left focus-visible:outline-none"
|
|
131
|
+
aria-label={`编辑 ${node.title}`}
|
|
132
|
+
onclick={() => onnodeclick?.(node)}
|
|
133
|
+
onkeydown={(event) => {
|
|
134
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
onnodeclick?.(node);
|
|
137
|
+
}
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
{@render customNode(node)}
|
|
125
141
|
</div>
|
|
126
142
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
>
|
|
144
|
-
<svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
|
145
|
-
<line x1="18" y1="6" x2="6" y2="18" />
|
|
146
|
-
<line x1="6" y1="6" x2="18" y2="18" />
|
|
147
|
-
</svg>
|
|
148
|
-
</button>
|
|
149
|
-
{/if}
|
|
150
|
-
</div>
|
|
143
|
+
{#if !readonly && node.type !== 'start'}
|
|
144
|
+
<button
|
|
145
|
+
type="button"
|
|
146
|
+
aria-label={`删除 ${node.title}`}
|
|
147
|
+
class="absolute right-2 top-2 p-0.5 text-muted-foreground transition-colors hover:text-destructive"
|
|
148
|
+
onclick={(event) => {
|
|
149
|
+
event.stopPropagation();
|
|
150
|
+
ondeletenode?.(node.id);
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
<svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
|
154
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
155
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
156
|
+
</svg>
|
|
157
|
+
</button>
|
|
158
|
+
{/if}
|
|
151
159
|
</div>
|
|
160
|
+
{:else}
|
|
161
|
+
<!-- Node Card -->
|
|
162
|
+
<div class="group/node relative flex w-72 flex-col rounded-[4px] border border-border bg-card shadow-xs transition-all hover:shadow-md">
|
|
163
|
+
<!-- Node Header -->
|
|
164
|
+
<div class={cn('flex items-center justify-between px-3 py-1.5 rounded-t-[3px]', colors.headerBg, colors.headerText)}>
|
|
165
|
+
<div class="flex items-center gap-1.5 text-xs font-medium">
|
|
166
|
+
<span>{node.title}</span>
|
|
167
|
+
</div>
|
|
152
168
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
169
|
+
<div class="flex items-center gap-1">
|
|
170
|
+
{#if node.status}
|
|
171
|
+
<span class={cn('rounded-[2px] border px-1.5 py-0.2 text-[10px] font-normal leading-tight', getStatusTone(node.status))}>
|
|
172
|
+
{node.status}
|
|
173
|
+
</span>
|
|
174
|
+
{/if}
|
|
175
|
+
|
|
176
|
+
{#if !readonly && node.type !== 'start'}
|
|
177
|
+
<button
|
|
178
|
+
type="button"
|
|
179
|
+
aria-label={`删除 ${node.title}`}
|
|
180
|
+
class="opacity-0 transition-opacity group-hover/node:opacity-100 p-0.5 text-white/80 hover:text-white"
|
|
181
|
+
onclick={(e) => {
|
|
182
|
+
e.stopPropagation();
|
|
183
|
+
ondeletenode?.(node.id);
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
<svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
|
187
|
+
<line x1="18" y1="6" x2="6" y2="18" />
|
|
188
|
+
<line x1="6" y1="6" x2="18" y2="18" />
|
|
189
|
+
</svg>
|
|
190
|
+
</button>
|
|
191
|
+
{/if}
|
|
192
|
+
</div>
|
|
161
193
|
</div>
|
|
162
194
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
195
|
+
<!-- Node Body -->
|
|
196
|
+
<button
|
|
197
|
+
type="button"
|
|
198
|
+
class="flex w-full flex-col items-start p-3 text-left transition-colors hover:bg-muted/30 focus-visible:outline-none"
|
|
199
|
+
onclick={() => onnodeclick?.(node)}
|
|
200
|
+
>
|
|
201
|
+
<div class="text-xs text-foreground line-clamp-2">
|
|
202
|
+
{node.content || '请设置节点属性'}
|
|
170
203
|
</div>
|
|
171
|
-
{/if}
|
|
172
204
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
205
|
+
{#if node.assignees && node.assignees.length > 0}
|
|
206
|
+
<div class="mt-2 flex flex-wrap gap-1">
|
|
207
|
+
{#each node.assignees as assignee (assignee)}
|
|
208
|
+
<span class="rounded-[2px] bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground">
|
|
209
|
+
{assignee}
|
|
210
|
+
</span>
|
|
211
|
+
{/each}
|
|
212
|
+
</div>
|
|
213
|
+
{/if}
|
|
214
|
+
|
|
215
|
+
{#if node.error}
|
|
216
|
+
<span class="mt-1 text-[11px] text-destructive">
|
|
217
|
+
{node.error}
|
|
218
|
+
</span>
|
|
219
|
+
{/if}
|
|
220
|
+
</button>
|
|
221
|
+
</div>
|
|
222
|
+
{/if}
|
|
180
223
|
|
|
181
224
|
<!-- Connecting line and Add Button -->
|
|
182
225
|
{#if index < nodes.length - 1 || !readonly}
|
|
@@ -8,6 +8,7 @@ export interface WorkflowNode {
|
|
|
8
8
|
error?: string;
|
|
9
9
|
assignees?: string[];
|
|
10
10
|
}
|
|
11
|
+
export type WorkflowNodeRenderer = Snippet<[WorkflowNode]>;
|
|
11
12
|
export interface WorkflowDesignerProps {
|
|
12
13
|
/** List of workflow steps in linear or branching order */
|
|
13
14
|
nodes?: WorkflowNode[];
|
|
@@ -19,6 +20,8 @@ export interface WorkflowDesignerProps {
|
|
|
19
20
|
onaddnode?: (targetNodeId: string, type: 'approver' | 'condition' | 'notifier') => void;
|
|
20
21
|
/** Callback when a node is removed */
|
|
21
22
|
ondeletenode?: (nodeId: string) => void;
|
|
23
|
+
/** Optional renderer per node type; defaults to the built-in node card. */
|
|
24
|
+
nodeTypes?: Partial<Record<WorkflowNode['type'], WorkflowNodeRenderer>>;
|
|
22
25
|
/** Extra header or toolbar slot */
|
|
23
26
|
extra?: Snippet;
|
|
24
27
|
/** Additional CSS classes */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { useStorage } from '@svadmin/core';
|
|
2
|
+
import { useStorage, type StorageProvider } from '@svadmin/core';
|
|
3
3
|
import { Upload, X, FileText, AlertCircle, Loader2 } from '@lucide/svelte';
|
|
4
4
|
|
|
5
5
|
export interface UploadFieldProps {
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
label?: string;
|
|
13
13
|
description?: string;
|
|
14
|
+
/** Optional storage adapter; defaults to the StorageProvider from AdminContext. */
|
|
15
|
+
storage?: StorageProvider;
|
|
14
16
|
onchange?: (value: string | string[] | null) => void;
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -23,15 +25,29 @@
|
|
|
23
25
|
disabled = false,
|
|
24
26
|
label,
|
|
25
27
|
description,
|
|
28
|
+
storage,
|
|
26
29
|
onchange,
|
|
27
30
|
}: UploadFieldProps = $props();
|
|
28
31
|
|
|
29
32
|
const inputId = $props.id();
|
|
30
|
-
const
|
|
33
|
+
const contextStorage = useStorage();
|
|
31
34
|
|
|
32
35
|
let isDragging = $state(false);
|
|
33
36
|
let errorMessage = $state<string | null>(null);
|
|
34
37
|
let uploadQueue = $state<Array<{ name: string; size: number; progress: number }>>([]);
|
|
38
|
+
let isUploading = $state(false);
|
|
39
|
+
let uploadProgress = $state(0);
|
|
40
|
+
let uploadedPaths = $state<Record<string, string>>({});
|
|
41
|
+
|
|
42
|
+
async function uploadFile(file: File, options: Parameters<StorageProvider['upload']>[1]) {
|
|
43
|
+
if (storage) return storage.upload(file, options);
|
|
44
|
+
return contextStorage.upload(file, options);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function deleteFile(path: string): Promise<void> {
|
|
48
|
+
if (storage) return storage.delete(path);
|
|
49
|
+
return contextStorage.deleteFile(path);
|
|
50
|
+
}
|
|
35
51
|
|
|
36
52
|
// Normalize initial value to array for uniform internal rendering
|
|
37
53
|
let fileList = $derived.by<string[]>(() => {
|
|
@@ -66,11 +82,14 @@
|
|
|
66
82
|
const queueItem = { name: file.name, size: file.size, progress: 0 };
|
|
67
83
|
uploadQueue = [...uploadQueue, queueItem];
|
|
68
84
|
|
|
85
|
+
isUploading = true;
|
|
86
|
+
uploadProgress = 0;
|
|
69
87
|
try {
|
|
70
|
-
const res = await
|
|
88
|
+
const res = await uploadFile(file, {
|
|
71
89
|
path,
|
|
72
90
|
filename: file.name,
|
|
73
91
|
onProgress: (p) => {
|
|
92
|
+
uploadProgress = p.percentage;
|
|
74
93
|
uploadQueue = uploadQueue.map((item) => item === queueItem ? { ...item, progress: p.percentage } : item);
|
|
75
94
|
},
|
|
76
95
|
});
|
|
@@ -80,9 +99,12 @@
|
|
|
80
99
|
} else {
|
|
81
100
|
currentUrls.splice(0, currentUrls.length, res.url);
|
|
82
101
|
}
|
|
102
|
+
uploadedPaths = { ...uploadedPaths, [res.url]: res.path };
|
|
83
103
|
} catch (err) {
|
|
84
104
|
errorMessage = err instanceof Error ? err.message : 'Upload failed';
|
|
85
105
|
} finally {
|
|
106
|
+
isUploading = false;
|
|
107
|
+
uploadProgress = 0;
|
|
86
108
|
uploadQueue = uploadQueue.filter((q) => q !== queueItem);
|
|
87
109
|
}
|
|
88
110
|
}
|
|
@@ -114,11 +136,17 @@
|
|
|
114
136
|
|
|
115
137
|
// Attempt backend delete if path is extractable
|
|
116
138
|
try {
|
|
139
|
+
const trackedPath = uploadedPaths[urlToRemove];
|
|
117
140
|
const urlObj = new URL(urlToRemove, 'https://dummy.local');
|
|
118
|
-
const cleanPath = urlObj.pathname.replace(/^\/+/, '');
|
|
119
|
-
await
|
|
141
|
+
const cleanPath = trackedPath ?? urlObj.pathname.replace(/^\/+/, '');
|
|
142
|
+
await deleteFile(cleanPath);
|
|
120
143
|
} catch {
|
|
121
144
|
// Best-effort cleanup
|
|
145
|
+
} finally {
|
|
146
|
+
if (uploadedPaths[urlToRemove]) {
|
|
147
|
+
const { [urlToRemove]: _removed, ...remainingPaths } = uploadedPaths;
|
|
148
|
+
uploadedPaths = remainingPaths;
|
|
149
|
+
}
|
|
122
150
|
}
|
|
123
151
|
}
|
|
124
152
|
</script>
|
|
@@ -151,9 +179,9 @@
|
|
|
151
179
|
/>
|
|
152
180
|
|
|
153
181
|
<div class="flex flex-col items-center justify-center gap-1.5 py-2 pointer-events-none">
|
|
154
|
-
{#if
|
|
182
|
+
{#if isUploading}
|
|
155
183
|
<Loader2 class="h-6 w-6 text-primary animate-spin" />
|
|
156
|
-
<span class="text-xs font-medium text-muted-foreground">Uploading... ({
|
|
184
|
+
<span class="text-xs font-medium text-muted-foreground">Uploading... ({uploadProgress}%)</span>
|
|
157
185
|
{:else}
|
|
158
186
|
<Upload class="h-6 w-6 text-muted-foreground/80" />
|
|
159
187
|
<div class="text-xs text-foreground font-medium">
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StorageProvider } from '@svadmin/core';
|
|
1
2
|
export interface UploadFieldProps {
|
|
2
3
|
value?: string | string[] | null;
|
|
3
4
|
multiple?: boolean;
|
|
@@ -7,6 +8,8 @@ export interface UploadFieldProps {
|
|
|
7
8
|
disabled?: boolean;
|
|
8
9
|
label?: string;
|
|
9
10
|
description?: string;
|
|
11
|
+
/** Optional storage adapter; defaults to the StorageProvider from AdminContext. */
|
|
12
|
+
storage?: StorageProvider;
|
|
10
13
|
onchange?: (value: string | string[] | null) => void;
|
|
11
14
|
}
|
|
12
15
|
declare const UploadField: import("svelte").Component<UploadFieldProps, {}, "value">;
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export { default as AppShellPage } from './components/AppShellPage.svelte';
|
|
|
59
59
|
export { default as ResourceOperationsPage } from './components/ResourceOperationsPage.svelte';
|
|
60
60
|
export { default as RecordDetailDrawer } from './components/RecordDetailDrawer.svelte';
|
|
61
61
|
export { default as AuditLogDrawer } from './components/AuditLogDrawer.svelte';
|
|
62
|
+
export type { AuditLogDrawerLoader } from './components/AuditLogDrawer.svelte';
|
|
62
63
|
export { default as ResourceAccessGuard } from './components/ResourceAccessGuard.svelte';
|
|
63
64
|
export { default as RouteAccessGuard } from './components/RouteAccessGuard.svelte';
|
|
64
65
|
export { default as LoginPage } from './components/LoginPage.svelte';
|
|
@@ -491,9 +492,19 @@ export type { ProDescriptionsProps, ProDescriptionItem } from './components/ProD
|
|
|
491
492
|
export { default as FormDependency } from './components/FormDependency.svelte';
|
|
492
493
|
export type { FormDependencyProps } from './components/FormDependency.svelte';
|
|
493
494
|
export { default as WorkflowDesigner } from './components/WorkflowDesigner.svelte';
|
|
494
|
-
export type { WorkflowDesignerProps, WorkflowNode } from './components/WorkflowDesigner.svelte';
|
|
495
|
+
export type { WorkflowDesignerProps, WorkflowNode, WorkflowNodeRenderer } from './components/WorkflowDesigner.svelte';
|
|
495
496
|
export { default as RoleSwitcher } from './components/RoleSwitcher.svelte';
|
|
496
497
|
export type { RoleSwitcherProps, RoleItem } from './components/RoleSwitcher.svelte';
|
|
497
498
|
export { default as RealtimeMonitorView } from './components/RealtimeMonitorView.svelte';
|
|
498
499
|
export type { RealtimeMonitorViewProps, MetricCardItem } from './components/RealtimeMonitorView.svelte';
|
|
499
500
|
export * from './components/icons/index.js';
|
|
501
|
+
export { default as CheckCard } from './components/CheckCard.svelte';
|
|
502
|
+
export type { CheckCardProps } from './components/CheckCard.svelte';
|
|
503
|
+
export { default as StatisticCard } from './components/StatisticCard.svelte';
|
|
504
|
+
export type { StatisticCardProps, StatisticTrendItem } from './components/StatisticCard.svelte';
|
|
505
|
+
export { default as MaskedText } from './components/SensitiveDataMask.svelte';
|
|
506
|
+
export { default as WaterMark } from './components/Watermark.svelte';
|
|
507
|
+
export { default as PricingCard } from './components/PricingCard.svelte';
|
|
508
|
+
export type { PricingCardProps, PricingFeature } from './components/PricingCard.svelte';
|
|
509
|
+
export { default as QuotaProgressBar } from './components/QuotaProgressBar.svelte';
|
|
510
|
+
export type { QuotaProgressBarProps } from './components/QuotaProgressBar.svelte';
|
package/dist/index.js
CHANGED
|
@@ -389,3 +389,12 @@ export { default as RoleSwitcher } from './components/RoleSwitcher.svelte';
|
|
|
389
389
|
export { default as RealtimeMonitorView } from './components/RealtimeMonitorView.svelte';
|
|
390
390
|
// Enterprise business icons suite
|
|
391
391
|
export * from './components/icons/index.js';
|
|
392
|
+
// Enterprise card-level selection and analytical statistics components
|
|
393
|
+
export { default as CheckCard } from './components/CheckCard.svelte';
|
|
394
|
+
export { default as StatisticCard } from './components/StatisticCard.svelte';
|
|
395
|
+
// Canonical compatibility aliases for security and masking
|
|
396
|
+
export { default as MaskedText } from './components/SensitiveDataMask.svelte';
|
|
397
|
+
export { default as WaterMark } from './components/Watermark.svelte';
|
|
398
|
+
// Enterprise SaaS billing, pricing, and quota management components
|
|
399
|
+
export { default as PricingCard } from './components/PricingCard.svelte';
|
|
400
|
+
export { default as QuotaProgressBar } from './components/QuotaProgressBar.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.116.0",
|
|
4
4
|
"description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@codemirror/lang-json": "^6.0.0",
|
|
89
89
|
"@codemirror/lang-markdown": "^6.0.0",
|
|
90
90
|
"@codemirror/lang-sql": "^6.0.0",
|
|
91
|
-
"@svadmin/core": "^0.
|
|
91
|
+
"@svadmin/core": "^0.77.0",
|
|
92
92
|
"@tanstack/svelte-query": "^6.1.48",
|
|
93
93
|
"codemirror": "^6.0.0",
|
|
94
94
|
"dashjs": "^4.7.4",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
153
|
"dependencies": {
|
|
154
|
-
"@svadmin/devtools": "^0.6.
|
|
154
|
+
"@svadmin/devtools": "^0.6.6",
|
|
155
155
|
"@svadmin/devtools-contract": "^0.3.1",
|
|
156
156
|
"@vibeunion/devtools-devframe": "^0.1.0",
|
|
157
157
|
"typebox": "^1.3.34",
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
"@codemirror/lang-markdown": "^6.5.2",
|
|
190
190
|
"@codemirror/lang-sql": "^6.10.0",
|
|
191
191
|
"@happy-dom/global-registrator": "^20.11.12",
|
|
192
|
-
"@svadmin/ai-elements": "^0.14.
|
|
192
|
+
"@svadmin/ai-elements": "^0.14.1",
|
|
193
193
|
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
194
194
|
"@tailwindcss/cli": "4.3.3",
|
|
195
195
|
"@testing-library/dom": "^10.4.1",
|