@svadmin/ui 0.116.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 +320 -26
- package/dist/app.theme.css +320 -26
- 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/CopyableText.svelte +90 -0
- package/dist/components/CopyableText.svelte.d.ts +13 -0
- package/dist/components/Divider.svelte +89 -0
- package/dist/components/Divider.svelte.d.ts +19 -0
- package/dist/components/EllipsisText.svelte +78 -0
- package/dist/components/EllipsisText.svelte.d.ts +15 -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/FullscreenButton.svelte +88 -0
- package/dist/components/FullscreenButton.svelte.d.ts +10 -0
- package/dist/components/GlobalShortcuts.svelte +229 -0
- package/dist/components/GlobalShortcuts.svelte.d.ts +18 -0
- package/dist/components/Header.svelte +17 -1
- package/dist/components/Header.svelte.d.ts +3 -0
- package/dist/components/Layout.svelte +3 -0
- package/dist/components/Layout.svelte.d.ts +1 -0
- package/dist/components/LightFilter.svelte +281 -0
- package/dist/components/LightFilter.svelte.d.ts +36 -0
- package/dist/components/LockScreen.svelte +295 -0
- package/dist/components/LockScreen.svelte.d.ts +21 -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/PricingCard.svelte +12 -12
- package/dist/components/PricingCard.svelte.d.ts +12 -12
- package/dist/components/PricingTable.svelte +185 -0
- package/dist/components/PricingTable.svelte.d.ts +40 -0
- package/dist/components/ProCard.svelte +267 -0
- package/dist/components/ProCard.svelte.d.ts +56 -0
- package/dist/components/ProSkeleton.svelte +186 -0
- package/dist/components/ProSkeleton.svelte.d.ts +20 -0
- package/dist/components/QuotaProgressBar.svelte +8 -8
- package/dist/components/QuotaProgressBar.svelte.d.ts +8 -8
- 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/TypographyEllipsis.svelte +12 -9
- package/dist/components/TypographyEllipsis.svelte.d.ts +9 -8
- package/dist/components/TypographyText.svelte +41 -3
- package/dist/components/TypographyText.svelte.d.ts +10 -2
- package/dist/components/UsageCard.svelte +97 -0
- package/dist/components/UsageCard.svelte.d.ts +26 -0
- package/dist/components/WorkflowProcessCard.svelte +93 -0
- package/dist/components/WorkflowProcessCard.svelte.d.ts +21 -0
- package/dist/components/ui/badge/badge.svelte +156 -12
- package/dist/components/ui/badge/badge.svelte.d.ts +9 -0
- package/dist/components/ui/badge/index.d.ts +1 -1
- package/dist/index.d.ts +44 -3
- package/dist/index.js +28 -2
- package/package.json +5 -5
|
@@ -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;
|
|
@@ -9,21 +9,21 @@
|
|
|
9
9
|
/** Total allocated quota limit */
|
|
10
10
|
total: number;
|
|
11
11
|
/** Metric unit suffix (e.g. 'GB', 'calls', 'seats') */
|
|
12
|
-
unit?: string;
|
|
12
|
+
unit?: string | undefined;
|
|
13
13
|
/** Ratio for warning state (0-1). Defaults to 0.8 (80%) */
|
|
14
|
-
warningThreshold?: number;
|
|
14
|
+
warningThreshold?: number | undefined;
|
|
15
15
|
/** Ratio for critical state (0-1). Defaults to 0.95 (95%) */
|
|
16
|
-
criticalThreshold?: number;
|
|
16
|
+
criticalThreshold?: number | undefined;
|
|
17
17
|
/** Whether to display the percentage badge. Defaults to true */
|
|
18
|
-
showPercent?: boolean;
|
|
18
|
+
showPercent?: boolean | undefined;
|
|
19
19
|
/** Optional custom number formatter */
|
|
20
|
-
formatter?: (val: number) => string;
|
|
20
|
+
formatter?: ((val: number) => string) | undefined;
|
|
21
21
|
/** Optional extra description or action */
|
|
22
|
-
description?: string;
|
|
22
|
+
description?: string | undefined;
|
|
23
23
|
/** Compact inline single-line display */
|
|
24
|
-
compact?: boolean;
|
|
24
|
+
compact?: boolean | undefined;
|
|
25
25
|
/** Additional CSS classes */
|
|
26
|
-
class?: string;
|
|
26
|
+
class?: string | undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
let {
|
|
@@ -6,21 +6,21 @@ export interface QuotaProgressBarProps {
|
|
|
6
6
|
/** Total allocated quota limit */
|
|
7
7
|
total: number;
|
|
8
8
|
/** Metric unit suffix (e.g. 'GB', 'calls', 'seats') */
|
|
9
|
-
unit?: string;
|
|
9
|
+
unit?: string | undefined;
|
|
10
10
|
/** Ratio for warning state (0-1). Defaults to 0.8 (80%) */
|
|
11
|
-
warningThreshold?: number;
|
|
11
|
+
warningThreshold?: number | undefined;
|
|
12
12
|
/** Ratio for critical state (0-1). Defaults to 0.95 (95%) */
|
|
13
|
-
criticalThreshold?: number;
|
|
13
|
+
criticalThreshold?: number | undefined;
|
|
14
14
|
/** Whether to display the percentage badge. Defaults to true */
|
|
15
|
-
showPercent?: boolean;
|
|
15
|
+
showPercent?: boolean | undefined;
|
|
16
16
|
/** Optional custom number formatter */
|
|
17
|
-
formatter?: (val: number) => string;
|
|
17
|
+
formatter?: ((val: number) => string) | undefined;
|
|
18
18
|
/** Optional extra description or action */
|
|
19
|
-
description?: string;
|
|
19
|
+
description?: string | undefined;
|
|
20
20
|
/** Compact inline single-line display */
|
|
21
|
-
compact?: boolean;
|
|
21
|
+
compact?: boolean | undefined;
|
|
22
22
|
/** Additional CSS classes */
|
|
23
|
-
class?: string;
|
|
23
|
+
class?: string | undefined;
|
|
24
24
|
}
|
|
25
25
|
declare const QuotaProgressBar: import("svelte").Component<QuotaProgressBarProps, {}, "">;
|
|
26
26
|
type QuotaProgressBar = ReturnType<typeof QuotaProgressBar>;
|
|
@@ -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;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Search, ChevronRight, ChevronDown, X, ArrowRight } from '@lucide/svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
import { useTranslation } from '@svadmin/core';
|
|
5
|
+
|
|
6
|
+
export interface TreeTransferNode {
|
|
7
|
+
key: string;
|
|
8
|
+
title: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
children?: TreeTransferNode[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface TreeTransferProps {
|
|
14
|
+
/** Hierarchical tree data source */
|
|
15
|
+
dataSource: TreeTransferNode[];
|
|
16
|
+
/** Keys of selected items in the right transfer panel */
|
|
17
|
+
targetKeys?: string[];
|
|
18
|
+
/** Titles of left and right panels */
|
|
19
|
+
titles?: [string, string];
|
|
20
|
+
/** Whether search inputs are shown */
|
|
21
|
+
searchable?: boolean;
|
|
22
|
+
/** Whether the entire transfer component is disabled */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Additional CSS classes */
|
|
25
|
+
class?: string;
|
|
26
|
+
/** Callback when target keys change */
|
|
27
|
+
onchange?: (nextTargetKeys: string[]) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
dataSource = [],
|
|
32
|
+
targetKeys = $bindable([]),
|
|
33
|
+
titles,
|
|
34
|
+
searchable = true,
|
|
35
|
+
disabled = false,
|
|
36
|
+
class: className = '',
|
|
37
|
+
onchange,
|
|
38
|
+
}: TreeTransferProps = $props();
|
|
39
|
+
|
|
40
|
+
const i18n = useTranslation();
|
|
41
|
+
const defaultTitles = $derived<[string, string]>([
|
|
42
|
+
titles?.[0] ?? i18n.t('org.source'),
|
|
43
|
+
titles?.[1] ?? i18n.t('org.target'),
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
let leftSearch = $state('');
|
|
47
|
+
let rightSearch = $state('');
|
|
48
|
+
let expandedKeys = $state<Record<string, boolean>>({});
|
|
49
|
+
|
|
50
|
+
function toggleExpand(key: string, e?: MouseEvent) {
|
|
51
|
+
e?.stopPropagation();
|
|
52
|
+
expandedKeys[key] = !expandedKeys[key];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getAllLeaves(nodes: TreeTransferNode[]): TreeTransferNode[] {
|
|
56
|
+
const leaves: TreeTransferNode[] = [];
|
|
57
|
+
function traverse(list: TreeTransferNode[]) {
|
|
58
|
+
for (const node of list) {
|
|
59
|
+
if (!node.children || node.children.length === 0) {
|
|
60
|
+
leaves.push(node);
|
|
61
|
+
} else {
|
|
62
|
+
traverse(node.children);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
traverse(nodes);
|
|
67
|
+
return leaves;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const allLeaves = $derived(getAllLeaves(dataSource));
|
|
71
|
+
const leafMap = $derived(new Map(allLeaves.map((l) => [l.key, l])));
|
|
72
|
+
|
|
73
|
+
function isNodeSelected(node: TreeTransferNode): boolean {
|
|
74
|
+
if (!node.children || node.children.length === 0) {
|
|
75
|
+
return !node.disabled && targetKeys.includes(node.key);
|
|
76
|
+
}
|
|
77
|
+
const nodeLeaves = getAllLeaves([node]).filter((leaf) => !leaf.disabled);
|
|
78
|
+
return nodeLeaves.length > 0 && nodeLeaves.every((l) => targetKeys.includes(l.key));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function isNodeIndeterminate(node: TreeTransferNode): boolean {
|
|
82
|
+
if (!node.children || node.children.length === 0) return false;
|
|
83
|
+
const nodeLeaves = getAllLeaves([node]).filter((leaf) => !leaf.disabled);
|
|
84
|
+
const selectedCount = nodeLeaves.filter((l) => targetKeys.includes(l.key)).length;
|
|
85
|
+
return selectedCount > 0 && selectedCount < nodeLeaves.length;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function toggleSelect(node: TreeTransferNode) {
|
|
89
|
+
if (disabled || node.disabled) return;
|
|
90
|
+
const nodeLeaves = getAllLeaves([node]).filter((leaf) => !leaf.disabled);
|
|
91
|
+
const leafKeys = nodeLeaves.map((l) => l.key);
|
|
92
|
+
const allSelected = isNodeSelected(node);
|
|
93
|
+
|
|
94
|
+
let next: string[];
|
|
95
|
+
if (allSelected) {
|
|
96
|
+
next = targetKeys.filter((k) => !leafKeys.includes(k));
|
|
97
|
+
} else {
|
|
98
|
+
next = Array.from(new Set([...targetKeys, ...leafKeys]));
|
|
99
|
+
}
|
|
100
|
+
targetKeys = next;
|
|
101
|
+
onchange?.(next);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function removeItem(key: string) {
|
|
105
|
+
if (disabled) return;
|
|
106
|
+
const next = targetKeys.filter((k) => k !== key);
|
|
107
|
+
targetKeys = next;
|
|
108
|
+
onchange?.(next);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function clearAll() {
|
|
112
|
+
if (disabled) return;
|
|
113
|
+
targetKeys = [];
|
|
114
|
+
onchange?.([]);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const selectedItems = $derived(
|
|
118
|
+
targetKeys
|
|
119
|
+
.map((k) => leafMap.get(k))
|
|
120
|
+
.filter((item): item is TreeTransferNode => item !== undefined)
|
|
121
|
+
.filter((item) => (rightSearch.trim() ? item.title.toLowerCase().includes(rightSearch.toLowerCase()) : true)),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
$effect(() => {
|
|
125
|
+
const validKeys = targetKeys.filter((key) => leafMap.has(key));
|
|
126
|
+
if (validKeys.length !== targetKeys.length) targetKeys = validKeys;
|
|
127
|
+
});
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<div
|
|
131
|
+
data-svadmin-component="TreeTransfer"
|
|
132
|
+
class={cn(
|
|
133
|
+
'flex flex-col sm:flex-row items-stretch gap-4 p-4 rounded-xl border border-border bg-card text-card-foreground',
|
|
134
|
+
disabled && 'opacity-60 pointer-events-none',
|
|
135
|
+
className,
|
|
136
|
+
)}
|
|
137
|
+
>
|
|
138
|
+
<!-- 左侧树状面板 -->
|
|
139
|
+
<div class="flex-1 flex flex-col rounded-lg border border-border bg-background overflow-hidden min-h-0">
|
|
140
|
+
<div class="flex items-center justify-between border-b border-border bg-muted/40 px-3 py-2 text-xs font-semibold text-muted-foreground">
|
|
141
|
+
<span>{defaultTitles[0]}</span>
|
|
142
|
+
<span>{allLeaves.length} 项</span>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
{#if searchable}
|
|
146
|
+
<div class="p-2 border-b border-border/50 bg-muted/20">
|
|
147
|
+
<div class="relative flex items-center">
|
|
148
|
+
<Search size={14} class="absolute left-2.5 text-muted-foreground pointer-events-none" />
|
|
149
|
+
<input
|
|
150
|
+
type="text"
|
|
151
|
+
bind:value={leftSearch}
|
|
152
|
+
placeholder={i18n.t('org.search')}
|
|
153
|
+
class="h-8 w-full rounded-md border border-input bg-background pl-8 pr-2.5 text-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
|
154
|
+
/>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
{/if}
|
|
158
|
+
|
|
159
|
+
<div class="flex-1 overflow-y-auto p-2 space-y-1">
|
|
160
|
+
{#snippet renderTreeNode(node: TreeTransferNode, level = 0)}
|
|
161
|
+
{@const hasChildren = node.children && node.children.length > 0}
|
|
162
|
+
{@const expanded = expandedKeys[node.key] ?? true}
|
|
163
|
+
{@const selected = isNodeSelected(node)}
|
|
164
|
+
{@const indeterminate = isNodeIndeterminate(node)}
|
|
165
|
+
{@const matchesSearch = !leftSearch.trim() || node.title.toLowerCase().includes(leftSearch.toLowerCase())}
|
|
166
|
+
|
|
167
|
+
{#if matchesSearch || hasChildren}
|
|
168
|
+
<div class="select-none">
|
|
169
|
+
<div
|
|
170
|
+
class={cn(
|
|
171
|
+
'flex items-center gap-1.5 rounded-md px-2 py-1 text-xs hover:bg-muted/60 cursor-pointer transition-colors',
|
|
172
|
+
selected && 'bg-primary/10 text-primary font-medium',
|
|
173
|
+
)}
|
|
174
|
+
style={`padding-left: ${level * 16 + 8}px`}
|
|
175
|
+
onclick={() => toggleSelect(node)}
|
|
176
|
+
role="checkbox"
|
|
177
|
+
aria-checked={indeterminate ? 'mixed' : selected}
|
|
178
|
+
tabindex="0"
|
|
179
|
+
onkeydown={(e) => e.key === 'Enter' && toggleSelect(node)}
|
|
180
|
+
>
|
|
181
|
+
{#if hasChildren}
|
|
182
|
+
<button
|
|
183
|
+
type="button"
|
|
184
|
+
class="p-0.5 rounded text-muted-foreground hover:text-foreground"
|
|
185
|
+
onclick={(e) => toggleExpand(node.key, e)}
|
|
186
|
+
aria-label="Toggle node"
|
|
187
|
+
>
|
|
188
|
+
{#if expanded}
|
|
189
|
+
<ChevronDown size={14} />
|
|
190
|
+
{:else}
|
|
191
|
+
<ChevronRight size={14} />
|
|
192
|
+
{/if}
|
|
193
|
+
</button>
|
|
194
|
+
{:else}
|
|
195
|
+
<span class="w-4.5 inline-block"></span>
|
|
196
|
+
{/if}
|
|
197
|
+
|
|
198
|
+
<input
|
|
199
|
+
type="checkbox"
|
|
200
|
+
checked={selected}
|
|
201
|
+
indeterminate={indeterminate}
|
|
202
|
+
disabled={node.disabled}
|
|
203
|
+
class="rounded border-input text-primary focus:ring-ring h-3.5 w-3.5 pointer-events-none"
|
|
204
|
+
/>
|
|
205
|
+
<span class="truncate">{node.title}</span>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
{#if hasChildren && expanded && node.children}
|
|
209
|
+
<div class="mt-0.5">
|
|
210
|
+
{#each node.children as child (child.key)}
|
|
211
|
+
{@render renderTreeNode(child, level + 1)}
|
|
212
|
+
{/each}
|
|
213
|
+
</div>
|
|
214
|
+
{/if}
|
|
215
|
+
</div>
|
|
216
|
+
{/if}
|
|
217
|
+
{/snippet}
|
|
218
|
+
|
|
219
|
+
{#each dataSource as rootNode (rootNode.key)}
|
|
220
|
+
{@render renderTreeNode(rootNode)}
|
|
221
|
+
{/each}
|
|
222
|
+
|
|
223
|
+
{#if dataSource.length === 0}
|
|
224
|
+
<div class="py-8 text-center text-xs text-muted-foreground">{i18n.t('org.empty')}</div>
|
|
225
|
+
{/if}
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<!-- 中间穿梭指示器 -->
|
|
230
|
+
<div class="flex sm:flex-col items-center justify-center gap-2 text-muted-foreground self-center">
|
|
231
|
+
<div class="flex h-8 w-8 items-center justify-center rounded-full bg-muted border border-border shadow-2xs">
|
|
232
|
+
<ArrowRight size={14} class="rotate-90 sm:rotate-0" />
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<!-- 右侧已选列表面板 -->
|
|
237
|
+
<div class="flex-1 flex flex-col rounded-lg border border-border bg-background overflow-hidden min-h-0">
|
|
238
|
+
<div class="flex items-center justify-between border-b border-border bg-muted/40 px-3 py-2 text-xs font-semibold text-muted-foreground">
|
|
239
|
+
<span>{defaultTitles[1]}</span>
|
|
240
|
+
<div class="flex items-center gap-2">
|
|
241
|
+
<span>已选 {selectedItems.length} 项</span>
|
|
242
|
+
{#if targetKeys.length > 0}
|
|
243
|
+
<button
|
|
244
|
+
type="button"
|
|
245
|
+
class="text-destructive hover:underline text-[11px] font-normal"
|
|
246
|
+
onclick={clearAll}
|
|
247
|
+
>
|
|
248
|
+
{i18n.t('org.clearAll')}
|
|
249
|
+
</button>
|
|
250
|
+
{/if}
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
{#if searchable}
|
|
255
|
+
<div class="p-2 border-b border-border/50 bg-muted/20">
|
|
256
|
+
<div class="relative flex items-center">
|
|
257
|
+
<Search size={14} class="absolute left-2.5 text-muted-foreground pointer-events-none" />
|
|
258
|
+
<input
|
|
259
|
+
type="text"
|
|
260
|
+
bind:value={rightSearch}
|
|
261
|
+
placeholder={i18n.t('org.search')}
|
|
262
|
+
class="h-8 w-full rounded-md border border-input bg-background pl-8 pr-2.5 text-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
|
|
263
|
+
/>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
{/if}
|
|
267
|
+
|
|
268
|
+
<div class="flex-1 overflow-y-auto p-2 space-y-1">
|
|
269
|
+
{#each selectedItems as item (item.key)}
|
|
270
|
+
<div class="flex items-center justify-between rounded-md px-2.5 py-1.5 text-xs bg-muted/30 hover:bg-muted/60 transition-colors group">
|
|
271
|
+
<span class="truncate font-medium text-foreground">{item.title}</span>
|
|
272
|
+
<button
|
|
273
|
+
type="button"
|
|
274
|
+
class="text-muted-foreground hover:text-destructive p-0.5 rounded transition-colors"
|
|
275
|
+
onclick={() => removeItem(item.key)}
|
|
276
|
+
aria-label={`Remove ${item.title}`}
|
|
277
|
+
>
|
|
278
|
+
<X size={13} />
|
|
279
|
+
</button>
|
|
280
|
+
</div>
|
|
281
|
+
{/each}
|
|
282
|
+
|
|
283
|
+
{#if targetKeys.length === 0}
|
|
284
|
+
<div class="py-12 text-center text-xs text-muted-foreground">{i18n.t('org.empty')}</div>
|
|
285
|
+
{/if}
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|