@svadmin/ui 0.132.0 → 0.133.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 +267 -81
- package/dist/app.theme.css +267 -81
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/BackTop.svelte +62 -8
- package/dist/components/BackTop.svelte.d.ts +8 -3
- package/dist/components/Carousel.svelte +59 -19
- package/dist/components/Carousel.svelte.d.ts +3 -1
- package/dist/components/Collapse.svelte +5 -2
- package/dist/components/EmptyState.svelte +33 -18
- package/dist/components/EmptyState.svelte.d.ts +3 -1
- package/dist/components/Link.svelte +19 -7
- package/dist/components/Link.svelte.d.ts +5 -3
- package/dist/components/NotificationHost.svelte +2 -2
- package/dist/components/RadioGroup.svelte +3 -1
- package/dist/components/RadioGroup.svelte.d.ts +1 -0
- package/dist/components/RangeSlider.svelte +47 -29
- package/dist/components/RangeSlider.svelte.d.ts +1 -0
- package/dist/components/Slider.svelte +39 -18
- package/dist/components/Slider.svelte.d.ts +1 -0
- package/dist/components/Space.svelte +27 -0
- package/dist/components/Space.svelte.d.ts +1 -0
- package/dist/components/Statistic.svelte +11 -2
- package/dist/components/Statistic.svelte.d.ts +2 -0
- package/dist/components/StepsForm.svelte +4 -2
- package/dist/components/TableToolbar.svelte +132 -0
- package/dist/components/TableToolbar.svelte.d.ts +26 -0
- package/dist/components/TagsInput.svelte +47 -2
- package/dist/components/TagsInput.svelte.d.ts +2 -0
- package/dist/components/ui/alert/alert.svelte +42 -1
- package/dist/components/ui/alert/alert.svelte.d.ts +5 -0
- package/dist/components/ui/card/card.svelte +29 -3
- package/dist/components/ui/card/card.svelte.d.ts +5 -2
- package/dist/components/ui/input/input.svelte +74 -17
- package/dist/components/ui/input/input.svelte.d.ts +5 -1
- package/dist/components/ui/progress/progress.svelte +3 -2
- package/dist/components/ui/switch/switch.svelte +17 -3
- package/dist/components/ui/switch/switch.svelte.d.ts +2 -0
- package/dist/components/ui/textarea/textarea.svelte +69 -15
- package/dist/components/ui/textarea/textarea.svelte.d.ts +3 -0
- package/dist/components.css +9 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
describedby?: string;
|
|
15
15
|
ariaLabel?: string;
|
|
16
16
|
showValue?: boolean;
|
|
17
|
+
marks?: Record<number, string>;
|
|
17
18
|
class?: string;
|
|
18
19
|
onchange?: (value: number) => void;
|
|
19
20
|
}
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
describedby,
|
|
32
33
|
ariaLabel,
|
|
33
34
|
showValue = false,
|
|
35
|
+
marks,
|
|
34
36
|
class: className = '',
|
|
35
37
|
onchange,
|
|
36
38
|
}: Props = $props();
|
|
@@ -53,24 +55,43 @@
|
|
|
53
55
|
}
|
|
54
56
|
</script>
|
|
55
57
|
|
|
56
|
-
<div class={cn('svadmin-slider', className)} data-invalid={invalid ? 'true' : undefined}>
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
<div class={cn('svadmin-slider flex flex-col w-full gap-1', className)} data-invalid={invalid ? 'true' : undefined}>
|
|
59
|
+
<div class="flex items-center gap-2 w-full">
|
|
60
|
+
<input
|
|
61
|
+
{id}
|
|
62
|
+
{name}
|
|
63
|
+
type="range"
|
|
64
|
+
value={normalizedValue}
|
|
65
|
+
{min}
|
|
66
|
+
{max}
|
|
67
|
+
{step}
|
|
68
|
+
{disabled}
|
|
69
|
+
{required}
|
|
70
|
+
aria-label={ariaLabel}
|
|
71
|
+
aria-invalid={invalid || undefined}
|
|
72
|
+
aria-describedby={describedby}
|
|
73
|
+
aria-valuetext={showValue ? String(normalizedValue) : undefined}
|
|
74
|
+
oninput={handleInput}
|
|
75
|
+
/>
|
|
76
|
+
{#if showValue}<output for={id}>{normalizedValue}</output>{/if}
|
|
77
|
+
</div>
|
|
78
|
+
{#if marks && Object.keys(marks).length > 0}
|
|
79
|
+
<div class="relative w-full h-5 text-[11px] text-muted-foreground select-none" data-slot="slider-marks">
|
|
80
|
+
{#each Object.entries(marks) as [markVal, label] (markVal)}
|
|
81
|
+
{@const valNum = Number(markVal)}
|
|
82
|
+
{@const pct = boundsValid ? Math.min(100, Math.max(0, ((valNum - min) / (max - min)) * 100)) : 0}
|
|
83
|
+
<button
|
|
84
|
+
type="button"
|
|
85
|
+
class="absolute -translate-x-1/2 cursor-pointer hover:text-foreground transition-colors border-0 bg-transparent p-0 font-inherit text-inherit"
|
|
86
|
+
style={`left: ${pct}%;`}
|
|
87
|
+
disabled={disabled}
|
|
88
|
+
onclick={() => { if (!disabled) { value = valNum; onchange?.(valNum); } }}
|
|
89
|
+
>
|
|
90
|
+
{label}
|
|
91
|
+
</button>
|
|
92
|
+
{/each}
|
|
93
|
+
</div>
|
|
94
|
+
{/if}
|
|
74
95
|
</div>
|
|
75
96
|
|
|
76
97
|
<style>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
|
|
17
17
|
wrap?: boolean;
|
|
18
18
|
inline?: boolean;
|
|
19
|
+
split?: Snippet;
|
|
19
20
|
class?: string;
|
|
20
21
|
children?: Snippet;
|
|
21
22
|
}
|
|
@@ -27,10 +28,32 @@
|
|
|
27
28
|
justify = 'start',
|
|
28
29
|
wrap = false,
|
|
29
30
|
inline = false,
|
|
31
|
+
split,
|
|
30
32
|
class: className = '',
|
|
31
33
|
children,
|
|
32
34
|
}: Props = $props();
|
|
33
35
|
|
|
36
|
+
let root = $state<HTMLDivElement | null>(null);
|
|
37
|
+
let splitSource = $state<HTMLSpanElement | null>(null);
|
|
38
|
+
|
|
39
|
+
// A snippet is one block, so clone the rendered separator between child elements.
|
|
40
|
+
$effect(() => {
|
|
41
|
+
const host = root;
|
|
42
|
+
const source = split ? splitSource : null;
|
|
43
|
+
if (!host) return;
|
|
44
|
+
for (const node of [...host.querySelectorAll(':scope > .svadmin-space__split')]) node.remove();
|
|
45
|
+
if (!source) return;
|
|
46
|
+
const items = [...host.children].filter((child) => !child.classList.contains('svadmin-space__split'));
|
|
47
|
+
for (let index = items.length - 1; index > 0; index -= 1) {
|
|
48
|
+
const clone = source.cloneNode(true);
|
|
49
|
+
if (!(clone instanceof HTMLElement)) continue;
|
|
50
|
+
clone.hidden = false;
|
|
51
|
+
clone.classList.remove('svadmin-space__split-source');
|
|
52
|
+
clone.classList.add('svadmin-space__split');
|
|
53
|
+
items[index]?.before(clone);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
34
57
|
const spaceStep: Record<Exclude<SpaceSize, number>, string> = {
|
|
35
58
|
xs: '1',
|
|
36
59
|
mini: '1',
|
|
@@ -47,6 +70,7 @@
|
|
|
47
70
|
</script>
|
|
48
71
|
|
|
49
72
|
<div
|
|
73
|
+
bind:this={root}
|
|
50
74
|
class={cn('svadmin-space', className)}
|
|
51
75
|
data-direction={direction}
|
|
52
76
|
data-size={typeof size === 'number' ? undefined : size}
|
|
@@ -58,6 +82,9 @@
|
|
|
58
82
|
>
|
|
59
83
|
{@render children?.()}
|
|
60
84
|
</div>
|
|
85
|
+
{#if split}
|
|
86
|
+
<span class="svadmin-space__split-source" hidden bind:this={splitSource}>{@render split()}</span>
|
|
87
|
+
{/if}
|
|
61
88
|
|
|
62
89
|
<style>
|
|
63
90
|
.svadmin-space {
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
precision?: number;
|
|
10
10
|
prefix?: string | Snippet;
|
|
11
11
|
suffix?: string | Snippet;
|
|
12
|
+
extra?: string | Snippet;
|
|
13
|
+
groupSeparator?: boolean;
|
|
12
14
|
trend?: 'up' | 'down' | 'neutral';
|
|
13
15
|
trendLabel?: string;
|
|
14
16
|
loading?: boolean;
|
|
@@ -22,6 +24,8 @@
|
|
|
22
24
|
precision = 0,
|
|
23
25
|
prefix,
|
|
24
26
|
suffix,
|
|
27
|
+
extra,
|
|
28
|
+
groupSeparator = false,
|
|
25
29
|
trend,
|
|
26
30
|
trendLabel,
|
|
27
31
|
loading = false,
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
|
|
32
36
|
const display = $derived(
|
|
33
37
|
typeof value === 'number'
|
|
34
|
-
? formatAdminNumber(value, { locale: null, minimumFractionDigits: precision, maximumFractionDigits: precision })
|
|
38
|
+
? formatAdminNumber(value, { locale: groupSeparator ? 'en-US' : null, minimumFractionDigits: precision, maximumFractionDigits: precision })
|
|
35
39
|
: value,
|
|
36
40
|
);
|
|
37
41
|
</script>
|
|
@@ -58,6 +62,11 @@
|
|
|
58
62
|
{#if trendLabel}<span>{trendLabel}</span>{/if}
|
|
59
63
|
</p>
|
|
60
64
|
{/if}
|
|
65
|
+
{#if extra}
|
|
66
|
+
<div class="svadmin-statistic__extra text-xs text-muted-foreground mt-2">
|
|
67
|
+
{#if typeof extra === 'string'}{extra}{:else}{@render extra()}{/if}
|
|
68
|
+
</div>
|
|
69
|
+
{/if}
|
|
61
70
|
{@render children?.()}
|
|
62
71
|
</div>
|
|
63
72
|
|
|
@@ -65,7 +74,7 @@
|
|
|
65
74
|
.svadmin-statistic { display: grid; min-width: 0; gap: 0; line-height: 1.5715; color: var(--muted-foreground); }
|
|
66
75
|
.svadmin-statistic__title { margin: 0 0 8px; color: var(--muted-foreground); font-size: var(--svadmin-text-body); }
|
|
67
76
|
.svadmin-statistic__value { display: flex; align-items: baseline; gap: var(--svadmin-space-1); margin: 0; color: var(--foreground); font-size: 1.625rem; font-weight: 500; line-height: 1.5715; }
|
|
68
|
-
.svadmin-statistic__affix { color: var(--muted-foreground); font-size: var(--svadmin-text-
|
|
77
|
+
.svadmin-statistic__affix { color: var(--muted-foreground); font-size: var(--svadmin-text-body); font-weight: 500; }
|
|
69
78
|
.svadmin-statistic__trend { display: flex; align-items: center; gap: var(--svadmin-space-1); margin: 0; color: var(--muted-foreground); font-size: var(--svadmin-text-caption); }
|
|
70
79
|
.svadmin-statistic__trend[data-trend='up'] { color: var(--success, var(--primary)); }
|
|
71
80
|
.svadmin-statistic__trend[data-trend='down'] { color: var(--destructive); }
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { FieldDefinition } from '@svadmin/core';
|
|
8
8
|
import { useTranslation } from '@svadmin/core/i18n';
|
|
9
9
|
|
|
10
|
+
import { cn } from '../utils.js';
|
|
10
11
|
import { Button } from './ui/button/index.js';
|
|
11
12
|
import * as Card from './ui/card/index.js';
|
|
12
13
|
import { Badge } from './ui/badge/index.js';
|
|
@@ -282,11 +283,12 @@
|
|
|
282
283
|
onclick={changeStep(i)}
|
|
283
284
|
>
|
|
284
285
|
<span
|
|
285
|
-
class="flex h-7 w-7 items-center justify-center rounded-full text-xs font-medium transition-
|
|
286
|
+
class={cn("flex h-7 w-7 items-center justify-center rounded-full text-xs font-medium transition-all duration-200", i === form.steps.currentStep && "ring-4 ring-primary/20")}
|
|
286
287
|
class:bg-primary={i <= form.steps.currentStep}
|
|
287
288
|
class:text-primary-foreground={i <= form.steps.currentStep}
|
|
288
289
|
class:bg-muted={i > form.steps.currentStep}
|
|
289
290
|
class:text-muted-foreground={i > form.steps.currentStep}
|
|
291
|
+
|
|
290
292
|
>
|
|
291
293
|
{#if i < form.steps.currentStep}
|
|
292
294
|
<Check class="h-3.5 w-3.5" />
|
|
@@ -297,7 +299,7 @@
|
|
|
297
299
|
<span class="hidden sm:inline">{step.title}</span>
|
|
298
300
|
</Button>
|
|
299
301
|
{#if i < steps.length - 1}
|
|
300
|
-
<div class="flex-1 mx-2 h-px bg-border" class:bg-primary={i < form.steps.currentStep}></div>
|
|
302
|
+
<div class="flex-1 mx-2 h-px bg-border transition-colors duration-300" class:bg-primary={i < form.steps.currentStep}></div>
|
|
301
303
|
{/if}
|
|
302
304
|
{/each}
|
|
303
305
|
</div>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { RefreshCw, Columns3 } from "@lucide/svelte";
|
|
4
|
+
import { definedOptions } from "@svadmin/core/options";
|
|
5
|
+
import { Button } from "./ui/button/index.js";
|
|
6
|
+
import ColumnSettings, { type ColumnItem, type ColumnPreset } from "./ColumnSettings.svelte";
|
|
7
|
+
import FullscreenButton from "./FullscreenButton.svelte";
|
|
8
|
+
import { cn } from "../utils.js";
|
|
9
|
+
import { useTranslation } from "@svadmin/core/i18n";
|
|
10
|
+
|
|
11
|
+
export interface TableToolbarProps {
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
columns?: ColumnItem[];
|
|
15
|
+
density?: "default" | "compact";
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
storageKey?: string;
|
|
18
|
+
columnPresets?: ColumnPreset[];
|
|
19
|
+
fullscreenTarget?: HTMLElement | null;
|
|
20
|
+
showRefresh?: boolean;
|
|
21
|
+
showDensity?: boolean;
|
|
22
|
+
showColumns?: boolean;
|
|
23
|
+
showFullscreen?: boolean;
|
|
24
|
+
onrefresh?: () => void;
|
|
25
|
+
ondensitychange?: (density: "default" | "compact") => void;
|
|
26
|
+
oncolumnschange?: (columns: ColumnItem[]) => void;
|
|
27
|
+
actions?: Snippet;
|
|
28
|
+
extra?: Snippet;
|
|
29
|
+
children?: Snippet;
|
|
30
|
+
class?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let {
|
|
34
|
+
title,
|
|
35
|
+
description,
|
|
36
|
+
columns = $bindable([]),
|
|
37
|
+
density = $bindable("default"),
|
|
38
|
+
loading = false,
|
|
39
|
+
storageKey,
|
|
40
|
+
columnPresets = [],
|
|
41
|
+
fullscreenTarget,
|
|
42
|
+
showRefresh = true,
|
|
43
|
+
showDensity = true,
|
|
44
|
+
showColumns = true,
|
|
45
|
+
showFullscreen = true,
|
|
46
|
+
onrefresh,
|
|
47
|
+
ondensitychange,
|
|
48
|
+
oncolumnschange,
|
|
49
|
+
actions,
|
|
50
|
+
extra,
|
|
51
|
+
children,
|
|
52
|
+
class: className = "",
|
|
53
|
+
}: TableToolbarProps = $props();
|
|
54
|
+
|
|
55
|
+
const i18n = useTranslation();
|
|
56
|
+
|
|
57
|
+
function toggleDensity() {
|
|
58
|
+
const next = density === "default" ? "compact" : "default";
|
|
59
|
+
density = next;
|
|
60
|
+
ondensitychange?.(next);
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<div
|
|
65
|
+
data-svadmin-component="TableToolbar"
|
|
66
|
+
class={cn("svadmin-table-toolbar flex flex-wrap items-center justify-between gap-3 py-2.5", className)}
|
|
67
|
+
>
|
|
68
|
+
<!-- Left: Title / Description / Actions slot -->
|
|
69
|
+
<div class="flex flex-wrap items-center gap-2.5 min-w-0">
|
|
70
|
+
{#if title || description}
|
|
71
|
+
<div class="min-w-0 pr-2">
|
|
72
|
+
{#if title}<h3 class="text-sm font-semibold text-foreground truncate leading-tight">{title}</h3>{/if}
|
|
73
|
+
{#if description}<p class="text-xs text-muted-foreground truncate mt-0.5">{description}</p>{/if}
|
|
74
|
+
</div>
|
|
75
|
+
{/if}
|
|
76
|
+
{#if actions}
|
|
77
|
+
{@render actions()}
|
|
78
|
+
{/if}
|
|
79
|
+
{#if children}
|
|
80
|
+
{@render children()}
|
|
81
|
+
{/if}
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<!-- Right: Tool actions cluster (Refresh, Density, Columns, Fullscreen) -->
|
|
85
|
+
<div class="flex items-center gap-1.5 shrink-0">
|
|
86
|
+
{#if extra}
|
|
87
|
+
{@render extra()}
|
|
88
|
+
{/if}
|
|
89
|
+
|
|
90
|
+
{#if showRefresh && onrefresh}
|
|
91
|
+
<Button
|
|
92
|
+
variant="ghost"
|
|
93
|
+
size="icon"
|
|
94
|
+
class="h-8 w-8 text-muted-foreground hover:text-foreground"
|
|
95
|
+
title={i18n.t("common.refresh", { defaultValue: "Refresh" })}
|
|
96
|
+
aria-label={i18n.t("common.refresh", { defaultValue: "Refresh" })}
|
|
97
|
+
onclick={onrefresh}
|
|
98
|
+
>
|
|
99
|
+
<RefreshCw class={cn("h-4 w-4", loading && "animate-spin")} />
|
|
100
|
+
</Button>
|
|
101
|
+
{/if}
|
|
102
|
+
|
|
103
|
+
{#if showDensity}
|
|
104
|
+
<Button
|
|
105
|
+
variant="ghost"
|
|
106
|
+
size="icon"
|
|
107
|
+
class="h-8 w-8 text-muted-foreground hover:text-foreground"
|
|
108
|
+
title={density === "compact" ? i18n.t("common.standard", { defaultValue: "Standard" }) : i18n.t("common.compact", { defaultValue: "Compact" })}
|
|
109
|
+
aria-label="Toggle density"
|
|
110
|
+
aria-pressed={density === "compact"}
|
|
111
|
+
onclick={toggleDensity}
|
|
112
|
+
>
|
|
113
|
+
<Columns3 class="h-4 w-4" />
|
|
114
|
+
</Button>
|
|
115
|
+
{/if}
|
|
116
|
+
|
|
117
|
+
{#if showColumns && columns.length > 0}
|
|
118
|
+
<ColumnSettings
|
|
119
|
+
bind:columns
|
|
120
|
+
presets={columnPresets}
|
|
121
|
+
triggerVariant="ghost"
|
|
122
|
+
triggerSize="icon"
|
|
123
|
+
class="h-8 w-8"
|
|
124
|
+
{...definedOptions({ storageKey, onchange: oncolumnschange })}
|
|
125
|
+
/>
|
|
126
|
+
{/if}
|
|
127
|
+
|
|
128
|
+
{#if showFullscreen}
|
|
129
|
+
<FullscreenButton target={fullscreenTarget ?? undefined} class="h-8 w-8" />
|
|
130
|
+
{/if}
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import { type ColumnItem, type ColumnPreset } from "./ColumnSettings.svelte";
|
|
3
|
+
export interface TableToolbarProps {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
columns?: ColumnItem[];
|
|
7
|
+
density?: "default" | "compact";
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
storageKey?: string;
|
|
10
|
+
columnPresets?: ColumnPreset[];
|
|
11
|
+
fullscreenTarget?: HTMLElement | null;
|
|
12
|
+
showRefresh?: boolean;
|
|
13
|
+
showDensity?: boolean;
|
|
14
|
+
showColumns?: boolean;
|
|
15
|
+
showFullscreen?: boolean;
|
|
16
|
+
onrefresh?: () => void;
|
|
17
|
+
ondensitychange?: (density: "default" | "compact") => void;
|
|
18
|
+
oncolumnschange?: (columns: ColumnItem[]) => void;
|
|
19
|
+
actions?: Snippet;
|
|
20
|
+
extra?: Snippet;
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
class?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const TableToolbar: import("svelte").Component<TableToolbarProps, {}, "density" | "columns">;
|
|
25
|
+
type TableToolbar = ReturnType<typeof TableToolbar>;
|
|
26
|
+
export default TableToolbar;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { X } from '@lucide/svelte';
|
|
2
|
+
import { X, CircleX } from '@lucide/svelte';
|
|
3
3
|
import { cn } from '../utils.js';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
placeholder?: string | undefined;
|
|
9
9
|
separator?: string | undefined;
|
|
10
10
|
maxItems?: number | undefined;
|
|
11
|
+
maxTagCount?: number | undefined;
|
|
12
|
+
allowClear?: boolean | undefined;
|
|
11
13
|
disabled?: boolean | undefined;
|
|
12
14
|
required?: boolean | undefined;
|
|
13
15
|
invalid?: boolean | undefined;
|
|
@@ -23,6 +25,8 @@
|
|
|
23
25
|
placeholder = 'Add a tag',
|
|
24
26
|
separator = ',',
|
|
25
27
|
maxItems,
|
|
28
|
+
maxTagCount,
|
|
29
|
+
allowClear = false,
|
|
26
30
|
disabled = false,
|
|
27
31
|
required = false,
|
|
28
32
|
invalid = false,
|
|
@@ -34,6 +38,8 @@
|
|
|
34
38
|
|
|
35
39
|
let draft = $state('');
|
|
36
40
|
let composing = $state(false);
|
|
41
|
+
const displayedTags = $derived(maxTagCount !== undefined && maxTagCount >= 0 ? value.slice(0, maxTagCount) : value);
|
|
42
|
+
const overflowCount = $derived(maxTagCount !== undefined && maxTagCount >= 0 ? Math.max(0, value.length - maxTagCount) : 0);
|
|
37
43
|
|
|
38
44
|
function normalized(values: readonly string[]): string[] {
|
|
39
45
|
return [...new Set(values.map(item => item.trim()).filter(Boolean))];
|
|
@@ -54,6 +60,11 @@
|
|
|
54
60
|
draft = '';
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
function clearAll(): void {
|
|
64
|
+
if (disabled) return;
|
|
65
|
+
update([]);
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
function remove(index: number): void {
|
|
58
69
|
if (disabled) return;
|
|
59
70
|
update(value.filter((_, itemIndex) => itemIndex !== index));
|
|
@@ -81,7 +92,7 @@
|
|
|
81
92
|
<input type="hidden" {name} value={tag} {disabled} />
|
|
82
93
|
{/each}
|
|
83
94
|
{/if}
|
|
84
|
-
{#each
|
|
95
|
+
{#each displayedTags as tag, index (tag)}
|
|
85
96
|
<span class="svadmin-tags-input__tag">
|
|
86
97
|
<span>{tag}</span>
|
|
87
98
|
<button
|
|
@@ -94,6 +105,11 @@
|
|
|
94
105
|
</button>
|
|
95
106
|
</span>
|
|
96
107
|
{/each}
|
|
108
|
+
{#if overflowCount > 0}
|
|
109
|
+
<span class="svadmin-tags-input__tag svadmin-tags-input__tag--overflow" title={value.slice(maxTagCount).join(", ")}>
|
|
110
|
+
<span>+{overflowCount}</span>
|
|
111
|
+
</span>
|
|
112
|
+
{/if}
|
|
97
113
|
<input
|
|
98
114
|
value={draft}
|
|
99
115
|
{placeholder}
|
|
@@ -107,6 +123,16 @@
|
|
|
107
123
|
oncompositionstart={() => { composing = true; }}
|
|
108
124
|
oncompositionend={(event) => { composing = false; draft = (event.currentTarget as HTMLInputElement).value; }}
|
|
109
125
|
/>
|
|
126
|
+
{#if allowClear && value.length > 0 && !disabled}
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
class="svadmin-tags-input__clear"
|
|
130
|
+
aria-label="Clear all tags"
|
|
131
|
+
onclick={clearAll}
|
|
132
|
+
>
|
|
133
|
+
<CircleX size={14} aria-hidden="true" />
|
|
134
|
+
</button>
|
|
135
|
+
{/if}
|
|
110
136
|
</div>
|
|
111
137
|
|
|
112
138
|
<style>
|
|
@@ -165,6 +191,25 @@
|
|
|
165
191
|
color: var(--accent-foreground);
|
|
166
192
|
}
|
|
167
193
|
|
|
194
|
+
.svadmin-tags-input__clear {
|
|
195
|
+
display: inline-grid;
|
|
196
|
+
place-items: center;
|
|
197
|
+
border: 0;
|
|
198
|
+
background: transparent;
|
|
199
|
+
color: var(--muted-foreground);
|
|
200
|
+
cursor: pointer;
|
|
201
|
+
padding: 2px;
|
|
202
|
+
border-radius: 999px;
|
|
203
|
+
}
|
|
204
|
+
.svadmin-tags-input__clear:hover {
|
|
205
|
+
color: var(--foreground);
|
|
206
|
+
}
|
|
207
|
+
.svadmin-tags-input__tag--overflow {
|
|
208
|
+
background: var(--secondary);
|
|
209
|
+
color: var(--secondary-foreground);
|
|
210
|
+
padding: 2px 6px;
|
|
211
|
+
font-weight: 500;
|
|
212
|
+
}
|
|
168
213
|
.svadmin-tags-input input {
|
|
169
214
|
min-inline-size: 8rem;
|
|
170
215
|
flex: 1 1 8rem;
|
|
@@ -4,6 +4,8 @@ interface Props {
|
|
|
4
4
|
placeholder?: string | undefined;
|
|
5
5
|
separator?: string | undefined;
|
|
6
6
|
maxItems?: number | undefined;
|
|
7
|
+
maxTagCount?: number | undefined;
|
|
8
|
+
allowClear?: boolean | undefined;
|
|
7
9
|
disabled?: boolean | undefined;
|
|
8
10
|
required?: boolean | undefined;
|
|
9
11
|
invalid?: boolean | undefined;
|
|
@@ -8,12 +8,18 @@
|
|
|
8
8
|
|
|
9
9
|
<script lang="ts">
|
|
10
10
|
import X from "@lucide/svelte/icons/x";
|
|
11
|
+
import { CheckCircle2, CircleAlert, Info, TriangleAlert } from "@lucide/svelte";
|
|
11
12
|
import type { Snippet } from "svelte";
|
|
12
13
|
|
|
13
14
|
type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
14
15
|
variant?: AlertVariantValue;
|
|
15
16
|
closable?: boolean;
|
|
16
17
|
closeLabel?: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
showIcon?: boolean;
|
|
20
|
+
banner?: boolean;
|
|
21
|
+
action?: Snippet;
|
|
22
|
+
icon?: Snippet;
|
|
17
23
|
onclose?: (event: MouseEvent) => void;
|
|
18
24
|
children?: Snippet;
|
|
19
25
|
};
|
|
@@ -23,11 +29,25 @@
|
|
|
23
29
|
variant = "default",
|
|
24
30
|
closable = false,
|
|
25
31
|
closeLabel = "Dismiss alert",
|
|
32
|
+
title,
|
|
33
|
+
showIcon = false,
|
|
34
|
+
banner = false,
|
|
35
|
+
action,
|
|
36
|
+
icon,
|
|
26
37
|
onclose,
|
|
27
38
|
class: className,
|
|
28
39
|
children,
|
|
29
40
|
...restProps
|
|
30
41
|
}: Props = $props();
|
|
42
|
+
|
|
43
|
+
const statusIcons = {
|
|
44
|
+
default: Info,
|
|
45
|
+
destructive: CircleAlert,
|
|
46
|
+
warning: TriangleAlert,
|
|
47
|
+
success: CheckCircle2,
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
const IconComponent = $derived(statusIcons[variant] ?? Info);
|
|
31
51
|
</script>
|
|
32
52
|
|
|
33
53
|
<div
|
|
@@ -37,10 +57,31 @@
|
|
|
37
57
|
data-feedback="static"
|
|
38
58
|
data-variant={variant}
|
|
39
59
|
data-closable={closable || undefined}
|
|
40
|
-
class={cn(
|
|
60
|
+
class={cn(
|
|
61
|
+
resolveAlertVariants({ variant }),
|
|
62
|
+
banner && "svadmin-alert--banner rounded-none border-x-0 border-t-0 border-b border-border",
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
41
65
|
{...restProps}
|
|
42
66
|
>
|
|
67
|
+
{#if icon}
|
|
68
|
+
{@render icon()}
|
|
69
|
+
{:else if showIcon}
|
|
70
|
+
<IconComponent class="svadmin-alert__icon" aria-hidden="true" />
|
|
71
|
+
{/if}
|
|
72
|
+
|
|
73
|
+
{#if title}
|
|
74
|
+
<div data-slot="alert-title" class="svadmin-alert-title font-semibold">{title}</div>
|
|
75
|
+
{/if}
|
|
76
|
+
|
|
43
77
|
{@render children?.()}
|
|
78
|
+
|
|
79
|
+
{#if action}
|
|
80
|
+
<div class="svadmin-alert__action shrink-0 justify-self-end">
|
|
81
|
+
{@render action()}
|
|
82
|
+
</div>
|
|
83
|
+
{/if}
|
|
84
|
+
|
|
44
85
|
{#if closable}
|
|
45
86
|
<button type="button" class="svadmin-alert__close" aria-label={closeLabel} onclick={(event) => onclose?.(event)}>
|
|
46
87
|
<X size={14} aria-hidden="true" />
|
|
@@ -7,6 +7,11 @@ type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
|
7
7
|
variant?: AlertVariantValue;
|
|
8
8
|
closable?: boolean;
|
|
9
9
|
closeLabel?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
showIcon?: boolean;
|
|
12
|
+
banner?: boolean;
|
|
13
|
+
action?: Snippet;
|
|
14
|
+
icon?: Snippet;
|
|
10
15
|
onclose?: (event: MouseEvent) => void;
|
|
11
16
|
children?: Snippet;
|
|
12
17
|
};
|
|
@@ -1,22 +1,48 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { HTMLAttributes } from "svelte/elements";
|
|
3
3
|
import { cn, type WithElementRef } from "../../../utils.js";
|
|
4
|
+
import { Skeleton } from "../skeleton/index.js";
|
|
5
|
+
|
|
6
|
+
type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
7
|
+
size?: "default" | "sm";
|
|
8
|
+
hoverable?: boolean;
|
|
9
|
+
bordered?: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
};
|
|
4
12
|
|
|
5
13
|
let {
|
|
6
14
|
ref = $bindable(null),
|
|
7
15
|
class: className,
|
|
8
16
|
children,
|
|
9
17
|
size = "default",
|
|
18
|
+
hoverable = false,
|
|
19
|
+
bordered = true,
|
|
20
|
+
loading = false,
|
|
10
21
|
...restProps
|
|
11
|
-
}:
|
|
22
|
+
}: Props = $props();
|
|
12
23
|
</script>
|
|
13
24
|
|
|
14
25
|
<div
|
|
15
26
|
bind:this={ref}
|
|
16
27
|
data-slot="card"
|
|
17
28
|
data-size={size}
|
|
18
|
-
|
|
29
|
+
data-hoverable={hoverable ? "true" : undefined}
|
|
30
|
+
class={cn(
|
|
31
|
+
"svadmin-card",
|
|
32
|
+
hoverable && "svadmin-card--hoverable",
|
|
33
|
+
!bordered && "border-0 shadow-none",
|
|
34
|
+
className
|
|
35
|
+
)}
|
|
19
36
|
{...restProps}
|
|
20
37
|
>
|
|
21
|
-
{
|
|
38
|
+
{#if loading}
|
|
39
|
+
<div class="space-y-3 p-6" data-slot="card-loading">
|
|
40
|
+
<Skeleton class="h-6 w-1/3" />
|
|
41
|
+
<Skeleton class="h-4 w-full" />
|
|
42
|
+
<Skeleton class="h-4 w-4/5" />
|
|
43
|
+
<Skeleton class="h-16 w-full mt-2" />
|
|
44
|
+
</div>
|
|
45
|
+
{:else}
|
|
46
|
+
{@render children?.()}
|
|
47
|
+
{/if}
|
|
22
48
|
</div>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { HTMLAttributes } from "svelte/elements";
|
|
2
2
|
import { type WithElementRef } from "../../../utils.js";
|
|
3
|
-
type
|
|
3
|
+
type Props = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
4
4
|
size?: "default" | "sm";
|
|
5
|
+
hoverable?: boolean;
|
|
6
|
+
bordered?: boolean;
|
|
7
|
+
loading?: boolean;
|
|
5
8
|
};
|
|
6
|
-
declare const Card: import("svelte").Component
|
|
9
|
+
declare const Card: import("svelte").Component<Props, {}, "ref">;
|
|
7
10
|
type Card = ReturnType<typeof Card>;
|
|
8
11
|
export default Card;
|