@svadmin/ui 0.50.0 → 0.52.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/AuditTimeline.svelte +86 -0
- package/dist/components/content/AuditTimeline.svelte.d.ts +20 -0
- package/dist/components/content/DescriptionList.svelte +125 -15
- package/dist/components/content/DescriptionList.svelte.d.ts +6 -2
- package/dist/components/content/index.d.ts +2 -0
- package/dist/components/content/index.js +1 -0
- package/dist/components/fields/BooleanField.svelte +90 -8
- package/dist/components/fields/BooleanField.svelte.d.ts +8 -0
- package/dist/components/fields/DateField.svelte +74 -4
- package/dist/components/fields/DateField.svelte.d.ts +4 -0
- package/dist/components/fields/NumberField.svelte +72 -4
- package/dist/components/fields/NumberField.svelte.d.ts +9 -0
- package/dist/components/fields/TagField.svelte +90 -6
- package/dist/components/fields/TagField.svelte.d.ts +9 -0
- package/dist/components/fields/UrlField.svelte +43 -7
- package/dist/components/fields/UrlField.svelte.d.ts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -1,12 +1,96 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type TagTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
1
5
|
<script lang="ts">
|
|
2
6
|
import { Badge } from '../ui/badge/index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
import { cn } from '../../utils.js';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
value: string | string[] | null | undefined;
|
|
11
|
+
colorMap?: Record<string, TagTone | string>;
|
|
12
|
+
tone?: TagTone;
|
|
13
|
+
variant?: 'secondary' | 'outline' | 'default' | 'destructive';
|
|
14
|
+
size?: 'sm' | 'default';
|
|
15
|
+
clickable?: boolean;
|
|
16
|
+
onclick?: (tag: string) => void;
|
|
17
|
+
nullLabel?: string;
|
|
18
|
+
class?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
value,
|
|
23
|
+
colorMap,
|
|
24
|
+
tone,
|
|
25
|
+
variant = 'secondary',
|
|
26
|
+
size = 'default',
|
|
27
|
+
clickable = false,
|
|
28
|
+
onclick,
|
|
29
|
+
nullLabel = '—',
|
|
30
|
+
class: className = '',
|
|
31
|
+
}: Props = $props();
|
|
32
|
+
|
|
33
|
+
const toneClass: Record<TagTone, string> = {
|
|
34
|
+
success: 'border-success/30 bg-success/10 text-success',
|
|
35
|
+
warning: 'border-warning/30 bg-warning/10 text-warning-foreground',
|
|
36
|
+
danger: 'border-destructive/30 bg-destructive/10 text-destructive',
|
|
37
|
+
info: 'border-primary/30 bg-primary/10 text-primary',
|
|
38
|
+
neutral: 'border-border bg-muted text-muted-foreground',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const tags = $derived(
|
|
42
|
+
Array.isArray(value)
|
|
43
|
+
? value.filter((t): t is string => t != null && t !== '')
|
|
44
|
+
: value != null && value !== ''
|
|
45
|
+
? [String(value)]
|
|
46
|
+
: []
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
function resolveTagClass(tag: string): string {
|
|
50
|
+
const mapped = colorMap?.[tag] ?? tone;
|
|
51
|
+
if (mapped && mapped in toneClass) {
|
|
52
|
+
return toneClass[mapped as TagTone];
|
|
53
|
+
}
|
|
54
|
+
if (typeof mapped === 'string') {
|
|
55
|
+
return mapped;
|
|
56
|
+
}
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
6
59
|
</script>
|
|
7
|
-
|
|
60
|
+
|
|
61
|
+
<span class={cn('inline-flex flex-wrap gap-1 items-center', className)}>
|
|
8
62
|
{#each tags as tag, _i (_i)}
|
|
9
|
-
|
|
63
|
+
{@const customClass = resolveTagClass(tag)}
|
|
64
|
+
{#if clickable || onclick}
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
onclick={() => onclick?.(tag)}
|
|
68
|
+
class="focus:outline-none focus:ring-1 focus:ring-ring rounded"
|
|
69
|
+
>
|
|
70
|
+
<Badge
|
|
71
|
+
variant={customClass ? 'outline' : variant}
|
|
72
|
+
class={cn(
|
|
73
|
+
'transition-colors cursor-pointer hover:opacity-80',
|
|
74
|
+
size === 'sm' ? 'px-1.5 py-0 text-[11px] h-5' : '',
|
|
75
|
+
customClass
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
{tag}
|
|
79
|
+
</Badge>
|
|
80
|
+
</button>
|
|
81
|
+
{:else}
|
|
82
|
+
<Badge
|
|
83
|
+
variant={customClass ? 'outline' : variant}
|
|
84
|
+
class={cn(
|
|
85
|
+
size === 'sm' ? 'px-1.5 py-0 text-[11px] h-5' : '',
|
|
86
|
+
customClass
|
|
87
|
+
)}
|
|
88
|
+
>
|
|
89
|
+
{tag}
|
|
90
|
+
</Badge>
|
|
91
|
+
{/if}
|
|
10
92
|
{/each}
|
|
11
|
-
{#if tags.length === 0}
|
|
93
|
+
{#if tags.length === 0}
|
|
94
|
+
<span class="text-muted-foreground">{nullLabel}</span>
|
|
95
|
+
{/if}
|
|
12
96
|
</span>
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
export type TagTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
1
2
|
interface Props {
|
|
2
3
|
value: string | string[] | null | undefined;
|
|
4
|
+
colorMap?: Record<string, TagTone | string>;
|
|
5
|
+
tone?: TagTone;
|
|
6
|
+
variant?: 'secondary' | 'outline' | 'default' | 'destructive';
|
|
7
|
+
size?: 'sm' | 'default';
|
|
8
|
+
clickable?: boolean;
|
|
9
|
+
onclick?: (tag: string) => void;
|
|
10
|
+
nullLabel?: string;
|
|
11
|
+
class?: string;
|
|
3
12
|
}
|
|
4
13
|
declare const TagField: import("svelte").Component<Props, {}, "">;
|
|
5
14
|
type TagField = ReturnType<typeof TagField>;
|
|
@@ -1,14 +1,50 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ExternalLink } from '@lucide/svelte';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
value: string | null | undefined;
|
|
7
|
+
label?: string;
|
|
8
|
+
target?: string;
|
|
9
|
+
maxDisplayLength?: number;
|
|
10
|
+
showIcon?: boolean;
|
|
11
|
+
nullLabel?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
value,
|
|
17
|
+
label,
|
|
18
|
+
target = '_blank',
|
|
19
|
+
maxDisplayLength = 40,
|
|
20
|
+
showIcon = true,
|
|
21
|
+
nullLabel = '—',
|
|
22
|
+
class: className = '',
|
|
23
|
+
}: Props = $props();
|
|
24
|
+
|
|
25
|
+
const display = $derived.by(() => {
|
|
26
|
+
if (label) return label;
|
|
27
|
+
if (!value) return '';
|
|
28
|
+
if (maxDisplayLength && value.length > maxDisplayLength) {
|
|
29
|
+
return value.slice(0, maxDisplayLength) + '…';
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
});
|
|
6
33
|
</script>
|
|
34
|
+
|
|
7
35
|
{#if value}
|
|
8
|
-
<a
|
|
9
|
-
{
|
|
10
|
-
|
|
36
|
+
<a
|
|
37
|
+
href={value}
|
|
38
|
+
{target}
|
|
39
|
+
rel="noopener noreferrer"
|
|
40
|
+
class={cn('text-primary hover:underline inline-flex items-center gap-1 text-sm font-medium', className)}
|
|
41
|
+
title={value}
|
|
42
|
+
>
|
|
43
|
+
<span>{display}</span>
|
|
44
|
+
{#if showIcon}
|
|
45
|
+
<ExternalLink class="h-3 w-3 shrink-0 opacity-60" />
|
|
46
|
+
{/if}
|
|
11
47
|
</a>
|
|
12
48
|
{:else}
|
|
13
|
-
<span class="text-muted-foreground"
|
|
49
|
+
<span class="text-muted-foreground">{nullLabel}</span>
|
|
14
50
|
{/if}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
interface Props {
|
|
2
2
|
value: string | null | undefined;
|
|
3
3
|
label?: string;
|
|
4
|
+
target?: string;
|
|
5
|
+
maxDisplayLength?: number;
|
|
6
|
+
showIcon?: boolean;
|
|
7
|
+
nullLabel?: string;
|
|
8
|
+
class?: string;
|
|
4
9
|
}
|
|
5
10
|
declare const UrlField: import("svelte").Component<Props, {}, "">;
|
|
6
11
|
type UrlField = ReturnType<typeof UrlField>;
|
package/dist/index.d.ts
CHANGED
|
@@ -204,3 +204,8 @@ export type { DemoMember, DemoProject, DemoTeam, DemoIntegration, DemoApiKey, De
|
|
|
204
204
|
export { default as RowActions } from './components/RowActions.svelte';
|
|
205
205
|
export type { RowActionItem } from './components/RowActions.svelte';
|
|
206
206
|
export { default as DetailDrawer } from './components/DetailDrawer.svelte';
|
|
207
|
+
export { default as AuditTimeline } from './components/content/AuditTimeline.svelte';
|
|
208
|
+
export type { TimelineItem } from './components/content/AuditTimeline.svelte';
|
|
209
|
+
export type { TagTone } from './components/fields/TagField.svelte';
|
|
210
|
+
export type { BooleanTone } from './components/fields/BooleanField.svelte';
|
|
211
|
+
export type { DateFieldFormat } from './components/fields/DateField.svelte';
|
package/dist/index.js
CHANGED
|
@@ -202,3 +202,4 @@ export { default as SystemErrorState } from './components/content/SystemErrorSta
|
|
|
202
202
|
export { referenceDemoData } from './reference-data.js';
|
|
203
203
|
export { default as RowActions } from './components/RowActions.svelte';
|
|
204
204
|
export { default as DetailDrawer } from './components/DetailDrawer.svelte';
|
|
205
|
+
export { default as AuditTimeline } from './components/content/AuditTimeline.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svadmin/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.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",
|