@skeletonlabs/skeleton-svelte 1.0.0-next.8 → 1.0.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/README.md +1 -1
- package/dist/components/Accordion/Accordion.svelte +49 -52
- package/dist/components/Accordion/Accordion.svelte.d.ts +2 -14
- package/dist/components/Accordion/AccordionItem.svelte +43 -37
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +2 -14
- package/dist/components/Accordion/context.js +2 -1
- package/dist/components/Accordion/index.d.ts +4 -0
- package/dist/components/Accordion/index.js +1 -1
- package/dist/components/Accordion/types.d.ts +7 -9
- package/dist/components/AppBar/AppBar.svelte +43 -40
- package/dist/components/AppBar/AppBar.svelte.d.ts +2 -14
- package/dist/components/Avatar/Avatar.svelte +56 -44
- package/dist/components/Avatar/Avatar.svelte.d.ts +2 -14
- package/dist/components/Avatar/types.d.ts +3 -3
- package/dist/components/Combobox/Combobox.svelte +144 -0
- package/dist/components/Combobox/Combobox.svelte.d.ts +18 -0
- package/dist/components/Combobox/types.d.ts +64 -0
- package/dist/components/Combobox/types.js +1 -0
- package/dist/components/FileUpload/FileUpload.svelte +70 -63
- package/dist/components/FileUpload/FileUpload.svelte.d.ts +2 -14
- package/dist/components/FileUpload/types.d.ts +3 -4
- package/dist/components/Modal/Modal.svelte +87 -0
- package/dist/components/Modal/Modal.svelte.d.ts +4 -0
- package/dist/components/Modal/types.d.ts +57 -0
- package/dist/components/Modal/types.js +1 -0
- package/dist/components/Navigation/NavBar.svelte +48 -0
- package/dist/components/Navigation/NavBar.svelte.d.ts +5 -0
- package/dist/components/Navigation/NavRail.svelte +90 -0
- package/dist/components/Navigation/NavRail.svelte.d.ts +5 -0
- package/dist/components/Navigation/NavTile.svelte +87 -0
- package/dist/components/Navigation/NavTile.svelte.d.ts +5 -0
- package/dist/components/Navigation/context.js +7 -0
- package/dist/components/Navigation/index.d.ts +6 -0
- package/dist/components/{Nav → Navigation}/index.js +1 -1
- package/dist/components/{Nav → Navigation}/types.d.ts +5 -3
- package/dist/components/Pagination/Pagination.svelte +58 -67
- package/dist/components/Pagination/Pagination.svelte.d.ts +2 -14
- package/dist/components/Pagination/types.d.ts +15 -15
- package/dist/components/Popover/Popover.svelte +78 -0
- package/dist/components/Popover/Popover.svelte.d.ts +4 -0
- package/dist/components/Popover/types.d.ts +42 -0
- package/dist/components/Popover/types.js +1 -0
- package/dist/components/Progress/Progress.svelte +44 -38
- package/dist/components/Progress/Progress.svelte.d.ts +2 -14
- package/dist/components/Progress/types.d.ts +1 -1
- package/dist/components/ProgressRing/ProgressRing.svelte +58 -46
- package/dist/components/ProgressRing/ProgressRing.svelte.d.ts +2 -14
- package/dist/components/ProgressRing/types.d.ts +3 -1
- package/dist/components/Rating/Rating.svelte +101 -57
- package/dist/components/Rating/Rating.svelte.d.ts +2 -14
- package/dist/components/Rating/types.d.ts +1 -5
- package/dist/components/Segment/Segment.svelte +59 -67
- package/dist/components/Segment/Segment.svelte.d.ts +3 -15
- package/dist/components/Segment/SegmentItem.svelte +28 -21
- package/dist/components/Segment/SegmentItem.svelte.d.ts +2 -14
- package/dist/components/Segment/context.js +3 -2
- package/dist/components/Segment/index.d.ts +4 -0
- package/dist/components/Segment/index.js +1 -1
- package/dist/components/Segment/types.d.ts +8 -10
- package/dist/components/Slider/Slider.svelte +67 -72
- package/dist/components/Slider/Slider.svelte.d.ts +2 -14
- package/dist/components/Slider/types.d.ts +5 -9
- package/dist/components/Switch/Switch.svelte +75 -90
- package/dist/components/Switch/Switch.svelte.d.ts +2 -14
- package/dist/components/Switch/types.d.ts +2 -8
- package/dist/components/Tabs/Tabs.svelte +59 -0
- package/dist/components/Tabs/Tabs.svelte.d.ts +5 -0
- package/dist/components/Tabs/TabsControl.svelte +51 -0
- package/dist/components/Tabs/TabsControl.svelte.d.ts +5 -0
- package/dist/components/Tabs/TabsPanel.svelte +23 -0
- package/dist/components/Tabs/TabsPanel.svelte.d.ts +5 -0
- package/dist/components/{Tab → Tabs}/context.js +3 -2
- package/dist/components/Tabs/index.d.ts +5 -0
- package/dist/components/{Tab → Tabs}/index.js +1 -1
- package/dist/components/{Tab → Tabs}/types.d.ts +1 -3
- package/dist/components/TagsInput/TagsInput.svelte +48 -54
- package/dist/components/TagsInput/TagsInput.svelte.d.ts +2 -14
- package/dist/components/TagsInput/types.d.ts +3 -7
- package/dist/components/Toast/ToastProvider.svelte +133 -0
- package/dist/components/Toast/ToastProvider.svelte.d.ts +4 -0
- package/dist/components/Toast/types.d.ts +87 -0
- package/dist/components/Tooltip/Tooltip.svelte +79 -0
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +4 -0
- package/dist/components/Tooltip/types.d.ts +44 -0
- package/dist/components/Tooltip/types.js +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +11 -2
- package/dist/internal/create-context.d.ts +6 -0
- package/dist/internal/create-context.js +3 -3
- package/dist/internal/test-utils.d.ts +3 -0
- package/dist/internal/test-utils.js +9 -0
- package/package.json +43 -54
- package/dist/components/Accordion/Accordion.svelte.spec.js +0 -4
- package/dist/components/Nav/NavBar.svelte +0 -45
- package/dist/components/Nav/NavBar.svelte.d.ts +0 -17
- package/dist/components/Nav/NavRail.svelte +0 -79
- package/dist/components/Nav/NavRail.svelte.d.ts +0 -17
- package/dist/components/Nav/NavTile.svelte +0 -76
- package/dist/components/Nav/NavTile.svelte.d.ts +0 -17
- package/dist/components/Nav/context.js +0 -7
- package/dist/components/Tab/Tabs.svelte +0 -65
- package/dist/components/Tab/Tabs.svelte.d.ts +0 -17
- package/dist/components/Tab/TabsControl.svelte +0 -42
- package/dist/components/Tab/TabsControl.svelte.d.ts +0 -17
- package/dist/components/Tab/TabsPanel.svelte +0 -18
- package/dist/components/Tab/TabsPanel.svelte.d.ts +0 -17
- package/dist/internal/noop.d.ts +0 -1
- package/dist/internal/noop.js +0 -2
- package/dist/internal/snippets.d.ts +0 -3
- package/dist/internal/snippets.js +0 -45
- package/dist/internal/use-id.d.ts +0 -2
- package/dist/internal/use-id.js +0 -5
- /package/dist/components/{Nav → Navigation}/context.d.ts +0 -0
- /package/dist/components/{Nav → Navigation}/types.js +0 -0
- /package/dist/components/{Tab → Tabs}/context.d.ts +0 -0
- /package/dist/components/{Tab → Tabs}/types.js +0 -0
- /package/dist/components/{Accordion/Accordion.svelte.spec.d.ts → Toast/types.js} +0 -0
package/README.md
CHANGED
|
@@ -1,58 +1,55 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { setAccordionContext } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return iconOpen;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as accordion from '@zag-js/accordion';
|
|
3
|
+
import { useMachine, normalizeProps } from '@zag-js/svelte';
|
|
4
|
+
import { setAccordionContext } from './context.js';
|
|
5
|
+
import type { AccordionProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
// Props
|
|
8
|
+
const {
|
|
9
|
+
animationConfig = {
|
|
10
|
+
duration: 200
|
|
11
|
+
},
|
|
12
|
+
// Root
|
|
13
|
+
base = '',
|
|
14
|
+
padding = '',
|
|
15
|
+
spaceY = 'space-y-2',
|
|
16
|
+
rounded = 'rounded-base',
|
|
17
|
+
width = 'w-full',
|
|
18
|
+
classes = '',
|
|
19
|
+
// Snippets
|
|
20
|
+
children,
|
|
21
|
+
iconOpen,
|
|
22
|
+
iconClosed,
|
|
23
|
+
...zagProps
|
|
24
|
+
}: AccordionProps = $props();
|
|
25
|
+
|
|
26
|
+
// Zag
|
|
27
|
+
const id = $props.id();
|
|
28
|
+
const service = useMachine(accordion.machine, () => ({
|
|
29
|
+
id: id,
|
|
30
|
+
...zagProps
|
|
31
|
+
}));
|
|
32
|
+
const api = $derived(accordion.connect(service, normalizeProps));
|
|
33
|
+
|
|
34
|
+
// Context
|
|
35
|
+
setAccordionContext({
|
|
36
|
+
get api() {
|
|
37
|
+
return api;
|
|
38
|
+
},
|
|
39
|
+
get animationConfig() {
|
|
40
|
+
return animationConfig;
|
|
41
|
+
},
|
|
42
|
+
get iconClosed() {
|
|
43
|
+
return iconClosed;
|
|
44
|
+
},
|
|
45
|
+
get iconOpen() {
|
|
46
|
+
return iconOpen;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
52
49
|
</script>
|
|
53
50
|
|
|
54
51
|
<!-- @component Divide content into collapsible sections. -->
|
|
55
52
|
|
|
56
53
|
<div class="{base} {padding} {spaceY} {rounded} {width} {classes}" {...api.getRootProps()} data-testid="accordion">
|
|
57
|
-
{@render children()}
|
|
54
|
+
{@render children?.()}
|
|
58
55
|
</div>
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { AccordionProps } from './types.js';
|
|
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;
|
|
11
|
-
}
|
|
12
2
|
/** Divide content into collapsible sections. */
|
|
13
|
-
declare const Accordion:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "value">;
|
|
16
|
-
type Accordion = InstanceType<typeof Accordion>;
|
|
3
|
+
declare const Accordion: import("svelte").Component<AccordionProps, {}, "">;
|
|
4
|
+
type Accordion = ReturnType<typeof Accordion>;
|
|
17
5
|
export default Accordion;
|
|
@@ -1,45 +1,51 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { slide } from 'svelte/transition';
|
|
3
|
+
import { getAccordionContext } from './context.js';
|
|
4
|
+
import type { AccordionItemProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
// Props
|
|
7
|
+
const {
|
|
8
|
+
headingLevel = 3,
|
|
9
|
+
// Root
|
|
10
|
+
base,
|
|
11
|
+
spaceY,
|
|
12
|
+
classes,
|
|
13
|
+
// Control
|
|
14
|
+
controlBase = 'flex text-start items-center space-x-4 w-full',
|
|
15
|
+
controlHover = 'hover:preset-tonal-primary',
|
|
16
|
+
controlPadding = 'py-2 px-4',
|
|
17
|
+
controlRounded = 'rounded-base',
|
|
18
|
+
controlClasses,
|
|
19
|
+
// Lead
|
|
20
|
+
leadBase = '',
|
|
21
|
+
leadClasses = '',
|
|
22
|
+
// Content
|
|
23
|
+
contentBase = 'flex-1',
|
|
24
|
+
contentClasses = '',
|
|
25
|
+
// Indicator
|
|
26
|
+
indicatorBase = '',
|
|
27
|
+
indicatorClasses = '',
|
|
28
|
+
// Panel
|
|
29
|
+
panelBase,
|
|
30
|
+
panelPadding = 'py-2 px-4',
|
|
31
|
+
panelRounded,
|
|
32
|
+
panelClasses,
|
|
33
|
+
// Snippets
|
|
34
|
+
control,
|
|
35
|
+
lead,
|
|
36
|
+
panel,
|
|
37
|
+
...zagProps
|
|
38
|
+
}: AccordionItemProps = $props();
|
|
39
|
+
|
|
40
|
+
// Context
|
|
41
|
+
const ctx = getAccordionContext();
|
|
36
42
|
</script>
|
|
37
43
|
|
|
38
44
|
<!-- @component A accordion item component. -->
|
|
39
45
|
|
|
40
46
|
<div class="{base} {spaceY} {classes}" {...ctx.api.getItemProps(zagProps)} data-testid="accordion-item">
|
|
41
47
|
<!-- Control -->
|
|
42
|
-
<svelte:element this={
|
|
48
|
+
<svelte:element this={`h${headingLevel}`}>
|
|
43
49
|
<button
|
|
44
50
|
class="{controlBase} {controlHover} {controlPadding} {controlRounded} {controlClasses}"
|
|
45
51
|
{...ctx.api.getItemTriggerProps(zagProps)}
|
|
@@ -75,7 +81,7 @@ const ctx = getAccordionContext();
|
|
|
75
81
|
<div
|
|
76
82
|
class="{panelBase} {panelPadding} {panelRounded} {panelClasses}"
|
|
77
83
|
{...ctx.api.getItemContentProps(zagProps)}
|
|
78
|
-
transition:slide={
|
|
84
|
+
transition:slide={ctx.animationConfig}
|
|
79
85
|
data-testid="accordion-panel"
|
|
80
86
|
>
|
|
81
87
|
{@render panel?.()}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { AccordionItemProps } from './types.js';
|
|
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;
|
|
11
|
-
}
|
|
12
2
|
/** A accordion item component. */
|
|
13
|
-
declare const AccordionItem:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "">;
|
|
16
|
-
type AccordionItem = InstanceType<typeof AccordionItem>;
|
|
3
|
+
declare const AccordionItem: import("svelte").Component<AccordionItemProps, {}, "">;
|
|
4
|
+
type AccordionItem = ReturnType<typeof AccordionItem>;
|
|
17
5
|
export default AccordionItem;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { createContext } from '../../internal/create-context.js';
|
|
2
3
|
// @ts-expect-error - Defaults for context don't make sense, `createContext` should just throw TBH
|
|
3
|
-
export
|
|
4
|
+
export var setAccordionContext = (_a = createContext(), _a[0]), getAccordionContext = _a[1], key = _a[2];
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import * as accordion from '@zag-js/accordion';
|
|
3
|
-
|
|
3
|
+
import type { SlideParams } from 'svelte/transition';
|
|
4
|
+
export interface AccordionContext extends Pick<AccordionProps, 'animationConfig' | 'iconOpen' | 'iconClosed'> {
|
|
4
5
|
api: ReturnType<typeof accordion.connect>;
|
|
5
|
-
animDuration: number;
|
|
6
|
-
iconOpen?: Snippet;
|
|
7
|
-
iconClosed?: Snippet;
|
|
8
6
|
}
|
|
9
|
-
export interface AccordionProps extends Omit<accordion.
|
|
10
|
-
/** The
|
|
11
|
-
|
|
7
|
+
export interface AccordionProps extends Omit<accordion.Props, 'id' | 'orientation'> {
|
|
8
|
+
/** The animation configuration */
|
|
9
|
+
animationConfig?: SlideParams;
|
|
12
10
|
/** Sets base styles. */
|
|
13
11
|
base?: string;
|
|
14
12
|
/** Set padding styles. */
|
|
@@ -29,8 +27,8 @@ export interface AccordionProps extends Omit<accordion.Context, 'id' | 'orientat
|
|
|
29
27
|
iconClosed?: Snippet;
|
|
30
28
|
}
|
|
31
29
|
export interface AccordionItemProps extends accordion.ItemProps {
|
|
32
|
-
/** The
|
|
33
|
-
|
|
30
|
+
/** The heading level. */
|
|
31
|
+
headingLevel?: number;
|
|
34
32
|
/** Sets base styles. */
|
|
35
33
|
base?: string;
|
|
36
34
|
/** Set vertical spacing styles. */
|
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { AppBarProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
const {
|
|
5
|
+
// Root
|
|
6
|
+
base = 'w-full flex flex-col',
|
|
7
|
+
background = 'bg-surface-100-900',
|
|
8
|
+
spaceY = 'space-y-4',
|
|
9
|
+
border = '',
|
|
10
|
+
padding = 'p-4',
|
|
11
|
+
shadow = '',
|
|
12
|
+
classes = '',
|
|
13
|
+
// Toolbar
|
|
14
|
+
toolbarBase = 'flex justify-between',
|
|
15
|
+
toolbarGridCols = 'grid-cols-[auto_1fr_auto]',
|
|
16
|
+
toolbarGap = 'gap-4',
|
|
17
|
+
toolbarClasses = '',
|
|
18
|
+
// Lead
|
|
19
|
+
leadBase = 'flex',
|
|
20
|
+
leadSpaceX = 'space-x-4 rtl:space-x-reverse',
|
|
21
|
+
leadPadding = '',
|
|
22
|
+
leadClasses = '',
|
|
23
|
+
// Center
|
|
24
|
+
centerBase = 'grow',
|
|
25
|
+
centerAlign = 'text-center',
|
|
26
|
+
centerPadding = '',
|
|
27
|
+
centerClasses = '',
|
|
28
|
+
// Trail
|
|
29
|
+
trailBase = 'flex',
|
|
30
|
+
trailSpaceX = 'space-x-4 rtl:space-x-reverse',
|
|
31
|
+
trailPadding = '',
|
|
32
|
+
trailClasses = '',
|
|
33
|
+
// Headline
|
|
34
|
+
headlineBase = 'w-full',
|
|
35
|
+
headlineClasses = '',
|
|
36
|
+
// Snippets
|
|
37
|
+
children,
|
|
38
|
+
lead,
|
|
39
|
+
trail,
|
|
40
|
+
headline
|
|
41
|
+
}: AppBarProps = $props();
|
|
39
42
|
</script>
|
|
40
43
|
|
|
41
44
|
<!-- @component A header element for the top of a page layout. -->
|
|
42
45
|
|
|
43
46
|
<header class="{base} {background} {spaceY} {border} {padding} {shadow} {classes}" role="toolbar" data-testid="app-bar">
|
|
44
|
-
<section class="{toolbarBase} {toolbarGridCols} {toolbarGap} {toolbarClasses}">
|
|
47
|
+
<section class="{toolbarBase} {toolbarGridCols} {toolbarGap} {toolbarClasses}" data-testid="app-bar-toolbar">
|
|
45
48
|
{#if lead}
|
|
46
49
|
<div class="{leadBase} {leadSpaceX} {leadPadding} {leadClasses}">
|
|
47
50
|
{@render lead()}
|
|
@@ -62,7 +65,7 @@
|
|
|
62
65
|
</section>
|
|
63
66
|
|
|
64
67
|
{#if headline}
|
|
65
|
-
<section class="{headlineBase} {headlineClasses}">
|
|
68
|
+
<section class="{headlineBase} {headlineClasses}" data-testid="app-bar-headline">
|
|
66
69
|
{@render headline()}
|
|
67
70
|
</section>
|
|
68
71
|
{/if}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { AppBarProps } from './types.js';
|
|
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;
|
|
11
|
-
}
|
|
12
2
|
/** A header element for the top of a page layout. */
|
|
13
|
-
declare const AppBar:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "">;
|
|
16
|
-
type AppBar = InstanceType<typeof AppBar>;
|
|
3
|
+
declare const AppBar: import("svelte").Component<AppBarProps, {}, "">;
|
|
4
|
+
type AppBar = ReturnType<typeof AppBar>;
|
|
17
5
|
export default AppBar;
|
|
@@ -1,51 +1,59 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as avatar from '@zag-js/avatar';
|
|
3
|
+
import { useMachine, normalizeProps } from '@zag-js/svelte';
|
|
4
|
+
import type { AvatarProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
src,
|
|
8
|
+
srcset,
|
|
9
|
+
name,
|
|
10
|
+
// Root
|
|
11
|
+
base = 'overflow-hidden isolate',
|
|
12
|
+
background = 'bg-surface-400-600',
|
|
13
|
+
size = 'size-16',
|
|
14
|
+
font = '',
|
|
15
|
+
border = '',
|
|
16
|
+
rounded = 'rounded-full',
|
|
17
|
+
shadow = '',
|
|
18
|
+
classes = '',
|
|
19
|
+
// Image
|
|
20
|
+
imageBase = 'w-full object-cover',
|
|
21
|
+
imageClasses = '',
|
|
22
|
+
style = '',
|
|
23
|
+
// Fallback
|
|
24
|
+
fallbackBase = 'w-full h-full flex justify-center items-center',
|
|
25
|
+
fallbackClasses = '',
|
|
26
|
+
// Snippets
|
|
27
|
+
children,
|
|
28
|
+
// Zag
|
|
29
|
+
...zagProps
|
|
30
|
+
}: AvatarProps = $props();
|
|
31
|
+
|
|
32
|
+
// Zag
|
|
33
|
+
const id = $props.id();
|
|
34
|
+
const service = useMachine(avatar.machine, () => ({
|
|
35
|
+
id: id,
|
|
36
|
+
...zagProps
|
|
37
|
+
}));
|
|
38
|
+
const api = $derived(avatar.connect(service, normalizeProps));
|
|
39
|
+
|
|
40
|
+
// Generate Initials
|
|
41
|
+
function getInitials(name: string) {
|
|
42
|
+
return name
|
|
43
|
+
.split(' ')
|
|
44
|
+
.map((word) => word[0])
|
|
45
|
+
.join('');
|
|
46
|
+
}
|
|
32
47
|
</script>
|
|
33
48
|
|
|
34
49
|
<!-- @component An image with a fallback for representing a single user. -->
|
|
35
50
|
|
|
36
|
-
<figure
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{srcset}
|
|
43
|
-
alt={name}
|
|
44
|
-
class="{imageBase} {imageClasses}"
|
|
45
|
-
style:filter={filter && `url(${filter})`}
|
|
46
|
-
data-testid="avatar-image"
|
|
47
|
-
/>
|
|
48
|
-
{/if}
|
|
51
|
+
<figure
|
|
52
|
+
{...api.getRootProps()}
|
|
53
|
+
class="{base} {background} {size} {font} {border} {rounded} {shadow} {classes}"
|
|
54
|
+
{style}
|
|
55
|
+
data-testid="avatar"
|
|
56
|
+
>
|
|
49
57
|
<!-- Fallback -->
|
|
50
58
|
<span {...api.getFallbackProps()} class="{fallbackBase} {fallbackClasses}" data-testid="avatar-fallback">
|
|
51
59
|
{#if children}
|
|
@@ -54,4 +62,8 @@ function getInitials(name2) {
|
|
|
54
62
|
{getInitials(name)}
|
|
55
63
|
{/if}
|
|
56
64
|
</span>
|
|
65
|
+
<!-- Image -->
|
|
66
|
+
{#if src || srcset}
|
|
67
|
+
<img {...api.getImageProps()} {src} {srcset} alt={name} class="{imageBase} {imageClasses}" data-testid="avatar-image" />
|
|
68
|
+
{/if}
|
|
57
69
|
</figure>
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { AvatarProps } from './types.js';
|
|
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;
|
|
11
|
-
}
|
|
12
2
|
/** An image with a fallback for representing a single user. */
|
|
13
|
-
declare const Avatar:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "">;
|
|
16
|
-
type Avatar = InstanceType<typeof Avatar>;
|
|
3
|
+
declare const Avatar: import("svelte").Component<AvatarProps, {}, "">;
|
|
4
|
+
type Avatar = ReturnType<typeof Avatar>;
|
|
17
5
|
export default Avatar;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
1
2
|
import type { Snippet } from 'svelte';
|
|
2
|
-
|
|
3
|
+
import type * as avatar from '@zag-js/avatar';
|
|
4
|
+
export interface AvatarProps extends Omit<avatar.Props, 'id'>, Pick<HTMLAttributes<HTMLElement>, 'style'> {
|
|
3
5
|
/** Set avatar image source URL. */
|
|
4
6
|
src?: string;
|
|
5
7
|
/** The source set of the avatar image. */
|
|
6
8
|
srcset?: string;
|
|
7
9
|
/** Provide a name or username for the avatar. */
|
|
8
10
|
name: string;
|
|
9
|
-
/** Set avatar image filter name, such as: "#Apollo". */
|
|
10
|
-
filter?: string;
|
|
11
11
|
/** Set base styles. */
|
|
12
12
|
base?: string;
|
|
13
13
|
/** Set background styles. */
|