@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
|
@@ -2,7 +2,7 @@ import type { RadioGroupBaseProps } from "@xds/core";
|
|
|
2
2
|
import type { RootProps } from "./root.js";
|
|
3
3
|
export type { RadioOption } from "@xds/core";
|
|
4
4
|
export type RadioGroupProps<Value extends string = string> = RadioGroupBaseProps<Value> & RootProps & {
|
|
5
|
-
onChange
|
|
5
|
+
onChange?: (value: Value) => void;
|
|
6
6
|
};
|
|
7
7
|
declare function $$render<Value extends string = string>(): {
|
|
8
8
|
props: RadioGroupProps<Value>;
|
|
@@ -31,7 +31,9 @@ interface $$IsomorphicComponent {
|
|
|
31
31
|
*
|
|
32
32
|
* The chosen option has a dot and a thicker ring, so the choice does not depend on color. The
|
|
33
33
|
* options are native radio buttons, hidden and drawn beside, in a group named by the legend: the
|
|
34
|
-
* arrow keys move between them, and the error is tied to the group and announced.
|
|
34
|
+
* arrow keys move between them, and the error is tied to the group and announced. Without
|
|
35
|
+
* `value` it keeps its own choice, from `defaultValue`, and a reset of its form puts that back;
|
|
36
|
+
* given `value`, even as `undefined`, it shows the app's.
|
|
35
37
|
*/
|
|
36
38
|
declare const RadioGroup: $$IsomorphicComponent;
|
|
37
39
|
type RadioGroup<Value extends string = string> = InstanceType<typeof RadioGroup<Value>>;
|
package/dist/SearchField.svelte
CHANGED
|
@@ -1,45 +1,89 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
A text field for a query: TextField's box as a pill, with a search icon in front and, while
|
|
4
|
-
there is a value, a control that clears it. Escape clears too.
|
|
4
|
+
there is a value, a control that clears it. Escape clears too. A read-only field has neither.
|
|
5
5
|
|
|
6
6
|
Use it to filter or search what is on the screen. For a value that is saved with a form, use a
|
|
7
|
-
TextField, which has a visible label.
|
|
7
|
+
TextField, which has a visible label. Without `value` it keeps its own query, from
|
|
8
|
+
`defaultValue`, and a reset of its form puts that back.
|
|
9
|
+
|
|
10
|
+
`focus()`, `blur()` and `element()` on the instance reach the native input.
|
|
8
11
|
-->
|
|
9
12
|
<script module lang="ts">
|
|
10
13
|
import type { SearchFieldBaseProps } from "@xds/core";
|
|
14
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
11
15
|
import type { RootProps } from "./root.js";
|
|
12
16
|
|
|
13
17
|
export type SearchFieldProps = SearchFieldBaseProps &
|
|
14
18
|
RootProps & {
|
|
15
|
-
onChange
|
|
19
|
+
onChange?: (value: string) => void;
|
|
16
20
|
/** Called with the query on Enter, or on the search key of a software keyboard. */
|
|
17
21
|
onSubmit?: (value: string) => void;
|
|
22
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
23
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
18
24
|
};
|
|
19
25
|
</script>
|
|
20
26
|
|
|
21
27
|
<script lang="ts">
|
|
22
|
-
import { classes, rootPart } from "@xds/core";
|
|
28
|
+
import { classes, rootAttributes, rootPart } from "@xds/core";
|
|
29
|
+
import { controllable, followFormReset } from "./controllable.svelte.js";
|
|
23
30
|
import { keepValue } from "./controlled.js";
|
|
24
31
|
import Icon from "./Icon.svelte";
|
|
32
|
+
import { useLabels } from "./labels.svelte.js";
|
|
25
33
|
|
|
34
|
+
// `value` stays in the rest, where whether it is given at all can be asked.
|
|
26
35
|
let {
|
|
27
|
-
|
|
36
|
+
defaultValue = "",
|
|
37
|
+
readOnly,
|
|
28
38
|
label,
|
|
29
39
|
placeholder,
|
|
30
40
|
disabled,
|
|
31
41
|
clearLabel,
|
|
32
42
|
onChange,
|
|
33
43
|
onSubmit,
|
|
44
|
+
onFocus,
|
|
45
|
+
onBlur,
|
|
34
46
|
class: className,
|
|
35
47
|
style,
|
|
48
|
+
...rest
|
|
36
49
|
}: SearchFieldProps = $props();
|
|
37
50
|
|
|
51
|
+
const labels = useLabels();
|
|
52
|
+
|
|
53
|
+
const control = controllable(
|
|
54
|
+
() => rest,
|
|
55
|
+
"value",
|
|
56
|
+
() => rest.value ?? "",
|
|
57
|
+
() => defaultValue,
|
|
58
|
+
() => onChange,
|
|
59
|
+
);
|
|
38
60
|
let input = $state<HTMLInputElement>();
|
|
61
|
+
followFormReset(() => input, control);
|
|
62
|
+
// Nothing to clear in a field that cannot be changed.
|
|
63
|
+
const clearable = $derived(control.current !== "" && !disabled && !readOnly);
|
|
64
|
+
|
|
65
|
+
/** Moves the focus to the native input. */
|
|
66
|
+
export function focus(options?: FocusOptions) {
|
|
67
|
+
input?.focus(options);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Takes the focus from the native input. */
|
|
71
|
+
export function blur() {
|
|
72
|
+
input?.blur();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The native input, once it is on the page. */
|
|
76
|
+
export function element(): HTMLInputElement | undefined {
|
|
77
|
+
return input;
|
|
78
|
+
}
|
|
39
79
|
</script>
|
|
40
80
|
|
|
41
81
|
<!-- TextField's box, so its part as well as its own. -->
|
|
42
|
-
<div
|
|
82
|
+
<div
|
|
83
|
+
{...rootAttributes(rest)}
|
|
84
|
+
class={classes("xds-text-field", rootPart("SearchField"), className)}
|
|
85
|
+
{style}
|
|
86
|
+
>
|
|
43
87
|
<div class="xds-text-field__control xds-text-field__control--pill xds-text-field__group">
|
|
44
88
|
<span class="xds-text-field__slot xds-text-field__slot--leading"
|
|
45
89
|
><Icon name="search" size="sm" /></span
|
|
@@ -54,36 +98,39 @@
|
|
|
54
98
|
aria-label={label}
|
|
55
99
|
enterkeyhint="search"
|
|
56
100
|
{placeholder}
|
|
57
|
-
{
|
|
58
|
-
defaultValue={
|
|
101
|
+
value={control.current}
|
|
102
|
+
defaultValue={control.controlled ? control.current : defaultValue}
|
|
103
|
+
readonly={readOnly}
|
|
59
104
|
{disabled}
|
|
60
|
-
data-uses-escape={
|
|
105
|
+
data-uses-escape={clearable ? "" : undefined}
|
|
61
106
|
oninput={(event) => {
|
|
62
|
-
|
|
107
|
+
control.set(event.currentTarget.value);
|
|
63
108
|
if (!(event instanceof InputEvent && event.isComposing))
|
|
64
|
-
keepValue(event.currentTarget, () =>
|
|
109
|
+
keepValue(event.currentTarget, () => control.current);
|
|
65
110
|
}}
|
|
66
|
-
oncompositionend={(event) => keepValue(event.currentTarget, () =>
|
|
111
|
+
oncompositionend={(event) => keepValue(event.currentTarget, () => control.current)}
|
|
67
112
|
onkeydown={(event) => {
|
|
68
113
|
// While a composition is open, Enter and Escape belong to the input method.
|
|
69
114
|
if (event.isComposing) return;
|
|
70
115
|
if (event.key === "Enter" && onSubmit) {
|
|
71
116
|
event.preventDefault();
|
|
72
|
-
onSubmit(
|
|
117
|
+
onSubmit(control.current);
|
|
73
118
|
}
|
|
74
|
-
if (event.key === "Escape" &&
|
|
119
|
+
if (event.key === "Escape" && clearable) {
|
|
75
120
|
event.stopPropagation();
|
|
76
|
-
|
|
121
|
+
control.set("");
|
|
77
122
|
}
|
|
78
123
|
}}
|
|
124
|
+
onfocus={onFocus}
|
|
125
|
+
onblur={onBlur}
|
|
79
126
|
/>
|
|
80
|
-
{#if
|
|
127
|
+
{#if clearable}
|
|
81
128
|
<span class="xds-text-field__slot xds-text-field__slot--trailing">
|
|
82
129
|
<button
|
|
83
130
|
type="button"
|
|
84
|
-
aria-label={clearLabel ??
|
|
131
|
+
aria-label={clearLabel ?? labels().clear}
|
|
85
132
|
onclick={() => {
|
|
86
|
-
|
|
133
|
+
control.set("");
|
|
87
134
|
// The control is about to disappear, and focus would be lost with it.
|
|
88
135
|
input?.focus();
|
|
89
136
|
}}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import type { SearchFieldBaseProps } from "@xds/core";
|
|
2
|
+
import type { FocusEventHandler } from "svelte/elements";
|
|
2
3
|
import type { RootProps } from "./root.js";
|
|
3
4
|
export type SearchFieldProps = SearchFieldBaseProps & RootProps & {
|
|
4
|
-
onChange
|
|
5
|
+
onChange?: (value: string) => void;
|
|
5
6
|
/** Called with the query on Enter, or on the search key of a software keyboard. */
|
|
6
7
|
onSubmit?: (value: string) => void;
|
|
8
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
9
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
7
10
|
};
|
|
8
11
|
/**
|
|
9
12
|
* A text field for a query: TextField's box as a pill, with a search icon in front and, while
|
|
10
|
-
* there is a value, a control that clears it. Escape clears too.
|
|
13
|
+
* there is a value, a control that clears it. Escape clears too. A read-only field has neither.
|
|
11
14
|
*
|
|
12
15
|
* Use it to filter or search what is on the screen. For a value that is saved with a form, use a
|
|
13
|
-
* TextField, which has a visible label.
|
|
16
|
+
* TextField, which has a visible label. Without `value` it keeps its own query, from
|
|
17
|
+
* `defaultValue`, and a reset of its form puts that back.
|
|
18
|
+
*
|
|
19
|
+
* `focus()`, `blur()` and `element()` on the instance reach the native input.
|
|
14
20
|
*/
|
|
15
|
-
declare const SearchField: import("svelte").Component<SearchFieldProps, {
|
|
21
|
+
declare const SearchField: import("svelte").Component<SearchFieldProps, {
|
|
22
|
+
focus: (options?: FocusOptions) => void;
|
|
23
|
+
blur: () => void;
|
|
24
|
+
element: () => HTMLInputElement | undefined;
|
|
25
|
+
}, "">;
|
|
16
26
|
type SearchField = ReturnType<typeof SearchField>;
|
|
17
27
|
export default SearchField;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<script lang="ts">
|
|
18
|
-
import { classes, rootPart, SECTION_HEADER_PARTS } from "@xds/core";
|
|
18
|
+
import { classes, rootAttributes, rootPart, SECTION_HEADER_PARTS } from "@xds/core";
|
|
19
19
|
import Button from "./Button.svelte";
|
|
20
20
|
import Icon from "./Icon.svelte";
|
|
21
21
|
|
|
@@ -27,10 +27,15 @@
|
|
|
27
27
|
action,
|
|
28
28
|
class: className,
|
|
29
29
|
style,
|
|
30
|
+
...rest
|
|
30
31
|
}: SectionHeaderProps = $props();
|
|
31
32
|
</script>
|
|
32
33
|
|
|
33
|
-
<div
|
|
34
|
+
<div
|
|
35
|
+
{...rootAttributes(rest)}
|
|
36
|
+
class={classes(rootPart("SectionHeader"), SECTION_HEADER_PARTS.root, className)}
|
|
37
|
+
{style}
|
|
38
|
+
>
|
|
34
39
|
<div class={SECTION_HEADER_PARTS.lead}>
|
|
35
40
|
{#if icon}
|
|
36
41
|
<span class={SECTION_HEADER_PARTS.icon}><Icon name={icon} size="md" /></span>
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
A choice between a few views or modes, all visible at once. The selected segment is outlined as
|
|
4
4
|
well as filled, so the choice does not depend on telling two greys apart.
|
|
5
5
|
|
|
6
|
-
It is a group of native radio buttons, so the arrow keys move between segments.
|
|
6
|
+
It is a group of native radio buttons, so the arrow keys move between segments. Without
|
|
7
|
+
`value` it keeps its own choice, from `defaultValue` or else the first segment.
|
|
7
8
|
-->
|
|
8
9
|
<script module lang="ts">
|
|
9
10
|
import type { SegmentedControlBaseProps } from "@xds/core";
|
|
@@ -11,35 +12,48 @@
|
|
|
11
12
|
|
|
12
13
|
export type SegmentedControlProps<Value extends string> = SegmentedControlBaseProps<Value> &
|
|
13
14
|
RootProps & {
|
|
14
|
-
onChange
|
|
15
|
+
onChange?: (value: Value) => void;
|
|
15
16
|
};
|
|
16
17
|
</script>
|
|
17
18
|
|
|
18
19
|
<script lang="ts" generics="Value extends string">
|
|
19
20
|
import {
|
|
20
21
|
classes,
|
|
22
|
+
rootAttributes,
|
|
21
23
|
rootPart,
|
|
22
24
|
segmentedControlClass,
|
|
23
25
|
segmentedControlOptionClass,
|
|
24
26
|
segmentedControlSegmentClass,
|
|
25
27
|
} from "@xds/core";
|
|
28
|
+
import { controllable } from "./controllable.svelte.js";
|
|
26
29
|
import { keepChecked } from "./controlled.js";
|
|
27
30
|
|
|
31
|
+
// `value` stays in the rest, where whether it is given at all can be asked.
|
|
28
32
|
let {
|
|
29
33
|
options,
|
|
30
|
-
|
|
34
|
+
defaultValue,
|
|
31
35
|
"aria-label": ariaLabel,
|
|
32
36
|
fullWidth,
|
|
33
37
|
onChange,
|
|
34
38
|
class: className,
|
|
35
39
|
style,
|
|
40
|
+
...rest
|
|
36
41
|
}: SegmentedControlProps<Value> = $props();
|
|
37
42
|
|
|
43
|
+
const control = controllable<Value | undefined, Value>(
|
|
44
|
+
() => rest,
|
|
45
|
+
"value",
|
|
46
|
+
() => rest.value,
|
|
47
|
+
() => defaultValue ?? options[0]?.value,
|
|
48
|
+
() => onChange,
|
|
49
|
+
);
|
|
50
|
+
|
|
38
51
|
const name = $props.id();
|
|
39
52
|
let group = $state<HTMLDivElement>();
|
|
40
53
|
</script>
|
|
41
54
|
|
|
42
55
|
<div
|
|
56
|
+
{...rootAttributes(rest)}
|
|
43
57
|
bind:this={group}
|
|
44
58
|
aria-label={ariaLabel}
|
|
45
59
|
role="radiogroup"
|
|
@@ -53,14 +67,14 @@
|
|
|
53
67
|
{name}
|
|
54
68
|
value={option.value}
|
|
55
69
|
class="peer sr-only"
|
|
56
|
-
checked={option.value ===
|
|
57
|
-
defaultChecked={option.value ===
|
|
70
|
+
checked={option.value === control.current}
|
|
71
|
+
defaultChecked={option.value === control.current}
|
|
58
72
|
onchange={() => {
|
|
59
|
-
|
|
73
|
+
control.set(option.value);
|
|
60
74
|
// The browser moved the dot already; where the owner kept the old value, it goes
|
|
61
75
|
// back, on every radio of the group.
|
|
62
76
|
for (const input of group?.querySelectorAll("input") ?? []) {
|
|
63
|
-
keepChecked(input, () => input.value ===
|
|
77
|
+
keepChecked(input, () => input.value === control.current);
|
|
64
78
|
}
|
|
65
79
|
}}
|
|
66
80
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SegmentedControlBaseProps } from "@xds/core";
|
|
2
2
|
import type { RootProps } from "./root.js";
|
|
3
3
|
export type SegmentedControlProps<Value extends string> = SegmentedControlBaseProps<Value> & RootProps & {
|
|
4
|
-
onChange
|
|
4
|
+
onChange?: (value: Value) => void;
|
|
5
5
|
};
|
|
6
6
|
declare function $$render<Value extends string>(): {
|
|
7
7
|
props: SegmentedControlProps<Value>;
|
|
@@ -28,7 +28,8 @@ interface $$IsomorphicComponent {
|
|
|
28
28
|
* A choice between a few views or modes, all visible at once. The selected segment is outlined as
|
|
29
29
|
* well as filled, so the choice does not depend on telling two greys apart.
|
|
30
30
|
*
|
|
31
|
-
* It is a group of native radio buttons, so the arrow keys move between segments.
|
|
31
|
+
* It is a group of native radio buttons, so the arrow keys move between segments. Without
|
|
32
|
+
* `value` it keeps its own choice, from `defaultValue` or else the first segment.
|
|
32
33
|
*/
|
|
33
34
|
declare const SegmentedControl: $$IsomorphicComponent;
|
|
34
35
|
type SegmentedControl<Value extends string> = InstanceType<typeof SegmentedControl<Value>>;
|
package/dist/Select.svelte
CHANGED
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
The field is a button that says it opens a list box and whether the list is open. In the list
|
|
9
9
|
the arrow keys move, typing jumps to an option, and Enter chooses. The chosen option is
|
|
10
|
-
selected for assistive technology and marked with a check.
|
|
10
|
+
selected for assistive technology and marked with a check. Without `value` it keeps its own
|
|
11
|
+
choice, from `defaultValue`.
|
|
12
|
+
|
|
13
|
+
With `multiple`, any number of options can be chosen: choosing one adds it or takes it away, the
|
|
14
|
+
list stays open, and `onValuesChange` gets them all. The list box says that several can be
|
|
15
|
+
chosen.
|
|
11
16
|
-->
|
|
12
17
|
<script module lang="ts">
|
|
13
18
|
import type { SelectBaseProps } from "@xds/core";
|
|
@@ -17,7 +22,9 @@
|
|
|
17
22
|
|
|
18
23
|
export type SelectProps<Value extends string = string> = SelectBaseProps<Value> &
|
|
19
24
|
RootProps & {
|
|
20
|
-
onChange
|
|
25
|
+
onChange?: (value: Value) => void;
|
|
26
|
+
/** Called with the chosen options of a select with `multiple`, in the options' order. */
|
|
27
|
+
onValuesChange?: (values: Value[]) => void;
|
|
21
28
|
};
|
|
22
29
|
</script>
|
|
23
30
|
|
|
@@ -25,15 +32,20 @@
|
|
|
25
32
|
import { space } from "@xds/tokens";
|
|
26
33
|
import {
|
|
27
34
|
classes,
|
|
35
|
+
createItemPropsCache,
|
|
28
36
|
keepListKeys,
|
|
37
|
+
orderedValues,
|
|
29
38
|
readCssPx,
|
|
39
|
+
rootAttributes,
|
|
30
40
|
type SelectOption,
|
|
41
|
+
selectedLabels,
|
|
31
42
|
selectOptionIds,
|
|
32
43
|
underlayLayerStyle,
|
|
33
44
|
} from "@xds/core";
|
|
34
45
|
import * as select from "@zag-js/select";
|
|
35
46
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
36
47
|
import type { HTMLAttributes, HTMLLabelAttributes } from "svelte/elements";
|
|
48
|
+
import { controllable } from "./controllable.svelte.js";
|
|
37
49
|
import Icon from "./Icon.svelte";
|
|
38
50
|
import { modalPopover } from "./modal-popover.svelte.js";
|
|
39
51
|
import Portal from "./Portal.svelte";
|
|
@@ -41,20 +53,42 @@
|
|
|
41
53
|
|
|
42
54
|
type KeyHandler = (event: KeyboardEvent) => void;
|
|
43
55
|
|
|
56
|
+
// `value` and `values` stay in the rest, where whether they are given at all can be asked.
|
|
44
57
|
let {
|
|
45
58
|
label,
|
|
46
59
|
options,
|
|
47
|
-
|
|
60
|
+
defaultValue,
|
|
48
61
|
placeholder,
|
|
49
62
|
description,
|
|
50
63
|
error,
|
|
51
64
|
name,
|
|
52
65
|
disabled,
|
|
53
66
|
onChange,
|
|
67
|
+
multiple = false,
|
|
68
|
+
defaultValues,
|
|
69
|
+
onValuesChange,
|
|
54
70
|
class: className,
|
|
55
71
|
style,
|
|
72
|
+
...rest
|
|
56
73
|
}: SelectProps<Value> = $props();
|
|
57
74
|
|
|
75
|
+
const control = controllable<Value | undefined, Value>(
|
|
76
|
+
() => rest,
|
|
77
|
+
"value",
|
|
78
|
+
() => rest.value,
|
|
79
|
+
() => defaultValue,
|
|
80
|
+
() => onChange,
|
|
81
|
+
);
|
|
82
|
+
const value = $derived(control.current);
|
|
83
|
+
const valuesControl = controllable<readonly Value[], Value[]>(
|
|
84
|
+
() => rest,
|
|
85
|
+
"values",
|
|
86
|
+
() => rest.values ?? [],
|
|
87
|
+
() => defaultValues ?? [],
|
|
88
|
+
() => onValuesChange,
|
|
89
|
+
);
|
|
90
|
+
const values = $derived(valuesControl.current);
|
|
91
|
+
|
|
58
92
|
const id = $props.id();
|
|
59
93
|
const valueId = `${id}-value`;
|
|
60
94
|
const descriptionId = `${id}-description`;
|
|
@@ -70,11 +104,18 @@
|
|
|
70
104
|
const service = useMachine(select.machine, () => ({
|
|
71
105
|
id,
|
|
72
106
|
collection,
|
|
73
|
-
value: value === undefined ? [] : [value],
|
|
107
|
+
value: multiple ? [...values] : value === undefined ? [] : [value],
|
|
74
108
|
onValueChange: (details: select.ValueChangeDetails<SelectOption<Value>>) => {
|
|
109
|
+
if (multiple) {
|
|
110
|
+
valuesControl.set(orderedValues(options, details.value as Value[]));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
75
113
|
const next = details.value[0];
|
|
76
|
-
if (next !== undefined)
|
|
114
|
+
if (next !== undefined) control.set(next as Value);
|
|
77
115
|
},
|
|
116
|
+
multiple,
|
|
117
|
+
// Several are chosen one after another, so the list stays until the person closes it.
|
|
118
|
+
closeOnSelect: !multiple,
|
|
78
119
|
disabled,
|
|
79
120
|
invalid,
|
|
80
121
|
name,
|
|
@@ -87,6 +128,9 @@
|
|
|
87
128
|
},
|
|
88
129
|
}));
|
|
89
130
|
const api = $derived(select.connect(service, normalizeProps));
|
|
131
|
+
// The rows' props as they last were while they draw the same, so that a step of the highlight
|
|
132
|
+
// sets the attributes and the handlers of the two rows it moves between, not of every row.
|
|
133
|
+
const keep = createItemPropsCache();
|
|
90
134
|
// Zag's key handlers read whether a search by typing is under way when the field renders, and
|
|
91
135
|
// a search ends on a timer, which renders nothing: long after a search, Space would still
|
|
92
136
|
// search for a space instead of opening the list or choosing. A handler taken from the
|
|
@@ -143,7 +187,13 @@
|
|
|
143
187
|
</script>
|
|
144
188
|
|
|
145
189
|
<!-- Merged, so that the app's style joins any the machine writes on the root. -->
|
|
146
|
-
<div
|
|
190
|
+
<div
|
|
191
|
+
{...mergeProps(api.getRootProps(), {
|
|
192
|
+
...rootAttributes(rest),
|
|
193
|
+
class: classes("xds-select", className),
|
|
194
|
+
style,
|
|
195
|
+
})}
|
|
196
|
+
>
|
|
147
197
|
<span {...labelProps} class="xds-select__label">{label}</span>
|
|
148
198
|
<button
|
|
149
199
|
{...triggerProps}
|
|
@@ -154,7 +204,7 @@
|
|
|
154
204
|
<!-- The chosen option's label alone: the list's rows also hold a description and a check,
|
|
155
205
|
which do not belong in the field. -->
|
|
156
206
|
<span {...api.getValueTextProps()} id={valueId} class="xds-select__value"
|
|
157
|
-
>{api.valueAsString || placeholder}</span
|
|
207
|
+
>{(multiple ? selectedLabels(options, values) : api.valueAsString) || placeholder}</span
|
|
158
208
|
>
|
|
159
209
|
<Icon name="chevrons-up-down" size="sm" class="text-xds-field-placeholder" />
|
|
160
210
|
</button>
|
|
@@ -166,10 +216,12 @@
|
|
|
166
216
|
{/if}
|
|
167
217
|
<span id={errorId} class="xds-select__error" aria-live="polite">{error}</span>
|
|
168
218
|
</div>
|
|
169
|
-
<!-- What a form submits; the first option stands for no choice. Zag's props
|
|
170
|
-
from assistive technology, which uses the trigger. -->
|
|
219
|
+
<!-- What a form submits; in a select of one, the first option stands for no choice. Zag's props
|
|
220
|
+
hide the select from assistive technology, which uses the trigger. -->
|
|
171
221
|
<select {...api.getHiddenSelectProps()}>
|
|
172
|
-
|
|
222
|
+
{#if !multiple}
|
|
223
|
+
<option value=""></option>
|
|
224
|
+
{/if}
|
|
173
225
|
{#each options as option (option.value)}
|
|
174
226
|
<option value={option.value}>{option.label}</option>
|
|
175
227
|
{/each}
|
|
@@ -193,14 +245,14 @@
|
|
|
193
245
|
{@const ids = selectOptionIds(id, index)}
|
|
194
246
|
<!-- Named by its label alone, as the field shows it; the help line describes it. -->
|
|
195
247
|
<div
|
|
196
|
-
{...api.getItemProps({ item: option })}
|
|
248
|
+
{...keep(`item:${option.value}`, api.getItemProps({ item: option }))}
|
|
197
249
|
aria-labelledby={ids.label}
|
|
198
250
|
aria-describedby={option.description ? ids.description : undefined}
|
|
199
251
|
class="xds-select__item"
|
|
200
252
|
>
|
|
201
253
|
<span class="xds-select__item-words">
|
|
202
254
|
<span
|
|
203
|
-
{...api.getItemTextProps({ item: option })}
|
|
255
|
+
{...keep(`text:${option.value}`, api.getItemTextProps({ item: option }))}
|
|
204
256
|
id={ids.label}
|
|
205
257
|
class="xds-select__item-label">{option.label}</span
|
|
206
258
|
>
|
package/dist/Select.svelte.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import type { SelectBaseProps } from "@xds/core";
|
|
|
2
2
|
import type { RootProps } from "./root.js";
|
|
3
3
|
export type { SelectOption } from "@xds/core";
|
|
4
4
|
export type SelectProps<Value extends string = string> = SelectBaseProps<Value> & RootProps & {
|
|
5
|
-
onChange
|
|
5
|
+
onChange?: (value: Value) => void;
|
|
6
|
+
/** Called with the chosen options of a select with `multiple`, in the options' order. */
|
|
7
|
+
onValuesChange?: (values: Value[]) => void;
|
|
6
8
|
};
|
|
7
9
|
declare function $$render<Value extends string = string>(): {
|
|
8
10
|
props: SelectProps<Value>;
|
|
@@ -33,7 +35,12 @@ interface $$IsomorphicComponent {
|
|
|
33
35
|
*
|
|
34
36
|
* The field is a button that says it opens a list box and whether the list is open. In the list
|
|
35
37
|
* the arrow keys move, typing jumps to an option, and Enter chooses. The chosen option is
|
|
36
|
-
* selected for assistive technology and marked with a check.
|
|
38
|
+
* selected for assistive technology and marked with a check. Without `value` it keeps its own
|
|
39
|
+
* choice, from `defaultValue`.
|
|
40
|
+
*
|
|
41
|
+
* With `multiple`, any number of options can be chosen: choosing one adds it or takes it away, the
|
|
42
|
+
* list stays open, and `onValuesChange` gets them all. The list box says that several can be
|
|
43
|
+
* chosen.
|
|
37
44
|
*/
|
|
38
45
|
declare const Select: $$IsomorphicComponent;
|
|
39
46
|
type Select<Value extends string = string> = InstanceType<typeof Select<Value>>;
|
package/dist/Sidebar.svelte
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
<script lang="ts" generics="Value extends string = string">
|
|
28
28
|
import {
|
|
29
29
|
classes,
|
|
30
|
+
rootAttributes,
|
|
30
31
|
rootPart,
|
|
31
32
|
SIDEBAR_PARTS,
|
|
32
33
|
sidebarClass,
|
|
@@ -51,12 +52,14 @@
|
|
|
51
52
|
footer,
|
|
52
53
|
class: className,
|
|
53
54
|
style,
|
|
55
|
+
...rest
|
|
54
56
|
}: SidebarProps<Value> = $props();
|
|
55
57
|
|
|
56
58
|
const id = $props.id();
|
|
57
59
|
</script>
|
|
58
60
|
|
|
59
61
|
<nav
|
|
62
|
+
{...rootAttributes(rest)}
|
|
60
63
|
aria-label={label}
|
|
61
64
|
class={classes(rootPart("Sidebar"), sidebarClass(collapsed), className)}
|
|
62
65
|
{style}
|
package/dist/Skeleton.svelte
CHANGED
|
@@ -14,10 +14,17 @@
|
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<script lang="ts">
|
|
17
|
-
import { classes, rootPart, skeletonClass, skeletonSize } from "@xds/core";
|
|
17
|
+
import { classes, rootAttributes, rootPart, skeletonClass, skeletonSize } from "@xds/core";
|
|
18
18
|
import { useDefaults } from "./defaults.svelte.js";
|
|
19
19
|
|
|
20
|
-
let {
|
|
20
|
+
let {
|
|
21
|
+
shape: ownShape,
|
|
22
|
+
width,
|
|
23
|
+
height,
|
|
24
|
+
class: className,
|
|
25
|
+
style,
|
|
26
|
+
...rest
|
|
27
|
+
}: SkeletonProps = $props();
|
|
21
28
|
|
|
22
29
|
const defaults = useDefaults("Skeleton");
|
|
23
30
|
const shape = $derived(ownShape ?? defaults().shape);
|
|
@@ -36,6 +43,7 @@
|
|
|
36
43
|
</script>
|
|
37
44
|
|
|
38
45
|
<span
|
|
46
|
+
{...rootAttributes(rest)}
|
|
39
47
|
aria-hidden="true"
|
|
40
48
|
class={classes(rootPart("Skeleton"), skeletonClass(shape), className)}
|
|
41
49
|
style={combinedStyle || undefined}
|
package/dist/Slider.svelte
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
The values snap to `step`.
|
|
5
5
|
|
|
6
6
|
It is a slider named by its label with its value, minimum and maximum, and each arrow key moves
|
|
7
|
-
it one step.
|
|
7
|
+
it one step. Without `value` it keeps its own, from `defaultValue` or else `min`.
|
|
8
8
|
-->
|
|
9
9
|
<script module lang="ts">
|
|
10
10
|
import type { SliderBaseProps } from "@xds/core";
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
export type SliderProps = SliderBaseProps &
|
|
14
14
|
RootProps & {
|
|
15
|
-
onChange
|
|
15
|
+
onChange?: (value: number) => void;
|
|
16
16
|
};
|
|
17
17
|
</script>
|
|
18
18
|
|
|
@@ -20,16 +20,19 @@
|
|
|
20
20
|
import {
|
|
21
21
|
classes,
|
|
22
22
|
focusThumbOnPress,
|
|
23
|
+
rootAttributes,
|
|
23
24
|
sliderArrowValue,
|
|
24
25
|
sliderPageSize,
|
|
25
26
|
sliderValueText,
|
|
26
27
|
} from "@xds/core";
|
|
27
28
|
import * as slider from "@zag-js/slider";
|
|
28
29
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
30
|
+
import { controllable } from "./controllable.svelte.js";
|
|
29
31
|
|
|
32
|
+
// `value` stays in the rest, where whether it is given at all can be asked.
|
|
30
33
|
let {
|
|
31
34
|
label,
|
|
32
|
-
|
|
35
|
+
defaultValue,
|
|
33
36
|
min = 0,
|
|
34
37
|
max = 100,
|
|
35
38
|
step = 1,
|
|
@@ -40,16 +43,25 @@
|
|
|
40
43
|
onChange,
|
|
41
44
|
class: className,
|
|
42
45
|
style,
|
|
46
|
+
...rest
|
|
43
47
|
}: SliderProps = $props();
|
|
44
48
|
|
|
49
|
+
const position = controllable(
|
|
50
|
+
() => rest,
|
|
51
|
+
"value",
|
|
52
|
+
() => rest.value ?? min,
|
|
53
|
+
() => defaultValue ?? min,
|
|
54
|
+
() => onChange,
|
|
55
|
+
);
|
|
56
|
+
|
|
45
57
|
const id = $props.id();
|
|
46
58
|
const pageSize = $derived(sliderPageSize({ min, max, step }));
|
|
47
59
|
const service = useMachine(slider.machine, () => ({
|
|
48
60
|
id,
|
|
49
61
|
name,
|
|
50
|
-
value: [
|
|
62
|
+
value: [position.current],
|
|
51
63
|
// One thumb, so one number.
|
|
52
|
-
onValueChange: (details: slider.ValueChangeDetails) =>
|
|
64
|
+
onValueChange: (details: slider.ValueChangeDetails) => position.set(details.value[0] ?? min),
|
|
53
65
|
min,
|
|
54
66
|
max,
|
|
55
67
|
step,
|
|
@@ -94,7 +106,11 @@
|
|
|
94
106
|
that is for a set of fields, and this is one slider and its label. The app's style is merged
|
|
95
107
|
with the one the machine writes on the root. -->
|
|
96
108
|
<div
|
|
97
|
-
{...mergeProps(api.getRootProps(), {
|
|
109
|
+
{...mergeProps(api.getRootProps(), {
|
|
110
|
+
...rootAttributes(rest),
|
|
111
|
+
class: classes("xds-slider", className),
|
|
112
|
+
style,
|
|
113
|
+
})}
|
|
98
114
|
role="group"
|
|
99
115
|
aria-labelledby={api.getLabelProps().id}
|
|
100
116
|
>
|
|
@@ -103,7 +119,7 @@
|
|
|
103
119
|
{#if showValue}
|
|
104
120
|
<!-- Read when asked for, not at every step: the slider itself announces its value. -->
|
|
105
121
|
<output {...api.getValueTextProps()} aria-live="off" class="xds-slider__output"
|
|
106
|
-
>{sliderValueText(api.value[0] ??
|
|
122
|
+
>{sliderValueText(api.value[0] ?? position.current, locale)}</output
|
|
107
123
|
>
|
|
108
124
|
{/if}
|
|
109
125
|
<div {...control} class="xds-slider__control">
|