@svadmin/ui 0.131.2 → 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.
Files changed (55) hide show
  1. package/dist/app.css +640 -250
  2. package/dist/app.theme.css +640 -250
  3. package/dist/components/AboutSettings.svelte +1 -1
  4. package/dist/components/BackTop.svelte +62 -8
  5. package/dist/components/BackTop.svelte.d.ts +8 -3
  6. package/dist/components/Carousel.svelte +59 -19
  7. package/dist/components/Carousel.svelte.d.ts +3 -1
  8. package/dist/components/Collapse.svelte +11 -7
  9. package/dist/components/EmptyState.svelte +33 -18
  10. package/dist/components/EmptyState.svelte.d.ts +3 -1
  11. package/dist/components/FileUpload.svelte +6 -4
  12. package/dist/components/Link.svelte +19 -7
  13. package/dist/components/Link.svelte.d.ts +5 -3
  14. package/dist/components/NotificationHost.svelte +8 -8
  15. package/dist/components/RadioGroup.svelte +3 -1
  16. package/dist/components/RadioGroup.svelte.d.ts +1 -0
  17. package/dist/components/RangeSlider.svelte +47 -29
  18. package/dist/components/RangeSlider.svelte.d.ts +1 -0
  19. package/dist/components/Slider.svelte +39 -18
  20. package/dist/components/Slider.svelte.d.ts +1 -0
  21. package/dist/components/Space.svelte +27 -0
  22. package/dist/components/Space.svelte.d.ts +1 -0
  23. package/dist/components/Statistic.svelte +14 -5
  24. package/dist/components/Statistic.svelte.d.ts +2 -0
  25. package/dist/components/Steps.svelte +5 -3
  26. package/dist/components/StepsForm.svelte +4 -2
  27. package/dist/components/TableToolbar.svelte +132 -0
  28. package/dist/components/TableToolbar.svelte.d.ts +26 -0
  29. package/dist/components/Tag.svelte +1 -1
  30. package/dist/components/TagsInput.svelte +47 -2
  31. package/dist/components/TagsInput.svelte.d.ts +2 -0
  32. package/dist/components/Timeline.svelte +8 -5
  33. package/dist/components/Tree.svelte +6 -5
  34. package/dist/components/TypographyEllipsis.svelte +1 -1
  35. package/dist/components/content/DataState.svelte +2 -2
  36. package/dist/components/content/DescriptionList.svelte +25 -21
  37. package/dist/components/ui/alert/alert.svelte +42 -1
  38. package/dist/components/ui/alert/alert.svelte.d.ts +5 -0
  39. package/dist/components/ui/card/card.svelte +29 -3
  40. package/dist/components/ui/card/card.svelte.d.ts +5 -2
  41. package/dist/components/ui/input/input.svelte +74 -17
  42. package/dist/components/ui/input/input.svelte.d.ts +5 -1
  43. package/dist/components/ui/pagination/pagination-link.svelte +2 -8
  44. package/dist/components/ui/pagination/pagination-next.svelte +2 -5
  45. package/dist/components/ui/pagination/pagination-previous.svelte +2 -5
  46. package/dist/components/ui/progress/progress.svelte +15 -12
  47. package/dist/components/ui/switch/switch.svelte +17 -3
  48. package/dist/components/ui/switch/switch.svelte.d.ts +2 -0
  49. package/dist/components/ui/textarea/textarea.svelte +69 -15
  50. package/dist/components/ui/textarea/textarea.svelte.d.ts +3 -0
  51. package/dist/components.css +9 -1
  52. package/dist/index.d.ts +2 -1
  53. package/dist/index.js +3 -1
  54. package/dist/page-chrome.css +2 -1
  55. package/package.json +1 -1
@@ -18,6 +18,7 @@
18
18
  describedby?: string;
19
19
  ariaLabel?: string;
20
20
  showValue?: boolean;
21
+ marks?: Record<number, string>;
21
22
  class?: string;
22
23
  onchange?: (value: RangeSliderValue) => void;
23
24
  }
@@ -34,6 +35,7 @@
34
35
  describedby,
35
36
  ariaLabel,
36
37
  showValue = false,
38
+ marks,
37
39
  class: className = '',
38
40
  onchange,
39
41
  }: Props = $props();
@@ -57,36 +59,52 @@
57
59
  }
58
60
  </script>
59
61
 
60
- <div class={cn('svadmin-range-slider', className)} data-invalid={invalid ? 'true' : undefined}>
61
- {#if minName}<input type="hidden" name={minName} value={lower} />{/if}
62
- {#if maxName}<input type="hidden" name={maxName} value={upper} />{/if}
63
- <div class="svadmin-range-slider__tracks">
64
- <input
65
- type="range"
66
- value={lower}
67
- {min}
68
- max={upper}
69
- {step}
70
- disabled={disabled}
71
- aria-label={ariaLabel ? `${ariaLabel} minimum` : 'Minimum'}
72
- aria-invalid={invalid || undefined}
73
- aria-describedby={describedby}
74
- oninput={(event) => update('min', (event.currentTarget as HTMLInputElement).value)}
75
- />
76
- <input
77
- type="range"
78
- value={upper}
79
- min={lower}
80
- {max}
81
- {step}
82
- disabled={disabled}
83
- aria-label={ariaLabel ? `${ariaLabel} maximum` : 'Maximum'}
84
- aria-invalid={invalid || undefined}
85
- aria-describedby={describedby}
86
- oninput={(event) => update('max', (event.currentTarget as HTMLInputElement).value)}
87
- />
62
+ <div class={cn('svadmin-range-slider flex flex-col w-full gap-1', className)} data-invalid={invalid ? 'true' : undefined}>
63
+ <div class="flex items-center gap-2 w-full">
64
+ {#if minName}<input type="hidden" name={minName} value={lower} />{/if}
65
+ {#if maxName}<input type="hidden" name={maxName} value={upper} />{/if}
66
+ <div class="svadmin-range-slider__tracks">
67
+ <input
68
+ type="range"
69
+ value={lower}
70
+ {min}
71
+ max={upper}
72
+ {step}
73
+ disabled={disabled}
74
+ aria-label={ariaLabel ? `${ariaLabel} minimum` : 'Minimum'}
75
+ aria-invalid={invalid || undefined}
76
+ aria-describedby={describedby}
77
+ oninput={(event) => update('min', (event.currentTarget as HTMLInputElement).value)}
78
+ />
79
+ <input
80
+ type="range"
81
+ value={upper}
82
+ min={lower}
83
+ {max}
84
+ {step}
85
+ disabled={disabled}
86
+ aria-label={ariaLabel ? `${ariaLabel} maximum` : 'Maximum'}
87
+ aria-invalid={invalid || undefined}
88
+ aria-describedby={describedby}
89
+ oninput={(event) => update('max', (event.currentTarget as HTMLInputElement).value)}
90
+ />
91
+ </div>
92
+ {#if showValue}<output>{lower} - {upper}</output>{/if}
88
93
  </div>
89
- {#if showValue}<output>{lower} - {upper}</output>{/if}
94
+ {#if marks && Object.keys(marks).length > 0}
95
+ <div class="relative w-full h-5 text-[11px] text-muted-foreground select-none" data-slot="slider-marks">
96
+ {#each Object.entries(marks) as [markVal, label] (markVal)}
97
+ {@const valNum = Number(markVal)}
98
+ {@const pct = boundsValid ? Math.min(100, Math.max(0, ((valNum - min) / (max - min)) * 100)) : 0}
99
+ <span
100
+ class="absolute -translate-x-1/2 hover:text-foreground transition-colors"
101
+ style={`left: ${pct}%;`}
102
+ >
103
+ {label}
104
+ </span>
105
+ {/each}
106
+ </div>
107
+ {/if}
90
108
  </div>
91
109
 
92
110
  <style>
@@ -14,6 +14,7 @@ interface Props {
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: RangeSliderValue) => void;
19
20
  }
@@ -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
- <input
58
- {id}
59
- {name}
60
- type="range"
61
- value={normalizedValue}
62
- {min}
63
- {max}
64
- {step}
65
- {disabled}
66
- {required}
67
- aria-label={ariaLabel}
68
- aria-invalid={invalid || undefined}
69
- aria-describedby={describedby}
70
- aria-valuetext={showValue ? String(normalizedValue) : undefined}
71
- oninput={handleInput}
72
- />
73
- {#if showValue}<output for={id}>{normalizedValue}</output>{/if}
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>
@@ -11,6 +11,7 @@ interface Props {
11
11
  describedby?: string;
12
12
  ariaLabel?: string;
13
13
  showValue?: boolean;
14
+ marks?: Record<number, string>;
14
15
  class?: string;
15
16
  onchange?: (value: number) => void;
16
17
  }
@@ -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 {
@@ -12,6 +12,7 @@ interface Props {
12
12
  justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
13
13
  wrap?: boolean;
14
14
  inline?: boolean;
15
+ split?: Snippet;
15
16
  class?: string;
16
17
  children?: Snippet;
17
18
  }
@@ -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,14 +62,19 @@
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
 
64
73
  <style>
65
- .svadmin-statistic { display: grid; min-width: 0; gap: var(--svadmin-space-1); }
66
- .svadmin-statistic__title { margin: 0; color: var(--muted-foreground); font-size: var(--svadmin-text-label); }
67
- .svadmin-statistic__value { display: flex; align-items: baseline; gap: var(--svadmin-space-1); margin: 0; color: var(--foreground); font-size: var(--svadmin-text-heading); font-weight: 650; line-height: var(--svadmin-leading-tight); }
68
- .svadmin-statistic__affix { color: var(--muted-foreground); font-size: var(--svadmin-text-label); font-weight: 500; }
74
+ .svadmin-statistic { display: grid; min-width: 0; gap: 0; line-height: 1.5715; color: var(--muted-foreground); }
75
+ .svadmin-statistic__title { margin: 0 0 8px; color: var(--muted-foreground); font-size: var(--svadmin-text-body); }
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; }
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); }
@@ -5,6 +5,8 @@ interface Props {
5
5
  precision?: number;
6
6
  prefix?: string | Snippet;
7
7
  suffix?: string | Snippet;
8
+ extra?: string | Snippet;
9
+ groupSeparator?: boolean;
8
10
  trend?: 'up' | 'down' | 'neutral';
9
11
  trendLabel?: string;
10
12
  loading?: boolean;
@@ -115,9 +115,11 @@
115
115
  .svadmin-steps__item[data-status='process'] .svadmin-steps__indicator { background: var(--primary); color: var(--primary-foreground); }
116
116
  .svadmin-steps__item[data-status='error'] .svadmin-steps__indicator { background: var(--destructive); color: var(--destructive-foreground); }
117
117
  .svadmin-steps__text { display: grid; min-width: 0; gap: 0.15rem; }
118
- .svadmin-steps__title { color: var(--foreground); font-size: var(--svadmin-text-section); font-weight: 500; }
119
- .svadmin-steps__item[data-status='wait'] .svadmin-steps__title { color: var(--muted-foreground); font-weight: 500; }
120
- .svadmin-steps__description { color: var(--muted-foreground); font-size: var(--svadmin-text-caption); }
118
+ /* Official step title is 16px. Only the active step is weight 500. */
119
+ .svadmin-steps__title { color: var(--foreground); font-size: var(--svadmin-text-section); font-weight: 400; line-height: 1.75; }
120
+ .svadmin-steps__item[data-status='process'] .svadmin-steps__title { font-weight: 500; }
121
+ .svadmin-steps__item[data-status='wait'] .svadmin-steps__title { color: var(--muted-foreground); font-weight: 400; }
122
+ .svadmin-steps__description { margin-top: 2px; color: var(--muted-foreground); font-size: var(--svadmin-text-caption); }
121
123
  .svadmin-steps__connector {
122
124
  position: relative;
123
125
  flex: 1;
@@ -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-colors"
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;
@@ -85,7 +85,7 @@
85
85
  .svadmin-tag { gap: 0.25rem; max-width: 100%; min-height: 24px; padding-inline: 8px; border-radius: 2px; font-weight: 500; }
86
86
  .svadmin-tag[data-size='compact'] { min-height: 20px; }
87
87
  .svadmin-tag.is-disabled { opacity: 1; color: var(--svadmin-text-4); }
88
- .svadmin-tag__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
88
+ .svadmin-tag__label { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
89
89
  .svadmin-tag__control,
90
90
  .svadmin-tag__close {
91
91
  display: inline-flex;
@@ -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 value as tag, index (tag)}
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;