@svadmin/ui 0.111.0 → 0.113.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 +216 -0
- package/dist/app.theme.css +216 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AutoForm.svelte +24 -35
- package/dist/components/FormDependency.svelte +36 -0
- package/dist/components/FormDependency.svelte.d.ts +12 -0
- package/dist/components/Icon.svelte +57 -0
- package/dist/components/Icon.svelte.d.ts +10 -0
- package/dist/components/JsonSchemaForm.svelte +68 -10
- package/dist/components/PageContainer.svelte +263 -0
- package/dist/components/PageContainer.svelte.d.ts +53 -0
- package/dist/components/ProDescriptions.svelte +278 -0
- package/dist/components/ProDescriptions.svelte.d.ts +37 -0
- package/dist/components/QueryFilter.svelte +194 -0
- package/dist/components/QueryFilter.svelte.d.ts +34 -0
- package/dist/components/RealtimeMonitorView.svelte +245 -0
- package/dist/components/RealtimeMonitorView.svelte.d.ts +40 -0
- package/dist/components/RoleSwitcher.svelte +267 -0
- package/dist/components/RoleSwitcher.svelte.d.ts +40 -0
- package/dist/components/WorkflowDesigner.svelte +244 -0
- package/dist/components/WorkflowDesigner.svelte.d.ts +29 -0
- package/dist/components/auto-form-layout.d.ts +28 -0
- package/dist/components/auto-form-layout.js +70 -0
- package/dist/components/fields/UploadField.svelte +222 -0
- package/dist/components/fields/UploadField.svelte.d.ts +14 -0
- package/dist/components/icons/IconApprove.svelte +35 -0
- package/dist/components/icons/IconApprove.svelte.d.ts +4 -0
- package/dist/components/icons/IconAudit.svelte +38 -0
- package/dist/components/icons/IconAudit.svelte.d.ts +4 -0
- package/dist/components/icons/IconBilling.svelte +37 -0
- package/dist/components/icons/IconBilling.svelte.d.ts +4 -0
- package/dist/components/icons/IconCluster.svelte +41 -0
- package/dist/components/icons/IconCluster.svelte.d.ts +4 -0
- package/dist/components/icons/IconMonitor.svelte +37 -0
- package/dist/components/icons/IconMonitor.svelte.d.ts +4 -0
- package/dist/components/icons/IconReject.svelte +36 -0
- package/dist/components/icons/IconReject.svelte.d.ts +4 -0
- package/dist/components/icons/IconSeal.svelte +36 -0
- package/dist/components/icons/IconSeal.svelte.d.ts +4 -0
- package/dist/components/icons/IconSecurity.svelte +35 -0
- package/dist/components/icons/IconSecurity.svelte.d.ts +4 -0
- package/dist/components/icons/IconTenant.svelte +39 -0
- package/dist/components/icons/IconTenant.svelte.d.ts +4 -0
- package/dist/components/icons/IconWorkflow.svelte +38 -0
- package/dist/components/icons/IconWorkflow.svelte.d.ts +4 -0
- package/dist/components/icons/index.d.ts +11 -0
- package/dist/components/icons/index.js +10 -0
- package/dist/components/icons/types.d.ts +15 -0
- package/dist/components/icons/types.js +1 -0
- package/dist/components/json-schema-form-state.d.ts +3 -1
- package/dist/icon-registry.d.ts +27 -0
- package/dist/icon-registry.js +52 -0
- package/dist/icons.d.ts +5 -1
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +27 -7
- package/dist/index.js +19 -6
- package/dist/intent-preload.d.ts +28 -0
- package/dist/intent-preload.js +76 -0
- package/package.json +5 -5
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* `<Icon name>` renders, in order: a registered component, a sprite symbol, or
|
|
4
|
+
* a remote SVG. Sprite output is server-rendered `<svg><use>`, so SSR and CSP
|
|
5
|
+
* behave like any other inline SVG (no runtime style injection).
|
|
6
|
+
*/
|
|
7
|
+
import { resolveIcon, resolveIconSource } from '../icons.js';
|
|
8
|
+
import { cn } from '../utils.js';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
name: string;
|
|
12
|
+
size?: number | string;
|
|
13
|
+
/** Accessible name; omit for decorative icons. */
|
|
14
|
+
label?: string;
|
|
15
|
+
class?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let { name, size = 16, label, class: className }: Props = $props();
|
|
19
|
+
|
|
20
|
+
const icon = $derived(resolveIcon(name));
|
|
21
|
+
const source = $derived(icon ? undefined : resolveIconSource(name));
|
|
22
|
+
const spriteHref = $derived(source?.type === 'sprite'
|
|
23
|
+
? `${source.url}#${source.symbolPrefix ?? ''}${name}`
|
|
24
|
+
: undefined);
|
|
25
|
+
const remoteUrl = $derived(source?.type === 'remote-svg'
|
|
26
|
+
? source.urlTemplate.replace('{name}', encodeURIComponent(name))
|
|
27
|
+
: undefined);
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
{#if icon}
|
|
31
|
+
{@const ResolvedIcon = icon}
|
|
32
|
+
<ResolvedIcon {size} class={className} aria-hidden={label ? undefined : 'true'} aria-label={label} />
|
|
33
|
+
{:else if spriteHref}
|
|
34
|
+
<svg
|
|
35
|
+
class={cn('inline-block shrink-0', className)}
|
|
36
|
+
width={size}
|
|
37
|
+
height={size}
|
|
38
|
+
viewBox="0 0 24 24"
|
|
39
|
+
role={label ? 'img' : undefined}
|
|
40
|
+
aria-label={label}
|
|
41
|
+
aria-hidden={label ? undefined : 'true'}
|
|
42
|
+
focusable="false"
|
|
43
|
+
>
|
|
44
|
+
<use href={spriteHref} />
|
|
45
|
+
</svg>
|
|
46
|
+
{:else if remoteUrl}
|
|
47
|
+
<img
|
|
48
|
+
class={cn('inline-block shrink-0', className)}
|
|
49
|
+
src={remoteUrl}
|
|
50
|
+
width={size}
|
|
51
|
+
height={size}
|
|
52
|
+
alt={label ?? ''}
|
|
53
|
+
aria-hidden={label ? undefined : 'true'}
|
|
54
|
+
loading="lazy"
|
|
55
|
+
decoding="async"
|
|
56
|
+
/>
|
|
57
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
name: string;
|
|
3
|
+
size?: number | string;
|
|
4
|
+
/** Accessible name; omit for decorative icons. */
|
|
5
|
+
label?: string;
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const Icon: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type Icon = ReturnType<typeof Icon>;
|
|
10
|
+
export default Icon;
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
assertSchemaFormSchema,
|
|
5
5
|
isSchemaFormNodeVisible,
|
|
6
6
|
prepareSchemaFormValue,
|
|
7
|
+
resolveSchemaFormLayout,
|
|
8
|
+
type SchemaFormLayoutGroup,
|
|
9
|
+
type SchemaFormLayoutPlan,
|
|
7
10
|
type SchemaFormSchema,
|
|
8
11
|
} from '@svadmin/core/schema-form';
|
|
9
12
|
import { tick } from 'svelte';
|
|
@@ -175,6 +178,48 @@
|
|
|
175
178
|
return undefined;
|
|
176
179
|
}
|
|
177
180
|
});
|
|
181
|
+
// Layout plans are pure and per-node; cache so re-renders stay cheap.
|
|
182
|
+
const layoutPlans = new WeakMap<SchemaFormSchema, SchemaFormLayoutPlan>();
|
|
183
|
+
function layoutPlan(node: JsonSchema): SchemaFormLayoutPlan | undefined {
|
|
184
|
+
if (!coreSchema) return undefined;
|
|
185
|
+
const key = node as SchemaFormSchema;
|
|
186
|
+
const cached = layoutPlans.get(key);
|
|
187
|
+
if (cached) return cached;
|
|
188
|
+
try {
|
|
189
|
+
const plan = resolveSchemaFormLayout(key);
|
|
190
|
+
layoutPlans.set(key, plan);
|
|
191
|
+
return plan;
|
|
192
|
+
} catch {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const gridClasses: Record<1 | 2 | 3 | 4, string> = {
|
|
197
|
+
1: 'space-y-3.5',
|
|
198
|
+
2: 'grid grid-cols-1 gap-3.5 md:grid-cols-2',
|
|
199
|
+
3: 'grid grid-cols-1 gap-3.5 md:grid-cols-2 lg:grid-cols-3',
|
|
200
|
+
4: 'grid grid-cols-1 gap-3.5 md:grid-cols-2 lg:grid-cols-4',
|
|
201
|
+
};
|
|
202
|
+
const spanClasses: Record<1 | 2 | 3 | 4, string> = {
|
|
203
|
+
1: '',
|
|
204
|
+
2: 'md:col-span-2',
|
|
205
|
+
3: 'md:col-span-2 lg:col-span-3',
|
|
206
|
+
4: 'md:col-span-2 lg:col-span-4',
|
|
207
|
+
};
|
|
208
|
+
function layoutGroups(node: JsonSchema): readonly SchemaFormLayoutGroup[] {
|
|
209
|
+
const plan = layoutPlan(node);
|
|
210
|
+
if (plan) return plan.groups;
|
|
211
|
+
return [{
|
|
212
|
+
key: '',
|
|
213
|
+
columns: 1,
|
|
214
|
+
fields: Object.keys(node.properties ?? {}).map((fieldKey) => ({ key: fieldKey, span: 1 })),
|
|
215
|
+
}];
|
|
216
|
+
}
|
|
217
|
+
function columnsClass(columns: number): string {
|
|
218
|
+
return gridClasses[(columns as 1 | 2 | 3 | 4)] ?? gridClasses[1];
|
|
219
|
+
}
|
|
220
|
+
function spanClass(span: number): string {
|
|
221
|
+
return spanClasses[(span as 1 | 2 | 3 | 4)] ?? '';
|
|
222
|
+
}
|
|
178
223
|
const locked = $derived(disabled || readonly || isSubmitting || !prepared.ok);
|
|
179
224
|
let reportedConfiguration = '';
|
|
180
225
|
let reportedSchema: JsonSchema | undefined;
|
|
@@ -520,11 +565,7 @@
|
|
|
520
565
|
<legend class="block font-medium">{title}</legend>
|
|
521
566
|
{#if error}<p id={errorId}>{i18n.t('validation.invalidFormat')}</p>{/if}
|
|
522
567
|
{#if node.description}<p id={descriptionId} class="text-[11px] text-muted-foreground">{node.description}</p>{/if}
|
|
523
|
-
|
|
524
|
-
{#each Object.entries(node.properties ?? {}) as [key, child] (key)}
|
|
525
|
-
{@render renderField(child, compiled?.kind === 'object' ? compiled.properties[key] : undefined, [...path, key], child.title ?? key, node.required?.includes(key) ?? false)}
|
|
526
|
-
{/each}
|
|
527
|
-
</div>
|
|
568
|
+
{@render renderObjectGroups(node, compiled, path)}
|
|
528
569
|
</fieldset>
|
|
529
570
|
{:else if type === 'array'}
|
|
530
571
|
{@const items = Array.isArray(current) ? current : []}
|
|
@@ -569,16 +610,33 @@
|
|
|
569
610
|
{/if}
|
|
570
611
|
{/snippet}
|
|
571
612
|
|
|
613
|
+
{#snippet renderObjectGroups(node: JsonSchema, compiled: RecursiveSchemaFormNode | undefined, path: string[])}
|
|
614
|
+
{#each layoutGroups(node) as group (group.key)}
|
|
615
|
+
<div class="space-y-2">
|
|
616
|
+
{#if group.title}
|
|
617
|
+
<h3 class="text-xs font-semibold uppercase tracking-wide text-muted-foreground">{group.title}</h3>
|
|
618
|
+
{#if group.description}<p class="text-[11px] text-muted-foreground">{group.description}</p>{/if}
|
|
619
|
+
{/if}
|
|
620
|
+
<div class={columnsClass(group.columns)} data-svadmin-form-group={group.key}>
|
|
621
|
+
{#each group.fields as field (field.key)}
|
|
622
|
+
{@const child = node.properties?.[field.key]}
|
|
623
|
+
{#if child}
|
|
624
|
+
<div class={spanClass(field.span)}>
|
|
625
|
+
{@render renderField(child, compiled?.kind === 'object' ? compiled.properties[field.key] : undefined, [...path, field.key], child.title ?? field.key, node.required?.includes(field.key) ?? false)}
|
|
626
|
+
</div>
|
|
627
|
+
{/if}
|
|
628
|
+
{/each}
|
|
629
|
+
</div>
|
|
630
|
+
</div>
|
|
631
|
+
{/each}
|
|
632
|
+
{/snippet}
|
|
633
|
+
|
|
572
634
|
<fieldset class="schema-form-fields space-y-4" disabled={locked}>
|
|
573
635
|
{#if prepared.ok}
|
|
574
636
|
{#if model.node?.kind === 'oneOf'}
|
|
575
637
|
{@render renderField(resolvedSchema as JsonSchema, model.node, [], resolvedSchema?.title ?? '', false)}
|
|
576
638
|
{:else}
|
|
577
|
-
|
|
578
|
-
{#each Object.entries(resolvedSchema?.properties ?? {}) as [key, node] (key)}
|
|
579
|
-
{@render renderField(node, model.node?.kind === 'object' ? model.node.properties[key] : undefined, [key], node.title ?? key, resolvedSchema?.required?.includes(key) ?? false)}
|
|
580
|
-
{/each}
|
|
581
|
-
</div>
|
|
639
|
+
{@render renderObjectGroups(resolvedSchema as JsonSchema, model.node?.kind === 'object' ? model.node : undefined, [])}
|
|
582
640
|
{/if}
|
|
583
641
|
{/if}
|
|
584
642
|
<div class="pt-4 border-t border-border/60 flex justify-end">
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils';
|
|
4
|
+
|
|
5
|
+
export interface PageContainerTab {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PageContainerTag {
|
|
12
|
+
label: string;
|
|
13
|
+
tone?: 'primary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PageContainerBreadcrumb {
|
|
17
|
+
label: string;
|
|
18
|
+
href?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PageContainerProps {
|
|
22
|
+
/** Main page title text */
|
|
23
|
+
title?: string;
|
|
24
|
+
/** Subtitle or secondary description text */
|
|
25
|
+
subTitle?: string;
|
|
26
|
+
/** Breadcrumb trail items */
|
|
27
|
+
breadcrumbs?: PageContainerBreadcrumb[];
|
|
28
|
+
/** Whether to show back navigation button */
|
|
29
|
+
backIcon?: boolean;
|
|
30
|
+
/** Callback when back button is clicked */
|
|
31
|
+
onback?: () => void;
|
|
32
|
+
/** Status tags or badges displayed next to the title */
|
|
33
|
+
tags?: PageContainerTag[];
|
|
34
|
+
/** Header tabs navigation items */
|
|
35
|
+
tabs?: PageContainerTab[];
|
|
36
|
+
/** Currently active tab key */
|
|
37
|
+
activeTab?: string;
|
|
38
|
+
/** Callback triggered when a tab is selected */
|
|
39
|
+
ontabchange?: (key: string) => void;
|
|
40
|
+
/** If true, content has no card wrapper background (transparent) */
|
|
41
|
+
ghost?: boolean;
|
|
42
|
+
/** Content container width layout ('fluid' or 'fixed') */
|
|
43
|
+
contentWidth?: 'fluid' | 'fixed';
|
|
44
|
+
/** Whether header is fixed at top */
|
|
45
|
+
fixedHeader?: boolean;
|
|
46
|
+
/** Main content body */
|
|
47
|
+
children?: Snippet;
|
|
48
|
+
/** Custom complete header slot */
|
|
49
|
+
header?: Snippet;
|
|
50
|
+
/** Extra actions slot placed on top right */
|
|
51
|
+
extra?: Snippet;
|
|
52
|
+
/** Footer slot for header (below tabs or extra info) */
|
|
53
|
+
footer?: Snippet;
|
|
54
|
+
/** Additional classes */
|
|
55
|
+
class?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let {
|
|
59
|
+
title,
|
|
60
|
+
subTitle,
|
|
61
|
+
breadcrumbs,
|
|
62
|
+
backIcon = false,
|
|
63
|
+
onback,
|
|
64
|
+
tags,
|
|
65
|
+
tabs,
|
|
66
|
+
activeTab = $bindable(),
|
|
67
|
+
ontabchange,
|
|
68
|
+
ghost = false,
|
|
69
|
+
contentWidth = 'fluid',
|
|
70
|
+
fixedHeader = false,
|
|
71
|
+
children,
|
|
72
|
+
header,
|
|
73
|
+
extra,
|
|
74
|
+
footer,
|
|
75
|
+
class: className = '',
|
|
76
|
+
}: PageContainerProps = $props();
|
|
77
|
+
|
|
78
|
+
let internalActiveTab = $derived(activeTab ?? tabs?.[0]?.key ?? '');
|
|
79
|
+
|
|
80
|
+
function handleTabClick(tab: PageContainerTab) {
|
|
81
|
+
if (tab.disabled) return;
|
|
82
|
+
internalActiveTab = tab.key;
|
|
83
|
+
activeTab = tab.key;
|
|
84
|
+
ontabchange?.(tab.key);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handleBack() {
|
|
88
|
+
onback?.();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getTagToneClasses(tone?: PageContainerTag['tone']): string {
|
|
92
|
+
switch (tone) {
|
|
93
|
+
case 'success':
|
|
94
|
+
return 'bg-success/10 text-success border-success/30';
|
|
95
|
+
case 'warning':
|
|
96
|
+
return 'bg-warning/10 text-warning border-warning/30';
|
|
97
|
+
case 'danger':
|
|
98
|
+
return 'bg-destructive/10 text-destructive border-destructive/30';
|
|
99
|
+
case 'primary':
|
|
100
|
+
return 'bg-primary/10 text-primary border-primary/30';
|
|
101
|
+
case 'neutral':
|
|
102
|
+
default:
|
|
103
|
+
return 'bg-muted text-muted-foreground border-border';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<div
|
|
109
|
+
data-svadmin-component="PageContainer"
|
|
110
|
+
class={cn(
|
|
111
|
+
'svadmin-page-container min-h-full w-full bg-background',
|
|
112
|
+
className
|
|
113
|
+
)}
|
|
114
|
+
>
|
|
115
|
+
<!-- Page Header Container -->
|
|
116
|
+
{#if header}
|
|
117
|
+
{@render header()}
|
|
118
|
+
{:else if title || breadcrumbs || extra || tabs}
|
|
119
|
+
<header
|
|
120
|
+
class={cn(
|
|
121
|
+
'svadmin-page-header border-b border-border bg-card px-6 pt-4 pb-0 transition-all',
|
|
122
|
+
fixedHeader && 'sticky top-0 z-20 shadow-xs'
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
<div
|
|
126
|
+
class={cn(
|
|
127
|
+
'mx-auto w-full',
|
|
128
|
+
contentWidth === 'fixed' && 'max-w-7xl'
|
|
129
|
+
)}
|
|
130
|
+
>
|
|
131
|
+
<!-- Breadcrumb row -->
|
|
132
|
+
{#if breadcrumbs && breadcrumbs.length > 0}
|
|
133
|
+
<nav aria-label="Breadcrumb" class="mb-2 flex items-center gap-1.5 text-xs text-muted-foreground">
|
|
134
|
+
{#each breadcrumbs as item, index (item.href ?? `${item.label}-${index}`)}
|
|
135
|
+
{#if index > 0}
|
|
136
|
+
<span class="text-muted select-none">/</span>
|
|
137
|
+
{/if}
|
|
138
|
+
{#if item.href}
|
|
139
|
+
<a
|
|
140
|
+
href={item.href}
|
|
141
|
+
class="transition-colors hover:text-primary focus-visible:outline-none"
|
|
142
|
+
>
|
|
143
|
+
{item.label}
|
|
144
|
+
</a>
|
|
145
|
+
{:else}
|
|
146
|
+
<span class="text-foreground font-normal">{item.label}</span>
|
|
147
|
+
{/if}
|
|
148
|
+
{/each}
|
|
149
|
+
</nav>
|
|
150
|
+
{/if}
|
|
151
|
+
|
|
152
|
+
<!-- Title & Extra row -->
|
|
153
|
+
<div class="flex flex-wrap items-center justify-between gap-3 pb-4">
|
|
154
|
+
<div class="flex flex-wrap items-center gap-2.5">
|
|
155
|
+
{#if backIcon || onback}
|
|
156
|
+
<button
|
|
157
|
+
type="button"
|
|
158
|
+
aria-label="返回上一页"
|
|
159
|
+
class="inline-flex h-7 w-7 items-center justify-center rounded-[4px] border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-primary active:bg-accent"
|
|
160
|
+
onclick={handleBack}
|
|
161
|
+
>
|
|
162
|
+
<svg
|
|
163
|
+
class="h-4 w-4"
|
|
164
|
+
viewBox="0 0 24 24"
|
|
165
|
+
fill="none"
|
|
166
|
+
stroke="currentColor"
|
|
167
|
+
stroke-width="2"
|
|
168
|
+
stroke-linecap="round"
|
|
169
|
+
stroke-linejoin="round"
|
|
170
|
+
>
|
|
171
|
+
<path d="m15 18-6-6 6-6" />
|
|
172
|
+
</svg>
|
|
173
|
+
</button>
|
|
174
|
+
{/if}
|
|
175
|
+
|
|
176
|
+
{#if title}
|
|
177
|
+
<h1 class="text-lg font-semibold tracking-tight text-foreground">
|
|
178
|
+
{title}
|
|
179
|
+
</h1>
|
|
180
|
+
{/if}
|
|
181
|
+
|
|
182
|
+
{#if subTitle}
|
|
183
|
+
<span class="hidden sm:inline-block border-l border-border pl-2.5 text-xs text-muted-foreground">
|
|
184
|
+
{subTitle}
|
|
185
|
+
</span>
|
|
186
|
+
{/if}
|
|
187
|
+
|
|
188
|
+
{#if tags && tags.length > 0}
|
|
189
|
+
<div class="ml-1 flex items-center gap-1.5">
|
|
190
|
+
{#each tags as tag (tag.label)}
|
|
191
|
+
<span
|
|
192
|
+
class={cn(
|
|
193
|
+
'inline-flex items-center rounded-[2px] border px-2 py-0.5 text-[11px] font-medium leading-none select-none',
|
|
194
|
+
getTagToneClasses(tag.tone)
|
|
195
|
+
)}
|
|
196
|
+
>
|
|
197
|
+
{tag.label}
|
|
198
|
+
</span>
|
|
199
|
+
{/each}
|
|
200
|
+
</div>
|
|
201
|
+
{/if}
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
{#if extra}
|
|
205
|
+
<div class="flex items-center gap-2">
|
|
206
|
+
{@render extra()}
|
|
207
|
+
</div>
|
|
208
|
+
{/if}
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<!-- Header Tabs -->
|
|
212
|
+
{#if tabs && tabs.length > 0}
|
|
213
|
+
<div role="tablist" class="flex items-center gap-6 border-t border-border/60 -mb-[1px]">
|
|
214
|
+
{#each tabs as tab (tab.key)}
|
|
215
|
+
<button
|
|
216
|
+
type="button"
|
|
217
|
+
role="tab"
|
|
218
|
+
aria-selected={internalActiveTab === tab.key}
|
|
219
|
+
disabled={tab.disabled}
|
|
220
|
+
class={cn(
|
|
221
|
+
'relative py-2.5 text-xs font-medium transition-colors focus-visible:outline-none',
|
|
222
|
+
internalActiveTab === tab.key
|
|
223
|
+
? 'text-primary font-semibold'
|
|
224
|
+
: 'text-muted-foreground hover:text-primary',
|
|
225
|
+
tab.disabled && 'cursor-not-allowed opacity-40 hover:text-inherit'
|
|
226
|
+
)}
|
|
227
|
+
onclick={() => handleTabClick(tab)}
|
|
228
|
+
>
|
|
229
|
+
{tab.label}
|
|
230
|
+
{#if internalActiveTab === tab.key}
|
|
231
|
+
<span
|
|
232
|
+
class="absolute bottom-0 left-0 right-0 h-[2px] rounded-full bg-primary"
|
|
233
|
+
></span>
|
|
234
|
+
{/if}
|
|
235
|
+
</button>
|
|
236
|
+
{/each}
|
|
237
|
+
</div>
|
|
238
|
+
{/if}
|
|
239
|
+
|
|
240
|
+
{#if footer}
|
|
241
|
+
<div class="pt-2 pb-3">
|
|
242
|
+
{@render footer()}
|
|
243
|
+
</div>
|
|
244
|
+
{/if}
|
|
245
|
+
</div>
|
|
246
|
+
</header>
|
|
247
|
+
{/if}
|
|
248
|
+
|
|
249
|
+
<!-- Content Container -->
|
|
250
|
+
<main class="w-full p-5 sm:p-6">
|
|
251
|
+
<div
|
|
252
|
+
class={cn(
|
|
253
|
+
'mx-auto w-full transition-all',
|
|
254
|
+
contentWidth === 'fixed' && 'max-w-7xl',
|
|
255
|
+
!ghost && 'rounded-[4px] border border-border bg-card p-5 shadow-xs'
|
|
256
|
+
)}
|
|
257
|
+
>
|
|
258
|
+
{#if children}
|
|
259
|
+
{@render children()}
|
|
260
|
+
{/if}
|
|
261
|
+
</div>
|
|
262
|
+
</main>
|
|
263
|
+
</div>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface PageContainerTab {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface PageContainerTag {
|
|
8
|
+
label: string;
|
|
9
|
+
tone?: 'primary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
10
|
+
}
|
|
11
|
+
export interface PageContainerBreadcrumb {
|
|
12
|
+
label: string;
|
|
13
|
+
href?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PageContainerProps {
|
|
16
|
+
/** Main page title text */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Subtitle or secondary description text */
|
|
19
|
+
subTitle?: string;
|
|
20
|
+
/** Breadcrumb trail items */
|
|
21
|
+
breadcrumbs?: PageContainerBreadcrumb[];
|
|
22
|
+
/** Whether to show back navigation button */
|
|
23
|
+
backIcon?: boolean;
|
|
24
|
+
/** Callback when back button is clicked */
|
|
25
|
+
onback?: () => void;
|
|
26
|
+
/** Status tags or badges displayed next to the title */
|
|
27
|
+
tags?: PageContainerTag[];
|
|
28
|
+
/** Header tabs navigation items */
|
|
29
|
+
tabs?: PageContainerTab[];
|
|
30
|
+
/** Currently active tab key */
|
|
31
|
+
activeTab?: string;
|
|
32
|
+
/** Callback triggered when a tab is selected */
|
|
33
|
+
ontabchange?: (key: string) => void;
|
|
34
|
+
/** If true, content has no card wrapper background (transparent) */
|
|
35
|
+
ghost?: boolean;
|
|
36
|
+
/** Content container width layout ('fluid' or 'fixed') */
|
|
37
|
+
contentWidth?: 'fluid' | 'fixed';
|
|
38
|
+
/** Whether header is fixed at top */
|
|
39
|
+
fixedHeader?: boolean;
|
|
40
|
+
/** Main content body */
|
|
41
|
+
children?: Snippet;
|
|
42
|
+
/** Custom complete header slot */
|
|
43
|
+
header?: Snippet;
|
|
44
|
+
/** Extra actions slot placed on top right */
|
|
45
|
+
extra?: Snippet;
|
|
46
|
+
/** Footer slot for header (below tabs or extra info) */
|
|
47
|
+
footer?: Snippet;
|
|
48
|
+
/** Additional classes */
|
|
49
|
+
class?: string;
|
|
50
|
+
}
|
|
51
|
+
declare const PageContainer: import("svelte").Component<PageContainerProps, {}, "activeTab">;
|
|
52
|
+
type PageContainer = ReturnType<typeof PageContainer>;
|
|
53
|
+
export default PageContainer;
|