@skeletonlabs/skeleton-svelte 1.0.0-next.4 → 1.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion/Accordion.svelte +31 -28
- package/dist/components/Accordion/Accordion.svelte.d.ts +15 -14
- package/dist/components/Accordion/AccordionItem.svelte +58 -49
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +15 -14
- package/dist/components/Accordion/context.js +2 -7
- package/dist/components/Accordion/types.d.ts +20 -20
- package/dist/components/Accordion/types.js +1 -1
- package/dist/components/AppBar/AppBar.svelte.d.ts +15 -14
- package/dist/components/Avatar/Avatar.svelte +37 -10
- package/dist/components/Avatar/Avatar.svelte.d.ts +15 -14
- package/dist/components/Avatar/types.d.ts +9 -3
- package/dist/components/Nav/NavBar.svelte +3 -2
- package/dist/components/Nav/NavBar.svelte.d.ts +15 -13
- package/dist/components/Nav/NavRail.svelte +3 -2
- package/dist/components/Nav/NavRail.svelte.d.ts +15 -13
- package/dist/components/Nav/NavTile.svelte +5 -6
- package/dist/components/Nav/NavTile.svelte.d.ts +15 -13
- package/dist/components/Progress/Progress.svelte +46 -30
- package/dist/components/Progress/Progress.svelte.d.ts +15 -14
- package/dist/components/Progress/types.d.ts +20 -8
- package/dist/components/Progress/types.js +1 -1
- package/dist/components/ProgressRing/ProgressRing.svelte +40 -55
- package/dist/components/ProgressRing/ProgressRing.svelte.d.ts +15 -13
- package/dist/components/ProgressRing/types.d.ts +10 -13
- package/dist/components/ProgressRing/types.js +1 -1
- package/dist/components/Rating/Rating.svelte +80 -91
- package/dist/components/Rating/Rating.svelte.d.ts +15 -13
- package/dist/components/Rating/index.d.ts +2 -0
- package/dist/components/Rating/index.js +2 -0
- package/dist/components/Rating/types.d.ts +34 -51
- package/dist/components/Rating/types.js +1 -1
- package/dist/components/Segment/Segment.svelte +57 -20
- package/dist/components/Segment/Segment.svelte.d.ts +15 -13
- package/dist/components/Segment/SegmentItem.svelte +18 -34
- package/dist/components/Segment/SegmentItem.svelte.d.ts +15 -13
- package/dist/components/Segment/context.js +3 -3
- package/dist/components/Segment/types.d.ts +28 -24
- package/dist/components/Segment/types.js +1 -1
- package/dist/components/Switch/Switch.svelte +91 -60
- package/dist/components/Switch/Switch.svelte.d.ts +15 -13
- package/dist/components/Switch/types.d.ts +30 -27
- package/dist/components/Switch/types.js +1 -1
- package/dist/components/Tab/Tabs.svelte +50 -20
- package/dist/components/Tab/Tabs.svelte.d.ts +15 -14
- package/dist/components/Tab/TabsControl.svelte +32 -117
- package/dist/components/Tab/TabsControl.svelte.d.ts +15 -14
- package/dist/components/Tab/TabsPanel.svelte +12 -14
- package/dist/components/Tab/TabsPanel.svelte.d.ts +15 -14
- package/dist/components/Tab/context.d.ts +2 -0
- package/dist/components/Tab/context.js +6 -0
- package/dist/components/Tab/types.d.ts +51 -90
- package/dist/components/Tab/types.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/noop.d.ts +1 -0
- package/dist/internal/noop.js +2 -0
- package/dist/internal/snippets.d.ts +3 -0
- package/dist/internal/snippets.js +45 -0
- package/dist/internal/use-id.d.ts +2 -0
- package/dist/internal/use-id.js +5 -0
- package/package.json +28 -21
- package/dist/components/Accordion/index.d.ts +0 -6
- package/dist/components/Nav/index.d.ts +0 -9
- package/dist/components/Segment/index.d.ts +0 -6
- package/dist/components/Tab/index.d.ts +0 -8
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
<script lang="ts">import
|
|
1
|
+
<script lang="ts">import * as accordion from "@zag-js/accordion";
|
|
2
|
+
import { useMachine, normalizeProps } from "@zag-js/svelte";
|
|
3
|
+
import { useId } from "../../internal/use-id.js";
|
|
4
|
+
import { setAccordionContext } from "./context.js";
|
|
2
5
|
let {
|
|
3
|
-
multiple = false,
|
|
4
6
|
value = $bindable([]),
|
|
5
7
|
animDuration = 200,
|
|
6
8
|
// Root
|
|
@@ -13,43 +15,44 @@ let {
|
|
|
13
15
|
// Snippets
|
|
14
16
|
children,
|
|
15
17
|
iconOpen,
|
|
16
|
-
iconClosed
|
|
18
|
+
iconClosed,
|
|
19
|
+
...zagProps
|
|
17
20
|
} = $props();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
const [snapshot, send] = useMachine(
|
|
22
|
+
accordion.machine({
|
|
23
|
+
id: useId(),
|
|
24
|
+
onValueChange(details) {
|
|
25
|
+
value = details.value;
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
{
|
|
29
|
+
context: {
|
|
30
|
+
...zagProps,
|
|
31
|
+
get value() {
|
|
32
|
+
return $state.snapshot(value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
const api = $derived(accordion.connect(snapshot, send, normalizeProps));
|
|
30
38
|
setAccordionContext({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
isOpen,
|
|
39
|
+
get api() {
|
|
40
|
+
return api;
|
|
41
|
+
},
|
|
35
42
|
get animDuration() {
|
|
36
43
|
return animDuration;
|
|
37
44
|
},
|
|
38
|
-
get iconOpen() {
|
|
39
|
-
return iconOpen;
|
|
40
|
-
},
|
|
41
45
|
get iconClosed() {
|
|
42
46
|
return iconClosed;
|
|
47
|
+
},
|
|
48
|
+
get iconOpen() {
|
|
49
|
+
return iconOpen;
|
|
43
50
|
}
|
|
44
51
|
});
|
|
45
|
-
$effect(() => {
|
|
46
|
-
if (!multiple && value.length > 1)
|
|
47
|
-
value = [value[0]];
|
|
48
|
-
});
|
|
49
52
|
</script>
|
|
50
53
|
|
|
51
|
-
<!-- @component
|
|
54
|
+
<!-- @component Divide content into collapsible sections. -->
|
|
52
55
|
|
|
53
|
-
<div class="{base} {padding} {spaceY} {rounded} {width} {classes}" data-testid="accordion">
|
|
56
|
+
<div class="{base} {padding} {spaceY} {rounded} {width} {classes}" {...api.getRootProps()} data-testid="accordion">
|
|
54
57
|
{@render children()}
|
|
55
58
|
</div>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { AccordionProps } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type AccordionEvents = typeof __propDef.events;
|
|
13
|
-
export type AccordionSlots = typeof __propDef.slots;
|
|
14
|
-
/** An Accordion parent component. */
|
|
15
|
-
export default class Accordion extends SvelteComponent<AccordionProps_, AccordionEvents, AccordionSlots> {
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports;
|
|
10
|
+
z_$$bindings?: Bindings;
|
|
16
11
|
}
|
|
12
|
+
/** Divide content into collapsible sections. */
|
|
13
|
+
declare const Accordion: $$__sveltets_2_IsomorphicComponent<AccordionProps, {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
}, {}, {}, "value">;
|
|
16
|
+
type Accordion = InstanceType<typeof Accordion>;
|
|
17
|
+
export default Accordion;
|
|
@@ -1,75 +1,84 @@
|
|
|
1
1
|
<script lang="ts">import { slide } from "svelte/transition";
|
|
2
2
|
import { getAccordionContext } from "./context.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
disabled = false,
|
|
3
|
+
const {
|
|
4
|
+
headingElement = "h3",
|
|
6
5
|
// Root
|
|
7
|
-
base
|
|
8
|
-
spaceY
|
|
9
|
-
classes
|
|
6
|
+
base,
|
|
7
|
+
spaceY,
|
|
8
|
+
classes,
|
|
10
9
|
// Control
|
|
11
10
|
controlBase = "flex text-start items-center space-x-4 w-full",
|
|
12
11
|
controlHover = "hover:preset-tonal-primary",
|
|
13
12
|
controlPadding = "py-2 px-4",
|
|
14
13
|
controlRounded = "rounded",
|
|
15
|
-
controlClasses
|
|
16
|
-
//
|
|
17
|
-
|
|
14
|
+
controlClasses,
|
|
15
|
+
// Lead
|
|
16
|
+
leadBase = "",
|
|
17
|
+
leadClasses = "",
|
|
18
|
+
// Content
|
|
19
|
+
contentBase = "flex-1",
|
|
20
|
+
contentClasses = "",
|
|
21
|
+
// Indicator
|
|
22
|
+
indicatorBase = "",
|
|
23
|
+
indicatorClasses = "",
|
|
18
24
|
// Panel
|
|
19
|
-
panelBase
|
|
25
|
+
panelBase,
|
|
20
26
|
panelPadding = "py-2 px-4",
|
|
21
|
-
panelRounded
|
|
22
|
-
panelClasses
|
|
23
|
-
// Events
|
|
24
|
-
onclick = () => {
|
|
25
|
-
},
|
|
27
|
+
panelRounded,
|
|
28
|
+
panelClasses,
|
|
26
29
|
// Snippets
|
|
27
30
|
control,
|
|
28
|
-
|
|
29
|
-
panel
|
|
31
|
+
lead,
|
|
32
|
+
panel,
|
|
33
|
+
...zagProps
|
|
30
34
|
} = $props();
|
|
31
|
-
function clickHandler(event) {
|
|
32
|
-
ctx.toggle(id);
|
|
33
|
-
onclick(event);
|
|
34
|
-
}
|
|
35
35
|
const ctx = getAccordionContext();
|
|
36
36
|
</script>
|
|
37
37
|
|
|
38
|
-
<!-- @component
|
|
38
|
+
<!-- @component A accordion item component. -->
|
|
39
39
|
|
|
40
|
-
<div class="{base} {spaceY} {classes}" data-testid="accordion-item">
|
|
40
|
+
<div class="{base} {spaceY} {classes}" {...ctx.api.getItemProps(zagProps)} data-testid="accordion-item">
|
|
41
41
|
<!-- Control -->
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
{#if ctx.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
<svelte:element this={headingElement}>
|
|
43
|
+
<button
|
|
44
|
+
class="{controlBase} {controlHover} {controlPadding} {controlRounded} {controlClasses}"
|
|
45
|
+
{...ctx.api.getItemTriggerProps(zagProps)}
|
|
46
|
+
data-testid="accordion-control"
|
|
47
|
+
>
|
|
48
|
+
<!-- Lead -->
|
|
49
|
+
{#if lead}
|
|
50
|
+
<div class="{leadBase} {leadClasses}" data-testid="accordion-lead">{@render lead()}</div>
|
|
51
|
+
{/if}
|
|
52
|
+
<!-- Content -->
|
|
53
|
+
<div class="{contentBase} {contentClasses}" data-testid="accordion-control">
|
|
54
|
+
{@render control()}
|
|
55
|
+
</div>
|
|
56
|
+
<!-- Indicator -->
|
|
57
|
+
<div class="{indicatorBase} {indicatorClasses}" data-testid="accordion-indicator">
|
|
58
|
+
{#if ctx.api.value.includes(zagProps.value)}
|
|
59
|
+
{#if ctx.iconOpen}
|
|
60
|
+
{@render ctx.iconOpen()}
|
|
61
|
+
{:else}
|
|
62
|
+
−
|
|
63
|
+
{/if}
|
|
64
|
+
{:else if ctx.iconClosed}
|
|
65
|
+
{@render ctx.iconClosed()}
|
|
66
|
+
{:else}
|
|
67
|
+
+
|
|
68
|
+
{/if}
|
|
69
|
+
</div>
|
|
70
|
+
</button>
|
|
71
|
+
</svelte:element>
|
|
72
|
+
|
|
62
73
|
<!-- Panel -->
|
|
63
|
-
{#if
|
|
74
|
+
{#if ctx.api.value.includes(zagProps.value)}
|
|
64
75
|
<div
|
|
65
76
|
class="{panelBase} {panelPadding} {panelRounded} {panelClasses}"
|
|
77
|
+
{...ctx.api.getItemContentProps(zagProps)}
|
|
66
78
|
transition:slide={{ duration: ctx.animDuration }}
|
|
67
|
-
|
|
68
|
-
role="region"
|
|
69
|
-
aria-hidden={ctx.isOpen(id)}
|
|
70
|
-
aria-labelledby={id}
|
|
79
|
+
data-testid="accordion-panel"
|
|
71
80
|
>
|
|
72
|
-
{@render panel()}
|
|
81
|
+
{@render panel?.()}
|
|
73
82
|
</div>
|
|
74
83
|
{/if}
|
|
75
84
|
</div>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { AccordionItemProps } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type AccordionItemEvents = typeof __propDef.events;
|
|
13
|
-
export type AccordionItemSlots = typeof __propDef.slots;
|
|
14
|
-
/** An Accordion child item. */
|
|
15
|
-
export default class AccordionItem extends SvelteComponent<AccordionItemProps_, AccordionItemEvents, AccordionItemSlots> {
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports;
|
|
10
|
+
z_$$bindings?: Bindings;
|
|
16
11
|
}
|
|
12
|
+
/** A accordion item component. */
|
|
13
|
+
declare const AccordionItem: $$__sveltets_2_IsomorphicComponent<AccordionItemProps, {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
}, {}, {}, "">;
|
|
16
|
+
type AccordionItem = InstanceType<typeof AccordionItem>;
|
|
17
|
+
export default AccordionItem;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { createContext } from '../../internal/create-context.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
close: () => { },
|
|
5
|
-
toggle: () => { },
|
|
6
|
-
isOpen: () => false,
|
|
7
|
-
animDuration: 0
|
|
8
|
-
});
|
|
2
|
+
// @ts-expect-error - Defaults for context don't make sense, `createContext` should just throw TBH
|
|
3
|
+
export const [setAccordionContext, getAccordionContext, key] = createContext();
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import * as accordion from '@zag-js/accordion';
|
|
2
3
|
export interface AccordionContext {
|
|
3
|
-
|
|
4
|
-
close: (id: string) => void;
|
|
5
|
-
toggle: (id: string) => void;
|
|
6
|
-
isOpen: (id: string) => boolean;
|
|
4
|
+
api: ReturnType<typeof accordion.connect>;
|
|
7
5
|
animDuration: number;
|
|
8
6
|
iconOpen?: Snippet;
|
|
9
7
|
iconClosed?: Snippet;
|
|
10
8
|
}
|
|
11
|
-
export interface AccordionProps {
|
|
12
|
-
/** Enables opening multiple items at once. */
|
|
13
|
-
multiple?: boolean;
|
|
14
|
-
/** Takes an array list of open items. */
|
|
15
|
-
value?: string[];
|
|
9
|
+
export interface AccordionProps extends Omit<accordion.Context, 'id' | 'orientation'> {
|
|
16
10
|
/** The slide animation duration in milliseconds. */
|
|
17
11
|
animDuration?: number;
|
|
18
12
|
/** Sets base styles. */
|
|
@@ -34,19 +28,15 @@ export interface AccordionProps {
|
|
|
34
28
|
/** Set the closed state icon. */
|
|
35
29
|
iconClosed?: Snippet;
|
|
36
30
|
}
|
|
37
|
-
export interface AccordionItemProps {
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
/** Set a disabled state for the item. */
|
|
41
|
-
disabled?: boolean;
|
|
31
|
+
export interface AccordionItemProps extends accordion.ItemProps {
|
|
32
|
+
/** The element used as the header. */
|
|
33
|
+
headingElement?: string;
|
|
42
34
|
/** Sets base styles. */
|
|
43
35
|
base?: string;
|
|
44
36
|
/** Set vertical spacing styles. */
|
|
45
37
|
spaceY?: string;
|
|
46
38
|
/** Provide arbitrary CSS classes. */
|
|
47
39
|
classes?: string;
|
|
48
|
-
/** Triggers on item open or close. */
|
|
49
|
-
onclick?: (event: MouseEvent) => void;
|
|
50
40
|
/** Sets control's base styles. */
|
|
51
41
|
controlBase?: string;
|
|
52
42
|
/** Sets control's the hover styles. */
|
|
@@ -57,8 +47,18 @@ export interface AccordionItemProps {
|
|
|
57
47
|
controlRounded?: string;
|
|
58
48
|
/** Provide arbitrary CSS classes to the control. */
|
|
59
49
|
controlClasses?: string;
|
|
60
|
-
/**
|
|
61
|
-
|
|
50
|
+
/** Sets the lead's base styles */
|
|
51
|
+
leadBase?: string;
|
|
52
|
+
/** Provide arbitrary CSS classes to the lead. */
|
|
53
|
+
leadClasses?: string;
|
|
54
|
+
/** Sets the lead's base styles */
|
|
55
|
+
contentBase?: string;
|
|
56
|
+
/** Provide arbitrary CSS classes to the content. */
|
|
57
|
+
contentClasses?: string;
|
|
58
|
+
/** Sets the lead's base styles */
|
|
59
|
+
indicatorBase?: string;
|
|
60
|
+
/** Provide arbitrary CSS classes to the indicator. */
|
|
61
|
+
indicatorClasses?: string;
|
|
62
62
|
/** Set the panel's base styles. */
|
|
63
63
|
panelBase?: string;
|
|
64
64
|
/** Set the panel's padding styles. */
|
|
@@ -70,7 +70,7 @@ export interface AccordionItemProps {
|
|
|
70
70
|
/** The control's default slot. */
|
|
71
71
|
control: Snippet;
|
|
72
72
|
/** The control's lead icon slot. */
|
|
73
|
-
|
|
73
|
+
lead?: Snippet;
|
|
74
74
|
/** The panels's default slot. */
|
|
75
75
|
panel?: Snippet;
|
|
76
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as accordion from '@zag-js/accordion';
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { AppBarProps } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type AppBarEvents = typeof __propDef.events;
|
|
13
|
-
export type AppBarSlots = typeof __propDef.slots;
|
|
14
|
-
/** A header element for the top of a page layout. */
|
|
15
|
-
export default class AppBar extends SvelteComponent<AppBarProps_, AppBarEvents, AppBarSlots> {
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports;
|
|
10
|
+
z_$$bindings?: Bindings;
|
|
16
11
|
}
|
|
12
|
+
/** A header element for the top of a page layout. */
|
|
13
|
+
declare const AppBar: $$__sveltets_2_IsomorphicComponent<AppBarProps, {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
}, {}, {}, "">;
|
|
16
|
+
type AppBar = InstanceType<typeof AppBar>;
|
|
17
|
+
export default AppBar;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<script lang="ts">import * as avatar from "@zag-js/avatar";
|
|
2
|
+
import { useMachine, normalizeProps } from "@zag-js/svelte";
|
|
3
|
+
import { useId } from "../../internal/use-id.js";
|
|
4
|
+
let {
|
|
5
|
+
src,
|
|
6
|
+
srcset,
|
|
7
|
+
name,
|
|
8
|
+
filter,
|
|
5
9
|
// Root
|
|
6
10
|
base = "overflow-hidden isolate",
|
|
7
11
|
background = "bg-surface-400-600",
|
|
@@ -14,17 +18,40 @@
|
|
|
14
18
|
// Image
|
|
15
19
|
imageBase = "w-full object-cover",
|
|
16
20
|
imageClasses = "",
|
|
21
|
+
// Fallback
|
|
22
|
+
fallbackBase = "w-full h-full flex justify-center items-center",
|
|
23
|
+
fallbackClasses = "",
|
|
17
24
|
// Snippets
|
|
18
25
|
children
|
|
19
26
|
} = $props();
|
|
27
|
+
const [snapshot, send] = useMachine(avatar.machine({ id: useId() }));
|
|
28
|
+
const api = $derived(avatar.connect(snapshot, send, normalizeProps));
|
|
29
|
+
function getInitials(name2) {
|
|
30
|
+
return name2.split(" ").map((word) => word[0]).join("");
|
|
31
|
+
}
|
|
20
32
|
</script>
|
|
21
33
|
|
|
22
|
-
<!-- @component An image with a fallback for representing
|
|
34
|
+
<!-- @component An image with a fallback for representing a single user. -->
|
|
23
35
|
|
|
24
|
-
<figure class="{base} {background} {size} {font} {border} {rounded} {shadow} {classes}" data-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
<figure {...api.getRootProps()} class="{base} {background} {size} {font} {border} {rounded} {shadow} {classes}" data-testid="avatar">
|
|
37
|
+
<!-- Image -->
|
|
38
|
+
{#if src || srcset}
|
|
39
|
+
<img
|
|
40
|
+
{...api.getImageProps()}
|
|
41
|
+
{src}
|
|
42
|
+
{srcset}
|
|
43
|
+
alt={name}
|
|
44
|
+
class="{imageBase} {imageClasses}"
|
|
45
|
+
style:filter={filter && `url(${filter})`}
|
|
46
|
+
data-testid="avatar-image"
|
|
47
|
+
/>
|
|
29
48
|
{/if}
|
|
49
|
+
<!-- Fallback -->
|
|
50
|
+
<span {...api.getFallbackProps()} class="{fallbackBase} {fallbackClasses}" data-testid="avatar-fallback">
|
|
51
|
+
{#if children}
|
|
52
|
+
{@render children()}
|
|
53
|
+
{:else}
|
|
54
|
+
{getInitials(name)}
|
|
55
|
+
{/if}
|
|
56
|
+
</span>
|
|
30
57
|
</figure>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { AvatarProps } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type AvatarEvents = typeof __propDef.events;
|
|
13
|
-
export type AvatarSlots = typeof __propDef.slots;
|
|
14
|
-
/** An image with a fallback for representing the user. */
|
|
15
|
-
export default class Avatar extends SvelteComponent<AvatarProps_, AvatarEvents, AvatarSlots> {
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports;
|
|
10
|
+
z_$$bindings?: Bindings;
|
|
16
11
|
}
|
|
12
|
+
/** An image with a fallback for representing a single user. */
|
|
13
|
+
declare const Avatar: $$__sveltets_2_IsomorphicComponent<AvatarProps, {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
}, {}, {}, "">;
|
|
16
|
+
type Avatar = InstanceType<typeof Avatar>;
|
|
17
|
+
export default Avatar;
|
|
@@ -2,9 +2,11 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
export interface AvatarProps {
|
|
3
3
|
/** Set avatar image source URL. */
|
|
4
4
|
src?: string;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
/**
|
|
5
|
+
/** The source set of the avatar image. */
|
|
6
|
+
srcset?: string;
|
|
7
|
+
/** Provide a name or username for the avatar. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Set avatar image filter name, such as: "#Apollo". */
|
|
8
10
|
filter?: string;
|
|
9
11
|
/** Set base styles. */
|
|
10
12
|
base?: string;
|
|
@@ -26,6 +28,10 @@ export interface AvatarProps {
|
|
|
26
28
|
imageBase?: string;
|
|
27
29
|
/** Provide avatar image arbitrary CSS classes. */
|
|
28
30
|
imageClasses?: string;
|
|
31
|
+
/** Set base classes for the fallback element. */
|
|
32
|
+
fallbackBase?: string;
|
|
33
|
+
/** Provide arbitrary CSS classes to fallback element. */
|
|
34
|
+
fallbackClasses?: string;
|
|
29
35
|
/** The default child slot. */
|
|
30
36
|
children?: Snippet;
|
|
31
37
|
}
|
|
@@ -22,8 +22,7 @@ let {
|
|
|
22
22
|
} = $props();
|
|
23
23
|
function onSelectionHandler(id) {
|
|
24
24
|
value = id;
|
|
25
|
-
if (onchange)
|
|
26
|
-
onchange(id);
|
|
25
|
+
if (onchange) onchange(id);
|
|
27
26
|
}
|
|
28
27
|
setNavigationContext({
|
|
29
28
|
parent: "bar",
|
|
@@ -35,6 +34,8 @@ setNavigationContext({
|
|
|
35
34
|
});
|
|
36
35
|
</script>
|
|
37
36
|
|
|
37
|
+
<!-- @component Provides a horizontal navigation interface. -->
|
|
38
|
+
|
|
38
39
|
<aside class="{base} {background} {width} {height} {padding} {classes}" data-testid="nav-bar">
|
|
39
40
|
{#if children}
|
|
40
41
|
<nav class="{tilesBase} {tilesFlexDirection} {tilesJustify} {tilesItems} {tilesGap} {tilesClasses}">
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { NavBarProps } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type NavBarEvents = typeof __propDef.events;
|
|
13
|
-
export type NavBarSlots = typeof __propDef.slots;
|
|
14
|
-
export default class NavBar extends SvelteComponent<NavBarProps_, NavBarEvents, NavBarSlots> {
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports;
|
|
10
|
+
z_$$bindings?: Bindings;
|
|
15
11
|
}
|
|
12
|
+
/** Provides a horizontal navigation interface. */
|
|
13
|
+
declare const NavBar: $$__sveltets_2_IsomorphicComponent<NavBarProps, {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
}, {}, {}, "value">;
|
|
16
|
+
type NavBar = InstanceType<typeof NavBar>;
|
|
17
|
+
export default NavBar;
|
|
@@ -40,8 +40,7 @@ let {
|
|
|
40
40
|
} = $props();
|
|
41
41
|
function onSelectionHandler(id) {
|
|
42
42
|
value = id;
|
|
43
|
-
if (onchange)
|
|
44
|
-
onchange(id);
|
|
43
|
+
if (onchange) onchange(id);
|
|
45
44
|
}
|
|
46
45
|
setNavigationContext({
|
|
47
46
|
parent: "rail",
|
|
@@ -56,6 +55,8 @@ setNavigationContext({
|
|
|
56
55
|
let rxWidth = $derived(expanded ? widthExpanded : width);
|
|
57
56
|
</script>
|
|
58
57
|
|
|
58
|
+
<!-- @component Provides a vertical navigation interface. -->
|
|
59
|
+
|
|
59
60
|
<aside class="{base} {background} {height} {padding} {rxWidth} {classes}" data-testid="nav-rail">
|
|
60
61
|
<!-- Header -->
|
|
61
62
|
{#if header}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { NavRailProps } from './types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type NavRailEvents = typeof __propDef.events;
|
|
13
|
-
export type NavRailSlots = typeof __propDef.slots;
|
|
14
|
-
export default class NavRail extends SvelteComponent<NavRailProps_, NavRailEvents, NavRailSlots> {
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports;
|
|
10
|
+
z_$$bindings?: Bindings;
|
|
15
11
|
}
|
|
12
|
+
/** Provides a vertical navigation interface. */
|
|
13
|
+
declare const NavRail: $$__sveltets_2_IsomorphicComponent<NavRailProps, {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
}, {}, {}, "value">;
|
|
16
|
+
type NavRail = InstanceType<typeof NavRail>;
|
|
17
|
+
export default NavRail;
|
|
@@ -43,15 +43,14 @@ const classesExtended = $derived(`${expandedPadding} ${expandedGap} ${expandedCl
|
|
|
43
43
|
const rxMode = $derived(ctx.expanded ? classesExtended : classesCollapsed);
|
|
44
44
|
const rxBackground = $derived(selected || ctx.value === id ? active : `${background} ${hover}`);
|
|
45
45
|
function onClickHandler() {
|
|
46
|
-
if (onclick && !id)
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
onclick(id);
|
|
50
|
-
if (ctx.onSelectionHandler && id)
|
|
51
|
-
ctx.onSelectionHandler(id);
|
|
46
|
+
if (onclick && !id) throw new Error("No ID was provided");
|
|
47
|
+
if (onclick && id) onclick(id);
|
|
48
|
+
if (ctx.onSelectionHandler && id) ctx.onSelectionHandler(id);
|
|
52
49
|
}
|
|
53
50
|
</script>
|
|
54
51
|
|
|
52
|
+
<!-- @component An individual Navgiation component tile. -->
|
|
53
|
+
|
|
55
54
|
<svelte:element
|
|
56
55
|
this={element}
|
|
57
56
|
class="{base} {width} {rounded} {rxBackground} {rxMode}"
|