@svadmin/ui 0.110.1 → 0.112.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
@@ -6677,6 +6677,9 @@
6677
6677
  .gap-3 {
6678
6678
  gap: calc(var(--spacing) * 3);
6679
6679
  }
6680
+ .gap-3\.5 {
6681
+ gap: calc(var(--spacing) * 3.5);
6682
+ }
6680
6683
  .gap-4 {
6681
6684
  gap: calc(var(--spacing) * 4);
6682
6685
  }
@@ -9095,6 +9098,12 @@
9095
9098
  .lg\:col-span-2 {
9096
9099
  grid-column: span 2 / span 2;
9097
9100
  }
9101
+ .lg\:col-span-3 {
9102
+ grid-column: span 3 / span 3;
9103
+ }
9104
+ .lg\:col-span-4 {
9105
+ grid-column: span 4 / span 4;
9106
+ }
9098
9107
  .lg\:flex {
9099
9108
  display: flex;
9100
9109
  }
@@ -6677,6 +6677,9 @@
6677
6677
  .gap-3 {
6678
6678
  gap: calc(var(--spacing) * 3);
6679
6679
  }
6680
+ .gap-3\.5 {
6681
+ gap: calc(var(--spacing) * 3.5);
6682
+ }
6680
6683
  .gap-4 {
6681
6684
  gap: calc(var(--spacing) * 4);
6682
6685
  }
@@ -9095,6 +9098,12 @@
9095
9098
  .lg\:col-span-2 {
9096
9099
  grid-column: span 2 / span 2;
9097
9100
  }
9101
+ .lg\:col-span-3 {
9102
+ grid-column: span 3 / span 3;
9103
+ }
9104
+ .lg\:col-span-4 {
9105
+ grid-column: span 4 / span 4;
9106
+ }
9098
9107
  .lg\:flex {
9099
9108
  display: flex;
9100
9109
  }
@@ -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.110.1";
14
+ const buildVersion = "0.112.0";
15
15
  const version = $derived(suppliedVersion ?? (
16
16
  buildVersion.startsWith('__')
17
17
  ? (i18n.locale === 'zh-CN' ? '开发构建(未提供版本)' : 'Development build (version unavailable)')
@@ -5,6 +5,7 @@
5
5
  import { definedOptions } from '@svadmin/core/options';
6
6
 
7
7
  import { captureAdminContext, captureAuthSession, useResourceContract, getContractFormFields, deriveValidator, useNavigation, useCan, useForm, parseQueryKey } from '@svadmin/core';
8
+ import { resolveDeclaredFieldLayout } from '@svadmin/core/schema-form';
8
9
  import { useQueryClient } from '@tanstack/svelte-query';
9
10
  import { slide } from 'svelte/transition';
10
11
  import { untrack } from 'svelte';
@@ -17,6 +18,14 @@
17
18
  import { Badge } from './ui/badge/index.js';
18
19
  import { Save, ArrowLeft, Loader2, AlertCircle } from '@lucide/svelte';
19
20
  import FieldRenderer from './FieldRenderer.svelte';
21
+ import {
22
+ buildFormGroups,
23
+ buildSpanByKey,
24
+ gridClassFor,
25
+ isFullWidthField,
26
+ spanClass,
27
+ type FormLayoutGroup,
28
+ } from './auto-form-layout.js';
20
29
  import type { UploadCancelHandler, UploadHandler } from './file-upload-types.js';
21
30
  import * as Alert from './ui/alert/index.js';
22
31
  import { Skeleton } from './ui/skeleton/index.js';
@@ -132,38 +141,17 @@
132
141
  return true;
133
142
  }));
134
143
 
135
- const hasGroups = $derived(formFields.some(f => f.group));
136
- const groups = $derived((() => {
137
- if (!hasGroups) return [];
138
- const order: string[] = [];
139
- const map = new Map<string, FieldDefinition[]>();
140
- for (const f of formFields) {
141
- const g = f.group ?? '';
142
- if (!map.has(g)) { order.push(g); map.set(g, []); }
143
- (map.get(g) ?? []).push(f);
144
- }
145
- return order.map(g => ({ name: g, fields: map.get(g) ?? [] }));
146
- })());
147
-
148
- const gridClass = $derived(
149
- columns === 4
150
- ? 'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4'
151
- : columns === 3
152
- ? 'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4'
153
- : columns === 2
154
- ? 'grid grid-cols-1 md:grid-cols-2 gap-4'
155
- : 'space-y-5'
156
- );
144
+ const declarativeLayout = $derived(resolveDeclaredFieldLayout(formFields));
145
+ const spanByKey = $derived(buildSpanByKey(declarativeLayout));
146
+ const effectiveColumns = $derived(declarativeLayout?.kind === 'flat' ? declarativeLayout.columns : columns);
157
147
 
158
- function isFullWidthField(field: FieldDefinition): boolean {
159
- return (
160
- field.type === 'textarea' ||
161
- field.type === 'richtext' ||
162
- field.type === 'json' ||
163
- field.type === 'array' ||
164
- field.type === 'images'
165
- );
166
- }
148
+ const groups = $derived.by((): FormLayoutGroup[] => buildFormGroups({
149
+ layout: declarativeLayout,
150
+ fields: formFields,
151
+ columns,
152
+ }));
153
+ const hasGroups = $derived(groups.length > 0);
154
+ const gridClass = $derived(gridClassFor(effectiveColumns));
167
155
 
168
156
  // ─── Default values from field metadata ───────────────────────────
169
157
  function getDefaultForType(field: FieldDefinition): unknown {
@@ -639,10 +627,11 @@
639
627
  {#if group.name}
640
628
  <Card.Header>
641
629
  <Card.Title class="text-lg">{group.name}</Card.Title>
630
+ {#if group.description}<p class="text-[11px] text-muted-foreground">{group.description}</p>{/if}
642
631
  </Card.Header>
643
632
  {/if}
644
633
  <Card.Content class="px-4 sm:px-6 pb-4 sm:pb-6 pt-0">
645
- <div class={gridClass}>
634
+ <div class={gridClassFor(group.columns)} data-svadmin-form-grid data-columns={group.columns}>
646
635
  {#each group.fields as field (field.key)}
647
636
  {@const customField = fields?.[field.key]}
648
637
  <div
@@ -650,7 +639,7 @@
650
639
  data-svadmin-field-key={field.key}
651
640
  data-svadmin-field={field.key}
652
641
  data-svadmin-field-type={field.type}
653
- class={cn(columns > 1 && isFullWidthField(field) && 'col-span-full', !!form.errors[field.key] && 'border-destructive')}
642
+ class={cn(group.columns > 1 && isFullWidthField(field) && 'col-span-full', spanClass(spanByKey.get(field.key)), !!form.errors[field.key] && 'border-destructive')}
654
643
  >
655
644
  {#if customField}
656
645
  {@render customField({
@@ -688,7 +677,7 @@
688
677
  {:else}
689
678
  <Card.Root class="border-border/40 shadow-sm">
690
679
  <Card.Content class="px-4 pt-5 pb-4 sm:px-6 sm:pt-6 sm:pb-6">
691
- <div class={gridClass} data-svadmin-form-grid data-columns={columns}>
680
+ <div class={gridClass} data-svadmin-form-grid data-columns={effectiveColumns}>
692
681
  {#each formFields as field (field.key)}
693
682
  {@const customField = fields?.[field.key]}
694
683
  <div
@@ -696,7 +685,7 @@
696
685
  data-svadmin-field-key={field.key}
697
686
  data-svadmin-field={field.key}
698
687
  data-svadmin-field-type={field.type}
699
- class={cn(columns > 1 && isFullWidthField(field) && 'col-span-full', !!form.errors[field.key] && 'border-destructive')}
688
+ class={cn(effectiveColumns > 1 && isFullWidthField(field) && 'col-span-full', spanClass(spanByKey.get(field.key)), !!form.errors[field.key] && 'border-destructive')}
700
689
  >
701
690
  {#if customField}
702
691
  {@render customField({
@@ -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;
@@ -1,5 +1,14 @@
1
1
  <script lang="ts">
2
- import { assertSchemaFormSchema, isSchemaFormNodeVisible, prepareSchemaFormValue, type SchemaFormSchema } from '@svadmin/core/schema-form';
2
+ import {
3
+ applySchemaFormComputed,
4
+ assertSchemaFormSchema,
5
+ isSchemaFormNodeVisible,
6
+ prepareSchemaFormValue,
7
+ resolveSchemaFormLayout,
8
+ type SchemaFormLayoutGroup,
9
+ type SchemaFormLayoutPlan,
10
+ type SchemaFormSchema,
11
+ } from '@svadmin/core/schema-form';
3
12
  import { tick } from 'svelte';
4
13
  import { useTranslation } from '@svadmin/core/i18n';
5
14
  import { Button } from './ui/button/index.js';
@@ -156,6 +165,61 @@
156
165
  return { ok: false as const };
157
166
  }
158
167
  });
168
+ // Computed fields are derived from the projected value; they render read-only
169
+ // and are recomputed on submit instead of being trusted from local input.
170
+ const computedValue = $derived.by(() => {
171
+ if (!coreSchema || !prepared.ok) return undefined;
172
+ try {
173
+ const result = applySchemaFormComputed(coreSchema, prepared.value);
174
+ return result !== null && typeof result === 'object' && !Array.isArray(result)
175
+ ? result as Record<string, unknown>
176
+ : undefined;
177
+ } catch {
178
+ return undefined;
179
+ }
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
+ }
159
223
  const locked = $derived(disabled || readonly || isSubmitting || !prepared.ok);
160
224
  let reportedConfiguration = '';
161
225
  let reportedSchema: JsonSchema | undefined;
@@ -290,7 +354,7 @@
290
354
  function readPath(path: string[]): unknown {
291
355
  return path.reduce<unknown>((current, key) => (
292
356
  current && typeof current === 'object' && Object.hasOwn(current, key) ? (current as Record<string, unknown>)[key] : undefined
293
- ), prepared.ok ? prepared.value : {});
357
+ ), computedValue ?? (prepared.ok ? prepared.value : {}));
294
358
  }
295
359
  function recordValue(current: unknown, key: string): unknown {
296
360
  if (current === null || typeof current !== 'object' || Array.isArray(current) || !Object.hasOwn(current, key)) return undefined;
@@ -362,7 +426,10 @@
362
426
  let payload: Record<string, unknown>;
363
427
  try {
364
428
  // 分支切换后只提交当前 discriminator 对应分支;旧分支字段不会随草稿误提交。
365
- const submittedValue = pruneRecursiveSchemaFormValue(model, prepared.value);
429
+ const pruned = pruneRecursiveSchemaFormValue(model, prepared.value);
430
+ const submittedValue = coreSchema
431
+ ? applySchemaFormComputed(coreSchema, pruned) as Record<string, unknown>
432
+ : pruned;
366
433
  const result = coreSchema ? prepareSchemaFormValue(coreSchema, submittedValue) : undefined;
367
434
  const detailedIssues = model.issues.length ? [] : validateRecursiveSchemaForm(model, submittedValue);
368
435
  // 隐藏字段暂不参与校验,但保留解析错误,重新显示时仍需修正。
@@ -427,7 +494,7 @@
427
494
  {@const current = readPath(path)}
428
495
  {@const id = `${prefix}_${path.map(encodeURIComponent).join('/')}`}
429
496
  {@const type = nodeType(node)}
430
- {@const fieldLocked = locked || pathReadonly(path)}
497
+ {@const fieldLocked = locked || pathReadonly(path) || Boolean(coreSchema && (node as SchemaFormSchema).computed)}
431
498
  {@const error = fieldInvalid(path)}
432
499
  {@const options = choices(node)}
433
500
  {@const descriptionId = node.description ? `${id}:description` : undefined}
@@ -498,11 +565,7 @@
498
565
  <legend class="block font-medium">{title}</legend>
499
566
  {#if error}<p id={errorId}>{i18n.t('validation.invalidFormat')}</p>{/if}
500
567
  {#if node.description}<p id={descriptionId} class="text-[11px] text-muted-foreground">{node.description}</p>{/if}
501
- <div class="space-y-3.5">
502
- {#each Object.entries(node.properties ?? {}) as [key, child] (key)}
503
- {@render renderField(child, compiled?.kind === 'object' ? compiled.properties[key] : undefined, [...path, key], child.title ?? key, node.required?.includes(key) ?? false)}
504
- {/each}
505
- </div>
568
+ {@render renderObjectGroups(node, compiled, path)}
506
569
  </fieldset>
507
570
  {:else if type === 'array'}
508
571
  {@const items = Array.isArray(current) ? current : []}
@@ -547,16 +610,33 @@
547
610
  {/if}
548
611
  {/snippet}
549
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
+
550
634
  <fieldset class="schema-form-fields space-y-4" disabled={locked}>
551
635
  {#if prepared.ok}
552
636
  {#if model.node?.kind === 'oneOf'}
553
637
  {@render renderField(resolvedSchema as JsonSchema, model.node, [], resolvedSchema?.title ?? '', false)}
554
638
  {:else}
555
- <div class="space-y-3.5">
556
- {#each Object.entries(resolvedSchema?.properties ?? {}) as [key, node] (key)}
557
- {@render renderField(node, model.node?.kind === 'object' ? model.node.properties[key] : undefined, [key], node.title ?? key, resolvedSchema?.required?.includes(key) ?? false)}
558
- {/each}
559
- </div>
639
+ {@render renderObjectGroups(resolvedSchema as JsonSchema, model.node?.kind === 'object' ? model.node : undefined, [])}
560
640
  {/if}
561
641
  {/if}
562
642
  <div class="pt-4 border-t border-border/60 flex justify-end">
@@ -17,13 +17,10 @@
17
17
  import * as Collapsible from './ui/collapsible/index.js';
18
18
  import { Avatar } from './ui/avatar/index.js';
19
19
  import {
20
- LayoutDashboard, FileText, Users, Settings, Home,
20
+ LayoutDashboard, Settings,
21
21
  ChevronLeft, ChevronRight, ChevronDown, LogOut, Sun, Moon, Palette,
22
- Image as ImageIcon, Layout, Folder, Type, Video,
23
- Download, ListTodo, TrendingUp, Sparkles, Images, Bot, Key, KeyRound, CreditCard, BookOpen, Wrench,
24
- Repeat, ClipboardCheck, SlidersHorizontal, AlertTriangle, Mail, Map as MapIcon, MessageSquare, Send, ShoppingBag, Star, Briefcase, Building2,
25
- Calendar, Bell, Clock, Tag, Trash2, Shield
26
22
  } from '@lucide/svelte';
23
+ import { resolveIcon, type IconComponent } from '../icons.js';
27
24
 
28
25
  const i18n = useTranslation();
29
26
 
@@ -50,54 +47,10 @@
50
47
  return effectiveRouteMode === 'hash' ? `#${path}` : path;
51
48
  }
52
49
 
53
- const iconMap: Record<string, typeof LayoutDashboard> = {
54
- 'dashboard': LayoutDashboard,
55
- 'posts': FileText,
56
- 'file': FileText,
57
- 'users': Users,
58
- 'settings': Settings,
59
- 'home': Home,
60
- 'palette': Palette,
61
- 'image': ImageIcon,
62
- 'layout': Layout,
63
- 'folder': Folder,
64
- 'type': Type,
65
- 'video': Video,
66
- 'download': Download,
67
- 'list-todo': ListTodo,
68
- 'trending-up': TrendingUp,
69
- 'sparkles': Sparkles,
70
- 'images': Images,
71
- 'bot': Bot,
72
- 'key': Key,
73
- 'key-round': KeyRound,
74
- 'credit-card': CreditCard,
75
- 'book-open': BookOpen,
76
- 'wrench': Wrench,
77
- 'repeat': Repeat,
78
- 'clipboard-check': ClipboardCheck,
79
- 'sliders-horizontal': SlidersHorizontal,
80
- 'alert-triangle': AlertTriangle,
81
- 'mail': Mail,
82
- 'map': MapIcon,
83
- 'message-square': MessageSquare,
84
- 'send': Send,
85
- 'shopping-bag': ShoppingBag,
86
- 'star': Star,
87
- 'briefcase': Briefcase,
88
- 'building': Building2,
89
- 'calendar': Calendar,
90
- 'bell': Bell,
91
- 'clock': Clock,
92
- 'tag': Tag,
93
- 'trash': Trash2,
94
- 'shield': Shield,
95
- };
96
-
97
50
  interface NavItem {
98
51
  path: string;
99
52
  label: string;
100
- Icon: typeof LayoutDashboard;
53
+ Icon: IconComponent;
101
54
  group?: string;
102
55
  }
103
56
 
@@ -193,7 +146,9 @@
193
146
  items.push(definedOptions({
194
147
  path: `/${r.name}`,
195
148
  label: r.label,
196
- Icon: (typeof r.icon === 'string' ? iconMap[r.icon] : r.icon) ?? iconMap[r.name] ?? Settings,
149
+ Icon: (typeof r.icon === 'string' ? resolveIcon(r.icon, Settings) : r.icon)
150
+ ?? resolveIcon(r.name, Settings)
151
+ ?? Settings,
197
152
  group: r.group,
198
153
  }));
199
154
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Layout helpers for `AutoForm`.
3
+ *
4
+ * Kept out of the component so the form stays under the module-size budget and
5
+ * the grid/span mapping can be tested without rendering.
6
+ */
7
+ import type { FieldDefinition } from '@svadmin/core';
8
+ import type { SchemaFormLayoutPlan } from '@svadmin/core/schema-form';
9
+ export declare function gridClassFor(count: number): string;
10
+ export declare function spanClass(span: number | undefined): string;
11
+ export interface FormLayoutGroup {
12
+ name: string;
13
+ description: string | undefined;
14
+ columns: number;
15
+ fields: FieldDefinition[];
16
+ }
17
+ /** Map declarative layout spans into a lookup the field renderer can use. */
18
+ export declare function buildSpanByKey(layout: SchemaFormLayoutPlan | undefined): Map<string, number>;
19
+ /**
20
+ * Resolve render groups: declarative sections/steps win, then `field.group`,
21
+ * then a single ungrouped list.
22
+ */
23
+ export declare function buildFormGroups(input: {
24
+ layout: SchemaFormLayoutPlan | undefined;
25
+ fields: readonly FieldDefinition[];
26
+ columns: number;
27
+ }): FormLayoutGroup[];
28
+ export declare function isFullWidthField(field: Pick<FieldDefinition, 'type'>): boolean;
@@ -0,0 +1,70 @@
1
+ export function gridClassFor(count) {
2
+ if (count === 4)
3
+ return 'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4';
4
+ if (count === 3)
5
+ return 'grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4';
6
+ if (count === 2)
7
+ return 'grid grid-cols-1 md:grid-cols-2 gap-4';
8
+ return 'space-y-5';
9
+ }
10
+ export function spanClass(span) {
11
+ if (span === 2)
12
+ return 'md:col-span-2';
13
+ if (span === 3)
14
+ return 'md:col-span-2 lg:col-span-3';
15
+ if (span !== undefined && span >= 4)
16
+ return 'md:col-span-2 lg:col-span-4';
17
+ return '';
18
+ }
19
+ /** Map declarative layout spans into a lookup the field renderer can use. */
20
+ export function buildSpanByKey(layout) {
21
+ const spans = new Map();
22
+ for (const group of layout?.groups ?? []) {
23
+ for (const field of group.fields)
24
+ spans.set(field.key, field.span);
25
+ }
26
+ return spans;
27
+ }
28
+ /**
29
+ * Resolve render groups: declarative sections/steps win, then `field.group`,
30
+ * then a single ungrouped list.
31
+ */
32
+ export function buildFormGroups(input) {
33
+ const { layout, fields, columns } = input;
34
+ if (layout && (layout.kind === 'sections' || layout.kind === 'steps')) {
35
+ return layout.groups.map((group) => ({
36
+ name: group.step !== undefined ? `${group.step}. ${group.title ?? ''}`.trim() : (group.title ?? ''),
37
+ description: group.description,
38
+ columns: group.columns,
39
+ fields: group.fields.flatMap((item) => {
40
+ const field = fields.find((candidate) => candidate.key === item.key);
41
+ return field ? [field] : [];
42
+ }),
43
+ }));
44
+ }
45
+ if (!fields.some((field) => field.group))
46
+ return [];
47
+ const order = [];
48
+ const map = new Map();
49
+ for (const field of fields) {
50
+ const name = field.group ?? '';
51
+ if (!map.has(name)) {
52
+ order.push(name);
53
+ map.set(name, []);
54
+ }
55
+ (map.get(name) ?? []).push(field);
56
+ }
57
+ return order.map((name) => ({
58
+ name,
59
+ description: undefined,
60
+ columns,
61
+ fields: map.get(name) ?? [],
62
+ }));
63
+ }
64
+ export function isFullWidthField(field) {
65
+ return (field.type === 'textarea' ||
66
+ field.type === 'richtext' ||
67
+ field.type === 'json' ||
68
+ field.type === 'array' ||
69
+ field.type === 'images');
70
+ }
@@ -1,3 +1,4 @@
1
+ import type { SchemaFormComputed, SchemaFormCondition, SchemaFormLayout } from '@svadmin/core/schema-form';
1
2
  /** 嵌套表单的草稿与传输语义;不是替代服务端的 JSON Schema 校验器。 */
2
3
  export interface JsonSchemaFormSchema {
3
4
  $schema?: string;
@@ -33,12 +34,10 @@ export interface JsonSchemaFormSchema {
33
34
  enum?: Array<string | number | boolean | null>;
34
35
  default?: unknown;
35
36
  required?: string[];
36
- visibleWhen?: {
37
- path: readonly string[];
38
- equals?: string | number | boolean | null;
39
- notEquals?: string | number | boolean | null;
40
- exists?: boolean;
41
- };
37
+ visibleWhen?: SchemaFormCondition;
38
+ computed?: SchemaFormComputed;
39
+ /** 呈现分组。不参与草稿、传输或校验。 */
40
+ layout?: SchemaFormLayout;
42
41
  }
43
42
  export declare const SCHEMA_FORM_LIMITS: Readonly<{
44
43
  depth: 32;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Icon registry — resolve icons by name instead of a hardcoded local map.
3
+ *
4
+ * Arco resolves icons from a name (`<IconUser />` / `icon="user"`). svadmin keeps
5
+ * `@lucide/svelte` as the default set, but name resolution must be extensible:
6
+ * third-party plugins contribute icons without patching `Sidebar`, and a missing
7
+ * name must fail predictably instead of rendering nothing.
8
+ *
9
+ * Resolution order: registrations (last write wins) → built-in lucide names →
10
+ * explicit fallback → `undefined`.
11
+ */
12
+ import type { Component } from 'svelte';
13
+ /** Minimal icon component contract used by navigation surfaces. */
14
+ export type IconComponent = Component<Record<string, unknown>>;
15
+ /**
16
+ * Non-component icon sources. Design systems that ship a sprite sheet or a CDN
17
+ * set can register names without generating one component per icon.
18
+ */
19
+ export type IconSource = {
20
+ type: 'sprite';
21
+ url: string;
22
+ symbolPrefix?: string;
23
+ } | {
24
+ type: 'remote-svg';
25
+ urlTemplate: string;
26
+ };
27
+ /** Public registration shape. `url` is a sprite URL or a `{name}` template. */
28
+ export interface IconSourceInput {
29
+ type: 'sprite' | 'remote-svg';
30
+ url: string;
31
+ symbolPrefix?: string;
32
+ /** Omit to use this source for every name that has no component. */
33
+ names?: readonly string[];
34
+ }
35
+ /** Handler invoked once per missing icon name. Keep it cheap: no throwing. */
36
+ export type IconMissHandler = (name: string) => void;
37
+ export interface IconRegistry {
38
+ /** Register or override icons by name. Names are matched verbatim. */
39
+ registerIcons(icons: Readonly<Record<string, IconComponent>>, options?: {
40
+ replace?: boolean;
41
+ }): void;
42
+ /** Replace the built-in vocabulary as well as registrations (design-system swap). */
43
+ replaceIcons(icons: Readonly<Record<string, IconComponent>>): void;
44
+ /** Register sprite/remote sources for names that have no component. */
45
+ registerIconSources(sources: Readonly<Record<string, IconSource>>): void;
46
+ /** Register one sprite sheet or remote template, optionally limited to `names`. */
47
+ registerIconSource(source: IconSourceInput): void;
48
+ /** Last registered source wins; components always take precedence at render time. */
49
+ resolveIconSource(name: string | undefined): IconSource | undefined;
50
+ getIconSourceNames(): string[];
51
+ /** Resolve a name, optionally falling back to a caller-provided component. */
52
+ resolveIcon(name: string | undefined, fallback?: IconComponent): IconComponent | undefined;
53
+ hasIcon(name: string): boolean;
54
+ /** Registered names in registration order, built-ins first. */
55
+ getIconNames(): string[];
56
+ /** Component rendered when a name is missing; registration still wins. */
57
+ setIconFallback(icon: IconComponent | undefined): void;
58
+ /** Observe missing names (devtools bridge, warnings, telemetry). */
59
+ setIconMissHandler(handler: IconMissHandler | undefined): void;
60
+ /** Restore built-ins only; intended for tests. */
61
+ resetIconRegistry(): void;
62
+ }
63
+ export declare function createIconRegistry(builtinIcons?: Readonly<Record<string, IconComponent>>): IconRegistry;
@@ -0,0 +1,127 @@
1
+ function isIconSource(value) {
2
+ if (typeof value !== 'object' || value === null)
3
+ return false;
4
+ const type = Reflect.get(value, 'type');
5
+ if (type === 'sprite') {
6
+ const url = Reflect.get(value, 'url');
7
+ const prefix = Reflect.get(value, 'symbolPrefix');
8
+ return typeof url === 'string' && url.length > 0 && (prefix === undefined || typeof prefix === 'string');
9
+ }
10
+ if (type === 'remote-svg') {
11
+ const template = Reflect.get(value, 'urlTemplate');
12
+ return typeof template === 'string' && template.includes('{name}');
13
+ }
14
+ return false;
15
+ }
16
+ export function createIconRegistry(builtinIcons = {}) {
17
+ const original = new Map(Object.entries(builtinIcons));
18
+ let builtin = new Map(original);
19
+ const registered = new Map();
20
+ const sources = new Map();
21
+ let defaultSource;
22
+ const missing = new Set();
23
+ let fallback;
24
+ let onMiss;
25
+ let missCount = 0;
26
+ function reportMiss(name) {
27
+ // Bound the noise: one report per distinct name, and never more than 50.
28
+ if (!onMiss || missing.has(name) || missCount >= 50)
29
+ return;
30
+ missing.add(name);
31
+ missCount += 1;
32
+ try {
33
+ onMiss(name);
34
+ }
35
+ catch {
36
+ // A diagnostic hook must not break navigation rendering.
37
+ }
38
+ }
39
+ return {
40
+ registerIcons(icons, options = {}) {
41
+ if (!options.replace) {
42
+ for (const [name, icon] of Object.entries(icons)) {
43
+ if (name.trim() === '' || typeof icon !== 'function')
44
+ continue;
45
+ registered.set(name, icon);
46
+ }
47
+ return;
48
+ }
49
+ registered.clear();
50
+ for (const [name, icon] of Object.entries(icons)) {
51
+ if (name.trim() === '' || typeof icon !== 'function')
52
+ continue;
53
+ registered.set(name, icon);
54
+ }
55
+ },
56
+ replaceIcons(icons) {
57
+ builtin = new Map(Object.entries(icons).filter(([name, icon]) => name.trim() !== '' && typeof icon === 'function'));
58
+ registered.clear();
59
+ },
60
+ registerIconSources(next) {
61
+ for (const [name, source] of Object.entries(next)) {
62
+ if (name.trim() === '' || !isIconSource(source))
63
+ continue;
64
+ sources.set(name, source);
65
+ }
66
+ },
67
+ registerIconSource(source) {
68
+ const normalized = source.type === 'sprite'
69
+ ? (source.url.length > 0 ? {
70
+ type: 'sprite',
71
+ url: source.url,
72
+ ...(source.symbolPrefix !== undefined ? { symbolPrefix: source.symbolPrefix } : {}),
73
+ } : undefined)
74
+ : (source.url.includes('{name}') ? { type: 'remote-svg', urlTemplate: source.url } : undefined);
75
+ if (normalized === undefined || !isIconSource(normalized))
76
+ return;
77
+ const names = source.names?.filter((name) => name.trim() !== '') ?? [];
78
+ if (names.length === 0) {
79
+ defaultSource = normalized;
80
+ return;
81
+ }
82
+ for (const name of names)
83
+ sources.set(name, normalized);
84
+ },
85
+ resolveIconSource(name) {
86
+ if (name === undefined || name === '')
87
+ return undefined;
88
+ return sources.get(name) ?? defaultSource;
89
+ },
90
+ getIconSourceNames() {
91
+ return [...sources.keys()];
92
+ },
93
+ resolveIcon(name, fallbackIcon) {
94
+ if (name === undefined || name === '')
95
+ return fallbackIcon ?? fallback;
96
+ const direct = registered.get(name) ?? builtin.get(name);
97
+ if (direct)
98
+ return direct;
99
+ reportMiss(name);
100
+ return fallbackIcon ?? fallback;
101
+ },
102
+ hasIcon(name) {
103
+ return registered.has(name) || builtin.has(name);
104
+ },
105
+ getIconNames() {
106
+ return [...new Set([...builtin.keys(), ...registered.keys()])];
107
+ },
108
+ setIconFallback(icon) {
109
+ fallback = icon;
110
+ },
111
+ setIconMissHandler(handler) {
112
+ onMiss = handler;
113
+ missing.clear();
114
+ missCount = 0;
115
+ },
116
+ resetIconRegistry() {
117
+ builtin = new Map(original);
118
+ registered.clear();
119
+ sources.clear();
120
+ defaultSource = undefined;
121
+ fallback = undefined;
122
+ onMiss = undefined;
123
+ missing.clear();
124
+ missCount = 0;
125
+ },
126
+ };
127
+ }
@@ -0,0 +1,18 @@
1
+ import { type IconComponent } from './icon-registry.js';
2
+ /** Default icon vocabulary; keys are the documented string form. */
3
+ export declare const builtinIcons: Readonly<Record<string, IconComponent>>;
4
+ export declare const replaceIcons: (icons: Readonly<Record<string, IconComponent>>) => void;
5
+ export declare const registerIcons: (icons: Readonly<Record<string, IconComponent>>, options?: {
6
+ replace?: boolean;
7
+ }) => void;
8
+ export declare const resolveIcon: (name: string | undefined, fallback?: IconComponent) => IconComponent | undefined;
9
+ export declare const hasIcon: (name: string) => boolean;
10
+ export declare const getIconNames: () => string[];
11
+ export declare const registerIconSources: (sources: Readonly<Record<string, import("./icon-registry.js").IconSource>>) => void;
12
+ export declare const registerIconSource: (source: import("./icon-registry.js").IconSourceInput) => void;
13
+ export declare const resolveIconSource: (name: string | undefined) => import("./icon-registry.js").IconSource | undefined;
14
+ export declare const getIconSourceNames: () => string[];
15
+ export declare const setIconFallback: (icon: IconComponent | undefined) => void;
16
+ export declare const setIconMissHandler: (handler: import("./icon-registry.js").IconMissHandler | undefined) => void;
17
+ export declare const resetIconRegistry: () => void;
18
+ export type { IconComponent, IconMissHandler, IconRegistry, IconSource, IconSourceInput } from './icon-registry.js';
package/dist/icons.js ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Built-in icon names for navigation and resource metadata.
3
+ *
4
+ * `MenuItem.icon` and `ResourceDefinition.icon` accept either a component or a
5
+ * string. This module owns the string → component mapping (lucide by default),
6
+ * so hosts and plugins can extend it through `registerIcons()` instead of
7
+ * editing `Sidebar`.
8
+ */
9
+ import { LayoutDashboard, FileText, Users, Settings, Home, Palette, Image as ImageIcon, Layout, Folder, Type, Video, Download, ListTodo, TrendingUp, Sparkles, Images, Bot, Key, KeyRound, CreditCard, BookOpen, Wrench, Repeat, ClipboardCheck, SlidersHorizontal, AlertTriangle, Mail, Map as MapIcon, MessageSquare, Send, ShoppingBag, Star, Briefcase, Building2, Calendar, Bell, Clock, Tag, Trash2, Shield, } from '@lucide/svelte';
10
+ import { createIconRegistry } from './icon-registry.js';
11
+ /** Default icon vocabulary; keys are the documented string form. */
12
+ export const builtinIcons = {
13
+ dashboard: LayoutDashboard,
14
+ posts: FileText,
15
+ file: FileText,
16
+ users: Users,
17
+ settings: Settings,
18
+ home: Home,
19
+ palette: Palette,
20
+ image: ImageIcon,
21
+ layout: Layout,
22
+ folder: Folder,
23
+ type: Type,
24
+ video: Video,
25
+ download: Download,
26
+ 'list-todo': ListTodo,
27
+ 'trending-up': TrendingUp,
28
+ sparkles: Sparkles,
29
+ images: Images,
30
+ bot: Bot,
31
+ key: Key,
32
+ 'key-round': KeyRound,
33
+ 'credit-card': CreditCard,
34
+ 'book-open': BookOpen,
35
+ wrench: Wrench,
36
+ repeat: Repeat,
37
+ 'clipboard-check': ClipboardCheck,
38
+ 'sliders-horizontal': SlidersHorizontal,
39
+ 'alert-triangle': AlertTriangle,
40
+ mail: Mail,
41
+ map: MapIcon,
42
+ 'message-square': MessageSquare,
43
+ send: Send,
44
+ 'shopping-bag': ShoppingBag,
45
+ star: Star,
46
+ briefcase: Briefcase,
47
+ building: Building2,
48
+ calendar: Calendar,
49
+ bell: Bell,
50
+ clock: Clock,
51
+ tag: Tag,
52
+ trash: Trash2,
53
+ shield: Shield,
54
+ };
55
+ const registry = createIconRegistry(builtinIcons);
56
+ export const replaceIcons = registry.replaceIcons;
57
+ export const registerIcons = registry.registerIcons;
58
+ export const resolveIcon = registry.resolveIcon;
59
+ export const hasIcon = registry.hasIcon;
60
+ export const getIconNames = registry.getIconNames;
61
+ export const registerIconSources = registry.registerIconSources;
62
+ export const registerIconSource = registry.registerIconSource;
63
+ export const resolveIconSource = registry.resolveIconSource;
64
+ export const getIconSourceNames = registry.getIconSourceNames;
65
+ export const setIconFallback = registry.setIconFallback;
66
+ export const setIconMissHandler = registry.setIconMissHandler;
67
+ export const resetIconRegistry = registry.resetIconRegistry;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export { surfaceDesignContract } from "./design-contract.js";
2
2
  export type { AdminPageFamily, AdminPageState, SurfaceDensity, SurfaceTone } from "./design-contract.js";
3
3
  export { designSystemComponents, type DesignComponentContract, type DesignComponentId, type DesignComponentState, } from "./design-system-components.js";
4
4
  export { metricSurfaceClasses, tableSurfaceClasses } from "./design-system.js";
5
+ export { builtinIcons, getIconNames, hasIcon, getIconSourceNames, registerIconSource, registerIconSources, registerIcons, replaceIcons, resetIconRegistry, resolveIcon, resolveIconSource, setIconFallback, setIconMissHandler, } from "./icons.js";
6
+ export type { IconComponent, IconMissHandler, IconRegistry, IconSource, IconSourceInput } from "./icons.js";
5
7
  export { default as AdminApp } from './components/AdminApp.svelte';
6
8
  export type { AdminPageRoute } from './components/AdminApp.svelte';
7
9
  export { default as AutoTable } from './components/AutoTable.svelte';
@@ -33,6 +35,7 @@ export type { ListStateSnapshot } from './components/list-state.svelte.js';
33
35
  export { default as AutoForm } from './components/AutoForm.svelte';
34
36
  export { default as ShowPage } from './components/ShowPage.svelte';
35
37
  export { default as ConfirmDialog } from './components/ConfirmDialog.svelte';
38
+ export { default as Icon } from './components/Icon.svelte';
36
39
  export { default as Sidebar } from './components/Sidebar.svelte';
37
40
  export { default as Layout } from './components/Layout.svelte';
38
41
  export type { LayoutAIAssistantProps } from './components/Layout.svelte';
@@ -327,6 +330,8 @@ export { setComponentRegistry, getComponentRegistry, useComponent, type Componen
327
330
  export { builtinDisplayComponents, registerDisplayComponent, getDisplayComponent, hasDisplayComponent, } from './components/fieldComponentMap';
328
331
  export type { FieldComponentMap, FieldDisplayProps } from './components/fieldComponentMap';
329
332
  export { clickOutside, shortcut, intersect, copyOnClick } from './actions';
333
+ export { intentPreload, preloadModule, resetIntentPreloads, INTENT_PRELOAD_BUDGET } from './intent-preload';
334
+ export type { IntentPreloadParams } from './intent-preload';
330
335
  export { default as ProfileCard } from './components/profile/ProfileCard.svelte';
331
336
  export { default as ProjectsGrid } from './components/profile/ProjectsGrid.svelte';
332
337
  export { default as ActivityTimeline } from './components/profile/ActivityTimeline.svelte';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  export { surfaceDesignContract } from "./design-contract.js";
3
3
  export { designSystemComponents, } from "./design-system-components.js";
4
4
  export { metricSurfaceClasses, tableSurfaceClasses } from "./design-system.js";
5
+ export { builtinIcons, getIconNames, hasIcon, getIconSourceNames, registerIconSource, registerIconSources, registerIcons, replaceIcons, resetIconRegistry, resolveIcon, resolveIconSource, setIconFallback, setIconMissHandler, } from "./icons.js";
5
6
  // Entry component
6
7
  export { default as AdminApp } from './components/AdminApp.svelte';
7
8
  // Admin components
@@ -26,6 +27,7 @@ export { cloneListFilter, cloneListStateSnapshot } from './components/list-state
26
27
  export { default as AutoForm } from './components/AutoForm.svelte';
27
28
  export { default as ShowPage } from './components/ShowPage.svelte';
28
29
  export { default as ConfirmDialog } from './components/ConfirmDialog.svelte';
30
+ export { default as Icon } from './components/Icon.svelte';
29
31
  export { default as Sidebar } from './components/Sidebar.svelte';
30
32
  export { default as Layout } from './components/Layout.svelte';
31
33
  export { default as Header } from './components/Header.svelte';
@@ -270,6 +272,7 @@ export { setComponentRegistry, getComponentRegistry, useComponent, } from './com
270
272
  export { builtinDisplayComponents, registerDisplayComponent, getDisplayComponent, hasDisplayComponent, } from './components/fieldComponentMap';
271
273
  // Svelte Actions
272
274
  export { clickOutside, shortcut, intersect, copyOnClick } from './actions';
275
+ export { intentPreload, preloadModule, resetIntentPreloads, INTENT_PRELOAD_BUDGET } from './intent-preload';
273
276
  // Public Profile
274
277
  export { default as ProfileCard } from './components/profile/ProfileCard.svelte';
275
278
  export { default as ProjectsGrid } from './components/profile/ProjectsGrid.svelte';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Intent preload: start a dynamic import on hover, focus, or viewport entry.
3
+ *
4
+ * This is the part of Arco's component lazy-load plugin worth keeping. It does
5
+ * not rewrite imports. SSR never calls the loader; the host renders its fallback
6
+ * until the client preloads.
7
+ */
8
+ export declare const INTENT_PRELOAD_BUDGET: Readonly<{
9
+ maxInflight: 2;
10
+ /** Source budget for this module. Enforced by intent-preload.test.ts. */
11
+ maxModuleBytes: 4000;
12
+ }>;
13
+ export interface IntentPreloadParams {
14
+ key: string;
15
+ load: () => Promise<unknown>;
16
+ }
17
+ export declare function resetIntentPreloads(): void;
18
+ /** Returns the in-flight promise, or undefined when SSR or the budget is full. */
19
+ export declare function preloadModule(key: string, loader: () => Promise<unknown>, options?: {
20
+ ssr?: boolean;
21
+ }): Promise<unknown> | undefined;
22
+ /**
23
+ * Svelte action. On the server it is a no-op so the fallback markup stays put.
24
+ */
25
+ export declare function intentPreload(node: HTMLElement, params: IntentPreloadParams): {
26
+ destroy: () => void;
27
+ update: (next: IntentPreloadParams) => void;
28
+ };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Intent preload: start a dynamic import on hover, focus, or viewport entry.
3
+ *
4
+ * This is the part of Arco's component lazy-load plugin worth keeping. It does
5
+ * not rewrite imports. SSR never calls the loader; the host renders its fallback
6
+ * until the client preloads.
7
+ */
8
+ export const INTENT_PRELOAD_BUDGET = Object.freeze({
9
+ maxInflight: 2,
10
+ /** Source budget for this module. Enforced by intent-preload.test.ts. */
11
+ maxModuleBytes: 4_000,
12
+ });
13
+ const inflight = new Map();
14
+ export function resetIntentPreloads() {
15
+ inflight.clear();
16
+ }
17
+ function onServer(ssr) {
18
+ return ssr ?? typeof window === 'undefined';
19
+ }
20
+ /** Returns the in-flight promise, or undefined when SSR or the budget is full. */
21
+ export function preloadModule(key, loader, options = {}) {
22
+ if (key.trim() === '' || onServer(options.ssr))
23
+ return undefined;
24
+ const existing = inflight.get(key);
25
+ if (existing)
26
+ return existing;
27
+ if (inflight.size >= INTENT_PRELOAD_BUDGET.maxInflight)
28
+ return undefined;
29
+ let pending;
30
+ try {
31
+ pending = Promise.resolve(loader());
32
+ }
33
+ catch (error) {
34
+ pending = Promise.reject(error);
35
+ }
36
+ const settled = pending.finally(() => {
37
+ if (inflight.get(key) === settled)
38
+ inflight.delete(key);
39
+ });
40
+ inflight.set(key, settled);
41
+ return settled;
42
+ }
43
+ /**
44
+ * Svelte action. On the server it is a no-op so the fallback markup stays put.
45
+ */
46
+ export function intentPreload(node, params) {
47
+ if (onServer(undefined))
48
+ return { destroy() { }, update() { } };
49
+ let current = params;
50
+ let started = false;
51
+ const start = () => {
52
+ if (started)
53
+ return;
54
+ started = true;
55
+ void preloadModule(current.key, current.load, { ssr: false });
56
+ };
57
+ node.addEventListener('pointerenter', start);
58
+ node.addEventListener('focus', start);
59
+ const observer = typeof IntersectionObserver === 'function'
60
+ ? new IntersectionObserver((entries) => {
61
+ if (entries.some((entry) => entry.isIntersecting))
62
+ start();
63
+ })
64
+ : undefined;
65
+ observer?.observe(node);
66
+ return {
67
+ destroy() {
68
+ node.removeEventListener('pointerenter', start);
69
+ node.removeEventListener('focus', start);
70
+ observer?.disconnect();
71
+ },
72
+ update(next) {
73
+ current = next;
74
+ },
75
+ };
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/ui",
3
- "version": "0.110.1",
3
+ "version": "0.112.0",
4
4
  "description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -88,7 +88,7 @@
88
88
  "@codemirror/lang-json": "^6.0.0",
89
89
  "@codemirror/lang-markdown": "^6.0.0",
90
90
  "@codemirror/lang-sql": "^6.0.0",
91
- "@svadmin/core": "^0.72.0",
91
+ "@svadmin/core": "^0.74.0",
92
92
  "@tanstack/svelte-query": "^6.1.48",
93
93
  "codemirror": "^6.0.0",
94
94
  "dashjs": "^4.7.4",
@@ -151,7 +151,7 @@
151
151
  }
152
152
  },
153
153
  "dependencies": {
154
- "@svadmin/devtools": "^0.6.1",
154
+ "@svadmin/devtools": "^0.6.3",
155
155
  "@svadmin/devtools-contract": "^0.3.1",
156
156
  "@vibeunion/devtools-devframe": "^0.1.0",
157
157
  "typebox": "^1.3.34",
@@ -189,7 +189,7 @@
189
189
  "@codemirror/lang-markdown": "^6.5.2",
190
190
  "@codemirror/lang-sql": "^6.10.0",
191
191
  "@happy-dom/global-registrator": "^20.11.12",
192
- "@svadmin/ai-elements": "^0.13.8",
192
+ "@svadmin/ai-elements": "^0.13.10",
193
193
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
194
194
  "@tailwindcss/cli": "4.3.3",
195
195
  "@testing-library/dom": "^10.4.1",