@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,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 16,
|
|
7
|
+
color = 'currentColor',
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
spin = false,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style = '',
|
|
12
|
+
...restProps
|
|
13
|
+
}: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
const dimension = $derived(typeof size === 'number' ? `${size}px` : size);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svg
|
|
19
|
+
data-svadmin-component="IconBilling"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
width={dimension}
|
|
23
|
+
height={dimension}
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke={color}
|
|
26
|
+
stroke-width={strokeWidth}
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
class={cn('svadmin-icon svadmin-icon-billing inline-block shrink-0', spin && 'animate-spin', className)}
|
|
30
|
+
style={style}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<rect x="2" y="4" width="20" height="16" rx="2" />
|
|
34
|
+
<line x1="2" y1="10" x2="22" y2="10" />
|
|
35
|
+
<line x1="6" y1="15" x2="10" y2="15" />
|
|
36
|
+
<circle cx="17" cy="15" r="1.5" />
|
|
37
|
+
</svg>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 16,
|
|
7
|
+
color = 'currentColor',
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
spin = false,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style = '',
|
|
12
|
+
...restProps
|
|
13
|
+
}: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
const dimension = $derived(typeof size === 'number' ? `${size}px` : size);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svg
|
|
19
|
+
data-svadmin-component="IconCluster"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
width={dimension}
|
|
23
|
+
height={dimension}
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke={color}
|
|
26
|
+
stroke-width={strokeWidth}
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
class={cn('svadmin-icon svadmin-icon-cluster inline-block shrink-0', spin && 'animate-spin', className)}
|
|
30
|
+
style={style}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<rect x="2" y="2" width="8" height="8" rx="2" />
|
|
34
|
+
<rect x="14" y="2" width="8" height="8" rx="2" />
|
|
35
|
+
<rect x="2" y="14" width="8" height="8" rx="2" />
|
|
36
|
+
<rect x="14" y="14" width="8" height="8" rx="2" />
|
|
37
|
+
<line x1="6" y1="10" x2="6" y2="14" />
|
|
38
|
+
<line x1="18" y1="10" x2="18" y2="14" />
|
|
39
|
+
<line x1="10" y1="6" x2="14" y2="6" />
|
|
40
|
+
<line x1="10" y1="18" x2="14" y2="18" />
|
|
41
|
+
</svg>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 16,
|
|
7
|
+
color = 'currentColor',
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
spin = false,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style = '',
|
|
12
|
+
...restProps
|
|
13
|
+
}: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
const dimension = $derived(typeof size === 'number' ? `${size}px` : size);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svg
|
|
19
|
+
data-svadmin-component="IconMonitor"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
width={dimension}
|
|
23
|
+
height={dimension}
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke={color}
|
|
26
|
+
stroke-width={strokeWidth}
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
class={cn('svadmin-icon svadmin-icon-monitor inline-block shrink-0', spin && 'animate-spin', className)}
|
|
30
|
+
style={style}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<rect x="2" y="3" width="20" height="14" rx="2" ry="2" />
|
|
34
|
+
<line x1="8" y1="21" x2="16" y2="21" />
|
|
35
|
+
<line x1="12" y1="17" x2="12" y2="21" />
|
|
36
|
+
<polyline points="6 10 9 7 12 11 15 8 18 10" />
|
|
37
|
+
</svg>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 16,
|
|
7
|
+
color = 'currentColor',
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
spin = false,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style = '',
|
|
12
|
+
...restProps
|
|
13
|
+
}: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
const dimension = $derived(typeof size === 'number' ? `${size}px` : size);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svg
|
|
19
|
+
data-svadmin-component="IconReject"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
width={dimension}
|
|
23
|
+
height={dimension}
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke={color}
|
|
26
|
+
stroke-width={strokeWidth}
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
class={cn('svadmin-icon svadmin-icon-reject inline-block shrink-0', spin && 'animate-spin', className)}
|
|
30
|
+
style={style}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<circle cx="12" cy="12" r="10" />
|
|
34
|
+
<line x1="15" y1="9" x2="9" y2="15" />
|
|
35
|
+
<line x1="9" y1="9" x2="15" y2="15" />
|
|
36
|
+
</svg>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 16,
|
|
7
|
+
color = 'currentColor',
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
spin = false,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style = '',
|
|
12
|
+
...restProps
|
|
13
|
+
}: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
const dimension = $derived(typeof size === 'number' ? `${size}px` : size);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svg
|
|
19
|
+
data-svadmin-component="IconSeal"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
width={dimension}
|
|
23
|
+
height={dimension}
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke={color}
|
|
26
|
+
stroke-width={strokeWidth}
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
class={cn('svadmin-icon svadmin-icon-seal inline-block shrink-0', spin && 'animate-spin', className)}
|
|
30
|
+
style={style}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<circle cx="12" cy="12" r="9" />
|
|
34
|
+
<circle cx="12" cy="12" r="5" stroke-dasharray="2 2" />
|
|
35
|
+
<polygon points="12 9 13 11 15.5 11 13.5 12.5 14.5 15 12 13.5 9.5 15 10.5 12.5 8.5 11 11 11" fill={color} stroke="none" />
|
|
36
|
+
</svg>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 16,
|
|
7
|
+
color = 'currentColor',
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
spin = false,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style = '',
|
|
12
|
+
...restProps
|
|
13
|
+
}: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
const dimension = $derived(typeof size === 'number' ? `${size}px` : size);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svg
|
|
19
|
+
data-svadmin-component="IconSecurity"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
width={dimension}
|
|
23
|
+
height={dimension}
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke={color}
|
|
26
|
+
stroke-width={strokeWidth}
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
class={cn('svadmin-icon svadmin-icon-security inline-block shrink-0', spin && 'animate-spin', className)}
|
|
30
|
+
style={style}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" />
|
|
34
|
+
<polyline points="9 12 11 14 15 10" />
|
|
35
|
+
</svg>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 16,
|
|
7
|
+
color = 'currentColor',
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
spin = false,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style = '',
|
|
12
|
+
...restProps
|
|
13
|
+
}: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
const dimension = $derived(typeof size === 'number' ? `${size}px` : size);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svg
|
|
19
|
+
data-svadmin-component="IconTenant"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
width={dimension}
|
|
23
|
+
height={dimension}
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke={color}
|
|
26
|
+
stroke-width={strokeWidth}
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
class={cn('svadmin-icon svadmin-icon-tenant inline-block shrink-0', spin && 'animate-spin', className)}
|
|
30
|
+
style={style}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<path d="M3 21h18" />
|
|
34
|
+
<path d="M5 21V7l8-4v18" />
|
|
35
|
+
<path d="M19 21V11l-6-3" />
|
|
36
|
+
<line x1="9" y1="9" x2="9" y2="9.01" />
|
|
37
|
+
<line x1="9" y1="13" x2="9" y2="13.01" />
|
|
38
|
+
<line x1="9" y1="17" x2="9" y2="17.01" />
|
|
39
|
+
</svg>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from './types.js';
|
|
3
|
+
import { cn } from '../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 16,
|
|
7
|
+
color = 'currentColor',
|
|
8
|
+
strokeWidth = 2,
|
|
9
|
+
spin = false,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style = '',
|
|
12
|
+
...restProps
|
|
13
|
+
}: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
const dimension = $derived(typeof size === 'number' ? `${size}px` : size);
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<svg
|
|
19
|
+
data-svadmin-component="IconWorkflow"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
width={dimension}
|
|
23
|
+
height={dimension}
|
|
24
|
+
fill="none"
|
|
25
|
+
stroke={color}
|
|
26
|
+
stroke-width={strokeWidth}
|
|
27
|
+
stroke-linecap="round"
|
|
28
|
+
stroke-linejoin="round"
|
|
29
|
+
class={cn('svadmin-icon svadmin-icon-workflow inline-block shrink-0', spin && 'animate-spin', className)}
|
|
30
|
+
style={style}
|
|
31
|
+
{...restProps}
|
|
32
|
+
>
|
|
33
|
+
<rect x="3" y="3" width="6" height="6" rx="1" />
|
|
34
|
+
<rect x="15" y="3" width="6" height="6" rx="1" />
|
|
35
|
+
<rect x="9" y="15" width="6" height="6" rx="1" />
|
|
36
|
+
<path d="M6 9v3a3 3 0 0 0 3 3h3" />
|
|
37
|
+
<path d="M18 9v3a3 3 0 0 1-3 3" />
|
|
38
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { IconProps } from './types.js';
|
|
2
|
+
export { default as IconAudit } from './IconAudit.svelte';
|
|
3
|
+
export { default as IconWorkflow } from './IconWorkflow.svelte';
|
|
4
|
+
export { default as IconSeal } from './IconSeal.svelte';
|
|
5
|
+
export { default as IconTenant } from './IconTenant.svelte';
|
|
6
|
+
export { default as IconMonitor } from './IconMonitor.svelte';
|
|
7
|
+
export { default as IconSecurity } from './IconSecurity.svelte';
|
|
8
|
+
export { default as IconBilling } from './IconBilling.svelte';
|
|
9
|
+
export { default as IconCluster } from './IconCluster.svelte';
|
|
10
|
+
export { default as IconApprove } from './IconApprove.svelte';
|
|
11
|
+
export { default as IconReject } from './IconReject.svelte';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as IconAudit } from './IconAudit.svelte';
|
|
2
|
+
export { default as IconWorkflow } from './IconWorkflow.svelte';
|
|
3
|
+
export { default as IconSeal } from './IconSeal.svelte';
|
|
4
|
+
export { default as IconTenant } from './IconTenant.svelte';
|
|
5
|
+
export { default as IconMonitor } from './IconMonitor.svelte';
|
|
6
|
+
export { default as IconSecurity } from './IconSecurity.svelte';
|
|
7
|
+
export { default as IconBilling } from './IconBilling.svelte';
|
|
8
|
+
export { default as IconCluster } from './IconCluster.svelte';
|
|
9
|
+
export { default as IconApprove } from './IconApprove.svelte';
|
|
10
|
+
export { default as IconReject } from './IconReject.svelte';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IconProps {
|
|
2
|
+
/** Icon width and height in px or string */
|
|
3
|
+
size?: number | string;
|
|
4
|
+
/** Fill or stroke color */
|
|
5
|
+
color?: string;
|
|
6
|
+
/** Stroke width in px */
|
|
7
|
+
strokeWidth?: number;
|
|
8
|
+
/** Whether the icon has continuous rotation */
|
|
9
|
+
spin?: boolean;
|
|
10
|
+
/** Additional CSS class names */
|
|
11
|
+
class?: string;
|
|
12
|
+
/** Inline style string */
|
|
13
|
+
style?: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SchemaFormComputed, SchemaFormCondition } from '@svadmin/core/schema-form';
|
|
1
|
+
import type { SchemaFormComputed, SchemaFormCondition, SchemaFormLayout } from '@svadmin/core/schema-form';
|
|
2
2
|
/** 嵌套表单的草稿与传输语义;不是替代服务端的 JSON Schema 校验器。 */
|
|
3
3
|
export interface JsonSchemaFormSchema {
|
|
4
4
|
$schema?: string;
|
|
@@ -36,6 +36,8 @@ export interface JsonSchemaFormSchema {
|
|
|
36
36
|
required?: string[];
|
|
37
37
|
visibleWhen?: SchemaFormCondition;
|
|
38
38
|
computed?: SchemaFormComputed;
|
|
39
|
+
/** 呈现分组。不参与草稿、传输或校验。 */
|
|
40
|
+
layout?: SchemaFormLayout;
|
|
39
41
|
}
|
|
40
42
|
export declare const SCHEMA_FORM_LIMITS: Readonly<{
|
|
41
43
|
depth: 32;
|
package/dist/icon-registry.d.ts
CHANGED
|
@@ -12,6 +12,26 @@
|
|
|
12
12
|
import type { Component } from 'svelte';
|
|
13
13
|
/** Minimal icon component contract used by navigation surfaces. */
|
|
14
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
|
+
}
|
|
15
35
|
/** Handler invoked once per missing icon name. Keep it cheap: no throwing. */
|
|
16
36
|
export type IconMissHandler = (name: string) => void;
|
|
17
37
|
export interface IconRegistry {
|
|
@@ -21,6 +41,13 @@ export interface IconRegistry {
|
|
|
21
41
|
}): void;
|
|
22
42
|
/** Replace the built-in vocabulary as well as registrations (design-system swap). */
|
|
23
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[];
|
|
24
51
|
/** Resolve a name, optionally falling back to a caller-provided component. */
|
|
25
52
|
resolveIcon(name: string | undefined, fallback?: IconComponent): IconComponent | undefined;
|
|
26
53
|
hasIcon(name: string): boolean;
|
package/dist/icon-registry.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
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
|
+
}
|
|
1
16
|
export function createIconRegistry(builtinIcons = {}) {
|
|
2
17
|
const original = new Map(Object.entries(builtinIcons));
|
|
3
18
|
let builtin = new Map(original);
|
|
4
19
|
const registered = new Map();
|
|
20
|
+
const sources = new Map();
|
|
21
|
+
let defaultSource;
|
|
5
22
|
const missing = new Set();
|
|
6
23
|
let fallback;
|
|
7
24
|
let onMiss;
|
|
@@ -40,6 +57,39 @@ export function createIconRegistry(builtinIcons = {}) {
|
|
|
40
57
|
builtin = new Map(Object.entries(icons).filter(([name, icon]) => name.trim() !== '' && typeof icon === 'function'));
|
|
41
58
|
registered.clear();
|
|
42
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
|
+
},
|
|
43
93
|
resolveIcon(name, fallbackIcon) {
|
|
44
94
|
if (name === undefined || name === '')
|
|
45
95
|
return fallbackIcon ?? fallback;
|
|
@@ -66,6 +116,8 @@ export function createIconRegistry(builtinIcons = {}) {
|
|
|
66
116
|
resetIconRegistry() {
|
|
67
117
|
builtin = new Map(original);
|
|
68
118
|
registered.clear();
|
|
119
|
+
sources.clear();
|
|
120
|
+
defaultSource = undefined;
|
|
69
121
|
fallback = undefined;
|
|
70
122
|
onMiss = undefined;
|
|
71
123
|
missing.clear();
|
package/dist/icons.d.ts
CHANGED
|
@@ -8,7 +8,11 @@ export declare const registerIcons: (icons: Readonly<Record<string, IconComponen
|
|
|
8
8
|
export declare const resolveIcon: (name: string | undefined, fallback?: IconComponent) => IconComponent | undefined;
|
|
9
9
|
export declare const hasIcon: (name: string) => boolean;
|
|
10
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[];
|
|
11
15
|
export declare const setIconFallback: (icon: IconComponent | undefined) => void;
|
|
12
16
|
export declare const setIconMissHandler: (handler: import("./icon-registry.js").IconMissHandler | undefined) => void;
|
|
13
17
|
export declare const resetIconRegistry: () => void;
|
|
14
|
-
export type { IconComponent, IconMissHandler, IconRegistry } from './icon-registry.js';
|
|
18
|
+
export type { IconComponent, IconMissHandler, IconRegistry, IconSource, IconSourceInput } from './icon-registry.js';
|
package/dist/icons.js
CHANGED
|
@@ -58,6 +58,10 @@ export const registerIcons = registry.registerIcons;
|
|
|
58
58
|
export const resolveIcon = registry.resolveIcon;
|
|
59
59
|
export const hasIcon = registry.hasIcon;
|
|
60
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;
|
|
61
65
|
export const setIconFallback = registry.setIconFallback;
|
|
62
66
|
export const setIconMissHandler = registry.setIconMissHandler;
|
|
63
67
|
export const resetIconRegistry = registry.resetIconRegistry;
|