@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
package/dist/Slider.svelte.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { SliderBaseProps } from "@xds/core";
|
|
2
2
|
import type { RootProps } from "./root.js";
|
|
3
3
|
export type SliderProps = SliderBaseProps & RootProps & {
|
|
4
|
-
onChange
|
|
4
|
+
onChange?: (value: number) => void;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
7
|
* Picks a number in a range by dragging the thumb, or by pressing the track where it should go.
|
|
8
8
|
* The values snap to `step`.
|
|
9
9
|
*
|
|
10
10
|
* It is a slider named by its label with its value, minimum and maximum, and each arrow key moves
|
|
11
|
-
* it one step.
|
|
11
|
+
* it one step. Without `value` it keeps its own, from `defaultValue` or else `min`.
|
|
12
12
|
*/
|
|
13
13
|
declare const Slider: import("svelte").Component<SliderProps, {}, "">;
|
|
14
14
|
type Slider = ReturnType<typeof Slider>;
|
package/dist/Spinner.svelte
CHANGED
|
@@ -12,16 +12,17 @@
|
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
|
-
import { classes, rootPart, spinnerClass } from "@xds/core";
|
|
15
|
+
import { classes, rootAttributes, rootPart, spinnerClass } from "@xds/core";
|
|
16
16
|
import { useDefaults } from "./defaults.svelte.js";
|
|
17
17
|
|
|
18
|
-
let { size: ownSize, label, class: className, style }: SpinnerProps = $props();
|
|
18
|
+
let { size: ownSize, label, class: className, style, ...rest }: SpinnerProps = $props();
|
|
19
19
|
|
|
20
20
|
const defaults = useDefaults("Spinner");
|
|
21
21
|
const size = $derived(ownSize ?? defaults().size);
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
<span
|
|
25
|
+
{...rootAttributes(rest)}
|
|
25
26
|
class={classes(rootPart("Spinner"), "inline-flex shrink-0", className)}
|
|
26
27
|
{style}
|
|
27
28
|
role={label ? "status" : undefined}
|
package/dist/Switch.svelte
CHANGED
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
form, use a Checkbox.
|
|
5
5
|
|
|
6
6
|
It is a native checkbox with the switch role, so the keyboard, forms and screen readers treat
|
|
7
|
-
it as one. The input is hidden and the track is drawn beside it.
|
|
7
|
+
it as one. The input is hidden and the track is drawn beside it. Without `checked` it keeps its
|
|
8
|
+
own state, from `defaultChecked`, and a reset of its form puts that back.
|
|
9
|
+
|
|
10
|
+
`focus()`, `blur()` and `element()` on the instance reach the native checkbox.
|
|
8
11
|
-->
|
|
9
12
|
<script module lang="ts">
|
|
10
13
|
import {
|
|
11
14
|
classes,
|
|
15
|
+
rootAttributes,
|
|
12
16
|
rootPart,
|
|
13
17
|
type SwitchBaseProps,
|
|
14
18
|
switchClass,
|
|
@@ -16,42 +20,82 @@
|
|
|
16
20
|
switchThumbClass,
|
|
17
21
|
switchTrackClass,
|
|
18
22
|
} from "@xds/core";
|
|
23
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
19
24
|
import type { RootProps } from "./root.js";
|
|
20
25
|
|
|
21
26
|
export type SwitchProps = SwitchBaseProps &
|
|
22
27
|
RootProps & {
|
|
23
|
-
onChange
|
|
28
|
+
onChange?: (checked: boolean) => void;
|
|
29
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
30
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
24
31
|
};
|
|
25
32
|
</script>
|
|
26
33
|
|
|
27
34
|
<script lang="ts">
|
|
35
|
+
import { controllable, followFormReset } from "./controllable.svelte.js";
|
|
28
36
|
import { keepChecked } from "./controlled.js";
|
|
29
37
|
|
|
38
|
+
// `checked` stays in the rest, where whether it is given at all can be asked.
|
|
30
39
|
let {
|
|
31
|
-
|
|
40
|
+
defaultChecked = false,
|
|
32
41
|
label,
|
|
33
42
|
"aria-label": ariaLabel,
|
|
34
43
|
disabled,
|
|
35
44
|
onChange,
|
|
45
|
+
onFocus,
|
|
46
|
+
onBlur,
|
|
36
47
|
class: className,
|
|
37
48
|
style,
|
|
49
|
+
...rest
|
|
38
50
|
}: SwitchProps = $props();
|
|
51
|
+
|
|
52
|
+
const control = controllable(
|
|
53
|
+
() => rest,
|
|
54
|
+
"checked",
|
|
55
|
+
() => rest.checked ?? false,
|
|
56
|
+
() => defaultChecked,
|
|
57
|
+
() => onChange,
|
|
58
|
+
);
|
|
59
|
+
let input = $state<HTMLInputElement>();
|
|
60
|
+
followFormReset(() => input, control);
|
|
61
|
+
|
|
62
|
+
/** Moves the focus to the native checkbox. */
|
|
63
|
+
export function focus(options?: FocusOptions) {
|
|
64
|
+
input?.focus(options);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Takes the focus from the native checkbox. */
|
|
68
|
+
export function blur() {
|
|
69
|
+
input?.blur();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The native checkbox, once it is on the page. */
|
|
73
|
+
export function element(): HTMLInputElement | undefined {
|
|
74
|
+
return input;
|
|
75
|
+
}
|
|
39
76
|
</script>
|
|
40
77
|
|
|
41
|
-
<label
|
|
78
|
+
<label
|
|
79
|
+
{...rootAttributes(rest)}
|
|
80
|
+
class={classes(rootPart("Switch"), switchClass, className)}
|
|
81
|
+
{style}
|
|
82
|
+
>
|
|
42
83
|
<input
|
|
84
|
+
bind:this={input}
|
|
43
85
|
type="checkbox"
|
|
44
86
|
role="switch"
|
|
45
|
-
aria-checked={
|
|
87
|
+
aria-checked={control.current ? "true" : "false"}
|
|
46
88
|
aria-label={ariaLabel}
|
|
47
89
|
class="peer sr-only"
|
|
48
|
-
{
|
|
49
|
-
defaultChecked={
|
|
90
|
+
checked={control.current}
|
|
91
|
+
defaultChecked={control.controlled ? control.current : defaultChecked}
|
|
50
92
|
{disabled}
|
|
51
93
|
onchange={(event) => {
|
|
52
|
-
|
|
53
|
-
keepChecked(event.currentTarget, () =>
|
|
94
|
+
control.set(event.currentTarget.checked);
|
|
95
|
+
keepChecked(event.currentTarget, () => control.current);
|
|
54
96
|
}}
|
|
97
|
+
onfocus={onFocus}
|
|
98
|
+
onblur={onBlur}
|
|
55
99
|
/>
|
|
56
100
|
<span class={switchTrackClass}><span class={switchThumbClass}></span></span>
|
|
57
101
|
{#if label}
|
package/dist/Switch.svelte.d.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { type SwitchBaseProps } from "@xds/core";
|
|
2
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
2
3
|
import type { RootProps } from "./root.js";
|
|
3
4
|
export type SwitchProps = SwitchBaseProps & RootProps & {
|
|
4
|
-
onChange
|
|
5
|
+
onChange?: (checked: boolean) => void;
|
|
6
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
7
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
5
8
|
};
|
|
6
9
|
/**
|
|
7
10
|
* Turns a setting on or off, and takes effect at once. For a choice that is applied later, with a
|
|
8
11
|
* form, use a Checkbox.
|
|
9
12
|
*
|
|
10
13
|
* It is a native checkbox with the switch role, so the keyboard, forms and screen readers treat
|
|
11
|
-
* it as one. The input is hidden and the track is drawn beside it.
|
|
14
|
+
* it as one. The input is hidden and the track is drawn beside it. Without `checked` it keeps its
|
|
15
|
+
* own state, from `defaultChecked`, and a reset of its form puts that back.
|
|
16
|
+
*
|
|
17
|
+
* `focus()`, `blur()` and `element()` on the instance reach the native checkbox.
|
|
12
18
|
*/
|
|
13
|
-
declare const Switch: import("svelte").Component<SwitchProps, {
|
|
19
|
+
declare const Switch: import("svelte").Component<SwitchProps, {
|
|
20
|
+
focus: (options?: FocusOptions) => void;
|
|
21
|
+
blur: () => void;
|
|
22
|
+
element: () => HTMLInputElement | undefined;
|
|
23
|
+
}, "">;
|
|
14
24
|
type Switch = ReturnType<typeof Switch>;
|
|
15
25
|
export default Switch;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Rows of data under a row of column headers, to read and compare across. The header of a
|
|
4
|
+
sortable column is a button that asks for the rows sorted by it (`onSortChange`), ascending
|
|
5
|
+
first and then the other way, and the header they are sorted by says so with `aria-sort` and an
|
|
6
|
+
arrow. The rows are shown in the order given. Where the columns do not fit, the table scrolls
|
|
7
|
+
sideways.
|
|
8
|
+
-->
|
|
9
|
+
<script module lang="ts">
|
|
10
|
+
import type { TableBaseProps, TableSort } from "@xds/core";
|
|
11
|
+
import type { RootProps } from "./root.js";
|
|
12
|
+
|
|
13
|
+
export type { SortDirection, TableColumn, TableRow, TableSort } from "@xds/core";
|
|
14
|
+
|
|
15
|
+
export type TableProps = TableBaseProps &
|
|
16
|
+
RootProps & {
|
|
17
|
+
/** The sort a press on a sortable column's header asks for; the app sorts the rows. */
|
|
18
|
+
onSortChange?: (sort: TableSort) => void;
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import {
|
|
24
|
+
classes,
|
|
25
|
+
columnSort,
|
|
26
|
+
nextSort,
|
|
27
|
+
rootAttributes,
|
|
28
|
+
rootPart,
|
|
29
|
+
sortIcon,
|
|
30
|
+
TABLE_PARTS,
|
|
31
|
+
} from "@xds/core";
|
|
32
|
+
import Icon from "./Icon.svelte";
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
label,
|
|
36
|
+
columns,
|
|
37
|
+
rows,
|
|
38
|
+
sort,
|
|
39
|
+
empty,
|
|
40
|
+
onSortChange,
|
|
41
|
+
class: className,
|
|
42
|
+
style,
|
|
43
|
+
...rest
|
|
44
|
+
}: TableProps = $props();
|
|
45
|
+
|
|
46
|
+
const end = (align: string | undefined) => align === "end" && TABLE_PARTS.end;
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<div {...rootAttributes(rest)} class={classes(rootPart("Table"), className)} {style}>
|
|
50
|
+
<table class={TABLE_PARTS.table} aria-label={label}>
|
|
51
|
+
<thead>
|
|
52
|
+
<tr class={TABLE_PARTS.row}>
|
|
53
|
+
{#each columns as column (column.key)}
|
|
54
|
+
{@const direction = columnSort(sort, column.key)}
|
|
55
|
+
<th
|
|
56
|
+
scope="col"
|
|
57
|
+
aria-sort={direction}
|
|
58
|
+
class={classes(TABLE_PARTS.header, end(column.align))}
|
|
59
|
+
>
|
|
60
|
+
{#if column.sortable}
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
class={TABLE_PARTS.sort}
|
|
64
|
+
onclick={() => onSortChange?.(nextSort(sort, column.key))}
|
|
65
|
+
>
|
|
66
|
+
{column.label}
|
|
67
|
+
<Icon name={sortIcon(direction)} size="xs" />
|
|
68
|
+
</button>
|
|
69
|
+
{:else}
|
|
70
|
+
{column.label}
|
|
71
|
+
{/if}
|
|
72
|
+
</th>
|
|
73
|
+
{/each}
|
|
74
|
+
</tr>
|
|
75
|
+
</thead>
|
|
76
|
+
<tbody>
|
|
77
|
+
{#if rows.length === 0 && empty !== undefined}
|
|
78
|
+
<tr class={TABLE_PARTS.row}>
|
|
79
|
+
<td class={TABLE_PARTS.empty} colspan={columns.length}>{empty}</td>
|
|
80
|
+
</tr>
|
|
81
|
+
{:else}
|
|
82
|
+
{#each rows as row (row.id)}
|
|
83
|
+
<tr class={TABLE_PARTS.row}>
|
|
84
|
+
{#each columns as column, index (column.key)}
|
|
85
|
+
<td class={classes(TABLE_PARTS.cell, end(column.align))}>{row.cells[index]}</td>
|
|
86
|
+
{/each}
|
|
87
|
+
</tr>
|
|
88
|
+
{/each}
|
|
89
|
+
{/if}
|
|
90
|
+
</tbody>
|
|
91
|
+
</table>
|
|
92
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TableBaseProps, TableSort } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.js";
|
|
3
|
+
export type { SortDirection, TableColumn, TableRow, TableSort } from "@xds/core";
|
|
4
|
+
export type TableProps = TableBaseProps & RootProps & {
|
|
5
|
+
/** The sort a press on a sortable column's header asks for; the app sorts the rows. */
|
|
6
|
+
onSortChange?: (sort: TableSort) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Rows of data under a row of column headers, to read and compare across. The header of a
|
|
10
|
+
* sortable column is a button that asks for the rows sorted by it (`onSortChange`), ascending
|
|
11
|
+
* first and then the other way, and the header they are sorted by says so with `aria-sort` and an
|
|
12
|
+
* arrow. The rows are shown in the order given. Where the columns do not fit, the table scrolls
|
|
13
|
+
* sideways.
|
|
14
|
+
*/
|
|
15
|
+
declare const Table: import("svelte").Component<TableProps, {}, "">;
|
|
16
|
+
type Table = ReturnType<typeof Table>;
|
|
17
|
+
export default Table;
|
package/dist/Tabs.svelte
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
The selected tab is underlined as well as darker, so the choice does not depend on color. This
|
|
7
7
|
is only the row: the app shows the view that matches `value`. The arrow keys move between tabs.
|
|
8
|
+
Without `value` the tabs keep their own, from `defaultValue` or else the first.
|
|
8
9
|
-->
|
|
9
10
|
<script module lang="ts">
|
|
10
11
|
import type { TabsBaseProps } from "@xds/core";
|
|
@@ -12,37 +13,51 @@
|
|
|
12
13
|
|
|
13
14
|
export type TabsProps<Value extends string> = TabsBaseProps<Value> &
|
|
14
15
|
RootProps & {
|
|
15
|
-
onChange
|
|
16
|
+
onChange?: (value: Value) => void;
|
|
16
17
|
};
|
|
17
18
|
</script>
|
|
18
19
|
|
|
19
20
|
<script lang="ts" generics="Value extends string">
|
|
20
|
-
import { classes, tabStopIndex, tabsClass } from "@xds/core";
|
|
21
|
+
import { classes, rootAttributes, tabStopIndex, tabsClass } from "@xds/core";
|
|
21
22
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
22
23
|
import * as tabs from "@zag-js/tabs";
|
|
24
|
+
import { controllable } from "./controllable.svelte.js";
|
|
23
25
|
import Icon from "./Icon.svelte";
|
|
24
26
|
|
|
27
|
+
// `value` stays in the rest, where whether it is given at all can be asked.
|
|
25
28
|
let {
|
|
26
29
|
items,
|
|
27
|
-
|
|
30
|
+
defaultValue,
|
|
28
31
|
label,
|
|
29
32
|
fullWidth,
|
|
30
33
|
onChange,
|
|
31
34
|
class: className,
|
|
32
35
|
style,
|
|
36
|
+
...rest
|
|
33
37
|
}: TabsProps<Value> = $props();
|
|
34
38
|
|
|
39
|
+
const control = controllable<Value | undefined, Value>(
|
|
40
|
+
() => rest,
|
|
41
|
+
"value",
|
|
42
|
+
() => rest.value,
|
|
43
|
+
() => defaultValue ?? items[0]?.value,
|
|
44
|
+
() => onChange,
|
|
45
|
+
);
|
|
35
46
|
const id = $props.id();
|
|
36
47
|
const service = useMachine(tabs.machine, () => ({
|
|
37
48
|
id,
|
|
38
|
-
value,
|
|
39
|
-
onValueChange: (details: tabs.ValueChangeDetails) =>
|
|
49
|
+
value: control.current ?? null,
|
|
50
|
+
onValueChange: (details: tabs.ValueChangeDetails) => control.set(details.value as Value),
|
|
40
51
|
}));
|
|
41
52
|
const api = $derived(tabs.connect(service, normalizeProps));
|
|
42
53
|
// Merged, so that the app's style joins any the machine writes on the root. The recipe gives
|
|
43
54
|
// the root part, `xds-tabs`.
|
|
44
55
|
const root = $derived(
|
|
45
|
-
mergeProps(api.getRootProps(), {
|
|
56
|
+
mergeProps(api.getRootProps(), {
|
|
57
|
+
...rootAttributes(rest),
|
|
58
|
+
class: classes(tabsClass(fullWidth), className),
|
|
59
|
+
style,
|
|
60
|
+
}),
|
|
46
61
|
);
|
|
47
62
|
</script>
|
|
48
63
|
|
package/dist/Tabs.svelte.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TabsBaseProps } from "@xds/core";
|
|
2
2
|
import type { RootProps } from "./root.js";
|
|
3
3
|
export type TabsProps<Value extends string> = TabsBaseProps<Value> & RootProps & {
|
|
4
|
-
onChange
|
|
4
|
+
onChange?: (value: Value) => void;
|
|
5
5
|
};
|
|
6
6
|
declare function $$render<Value extends string>(): {
|
|
7
7
|
props: TabsProps<Value>;
|
|
@@ -30,6 +30,7 @@ interface $$IsomorphicComponent {
|
|
|
30
30
|
*
|
|
31
31
|
* The selected tab is underlined as well as darker, so the choice does not depend on color. This
|
|
32
32
|
* is only the row: the app shows the view that matches `value`. The arrow keys move between tabs.
|
|
33
|
+
* Without `value` the tabs keep their own, from `defaultValue` or else the first.
|
|
33
34
|
*/
|
|
34
35
|
declare const Tabs: $$IsomorphicComponent;
|
|
35
36
|
type Tabs<Value extends string> = InstanceType<typeof Tabs<Value>>;
|
package/dist/Text.svelte
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
|
-
import { classes, rootPart, textClass } from "@xds/core";
|
|
15
|
+
import { classes, rootAttributes, rootPart, textClass } from "@xds/core";
|
|
16
16
|
import { useDefaults } from "./defaults.svelte.js";
|
|
17
17
|
|
|
18
18
|
let {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
class: className,
|
|
23
23
|
style,
|
|
24
24
|
children,
|
|
25
|
+
...rest
|
|
25
26
|
}: TextProps = $props();
|
|
26
27
|
|
|
27
28
|
const defaults = useDefaults("Text");
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
|
|
32
33
|
<svelte:element
|
|
33
34
|
this={as}
|
|
35
|
+
{...rootAttributes(rest)}
|
|
34
36
|
class={classes(rootPart("Text"), textClass({ variant, tone }), className)}
|
|
35
37
|
{style}>{@render children()}</svelte:element
|
|
36
38
|
>
|
package/dist/TextField.svelte
CHANGED
|
@@ -4,16 +4,22 @@
|
|
|
4
4
|
are tied to the input for assistive technology, and the error is announced when it appears.
|
|
5
5
|
|
|
6
6
|
An invalid field blocks its form from being submitted, so `error` has to be cleared as soon as
|
|
7
|
-
the person edits the value.
|
|
7
|
+
the person edits the value. Without `value` it keeps its own text, from `defaultValue`, and a
|
|
8
|
+
reset of its form puts that back.
|
|
9
|
+
|
|
10
|
+
`focus()`, `blur()` and `element()` on the instance reach the native input or text area.
|
|
8
11
|
-->
|
|
9
12
|
<script module lang="ts">
|
|
10
13
|
import type { TextFieldBaseProps } from "@xds/core";
|
|
11
14
|
import type { Snippet } from "svelte";
|
|
15
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
12
16
|
import type { RootProps } from "./root.js";
|
|
13
17
|
|
|
14
18
|
export type TextFieldProps = TextFieldBaseProps &
|
|
15
19
|
RootProps & {
|
|
16
|
-
onChange
|
|
20
|
+
onChange?: (value: string) => void;
|
|
21
|
+
onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
22
|
+
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
17
23
|
/**
|
|
18
24
|
* Inside the box, in front of the text: an icon, a unit. It takes the placeholder's color
|
|
19
25
|
* unless it sets its own.
|
|
@@ -25,14 +31,17 @@
|
|
|
25
31
|
</script>
|
|
26
32
|
|
|
27
33
|
<script lang="ts">
|
|
28
|
-
import { classes } from "@xds/core";
|
|
34
|
+
import { classes, rootAttributes } from "@xds/core";
|
|
29
35
|
import { untrack } from "svelte";
|
|
30
36
|
import type { Attachment } from "svelte/attachments";
|
|
37
|
+
import { controllable, followFormReset } from "./controllable.svelte.js";
|
|
31
38
|
import { keepValue } from "./controlled.js";
|
|
32
39
|
|
|
40
|
+
// `value` stays in the rest, where whether it is given at all can be asked.
|
|
33
41
|
let {
|
|
34
42
|
label,
|
|
35
|
-
|
|
43
|
+
defaultValue = "",
|
|
44
|
+
readOnly,
|
|
36
45
|
description,
|
|
37
46
|
error,
|
|
38
47
|
placeholder,
|
|
@@ -47,12 +56,40 @@
|
|
|
47
56
|
required,
|
|
48
57
|
disabled,
|
|
49
58
|
onChange,
|
|
59
|
+
onFocus,
|
|
60
|
+
onBlur,
|
|
50
61
|
leading,
|
|
51
62
|
trailing,
|
|
52
63
|
class: className,
|
|
53
64
|
style,
|
|
65
|
+
...rest
|
|
54
66
|
}: TextFieldProps = $props();
|
|
55
67
|
|
|
68
|
+
const control = controllable(
|
|
69
|
+
() => rest,
|
|
70
|
+
"value",
|
|
71
|
+
() => rest.value ?? "",
|
|
72
|
+
() => defaultValue,
|
|
73
|
+
() => onChange,
|
|
74
|
+
);
|
|
75
|
+
let input = $state<HTMLInputElement | HTMLTextAreaElement>();
|
|
76
|
+
followFormReset(() => input, control);
|
|
77
|
+
|
|
78
|
+
/** Moves the focus to the native input or text area. */
|
|
79
|
+
export function focus(options?: FocusOptions) {
|
|
80
|
+
input?.focus(options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Takes the focus from the native input or text area. */
|
|
84
|
+
export function blur() {
|
|
85
|
+
input?.blur();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The native input or text area, once it is on the page. */
|
|
89
|
+
export function element(): HTMLInputElement | HTMLTextAreaElement | undefined {
|
|
90
|
+
return input;
|
|
91
|
+
}
|
|
92
|
+
|
|
56
93
|
const id = $props.id();
|
|
57
94
|
const descriptionId = `${id}-description`;
|
|
58
95
|
const errorId = `${id}-error`;
|
|
@@ -73,17 +110,17 @@
|
|
|
73
110
|
};
|
|
74
111
|
|
|
75
112
|
function oninput(event: Event & { currentTarget: HTMLInputElement | HTMLTextAreaElement }) {
|
|
76
|
-
|
|
113
|
+
control.set(event.currentTarget.value);
|
|
77
114
|
// While a composition is open the text belongs to the input method; it ends with
|
|
78
115
|
// compositionend.
|
|
79
116
|
if (!(event instanceof InputEvent && event.isComposing))
|
|
80
|
-
keepValue(event.currentTarget, () =>
|
|
117
|
+
keepValue(event.currentTarget, () => control.current);
|
|
81
118
|
}
|
|
82
119
|
|
|
83
120
|
function oncompositionend(
|
|
84
121
|
event: CompositionEvent & { currentTarget: HTMLInputElement | HTMLTextAreaElement },
|
|
85
122
|
) {
|
|
86
|
-
keepValue(event.currentTarget, () =>
|
|
123
|
+
keepValue(event.currentTarget, () => control.current);
|
|
87
124
|
}
|
|
88
125
|
</script>
|
|
89
126
|
|
|
@@ -96,20 +133,24 @@
|
|
|
96
133
|
{rows}
|
|
97
134
|
{id}
|
|
98
135
|
class={box ? "xds-text-field__input xds-text-field__control" : "xds-text-field__input"}
|
|
99
|
-
{
|
|
100
|
-
|
|
136
|
+
bind:this={input}
|
|
137
|
+
value={control.current}
|
|
138
|
+
defaultValue={control.controlled ? control.current : defaultValue}
|
|
101
139
|
{placeholder}
|
|
102
140
|
{name}
|
|
103
141
|
maxlength={maxLength}
|
|
104
142
|
inputmode={inputMode}
|
|
105
143
|
autocomplete={autoComplete as HTMLTextAreaElement["autocomplete"]}
|
|
144
|
+
readonly={readOnly}
|
|
106
145
|
{required}
|
|
107
146
|
{disabled}
|
|
108
147
|
aria-invalid={invalid ? "true" : undefined}
|
|
109
148
|
aria-errormessage={invalid ? errorId : undefined}
|
|
110
149
|
aria-describedby={describedBy}
|
|
111
150
|
{oninput}
|
|
112
|
-
{oncompositionend}
|
|
151
|
+
{oncompositionend}
|
|
152
|
+
onfocus={onFocus}
|
|
153
|
+
onblur={onBlur}></textarea>
|
|
113
154
|
{:else}
|
|
114
155
|
<input
|
|
115
156
|
{@attach settle}
|
|
@@ -117,13 +158,15 @@
|
|
|
117
158
|
{type}
|
|
118
159
|
{id}
|
|
119
160
|
class={box ? "xds-text-field__input xds-text-field__control" : "xds-text-field__input"}
|
|
120
|
-
{
|
|
121
|
-
|
|
161
|
+
bind:this={input}
|
|
162
|
+
value={control.current}
|
|
163
|
+
defaultValue={control.controlled ? control.current : defaultValue}
|
|
122
164
|
{placeholder}
|
|
123
165
|
{name}
|
|
124
166
|
maxlength={maxLength}
|
|
125
167
|
inputmode={inputMode}
|
|
126
168
|
autocomplete={autoComplete as HTMLInputElement["autocomplete"]}
|
|
169
|
+
readonly={readOnly}
|
|
127
170
|
{required}
|
|
128
171
|
{disabled}
|
|
129
172
|
aria-invalid={invalid ? "true" : undefined}
|
|
@@ -131,11 +174,13 @@
|
|
|
131
174
|
aria-describedby={describedBy}
|
|
132
175
|
{oninput}
|
|
133
176
|
{oncompositionend}
|
|
177
|
+
onfocus={onFocus}
|
|
178
|
+
onblur={onBlur}
|
|
134
179
|
/>
|
|
135
180
|
{/if}
|
|
136
181
|
{/snippet}
|
|
137
182
|
|
|
138
|
-
<div class={classes("xds-text-field", className)} {style}>
|
|
183
|
+
<div {...rootAttributes(rest)} class={classes("xds-text-field", className)} {style}>
|
|
139
184
|
<label for={id} class="xds-text-field__label">{label}</label>
|
|
140
185
|
{#if leading || trailing}
|
|
141
186
|
<div class="xds-text-field__control xds-text-field__group">
|
|
@@ -162,7 +207,7 @@
|
|
|
162
207
|
<span id={errorId} class="xds-text-field__error" aria-live="polite">{error}</span>
|
|
163
208
|
{#if maxLength !== undefined}
|
|
164
209
|
<span class="ms-auto shrink-0 text-xds-footnote text-xds-text-secondary tabular-nums"
|
|
165
|
-
>{
|
|
210
|
+
>{control.current.length}/{maxLength}</span
|
|
166
211
|
>
|
|
167
212
|
{/if}
|
|
168
213
|
</div>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { TextFieldBaseProps } 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 TextFieldProps = TextFieldBaseProps & RootProps & {
|
|
5
|
-
onChange
|
|
6
|
+
onChange?: (value: string) => void;
|
|
7
|
+
onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
8
|
+
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
6
9
|
/**
|
|
7
10
|
* Inside the box, in front of the text: an icon, a unit. It takes the placeholder's color
|
|
8
11
|
* unless it sets its own.
|
|
@@ -16,8 +19,15 @@ export type TextFieldProps = TextFieldBaseProps & RootProps & {
|
|
|
16
19
|
* are tied to the input for assistive technology, and the error is announced when it appears.
|
|
17
20
|
*
|
|
18
21
|
* An invalid field blocks its form from being submitted, so `error` has to be cleared as soon as
|
|
19
|
-
* the person edits the value.
|
|
22
|
+
* the person edits the value. Without `value` it keeps its own text, from `defaultValue`, and a
|
|
23
|
+
* reset of its form puts that back.
|
|
24
|
+
*
|
|
25
|
+
* `focus()`, `blur()` and `element()` on the instance reach the native input or text area.
|
|
20
26
|
*/
|
|
21
|
-
declare const TextField: import("svelte").Component<TextFieldProps, {
|
|
27
|
+
declare const TextField: import("svelte").Component<TextFieldProps, {
|
|
28
|
+
focus: (options?: FocusOptions) => void;
|
|
29
|
+
blur: () => void;
|
|
30
|
+
element: () => HTMLInputElement | HTMLTextAreaElement | undefined;
|
|
31
|
+
}, "">;
|
|
22
32
|
type TextField = ReturnType<typeof TextField>;
|
|
23
33
|
export default TextField;
|
package/dist/Thumbnail.svelte
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import {
|
|
17
17
|
classes,
|
|
18
18
|
pictureClass,
|
|
19
|
+
rootAttributes,
|
|
19
20
|
rootPart,
|
|
20
21
|
THUMBNAIL_PARTS,
|
|
21
22
|
thumbnailBadgeClass,
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
progress,
|
|
36
37
|
class: className,
|
|
37
38
|
style,
|
|
39
|
+
...rest
|
|
38
40
|
}: ThumbnailProps = $props();
|
|
39
41
|
|
|
40
42
|
const defaults = useDefaults("Thumbnail");
|
|
@@ -44,7 +46,11 @@
|
|
|
44
46
|
const watched = $derived(thumbnailWatched(progress));
|
|
45
47
|
</script>
|
|
46
48
|
|
|
47
|
-
<span
|
|
49
|
+
<span
|
|
50
|
+
{...rootAttributes(rest)}
|
|
51
|
+
class={classes(rootPart("Thumbnail"), thumbnailClass(ratio), className)}
|
|
52
|
+
{style}
|
|
53
|
+
>
|
|
48
54
|
<!-- The placeholder is the picture's stand-in for assistive technology too, so the description
|
|
49
55
|
is on the box that always shows, not on the picture that may not. -->
|
|
50
56
|
<span
|