@xds/svelte 1.0.1 → 1.2.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.
- .diffend-unextracted-0 +2 -1
- package/dist/Accordion.svelte +7 -2
- package/dist/Avatar.svelte +10 -2
- package/dist/AvatarStack.svelte +11 -1
- package/dist/Badge.svelte +14 -3
- package/dist/Banner.svelte +6 -1
- package/dist/Breadcrumb.svelte +53 -0
- package/dist/Breadcrumb.svelte.d.ts +11 -0
- package/dist/Button.svelte +30 -2
- package/dist/Button.svelte.d.ts +10 -1
- package/dist/Card.svelte +16 -2
- package/dist/Checkbox.svelte +62 -10
- package/dist/Checkbox.svelte.d.ts +14 -3
- package/dist/Chip.svelte +3 -1
- package/dist/ChipBar.svelte +3 -2
- package/dist/Combobox.svelte +194 -0
- package/dist/Combobox.svelte.d.ts +37 -0
- package/dist/CountBadge.svelte +4 -2
- package/dist/DatePicker.svelte +16 -5
- package/dist/DateRangePicker.svelte +6 -1
- package/dist/Dialog.svelte +9 -2
- package/dist/Divider.svelte +7 -3
- package/dist/EmptyState.svelte +15 -3
- package/dist/Icon.svelte +11 -2
- package/dist/IconButton.svelte +30 -2
- package/dist/IconButton.svelte.d.ts +10 -1
- package/dist/Labels.svelte +29 -0
- package/dist/Labels.svelte.d.ts +17 -0
- package/dist/Link.svelte +86 -0
- package/dist/Link.svelte.d.ts +26 -0
- package/dist/MediaCard.svelte +4 -1
- package/dist/Menu.svelte +21 -2
- package/dist/Pagination.svelte +108 -0
- package/dist/Pagination.svelte.d.ts +14 -0
- package/dist/PlaceRow.svelte +6 -1
- package/dist/Popover.svelte +91 -0
- package/dist/Popover.svelte.d.ts +21 -0
- package/dist/PopoverSurface.svelte +77 -0
- package/dist/PopoverSurface.svelte.d.ts +21 -0
- package/dist/ProgressBar.svelte +3 -1
- package/dist/RadioGroup.svelte +23 -8
- package/dist/RadioGroup.svelte.d.ts +4 -2
- package/dist/SearchField.svelte +65 -18
- package/dist/SearchField.svelte.d.ts +14 -4
- package/dist/SectionHeader.svelte +7 -2
- package/dist/SegmentedControl.svelte +21 -7
- package/dist/SegmentedControl.svelte.d.ts +3 -2
- package/dist/Select.svelte +64 -12
- package/dist/Select.svelte.d.ts +9 -2
- package/dist/Sidebar.svelte +3 -0
- package/dist/Skeleton.svelte +10 -2
- package/dist/Slider.svelte +23 -7
- package/dist/Slider.svelte.d.ts +2 -2
- package/dist/Spinner.svelte +3 -2
- package/dist/Switch.svelte +53 -9
- package/dist/Switch.svelte.d.ts +13 -3
- package/dist/Table.svelte +92 -0
- package/dist/Table.svelte.d.ts +17 -0
- package/dist/Tabs.svelte +21 -6
- package/dist/Tabs.svelte.d.ts +2 -1
- package/dist/Text.svelte +3 -1
- package/dist/TextField.svelte +59 -14
- package/dist/TextField.svelte.d.ts +13 -3
- package/dist/Thumbnail.svelte +7 -1
- package/dist/TimePicker.svelte +222 -0
- package/dist/TimePicker.svelte.d.ts +20 -0
- package/dist/Toast.svelte +12 -2
- package/dist/ToastQueue.svelte +57 -0
- package/dist/ToastQueue.svelte.d.ts +20 -0
- package/dist/Tooltip.svelte +9 -2
- package/dist/TooltipOverlay.svelte +9 -2
- package/dist/base.d.ts +14 -0
- package/dist/base.js +27 -0
- package/dist/controllable.svelte.d.ts +28 -0
- package/dist/controllable.svelte.js +41 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +12 -0
- package/dist/labels.svelte.d.ts +13 -0
- package/dist/labels.svelte.js +24 -0
- package/dist/modal-popover.svelte.js +5 -1
- package/dist/presence.svelte.js +5 -2
- package/dist/preview/Component.svelte +8 -3
- package/dist/preview/Preview.svelte +8 -2
- package/dist/preview/Preview.svelte.d.ts +2 -0
- package/dist/preview/components.d.ts +9 -2
- package/dist/preview/components.js +18 -1
- package/dist/preview/index.d.ts +1 -0
- package/dist/root.d.ts +4 -2
- package/eject/files/Accordion.svelte +100 -0
- package/eject/files/AccordionPanel.svelte +48 -0
- package/eject/files/Avatar.svelte +51 -0
- package/eject/files/AvatarStack.svelte +61 -0
- package/eject/files/Badge.svelte +52 -0
- package/eject/files/Banner.svelte +94 -0
- package/eject/files/Breadcrumb.svelte +52 -0
- package/eject/files/Button.svelte +126 -0
- package/eject/files/Card.svelte +112 -0
- package/eject/files/Checkbox.svelte +121 -0
- package/eject/files/Chip.svelte +51 -0
- package/eject/files/ChipBar.svelte +39 -0
- package/eject/files/Combobox.svelte +198 -0
- package/eject/files/CountBadge.svelte +51 -0
- package/eject/files/DatePicker.svelte +213 -0
- package/eject/files/DateRangePicker.svelte +294 -0
- package/eject/files/Dialog.svelte +119 -0
- package/eject/files/Divider.svelte +27 -0
- package/eject/files/EmptyState.svelte +52 -0
- package/eject/files/Icon.svelte +51 -0
- package/eject/files/IconButton.svelte +99 -0
- package/eject/files/Link.svelte +85 -0
- package/eject/files/ListRow.svelte +33 -0
- package/eject/files/MediaCard.svelte +117 -0
- package/eject/files/Menu.svelte +183 -0
- package/eject/files/Pagination.svelte +109 -0
- package/eject/files/PlaceRow.svelte +75 -0
- package/eject/files/Popover.svelte +100 -0
- package/eject/files/PopoverSurface.svelte +85 -0
- package/eject/files/ProgressBar.svelte +38 -0
- package/eject/files/RadioGroup.svelte +133 -0
- package/eject/files/SearchField.svelte +154 -0
- package/eject/files/SectionHeader.svelte +67 -0
- package/eject/files/SegmentedControl.svelte +85 -0
- package/eject/files/Select.svelte +276 -0
- package/eject/files/Sidebar.svelte +130 -0
- package/eject/files/SidebarRailButton.svelte +32 -0
- package/eject/files/Skeleton.svelte +55 -0
- package/eject/files/Slider.svelte +136 -0
- package/eject/files/Spinner.svelte +41 -0
- package/eject/files/Switch.svelte +105 -0
- package/eject/files/Table.svelte +90 -0
- package/eject/files/Tabs.svelte +85 -0
- package/eject/files/Text.svelte +43 -0
- package/eject/files/TextField.svelte +222 -0
- package/eject/files/Thumbnail.svelte +88 -0
- package/eject/files/TimePicker.svelte +237 -0
- package/eject/files/Toast.svelte +98 -0
- package/eject/files/ToastQueue.svelte +61 -0
- package/eject/files/Tooltip.svelte +51 -0
- package/eject/files/TooltipOverlay.svelte +88 -0
- package/eject/files/accordion.css +89 -0
- package/eject/files/accordion.ts +67 -0
- package/eject/files/avatar-stack.ts +57 -0
- package/eject/files/avatar.ts +42 -0
- package/eject/files/badge.ts +30 -0
- package/eject/files/banner.ts +71 -0
- package/eject/files/base.css +38 -0
- package/eject/files/breadcrumb.css +51 -0
- package/eject/files/breadcrumb.ts +42 -0
- package/eject/files/button.css +241 -0
- package/eject/files/button.ts +106 -0
- package/eject/files/card.ts +58 -0
- package/eject/files/checkbox.ts +52 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/combobox.css +269 -0
- package/eject/files/combobox.ts +85 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +375 -0
- package/eject/files/date-picker.ts +280 -0
- package/eject/files/date-range-picker.ts +338 -0
- package/eject/files/dialog.css +139 -0
- package/eject/files/dialog.ts +15 -0
- package/eject/files/divider.ts +5 -0
- package/eject/files/empty-state.ts +22 -0
- package/eject/files/icon.ts +36 -0
- package/eject/files/link.css +64 -0
- package/eject/files/link.ts +63 -0
- package/eject/files/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +192 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/overlay.css +40 -0
- package/eject/files/pagination.css +106 -0
- package/eject/files/pagination.ts +68 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/popover.css +101 -0
- package/eject/files/popover.ts +37 -0
- package/eject/files/progress-bar.ts +26 -0
- package/eject/files/radio-group.css +184 -0
- package/eject/files/radio-group.ts +30 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +33 -0
- package/eject/files/select.css +347 -0
- package/eject/files/select.ts +77 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +160 -0
- package/eject/files/slider.ts +80 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +45 -0
- package/eject/files/table.css +107 -0
- package/eject/files/table.ts +84 -0
- package/eject/files/tabs.css +120 -0
- package/eject/files/tabs.ts +37 -0
- package/eject/files/text-field.css +225 -0
- package/eject/files/text-field.ts +64 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/time-picker.ts +113 -0
- package/eject/files/toast-queue.ts +64 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +111 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +1053 -0
- package/package.json +12 -4
- package/styles.css +1064 -169
- package/tailwind.css +1295 -218
.diffend-unextracted-0
CHANGED
package/dist/Accordion.svelte
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
27
|
<script lang="ts" generics="Value extends string = string">
|
|
28
|
-
import { ACCORDION_PARTS, classes, focusTitleOnClick } from "@xds/core";
|
|
28
|
+
import { ACCORDION_PARTS, classes, focusTitleOnClick, rootAttributes } from "@xds/core";
|
|
29
29
|
import * as accordion from "@zag-js/accordion";
|
|
30
30
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
31
31
|
import AccordionPanel from "./AccordionPanel.svelte";
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
onChange,
|
|
39
39
|
class: className,
|
|
40
40
|
style,
|
|
41
|
+
...rest
|
|
41
42
|
}: AccordionProps<Value> = $props();
|
|
42
43
|
|
|
43
44
|
const id = $props.id();
|
|
@@ -52,7 +53,11 @@
|
|
|
52
53
|
const api = $derived(accordion.connect(service, normalizeProps));
|
|
53
54
|
// Merged, so that the app's style joins any the machine writes on the root.
|
|
54
55
|
const root = $derived(
|
|
55
|
-
mergeProps(api.getRootProps(), {
|
|
56
|
+
mergeProps(api.getRootProps(), {
|
|
57
|
+
...rootAttributes(rest),
|
|
58
|
+
class: classes("xds-accordion", className),
|
|
59
|
+
style,
|
|
60
|
+
}),
|
|
56
61
|
);
|
|
57
62
|
const body = (value: Value) => {
|
|
58
63
|
// The panel hides itself once it has finished closing; see AccordionPanel.
|
package/dist/Avatar.svelte
CHANGED
|
@@ -13,11 +13,18 @@
|
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
15
|
<script lang="ts">
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
avatarClass,
|
|
18
|
+
avatarInitials,
|
|
19
|
+
classes,
|
|
20
|
+
pictureClass,
|
|
21
|
+
rootAttributes,
|
|
22
|
+
rootPart,
|
|
23
|
+
} from "@xds/core";
|
|
17
24
|
import { useDefaults } from "./defaults.svelte.js";
|
|
18
25
|
import { createPicture } from "./picture.svelte.js";
|
|
19
26
|
|
|
20
|
-
let { name, src, size: ownSize, class: className, style }: AvatarProps = $props();
|
|
27
|
+
let { name, src, size: ownSize, class: className, style, ...rest }: AvatarProps = $props();
|
|
21
28
|
|
|
22
29
|
const defaults = useDefaults("Avatar");
|
|
23
30
|
const size = $derived(ownSize ?? defaults().size);
|
|
@@ -26,6 +33,7 @@
|
|
|
26
33
|
</script>
|
|
27
34
|
|
|
28
35
|
<span
|
|
36
|
+
{...rootAttributes(rest)}
|
|
29
37
|
role="img"
|
|
30
38
|
aria-label={name}
|
|
31
39
|
class={classes(rootPart("Avatar"), avatarClass(size), className)}
|
package/dist/AvatarStack.svelte
CHANGED
|
@@ -17,12 +17,21 @@
|
|
|
17
17
|
avatarStackItemClass,
|
|
18
18
|
avatarStackRestClass,
|
|
19
19
|
classes,
|
|
20
|
+
rootAttributes,
|
|
20
21
|
rootPart,
|
|
21
22
|
} from "@xds/core";
|
|
22
23
|
import Avatar from "./Avatar.svelte";
|
|
23
24
|
import { useDefaults } from "./defaults.svelte.js";
|
|
24
25
|
|
|
25
|
-
let {
|
|
26
|
+
let {
|
|
27
|
+
people,
|
|
28
|
+
max,
|
|
29
|
+
size: ownSize,
|
|
30
|
+
label,
|
|
31
|
+
class: className,
|
|
32
|
+
style,
|
|
33
|
+
...rest
|
|
34
|
+
}: AvatarStackProps = $props();
|
|
26
35
|
|
|
27
36
|
const defaults = useDefaults("AvatarStack");
|
|
28
37
|
// Resolved here, built-in default included, so that the avatars take the stack's size rather
|
|
@@ -33,6 +42,7 @@
|
|
|
33
42
|
</script>
|
|
34
43
|
|
|
35
44
|
<span
|
|
45
|
+
{...rootAttributes(rest)}
|
|
36
46
|
role="img"
|
|
37
47
|
aria-label={stack.name}
|
|
38
48
|
class={classes(rootPart("AvatarStack"), avatarStackClass, className)}
|
package/dist/Badge.svelte
CHANGED
|
@@ -18,17 +18,28 @@
|
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
20
|
<script lang="ts">
|
|
21
|
-
import { badgeClass, badgeDotClass, classes, rootPart } from "@xds/core";
|
|
21
|
+
import { badgeClass, badgeDotClass, classes, rootAttributes, rootPart } from "@xds/core";
|
|
22
22
|
import { useDefaults } from "./defaults.svelte.js";
|
|
23
23
|
import Icon from "./Icon.svelte";
|
|
24
24
|
|
|
25
|
-
let {
|
|
25
|
+
let {
|
|
26
|
+
tone: ownTone,
|
|
27
|
+
dot,
|
|
28
|
+
icon,
|
|
29
|
+
class: className,
|
|
30
|
+
style,
|
|
31
|
+
children,
|
|
32
|
+
...rest
|
|
33
|
+
}: BadgeProps = $props();
|
|
26
34
|
|
|
27
35
|
const defaults = useDefaults("Badge");
|
|
28
36
|
const tone = $derived(ownTone ?? defaults().tone);
|
|
29
37
|
</script>
|
|
30
38
|
|
|
31
|
-
<span
|
|
39
|
+
<span
|
|
40
|
+
{...rootAttributes(rest)}
|
|
41
|
+
class={classes(rootPart("Badge"), badgeClass(tone), className)}
|
|
42
|
+
{style}
|
|
32
43
|
>{#if dot}<span aria-hidden="true" class={badgeDotClass}></span>{/if}{#if icon}<Icon
|
|
33
44
|
name={icon}
|
|
34
45
|
size="xs"
|
package/dist/Banner.svelte
CHANGED
|
@@ -32,11 +32,13 @@
|
|
|
32
32
|
bannerIconPath,
|
|
33
33
|
bannerRole,
|
|
34
34
|
classes,
|
|
35
|
+
rootAttributes,
|
|
35
36
|
rootPart,
|
|
36
37
|
} from "@xds/core";
|
|
37
38
|
import Button from "./Button.svelte";
|
|
38
39
|
import { useDefaults } from "./defaults.svelte.js";
|
|
39
40
|
import IconButton from "./IconButton.svelte";
|
|
41
|
+
import { useLabels } from "./labels.svelte.js";
|
|
40
42
|
|
|
41
43
|
let {
|
|
42
44
|
tone: ownTone,
|
|
@@ -47,13 +49,16 @@
|
|
|
47
49
|
class: className,
|
|
48
50
|
style,
|
|
49
51
|
children,
|
|
52
|
+
...rest
|
|
50
53
|
}: BannerProps = $props();
|
|
51
54
|
|
|
52
55
|
const defaults = useDefaults("Banner");
|
|
56
|
+
const labels = useLabels();
|
|
53
57
|
const tone = $derived(ownTone ?? defaults().tone);
|
|
54
58
|
</script>
|
|
55
59
|
|
|
56
60
|
<div
|
|
61
|
+
{...rootAttributes(rest)}
|
|
57
62
|
role={bannerRole(tone)}
|
|
58
63
|
class={classes(rootPart("Banner"), bannerClass(tone), className)}
|
|
59
64
|
{style}
|
|
@@ -78,7 +83,7 @@
|
|
|
78
83
|
<div class={BANNER_PARTS.dismiss}>
|
|
79
84
|
<IconButton
|
|
80
85
|
icon="x"
|
|
81
|
-
label={dismissLabel ??
|
|
86
|
+
label={dismissLabel ?? labels().dismiss}
|
|
82
87
|
variant="ghost"
|
|
83
88
|
size="sm"
|
|
84
89
|
onPress={() => onDismiss()}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Where the current view sits in the app: the places above it, each a link, then the view
|
|
4
|
+
itself. A navigation landmark; the current place is marked as the page.
|
|
5
|
+
-->
|
|
6
|
+
<script module lang="ts">
|
|
7
|
+
import type { BreadcrumbBaseProps } from "@xds/core";
|
|
8
|
+
import type { RootProps } from "./root.js";
|
|
9
|
+
|
|
10
|
+
export type { BreadcrumbItem } from "@xds/core";
|
|
11
|
+
export type BreadcrumbProps = BreadcrumbBaseProps & RootProps;
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import {
|
|
16
|
+
BREADCRUMB_PARTS,
|
|
17
|
+
BREADCRUMB_SEPARATOR,
|
|
18
|
+
classes,
|
|
19
|
+
rootAttributes,
|
|
20
|
+
rootPart,
|
|
21
|
+
} from "@xds/core";
|
|
22
|
+
import Icon from "./Icon.svelte";
|
|
23
|
+
import { useLabels } from "./labels.svelte.js";
|
|
24
|
+
import Link from "./Link.svelte";
|
|
25
|
+
|
|
26
|
+
let { items, label, class: className, style, ...rest }: BreadcrumbProps = $props();
|
|
27
|
+
const labels = useLabels();
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<nav
|
|
31
|
+
{...rootAttributes(rest)}
|
|
32
|
+
aria-label={label ?? labels().breadcrumb}
|
|
33
|
+
class={classes(rootPart("Breadcrumb"), className)}
|
|
34
|
+
{style}
|
|
35
|
+
>
|
|
36
|
+
<ol class={BREADCRUMB_PARTS.list}>
|
|
37
|
+
<!-- Two places of a trail can share a label, so a place is known by where it is. -->
|
|
38
|
+
{#each items as item, index (index)}
|
|
39
|
+
<li class={BREADCRUMB_PARTS.item}>
|
|
40
|
+
{#if index === items.length - 1}
|
|
41
|
+
<span aria-current="page" class={BREADCRUMB_PARTS.current}>{item.label}</span>
|
|
42
|
+
{:else}
|
|
43
|
+
<Link href={item.href} onPress={item.onPress}>{item.label}</Link>
|
|
44
|
+
<Icon
|
|
45
|
+
name={BREADCRUMB_SEPARATOR.name}
|
|
46
|
+
size={BREADCRUMB_SEPARATOR.size}
|
|
47
|
+
class={BREADCRUMB_PARTS.separator}
|
|
48
|
+
/>
|
|
49
|
+
{/if}
|
|
50
|
+
</li>
|
|
51
|
+
{/each}
|
|
52
|
+
</ol>
|
|
53
|
+
</nav>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BreadcrumbBaseProps } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.js";
|
|
3
|
+
export type { BreadcrumbItem } from "@xds/core";
|
|
4
|
+
export type BreadcrumbProps = BreadcrumbBaseProps & RootProps;
|
|
5
|
+
/**
|
|
6
|
+
* Where the current view sits in the app: the places above it, each a link, then the view
|
|
7
|
+
* itself. A navigation landmark; the current place is marked as the page.
|
|
8
|
+
*/
|
|
9
|
+
declare const Breadcrumb: import("svelte").Component<BreadcrumbProps, {}, "">;
|
|
10
|
+
type Breadcrumb = ReturnType<typeof Breadcrumb>;
|
|
11
|
+
export default Breadcrumb;
|
package/dist/Button.svelte
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
@component
|
|
3
3
|
A native button. It also opens a Menu or a Tooltip it is the trigger of: their props reach it
|
|
4
4
|
through context.
|
|
5
|
+
|
|
6
|
+
`focus()`, `blur()` and `element()` on the instance reach the native button.
|
|
5
7
|
-->
|
|
6
8
|
<script module lang="ts">
|
|
7
9
|
import type { ButtonBaseProps } from "@xds/core";
|
|
8
10
|
import type { Snippet } from "svelte";
|
|
11
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
9
12
|
import type { RootProps } from "./root.js";
|
|
10
13
|
|
|
11
14
|
export type { ButtonVariant, ControlSize } from "@xds/core";
|
|
@@ -13,13 +16,15 @@
|
|
|
13
16
|
export type ButtonProps = ButtonBaseProps &
|
|
14
17
|
RootProps & {
|
|
15
18
|
onPress?: () => void;
|
|
19
|
+
onFocus?: FocusEventHandler<HTMLButtonElement>;
|
|
20
|
+
onBlur?: FocusEventHandler<HTMLButtonElement>;
|
|
16
21
|
/** Leave it out for a button that holds only an icon, and name that one with `aria-label`. */
|
|
17
22
|
children?: Snippet;
|
|
18
23
|
};
|
|
19
24
|
</script>
|
|
20
25
|
|
|
21
26
|
<script lang="ts">
|
|
22
|
-
import { BUTTON_ICON, buttonClass, classes, isHeld } from "@xds/core";
|
|
27
|
+
import { BUTTON_ICON, buttonClass, classes, isHeld, rootAttributes } from "@xds/core";
|
|
23
28
|
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
24
29
|
import { useDefaults } from "./defaults.svelte.js";
|
|
25
30
|
import Icon from "./Icon.svelte";
|
|
@@ -37,10 +42,13 @@
|
|
|
37
42
|
fullWidth = false,
|
|
38
43
|
type = "button",
|
|
39
44
|
onPress,
|
|
45
|
+
onFocus,
|
|
46
|
+
onBlur,
|
|
40
47
|
"aria-label": ariaLabel,
|
|
41
48
|
class: className,
|
|
42
49
|
style,
|
|
43
50
|
children,
|
|
51
|
+
...rest
|
|
44
52
|
}: ButtonProps = $props();
|
|
45
53
|
|
|
46
54
|
const defaults = useDefaults("Button");
|
|
@@ -77,12 +85,32 @@
|
|
|
77
85
|
}
|
|
78
86
|
onPress?.();
|
|
79
87
|
},
|
|
88
|
+
onfocus: onFocus,
|
|
89
|
+
onblur: onBlur,
|
|
80
90
|
}),
|
|
81
91
|
() => loading === true,
|
|
82
92
|
);
|
|
93
|
+
let button = $state<HTMLButtonElement>();
|
|
94
|
+
|
|
95
|
+
/** Moves the focus to the native button. */
|
|
96
|
+
export function focus(options?: FocusOptions) {
|
|
97
|
+
button?.focus(options);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Takes the focus from the native button. */
|
|
101
|
+
export function blur() {
|
|
102
|
+
button?.blur();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The native button, once it is on the page. */
|
|
106
|
+
export function element(): HTMLButtonElement | undefined {
|
|
107
|
+
return button;
|
|
108
|
+
}
|
|
83
109
|
</script>
|
|
84
110
|
|
|
85
|
-
|
|
111
|
+
<!-- The app's id gives way to the one an overlay gives its trigger, which the overlay's own
|
|
112
|
+
parts point at. -->
|
|
113
|
+
<button {...rootAttributes(rest)} {...attributes()} bind:this={button}
|
|
86
114
|
>{#if loading}{#if iconStart}
|
|
87
115
|
<!-- Where the icon was, so the button keeps its width. -->
|
|
88
116
|
<span class={icon.box}><Spinner size="sm" /></span>
|
package/dist/Button.svelte.d.ts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import type { ButtonBaseProps } from "@xds/core";
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
3
4
|
import type { RootProps } from "./root.js";
|
|
4
5
|
export type { ButtonVariant, ControlSize } from "@xds/core";
|
|
5
6
|
export type ButtonProps = ButtonBaseProps & RootProps & {
|
|
6
7
|
onPress?: () => void;
|
|
8
|
+
onFocus?: FocusEventHandler<HTMLButtonElement>;
|
|
9
|
+
onBlur?: FocusEventHandler<HTMLButtonElement>;
|
|
7
10
|
/** Leave it out for a button that holds only an icon, and name that one with `aria-label`. */
|
|
8
11
|
children?: Snippet;
|
|
9
12
|
};
|
|
10
13
|
/**
|
|
11
14
|
* A native button. It also opens a Menu or a Tooltip it is the trigger of: their props reach it
|
|
12
15
|
* through context.
|
|
16
|
+
*
|
|
17
|
+
* `focus()`, `blur()` and `element()` on the instance reach the native button.
|
|
13
18
|
*/
|
|
14
|
-
declare const Button: import("svelte").Component<ButtonProps, {
|
|
19
|
+
declare const Button: import("svelte").Component<ButtonProps, {
|
|
20
|
+
focus: (options?: FocusOptions) => void;
|
|
21
|
+
blur: () => void;
|
|
22
|
+
element: () => HTMLButtonElement | undefined;
|
|
23
|
+
}, "">;
|
|
15
24
|
type Button = ReturnType<typeof Button>;
|
|
16
25
|
export default Button;
|
package/dist/Card.svelte
CHANGED
|
@@ -22,7 +22,14 @@
|
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
<script lang="ts">
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
CARD_PARTS,
|
|
27
|
+
cardClass,
|
|
28
|
+
cardMediaClass,
|
|
29
|
+
classes,
|
|
30
|
+
rootAttributes,
|
|
31
|
+
rootPart,
|
|
32
|
+
} from "@xds/core";
|
|
26
33
|
|
|
27
34
|
let {
|
|
28
35
|
title,
|
|
@@ -35,6 +42,7 @@
|
|
|
35
42
|
class: className,
|
|
36
43
|
style,
|
|
37
44
|
children,
|
|
45
|
+
...rest
|
|
38
46
|
}: CardProps = $props();
|
|
39
47
|
|
|
40
48
|
const pressable = $derived(onPress !== undefined);
|
|
@@ -84,6 +92,7 @@
|
|
|
84
92
|
|
|
85
93
|
{#if pressable}
|
|
86
94
|
<button
|
|
95
|
+
{...rootAttributes(rest)}
|
|
87
96
|
type="button"
|
|
88
97
|
onclick={() => onPress?.()}
|
|
89
98
|
aria-pressed={selected === undefined ? undefined : selected ? "true" : "false"}
|
|
@@ -93,7 +102,12 @@
|
|
|
93
102
|
{@render content()}
|
|
94
103
|
</button>
|
|
95
104
|
{:else}
|
|
96
|
-
<section
|
|
105
|
+
<section
|
|
106
|
+
{...rootAttributes(rest)}
|
|
107
|
+
aria-current={selected ? "true" : undefined}
|
|
108
|
+
class={surface}
|
|
109
|
+
{style}
|
|
110
|
+
>
|
|
97
111
|
{@render content()}
|
|
98
112
|
</section>
|
|
99
113
|
{/if}
|
package/dist/Checkbox.svelte
CHANGED
|
@@ -1,60 +1,112 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
A choice that is applied later, with the form it belongs to. A native checkbox: the input is
|
|
4
|
-
hidden and the box is drawn beside it.
|
|
4
|
+
hidden and the box is drawn beside it. Without `checked` it keeps its own state, from
|
|
5
|
+
`defaultChecked`, and a reset of its form puts that back. With `indeterminate` it shows a dash
|
|
6
|
+
and is reported as mixed.
|
|
7
|
+
|
|
8
|
+
`focus()`, `blur()` and `element()` on the instance reach the native checkbox.
|
|
5
9
|
-->
|
|
6
10
|
<script module lang="ts">
|
|
7
11
|
import type { CheckboxBaseProps } from "@xds/core";
|
|
12
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
8
13
|
import type { RootProps } from "./root.js";
|
|
9
14
|
|
|
10
15
|
export type CheckboxProps = CheckboxBaseProps &
|
|
11
16
|
RootProps & {
|
|
12
|
-
onChange
|
|
17
|
+
onChange?: (checked: boolean) => void;
|
|
18
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
19
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
13
20
|
};
|
|
14
21
|
</script>
|
|
15
22
|
|
|
16
23
|
<script lang="ts">
|
|
17
24
|
import {
|
|
18
|
-
CHECKBOX_MARK,
|
|
19
25
|
checkboxBoxClass,
|
|
20
26
|
checkboxClass,
|
|
21
27
|
checkboxLabelClass,
|
|
28
|
+
checkboxMark,
|
|
22
29
|
checkboxMarkClass,
|
|
23
30
|
classes,
|
|
31
|
+
rootAttributes,
|
|
24
32
|
rootPart,
|
|
25
33
|
} from "@xds/core";
|
|
34
|
+
import { controllable, followFormReset } from "./controllable.svelte.js";
|
|
26
35
|
import { keepChecked } from "./controlled.js";
|
|
27
36
|
|
|
37
|
+
// `checked` stays in the rest, where whether it is given at all can be asked.
|
|
28
38
|
let {
|
|
29
|
-
|
|
39
|
+
defaultChecked = false,
|
|
40
|
+
indeterminate = false,
|
|
30
41
|
label,
|
|
31
42
|
"aria-label": ariaLabel,
|
|
32
43
|
name,
|
|
33
44
|
disabled,
|
|
34
45
|
onChange,
|
|
46
|
+
onFocus,
|
|
47
|
+
onBlur,
|
|
35
48
|
class: className,
|
|
36
49
|
style,
|
|
50
|
+
...rest
|
|
37
51
|
}: CheckboxProps = $props();
|
|
52
|
+
|
|
53
|
+
const control = controllable(
|
|
54
|
+
() => rest,
|
|
55
|
+
"checked",
|
|
56
|
+
() => rest.checked ?? false,
|
|
57
|
+
() => defaultChecked,
|
|
58
|
+
() => onChange,
|
|
59
|
+
);
|
|
60
|
+
let input = $state<HTMLInputElement>();
|
|
61
|
+
followFormReset(() => input, control);
|
|
62
|
+
// A property of the native input, with no attribute: it is what reports the box as mixed.
|
|
63
|
+
$effect(() => {
|
|
64
|
+
if (input) input.indeterminate = indeterminate;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/** Moves the focus to the native checkbox. */
|
|
68
|
+
export function focus(options?: FocusOptions) {
|
|
69
|
+
input?.focus(options);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Takes the focus from the native checkbox. */
|
|
73
|
+
export function blur() {
|
|
74
|
+
input?.blur();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The native checkbox, once it is on the page. */
|
|
78
|
+
export function element(): HTMLInputElement | undefined {
|
|
79
|
+
return input;
|
|
80
|
+
}
|
|
38
81
|
</script>
|
|
39
82
|
|
|
40
|
-
<label
|
|
83
|
+
<label
|
|
84
|
+
{...rootAttributes(rest)}
|
|
85
|
+
class={classes(rootPart("Checkbox"), checkboxClass, className)}
|
|
86
|
+
{style}
|
|
87
|
+
>
|
|
41
88
|
<input
|
|
89
|
+
bind:this={input}
|
|
42
90
|
type="checkbox"
|
|
43
91
|
aria-label={ariaLabel}
|
|
44
92
|
class="peer sr-only"
|
|
45
|
-
{
|
|
46
|
-
defaultChecked={
|
|
93
|
+
checked={control.current}
|
|
94
|
+
defaultChecked={control.controlled ? control.current : defaultChecked}
|
|
47
95
|
{disabled}
|
|
48
96
|
name={name || undefined}
|
|
49
97
|
onchange={(event) => {
|
|
50
|
-
|
|
51
|
-
|
|
98
|
+
// A press clears it on the input; it stays until the app clears it.
|
|
99
|
+
event.currentTarget.indeterminate = indeterminate;
|
|
100
|
+
control.set(event.currentTarget.checked);
|
|
101
|
+
keepChecked(event.currentTarget, () => control.current);
|
|
52
102
|
}}
|
|
103
|
+
onfocus={onFocus}
|
|
104
|
+
onblur={onBlur}
|
|
53
105
|
/>
|
|
54
106
|
<span class={checkboxBoxClass}>
|
|
55
107
|
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class={checkboxMarkClass}>
|
|
56
108
|
<path
|
|
57
|
-
d={
|
|
109
|
+
d={checkboxMark(indeterminate)}
|
|
58
110
|
stroke="currentColor"
|
|
59
111
|
stroke-width="2"
|
|
60
112
|
stroke-linecap="round"
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import type { CheckboxBaseProps } from "@xds/core";
|
|
2
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
2
3
|
import type { RootProps } from "./root.js";
|
|
3
4
|
export type CheckboxProps = CheckboxBaseProps & RootProps & {
|
|
4
|
-
onChange
|
|
5
|
+
onChange?: (checked: boolean) => void;
|
|
6
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
7
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
5
8
|
};
|
|
6
9
|
/**
|
|
7
10
|
* A choice that is applied later, with the form it belongs to. A native checkbox: the input is
|
|
8
|
-
* hidden and the box is drawn beside it.
|
|
11
|
+
* hidden and the box is drawn beside it. Without `checked` it keeps its own state, from
|
|
12
|
+
* `defaultChecked`, and a reset of its form puts that back. With `indeterminate` it shows a dash
|
|
13
|
+
* and is reported as mixed.
|
|
14
|
+
*
|
|
15
|
+
* `focus()`, `blur()` and `element()` on the instance reach the native checkbox.
|
|
9
16
|
*/
|
|
10
|
-
declare const Checkbox: import("svelte").Component<CheckboxProps, {
|
|
17
|
+
declare const Checkbox: import("svelte").Component<CheckboxProps, {
|
|
18
|
+
focus: (options?: FocusOptions) => void;
|
|
19
|
+
blur: () => void;
|
|
20
|
+
element: () => HTMLInputElement | undefined;
|
|
21
|
+
}, "">;
|
|
11
22
|
type Checkbox = ReturnType<typeof Checkbox>;
|
|
12
23
|
export default Checkbox;
|
package/dist/Chip.svelte
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<script lang="ts">
|
|
19
|
-
import { chipClass, chipIcon, classes, rootPart } from "@xds/core";
|
|
19
|
+
import { chipClass, chipIcon, classes, rootAttributes, rootPart } from "@xds/core";
|
|
20
20
|
import Icon from "./Icon.svelte";
|
|
21
21
|
|
|
22
22
|
let {
|
|
@@ -27,12 +27,14 @@
|
|
|
27
27
|
onPress,
|
|
28
28
|
class: className,
|
|
29
29
|
style,
|
|
30
|
+
...rest
|
|
30
31
|
}: ChipProps = $props();
|
|
31
32
|
|
|
32
33
|
const icon = $derived(chipIcon({ selected, iconStart }));
|
|
33
34
|
</script>
|
|
34
35
|
|
|
35
36
|
<button
|
|
37
|
+
{...rootAttributes(rest)}
|
|
36
38
|
type="button"
|
|
37
39
|
aria-pressed={selected ? "true" : "false"}
|
|
38
40
|
{disabled}
|
package/dist/ChipBar.svelte
CHANGED
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<script lang="ts">
|
|
19
|
-
import { chipBarClass, classes, rootPart } from "@xds/core";
|
|
19
|
+
import { chipBarClass, classes, rootAttributes, rootPart } from "@xds/core";
|
|
20
20
|
|
|
21
|
-
let { label, class: className, style, children }: ChipBarProps = $props();
|
|
21
|
+
let { label, class: className, style, children, ...rest }: ChipBarProps = $props();
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
<!-- A group, not a fieldset: a fieldset cannot be a scrolling flex row in every browser. -->
|
|
25
25
|
<div
|
|
26
|
+
{...rootAttributes(rest)}
|
|
26
27
|
role="group"
|
|
27
28
|
aria-label={label}
|
|
28
29
|
class={classes(rootPart("ChipBar"), chipBarClass, className)}
|