@svadmin/ui 0.50.0 → 0.51.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/components/AutoTable.svelte +223 -106
- package/dist/components/AutoTable.svelte.d.ts +5 -0
- package/dist/components/ListPage.svelte +16 -2
- package/dist/components/ListPage.svelte.d.ts +7 -1
- package/dist/components/ShowPage.svelte +65 -23
- package/dist/components/ShowPage.svelte.d.ts +3 -0
- package/dist/components/buttons/CloneButton.svelte +23 -2
- package/dist/components/buttons/CloneButton.svelte.d.ts +3 -0
- package/dist/components/buttons/CreateButton.svelte +22 -2
- package/dist/components/buttons/CreateButton.svelte.d.ts +3 -0
- package/dist/components/buttons/DeleteButton.svelte +23 -3
- package/dist/components/buttons/DeleteButton.svelte.d.ts +3 -0
- package/dist/components/buttons/EditButton.svelte +23 -2
- package/dist/components/buttons/EditButton.svelte.d.ts +3 -0
- package/dist/components/buttons/ExportButton.svelte +22 -3
- package/dist/components/buttons/ExportButton.svelte.d.ts +3 -0
- package/dist/components/buttons/ImportButton.svelte +39 -17
- package/dist/components/buttons/ImportButton.svelte.d.ts +3 -0
- package/dist/components/buttons/ListButton.svelte +13 -2
- package/dist/components/buttons/ListButton.svelte.d.ts +2 -0
- package/dist/components/buttons/RefreshButton.svelte +22 -2
- package/dist/components/buttons/RefreshButton.svelte.d.ts +3 -0
- package/dist/components/buttons/SaveButton.svelte +23 -2
- package/dist/components/buttons/SaveButton.svelte.d.ts +3 -0
- package/dist/components/buttons/ShowButton.svelte +24 -3
- package/dist/components/buttons/ShowButton.svelte.d.ts +3 -0
- package/dist/components/content/DescriptionList.svelte +125 -15
- package/dist/components/content/DescriptionList.svelte.d.ts +6 -2
- package/package.json +2 -2
|
@@ -1,27 +1,137 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { cn } from '../../utils.js';
|
|
3
|
+
|
|
2
4
|
export interface DescriptionItem {
|
|
3
5
|
label: string;
|
|
4
|
-
value:
|
|
6
|
+
value: unknown;
|
|
5
7
|
description?: string;
|
|
6
8
|
href?: string;
|
|
9
|
+
span?: number;
|
|
7
10
|
}
|
|
11
|
+
|
|
8
12
|
interface Props {
|
|
9
13
|
items?: DescriptionItem[];
|
|
10
|
-
columns?: 1 | 2;
|
|
14
|
+
columns?: 1 | 2 | 3 | 4;
|
|
15
|
+
layout?: 'vertical' | 'horizontal';
|
|
16
|
+
bordered?: boolean;
|
|
17
|
+
density?: 'compact' | 'comfortable';
|
|
11
18
|
class?: string;
|
|
12
19
|
}
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
items = [],
|
|
23
|
+
columns = 1,
|
|
24
|
+
layout = 'vertical',
|
|
25
|
+
bordered = false,
|
|
26
|
+
density = 'comfortable',
|
|
27
|
+
class: className = '',
|
|
28
|
+
}: Props = $props();
|
|
29
|
+
|
|
30
|
+
const isCompact = $derived(density === 'compact');
|
|
31
|
+
const isHorizontal = $derived(layout === 'horizontal');
|
|
32
|
+
|
|
33
|
+
function spanClass(span: number | undefined): string {
|
|
34
|
+
if (!span || span <= 1) return '';
|
|
35
|
+
if (span >= 4) return 'sm:col-span-4';
|
|
36
|
+
if (span === 3) return 'sm:col-span-3';
|
|
37
|
+
return 'sm:col-span-2';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const columnClass = $derived.by(() => {
|
|
41
|
+
switch (columns) {
|
|
42
|
+
case 4:
|
|
43
|
+
return 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4';
|
|
44
|
+
case 3:
|
|
45
|
+
return 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3';
|
|
46
|
+
case 2:
|
|
47
|
+
return 'grid-cols-1 sm:grid-cols-2';
|
|
48
|
+
default:
|
|
49
|
+
return 'grid-cols-1';
|
|
50
|
+
}
|
|
51
|
+
});
|
|
15
52
|
</script>
|
|
16
53
|
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
{#if bordered}
|
|
55
|
+
<div class={cn('overflow-hidden rounded-lg border border-border bg-card text-foreground', className)}>
|
|
56
|
+
<dl class={cn('grid divide-y divide-border/60 sm:divide-y-0', columnClass)}>
|
|
57
|
+
{#each items as item (item.label)}
|
|
58
|
+
<div
|
|
59
|
+
class={cn(
|
|
60
|
+
'flex flex-col border-b border-r border-border/40 last:border-b-0',
|
|
61
|
+
isHorizontal ? 'sm:flex-row' : '',
|
|
62
|
+
spanClass(Math.min(item.span ?? 1, columns)),
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
<dt
|
|
66
|
+
class={cn(
|
|
67
|
+
'bg-muted/30 font-medium text-muted-foreground shrink-0 border-b sm:border-b-0 sm:border-r border-border/30',
|
|
68
|
+
isCompact ? 'px-3 py-1.5 text-xs' : 'px-4 py-2.5 text-xs sm:text-sm',
|
|
69
|
+
isHorizontal ? 'sm:w-1/3' : '',
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
{item.label}
|
|
73
|
+
</dt>
|
|
74
|
+
<dd
|
|
75
|
+
class={cn(
|
|
76
|
+
'break-words font-medium text-foreground bg-card flex-1 min-w-0',
|
|
77
|
+
isCompact ? 'px-3 py-1.5 text-xs' : 'px-4 py-2.5 text-xs sm:text-sm',
|
|
78
|
+
)}
|
|
79
|
+
>
|
|
80
|
+
{#if item.href}
|
|
81
|
+
<a class="text-primary underline-offset-4 hover:underline" href={item.href}>{String(item.value ?? '—')}</a>
|
|
82
|
+
{:else}
|
|
83
|
+
{item.value != null ? String(item.value) : '—'}
|
|
84
|
+
{/if}
|
|
85
|
+
{#if item.description}
|
|
86
|
+
<p class="mt-0.5 text-xs font-normal text-muted-foreground">{item.description}</p>
|
|
87
|
+
{/if}
|
|
88
|
+
</dd>
|
|
89
|
+
</div>
|
|
90
|
+
{/each}
|
|
91
|
+
</dl>
|
|
92
|
+
</div>
|
|
93
|
+
{:else}
|
|
94
|
+
<dl
|
|
95
|
+
class={cn(
|
|
96
|
+
'grid',
|
|
97
|
+
columnClass,
|
|
98
|
+
isCompact ? 'gap-x-4 gap-y-3' : 'gap-x-6 gap-y-5',
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
>
|
|
102
|
+
{#each items as item (item.label)}
|
|
103
|
+
<div
|
|
104
|
+
class={cn(
|
|
105
|
+
'min-w-0',
|
|
106
|
+
isHorizontal ? 'flex items-baseline gap-2' : '',
|
|
107
|
+
spanClass(Math.min(item.span ?? 1, columns)),
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
<dt
|
|
111
|
+
class={cn(
|
|
112
|
+
'font-medium text-muted-foreground',
|
|
113
|
+
isCompact ? 'text-xs' : 'text-xs',
|
|
114
|
+
isHorizontal ? 'shrink-0 min-w-20' : '',
|
|
115
|
+
)}
|
|
116
|
+
>
|
|
117
|
+
{item.label}
|
|
118
|
+
</dt>
|
|
119
|
+
<dd
|
|
120
|
+
class={cn(
|
|
121
|
+
'break-words font-medium text-foreground min-w-0 flex-1',
|
|
122
|
+
isHorizontal ? 'text-xs sm:text-sm' : isCompact ? 'mt-0.5 text-xs sm:text-sm' : 'mt-1 text-sm',
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
{#if item.href}
|
|
126
|
+
<a class="text-primary underline-offset-4 hover:underline" href={item.href}>{String(item.value ?? '—')}</a>
|
|
127
|
+
{:else}
|
|
128
|
+
{item.value != null ? String(item.value) : '—'}
|
|
129
|
+
{/if}
|
|
130
|
+
{#if item.description}
|
|
131
|
+
<p class="mt-1 text-xs font-normal text-muted-foreground">{item.description}</p>
|
|
132
|
+
{/if}
|
|
133
|
+
</dd>
|
|
134
|
+
</div>
|
|
135
|
+
{/each}
|
|
136
|
+
</dl>
|
|
137
|
+
{/if}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
export interface DescriptionItem {
|
|
2
2
|
label: string;
|
|
3
|
-
value:
|
|
3
|
+
value: unknown;
|
|
4
4
|
description?: string;
|
|
5
5
|
href?: string;
|
|
6
|
+
span?: number;
|
|
6
7
|
}
|
|
7
8
|
interface Props {
|
|
8
9
|
items?: DescriptionItem[];
|
|
9
|
-
columns?: 1 | 2;
|
|
10
|
+
columns?: 1 | 2 | 3 | 4;
|
|
11
|
+
layout?: 'vertical' | 'horizontal';
|
|
12
|
+
bordered?: boolean;
|
|
13
|
+
density?: 'compact' | 'comfortable';
|
|
10
14
|
class?: string;
|
|
11
15
|
}
|
|
12
16
|
declare const DescriptionList: import("svelte").Component<Props, {}, "">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"./components/*": "./dist/components/*"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@svadmin/core": "^0.
|
|
42
|
+
"@svadmin/core": "^0.41.0",
|
|
43
43
|
"@tanstack/svelte-query": "^6.1.38",
|
|
44
44
|
"highlight.js": "^11.11.1",
|
|
45
45
|
"isomorphic-dompurify": "^3.22.0",
|