@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,25 @@
|
|
|
1
|
+
export interface TreeTransferNode {
|
|
2
|
+
key: string;
|
|
3
|
+
title: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
children?: TreeTransferNode[];
|
|
6
|
+
}
|
|
7
|
+
export interface TreeTransferProps {
|
|
8
|
+
/** Hierarchical tree data source */
|
|
9
|
+
dataSource: TreeTransferNode[];
|
|
10
|
+
/** Keys of selected items in the right transfer panel */
|
|
11
|
+
targetKeys?: string[];
|
|
12
|
+
/** Titles of left and right panels */
|
|
13
|
+
titles?: [string, string];
|
|
14
|
+
/** Whether search inputs are shown */
|
|
15
|
+
searchable?: boolean;
|
|
16
|
+
/** Whether the entire transfer component is disabled */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Additional CSS classes */
|
|
19
|
+
class?: string;
|
|
20
|
+
/** Callback when target keys change */
|
|
21
|
+
onchange?: (nextTargetKeys: string[]) => void;
|
|
22
|
+
}
|
|
23
|
+
declare const TreeTransfer: import("svelte").Component<TreeTransferProps, {}, "targetKeys">;
|
|
24
|
+
type TreeTransfer = ReturnType<typeof TreeTransfer>;
|
|
25
|
+
export default TreeTransfer;
|
|
@@ -8,16 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
/** 折叠时保留的行数,对齐参考排版的 ellipsis.rows。 */
|
|
11
|
-
rows?: number;
|
|
11
|
+
rows?: number | undefined;
|
|
12
12
|
/** 内容超出时显示“展开 / 收起”,对齐参考排版的 ellipsis.expandable。 */
|
|
13
|
-
expandable?: boolean;
|
|
14
|
-
expanded?: boolean;
|
|
15
|
-
expandText?: string;
|
|
16
|
-
collapseText?: string;
|
|
13
|
+
expandable?: boolean | undefined;
|
|
14
|
+
expanded?: boolean | undefined;
|
|
15
|
+
expandText?: string | undefined;
|
|
16
|
+
collapseText?: string | undefined;
|
|
17
|
+
tooltip?: string | undefined;
|
|
17
18
|
/** 展开按钮的附加说明,例如“展开全部 12 条”。 */
|
|
18
|
-
expandLabel?: string;
|
|
19
|
-
class?: string;
|
|
20
|
-
onExpand?: (expanded: boolean) => void;
|
|
19
|
+
expandLabel?: string | undefined;
|
|
20
|
+
class?: string | undefined;
|
|
21
|
+
onExpand?: ((expanded: boolean) => void) | undefined;
|
|
21
22
|
children: Snippet;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
expanded = $bindable(false),
|
|
28
29
|
expandText,
|
|
29
30
|
collapseText,
|
|
31
|
+
tooltip,
|
|
30
32
|
expandLabel,
|
|
31
33
|
class: className = '',
|
|
32
34
|
onExpand,
|
|
@@ -73,6 +75,7 @@
|
|
|
73
75
|
bind:this={contentEl}
|
|
74
76
|
class="svadmin-typography-ellipsis__content"
|
|
75
77
|
class:is-clamped={!expanded}
|
|
78
|
+
title={tooltip}
|
|
76
79
|
>
|
|
77
80
|
{@render children()}
|
|
78
81
|
</div>
|
|
@@ -120,4 +123,4 @@
|
|
|
120
123
|
outline-offset: var(--svadmin-focus-offset);
|
|
121
124
|
border-radius: var(--radius-sm);
|
|
122
125
|
}
|
|
123
|
-
</style>
|
|
126
|
+
</style>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
interface Props {
|
|
3
3
|
/** 折叠时保留的行数,对齐参考排版的 ellipsis.rows。 */
|
|
4
|
-
rows?: number;
|
|
4
|
+
rows?: number | undefined;
|
|
5
5
|
/** 内容超出时显示“展开 / 收起”,对齐参考排版的 ellipsis.expandable。 */
|
|
6
|
-
expandable?: boolean;
|
|
7
|
-
expanded?: boolean;
|
|
8
|
-
expandText?: string;
|
|
9
|
-
collapseText?: string;
|
|
6
|
+
expandable?: boolean | undefined;
|
|
7
|
+
expanded?: boolean | undefined;
|
|
8
|
+
expandText?: string | undefined;
|
|
9
|
+
collapseText?: string | undefined;
|
|
10
|
+
tooltip?: string | undefined;
|
|
10
11
|
/** 展开按钮的附加说明,例如“展开全部 12 条”。 */
|
|
11
|
-
expandLabel?: string;
|
|
12
|
-
class?: string;
|
|
13
|
-
onExpand?: (expanded: boolean) => void;
|
|
12
|
+
expandLabel?: string | undefined;
|
|
13
|
+
class?: string | undefined;
|
|
14
|
+
onExpand?: ((expanded: boolean) => void) | undefined;
|
|
14
15
|
children: Snippet;
|
|
15
16
|
}
|
|
16
17
|
declare const TypographyEllipsis: import("svelte").Component<Props, {}, "expanded">;
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
import { tick, type Snippet } from 'svelte';
|
|
3
3
|
import { Check, Pencil, X } from '@lucide/svelte';
|
|
4
4
|
import CopyButton from './CopyButton.svelte';
|
|
5
|
+
import TypographyEllipsis from './TypographyEllipsis.svelte';
|
|
5
6
|
import { cn } from '../utils.js';
|
|
6
7
|
|
|
7
8
|
export type TypographyType = 'default' | 'secondary' | 'success' | 'warning' | 'danger';
|
|
8
9
|
|
|
9
|
-
interface
|
|
10
|
+
export interface TypographyEllipsisConfig {
|
|
11
|
+
rows?: number;
|
|
12
|
+
expandable?: boolean;
|
|
13
|
+
expandText?: string;
|
|
14
|
+
collapseText?: string;
|
|
15
|
+
tooltip?: boolean | string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface TypographyTextProps {
|
|
10
19
|
text?: string;
|
|
11
20
|
type?: TypographyType;
|
|
12
21
|
strong?: boolean;
|
|
@@ -18,6 +27,7 @@
|
|
|
18
27
|
copyable?: boolean;
|
|
19
28
|
copyLabel?: string;
|
|
20
29
|
copyDescription?: string;
|
|
30
|
+
ellipsis?: boolean | TypographyEllipsisConfig;
|
|
21
31
|
editable?: boolean;
|
|
22
32
|
editing?: boolean;
|
|
23
33
|
multiline?: boolean;
|
|
@@ -42,6 +52,7 @@
|
|
|
42
52
|
copyable = false,
|
|
43
53
|
copyLabel,
|
|
44
54
|
copyDescription,
|
|
55
|
+
ellipsis = false,
|
|
45
56
|
editable = false,
|
|
46
57
|
editing = $bindable(false),
|
|
47
58
|
multiline = false,
|
|
@@ -52,7 +63,18 @@
|
|
|
52
63
|
children,
|
|
53
64
|
onchange,
|
|
54
65
|
oncopied,
|
|
55
|
-
}:
|
|
66
|
+
}: TypographyTextProps = $props();
|
|
67
|
+
|
|
68
|
+
const isSingleEllipsis = $derived(ellipsis === true || (typeof ellipsis === 'object' && (!ellipsis.rows || ellipsis.rows === 1)));
|
|
69
|
+
const multiEllipsis = $derived(typeof ellipsis === 'object' && typeof ellipsis.rows === 'number' && ellipsis.rows > 1 ? ellipsis : null);
|
|
70
|
+
const ellipsisTooltip = $derived.by(() => {
|
|
71
|
+
if (!ellipsis) return undefined;
|
|
72
|
+
if (typeof ellipsis === 'object' && ellipsis.tooltip) {
|
|
73
|
+
return typeof ellipsis.tooltip === 'string' ? ellipsis.tooltip : text;
|
|
74
|
+
}
|
|
75
|
+
if (ellipsis === true) return text || undefined;
|
|
76
|
+
return undefined;
|
|
77
|
+
});
|
|
56
78
|
|
|
57
79
|
let draft = $state(text);
|
|
58
80
|
let input = $state<HTMLInputElement | HTMLTextAreaElement | null>(null);
|
|
@@ -117,7 +139,23 @@
|
|
|
117
139
|
</button>
|
|
118
140
|
</span>
|
|
119
141
|
{:else}
|
|
120
|
-
|
|
142
|
+
{#if multiEllipsis}
|
|
143
|
+
<TypographyEllipsis
|
|
144
|
+
rows={multiEllipsis.rows ?? 1}
|
|
145
|
+
expandable={multiEllipsis.expandable ?? false}
|
|
146
|
+
expandText={multiEllipsis.expandText}
|
|
147
|
+
collapseText={multiEllipsis.collapseText}
|
|
148
|
+
tooltip={ellipsisTooltip}
|
|
149
|
+
>
|
|
150
|
+
{#if children}{@render children()}{:else}{text}{/if}
|
|
151
|
+
</TypographyEllipsis>
|
|
152
|
+
{:else}
|
|
153
|
+
<span
|
|
154
|
+
class="svadmin-typography-text__content"
|
|
155
|
+
class:truncate={isSingleEllipsis && ellipsis !== false}
|
|
156
|
+
title={ellipsisTooltip}
|
|
157
|
+
>{#if children}{@render children()}{:else}{text}{/if}</span>
|
|
158
|
+
{/if}
|
|
121
159
|
{#if copyable}
|
|
122
160
|
<CopyButton value={text} description={copyDescription} label={copyLabel} oncopy={oncopied} class="svadmin-typography-text__action" />
|
|
123
161
|
{/if}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
2
|
export type TypographyType = 'default' | 'secondary' | 'success' | 'warning' | 'danger';
|
|
3
|
-
interface
|
|
3
|
+
export interface TypographyEllipsisConfig {
|
|
4
|
+
rows?: number;
|
|
5
|
+
expandable?: boolean;
|
|
6
|
+
expandText?: string;
|
|
7
|
+
collapseText?: string;
|
|
8
|
+
tooltip?: boolean | string;
|
|
9
|
+
}
|
|
10
|
+
export interface TypographyTextProps {
|
|
4
11
|
text?: string;
|
|
5
12
|
type?: TypographyType;
|
|
6
13
|
strong?: boolean;
|
|
@@ -12,6 +19,7 @@ interface Props {
|
|
|
12
19
|
copyable?: boolean;
|
|
13
20
|
copyLabel?: string;
|
|
14
21
|
copyDescription?: string;
|
|
22
|
+
ellipsis?: boolean | TypographyEllipsisConfig;
|
|
15
23
|
editable?: boolean;
|
|
16
24
|
editing?: boolean;
|
|
17
25
|
multiline?: boolean;
|
|
@@ -23,6 +31,6 @@ interface Props {
|
|
|
23
31
|
onchange?: (text: string) => void;
|
|
24
32
|
oncopied?: (text: string) => void;
|
|
25
33
|
}
|
|
26
|
-
declare const TypographyText: import("svelte").Component<
|
|
34
|
+
declare const TypographyText: import("svelte").Component<TypographyTextProps, {}, "text" | "editing">;
|
|
27
35
|
type TypographyText = ReturnType<typeof TypographyText>;
|
|
28
36
|
export default TypographyText;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
import QuotaProgressBar, { type QuotaProgressBarProps } from './QuotaProgressBar.svelte';
|
|
5
|
+
import IconBilling from './icons/IconBilling.svelte';
|
|
6
|
+
|
|
7
|
+
export interface UsageMetric extends Omit<QuotaProgressBarProps, 'class'> {
|
|
8
|
+
key: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface UsageCardProps {
|
|
12
|
+
/** Card title, e.g. 'Plan & Usage' */
|
|
13
|
+
title?: string;
|
|
14
|
+
/** Current plan tier name, e.g. 'Pro Plan' */
|
|
15
|
+
tier?: string;
|
|
16
|
+
/** Next billing or renewal date string */
|
|
17
|
+
renewalDate?: string;
|
|
18
|
+
/** Metrics to track */
|
|
19
|
+
metrics?: UsageMetric[];
|
|
20
|
+
/** Upgrade button text */
|
|
21
|
+
upgradeText?: string;
|
|
22
|
+
/** Callback on upgrade button click */
|
|
23
|
+
onupgrade?: () => void;
|
|
24
|
+
/** Custom extra action in header */
|
|
25
|
+
extra?: Snippet;
|
|
26
|
+
/** Additional CSS classes */
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
title = 'Plan Usage & Quotas',
|
|
32
|
+
tier = 'Pro Plan',
|
|
33
|
+
renewalDate,
|
|
34
|
+
metrics = [],
|
|
35
|
+
upgradeText = 'Upgrade Plan',
|
|
36
|
+
onupgrade,
|
|
37
|
+
extra,
|
|
38
|
+
class: className = '',
|
|
39
|
+
}: UsageCardProps = $props();
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<div
|
|
43
|
+
class={cn('rounded-xl border border-border bg-card p-6 text-card-foreground shadow-sm', className)}
|
|
44
|
+
data-svadmin-component="UsageCard"
|
|
45
|
+
>
|
|
46
|
+
<div class="flex items-start justify-between gap-4 border-b border-border/60 pb-5">
|
|
47
|
+
<div class="flex items-center gap-3">
|
|
48
|
+
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary">
|
|
49
|
+
<IconBilling class="h-5 w-5" />
|
|
50
|
+
</div>
|
|
51
|
+
<div>
|
|
52
|
+
<div class="flex items-center gap-2">
|
|
53
|
+
<h3 class="text-base font-bold tracking-tight text-foreground">{title}</h3>
|
|
54
|
+
{#if tier}
|
|
55
|
+
<span class="rounded-full bg-primary/10 px-2.5 py-0.5 text-xs font-semibold text-primary">
|
|
56
|
+
{tier}
|
|
57
|
+
</span>
|
|
58
|
+
{/if}
|
|
59
|
+
</div>
|
|
60
|
+
{#if renewalDate}
|
|
61
|
+
<p class="mt-0.5 text-xs text-muted-foreground">Renews on {renewalDate}</p>
|
|
62
|
+
{/if}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div class="flex items-center gap-2">
|
|
67
|
+
{#if extra}
|
|
68
|
+
{@render extra()}
|
|
69
|
+
{:else if onupgrade}
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
onclick={() => onupgrade()}
|
|
73
|
+
class="rounded-md bg-primary px-3.5 py-1.5 text-xs font-semibold text-primary-foreground transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
74
|
+
>
|
|
75
|
+
{upgradeText}
|
|
76
|
+
</button>
|
|
77
|
+
{/if}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
{#if metrics.length > 0}
|
|
82
|
+
<div class="mt-5 space-y-4">
|
|
83
|
+
{#each metrics as metric (metric.key)}
|
|
84
|
+
<QuotaProgressBar
|
|
85
|
+
label={metric.label}
|
|
86
|
+
used={metric.used}
|
|
87
|
+
total={metric.total}
|
|
88
|
+
unit={metric.unit}
|
|
89
|
+
warningThreshold={metric.warningThreshold}
|
|
90
|
+
criticalThreshold={metric.criticalThreshold}
|
|
91
|
+
showPercent={metric.showPercent}
|
|
92
|
+
compact={metric.compact ?? false}
|
|
93
|
+
/>
|
|
94
|
+
{/each}
|
|
95
|
+
</div>
|
|
96
|
+
{/if}
|
|
97
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type QuotaProgressBarProps } from './QuotaProgressBar.svelte';
|
|
3
|
+
export interface UsageMetric extends Omit<QuotaProgressBarProps, 'class'> {
|
|
4
|
+
key: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UsageCardProps {
|
|
7
|
+
/** Card title, e.g. 'Plan & Usage' */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Current plan tier name, e.g. 'Pro Plan' */
|
|
10
|
+
tier?: string;
|
|
11
|
+
/** Next billing or renewal date string */
|
|
12
|
+
renewalDate?: string;
|
|
13
|
+
/** Metrics to track */
|
|
14
|
+
metrics?: UsageMetric[];
|
|
15
|
+
/** Upgrade button text */
|
|
16
|
+
upgradeText?: string;
|
|
17
|
+
/** Callback on upgrade button click */
|
|
18
|
+
onupgrade?: () => void;
|
|
19
|
+
/** Custom extra action in header */
|
|
20
|
+
extra?: Snippet;
|
|
21
|
+
/** Additional CSS classes */
|
|
22
|
+
class?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const UsageCard: import("svelte").Component<UsageCardProps, {}, "">;
|
|
25
|
+
type UsageCard = ReturnType<typeof UsageCard>;
|
|
26
|
+
export default UsageCard;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
import ApprovalTimeline, { type ApprovalStep, type ApprovalStatus } from './ApprovalTimeline.svelte';
|
|
5
|
+
import IconWorkflow from './icons/IconWorkflow.svelte';
|
|
6
|
+
|
|
7
|
+
export interface WorkflowProcessCardProps {
|
|
8
|
+
/** Workflow title, e.g. 'Contract Approval Flow' */
|
|
9
|
+
title: string;
|
|
10
|
+
/** Process instance ID or ticket code */
|
|
11
|
+
ticketNo?: string;
|
|
12
|
+
/** Initiator name */
|
|
13
|
+
initiator?: string;
|
|
14
|
+
/** Current process overall state */
|
|
15
|
+
status?: ApprovalStatus | 'draft';
|
|
16
|
+
/** Steps list */
|
|
17
|
+
steps?: ApprovalStep[];
|
|
18
|
+
/** Actions slot in footer or header */
|
|
19
|
+
extra?: Snippet;
|
|
20
|
+
/** Additional CSS classes */
|
|
21
|
+
class?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
title,
|
|
26
|
+
ticketNo,
|
|
27
|
+
initiator,
|
|
28
|
+
status = 'running',
|
|
29
|
+
steps = [],
|
|
30
|
+
extra,
|
|
31
|
+
class: className = '',
|
|
32
|
+
}: WorkflowProcessCardProps = $props();
|
|
33
|
+
|
|
34
|
+
const statusBadge = $derived.by(() => {
|
|
35
|
+
switch (status) {
|
|
36
|
+
case 'approved':
|
|
37
|
+
return { text: 'Approved', class: 'bg-success/10 text-success border-success/20' };
|
|
38
|
+
case 'rejected':
|
|
39
|
+
return { text: 'Rejected', class: 'bg-destructive/10 text-destructive border-destructive/20' };
|
|
40
|
+
case 'running':
|
|
41
|
+
return { text: 'In Progress', class: 'bg-primary/10 text-primary border-primary/20' };
|
|
42
|
+
case 'draft':
|
|
43
|
+
default:
|
|
44
|
+
return { text: 'Pending', class: 'bg-muted text-muted-foreground border-border' };
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<div
|
|
50
|
+
data-svadmin-component="WorkflowProcessCard"
|
|
51
|
+
class={cn(
|
|
52
|
+
'rounded-xl border border-border bg-card p-6 text-card-foreground shadow-sm transition-all space-y-6',
|
|
53
|
+
className,
|
|
54
|
+
)}
|
|
55
|
+
>
|
|
56
|
+
<!-- Card Header -->
|
|
57
|
+
<div class="flex flex-wrap items-start justify-between gap-4 border-b border-border/60 pb-4">
|
|
58
|
+
<div class="flex items-center gap-3">
|
|
59
|
+
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary">
|
|
60
|
+
<IconWorkflow class="h-5 w-5" />
|
|
61
|
+
</div>
|
|
62
|
+
<div>
|
|
63
|
+
<div class="flex items-center gap-2.5">
|
|
64
|
+
<h3 class="text-base font-bold tracking-tight text-foreground">{title}</h3>
|
|
65
|
+
<span class={cn('inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold', statusBadge.class)}>
|
|
66
|
+
{statusBadge.text}
|
|
67
|
+
</span>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="mt-1 flex items-center gap-3 text-xs text-muted-foreground">
|
|
70
|
+
{#if ticketNo}
|
|
71
|
+
<span class="font-mono">Ticket: #{ticketNo}</span>
|
|
72
|
+
{/if}
|
|
73
|
+
{#if initiator}
|
|
74
|
+
<span>Initiator: {initiator}</span>
|
|
75
|
+
{/if}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
{#if extra}
|
|
81
|
+
<div class="flex items-center gap-2">
|
|
82
|
+
{@render extra()}
|
|
83
|
+
</div>
|
|
84
|
+
{/if}
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<!-- Steps Timeline Content -->
|
|
88
|
+
{#if steps.length > 0}
|
|
89
|
+
<div class="pt-2 px-1">
|
|
90
|
+
<ApprovalTimeline {steps} />
|
|
91
|
+
</div>
|
|
92
|
+
{/if}
|
|
93
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type ApprovalStep, type ApprovalStatus } from './ApprovalTimeline.svelte';
|
|
3
|
+
export interface WorkflowProcessCardProps {
|
|
4
|
+
/** Workflow title, e.g. 'Contract Approval Flow' */
|
|
5
|
+
title: string;
|
|
6
|
+
/** Process instance ID or ticket code */
|
|
7
|
+
ticketNo?: string;
|
|
8
|
+
/** Initiator name */
|
|
9
|
+
initiator?: string;
|
|
10
|
+
/** Current process overall state */
|
|
11
|
+
status?: ApprovalStatus | 'draft';
|
|
12
|
+
/** Steps list */
|
|
13
|
+
steps?: ApprovalStep[];
|
|
14
|
+
/** Actions slot in footer or header */
|
|
15
|
+
extra?: Snippet;
|
|
16
|
+
/** Additional CSS classes */
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const WorkflowProcessCard: import("svelte").Component<WorkflowProcessCardProps, {}, "">;
|
|
20
|
+
type WorkflowProcessCard = ReturnType<typeof WorkflowProcessCard>;
|
|
21
|
+
export default WorkflowProcessCard;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { badgeVariants as resolveBadgeVariants, type BadgeVariant as BadgeVariantValue } from "./badge-variants.js";
|
|
3
3
|
|
|
4
4
|
export { badgeVariants, type BadgeVariant } from "./badge-variants.js";
|
|
5
|
+
export type BadgeStatus = 'success' | 'processing' | 'default' | 'error' | 'warning';
|
|
5
6
|
</script>
|
|
6
7
|
|
|
7
8
|
<script lang="ts">
|
|
@@ -15,26 +16,169 @@
|
|
|
15
16
|
class: className,
|
|
16
17
|
variant = "default",
|
|
17
18
|
size: sizeProp,
|
|
19
|
+
count,
|
|
20
|
+
overflowCount = 99,
|
|
21
|
+
dot = false,
|
|
22
|
+
status,
|
|
23
|
+
text,
|
|
24
|
+
offset,
|
|
25
|
+
showZero = false,
|
|
26
|
+
color,
|
|
18
27
|
children,
|
|
19
28
|
...restProps
|
|
20
29
|
}: WithElementRef<HTMLAnchorAttributes> & {
|
|
21
30
|
variant?: BadgeVariantValue;
|
|
22
31
|
size?: "default" | "compact";
|
|
32
|
+
count?: number | string | undefined;
|
|
33
|
+
overflowCount?: number | undefined;
|
|
34
|
+
dot?: boolean | undefined;
|
|
35
|
+
status?: BadgeStatus | undefined;
|
|
36
|
+
text?: string | undefined;
|
|
37
|
+
offset?: [number, number] | undefined;
|
|
38
|
+
showZero?: boolean | undefined;
|
|
39
|
+
color?: string | undefined;
|
|
23
40
|
} = $props();
|
|
24
41
|
|
|
25
42
|
const config = useComponentConfig();
|
|
26
43
|
const size = $derived(sizeProp ?? (config.density === "compact" || config.componentSize === "sm" ? "compact" : "default"));
|
|
44
|
+
|
|
45
|
+
const isArcoMode = $derived(count !== undefined || dot || status !== undefined);
|
|
46
|
+
|
|
47
|
+
const displayCount = $derived.by(() => {
|
|
48
|
+
if (count === undefined) return null;
|
|
49
|
+
if (typeof count === 'number') {
|
|
50
|
+
if (count === 0 && !showZero) return null;
|
|
51
|
+
if (count > overflowCount) return `${overflowCount}+`;
|
|
52
|
+
return String(count);
|
|
53
|
+
}
|
|
54
|
+
return count;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const hasBadge = $derived(dot || displayCount !== null);
|
|
58
|
+
|
|
59
|
+
const offsetStyle = $derived.by(() => {
|
|
60
|
+
if (!offset) return '';
|
|
61
|
+
const [x, y] = offset;
|
|
62
|
+
return `transform: translate(calc(50% + ${x}px), calc(-50% + ${y}px));`;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const statusColorClass = $derived.by(() => {
|
|
66
|
+
if (color) return '';
|
|
67
|
+
switch (status) {
|
|
68
|
+
case 'success':
|
|
69
|
+
return 'bg-success';
|
|
70
|
+
case 'processing':
|
|
71
|
+
return 'bg-primary';
|
|
72
|
+
case 'warning':
|
|
73
|
+
return 'bg-warning';
|
|
74
|
+
case 'error':
|
|
75
|
+
return 'bg-destructive';
|
|
76
|
+
case 'default':
|
|
77
|
+
default:
|
|
78
|
+
return 'bg-muted-foreground';
|
|
79
|
+
}
|
|
80
|
+
});
|
|
27
81
|
</script>
|
|
28
82
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
83
|
+
{#if status !== undefined && !children}
|
|
84
|
+
<!-- 独立状态徽标 (Status Badge) -->
|
|
85
|
+
<svelte:element
|
|
86
|
+
this={href ? "a" : "span"}
|
|
87
|
+
bind:this={ref}
|
|
88
|
+
data-svadmin-component="badge"
|
|
89
|
+
data-slot="badge-status"
|
|
90
|
+
data-status={status}
|
|
91
|
+
{href}
|
|
92
|
+
class={cn('inline-flex items-center gap-2 text-sm text-foreground', className)}
|
|
93
|
+
{...restProps}
|
|
94
|
+
>
|
|
95
|
+
<span class="relative flex h-2 w-2">
|
|
96
|
+
{#if status === 'processing'}
|
|
97
|
+
<span class={cn('absolute inline-flex h-full w-full animate-ping rounded-full opacity-75', statusColorClass)} style={color ? `background-color: ${color}` : undefined}></span>
|
|
98
|
+
{/if}
|
|
99
|
+
<span class={cn('relative inline-flex h-2 w-2 rounded-full', statusColorClass)} style={color ? `background-color: ${color}` : undefined}></span>
|
|
100
|
+
</span>
|
|
101
|
+
{#if text}
|
|
102
|
+
<span class="svadmin-badge-status-text select-none text-xs">{text}</span>
|
|
103
|
+
{/if}
|
|
104
|
+
</svelte:element>
|
|
105
|
+
{:else if isArcoMode && children}
|
|
106
|
+
<!-- 包裹宿主元素右上角角标 (Wrapped Badge) -->
|
|
107
|
+
<svelte:element
|
|
108
|
+
this={href ? "a" : "span"}
|
|
109
|
+
bind:this={ref}
|
|
110
|
+
data-svadmin-component="badge"
|
|
111
|
+
data-slot="badge-wrapper"
|
|
112
|
+
{href}
|
|
113
|
+
class={cn('relative inline-flex shrink-0 align-middle', className)}
|
|
114
|
+
{...restProps}
|
|
115
|
+
>
|
|
116
|
+
{@render children()}
|
|
117
|
+
{#if hasBadge}
|
|
118
|
+
{#if dot}
|
|
119
|
+
<span
|
|
120
|
+
data-slot="badge-dot"
|
|
121
|
+
class={cn(
|
|
122
|
+
'absolute top-0 right-0 z-10 h-2 w-2 rounded-full ring-2 ring-background transform translate-x-1/2 -translate-y-1/2',
|
|
123
|
+
status ? statusColorClass : 'bg-destructive',
|
|
124
|
+
)}
|
|
125
|
+
style={`${offsetStyle}${color ? ` background-color: ${color};` : ''}`}
|
|
126
|
+
></span>
|
|
127
|
+
{:else if displayCount !== null}
|
|
128
|
+
<span
|
|
129
|
+
data-slot="badge-count"
|
|
130
|
+
class={cn(
|
|
131
|
+
'absolute top-0 right-0 z-10 flex min-w-4.5 h-4.5 items-center justify-center rounded-full px-1.5 text-[11px] font-semibold leading-none shadow-xs ring-2 ring-background transform translate-x-1/2 -translate-y-1/2 whitespace-nowrap',
|
|
132
|
+
status ? cn(statusColorClass, 'text-primary-foreground') : 'bg-destructive text-destructive-foreground',
|
|
133
|
+
)}
|
|
134
|
+
style={`${offsetStyle}${color ? ` background-color: ${color};` : ''}`}
|
|
135
|
+
>
|
|
136
|
+
{displayCount}
|
|
137
|
+
</span>
|
|
138
|
+
{/if}
|
|
139
|
+
{/if}
|
|
140
|
+
</svelte:element>
|
|
141
|
+
{:else if isArcoMode && !children && hasBadge}
|
|
142
|
+
<!-- 独立数字角标或小红点 (Standalone Badge) -->
|
|
143
|
+
<svelte:element
|
|
144
|
+
this={href ? "a" : "span"}
|
|
145
|
+
bind:this={ref}
|
|
146
|
+
data-svadmin-component="badge"
|
|
147
|
+
data-slot="badge-standalone"
|
|
148
|
+
{href}
|
|
149
|
+
class={cn('inline-flex items-center align-middle', className)}
|
|
150
|
+
{...restProps}
|
|
151
|
+
>
|
|
152
|
+
{#if dot}
|
|
153
|
+
<span
|
|
154
|
+
class={cn('h-2 w-2 rounded-full', status ? statusColorClass : 'bg-destructive')}
|
|
155
|
+
style={color ? `background-color: ${color}` : undefined}
|
|
156
|
+
></span>
|
|
157
|
+
{:else if displayCount !== null}
|
|
158
|
+
<span
|
|
159
|
+
class={cn(
|
|
160
|
+
'flex min-w-4.5 h-4.5 items-center justify-center rounded-full px-1.5 text-[11px] font-semibold leading-none shadow-xs whitespace-nowrap',
|
|
161
|
+
status ? cn(statusColorClass, 'text-primary-foreground') : 'bg-destructive text-destructive-foreground',
|
|
162
|
+
)}
|
|
163
|
+
style={color ? `background-color: ${color}` : undefined}
|
|
164
|
+
>
|
|
165
|
+
{displayCount}
|
|
166
|
+
</span>
|
|
167
|
+
{/if}
|
|
168
|
+
</svelte:element>
|
|
169
|
+
{:else}
|
|
170
|
+
<!-- 原始基础标签 (Pill Variant Badge) -->
|
|
171
|
+
<svelte:element
|
|
172
|
+
this={href ? "a" : "span"}
|
|
173
|
+
bind:this={ref}
|
|
174
|
+
data-svadmin-component="badge"
|
|
175
|
+
data-slot="badge"
|
|
176
|
+
data-variant={variant}
|
|
177
|
+
data-size={size}
|
|
178
|
+
{href}
|
|
179
|
+
class={cn(resolveBadgeVariants({ variant }), className)}
|
|
180
|
+
{...restProps}
|
|
181
|
+
>
|
|
182
|
+
{@render children?.()}
|
|
183
|
+
</svelte:element>
|
|
184
|
+
{/if}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { type BadgeVariant as BadgeVariantValue } from "./badge-variants.js";
|
|
2
2
|
export { badgeVariants, type BadgeVariant } from "./badge-variants.js";
|
|
3
|
+
export type BadgeStatus = 'success' | 'processing' | 'default' | 'error' | 'warning';
|
|
3
4
|
import type { HTMLAnchorAttributes } from "svelte/elements";
|
|
4
5
|
import { type WithElementRef } from "../../../utils.js";
|
|
5
6
|
type $$ComponentProps = WithElementRef<HTMLAnchorAttributes> & {
|
|
6
7
|
variant?: BadgeVariantValue;
|
|
7
8
|
size?: "default" | "compact";
|
|
9
|
+
count?: number | string | undefined;
|
|
10
|
+
overflowCount?: number | undefined;
|
|
11
|
+
dot?: boolean | undefined;
|
|
12
|
+
status?: BadgeStatus | undefined;
|
|
13
|
+
text?: string | undefined;
|
|
14
|
+
offset?: [number, number] | undefined;
|
|
15
|
+
showZero?: boolean | undefined;
|
|
16
|
+
color?: string | undefined;
|
|
8
17
|
};
|
|
9
18
|
declare const Badge: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
10
19
|
type Badge = ReturnType<typeof Badge>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as Badge } from "./badge.svelte";
|
|
2
|
-
export { badgeVariants, type BadgeVariant } from "./badge.svelte";
|
|
2
|
+
export { badgeVariants, type BadgeVariant, type BadgeStatus } from "./badge.svelte";
|