@svadmin/ui 0.35.0 → 0.36.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.
@@ -64,16 +64,41 @@
64
64
  return menuItem.children?.some((c: MenuItem) => hasActiveChild(c)) ?? false;
65
65
  }
66
66
 
67
+ function getItemBadge(menuItem: MenuItem): string | undefined {
68
+ const meta = menuItem.meta as (MenuItem['meta'] & { badge?: unknown }) | undefined;
69
+ return typeof meta?.badge === 'string' ? meta.badge : undefined;
70
+ }
71
+
72
+ function aggregateBadges(menuItems: MenuItem[] | undefined): string | undefined {
73
+ const total = menuItems?.reduce((sum, menuItem) => {
74
+ const ownBadge = Number(getItemBadge(menuItem));
75
+ const childBadge = Number(aggregateBadges(menuItem.children));
76
+ return sum + (Number.isFinite(ownBadge) ? ownBadge : 0) + (Number.isFinite(childBadge) ? childBadge : 0);
77
+ }, 0) ?? 0;
78
+
79
+ return total > 0 ? String(total) : undefined;
80
+ }
81
+
67
82
  const hasChildren = $derived(item.children && item.children.length > 0);
68
83
  const active = $derived(isActive(item.href));
69
84
  const childActive = $derived(hasActiveChild(item));
70
85
  const isExternal = $derived(item.target === '_blank' || item.href?.startsWith('http'));
86
+ const badge = $derived(getItemBadge(item));
87
+ const childrenBadge = $derived(aggregateBadges(item.children));
71
88
 
72
89
  const finalHref = $derived(isExternal ? item.href : (item.href ? formatLink(item.href) : undefined));
73
-
74
- // Track open state — auto-open if a child is active
90
+ // Auto-open the active branch once, then respect manual collapse/expand.
75
91
  let isOpen = $state(false);
76
- $effect(() => { if (childActive) isOpen = true; });
92
+ let touchedOpen = $state(false);
93
+
94
+ function setOpen(nextOpen: boolean) {
95
+ touchedOpen = true;
96
+ isOpen = nextOpen;
97
+ }
98
+
99
+ $effect(() => {
100
+ if (childActive && !touchedOpen && !isOpen) isOpen = true;
101
+ });
77
102
 
78
103
  const Icon = $derived(getIcon(item.icon));
79
104
  const label = $derived(getLabel(item));
@@ -83,13 +108,13 @@
83
108
  <!-- hidden item, render nothing -->
84
109
  {:else if hasChildren && !collapsed}
85
110
  <!-- Parent node with children: render as collapsible group -->
86
- <Collapsible.Root bind:open={isOpen}>
111
+ <Collapsible.Root open={isOpen} onOpenChange={setOpen}>
87
112
  <Collapsible.Trigger
88
- class="flex w-full items-center justify-between rounded-xl px-3 py-2 text-sm font-medium transition-all duration-200
113
+ class="flex w-full items-center justify-between rounded-xl px-3 {depth === 1 ? 'py-1.5' : 'py-2'} text-sm font-medium transition-all duration-200
89
114
  {childActive
90
- ? 'bg-primary/10 text-primary ring-1 ring-primary/15'
91
- : 'text-sidebar-foreground/68 hover:bg-sidebar-accent/65 hover:text-sidebar-foreground'}"
92
- style="padding-left: {12 + depth * 12}px"
115
+ ? 'text-primary font-semibold'
116
+ : 'text-sidebar-foreground/68 hover:bg-sidebar-accent/45 hover:text-sidebar-foreground'}"
117
+ style="padding-left: {depth === 0 ? 12 : 4 + (depth - 1) * 12}px"
93
118
  data-sidebar={depth === 0 ? "menu-button" : "menu-sub-button"}
94
119
  data-active={childActive ? "true" : "false"}
95
120
  >
@@ -97,10 +122,19 @@
97
122
  <Icon class="h-4 w-4 flex-shrink-0" />
98
123
  <span>{label}</span>
99
124
  </span>
100
- <ChevronDown class="h-3.5 w-3.5 transition-transform duration-200 {isOpen ? 'rotate-180' : ''}" />
125
+ <span class="ml-2 flex items-center gap-2">
126
+ {#if childrenBadge}
127
+ <span class="rounded-full {childActive ? 'bg-primary/12 text-primary' : 'bg-sidebar-accent text-sidebar-foreground/60'} px-2 py-0.5 text-[10px] font-semibold">{childrenBadge}</span>
128
+ {/if}
129
+ <ChevronDown class="h-3.5 w-3.5 transition-transform duration-200 {isOpen ? 'rotate-180' : ''}" />
130
+ </span>
101
131
  </Collapsible.Trigger>
102
132
  <Collapsible.Content>
103
- <div class="mt-0.5 space-y-0.5" style="padding-left: {depth > 0 ? 0 : 0}px" data-sidebar="menu-sub">
133
+ <div
134
+ class="mt-0.5 {depth >= 1 ? 'divide-y divide-border/45' : 'space-y-0'}"
135
+ style="padding-left: {depth > 0 ? 0 : 0}px"
136
+ data-sidebar="menu-sub"
137
+ >
104
138
  {#each item.children as child, _i (_i)}
105
139
  <SidebarItem item={child} {currentPath} {collapsed} depth={depth + 1} />
106
140
  {/each}
@@ -117,10 +151,10 @@
117
151
  href={finalHref}
118
152
  target={isExternal ? '_blank' : undefined}
119
153
  rel={isExternal ? 'noopener noreferrer' : undefined}
120
- class="flex items-center justify-center rounded-xl px-3 py-2.5 text-sm font-medium transition-all duration-200
154
+ class="mx-auto flex h-10 w-10 items-center justify-center text-sm font-medium transition-colors duration-200
121
155
  {active
122
- ? 'bg-primary/10 text-primary shadow-sm shadow-primary/10 ring-1 ring-primary/15'
123
- : 'text-sidebar-foreground/68 hover:bg-sidebar-accent/65 hover:text-sidebar-foreground'}"
156
+ ? 'text-primary'
157
+ : 'text-sidebar-foreground/68 hover:text-sidebar-foreground'}"
124
158
  data-sidebar={depth === 0 ? "menu-button" : "menu-sub-button"}
125
159
  data-active={active ? "true" : "false"}
126
160
  >
@@ -138,21 +172,21 @@
138
172
  href={finalHref}
139
173
  target={isExternal ? '_blank' : undefined}
140
174
  rel={isExternal ? 'noopener noreferrer' : undefined}
141
- class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-all duration-200
175
+ class="relative flex items-center gap-3 px-3 {depth === 1 ? 'py-1.5' : 'py-2'} text-sm font-medium transition-all duration-200 {depth >= 2 ? 'first:rounded-t-xl last:rounded-b-xl' : 'rounded-xl'}
142
176
  {active
143
- ? 'bg-primary/10 text-primary font-semibold shadow-sm shadow-primary/10 ring-1 ring-primary/15'
144
- : 'text-sidebar-foreground/68 hover:bg-sidebar-accent/65 hover:text-sidebar-foreground'}"
177
+ ? 'text-primary font-semibold'
178
+ : 'text-sidebar-foreground/68 hover:bg-sidebar-accent/45 hover:text-sidebar-foreground'}"
145
179
  style="padding-left: {12 + depth * 12}px"
146
180
  data-sidebar={depth === 0 ? "menu-button" : "menu-sub-button"}
147
181
  data-active={active ? "true" : "false"}
148
182
  >
149
- {#if active && !collapsed}
150
- <div class="absolute left-0 top-1/2 -translate-y-1/2 h-5 w-1 rounded-r-full bg-primary"></div>
151
- {/if}
152
183
  <Icon class="h-4 w-4 flex-shrink-0" />
153
184
  <span class="flex-1">{label}</span>
154
185
  {#if isExternal}
155
186
  <ExternalLink class="h-3 w-3 opacity-50" />
156
187
  {/if}
188
+ {#if badge}
189
+ <span class="rounded-full {active ? 'bg-primary/12 text-primary' : 'bg-sidebar-accent text-sidebar-foreground/60'} px-2 py-0.5 text-[10px] font-semibold">{badge}</span>
190
+ {/if}
157
191
  </a>
158
192
  {/if}
@@ -79,7 +79,7 @@
79
79
  }
80
80
  </script>
81
81
 
82
- <div class="flex min-h-[70vh] items-center justify-center p-4">
82
+ <div class="flex min-h-[70vh] items-center justify-center p-4" data-svadmin-content-page="auth-2fa">
83
83
  <div class="w-full max-w-lg space-y-6">
84
84
  {#if currentStep === 'intro' && !is2faEnabled}
85
85
  <!-- Intro -->
@@ -21,7 +21,7 @@
21
21
  }
22
22
  </script>
23
23
 
24
- <div class="space-y-6">
24
+ <div class="space-y-6" data-svadmin-content-page="account">
25
25
  <div>
26
26
  <h2 class="text-xl font-semibold text-foreground">{t('account.companyProfile')}</h2>
27
27
  <p class="mt-1 text-sm text-muted-foreground">{t('account.companyProfileDescription')}</p>
@@ -47,7 +47,7 @@
47
47
  }
48
48
  </script>
49
49
 
50
- <div class="space-y-6">
50
+ <div class="space-y-6" data-svadmin-content-page="account">
51
51
  <div class="flex items-start justify-between gap-4">
52
52
  <div>
53
53
  <h2 class="text-xl font-semibold text-foreground">{t('account.getStarted')}</h2>
@@ -59,7 +59,7 @@
59
59
  }
60
60
  </script>
61
61
 
62
- <div class="space-y-6">
62
+ <div class="space-y-6" data-svadmin-content-page="account">
63
63
  <div>
64
64
  <h2 class="text-xl font-semibold text-foreground">{t('account.importMembers')}</h2>
65
65
  <p class="mt-1 text-sm text-muted-foreground">{t('account.importMembersDescription')}</p>
@@ -43,7 +43,7 @@
43
43
  const initials = (name: string) => name.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2);
44
44
  </script>
45
45
 
46
- <div class="space-y-6">
46
+ <div class="space-y-6" data-svadmin-content-page="account">
47
47
  <div class="flex items-start justify-between gap-4">
48
48
  <div>
49
49
  <h2 class="text-xl font-semibold text-foreground">{t('account.membersStarter')}</h2>
@@ -43,7 +43,7 @@
43
43
 
44
44
  </script>
45
45
 
46
- <div class="space-y-6">
46
+ <div class="space-y-6" data-svadmin-content-page="account">
47
47
  <div class="flex items-start justify-between gap-4">
48
48
  <div>
49
49
  <h2 class="text-xl font-semibold text-foreground">{t('account.securityLog')}</h2>
@@ -74,7 +74,7 @@
74
74
  <!-- Log table -->
75
75
  <Card.Card class="border-border/60">
76
76
  <Card.CardContent class="p-0">
77
- <div class="overflow-x-auto">
77
+ <div class="hidden overflow-x-auto md:block">
78
78
  <table class="w-full">
79
79
  <thead>
80
80
  <tr class="border-b bg-muted/30">
@@ -103,6 +103,33 @@
103
103
  </tbody>
104
104
  </table>
105
105
  </div>
106
+ <div class="divide-y md:hidden">
107
+ {#each filteredLogs as log (log.id)}
108
+ <div class="space-y-3 p-4">
109
+ <div class="flex items-start justify-between gap-3">
110
+ <div class="flex min-w-0 items-center gap-2">
111
+ <span class="inline-flex h-2 w-2 shrink-0 rounded-full {log.severity === 'critical' ? 'bg-red-500' : log.severity === 'warning' ? 'bg-amber-500' : 'bg-blue-500'}"></span>
112
+ <span class="truncate text-sm font-medium text-foreground">{log.eventLabel}</span>
113
+ </div>
114
+ <span class="shrink-0 text-xs text-muted-foreground">{log.time}</span>
115
+ </div>
116
+ <div class="grid gap-2 text-xs text-muted-foreground">
117
+ <div class="flex items-center justify-between gap-3">
118
+ <span>{t('securityLog.ip')}</span>
119
+ <span class="font-mono text-foreground">{log.ip}</span>
120
+ </div>
121
+ <div class="flex items-center justify-between gap-3">
122
+ <span>{t('securityLog.device')}</span>
123
+ <span class="truncate text-foreground">{log.device}</span>
124
+ </div>
125
+ <div class="flex items-center justify-between gap-3">
126
+ <span>{t('securityLog.location')}</span>
127
+ <span class="truncate text-foreground">{log.location}</span>
128
+ </div>
129
+ </div>
130
+ </div>
131
+ {/each}
132
+ </div>
106
133
  </Card.CardContent>
107
134
  </Card.Card>
108
135
  </div>
@@ -25,7 +25,7 @@
25
25
  }
26
26
  </script>
27
27
 
28
- <div class="space-y-6">
28
+ <div class="space-y-6" data-svadmin-content-page="account">
29
29
  <div class="flex items-start justify-between gap-4">
30
30
  <div>
31
31
  <h2 class="text-xl font-semibold text-foreground">{t('account.settingsEnterprise')}</h2>
@@ -22,7 +22,7 @@
22
22
  }
23
23
  </script>
24
24
 
25
- <div class="space-y-6">
25
+ <div class="space-y-6" data-svadmin-content-page="account">
26
26
  <div>
27
27
  <h2 class="text-xl font-semibold text-foreground">{t('account.settingsPlain')}</h2>
28
28
  <p class="mt-1 text-sm text-muted-foreground">{t('account.settingsPlainDescription')}</p>
@@ -21,7 +21,7 @@
21
21
  }
22
22
  </script>
23
23
 
24
- <div class="space-y-6">
24
+ <div class="space-y-6" data-svadmin-content-page="account">
25
25
  <div>
26
26
  <h2 class="text-xl font-semibold text-foreground">{t('account.settingsSidebar')}</h2>
27
27
  <p class="mt-1 text-sm text-muted-foreground">{t('account.settingsSidebarDescription')}</p>
@@ -48,7 +48,7 @@
48
48
  const initials = (name: string) => name.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2);
49
49
  </script>
50
50
 
51
- <div class="space-y-6">
51
+ <div class="space-y-6" data-svadmin-content-page="account">
52
52
  <div class="flex items-start justify-between gap-4">
53
53
  <div>
54
54
  <h2 class="text-xl font-semibold text-foreground">{t('account.membersStarter')}</h2>
@@ -45,7 +45,7 @@
45
45
  const initials = (name: string) => name.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2);
46
46
  </script>
47
47
 
48
- <div class="space-y-6">
48
+ <div class="space-y-6" data-svadmin-content-page="network">
49
49
  <div class="flex items-start justify-between gap-4">
50
50
  <div>
51
51
  <h2 class="text-xl font-semibold text-foreground">{t('network.teamCrew')}</h2>
@@ -69,7 +69,7 @@
69
69
  <!-- Table -->
70
70
  <Card.Card class="border-border/60">
71
71
  <Card.CardContent class="p-0">
72
- <div class="overflow-x-auto">
72
+ <div class="hidden overflow-x-auto lg:block">
73
73
  <table class="w-full">
74
74
  <thead>
75
75
  <tr class="border-b bg-muted/30">
@@ -117,6 +117,39 @@
117
117
  </tbody>
118
118
  </table>
119
119
  </div>
120
+ <div class="divide-y lg:hidden">
121
+ {#each filtered as member (member.id)}
122
+ {@const sc = statusConfig[member.status]}
123
+ <div class="space-y-3 p-4">
124
+ <div class="flex items-start justify-between gap-3">
125
+ <div class="flex min-w-0 items-center gap-3">
126
+ <div class="relative shrink-0">
127
+ <div class="flex h-9 w-9 items-center justify-center rounded-full bg-primary/10 text-sm font-semibold text-primary">
128
+ {initials(member.name)}
129
+ </div>
130
+ <span class="absolute -bottom-0.5 -right-0.5 h-2.5 w-2.5 rounded-full {sc.dot} ring-2 ring-card"></span>
131
+ </div>
132
+ <div class="min-w-0">
133
+ <p class="truncate text-sm font-medium text-foreground">{member.name}</p>
134
+ <p class="truncate text-xs text-muted-foreground">{member.email}</p>
135
+ </div>
136
+ </div>
137
+ <Button variant="ghost" size="icon-sm" class="shrink-0"><MoreHorizontal class="h-4 w-4" /></Button>
138
+ </div>
139
+ <div class="grid gap-2 text-xs text-muted-foreground sm:grid-cols-2">
140
+ <div class="min-w-0">
141
+ <span class="block font-medium text-foreground">{member.role}</span>
142
+ <span class="truncate">{member.department}</span>
143
+ </div>
144
+ <div class="flex items-center gap-1 {sc.color}">
145
+ <sc.icon class="h-3 w-3" />{sc.label}
146
+ </div>
147
+ <div>{t('publicProfile.projects')}: <span class="font-medium text-foreground">{member.projects}</span></div>
148
+ <div>{t('account.joined')}: <span class="font-medium text-foreground">{member.joinedAt}</span></div>
149
+ </div>
150
+ </div>
151
+ {/each}
152
+ </div>
120
153
  </Card.CardContent>
121
154
  </Card.Card>
122
155
  </div>
@@ -51,7 +51,7 @@
51
51
  }
52
52
  </script>
53
53
 
54
- <div class="space-y-6">
54
+ <div class="space-y-6" data-svadmin-content-page="network">
55
55
  <div>
56
56
  <h2 class="text-xl font-semibold text-foreground">{t('network.userCards')}</h2>
57
57
  <p class="mt-1 text-sm text-muted-foreground">{t('network.userCardsDescription')}</p>
@@ -99,7 +99,7 @@
99
99
  ];
100
100
  </script>
101
101
 
102
- <div class="space-y-6">
102
+ <div class="space-y-6" data-svadmin-content-page="public-profile">
103
103
  <!-- Cover + Profile Header -->
104
104
  <Card.Card class="overflow-hidden border-border/60">
105
105
  <div class="h-40 bg-gradient-to-r from-primary/25 via-primary/15 to-accent/20 relative">
@@ -6,7 +6,7 @@
6
6
  let { class: className, ...restProps }: HTMLAttributes<HTMLSpanElement> = $props();
7
7
  </script>
8
8
 
9
- <span aria-hidden="true" data-slot="pagination-ellipsis" class={cn("flex size-9 items-center justify-center", className)} {...restProps}>
9
+ <span aria-hidden="true" data-slot="pagination-ellipsis" class={cn("flex size-8 items-center justify-center", className)} {...restProps}>
10
10
  <Ellipsis class="size-4" />
11
11
  <span class="sr-only">More pages</span>
12
12
  </span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/ui",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -33,7 +33,7 @@
33
33
  "./components/*": "./dist/components/*"
34
34
  },
35
35
  "peerDependencies": {
36
- "@svadmin/core": "^0.28.0",
36
+ "@svadmin/core": "^0.29.0",
37
37
  "@tanstack/svelte-query": "^6.1.29",
38
38
  "highlight.js": "^11.11.1",
39
39
  "isomorphic-dompurify": "^3.15.0",