@svadmin/ui 0.134.0 → 0.135.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 CHANGED
@@ -7321,6 +7321,9 @@
7321
7321
  .gap-x-6 {
7322
7322
  column-gap: calc(var(--spacing) * 6);
7323
7323
  }
7324
+ .gap-x-8 {
7325
+ column-gap: calc(var(--spacing) * 8);
7326
+ }
7324
7327
  :where(.-space-x-1\.5 > :not(:last-child)) {
7325
7328
  --tw-space-x-reverse: 0;
7326
7329
  margin-inline-start: calc(calc(var(--spacing) * -1.5) * var(--tw-space-x-reverse));
@@ -7334,12 +7337,18 @@
7334
7337
  .gap-y-1 {
7335
7338
  row-gap: var(--spacing);
7336
7339
  }
7340
+ .gap-y-3 {
7341
+ row-gap: calc(var(--spacing) * 3);
7342
+ }
7337
7343
  .gap-y-3\.5 {
7338
7344
  row-gap: calc(var(--spacing) * 3.5);
7339
7345
  }
7340
7346
  .gap-y-5 {
7341
7347
  row-gap: calc(var(--spacing) * 5);
7342
7348
  }
7349
+ .gap-y-6 {
7350
+ row-gap: calc(var(--spacing) * 6);
7351
+ }
7343
7352
  :where(.divide-x > :not(:last-child)) {
7344
7353
  --tw-divide-x-reverse: 0;
7345
7354
  border-inline-style: var(--tw-border-style);
@@ -10849,6 +10858,10 @@
10849
10858
  font-size: var(--text-3xl);
10850
10859
  line-height: var(--tw-leading, var(--text-3xl--line-height));
10851
10860
  }
10861
+ .sm\:text-base {
10862
+ font-size: var(--text-base);
10863
+ line-height: var(--tw-leading, var(--text-base--line-height));
10864
+ }
10852
10865
  .sm\:text-lg {
10853
10866
  font-size: var(--text-lg);
10854
10867
  line-height: var(--tw-leading, var(--text-lg--line-height));
@@ -13378,6 +13391,7 @@ h6,
13378
13391
  .svadmin-avatar:is([data-size="sm"], .svadmin-avatar-size--sm) { width: 2rem; height: 2rem; }
13379
13392
  .svadmin-avatar:is([data-size="lg"], .svadmin-avatar-size--lg) { width: 3rem; height: 3rem; }
13380
13393
  .svadmin-avatar:is([data-size="xl"], .svadmin-avatar-size--xl) { width: 4rem; height: 4rem; }
13394
+ .svadmin-avatar:is([data-shape="square"], .svadmin-avatar-shape--square) { border-radius: var(--radius-md); }
13381
13395
 
13382
13396
  [data-slot="avatar"] {
13383
13397
  width: 100%;
@@ -7321,6 +7321,9 @@
7321
7321
  .gap-x-6 {
7322
7322
  column-gap: calc(var(--spacing) * 6);
7323
7323
  }
7324
+ .gap-x-8 {
7325
+ column-gap: calc(var(--spacing) * 8);
7326
+ }
7324
7327
  :where(.-space-x-1\.5 > :not(:last-child)) {
7325
7328
  --tw-space-x-reverse: 0;
7326
7329
  margin-inline-start: calc(calc(var(--spacing) * -1.5) * var(--tw-space-x-reverse));
@@ -7334,12 +7337,18 @@
7334
7337
  .gap-y-1 {
7335
7338
  row-gap: var(--spacing);
7336
7339
  }
7340
+ .gap-y-3 {
7341
+ row-gap: calc(var(--spacing) * 3);
7342
+ }
7337
7343
  .gap-y-3\.5 {
7338
7344
  row-gap: calc(var(--spacing) * 3.5);
7339
7345
  }
7340
7346
  .gap-y-5 {
7341
7347
  row-gap: calc(var(--spacing) * 5);
7342
7348
  }
7349
+ .gap-y-6 {
7350
+ row-gap: calc(var(--spacing) * 6);
7351
+ }
7343
7352
  :where(.divide-x > :not(:last-child)) {
7344
7353
  --tw-divide-x-reverse: 0;
7345
7354
  border-inline-style: var(--tw-border-style);
@@ -10849,6 +10858,10 @@
10849
10858
  font-size: var(--text-3xl);
10850
10859
  line-height: var(--tw-leading, var(--text-3xl--line-height));
10851
10860
  }
10861
+ .sm\:text-base {
10862
+ font-size: var(--text-base);
10863
+ line-height: var(--tw-leading, var(--text-base--line-height));
10864
+ }
10852
10865
  .sm\:text-lg {
10853
10866
  font-size: var(--text-lg);
10854
10867
  line-height: var(--tw-leading, var(--text-lg--line-height));
@@ -13378,6 +13391,7 @@ h6,
13378
13391
  .svadmin-avatar:is([data-size="sm"], .svadmin-avatar-size--sm) { width: 2rem; height: 2rem; }
13379
13392
  .svadmin-avatar:is([data-size="lg"], .svadmin-avatar-size--lg) { width: 3rem; height: 3rem; }
13380
13393
  .svadmin-avatar:is([data-size="xl"], .svadmin-avatar-size--xl) { width: 4rem; height: 4rem; }
13394
+ .svadmin-avatar:is([data-shape="square"], .svadmin-avatar-shape--square) { border-radius: var(--radius-md); }
13381
13395
 
13382
13396
  [data-slot="avatar"] {
13383
13397
  width: 100%;
@@ -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.134.0";
14
+ const buildVersion = "0.135.0";
15
15
  const version = $derived(suppliedVersion ?? (
16
16
  buildVersion.startsWith('__')
17
17
  ? (i18n.locale === 'zh-CN' ? '开发构建(未提供版本)' : 'Development build (version unavailable)')
@@ -5,13 +5,18 @@
5
5
 
6
6
  interface Props {
7
7
  top?: number;
8
+ offsetTop?: number;
8
9
  bottom?: number;
10
+ offsetBottom?: number;
9
11
  target?: string;
10
12
  children: Snippet;
11
13
  class?: string;
14
+ onchange?: (stuck: boolean) => void;
12
15
  }
13
16
 
14
- let { top = 16, bottom, target = 'window', children, class: className = '' }: Props = $props();
17
+ let { top = 16, offsetTop, bottom, offsetBottom, target = 'window', children, class: className = '', onchange }: Props = $props();
18
+ const effectiveTop = $derived(offsetTop ?? top);
19
+ const effectiveBottom = $derived(offsetBottom ?? bottom);
15
20
  let stuck = $state(false);
16
21
  let sentinel: HTMLDivElement | undefined;
17
22
  let observer: IntersectionObserver | undefined;
@@ -19,8 +24,14 @@
19
24
  onMount(() => {
20
25
  if (!sentinel) return;
21
26
  observer = new IntersectionObserver(([entry]) => {
22
- if (entry) stuck = !entry.isIntersecting;
23
- }, { root: target === 'window' ? null : document.querySelector(target), rootMargin: `-${top}px 0px 0px 0px`, threshold: [0] });
27
+ if (entry) {
28
+ const nextStuck = !entry.isIntersecting;
29
+ if (stuck !== nextStuck) {
30
+ stuck = nextStuck;
31
+ onchange?.(nextStuck);
32
+ }
33
+ }
34
+ }, { root: target === 'window' ? null : document.querySelector(target), rootMargin: `-${effectiveTop}px 0px 0px 0px`, threshold: [0] });
24
35
  observer.observe(sentinel);
25
36
  return () => observer?.disconnect();
26
37
  });
@@ -30,8 +41,8 @@
30
41
  <div
31
42
  class={cn('svadmin-affix', className)}
32
43
  class:is-stuck={stuck}
33
- style:top={`${top}px`}
34
- style:bottom={bottom === undefined ? undefined : `${bottom}px`}
44
+ style:top={`${effectiveTop}px`}
45
+ style:bottom={effectiveBottom === undefined ? undefined : `${effectiveBottom}px`}
35
46
  >
36
47
  {@render children()}
37
48
  </div>
@@ -1,10 +1,13 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  interface Props {
3
3
  top?: number;
4
+ offsetTop?: number;
4
5
  bottom?: number;
6
+ offsetBottom?: number;
5
7
  target?: string;
6
8
  children: Snippet;
7
9
  class?: string;
10
+ onchange?: (stuck: boolean) => void;
8
11
  }
9
12
  declare const Affix: import("svelte").Component<Props, {}, "">;
10
13
  type Affix = ReturnType<typeof Affix>;
@@ -11,11 +11,14 @@
11
11
  interface Props {
12
12
  items: AnchorItem[];
13
13
  offset?: number;
14
+ targetOffset?: number;
14
15
  label?: string;
15
16
  class?: string;
17
+ onselect?: (id: string) => void;
16
18
  }
17
19
 
18
- let { items, offset = 96, label = 'On this page', class: className = '' }: Props = $props();
20
+ let { items, offset = 96, targetOffset, label = 'On this page', class: className = '', onselect }: Props = $props();
21
+ const effectiveOffset = $derived(targetOffset ?? offset);
19
22
  let active = $state(untrack(() => items[0]?.id ?? ''));
20
23
  let observer: IntersectionObserver | undefined;
21
24
 
@@ -25,7 +28,7 @@
25
28
  observer = new IntersectionObserver((entries) => {
26
29
  const visible = entries.filter((entry) => entry.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top);
27
30
  if (visible[0]?.target.id) active = visible[0].target.id;
28
- }, { rootMargin: `-${offset}px 0px -65% 0px`, threshold: [0, 1] });
31
+ }, { rootMargin: `-${effectiveOffset}px 0px -65% 0px`, threshold: [0, 1] });
29
32
  for (const element of elements) observer.observe(element);
30
33
  return () => observer?.disconnect();
31
34
  });
@@ -33,9 +36,10 @@
33
36
  function jump(id: string): void {
34
37
  const target = document.getElementById(id);
35
38
  if (!target) return;
36
- const top = target.getBoundingClientRect().top + window.scrollY - offset;
39
+ const top = target.getBoundingClientRect().top + window.scrollY - effectiveOffset;
37
40
  window.scrollTo({ top, behavior: 'smooth' });
38
41
  active = id;
42
+ onselect?.(id);
39
43
  }
40
44
  </script>
41
45
 
@@ -6,8 +6,10 @@ export interface AnchorItem {
6
6
  interface Props {
7
7
  items: AnchorItem[];
8
8
  offset?: number;
9
+ targetOffset?: number;
9
10
  label?: string;
10
11
  class?: string;
12
+ onselect?: (id: string) => void;
11
13
  }
12
14
  declare const Anchor: import("svelte").Component<Props, {}, "">;
13
15
  type Anchor = ReturnType<typeof Anchor>;
@@ -9,16 +9,29 @@
9
9
  import * as Breadcrumb from './ui/breadcrumb/index.js';
10
10
  import * as DropdownMenu from './ui/dropdown-menu/index.js';
11
11
 
12
+ export interface BreadcrumbItem {
13
+ label: string;
14
+ href?: string;
15
+ }
16
+
12
17
  const i18n = useTranslation();
13
18
 
14
19
  const adminContext = captureAdminContext();
15
20
  const resources = $derived((() => { try { return getResources(); } catch { return []; } })());
16
21
 
17
22
  let {
23
+ items: explicitItems,
18
24
  menu,
25
+ separator = 'slash',
19
26
  maxItems = 0,
20
27
  class: className = 'svadmin-breadcrumbs--spaced',
21
- }: { menu?: MenuItem[] | undefined; maxItems?: number; class?: string } = $props();
28
+ }: {
29
+ items?: BreadcrumbItem[] | undefined;
30
+ menu?: MenuItem[] | undefined;
31
+ separator?: 'slash' | 'arrow';
32
+ maxItems?: number;
33
+ class?: string;
34
+ } = $props();
22
35
 
23
36
  interface Crumb { label: string; href?: string; hidden?: boolean; children?: Crumb[]; }
24
37
 
@@ -44,7 +57,14 @@
44
57
  }
45
58
  }
46
59
 
47
- const crumbs = $derived.by(() => {
60
+ const crumbs = $derived.by<Crumb[]>(() => {
61
+ if (explicitItems && explicitItems.length > 0) {
62
+ // exactOptionalPropertyTypes: 不把 undefined 塞进可选 href。
63
+ return explicitItems.map((item) => (item.href === undefined
64
+ ? { label: item.label }
65
+ : { label: item.label, href: item.href }));
66
+ }
67
+
48
68
  const result: Crumb[] = [{ label: i18n.t('common.home') ?? 'Home', href: adminContext.formatLink('/') }];
49
69
  const currentPathname = normalizePath(getPath());
50
70
  if (currentPathname === '/') return result;
@@ -113,12 +133,12 @@
113
133
  });
114
134
  </script>
115
135
 
116
- {#if crumbs.length > 1}
136
+ {#if explicitItems ? crumbs.length > 0 : crumbs.length > 1}
117
137
  <Breadcrumb.Root class={cn('svadmin-breadcrumbs', className)}>
118
138
  <Breadcrumb.List>
119
139
  {#each displayCrumbs as crumb, i (`${crumb.label}-${i}`)}
120
140
  {#if i > 0}
121
- <Breadcrumb.Separator />
141
+ <Breadcrumb.Separator {separator} />
122
142
  {/if}
123
143
  <Breadcrumb.Item>
124
144
  <span class="svadmin-breadcrumbs__item svadmin-page-enter" style="animation-duration: 0.2s;">
@@ -1,6 +1,12 @@
1
1
  import { type MenuItem } from '@svadmin/core';
2
+ export interface BreadcrumbItem {
3
+ label: string;
4
+ href?: string;
5
+ }
2
6
  type $$ComponentProps = {
7
+ items?: BreadcrumbItem[] | undefined;
3
8
  menu?: MenuItem[] | undefined;
9
+ separator?: 'slash' | 'arrow';
4
10
  maxItems?: number;
5
11
  class?: string;
6
12
  };
@@ -11,6 +11,7 @@
11
11
  error?: boolean;
12
12
  autoFocus?: boolean;
13
13
  size?: 'sm' | 'md' | 'lg';
14
+ separator?: string;
14
15
  class?: string;
15
16
  'aria-label'?: string;
16
17
  onchange?: (value: string) => void;
@@ -26,6 +27,7 @@
26
27
  error = false,
27
28
  autoFocus = false,
28
29
  size = 'md',
30
+ separator,
29
31
  class: className = '',
30
32
  'aria-label': groupAriaLabel = 'OTP verification code input',
31
33
  onchange,
@@ -181,6 +183,9 @@
181
183
  aria-label={groupAriaLabel}
182
184
  >
183
185
  {#each digits as digit, index (index)}
186
+ {#if separator && index > 0 && index % 3 === 0}
187
+ <span class="svadmin-otp-separator text-muted-foreground font-mono select-none" aria-hidden="true">{separator}</span>
188
+ {/if}
184
189
  <input
185
190
  use:registerInput={index}
186
191
  type={mask ? 'password' : 'text'}
@@ -7,6 +7,7 @@ export interface OtpInputProps {
7
7
  error?: boolean;
8
8
  autoFocus?: boolean;
9
9
  size?: 'sm' | 'md' | 'lg';
10
+ separator?: string;
10
11
  class?: string;
11
12
  'aria-label'?: string;
12
13
  onchange?: (value: string) => void;
@@ -16,6 +16,8 @@
16
16
  items: StepItem[];
17
17
  direction?: 'horizontal' | 'vertical';
18
18
  labelPlacement?: 'horizontal' | 'vertical';
19
+ type?: 'default' | 'dot';
20
+ size?: 'default' | 'small';
19
21
  status?: 'wait' | 'process' | 'finish' | 'error';
20
22
  clickable?: boolean;
21
23
  class?: string;
@@ -27,6 +29,8 @@
27
29
  items,
28
30
  direction = 'horizontal',
29
31
  labelPlacement = 'horizontal',
32
+ type = 'default',
33
+ size = 'default',
30
34
  status = 'process',
31
35
  clickable = false,
32
36
  class: className = '',
@@ -46,7 +50,14 @@
46
50
  }
47
51
  </script>
48
52
 
49
- <ol class={cn('svadmin-steps', className)} data-direction={direction} data-label-placement={labelPlacement} aria-label="Steps">
53
+ <ol
54
+ class={cn('svadmin-steps', className)}
55
+ data-direction={direction}
56
+ data-label-placement={labelPlacement}
57
+ data-type={type}
58
+ data-size={size}
59
+ aria-label="Steps"
60
+ >
50
61
  {#each items as item, index (item.id ?? `${item.title}-${index}`)}
51
62
  {@const stateValue = state(index)}
52
63
  <li class="svadmin-steps__item" data-status={stateValue} data-disabled={item.disabled || undefined}>
@@ -58,7 +69,17 @@
58
69
  aria-current={index === current ? 'step' : undefined}
59
70
  >
60
71
  <span class="svadmin-steps__indicator" aria-hidden="true">
61
- {#if stateValue === 'finish'}<Check size={14} />{:else if stateValue === 'error'}<X size={14} />{:else if item.icon}{@render item.icon()}{:else}{index + 1}{/if}
72
+ {#if type === 'dot'}
73
+ <span class="svadmin-steps__dot"></span>
74
+ {:else if stateValue === 'finish'}
75
+ <Check size={size === 'small' ? 12 : 14} />
76
+ {:else if stateValue === 'error'}
77
+ <X size={size === 'small' ? 12 : 14} />
78
+ {:else if item.icon}
79
+ {@render item.icon()}
80
+ {:else}
81
+ {index + 1}
82
+ {/if}
62
83
  </span>
63
84
  <span class="svadmin-steps__text">
64
85
  <span class="svadmin-steps__title">{item.title}</span>
@@ -151,6 +172,58 @@
151
172
  }
152
173
  .svadmin-steps[data-label-placement='vertical'] .svadmin-steps__action { flex-direction: column; }
153
174
  .svadmin-steps__item[data-disabled='true'] { opacity: 1; color: var(--svadmin-text-4); }
175
+
176
+ /* Small size adjustments */
177
+ .svadmin-steps[data-size='small'] .svadmin-steps__indicator {
178
+ width: 1.5rem;
179
+ height: 1.5rem;
180
+ font-size: 0.75rem;
181
+ }
182
+ .svadmin-steps[data-size='small'] .svadmin-steps__title {
183
+ font-size: var(--svadmin-text-body);
184
+ line-height: 1.5rem;
185
+ }
186
+ .svadmin-steps[data-size='small'] .svadmin-steps__connector {
187
+ margin-block-start: 0.75rem;
188
+ }
189
+ .svadmin-steps[data-size='small'][data-direction='vertical'] .svadmin-steps__connector {
190
+ margin: 0 0 0 0.75rem;
191
+ }
192
+
193
+ /* Dot type adjustments */
194
+ .svadmin-steps[data-type='dot'] .svadmin-steps__indicator {
195
+ width: 0.75rem;
196
+ height: 0.75rem;
197
+ margin-block-start: 0.375rem;
198
+ background: transparent;
199
+ border: 0;
200
+ }
201
+ .svadmin-steps[data-type='dot'] .svadmin-steps__dot {
202
+ width: 0.5rem;
203
+ height: 0.5rem;
204
+ border-radius: 999px;
205
+ background: var(--svadmin-fill-3, var(--muted));
206
+ transition: all 200ms cubic-bezier(0, 0, 0.2, 1);
207
+ }
208
+ .svadmin-steps[data-type='dot'] .svadmin-steps__item[data-status='process'] .svadmin-steps__dot {
209
+ width: 0.625rem;
210
+ height: 0.625rem;
211
+ background: var(--primary);
212
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
213
+ }
214
+ .svadmin-steps[data-type='dot'] .svadmin-steps__item[data-status='finish'] .svadmin-steps__dot {
215
+ background: var(--primary);
216
+ }
217
+ .svadmin-steps[data-type='dot'] .svadmin-steps__item[data-status='error'] .svadmin-steps__dot {
218
+ background: var(--destructive);
219
+ }
220
+ .svadmin-steps[data-type='dot'] .svadmin-steps__connector {
221
+ margin-block-start: 0.75rem;
222
+ }
223
+ .svadmin-steps[data-type='dot'][data-direction='vertical'] .svadmin-steps__connector {
224
+ margin: 0 0 0 0.375rem;
225
+ }
226
+
154
227
  @media (max-width: 40rem) {
155
228
  .svadmin-steps[data-direction='horizontal'] { flex-direction: column; }
156
229
  .svadmin-steps[data-direction='horizontal'] .svadmin-steps__connector { width: 1px; height: 1rem; margin-inline-start: 0.875rem; }
@@ -11,6 +11,8 @@ interface Props {
11
11
  items: StepItem[];
12
12
  direction?: 'horizontal' | 'vertical';
13
13
  labelPlacement?: 'horizontal' | 'vertical';
14
+ type?: 'default' | 'dot';
15
+ size?: 'default' | 'small';
14
16
  status?: 'wait' | 'process' | 'finish' | 'error';
15
17
  clickable?: boolean;
16
18
  class?: string;
@@ -14,19 +14,36 @@
14
14
 
15
15
  interface Props {
16
16
  items: TimelineEntry[];
17
- mode?: 'vertical' | 'horizontal';
17
+ mode?: 'vertical' | 'horizontal' | 'alternate';
18
+ reverse?: boolean;
18
19
  label?: string;
19
20
  class?: string;
20
21
  dot?: Snippet<[TimelineEntry]>;
21
22
  children?: Snippet<[TimelineEntry]>;
22
23
  }
23
24
 
24
- let { items, mode = 'vertical', label = 'Timeline', class: className = '', dot, children }: Props = $props();
25
+ let {
26
+ items,
27
+ mode = 'vertical',
28
+ reverse = false,
29
+ label = 'Timeline',
30
+ class: className = '',
31
+ dot,
32
+ children,
33
+ }: Props = $props();
34
+
35
+ const displayItems = $derived(reverse ? [...items].reverse() : items);
25
36
  </script>
26
37
 
27
38
  <ol class={cn('svadmin-timeline', className)} data-mode={mode} aria-label={label}>
28
- {#each items as item (item.id)}
29
- <li class="svadmin-timeline__item" data-tone={item.tone ?? 'neutral'} data-active={item.active ? 'true' : undefined}>
39
+ {#each displayItems as item, index (item.id)}
40
+ {@const side = mode === 'alternate' ? (index % 2 === 0 ? 'left' : 'right') : undefined}
41
+ <li
42
+ class="svadmin-timeline__item"
43
+ data-tone={item.tone ?? 'neutral'}
44
+ data-active={item.active ? 'true' : undefined}
45
+ data-side={side}
46
+ >
30
47
  {#if item.dot}
31
48
  <span class="svadmin-timeline__custom-dot" aria-hidden="true">{@render item.dot()}</span>
32
49
  {:else if dot}
@@ -64,7 +81,7 @@
64
81
  color: var(--foreground);
65
82
  font-size: var(--svadmin-text-body);
66
83
  }
67
- .svadmin-timeline__item:not(:last-child)::before {
84
+ .svadmin-timeline:not([data-mode='alternate']) .svadmin-timeline__item:not(:last-child)::before {
68
85
  position: absolute;
69
86
  inset-block: 1rem calc(-1 * var(--svadmin-space-4));
70
87
  inset-inline-start: 0.3125rem;
@@ -99,4 +116,45 @@
99
116
  width: auto;
100
117
  height: 1px;
101
118
  }
119
+
120
+ /* Alternate mode */
121
+ .svadmin-timeline[data-mode='alternate'] {
122
+ position: relative;
123
+ display: block;
124
+ width: 100%;
125
+ }
126
+ .svadmin-timeline[data-mode='alternate']::before {
127
+ position: absolute;
128
+ inset-block: 0.5rem 1rem;
129
+ left: 50%;
130
+ transform: translateX(-50%);
131
+ width: 1px;
132
+ background: var(--border);
133
+ content: '';
134
+ }
135
+ .svadmin-timeline[data-mode='alternate'] .svadmin-timeline__item {
136
+ display: flex;
137
+ box-sizing: border-box;
138
+ width: 50%;
139
+ min-height: 70px;
140
+ }
141
+ .svadmin-timeline[data-mode='alternate'] .svadmin-timeline__item[data-side='left'] {
142
+ margin-right: auto;
143
+ flex-direction: row-reverse;
144
+ text-align: right;
145
+ padding-right: var(--svadmin-space-4);
146
+ }
147
+ .svadmin-timeline[data-mode='alternate'] .svadmin-timeline__item[data-side='left'] .svadmin-timeline__marker,
148
+ .svadmin-timeline[data-mode='alternate'] .svadmin-timeline__item[data-side='left'] .svadmin-timeline__custom-dot {
149
+ transform: translateX(calc(var(--svadmin-space-4) + 0.34375rem));
150
+ }
151
+ .svadmin-timeline[data-mode='alternate'] .svadmin-timeline__item[data-side='right'] {
152
+ margin-left: 50%;
153
+ text-align: left;
154
+ padding-left: var(--svadmin-space-4);
155
+ }
156
+ .svadmin-timeline[data-mode='alternate'] .svadmin-timeline__item[data-side='right'] .svadmin-timeline__marker,
157
+ .svadmin-timeline[data-mode='alternate'] .svadmin-timeline__item[data-side='right'] .svadmin-timeline__custom-dot {
158
+ transform: translateX(calc(-1 * (var(--svadmin-space-4) + 0.34375rem)));
159
+ }
102
160
  </style>
@@ -10,7 +10,8 @@ export interface TimelineEntry {
10
10
  }
11
11
  interface Props {
12
12
  items: TimelineEntry[];
13
- mode?: 'vertical' | 'horizontal';
13
+ mode?: 'vertical' | 'horizontal' | 'alternate';
14
+ reverse?: boolean;
14
15
  label?: string;
15
16
  class?: string;
16
17
  dot?: Snippet<[TimelineEntry]>;
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
- import { cn } from '../../utils.js';
2
+ import type { Snippet } from "svelte";
3
+ import { cn } from "../../utils.js";
3
4
 
4
5
  export interface DescriptionItem {
5
6
  label: string;
@@ -10,112 +11,137 @@
10
11
  }
11
12
 
12
13
  interface Props {
14
+ title?: string;
15
+ extra?: Snippet;
13
16
  items?: DescriptionItem[];
14
17
  columns?: 1 | 2 | 3 | 4;
15
- layout?: 'vertical' | 'horizontal';
18
+ layout?: "vertical" | "horizontal";
19
+ size?: "small" | "default" | "large";
16
20
  bordered?: boolean;
17
21
  class?: string;
18
22
  }
19
23
 
20
24
  let {
25
+ title,
26
+ extra,
21
27
  items = [],
22
28
  columns = 1,
23
- layout = 'vertical',
29
+ layout = "vertical",
30
+ size = "default",
24
31
  bordered = false,
25
- class: className = '',
32
+ class: className = "",
26
33
  }: Props = $props();
27
34
 
28
- const isHorizontal = $derived(layout === 'horizontal');
35
+ const isHorizontal = $derived(layout === "horizontal");
29
36
 
30
37
  function spanClass(span: number | undefined): string {
31
- if (!span || span <= 1) return '';
32
- if (span >= 4) return 'sm:col-span-4';
33
- if (span === 3) return 'sm:col-span-3';
34
- return 'sm:col-span-2';
38
+ if (!span || span <= 1) return "";
39
+ if (span >= 4) return "sm:col-span-4";
40
+ if (span === 3) return "sm:col-span-3";
41
+ return "sm:col-span-2";
35
42
  }
36
43
 
37
44
  const columnClass = $derived.by(() => {
38
45
  switch (columns) {
39
46
  case 4:
40
- return 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4';
47
+ return "grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4";
41
48
  case 3:
42
- return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3';
49
+ return "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3";
43
50
  case 2:
44
- return 'grid-cols-1 sm:grid-cols-2';
51
+ return "grid-cols-1 sm:grid-cols-2";
45
52
  default:
46
- return 'grid-cols-1';
53
+ return "grid-cols-1";
54
+ }
55
+ });
56
+
57
+ const sizePadding = $derived.by(() => {
58
+ switch (size) {
59
+ case "small":
60
+ return "px-3 py-1.5 text-xs";
61
+ case "large":
62
+ return "px-5 py-3.5 text-sm sm:text-base";
63
+ case "default":
64
+ default:
65
+ return "px-4 py-2.5 text-xs sm:text-sm";
47
66
  }
48
67
  });
49
68
  </script>
50
69
 
51
- {#if bordered}
52
- <div class={cn('overflow-hidden rounded-lg border border-border bg-card text-foreground', className)}>
53
- <dl class={cn('grid divide-y divide-border/60 sm:divide-y-0', columnClass)}>
70
+ <div class={cn("svadmin-description-list-wrapper w-full", className)}>
71
+ {#if title || extra}
72
+ <div class="flex items-center justify-between pb-2 mb-2" data-slot="description-list-header">
73
+ {#if title}<h3 class="text-sm font-semibold text-foreground m-0">{title}</h3>{/if}
74
+ {#if extra}<div class="text-xs text-muted-foreground">{@render extra()}</div>{/if}
75
+ </div>
76
+ {/if}
77
+ {#if bordered}
78
+ <div class="overflow-hidden rounded-lg border border-border bg-card text-foreground">
79
+ <dl class={cn("grid divide-y divide-border/60 sm:divide-y-0", columnClass)}>
80
+ {#each items as item, idx (item.label ? `${item.label}-${idx}` : idx)}
81
+ <div
82
+ class={cn(
83
+ "flex flex-col border-b border-r border-border/40 last:border-b-0",
84
+ isHorizontal ? "sm:flex-row" : "",
85
+ spanClass(Math.min(item.span ?? 1, columns)),
86
+ )}
87
+ >
88
+ <dt
89
+ class={cn(
90
+ "svadmin-description-list__label shrink-0 border-b sm:border-b-0 sm:border-r border-border/30 bg-muted/30",
91
+ sizePadding,
92
+ isHorizontal ? "sm:w-1/3" : "",
93
+ )}
94
+ >
95
+ {item.label}
96
+ </dt>
97
+ <dd class={cn("svadmin-description-list__value bg-card", sizePadding)}>
98
+ {#if item.href}
99
+ <a class="text-primary underline-offset-4 hover:underline" href={item.href}>{String(item.value ?? "—")}</a>
100
+ {:else}
101
+ {item.value != null ? String(item.value) : "—"}
102
+ {/if}
103
+ {#if item.description}
104
+ <p class="mt-0.5 text-xs font-normal text-muted-foreground">{item.description}</p>
105
+ {/if}
106
+ </dd>
107
+ </div>
108
+ {/each}
109
+ </dl>
110
+ </div>
111
+ {:else}
112
+ <dl
113
+ class={cn(
114
+ "grid",
115
+ columnClass,
116
+ size === "small" ? "gap-x-4 gap-y-3" : size === "large" ? "gap-x-8 gap-y-6" : "gap-x-6 gap-y-5",
117
+ )}
118
+ >
54
119
  {#each items as item, idx (item.label ? `${item.label}-${idx}` : idx)}
55
120
  <div
56
121
  class={cn(
57
- 'flex flex-col border-b border-r border-border/40 last:border-b-0',
58
- isHorizontal ? 'sm:flex-row' : '',
122
+ "min-w-0",
123
+ isHorizontal ? "flex items-baseline gap-2" : "",
59
124
  spanClass(Math.min(item.span ?? 1, columns)),
60
125
  )}
61
126
  >
62
- <dt
63
- class={cn(
64
- 'svadmin-description-list__label shrink-0 border-b sm:border-b-0 sm:border-r border-border/30 bg-muted/30',
65
- 'px-4 py-2.5',
66
- isHorizontal ? 'sm:w-1/3' : '',
67
- )}
68
- >
127
+ <dt class="svadmin-description-list__label">
69
128
  {item.label}
70
129
  </dt>
71
- <dd class="svadmin-description-list__value bg-card px-4 py-2.5">
130
+ <dd class="svadmin-description-list__value">
72
131
  {#if item.href}
73
- <a class="text-primary underline-offset-4 hover:underline" href={item.href}>{String(item.value ?? '—')}</a>
132
+ <a class="text-primary underline-offset-4 hover:underline" href={item.href}>{String(item.value ?? "—")}</a>
74
133
  {:else}
75
- {item.value != null ? String(item.value) : '—'}
134
+ {item.value != null ? String(item.value) : "—"}
76
135
  {/if}
77
136
  {#if item.description}
78
- <p class="mt-0.5 text-xs font-normal text-muted-foreground">{item.description}</p>
137
+ <p class="mt-1 text-xs font-normal text-muted-foreground">{item.description}</p>
79
138
  {/if}
80
139
  </dd>
81
140
  </div>
82
141
  {/each}
83
142
  </dl>
84
- </div>
85
- {:else}
86
- <dl
87
- class={cn(
88
- 'grid',
89
- columnClass,
90
- 'gap-x-6 gap-y-5',
91
- className,
92
- )}
93
- >
94
- {#each items as item, idx (item.label ? `${item.label}-${idx}` : idx)}
95
- <div
96
- class={cn(
97
- 'min-w-0',
98
- isHorizontal ? 'flex items-baseline gap-2' : '',
99
- spanClass(Math.min(item.span ?? 1, columns)),
100
- )}
101
- >
102
- <dt class="svadmin-description-list__label">
103
- {item.label}
104
- </dt>
105
- <dd class="svadmin-description-list__value">
106
- {#if item.href}
107
- <a class="text-primary underline-offset-4 hover:underline" href={item.href}>{String(item.value ?? '—')}</a>
108
- {:else}
109
- {item.value != null ? String(item.value) : '—'}
110
- {/if}
111
- {#if item.description}
112
- <p class="mt-1 text-xs font-normal text-muted-foreground">{item.description}</p>
113
- {/if}
114
- </dd>
115
- </div>
116
- {/each}
117
- </dl>
118
- {/if}
143
+ {/if}
144
+ </div>
119
145
 
120
146
  <style>
121
147
  .svadmin-description-list__label {
@@ -1,3 +1,4 @@
1
+ import type { Snippet } from "svelte";
1
2
  export interface DescriptionItem {
2
3
  label: string;
3
4
  value: unknown;
@@ -6,9 +7,12 @@ export interface DescriptionItem {
6
7
  span?: number;
7
8
  }
8
9
  interface Props {
10
+ title?: string;
11
+ extra?: Snippet;
9
12
  items?: DescriptionItem[];
10
13
  columns?: 1 | 2 | 3 | 4;
11
- layout?: 'vertical' | 'horizontal';
14
+ layout?: "vertical" | "horizontal";
15
+ size?: "small" | "default" | "large";
12
16
  bordered?: boolean;
13
17
  class?: string;
14
18
  }
@@ -1,6 +1,8 @@
1
1
  export type AvatarSize = "default" | "sm" | "lg" | "xl";
2
- export declare const avatarVariants: ({ size, class: className, className: extraClassName, }?: {
2
+ export type AvatarShape = "circle" | "square";
3
+ export declare const avatarVariants: ({ size, shape, class: className, className: extraClassName, }?: {
3
4
  size?: AvatarSize | null;
5
+ shape?: AvatarShape | null;
4
6
  class?: string;
5
7
  className?: string;
6
8
  }) => string;
@@ -1 +1,7 @@
1
- export const avatarVariants = ({ size = "default", class: className = "", className: extraClassName = "", } = {}) => ["svadmin-avatar", size && `svadmin-avatar-size--${size}`, className, extraClassName].filter(Boolean).join(" ");
1
+ export const avatarVariants = ({ size = "default", shape = "circle", class: className = "", className: extraClassName = "", } = {}) => [
2
+ "svadmin-avatar",
3
+ size && `svadmin-avatar-size--${size}`,
4
+ shape && `svadmin-avatar-shape--${shape}`,
5
+ className,
6
+ extraClassName,
7
+ ].filter(Boolean).join(" ");
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" module>
2
- import { avatarVariants as resolveAvatarVariants, type AvatarSize as AvatarSizeValue } from "./avatar-variants.js";
2
+ import { avatarVariants as resolveAvatarVariants, type AvatarSize as AvatarSizeValue, type AvatarShape as AvatarShapeValue } from "./avatar-variants.js";
3
3
 
4
- export { avatarVariants, type AvatarSize } from "./avatar-variants.js";
4
+ export { avatarVariants, type AvatarSize, type AvatarShape } from "./avatar-variants.js";
5
5
  </script>
6
6
 
7
7
  <script lang="ts">
@@ -10,6 +10,7 @@
10
10
 
11
11
  type Props = WithElementRef<HTMLImgAttributes, HTMLImageElement> & {
12
12
  size?: AvatarSizeValue;
13
+ shape?: AvatarShapeValue;
13
14
  fallback?: string;
14
15
  };
15
16
 
@@ -18,6 +19,7 @@
18
19
  src,
19
20
  alt = "",
20
21
  size = "default",
22
+ shape = "circle",
21
23
  fallback,
22
24
  class: className,
23
25
  ...restProps
@@ -27,7 +29,7 @@
27
29
  </script>
28
30
 
29
31
  {#if src && !imgError}
30
- <span data-size={size} class={cn(resolveAvatarVariants({ size }), className)}>
32
+ <span data-size={size} data-shape={shape} class={cn(resolveAvatarVariants({ size, shape }), className)}>
31
33
  <img
32
34
  bind:this={ref}
33
35
  data-slot="avatar"
@@ -42,8 +44,9 @@
42
44
  <span
43
45
  data-slot="avatar-fallback"
44
46
  data-size={size}
47
+ data-shape={shape}
45
48
  class={cn(
46
- resolveAvatarVariants({ size }),
49
+ resolveAvatarVariants({ size, shape }),
47
50
  "svadmin-avatar-fallback",
48
51
  className
49
52
  )}
@@ -1,9 +1,10 @@
1
- import { type AvatarSize as AvatarSizeValue } from "./avatar-variants.js";
2
- export { avatarVariants, type AvatarSize } from "./avatar-variants.js";
1
+ import { type AvatarSize as AvatarSizeValue, type AvatarShape as AvatarShapeValue } from "./avatar-variants.js";
2
+ export { avatarVariants, type AvatarSize, type AvatarShape } from "./avatar-variants.js";
3
3
  import { type WithElementRef } from "../../../utils.js";
4
4
  import type { HTMLImgAttributes } from "svelte/elements";
5
5
  type Props = WithElementRef<HTMLImgAttributes, HTMLImageElement> & {
6
6
  size?: AvatarSizeValue;
7
+ shape?: AvatarShapeValue;
7
8
  fallback?: string;
8
9
  };
9
10
  declare const Avatar: import("svelte").Component<Props, {}, "ref">;
@@ -1,2 +1,2 @@
1
- import Root from "./avatar.svelte";
2
- export { Root, Root as Avatar };
1
+ export { default as Root, default as Avatar } from "./avatar.svelte";
2
+ export { avatarVariants, type AvatarSize, type AvatarShape } from "./avatar.svelte";
@@ -1,2 +1,2 @@
1
- import Root from "./avatar.svelte";
2
- export { Root, Root as Avatar };
1
+ export { default as Root, default as Avatar } from "./avatar.svelte";
2
+ export { avatarVariants } from "./avatar.svelte";
@@ -467,6 +467,9 @@ h1, h2, h3, h4, h5, h6, [data-slot="card-title"] {
467
467
  width: 4rem;
468
468
  height: 4rem;
469
469
  }
470
+ .svadmin-avatar:is([data-shape="square"], .svadmin-avatar-shape--square) {
471
+ border-radius: var(--radius-md);
472
+ }
470
473
  [data-slot="avatar"] {
471
474
  width: 100%;
472
475
  height: 100%;
package/dist/index.d.ts CHANGED
@@ -43,7 +43,7 @@ export { default as Toast } from './components/Toast.svelte';
43
43
  export { default as NotificationHost } from './components/NotificationHost.svelte';
44
44
  export { notification, notification as Notification, getNotifications, closeNotification, closeNotificationByKey, clearNotifications, createNotificationController, provideNotificationController, useNotificationController } from './notifications.svelte.js';
45
45
  export type { NotificationOptions, NotificationRecord, NotificationTone, NotificationController } from './notifications.svelte.js';
46
- export { default as Breadcrumbs } from './components/Breadcrumbs.svelte';
46
+ export { default as Breadcrumbs, type BreadcrumbItem } from './components/Breadcrumbs.svelte';
47
47
  export { default as FieldRenderer } from './components/FieldRenderer.svelte';
48
48
  export { default as EmptyState } from './components/EmptyState.svelte';
49
49
  export { default as StatsCard } from './components/StatsCard.svelte';
@@ -292,7 +292,7 @@ export { default as ItemList, default as List } from './components/ItemList.svel
292
292
  export type { ListItem } from './components/ItemList.svelte';
293
293
  export { default as Tree } from './components/Tree.svelte';
294
294
  export type { TreeNode, TreeCheckInfo, TreeDragInfo } from './components/Tree.svelte';
295
- export { Avatar } from './components/ui/avatar/index.js';
295
+ export { Avatar, type AvatarShape } from './components/ui/avatar/index.js';
296
296
  export { Skeleton } from './components/ui/skeleton/index.js';
297
297
  export * as Sheet from './components/ui/sheet/index.js';
298
298
  export * as Drawer from './components/ui/sheet/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/ui",
3
- "version": "0.134.0",
3
+ "version": "0.135.0",
4
4
  "description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
5
5
  "type": "module",
6
6
  "sideEffects": [