@xtyle/svelte 0.5.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 +42 -0
- package/dist/Accordion.svelte +50 -0
- package/dist/Accordion.svelte.d.ts +22 -0
- package/dist/Alert.svelte +55 -0
- package/dist/Alert.svelte.d.ts +25 -0
- package/dist/AppShell.svelte +69 -0
- package/dist/AppShell.svelte.d.ts +27 -0
- package/dist/Avatar.svelte +53 -0
- package/dist/Avatar.svelte.d.ts +23 -0
- package/dist/AvatarGroup.svelte +31 -0
- package/dist/AvatarGroup.svelte.d.ts +18 -0
- package/dist/Badge.svelte +56 -0
- package/dist/Badge.svelte.d.ts +21 -0
- package/dist/Bar.svelte +69 -0
- package/dist/Bar.svelte.d.ts +30 -0
- package/dist/Breadcrumb.svelte +33 -0
- package/dist/Breadcrumb.svelte.d.ts +27 -0
- package/dist/Button.svelte +74 -0
- package/dist/Button.svelte.d.ts +28 -0
- package/dist/Card.svelte +26 -0
- package/dist/Card.svelte.d.ts +18 -0
- package/dist/CardLink.svelte +45 -0
- package/dist/CardLink.svelte.d.ts +18 -0
- package/dist/Carousel.svelte +39 -0
- package/dist/Carousel.svelte.d.ts +16 -0
- package/dist/Checkbox.svelte +59 -0
- package/dist/Checkbox.svelte.d.ts +21 -0
- package/dist/CheckboxGroup.svelte +47 -0
- package/dist/CheckboxGroup.svelte.d.ts +20 -0
- package/dist/Cluster.svelte +24 -0
- package/dist/Cluster.svelte.d.ts +17 -0
- package/dist/Code.svelte +29 -0
- package/dist/Code.svelte.d.ts +23 -0
- package/dist/ColorPicker.svelte +82 -0
- package/dist/ColorPicker.svelte.d.ts +26 -0
- package/dist/Dialog.svelte +60 -0
- package/dist/Dialog.svelte.d.ts +22 -0
- package/dist/Dock.svelte +57 -0
- package/dist/Dock.svelte.d.ts +23 -0
- package/dist/DockZone.svelte +74 -0
- package/dist/DockZone.svelte.d.ts +33 -0
- package/dist/Eyebrow.svelte +24 -0
- package/dist/Eyebrow.svelte.d.ts +17 -0
- package/dist/Field.svelte +92 -0
- package/dist/Field.svelte.d.ts +34 -0
- package/dist/FormGroup.svelte +43 -0
- package/dist/FormGroup.svelte.d.ts +18 -0
- package/dist/Grid.svelte +24 -0
- package/dist/Grid.svelte.d.ts +17 -0
- package/dist/Heading.svelte +20 -0
- package/dist/Heading.svelte.d.ts +14 -0
- package/dist/Heatmap.svelte +100 -0
- package/dist/Heatmap.svelte.d.ts +41 -0
- package/dist/Hero.svelte +20 -0
- package/dist/Hero.svelte.d.ts +13 -0
- package/dist/Icon.svelte +20 -0
- package/dist/Icon.svelte.d.ts +16 -0
- package/dist/Image.svelte +44 -0
- package/dist/Image.svelte.d.ts +19 -0
- package/dist/Kbd.svelte +21 -0
- package/dist/Kbd.svelte.d.ts +14 -0
- package/dist/Link.svelte +34 -0
- package/dist/Link.svelte.d.ts +18 -0
- package/dist/Menu.svelte +34 -0
- package/dist/Menu.svelte.d.ts +13 -0
- package/dist/NumberInput.svelte +76 -0
- package/dist/NumberInput.svelte.d.ts +25 -0
- package/dist/Pagination.svelte +56 -0
- package/dist/Pagination.svelte.d.ts +22 -0
- package/dist/Panel.svelte +52 -0
- package/dist/Panel.svelte.d.ts +19 -0
- package/dist/Parallax.svelte +19 -0
- package/dist/Parallax.svelte.d.ts +13 -0
- package/dist/Pie.svelte +48 -0
- package/dist/Pie.svelte.d.ts +17 -0
- package/dist/Progress.svelte +68 -0
- package/dist/Progress.svelte.d.ts +30 -0
- package/dist/Radio.svelte +72 -0
- package/dist/Radio.svelte.d.ts +24 -0
- package/dist/RadioGroup.svelte +39 -0
- package/dist/RadioGroup.svelte.d.ts +16 -0
- package/dist/Section.svelte +37 -0
- package/dist/Section.svelte.d.ts +21 -0
- package/dist/Segment.svelte +23 -0
- package/dist/Segment.svelte.d.ts +14 -0
- package/dist/Segmented.svelte +64 -0
- package/dist/Segmented.svelte.d.ts +28 -0
- package/dist/Select.svelte +57 -0
- package/dist/Select.svelte.d.ts +21 -0
- package/dist/Separator.svelte +23 -0
- package/dist/Separator.svelte.d.ts +16 -0
- package/dist/Skeleton.svelte +19 -0
- package/dist/Skeleton.svelte.d.ts +14 -0
- package/dist/Slider.svelte +82 -0
- package/dist/Slider.svelte.d.ts +24 -0
- package/dist/Sparkline.svelte +62 -0
- package/dist/Sparkline.svelte.d.ts +25 -0
- package/dist/Spinner.svelte +16 -0
- package/dist/Spinner.svelte.d.ts +12 -0
- package/dist/Splitter.svelte +85 -0
- package/dist/Splitter.svelte.d.ts +30 -0
- package/dist/Stack.svelte +23 -0
- package/dist/Stack.svelte.d.ts +16 -0
- package/dist/Stat.svelte +41 -0
- package/dist/Stat.svelte.d.ts +23 -0
- package/dist/Statusbar.svelte +50 -0
- package/dist/Statusbar.svelte.d.ts +20 -0
- package/dist/Swatch.svelte +48 -0
- package/dist/Swatch.svelte.d.ts +22 -0
- package/dist/Switch.svelte +69 -0
- package/dist/Switch.svelte.d.ts +24 -0
- package/dist/Table.svelte +39 -0
- package/dist/Table.svelte.d.ts +17 -0
- package/dist/Tabs.svelte +84 -0
- package/dist/Tabs.svelte.d.ts +28 -0
- package/dist/Text.svelte +38 -0
- package/dist/Text.svelte.d.ts +22 -0
- package/dist/Textarea.svelte +74 -0
- package/dist/Textarea.svelte.d.ts +25 -0
- package/dist/Toast.svelte +55 -0
- package/dist/Toast.svelte.d.ts +25 -0
- package/dist/Toc.svelte +22 -0
- package/dist/Toc.svelte.d.ts +15 -0
- package/dist/Toolbar.svelte +49 -0
- package/dist/Toolbar.svelte.d.ts +20 -0
- package/dist/Tooltip.svelte +28 -0
- package/dist/Tooltip.svelte.d.ts +19 -0
- package/dist/Tree.svelte +51 -0
- package/dist/Tree.svelte.d.ts +24 -0
- package/dist/elements.d.ts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +65 -0
- package/dist/register.d.ts +2 -0
- package/dist/register.js +2 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @xtyle/svelte
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@xtyle/svelte)
|
|
4
|
+
[](https://xtyle.dev)
|
|
5
|
+
[](https://opensource.org/license/mit)
|
|
6
|
+
|
|
7
|
+
Thin Svelte 5 wrappers over the [`@xtyle/core`](https://www.npmjs.com/package/@xtyle/core)
|
|
8
|
+
custom elements, the Svelte binding of the xtyle component contract. Each wrapper is a
|
|
9
|
+
typed Svelte component that renders the matching `<xtyle-*>` element and forwards its
|
|
10
|
+
props, slots, and arbitrary attributes (`{...rest}` lands on the element).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @xtyle/svelte @xtyle/core
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`svelte@^5` is a peer dependency; `@xtyle/core` (pulled in automatically) provides the
|
|
19
|
+
custom elements and the derivation engine.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script>
|
|
25
|
+
import { Button, Badge, Card } from "@xtyle/svelte";
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<Card>
|
|
29
|
+
<Badge tone="success">new</Badge>
|
|
30
|
+
<Button tone="accent">Save</Button>
|
|
31
|
+
</Card>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Components are styled entirely by **design tokens**, the CSS custom properties a xtyle
|
|
35
|
+
*algorithm* derives. Drop a derived theme on `:root` (or any ancestor) and every
|
|
36
|
+
component themes with it; no per-component styling required. See
|
|
37
|
+
[`@xtyle/core`](https://www.npmjs.com/package/@xtyle/core) for deriving and applying a
|
|
38
|
+
theme, and [xtyle.dev](https://xtyle.dev) for the full component reference.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./register.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { Size } from "@xtyle/core";
|
|
5
|
+
|
|
6
|
+
interface AccordionItem {
|
|
7
|
+
value: string;
|
|
8
|
+
header: string;
|
|
9
|
+
open?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
sections: AccordionItem[];
|
|
15
|
+
multiple?: boolean;
|
|
16
|
+
size?: Size;
|
|
17
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
18
|
+
ontoggle?: (event: Event) => void;
|
|
19
|
+
panel: Snippet<[string]>;
|
|
20
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
sections,
|
|
26
|
+
multiple = false,
|
|
27
|
+
size = "md",
|
|
28
|
+
headingLevel,
|
|
29
|
+
ontoggle,
|
|
30
|
+
panel,
|
|
31
|
+
...rest
|
|
32
|
+
}: Props = $props();
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<xtyle-accordion
|
|
36
|
+
{...rest}
|
|
37
|
+
multiple={multiple || undefined}
|
|
38
|
+
{size}
|
|
39
|
+
heading-level={headingLevel}
|
|
40
|
+
{ontoggle}
|
|
41
|
+
>
|
|
42
|
+
{#each sections as section (section.value)}
|
|
43
|
+
<span
|
|
44
|
+
slot="header"
|
|
45
|
+
value={section.value}
|
|
46
|
+
open={section.open || undefined}
|
|
47
|
+
disabled={section.disabled || undefined}>{section.header}</span>
|
|
48
|
+
<div slot="panel">{@render panel(section.value)}</div>
|
|
49
|
+
{/each}
|
|
50
|
+
</xtyle-accordion>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "./register.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { Size } from "@xtyle/core";
|
|
4
|
+
interface AccordionItem {
|
|
5
|
+
value: string;
|
|
6
|
+
header: string;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface Props {
|
|
11
|
+
sections: AccordionItem[];
|
|
12
|
+
multiple?: boolean;
|
|
13
|
+
size?: Size;
|
|
14
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
15
|
+
ontoggle?: (event: Event) => void;
|
|
16
|
+
panel: Snippet<[string]>;
|
|
17
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
declare const Accordion: import("svelte").Component<Props, {}, "">;
|
|
21
|
+
type Accordion = ReturnType<typeof Accordion>;
|
|
22
|
+
export default Accordion;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./register.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { FullTone } from "@xtyle/core";
|
|
5
|
+
type AlertSeverity = "success" | "warn" | "danger" | "info";
|
|
6
|
+
|
|
7
|
+
type AlertVariant = "soft" | "solid";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
/** Color — any semantic role, accent variant, or named hue. Defaults to the severity color. */
|
|
11
|
+
tone?: FullTone;
|
|
12
|
+
/** Meaning — drives the glyph + politeness, independent of color. Omit for a color-only notice. */
|
|
13
|
+
severity?: AlertSeverity;
|
|
14
|
+
variant?: AlertVariant;
|
|
15
|
+
dismissible?: boolean;
|
|
16
|
+
dismissLabel?: string;
|
|
17
|
+
ondismiss?: (event: CustomEvent) => void;
|
|
18
|
+
title?: Snippet;
|
|
19
|
+
actions?: Snippet;
|
|
20
|
+
/** Overrides the built-in severity glyph. */
|
|
21
|
+
icon?: Snippet;
|
|
22
|
+
children?: Snippet;
|
|
23
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let {
|
|
28
|
+
tone,
|
|
29
|
+
severity,
|
|
30
|
+
variant = "soft",
|
|
31
|
+
dismissible = false,
|
|
32
|
+
dismissLabel,
|
|
33
|
+
ondismiss,
|
|
34
|
+
title,
|
|
35
|
+
actions,
|
|
36
|
+
icon,
|
|
37
|
+
children,
|
|
38
|
+
...rest
|
|
39
|
+
}: Props = $props();
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<xtyle-alert
|
|
43
|
+
{...rest}
|
|
44
|
+
{tone}
|
|
45
|
+
{severity}
|
|
46
|
+
{variant}
|
|
47
|
+
dismissible={dismissible || undefined}
|
|
48
|
+
dismiss-label={dismissLabel}
|
|
49
|
+
{ondismiss}
|
|
50
|
+
>
|
|
51
|
+
{#if icon}<span slot="icon">{@render icon()}</span>{/if}
|
|
52
|
+
{#if title}<span slot="title">{@render title()}</span>{/if}
|
|
53
|
+
{@render children?.()}
|
|
54
|
+
{#if actions}<span slot="actions">{@render actions()}</span>{/if}
|
|
55
|
+
</xtyle-alert>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "./register.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { FullTone } from "@xtyle/core";
|
|
4
|
+
type AlertSeverity = "success" | "warn" | "danger" | "info";
|
|
5
|
+
type AlertVariant = "soft" | "solid";
|
|
6
|
+
interface Props {
|
|
7
|
+
/** Color — any semantic role, accent variant, or named hue. Defaults to the severity color. */
|
|
8
|
+
tone?: FullTone;
|
|
9
|
+
/** Meaning — drives the glyph + politeness, independent of color. Omit for a color-only notice. */
|
|
10
|
+
severity?: AlertSeverity;
|
|
11
|
+
variant?: AlertVariant;
|
|
12
|
+
dismissible?: boolean;
|
|
13
|
+
dismissLabel?: string;
|
|
14
|
+
ondismiss?: (event: CustomEvent) => void;
|
|
15
|
+
title?: Snippet;
|
|
16
|
+
actions?: Snippet;
|
|
17
|
+
/** Overrides the built-in severity glyph. */
|
|
18
|
+
icon?: Snippet;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
declare const Alert: import("svelte").Component<Props, {}, "">;
|
|
24
|
+
type Alert = ReturnType<typeof Alert>;
|
|
25
|
+
export default Alert;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./register.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
skipLink?: string | boolean;
|
|
7
|
+
leftSize?: number | string;
|
|
8
|
+
rightSize?: number | string;
|
|
9
|
+
/** Make the left / right rail user-resizable: a drag handle on its inner edge, arrow-key nudges
|
|
10
|
+
* (`Shift` for a bigger step, `Home` / `End` to jump to the bounds), and a double-click reset to
|
|
11
|
+
* `leftSize` / `rightSize`. The main column reflows as the rail changes. */
|
|
12
|
+
leftResizable?: boolean;
|
|
13
|
+
rightResizable?: boolean;
|
|
14
|
+
/** Clamp for the resizable rails, in px. */
|
|
15
|
+
leftMin?: number;
|
|
16
|
+
leftMax?: number;
|
|
17
|
+
rightMin?: number;
|
|
18
|
+
rightMax?: number;
|
|
19
|
+
toolbar?: Snippet;
|
|
20
|
+
left?: Snippet;
|
|
21
|
+
right?: Snippet;
|
|
22
|
+
statusbar?: Snippet;
|
|
23
|
+
children?: Snippet;
|
|
24
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
skipLink,
|
|
30
|
+
leftSize,
|
|
31
|
+
rightSize,
|
|
32
|
+
leftResizable,
|
|
33
|
+
rightResizable,
|
|
34
|
+
leftMin,
|
|
35
|
+
leftMax,
|
|
36
|
+
rightMin,
|
|
37
|
+
rightMax,
|
|
38
|
+
toolbar,
|
|
39
|
+
left,
|
|
40
|
+
right,
|
|
41
|
+
statusbar,
|
|
42
|
+
children,
|
|
43
|
+
...rest
|
|
44
|
+
}: Props = $props();
|
|
45
|
+
|
|
46
|
+
const skipAttr = $derived(skipLink === true ? "" : skipLink || undefined);
|
|
47
|
+
const railAttr = (v: number | string | undefined) =>
|
|
48
|
+
v === undefined ? undefined : typeof v === "number" ? String(v) : v;
|
|
49
|
+
const flag = (v: boolean | undefined) => (v ? "" : undefined);
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<xtyle-app-shell
|
|
53
|
+
{...rest}
|
|
54
|
+
skip-link={skipAttr}
|
|
55
|
+
left-size={railAttr(leftSize)}
|
|
56
|
+
right-size={railAttr(rightSize)}
|
|
57
|
+
left-resizable={flag(leftResizable)}
|
|
58
|
+
right-resizable={flag(rightResizable)}
|
|
59
|
+
left-min={railAttr(leftMin)}
|
|
60
|
+
left-max={railAttr(leftMax)}
|
|
61
|
+
right-min={railAttr(rightMin)}
|
|
62
|
+
right-max={railAttr(rightMax)}
|
|
63
|
+
>
|
|
64
|
+
{#if toolbar}<div slot="toolbar">{@render toolbar()}</div>{/if}
|
|
65
|
+
{#if left}<div slot="left">{@render left()}</div>{/if}
|
|
66
|
+
{@render children?.()}
|
|
67
|
+
{#if right}<div slot="right">{@render right()}</div>{/if}
|
|
68
|
+
{#if statusbar}<div slot="statusbar">{@render statusbar()}</div>{/if}
|
|
69
|
+
</xtyle-app-shell>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "./register.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
interface Props {
|
|
4
|
+
skipLink?: string | boolean;
|
|
5
|
+
leftSize?: number | string;
|
|
6
|
+
rightSize?: number | string;
|
|
7
|
+
/** Make the left / right rail user-resizable: a drag handle on its inner edge, arrow-key nudges
|
|
8
|
+
* (`Shift` for a bigger step, `Home` / `End` to jump to the bounds), and a double-click reset to
|
|
9
|
+
* `leftSize` / `rightSize`. The main column reflows as the rail changes. */
|
|
10
|
+
leftResizable?: boolean;
|
|
11
|
+
rightResizable?: boolean;
|
|
12
|
+
/** Clamp for the resizable rails, in px. */
|
|
13
|
+
leftMin?: number;
|
|
14
|
+
leftMax?: number;
|
|
15
|
+
rightMin?: number;
|
|
16
|
+
rightMax?: number;
|
|
17
|
+
toolbar?: Snippet;
|
|
18
|
+
left?: Snippet;
|
|
19
|
+
right?: Snippet;
|
|
20
|
+
statusbar?: Snippet;
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
declare const AppShell: import("svelte").Component<Props, {}, "">;
|
|
26
|
+
type AppShell = ReturnType<typeof AppShell>;
|
|
27
|
+
export default AppShell;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./register.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { FullTone as BadgeTone, Tone } from "@xtyle/core";
|
|
5
|
+
|
|
6
|
+
type AvatarSize = "sm" | "md" | "lg" | "xl";
|
|
7
|
+
type AvatarShape = "circle" | "square";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
src?: string;
|
|
11
|
+
alt?: string;
|
|
12
|
+
tone?: BadgeTone;
|
|
13
|
+
size?: AvatarSize;
|
|
14
|
+
shape?: AvatarShape;
|
|
15
|
+
status?: Tone;
|
|
16
|
+
statusLabel?: string;
|
|
17
|
+
/** Breathe the status dot for a live / online presence: a bare `true` pulses slow, `"fast"` quick. */
|
|
18
|
+
pulse?: boolean | "slow" | "fast";
|
|
19
|
+
icon?: Snippet;
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
src,
|
|
27
|
+
alt,
|
|
28
|
+
tone = "neutral",
|
|
29
|
+
size = "md",
|
|
30
|
+
shape = "circle",
|
|
31
|
+
status,
|
|
32
|
+
statusLabel,
|
|
33
|
+
pulse,
|
|
34
|
+
icon,
|
|
35
|
+
children,
|
|
36
|
+
...rest
|
|
37
|
+
}: Props = $props();
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<xtyle-avatar
|
|
41
|
+
{...rest}
|
|
42
|
+
{src}
|
|
43
|
+
{alt}
|
|
44
|
+
{tone}
|
|
45
|
+
{size}
|
|
46
|
+
{shape}
|
|
47
|
+
{status}
|
|
48
|
+
status-label={statusLabel}
|
|
49
|
+
pulse={pulse === true ? "" : pulse || undefined}
|
|
50
|
+
>
|
|
51
|
+
{#if icon}<span slot="icon">{@render icon()}</span>{/if}
|
|
52
|
+
{@render children?.()}
|
|
53
|
+
</xtyle-avatar>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./register.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { FullTone as BadgeTone, Tone } from "@xtyle/core";
|
|
4
|
+
type AvatarSize = "sm" | "md" | "lg" | "xl";
|
|
5
|
+
type AvatarShape = "circle" | "square";
|
|
6
|
+
interface Props {
|
|
7
|
+
src?: string;
|
|
8
|
+
alt?: string;
|
|
9
|
+
tone?: BadgeTone;
|
|
10
|
+
size?: AvatarSize;
|
|
11
|
+
shape?: AvatarShape;
|
|
12
|
+
status?: Tone;
|
|
13
|
+
statusLabel?: string;
|
|
14
|
+
/** Breathe the status dot for a live / online presence: a bare `true` pulses slow, `"fast"` quick. */
|
|
15
|
+
pulse?: boolean | "slow" | "fast";
|
|
16
|
+
icon?: Snippet;
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
declare const Avatar: import("svelte").Component<Props, {}, "">;
|
|
22
|
+
type Avatar = ReturnType<typeof Avatar>;
|
|
23
|
+
export default Avatar;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./register.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
|
|
5
|
+
type AvatarGroupSize = "sm" | "md" | "lg" | "xl";
|
|
6
|
+
type AvatarGroupSpacing = "snug" | "normal" | "loose";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
size?: AvatarGroupSize;
|
|
10
|
+
spacing?: AvatarGroupSpacing;
|
|
11
|
+
/** How many avatars beyond the shown ones to summarize as a trailing `+N` chip. */
|
|
12
|
+
overflow?: number;
|
|
13
|
+
/** Accessible name for the group (a list of people). */
|
|
14
|
+
label?: string;
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through. */
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let { size, spacing, overflow, label, children, ...rest }: Props = $props();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<xtyle-avatar-group
|
|
24
|
+
{...rest}
|
|
25
|
+
{size}
|
|
26
|
+
{spacing}
|
|
27
|
+
overflow={overflow ?? undefined}
|
|
28
|
+
{label}
|
|
29
|
+
>
|
|
30
|
+
{@render children?.()}
|
|
31
|
+
</xtyle-avatar-group>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./register.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
type AvatarGroupSize = "sm" | "md" | "lg" | "xl";
|
|
4
|
+
type AvatarGroupSpacing = "snug" | "normal" | "loose";
|
|
5
|
+
interface Props {
|
|
6
|
+
size?: AvatarGroupSize;
|
|
7
|
+
spacing?: AvatarGroupSpacing;
|
|
8
|
+
/** How many avatars beyond the shown ones to summarize as a trailing `+N` chip. */
|
|
9
|
+
overflow?: number;
|
|
10
|
+
/** Accessible name for the group (a list of people). */
|
|
11
|
+
label?: string;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through. */
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
declare const AvatarGroup: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type AvatarGroup = ReturnType<typeof AvatarGroup>;
|
|
18
|
+
export default AvatarGroup;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./register.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { FullTone as BadgeTone, Size } from "@xtyle/core";
|
|
5
|
+
|
|
6
|
+
type BadgeVariant = "solid" | "soft" | "outline";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
variant?: BadgeVariant;
|
|
10
|
+
tone?: BadgeTone;
|
|
11
|
+
size?: Size;
|
|
12
|
+
dot?: boolean;
|
|
13
|
+
pulse?: boolean | "slow" | "fast";
|
|
14
|
+
count?: string | number;
|
|
15
|
+
removable?: boolean;
|
|
16
|
+
removeLabel?: string;
|
|
17
|
+
onremove?: (event: MouseEvent) => void;
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
variant = "soft",
|
|
25
|
+
tone = "neutral",
|
|
26
|
+
size = "md",
|
|
27
|
+
dot = false,
|
|
28
|
+
pulse,
|
|
29
|
+
count,
|
|
30
|
+
removable = false,
|
|
31
|
+
removeLabel,
|
|
32
|
+
onremove,
|
|
33
|
+
children,
|
|
34
|
+
...rest
|
|
35
|
+
}: Props = $props();
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<xtyle-badge
|
|
39
|
+
{...rest}
|
|
40
|
+
{variant}
|
|
41
|
+
{tone}
|
|
42
|
+
{size}
|
|
43
|
+
dot={dot || undefined}
|
|
44
|
+
pulse={pulse === true ? "slow" : pulse || undefined}
|
|
45
|
+
count={count !== undefined && count !== null && count !== "" ? String(count) : undefined}
|
|
46
|
+
removable={removable || undefined}
|
|
47
|
+
remove-label={removeLabel}
|
|
48
|
+
onclick={onremove
|
|
49
|
+
? (event: MouseEvent) => {
|
|
50
|
+
const target = event.target as HTMLElement;
|
|
51
|
+
if (target.closest(".xtyle-badge__remove")) onremove(event);
|
|
52
|
+
}
|
|
53
|
+
: undefined}
|
|
54
|
+
>
|
|
55
|
+
{@render children?.()}
|
|
56
|
+
</xtyle-badge>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./register.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { FullTone as BadgeTone, Size } from "@xtyle/core";
|
|
4
|
+
type BadgeVariant = "solid" | "soft" | "outline";
|
|
5
|
+
interface Props {
|
|
6
|
+
variant?: BadgeVariant;
|
|
7
|
+
tone?: BadgeTone;
|
|
8
|
+
size?: Size;
|
|
9
|
+
dot?: boolean;
|
|
10
|
+
pulse?: boolean | "slow" | "fast";
|
|
11
|
+
count?: string | number;
|
|
12
|
+
removable?: boolean;
|
|
13
|
+
removeLabel?: string;
|
|
14
|
+
onremove?: (event: MouseEvent) => void;
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
declare const Badge: import("svelte").Component<Props, {}, "">;
|
|
20
|
+
type Badge = ReturnType<typeof Badge>;
|
|
21
|
+
export default Badge;
|
package/dist/Bar.svelte
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./register.js";
|
|
3
|
+
import type { BarSeries, BarScheme } from "@xtyle/core";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
series?: BarSeries[];
|
|
7
|
+
categories?: string[];
|
|
8
|
+
scheme?: BarScheme;
|
|
9
|
+
reverse?: boolean;
|
|
10
|
+
colorBy?: "series" | "category";
|
|
11
|
+
orientation?: "vertical" | "horizontal";
|
|
12
|
+
stacked?: boolean;
|
|
13
|
+
showValues?: boolean;
|
|
14
|
+
legend?: boolean;
|
|
15
|
+
height?: number;
|
|
16
|
+
label?: string;
|
|
17
|
+
/** Make bars actionable: each becomes a `role="button"` that fires `select` on click or Enter/Space. */
|
|
18
|
+
selectable?: boolean;
|
|
19
|
+
/** Fired when a bar is activated (only when `selectable`), carrying the series, category, value, and indices. */
|
|
20
|
+
onselect?: (
|
|
21
|
+
event: CustomEvent<{ series: string; category: string; value: number; seriesIndex: number; categoryIndex: number }>,
|
|
22
|
+
) => void;
|
|
23
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let {
|
|
28
|
+
series = [],
|
|
29
|
+
categories = [],
|
|
30
|
+
scheme = "accents",
|
|
31
|
+
reverse = false,
|
|
32
|
+
colorBy,
|
|
33
|
+
orientation = "vertical",
|
|
34
|
+
stacked = false,
|
|
35
|
+
showValues = false,
|
|
36
|
+
legend = true,
|
|
37
|
+
height = 320,
|
|
38
|
+
label,
|
|
39
|
+
selectable = false,
|
|
40
|
+
onselect,
|
|
41
|
+
...rest
|
|
42
|
+
}: Props = $props();
|
|
43
|
+
|
|
44
|
+
let host:
|
|
45
|
+
| (HTMLElement & { series: BarSeries[]; categories: string[]; scheme: BarScheme })
|
|
46
|
+
| undefined = $state();
|
|
47
|
+
|
|
48
|
+
$effect(() => {
|
|
49
|
+
if (!host) return;
|
|
50
|
+
host.series = series;
|
|
51
|
+
host.categories = categories;
|
|
52
|
+
host.scheme = scheme;
|
|
53
|
+
});
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<xtyle-bar
|
|
57
|
+
bind:this={host}
|
|
58
|
+
{...rest}
|
|
59
|
+
reverse={reverse || undefined}
|
|
60
|
+
color-by={colorBy}
|
|
61
|
+
orientation={orientation === "horizontal" ? "horizontal" : undefined}
|
|
62
|
+
stacked={stacked || undefined}
|
|
63
|
+
show-values={showValues || undefined}
|
|
64
|
+
legend={legend ? undefined : "false"}
|
|
65
|
+
selectable={selectable || undefined}
|
|
66
|
+
{onselect}
|
|
67
|
+
{height}
|
|
68
|
+
{label}
|
|
69
|
+
></xtyle-bar>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import "./register.js";
|
|
2
|
+
import type { BarSeries, BarScheme } from "@xtyle/core";
|
|
3
|
+
interface Props {
|
|
4
|
+
series?: BarSeries[];
|
|
5
|
+
categories?: string[];
|
|
6
|
+
scheme?: BarScheme;
|
|
7
|
+
reverse?: boolean;
|
|
8
|
+
colorBy?: "series" | "category";
|
|
9
|
+
orientation?: "vertical" | "horizontal";
|
|
10
|
+
stacked?: boolean;
|
|
11
|
+
showValues?: boolean;
|
|
12
|
+
legend?: boolean;
|
|
13
|
+
height?: number;
|
|
14
|
+
label?: string;
|
|
15
|
+
/** Make bars actionable: each becomes a `role="button"` that fires `select` on click or Enter/Space. */
|
|
16
|
+
selectable?: boolean;
|
|
17
|
+
/** Fired when a bar is activated (only when `selectable`), carrying the series, category, value, and indices. */
|
|
18
|
+
onselect?: (event: CustomEvent<{
|
|
19
|
+
series: string;
|
|
20
|
+
category: string;
|
|
21
|
+
value: number;
|
|
22
|
+
seriesIndex: number;
|
|
23
|
+
categoryIndex: number;
|
|
24
|
+
}>) => void;
|
|
25
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
declare const Bar: import("svelte").Component<Props, {}, "">;
|
|
29
|
+
type Bar = ReturnType<typeof Bar>;
|
|
30
|
+
export default Bar;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./register.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { Size, FullTone } from "@xtyle/core";
|
|
5
|
+
|
|
6
|
+
interface BreadcrumbItem {
|
|
7
|
+
label: string;
|
|
8
|
+
href?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
current?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
items?: BreadcrumbItem[];
|
|
15
|
+
separator?: string;
|
|
16
|
+
tone?: FullTone;
|
|
17
|
+
size?: Size;
|
|
18
|
+
label?: string;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
/** Fired when a valued crumb (no `href`) is activated; `detail` carries `{ value, index }`. */
|
|
21
|
+
onselect?: (event: CustomEvent<{ value: string; index: number }>) => void;
|
|
22
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let { items, separator = "/", tone = "accent", size = "md", label = "Breadcrumb", children, onselect, ...rest }: Props = $props();
|
|
27
|
+
|
|
28
|
+
const itemsAttr = $derived(items && items.length > 0 ? JSON.stringify(items) : undefined);
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<xtyle-breadcrumb {...rest} {tone} {size} {separator} {label} items={itemsAttr} {onselect}>
|
|
32
|
+
{@render children?.()}
|
|
33
|
+
</xtyle-breadcrumb>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "./register.js";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { Size, FullTone } from "@xtyle/core";
|
|
4
|
+
interface BreadcrumbItem {
|
|
5
|
+
label: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
current?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface Props {
|
|
11
|
+
items?: BreadcrumbItem[];
|
|
12
|
+
separator?: string;
|
|
13
|
+
tone?: FullTone;
|
|
14
|
+
size?: Size;
|
|
15
|
+
label?: string;
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
/** Fired when a valued crumb (no `href`) is activated; `detail` carries `{ value, index }`. */
|
|
18
|
+
onselect?: (event: CustomEvent<{
|
|
19
|
+
value: string;
|
|
20
|
+
index: number;
|
|
21
|
+
}>) => void;
|
|
22
|
+
/** Any other attribute (`title`, `id`, `data-*`, `aria-*`, …) passes through to the element. */
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
declare const Breadcrumb: import("svelte").Component<Props, {}, "">;
|
|
26
|
+
type Breadcrumb = ReturnType<typeof Breadcrumb>;
|
|
27
|
+
export default Breadcrumb;
|