@svadmin/ui 0.115.0 → 0.117.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 +260 -26
- package/dist/app.theme.css +260 -26
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AppearanceSettings.svelte +70 -1
- package/dist/components/CheckCard.svelte +149 -0
- package/dist/components/CheckCard.svelte.d.ts +31 -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/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 +51 -4
- 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/PricingCard.svelte +158 -0
- package/dist/components/PricingCard.svelte.d.ts +42 -0
- 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/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/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/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 +34 -3
- package/dist/index.js +24 -2
- package/package.json +5 -5
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const resources = $derived(adminContext.resources.filter((resource) => resource.meta?.['aboutVisible'] !== false));
|
|
12
12
|
const providerNames = $derived(adminContext.getDataProviderNames());
|
|
13
13
|
let { version: suppliedVersion, headingLevel = 'h1' }: { version?: string; headingLevel?: 'h1' | 'h2' } = $props();
|
|
14
|
-
const buildVersion = "0.
|
|
14
|
+
const buildVersion = "0.117.0";
|
|
15
15
|
const version = $derived(suppliedVersion ?? (
|
|
16
16
|
buildVersion.startsWith('__')
|
|
17
17
|
? (i18n.locale === 'zh-CN' ? '开发构建(未提供版本)' : 'Development build (version unavailable)')
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { useTranslation } from '@svadmin/core/i18n';
|
|
3
3
|
import { getTheme, setTheme, getColorTheme, setColorTheme, getColorPresets } from '@svadmin/core';
|
|
4
|
-
import { Check, Monitor, Moon, Sun } from '@lucide/svelte';
|
|
4
|
+
import { Check, Monitor, Moon, Sun, Layout, PanelLeft, Columns } from '@lucide/svelte';
|
|
5
|
+
import { uiPreferences, updateUiPreferences, type NavigationMode, type ContentWidth } from '../ui-preferences.svelte.js';
|
|
5
6
|
import SettingsGroup from './content/SettingsGroup.svelte';
|
|
6
7
|
import SettingsFieldRow from './content/SettingsFieldRow.svelte';
|
|
7
8
|
import ContentPageHeader from './content/ContentPageHeader.svelte';
|
|
@@ -14,6 +15,15 @@
|
|
|
14
15
|
{ value: 'dark' as const, icon: Moon, label: 'settings.dark' },
|
|
15
16
|
{ value: 'system' as const, icon: Monitor, label: 'settings.systemTheme' },
|
|
16
17
|
];
|
|
18
|
+
const navOptions: Array<{ value: NavigationMode; icon: typeof PanelLeft; label: string }> = [
|
|
19
|
+
{ value: 'side', icon: PanelLeft, label: 'settings.navSide' },
|
|
20
|
+
{ value: 'top', icon: Layout, label: 'settings.navTop' },
|
|
21
|
+
{ value: 'mix', icon: Columns, label: 'settings.navMix' },
|
|
22
|
+
];
|
|
23
|
+
const widthOptions: Array<{ value: ContentWidth; label: string }> = [
|
|
24
|
+
{ value: 'fixed', label: 'settings.widthFixed' },
|
|
25
|
+
{ value: 'fluid', label: 'settings.widthFluid' },
|
|
26
|
+
];
|
|
17
27
|
let currentTheme = $derived(getTheme());
|
|
18
28
|
let currentColor = $derived(getColorTheme());
|
|
19
29
|
let currentLocale = $derived(i18n.locale);
|
|
@@ -96,6 +106,65 @@
|
|
|
96
106
|
</div>
|
|
97
107
|
{/snippet}
|
|
98
108
|
</SettingsFieldRow>
|
|
109
|
+
<SettingsFieldRow label={i18n.t('settings.navigationLayout')}>
|
|
110
|
+
{#snippet control()}
|
|
111
|
+
<div class="flex overflow-hidden rounded-md border border-input">
|
|
112
|
+
{#each navOptions as option (option.value)}
|
|
113
|
+
{@const active = uiPreferences.navigation === option.value}
|
|
114
|
+
<button
|
|
115
|
+
type="button"
|
|
116
|
+
aria-pressed={active}
|
|
117
|
+
class="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors {active ? 'bg-primary text-primary-foreground' : 'bg-background text-muted-foreground hover:bg-accent'}"
|
|
118
|
+
onclick={() => updateUiPreferences({ navigation: option.value })}
|
|
119
|
+
>
|
|
120
|
+
<option.icon class="size-3.5" />
|
|
121
|
+
<span>{i18n.t(option.label)}</span>
|
|
122
|
+
</button>
|
|
123
|
+
{/each}
|
|
124
|
+
</div>
|
|
125
|
+
{/snippet}
|
|
126
|
+
</SettingsFieldRow>
|
|
127
|
+
<SettingsFieldRow label={i18n.t('settings.contentWidth')}>
|
|
128
|
+
{#snippet control()}
|
|
129
|
+
<div class="flex overflow-hidden rounded-md border border-input">
|
|
130
|
+
{#each widthOptions as option (option.value)}
|
|
131
|
+
{@const active = uiPreferences.contentWidth === option.value}
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
aria-pressed={active}
|
|
135
|
+
class="px-3 py-1.5 text-xs font-medium transition-colors {active ? 'bg-primary text-primary-foreground' : 'bg-background text-muted-foreground hover:bg-accent'}"
|
|
136
|
+
onclick={() => updateUiPreferences({ contentWidth: option.value })}
|
|
137
|
+
>
|
|
138
|
+
{i18n.t(option.label)}
|
|
139
|
+
</button>
|
|
140
|
+
{/each}
|
|
141
|
+
</div>
|
|
142
|
+
{/snippet}
|
|
143
|
+
</SettingsFieldRow>
|
|
144
|
+
<SettingsFieldRow label={i18n.t('settings.colorWeak')} description={i18n.t('settings.colorWeakDescription')}>
|
|
145
|
+
{#snippet control()}
|
|
146
|
+
<button
|
|
147
|
+
type="button"
|
|
148
|
+
aria-pressed={uiPreferences.colorWeak}
|
|
149
|
+
class="px-3 py-1.5 text-xs font-medium rounded-md border transition-colors {uiPreferences.colorWeak ? 'border-primary bg-primary text-primary-foreground' : 'border-input bg-background text-muted-foreground hover:bg-accent'}"
|
|
150
|
+
onclick={() => updateUiPreferences({ colorWeak: !uiPreferences.colorWeak })}
|
|
151
|
+
>
|
|
152
|
+
{uiPreferences.colorWeak ? i18n.t('settings.enabled') : i18n.t('settings.disabled')}
|
|
153
|
+
</button>
|
|
154
|
+
{/snippet}
|
|
155
|
+
</SettingsFieldRow>
|
|
156
|
+
<SettingsFieldRow label={i18n.t('settings.pageTransition')} description={i18n.t('settings.pageTransitionDescription')}>
|
|
157
|
+
{#snippet control()}
|
|
158
|
+
<button
|
|
159
|
+
type="button"
|
|
160
|
+
aria-pressed={uiPreferences.pageTransition}
|
|
161
|
+
class="px-3 py-1.5 text-xs font-medium rounded-md border transition-colors {uiPreferences.pageTransition ? 'border-primary bg-primary text-primary-foreground' : 'border-input bg-background text-muted-foreground hover:bg-accent'}"
|
|
162
|
+
onclick={() => updateUiPreferences({ pageTransition: !uiPreferences.pageTransition })}
|
|
163
|
+
>
|
|
164
|
+
{uiPreferences.pageTransition ? i18n.t('settings.enabled') : i18n.t('settings.disabled')}
|
|
165
|
+
</button>
|
|
166
|
+
{/snippet}
|
|
167
|
+
</SettingsFieldRow>
|
|
99
168
|
</div>
|
|
100
169
|
</SettingsGroup>
|
|
101
170
|
</div>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack, type Snippet } from 'svelte';
|
|
3
|
+
import { Loader2 } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
|
|
6
|
+
export interface CheckCardProps {
|
|
7
|
+
/** Whether the card is selected */
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
/** Default checked state for uncontrolled usage */
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
/** Title of the card */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** Description or secondary text */
|
|
14
|
+
description?: string;
|
|
15
|
+
/** Disabled state */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** Loading state */
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
/** Card size */
|
|
20
|
+
size?: 'default' | 'small';
|
|
21
|
+
/** Custom icon or avatar snippet */
|
|
22
|
+
avatar?: Snippet;
|
|
23
|
+
/** Extra content in the header */
|
|
24
|
+
extra?: Snippet;
|
|
25
|
+
/** Card body content */
|
|
26
|
+
children?: Snippet;
|
|
27
|
+
/** Callback when checked state changes */
|
|
28
|
+
onchange?: (checked: boolean) => void;
|
|
29
|
+
/** Additional CSS classes */
|
|
30
|
+
class?: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
checked,
|
|
36
|
+
defaultChecked = false,
|
|
37
|
+
title,
|
|
38
|
+
description,
|
|
39
|
+
disabled = false,
|
|
40
|
+
loading = false,
|
|
41
|
+
size = 'default',
|
|
42
|
+
avatar,
|
|
43
|
+
extra,
|
|
44
|
+
children,
|
|
45
|
+
onchange,
|
|
46
|
+
class: className = '',
|
|
47
|
+
...restProps
|
|
48
|
+
}: CheckCardProps = $props();
|
|
49
|
+
|
|
50
|
+
let internalChecked = $state(untrack(() => defaultChecked));
|
|
51
|
+
const isChecked = $derived(checked !== undefined ? checked : internalChecked);
|
|
52
|
+
|
|
53
|
+
function handleClick() {
|
|
54
|
+
if (disabled || loading) return;
|
|
55
|
+
const next = !isChecked;
|
|
56
|
+
if (checked === undefined) {
|
|
57
|
+
internalChecked = next;
|
|
58
|
+
}
|
|
59
|
+
onchange?.(next);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function handleKeyDown(event: KeyboardEvent) {
|
|
63
|
+
if (disabled || loading) return;
|
|
64
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
handleClick();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<div
|
|
72
|
+
role="checkbox"
|
|
73
|
+
aria-checked={isChecked}
|
|
74
|
+
aria-disabled={disabled || loading}
|
|
75
|
+
aria-busy={loading}
|
|
76
|
+
tabindex={disabled || loading ? -1 : 0}
|
|
77
|
+
onclick={handleClick}
|
|
78
|
+
onkeydown={handleKeyDown}
|
|
79
|
+
data-svadmin-component="CheckCard"
|
|
80
|
+
class={cn(
|
|
81
|
+
'svadmin-check-card relative flex flex-col justify-between border transition-all select-none cursor-pointer rounded-[4px] bg-card text-card-foreground',
|
|
82
|
+
size === 'small' ? 'p-3 text-xs min-w-[140px]' : 'p-4 text-sm min-w-[180px]',
|
|
83
|
+
isChecked
|
|
84
|
+
? 'border-primary bg-primary/5 shadow-sm'
|
|
85
|
+
: 'border-border hover:border-primary/50 hover:bg-muted/30',
|
|
86
|
+
(disabled || loading) && 'opacity-50 cursor-not-allowed hover:border-border hover:bg-card',
|
|
87
|
+
loading && 'cursor-wait',
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
{...restProps}
|
|
91
|
+
>
|
|
92
|
+
{#if loading}
|
|
93
|
+
<Loader2 class="absolute right-3 top-3 h-4 w-4 animate-spin text-muted-foreground" aria-hidden="true" />
|
|
94
|
+
{/if}
|
|
95
|
+
<!-- Active Checkmark Ribbon in Top-Right Corner (Arco style) -->
|
|
96
|
+
{#if isChecked}
|
|
97
|
+
<div
|
|
98
|
+
class="absolute top-0 right-0 w-0 h-0 border-t-[22px] border-l-[22px] border-t-primary border-l-transparent rounded-tr-[3px]"
|
|
99
|
+
aria-hidden="true"
|
|
100
|
+
>
|
|
101
|
+
<svg
|
|
102
|
+
class="absolute -top-[21px] -left-[11px] w-2.5 h-2.5 text-primary-foreground"
|
|
103
|
+
fill="none"
|
|
104
|
+
viewBox="0 0 24 24"
|
|
105
|
+
stroke="currentColor"
|
|
106
|
+
stroke-width="3.5"
|
|
107
|
+
>
|
|
108
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
|
|
109
|
+
</svg>
|
|
110
|
+
</div>
|
|
111
|
+
{/if}
|
|
112
|
+
|
|
113
|
+
<!-- Header: Avatar + Title + Extra -->
|
|
114
|
+
{#if title || avatar || extra}
|
|
115
|
+
<div class="flex items-start justify-between gap-2.5 mb-1.5">
|
|
116
|
+
<div class="flex items-center gap-2.5 min-w-0">
|
|
117
|
+
{#if avatar}
|
|
118
|
+
<div class="shrink-0 flex items-center justify-center">
|
|
119
|
+
{@render avatar()}
|
|
120
|
+
</div>
|
|
121
|
+
{/if}
|
|
122
|
+
{#if title}
|
|
123
|
+
<span class="font-semibold text-foreground truncate leading-snug">
|
|
124
|
+
{title}
|
|
125
|
+
</span>
|
|
126
|
+
{/if}
|
|
127
|
+
</div>
|
|
128
|
+
{#if extra}
|
|
129
|
+
<div class="shrink-0 text-muted-foreground text-xs">
|
|
130
|
+
{@render extra()}
|
|
131
|
+
</div>
|
|
132
|
+
{/if}
|
|
133
|
+
</div>
|
|
134
|
+
{/if}
|
|
135
|
+
|
|
136
|
+
<!-- Description -->
|
|
137
|
+
{#if description}
|
|
138
|
+
<p class="text-xs text-muted-foreground leading-relaxed line-clamp-2 mt-0.5">
|
|
139
|
+
{description}
|
|
140
|
+
</p>
|
|
141
|
+
{/if}
|
|
142
|
+
|
|
143
|
+
<!-- Body Content -->
|
|
144
|
+
{#if children}
|
|
145
|
+
<div class="mt-2 text-xs text-foreground/90">
|
|
146
|
+
{@render children()}
|
|
147
|
+
</div>
|
|
148
|
+
{/if}
|
|
149
|
+
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
export interface CheckCardProps {
|
|
3
|
+
/** Whether the card is selected */
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
/** Default checked state for uncontrolled usage */
|
|
6
|
+
defaultChecked?: boolean;
|
|
7
|
+
/** Title of the card */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Description or secondary text */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Disabled state */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Loading state */
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
/** Card size */
|
|
16
|
+
size?: 'default' | 'small';
|
|
17
|
+
/** Custom icon or avatar snippet */
|
|
18
|
+
avatar?: Snippet;
|
|
19
|
+
/** Extra content in the header */
|
|
20
|
+
extra?: Snippet;
|
|
21
|
+
/** Card body content */
|
|
22
|
+
children?: Snippet;
|
|
23
|
+
/** Callback when checked state changes */
|
|
24
|
+
onchange?: (checked: boolean) => void;
|
|
25
|
+
/** Additional CSS classes */
|
|
26
|
+
class?: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
declare const CheckCard: import("svelte").Component<CheckCardProps, {}, "">;
|
|
30
|
+
type CheckCard = ReturnType<typeof CheckCard>;
|
|
31
|
+
export default CheckCard;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy } from 'svelte';
|
|
3
|
+
import { Copy, Check } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
import { useTranslation } from '@svadmin/core';
|
|
6
|
+
|
|
7
|
+
const i18n = useTranslation();
|
|
8
|
+
|
|
9
|
+
export interface CopyableTextProps {
|
|
10
|
+
text: string;
|
|
11
|
+
copyValue?: string;
|
|
12
|
+
tooltip?: string;
|
|
13
|
+
copiedTooltip?: string;
|
|
14
|
+
masked?: boolean;
|
|
15
|
+
maskVisibleLength?: number;
|
|
16
|
+
oncopied?: (value: string) => void;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
text,
|
|
22
|
+
copyValue,
|
|
23
|
+
tooltip,
|
|
24
|
+
copiedTooltip,
|
|
25
|
+
masked = false,
|
|
26
|
+
maskVisibleLength = 4,
|
|
27
|
+
oncopied,
|
|
28
|
+
class: className = '',
|
|
29
|
+
}: CopyableTextProps = $props();
|
|
30
|
+
|
|
31
|
+
let copied = $state(false);
|
|
32
|
+
let resetTimer: ReturnType<typeof setTimeout> | undefined;
|
|
33
|
+
|
|
34
|
+
onDestroy(() => {
|
|
35
|
+
if (resetTimer) clearTimeout(resetTimer);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const displayText = $derived.by(() => {
|
|
39
|
+
if (!masked || !text) return text;
|
|
40
|
+
if (text.length <= maskVisibleLength * 2) {
|
|
41
|
+
return '••••••••';
|
|
42
|
+
}
|
|
43
|
+
const head = text.slice(0, maskVisibleLength);
|
|
44
|
+
const tail = text.slice(-maskVisibleLength);
|
|
45
|
+
return `${head}••••••••${tail}`;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const actualTooltip = $derived(tooltip ?? i18n.t('common.copy'));
|
|
49
|
+
const actualCopiedTooltip = $derived(copiedTooltip ?? i18n.t('common.copied'));
|
|
50
|
+
|
|
51
|
+
async function handleCopy() {
|
|
52
|
+
const valueToCopy = copyValue ?? text;
|
|
53
|
+
try {
|
|
54
|
+
if (typeof navigator === 'undefined' || !navigator.clipboard) return;
|
|
55
|
+
await navigator.clipboard.writeText(valueToCopy);
|
|
56
|
+
copied = true;
|
|
57
|
+
oncopied?.(valueToCopy);
|
|
58
|
+
if (resetTimer) clearTimeout(resetTimer);
|
|
59
|
+
resetTimer = setTimeout(() => {
|
|
60
|
+
copied = false;
|
|
61
|
+
}, 1500);
|
|
62
|
+
} catch {
|
|
63
|
+
// Graceful fallback
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<span
|
|
69
|
+
class={cn('inline-flex items-center gap-1.5 font-mono text-sm text-foreground', className)}
|
|
70
|
+
data-svadmin-component="CopyableText"
|
|
71
|
+
data-copied={copied}
|
|
72
|
+
>
|
|
73
|
+
<span class="truncate">{displayText}</span>
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
class={cn(
|
|
77
|
+
'inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring',
|
|
78
|
+
copied && 'text-success hover:text-success'
|
|
79
|
+
)}
|
|
80
|
+
onclick={handleCopy}
|
|
81
|
+
title={copied ? actualCopiedTooltip : actualTooltip}
|
|
82
|
+
aria-label={copied ? actualCopiedTooltip : actualTooltip}
|
|
83
|
+
>
|
|
84
|
+
{#if copied}
|
|
85
|
+
<Check class="h-3.5 w-3.5 text-success animate-in zoom-in-50" />
|
|
86
|
+
{:else}
|
|
87
|
+
<Copy class="h-3.5 w-3.5" />
|
|
88
|
+
{/if}
|
|
89
|
+
</button>
|
|
90
|
+
</span>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CopyableTextProps {
|
|
2
|
+
text: string;
|
|
3
|
+
copyValue?: string;
|
|
4
|
+
tooltip?: string;
|
|
5
|
+
copiedTooltip?: string;
|
|
6
|
+
masked?: boolean;
|
|
7
|
+
maskVisibleLength?: number;
|
|
8
|
+
oncopied?: (value: string) => void;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const CopyableText: import("svelte").Component<CopyableTextProps, {}, "">;
|
|
12
|
+
type CopyableText = ReturnType<typeof CopyableText>;
|
|
13
|
+
export default CopyableText;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
export interface DividerProps {
|
|
6
|
+
/** Direction of the divider */
|
|
7
|
+
type?: 'horizontal' | 'vertical';
|
|
8
|
+
/** Alignment of the text title inside the horizontal divider */
|
|
9
|
+
orientation?: 'left' | 'center' | 'right';
|
|
10
|
+
/** Whether the divider line is dashed */
|
|
11
|
+
dashed?: boolean;
|
|
12
|
+
/** Whether to use plain style text without extra bolding */
|
|
13
|
+
plain?: boolean;
|
|
14
|
+
/** Custom CSS class names */
|
|
15
|
+
class?: string;
|
|
16
|
+
/** Slot for divider text/content */
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
type = 'horizontal',
|
|
23
|
+
orientation = 'center',
|
|
24
|
+
dashed = false,
|
|
25
|
+
plain = true,
|
|
26
|
+
class: className = '',
|
|
27
|
+
children,
|
|
28
|
+
...restProps
|
|
29
|
+
}: DividerProps = $props();
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
{#if type === 'vertical'}
|
|
33
|
+
<span
|
|
34
|
+
role="separator"
|
|
35
|
+
aria-orientation="vertical"
|
|
36
|
+
data-svadmin-component="Divider"
|
|
37
|
+
data-svadmin-type="vertical"
|
|
38
|
+
class={cn(
|
|
39
|
+
'inline-block h-3.5 w-[1px] mx-2 align-middle bg-border',
|
|
40
|
+
dashed && 'border-l border-dashed border-border bg-transparent',
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...restProps}
|
|
44
|
+
></span>
|
|
45
|
+
{:else if !children}
|
|
46
|
+
<hr
|
|
47
|
+
aria-orientation="horizontal"
|
|
48
|
+
data-svadmin-component="Divider"
|
|
49
|
+
data-svadmin-type="horizontal"
|
|
50
|
+
class={cn(
|
|
51
|
+
'my-4 w-full border-0 border-t border-border',
|
|
52
|
+
dashed && 'border-dashed',
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
55
|
+
{...restProps}
|
|
56
|
+
/>
|
|
57
|
+
{:else}
|
|
58
|
+
<div
|
|
59
|
+
role="separator"
|
|
60
|
+
aria-orientation="horizontal"
|
|
61
|
+
data-svadmin-component="Divider"
|
|
62
|
+
data-svadmin-type="horizontal"
|
|
63
|
+
data-orientation={orientation}
|
|
64
|
+
class={cn(
|
|
65
|
+
'my-4 flex items-center w-full text-xs text-muted-foreground',
|
|
66
|
+
plain ? 'font-normal' : 'font-semibold text-foreground',
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...restProps}
|
|
70
|
+
>
|
|
71
|
+
<span
|
|
72
|
+
class={cn(
|
|
73
|
+
'border-t border-border',
|
|
74
|
+
dashed && 'border-dashed',
|
|
75
|
+
orientation === 'left' ? 'w-6' : orientation === 'right' ? 'flex-1' : 'flex-1'
|
|
76
|
+
)}
|
|
77
|
+
></span>
|
|
78
|
+
<span class="px-3 whitespace-nowrap">
|
|
79
|
+
{@render children()}
|
|
80
|
+
</span>
|
|
81
|
+
<span
|
|
82
|
+
class={cn(
|
|
83
|
+
'border-t border-border',
|
|
84
|
+
dashed && 'border-dashed',
|
|
85
|
+
orientation === 'left' ? 'flex-1' : orientation === 'right' ? 'w-6' : 'flex-1'
|
|
86
|
+
)}
|
|
87
|
+
></span>
|
|
88
|
+
</div>
|
|
89
|
+
{/if}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface DividerProps {
|
|
3
|
+
/** Direction of the divider */
|
|
4
|
+
type?: 'horizontal' | 'vertical';
|
|
5
|
+
/** Alignment of the text title inside the horizontal divider */
|
|
6
|
+
orientation?: 'left' | 'center' | 'right';
|
|
7
|
+
/** Whether the divider line is dashed */
|
|
8
|
+
dashed?: boolean;
|
|
9
|
+
/** Whether to use plain style text without extra bolding */
|
|
10
|
+
plain?: boolean;
|
|
11
|
+
/** Custom CSS class names */
|
|
12
|
+
class?: string;
|
|
13
|
+
/** Slot for divider text/content */
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
declare const Divider: import("svelte").Component<DividerProps, {}, "">;
|
|
18
|
+
type Divider = ReturnType<typeof Divider>;
|
|
19
|
+
export default Divider;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../utils.js';
|
|
3
|
+
import { useTranslation } from '@svadmin/core';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
|
|
6
|
+
const i18n = useTranslation();
|
|
7
|
+
|
|
8
|
+
export interface EllipsisTextProps {
|
|
9
|
+
text?: string;
|
|
10
|
+
maxLines?: number;
|
|
11
|
+
expandable?: boolean;
|
|
12
|
+
defaultExpanded?: boolean;
|
|
13
|
+
expandText?: string;
|
|
14
|
+
collapseText?: string;
|
|
15
|
+
tooltip?: boolean | string;
|
|
16
|
+
class?: string;
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
text = '',
|
|
22
|
+
maxLines = 3,
|
|
23
|
+
expandable = true,
|
|
24
|
+
defaultExpanded = false,
|
|
25
|
+
expandText,
|
|
26
|
+
collapseText,
|
|
27
|
+
tooltip = false,
|
|
28
|
+
class: className = '',
|
|
29
|
+
children,
|
|
30
|
+
}: EllipsisTextProps = $props();
|
|
31
|
+
|
|
32
|
+
let expandedState = $state<boolean | undefined>(undefined);
|
|
33
|
+
const expanded = $derived(expandedState ?? defaultExpanded);
|
|
34
|
+
|
|
35
|
+
const actualExpandText = $derived(expandText ?? i18n.t('common.expand'));
|
|
36
|
+
const actualCollapseText = $derived(collapseText ?? i18n.t('common.collapse'));
|
|
37
|
+
const tooltipText = $derived.by(() => {
|
|
38
|
+
if (!tooltip) return undefined;
|
|
39
|
+
if (typeof tooltip === 'string') return tooltip;
|
|
40
|
+
return text || undefined;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function toggleExpand() {
|
|
44
|
+
expandedState = !expanded;
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
class={cn('relative text-sm text-foreground leading-relaxed', className)}
|
|
50
|
+
data-svadmin-component="EllipsisText"
|
|
51
|
+
data-expanded={expanded}
|
|
52
|
+
title={!expanded ? tooltipText : undefined}
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
class={cn(
|
|
56
|
+
'transition-all duration-200',
|
|
57
|
+
!expanded && 'overflow-hidden [-webkit-box-orient:vertical] [-webkit-line-clamp:var(--line-clamp)] [display:-webkit-box]'
|
|
58
|
+
)}
|
|
59
|
+
style="--line-clamp: {maxLines};"
|
|
60
|
+
>
|
|
61
|
+
{#if children}
|
|
62
|
+
{@render children()}
|
|
63
|
+
{:else}
|
|
64
|
+
{text}
|
|
65
|
+
{/if}
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
{#if expandable}
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
class="mt-1 inline-flex items-center text-xs font-medium text-primary hover:text-primary/80 transition-colors focus:outline-none focus-visible:underline"
|
|
72
|
+
onclick={toggleExpand}
|
|
73
|
+
aria-expanded={expanded}
|
|
74
|
+
>
|
|
75
|
+
{expanded ? actualCollapseText : actualExpandText}
|
|
76
|
+
</button>
|
|
77
|
+
{/if}
|
|
78
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface EllipsisTextProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
maxLines?: number;
|
|
5
|
+
expandable?: boolean;
|
|
6
|
+
defaultExpanded?: boolean;
|
|
7
|
+
expandText?: string;
|
|
8
|
+
collapseText?: string;
|
|
9
|
+
tooltip?: boolean | string;
|
|
10
|
+
class?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
declare const EllipsisText: import("svelte").Component<EllipsisTextProps, {}, "">;
|
|
14
|
+
type EllipsisText = ReturnType<typeof EllipsisText>;
|
|
15
|
+
export default EllipsisText;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { Maximize2, Minimize2 } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
import { useTranslation } from '@svadmin/core';
|
|
6
|
+
|
|
7
|
+
const i18n = useTranslation();
|
|
8
|
+
|
|
9
|
+
export interface FullscreenButtonProps {
|
|
10
|
+
target?: HTMLElement | undefined;
|
|
11
|
+
title?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
onchange?: ((isFullscreen: boolean) => void) | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type FullScreenButtonProps = FullscreenButtonProps;
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
target,
|
|
20
|
+
title,
|
|
21
|
+
class: className = '',
|
|
22
|
+
onchange,
|
|
23
|
+
}: FullscreenButtonProps = $props();
|
|
24
|
+
|
|
25
|
+
let isFullscreen = $state(false);
|
|
26
|
+
|
|
27
|
+
function checkFullscreen(): boolean {
|
|
28
|
+
if (typeof document === 'undefined') return false;
|
|
29
|
+
return Boolean(document.fullscreenElement);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onMount(() => {
|
|
33
|
+
isFullscreen = checkFullscreen();
|
|
34
|
+
|
|
35
|
+
const handleFullscreenChange = () => {
|
|
36
|
+
const active = checkFullscreen();
|
|
37
|
+
isFullscreen = active;
|
|
38
|
+
onchange?.(active);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
document.addEventListener('fullscreenchange', handleFullscreenChange);
|
|
42
|
+
return () => {
|
|
43
|
+
document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
async function toggleFullscreen() {
|
|
48
|
+
if (typeof document === 'undefined') return;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
if (document.fullscreenElement) {
|
|
52
|
+
if (document.exitFullscreen) {
|
|
53
|
+
await document.exitFullscreen();
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
const el = target ?? document.documentElement;
|
|
57
|
+
if (el && el.requestFullscreen) {
|
|
58
|
+
await el.requestFullscreen();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
62
|
+
// Gracefully ignore permission or security restrictions in iframes
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const tooltipText = $derived(
|
|
67
|
+
title ?? (isFullscreen ? i18n.t('common.exitFullscreen') : i18n.t('common.fullscreen'))
|
|
68
|
+
);
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
class={cn(
|
|
74
|
+
'inline-flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-ring',
|
|
75
|
+
className
|
|
76
|
+
)}
|
|
77
|
+
onclick={toggleFullscreen}
|
|
78
|
+
title={tooltipText}
|
|
79
|
+
aria-label={tooltipText}
|
|
80
|
+
aria-pressed={isFullscreen}
|
|
81
|
+
data-svadmin-component="FullscreenButton"
|
|
82
|
+
>
|
|
83
|
+
{#if isFullscreen}
|
|
84
|
+
<Minimize2 class="h-4 w-4" />
|
|
85
|
+
{:else}
|
|
86
|
+
<Maximize2 class="h-4 w-4" />
|
|
87
|
+
{/if}
|
|
88
|
+
</button>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface FullscreenButtonProps {
|
|
2
|
+
target?: HTMLElement | undefined;
|
|
3
|
+
title?: string;
|
|
4
|
+
class?: string;
|
|
5
|
+
onchange?: ((isFullscreen: boolean) => void) | undefined;
|
|
6
|
+
}
|
|
7
|
+
export type FullScreenButtonProps = FullscreenButtonProps;
|
|
8
|
+
declare const FullscreenButton: import("svelte").Component<FullscreenButtonProps, {}, "">;
|
|
9
|
+
type FullscreenButton = ReturnType<typeof FullscreenButton>;
|
|
10
|
+
export default FullscreenButton;
|