@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
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
A field for choosing a time of day. Closed, it looks like a Select with a clock: the chosen time
|
|
8
|
+
on the locale's own clock ("9:30 AM", "09:30"). Pressed, it opens the times from `min` to `max`,
|
|
9
|
+
`step` minutes apart, under itself, with the chosen one in view; choosing one calls `onChange`
|
|
10
|
+
with it as `HH:MM` and closes the list.
|
|
11
|
+
|
|
12
|
+
The field is a button that says it opens a list box, as a Select's does: the arrow keys move,
|
|
13
|
+
typing the hour jumps to it, and Enter chooses. Without `value` it keeps its own choice, from
|
|
14
|
+
`defaultValue`.
|
|
15
|
+
-->
|
|
16
|
+
<script module lang="ts">
|
|
17
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
18
|
+
import type { IsoTime, TimePickerBaseProps } from "./time-picker.ts";
|
|
19
|
+
|
|
20
|
+
export type { IsoTime } from "./time-picker.ts";
|
|
21
|
+
|
|
22
|
+
export type TimePickerProps = TimePickerBaseProps &
|
|
23
|
+
RootProps & {
|
|
24
|
+
/** Called with the chosen time, as `HH:MM` on a 24-hour clock. */
|
|
25
|
+
onChange?: (value: IsoTime) => void;
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
import {
|
|
31
|
+
controllable,
|
|
32
|
+
createItemPropsCache,
|
|
33
|
+
createPresence,
|
|
34
|
+
followFormReset,
|
|
35
|
+
keepListKeys,
|
|
36
|
+
modalPopover,
|
|
37
|
+
Portal,
|
|
38
|
+
readCssPx,
|
|
39
|
+
rootAttributes,
|
|
40
|
+
space,
|
|
41
|
+
underlayLayerStyle,
|
|
42
|
+
} from "@xds/svelte/base";
|
|
43
|
+
import * as select from "@zag-js/select";
|
|
44
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
45
|
+
import type { HTMLAttributes, HTMLLabelAttributes } from "svelte/elements";
|
|
46
|
+
import Icon from "./Icon.svelte";
|
|
47
|
+
import { classes } from "./parts.ts";
|
|
48
|
+
import type { SelectOption } from "./select.ts";
|
|
49
|
+
import { timeOptions, timePickerIds, timePickerLocale } from "./time-picker.ts";
|
|
50
|
+
|
|
51
|
+
type KeyHandler = (event: KeyboardEvent) => void;
|
|
52
|
+
|
|
53
|
+
// `value` stays in the rest, where whether it is given at all can be asked.
|
|
54
|
+
let {
|
|
55
|
+
label,
|
|
56
|
+
defaultValue,
|
|
57
|
+
min,
|
|
58
|
+
max,
|
|
59
|
+
step,
|
|
60
|
+
placeholder,
|
|
61
|
+
description,
|
|
62
|
+
error,
|
|
63
|
+
name,
|
|
64
|
+
disabled,
|
|
65
|
+
locale,
|
|
66
|
+
onChange,
|
|
67
|
+
class: className,
|
|
68
|
+
style,
|
|
69
|
+
...rest
|
|
70
|
+
}: TimePickerProps = $props();
|
|
71
|
+
|
|
72
|
+
const control = controllable<IsoTime | undefined, IsoTime>(
|
|
73
|
+
() => rest,
|
|
74
|
+
"value",
|
|
75
|
+
() => rest.value,
|
|
76
|
+
() => defaultValue,
|
|
77
|
+
() => onChange,
|
|
78
|
+
);
|
|
79
|
+
const value = $derived(control.current);
|
|
80
|
+
let root = $state<HTMLDivElement>();
|
|
81
|
+
followFormReset(() => root, control);
|
|
82
|
+
|
|
83
|
+
const id = $props.id();
|
|
84
|
+
const ids = timePickerIds(id);
|
|
85
|
+
const invalid = $derived(error !== undefined);
|
|
86
|
+
const options = $derived(timeOptions({ min, max, step, value }, timePickerLocale(locale)));
|
|
87
|
+
const collection = $derived(
|
|
88
|
+
select.collection<SelectOption<IsoTime>>({
|
|
89
|
+
items: options,
|
|
90
|
+
itemToValue: (option) => option.value,
|
|
91
|
+
itemToString: (option) => option.label,
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
const service = useMachine(select.machine, () => ({
|
|
95
|
+
id,
|
|
96
|
+
collection,
|
|
97
|
+
value: value === undefined ? [] : [value],
|
|
98
|
+
onValueChange: (details: select.ValueChangeDetails<SelectOption<IsoTime>>) => {
|
|
99
|
+
const next = details.value[0];
|
|
100
|
+
if (next !== undefined) control.set(next);
|
|
101
|
+
},
|
|
102
|
+
disabled,
|
|
103
|
+
invalid,
|
|
104
|
+
positioning: {
|
|
105
|
+
placement: "bottom-start" as const,
|
|
106
|
+
gutter: readCssPx(null, "--xds-space-1", space[1]),
|
|
107
|
+
sameWidth: true,
|
|
108
|
+
overflowPadding: readCssPx(null, "--xds-space-3", space[3]),
|
|
109
|
+
},
|
|
110
|
+
}));
|
|
111
|
+
const api = $derived(select.connect(service, normalizeProps));
|
|
112
|
+
// The rows' props as they last were while they draw the same, so that a step of the highlight
|
|
113
|
+
// sets the attributes and the handlers of the two rows it moves between, not of every row.
|
|
114
|
+
const keep = createItemPropsCache();
|
|
115
|
+
// As in Select: a handler taken from the machine when the key comes reads whether a search by
|
|
116
|
+
// typing is still under way.
|
|
117
|
+
const current = () => select.connect(service, normalizeProps);
|
|
118
|
+
// A span: the field is a button, which a <label> cannot point at.
|
|
119
|
+
const labelProps = $derived.by(() => {
|
|
120
|
+
const { for: _, ...rest } = api.getLabelProps() as HTMLLabelAttributes;
|
|
121
|
+
return rest as HTMLAttributes<HTMLSpanElement>;
|
|
122
|
+
});
|
|
123
|
+
const triggerProps = $derived.by(() => {
|
|
124
|
+
const {
|
|
125
|
+
role: _role,
|
|
126
|
+
"aria-invalid": _invalid,
|
|
127
|
+
"aria-required": _required,
|
|
128
|
+
onkeydown: _onKeyDown,
|
|
129
|
+
...rest
|
|
130
|
+
} = api.getTriggerProps();
|
|
131
|
+
return {
|
|
132
|
+
...rest,
|
|
133
|
+
onkeydown: (event: KeyboardEvent) => {
|
|
134
|
+
if (!api.open && (event.key === "Home" || event.key === "End")) return;
|
|
135
|
+
(current().getTriggerProps().onkeydown as KeyHandler | undefined)?.(event);
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
let positioner = $state<HTMLDivElement>();
|
|
140
|
+
let surface = $state<HTMLDivElement>();
|
|
141
|
+
modalPopover(
|
|
142
|
+
() => api.open,
|
|
143
|
+
() => positioner,
|
|
144
|
+
);
|
|
145
|
+
const present = createPresence(
|
|
146
|
+
() => api.open,
|
|
147
|
+
() => [surface],
|
|
148
|
+
);
|
|
149
|
+
const content = $derived.by(() => {
|
|
150
|
+
const { onkeydown: _onKeyDown, ...rest } = api.getContentProps();
|
|
151
|
+
return mergeProps(rest, {
|
|
152
|
+
onkeydown: (event: KeyboardEvent) => {
|
|
153
|
+
keepListKeys(
|
|
154
|
+
event,
|
|
155
|
+
surface,
|
|
156
|
+
".{{prefix}}-time-picker__item:not([data-disabled])",
|
|
157
|
+
(value) => api.setHighlightedValue(value),
|
|
158
|
+
);
|
|
159
|
+
(current().getContentProps().onkeydown as KeyHandler | undefined)?.(event);
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
</script>
|
|
164
|
+
|
|
165
|
+
<!-- Merged, so that the app's style joins any the machine writes on the root. -->
|
|
166
|
+
<div
|
|
167
|
+
bind:this={root}
|
|
168
|
+
{...mergeProps(api.getRootProps(), {
|
|
169
|
+
...rootAttributes(rest),
|
|
170
|
+
class: classes("{{prefix}}-time-picker", className),
|
|
171
|
+
style,
|
|
172
|
+
})}
|
|
173
|
+
>
|
|
174
|
+
<span {...labelProps} class="{{prefix}}-time-picker__label">{label}</span>
|
|
175
|
+
<button
|
|
176
|
+
{...triggerProps}
|
|
177
|
+
aria-labelledby={`${ids.value} ${labelProps.id}`}
|
|
178
|
+
aria-describedby={invalid ? ids.error : description ? ids.description : undefined}
|
|
179
|
+
class="{{prefix}}-time-picker__trigger"
|
|
180
|
+
>
|
|
181
|
+
<span {...api.getValueTextProps()} id={ids.value} class="{{prefix}}-time-picker__value"
|
|
182
|
+
>{api.valueAsString || placeholder}</span
|
|
183
|
+
>
|
|
184
|
+
<Icon name="clock" size="sm" class="text-xds-field-placeholder" />
|
|
185
|
+
</button>
|
|
186
|
+
<div class="{{prefix}}-time-picker__footer">
|
|
187
|
+
{#if !invalid && description}
|
|
188
|
+
<span id={ids.description} class="{{prefix}}-time-picker__description">{description}</span>
|
|
189
|
+
{/if}
|
|
190
|
+
<span id={ids.error} class="{{prefix}}-time-picker__error" aria-live="polite">{error}</span>
|
|
191
|
+
</div>
|
|
192
|
+
<!-- What a form submits: the time as HH:MM, where the field shows it on the locale's clock. -->
|
|
193
|
+
{#if name !== undefined}
|
|
194
|
+
<input type="hidden" {name} value={value ?? ""} />
|
|
195
|
+
{/if}
|
|
196
|
+
<Portal>
|
|
197
|
+
{#if api.open}
|
|
198
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
199
|
+
<div
|
|
200
|
+
class="{{prefix}}-time-picker__underlay"
|
|
201
|
+
style:--layer-index={underlayLayerStyle(api.getPositionerProps().style)?.["--layer-index"]}
|
|
202
|
+
onmousedown={(event) => event.preventDefault()}
|
|
203
|
+
></div>
|
|
204
|
+
{/if}
|
|
205
|
+
<div
|
|
206
|
+
{...api.getPositionerProps()}
|
|
207
|
+
bind:this={positioner}
|
|
208
|
+
class="{{prefix}}-time-picker__positioner"
|
|
209
|
+
>
|
|
210
|
+
<div
|
|
211
|
+
{...content}
|
|
212
|
+
bind:this={surface}
|
|
213
|
+
hidden={!present()}
|
|
214
|
+
class="{{prefix}}-time-picker__content"
|
|
215
|
+
>
|
|
216
|
+
<div {...api.getListProps()} class="{{prefix}}-time-picker__list">
|
|
217
|
+
{#each collection.items as option (option.value)}
|
|
218
|
+
<div
|
|
219
|
+
{...keep(`item:${option.value}`, api.getItemProps({ item: option }))}
|
|
220
|
+
class="{{prefix}}-time-picker__item"
|
|
221
|
+
>
|
|
222
|
+
<span class="{{prefix}}-time-picker__item-words">
|
|
223
|
+
<span
|
|
224
|
+
{...keep(`text:${option.value}`, api.getItemTextProps({ item: option }))}
|
|
225
|
+
class="{{prefix}}-time-picker__item-label">{option.label}</span
|
|
226
|
+
>
|
|
227
|
+
</span>
|
|
228
|
+
{#if api.getItemState({ item: option }).selected}
|
|
229
|
+
<Icon name="check" size="sm" />
|
|
230
|
+
{/if}
|
|
231
|
+
</div>
|
|
232
|
+
{/each}
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
</Portal>
|
|
237
|
+
</div>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
A short message about what just happened, which leaves on its own. It sits at the bottom center
|
|
8
|
+
of the window, above everything else, and is announced politely without taking focus. The time
|
|
9
|
+
does not run while the pointer is over it or focus is inside it.
|
|
10
|
+
|
|
11
|
+
Do not put the only way to do something in a toast: it is gone in a few seconds.
|
|
12
|
+
-->
|
|
13
|
+
<script module lang="ts">
|
|
14
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
15
|
+
import type { ToastBaseProps } from "./toast.ts";
|
|
16
|
+
|
|
17
|
+
/** Its root is the toast, while it is open, not the region it appears in. */
|
|
18
|
+
export type ToastProps = ToastBaseProps &
|
|
19
|
+
RootProps & {
|
|
20
|
+
/** Called when the time is up and after the action. Set `open` to false in it. */
|
|
21
|
+
onClose: () => void;
|
|
22
|
+
};
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<script lang="ts">
|
|
26
|
+
import { motion, readCssMs, rootAttributes } from "@xds/svelte/base";
|
|
27
|
+
import type { Attachment } from "svelte/attachments";
|
|
28
|
+
import { classes, rootPart } from "./parts.ts";
|
|
29
|
+
import { TOAST_PARTS } from "./toast.ts";
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
open,
|
|
33
|
+
message,
|
|
34
|
+
action,
|
|
35
|
+
duration,
|
|
36
|
+
onClose,
|
|
37
|
+
class: className,
|
|
38
|
+
style,
|
|
39
|
+
...rest
|
|
40
|
+
}: ToastProps = $props();
|
|
41
|
+
|
|
42
|
+
let regionElement = $state<HTMLDivElement>();
|
|
43
|
+
// The toast the pointer is over and the one focus is in. A toast that closed under the pointer
|
|
44
|
+
// gets no event to say that the pointer left, so only one still in the page counts.
|
|
45
|
+
let hovered = $state<Element>();
|
|
46
|
+
let focused = $state<Element>();
|
|
47
|
+
const inPage = (toast: Element | undefined) => toast?.isConnected === true;
|
|
48
|
+
|
|
49
|
+
// The region is in the top layer for as long as the component is mounted, empty or not: a
|
|
50
|
+
// screen reader only announces what is added to a region it already knows.
|
|
51
|
+
const showRegion: Attachment<HTMLDivElement> = (region) => {
|
|
52
|
+
regionElement = region;
|
|
53
|
+
if (!region.showPopover) return;
|
|
54
|
+
region.showPopover();
|
|
55
|
+
return () => {
|
|
56
|
+
if (region.isConnected && region.matches(":popover-open")) region.hidePopover();
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
$effect(() => {
|
|
61
|
+
// Touch `message` so a replacement toast restarts the timer.
|
|
62
|
+
void message;
|
|
63
|
+
const ms =
|
|
64
|
+
duration ?? readCssMs(regionElement, "--xds-motion-duration-toast", motion.duration.toast);
|
|
65
|
+
if (!open || inPage(hovered) || inPage(focused) || ms <= 0) return;
|
|
66
|
+
// `onClose` is read when the time is up, so a new function does not restart it.
|
|
67
|
+
const timer = setTimeout(() => onClose(), ms);
|
|
68
|
+
return () => clearTimeout(timer);
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<div {@attach showRegion} role="status" popover="manual" class={TOAST_PARTS.region}>
|
|
73
|
+
{#if open}
|
|
74
|
+
<!-- Hover and focus only pause the timer; the action inside is a real button. -->
|
|
75
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
76
|
+
<div
|
|
77
|
+
{...rootAttributes(rest)}
|
|
78
|
+
onpointerenter={(event) => (hovered = event.currentTarget)}
|
|
79
|
+
onpointerleave={() => (hovered = undefined)}
|
|
80
|
+
onfocusin={(event) => (focused = event.currentTarget)}
|
|
81
|
+
onfocusout={() => (focused = undefined)}
|
|
82
|
+
class={classes(rootPart("Toast"), TOAST_PARTS.toast, className)}
|
|
83
|
+
{style}
|
|
84
|
+
>
|
|
85
|
+
<span class={TOAST_PARTS.message}>{message}</span>
|
|
86
|
+
{#if action}
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
onclick={() => {
|
|
90
|
+
action.onPress();
|
|
91
|
+
onClose();
|
|
92
|
+
}}
|
|
93
|
+
class={TOAST_PARTS.action}>{action.label}</button
|
|
94
|
+
>
|
|
95
|
+
{/if}
|
|
96
|
+
</div>
|
|
97
|
+
{/if}
|
|
98
|
+
</div>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
Shows the app's toasts one at a time, in their order: the first of `toasts`, which stays for its
|
|
8
|
+
own `duration` or until its action is taken, and then the next, `motion.duration.normal` after the
|
|
9
|
+
one before has gone, so that each is read and announced as a message of its own. Add a toast
|
|
10
|
+
with `queueToast`, which keeps at most three waiting, and take one out in `onClose`. Put one
|
|
11
|
+
where a single Toast would go.
|
|
12
|
+
-->
|
|
13
|
+
<script module lang="ts">
|
|
14
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
15
|
+
import type { QueuedToast, ToastQueueBaseProps } from "./toast-queue.ts";
|
|
16
|
+
|
|
17
|
+
/** `class`, `style`, `id` and `data-*` go on the toast shown, as Toast takes them. */
|
|
18
|
+
export type ToastQueueProps = ToastQueueBaseProps &
|
|
19
|
+
RootProps & {
|
|
20
|
+
/**
|
|
21
|
+
* Called with a toast's id when its time is up or its action was taken. Take it out of
|
|
22
|
+
* `toasts` in it.
|
|
23
|
+
*/
|
|
24
|
+
onClose: (id: QueuedToast["id"]) => void;
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<script lang="ts">
|
|
29
|
+
import { motion, readCssMs } from "@xds/svelte/base";
|
|
30
|
+
import { toastQueueStep } from "./toast-queue.ts";
|
|
31
|
+
import Toast from "./Toast.svelte";
|
|
32
|
+
|
|
33
|
+
let { toasts, onClose, ...root }: ToastQueueProps = $props();
|
|
34
|
+
|
|
35
|
+
let visible = $state<QueuedToast["id"]>();
|
|
36
|
+
const step = $derived(toastQueueStep(toasts, visible));
|
|
37
|
+
const shown = $derived(step === "keep" ? toasts[0] : undefined);
|
|
38
|
+
|
|
39
|
+
$effect(() => {
|
|
40
|
+
const first = toasts[0];
|
|
41
|
+
if (step === "close") {
|
|
42
|
+
visible = undefined;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (step !== "wait" || first === undefined) return;
|
|
46
|
+
const gap = readCssMs(null, "--xds-motion-duration-normal", motion.duration.normal);
|
|
47
|
+
const timer = setTimeout(() => (visible = first.id), gap);
|
|
48
|
+
return () => clearTimeout(timer);
|
|
49
|
+
});
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<Toast
|
|
53
|
+
{...root}
|
|
54
|
+
open={shown !== undefined}
|
|
55
|
+
message={shown?.message ?? ""}
|
|
56
|
+
action={shown?.action}
|
|
57
|
+
duration={shown?.duration}
|
|
58
|
+
onClose={() => {
|
|
59
|
+
if (shown !== undefined) onClose(shown.id);
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
Names a control when the pointer rests on it or the keyboard focuses it. It appears after a
|
|
8
|
+
short wait under a pointer and at once on keyboard focus, and goes when the pointer leaves,
|
|
9
|
+
focus leaves, or Escape is pressed.
|
|
10
|
+
|
|
11
|
+
It describes the control and is not its name: an IconButton still needs its `label`. It never
|
|
12
|
+
holds anything pressable, and touch input has no hover, so nothing may depend on it.
|
|
13
|
+
-->
|
|
14
|
+
<script module lang="ts">
|
|
15
|
+
import type { RootProps } from "@xds/svelte/base";
|
|
16
|
+
import type { Snippet } from "svelte";
|
|
17
|
+
import type { TooltipBaseProps } from "./tooltip.ts";
|
|
18
|
+
|
|
19
|
+
/** Its root is the tooltip, while it shows, not the control it describes. */
|
|
20
|
+
export type TooltipProps = TooltipBaseProps &
|
|
21
|
+
RootProps & {
|
|
22
|
+
/** The control it describes: a Button or an IconButton. */
|
|
23
|
+
children: Snippet;
|
|
24
|
+
};
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
import { rootAttributes } from "@xds/svelte/base";
|
|
29
|
+
import TooltipOverlay from "./TooltipOverlay.svelte";
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
label,
|
|
33
|
+
shortcut,
|
|
34
|
+
placement = "top",
|
|
35
|
+
class: className,
|
|
36
|
+
style,
|
|
37
|
+
children,
|
|
38
|
+
...rest
|
|
39
|
+
}: TooltipProps = $props();
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<!-- The overlay gives the root part, `{{prefix}}-tooltip`, to every tooltip, a collapsed Sidebar's
|
|
43
|
+
too. -->
|
|
44
|
+
<TooltipOverlay
|
|
45
|
+
{...rootAttributes(rest)}
|
|
46
|
+
{label}
|
|
47
|
+
{shortcut}
|
|
48
|
+
placement={() => placement}
|
|
49
|
+
class={className}
|
|
50
|
+
{style}>{@render children()}</TooltipOverlay
|
|
51
|
+
>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
-->
|
|
5
|
+
<!--
|
|
6
|
+
@component
|
|
7
|
+
What Tooltip draws, at the placement it is given: a collapsed Sidebar names its icons at the
|
|
8
|
+
end edge, on the side of the content, where they do not cover their neighbours. Only for this
|
|
9
|
+
package's own components: the index does not export it.
|
|
10
|
+
-->
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import {
|
|
13
|
+
createPresence,
|
|
14
|
+
motion,
|
|
15
|
+
Portal,
|
|
16
|
+
provideTrigger,
|
|
17
|
+
type RootProps,
|
|
18
|
+
readCssMs,
|
|
19
|
+
readCssPx,
|
|
20
|
+
rootAttributes,
|
|
21
|
+
space,
|
|
22
|
+
type TriggerProps,
|
|
23
|
+
} from "@xds/svelte/base";
|
|
24
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/svelte";
|
|
25
|
+
import * as tooltip from "@zag-js/tooltip";
|
|
26
|
+
import type { Snippet } from "svelte";
|
|
27
|
+
import { classes } from "./parts.ts";
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
label,
|
|
31
|
+
shortcut,
|
|
32
|
+
placement,
|
|
33
|
+
class: className,
|
|
34
|
+
style,
|
|
35
|
+
children,
|
|
36
|
+
...rest
|
|
37
|
+
}: RootProps & {
|
|
38
|
+
label: string;
|
|
39
|
+
shortcut?: string | undefined;
|
|
40
|
+
placement: () => tooltip.Placement;
|
|
41
|
+
children: Snippet;
|
|
42
|
+
} = $props();
|
|
43
|
+
|
|
44
|
+
const id = $props.id();
|
|
45
|
+
const service = useMachine(tooltip.machine, () => ({
|
|
46
|
+
id,
|
|
47
|
+
// The app's id names the tooltip, and the control's aria-describedby points there.
|
|
48
|
+
ids: rest.id === undefined ? undefined : { content: rest.id },
|
|
49
|
+
openDelay: readCssMs(
|
|
50
|
+
null,
|
|
51
|
+
"--xds-motion-duration-tooltip-delay",
|
|
52
|
+
motion.duration.tooltipDelay,
|
|
53
|
+
),
|
|
54
|
+
closeDelay: 0,
|
|
55
|
+
// It stays and follows its control when the page scrolls, for as long as the control keeps
|
|
56
|
+
// focus or the pointer. Tabbing to a control out of view scrolls the page, and a tooltip
|
|
57
|
+
// closed by that scroll would never show for it.
|
|
58
|
+
closeOnScroll: false,
|
|
59
|
+
positioning: { placement: placement(), gutter: readCssPx(null, "--xds-space-1", space[1]) },
|
|
60
|
+
}));
|
|
61
|
+
const api = $derived(tooltip.connect(service, normalizeProps));
|
|
62
|
+
provideTrigger(() => api.getTriggerProps() as TriggerProps);
|
|
63
|
+
let content = $state<HTMLDivElement>();
|
|
64
|
+
const present = createPresence(
|
|
65
|
+
() => api.open,
|
|
66
|
+
() => [content],
|
|
67
|
+
);
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
{@render children()}
|
|
71
|
+
{#if present()}
|
|
72
|
+
<Portal>
|
|
73
|
+
<div {...api.getPositionerProps()} class="{{prefix}}-tooltip__positioner">
|
|
74
|
+
<!-- Shown until its exit animation ends; Zag would hide it as it closes. -->
|
|
75
|
+
<div
|
|
76
|
+
{...mergeProps(api.getContentProps(), {
|
|
77
|
+
...rootAttributes(rest),
|
|
78
|
+
class: classes("{{prefix}}-tooltip", className),
|
|
79
|
+
style,
|
|
80
|
+
})}
|
|
81
|
+
bind:this={content}
|
|
82
|
+
hidden={false}
|
|
83
|
+
>
|
|
84
|
+
{label}{#if shortcut}<kbd class="{{prefix}}-tooltip__shortcut">{shortcut}</kbd>{/if}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</Portal>
|
|
88
|
+
{/if}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
* as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Accordion: Zag's accordion machine.
|
|
7
|
+
*
|
|
8
|
+
* Parts: `.{{prefix}}-accordion`, `.{{prefix}}-accordion__item`, `.{{prefix}}-accordion__heading` (the h3),
|
|
9
|
+
* `.{{prefix}}-accordion__trigger` (the button; also a Tailwind `group` for the chevron),
|
|
10
|
+
* `.{{prefix}}-accordion__panel` (the body's box, whose height moves) and `.{{prefix}}-accordion__body`.
|
|
11
|
+
* States: `:hover`, `:active`, `:focus-visible` and `[aria-expanded]` on the trigger. The
|
|
12
|
+
* panel's height is `--accordion-panel-height`, which the component sets: a length while it
|
|
13
|
+
* moves, `auto` while open and `0px` while closed.
|
|
14
|
+
*/
|
|
15
|
+
@layer components {
|
|
16
|
+
/* A hairline above the first item and one under every item, the last included. */
|
|
17
|
+
.{{prefix}}-accordion {
|
|
18
|
+
width: 100%;
|
|
19
|
+
border-top: var(--xds-border-width-thin) solid var(--xds-color-accordion-border);
|
|
20
|
+
contain: layout style;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.{{prefix}}-accordion__item {
|
|
24
|
+
position: relative;
|
|
25
|
+
border-style: none;
|
|
26
|
+
border-bottom: var(--xds-border-width-thin) solid var(--xds-color-accordion-border);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.{{prefix}}-accordion__heading {
|
|
30
|
+
display: flex;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.{{prefix}}-accordion__trigger {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex: 1;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
gap: var(--xds-space-3);
|
|
39
|
+
min-height: var(--xds-size-list-row);
|
|
40
|
+
padding: var(--xds-space-2) var(--xds-space-4);
|
|
41
|
+
font-size: var(--xds-typography-label-size);
|
|
42
|
+
font-weight: var(--xds-typography-label-weight);
|
|
43
|
+
line-height: var(--xds-typography-label-line-height);
|
|
44
|
+
text-align: start;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
touch-action: manipulation;
|
|
47
|
+
-webkit-tap-highlight-color: transparent;
|
|
48
|
+
transition: background-color var(--xds-motion-duration-fast) var(--xds-motion-easing-standard);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Open or closed, the row takes its own fills under the pointer and while pressed. */
|
|
52
|
+
@media (hover: hover) {
|
|
53
|
+
.{{prefix}}-accordion__trigger:hover {
|
|
54
|
+
background: var(--xds-color-accordion-header-background-hover);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* A press that drags does not select the title. */
|
|
59
|
+
.{{prefix}}-accordion__trigger:active {
|
|
60
|
+
background: var(--xds-color-accordion-header-background-pressed);
|
|
61
|
+
user-select: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Inside the row, so the hairlines next to it do not cut through the ring. */
|
|
65
|
+
.{{prefix}}-accordion__trigger:focus-visible {
|
|
66
|
+
outline: var(--xds-focus-width) solid var(--xds-color-border-focus);
|
|
67
|
+
outline-offset: calc(-1 * var(--xds-focus-offset));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Only the height moves. */
|
|
71
|
+
.{{prefix}}-accordion__panel {
|
|
72
|
+
height: var(--accordion-panel-height, auto);
|
|
73
|
+
overflow: clip;
|
|
74
|
+
transition: height var(--xds-motion-duration-normal) var(--xds-motion-easing-standard);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@media (prefers-reduced-motion: reduce) {
|
|
78
|
+
.{{prefix}}-accordion__panel {
|
|
79
|
+
transition: none;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.{{prefix}}-accordion__body {
|
|
84
|
+
padding: 0 var(--xds-space-4) var(--xds-space-4);
|
|
85
|
+
font-size: var(--xds-typography-body-size);
|
|
86
|
+
line-height: var(--xds-typography-body-line-height);
|
|
87
|
+
color: var(--xds-color-text-secondary);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { afterAnimations, focusWithoutRing } from "@xds/svelte/base";
|
|
5
|
+
|
|
6
|
+
/** An item of an Accordion in every framework, short of its body. */
|
|
7
|
+
export type AccordionItemBase<Value extends string = string> = {
|
|
8
|
+
value: Value;
|
|
9
|
+
title: string;
|
|
10
|
+
/** A line under the title, shown whether the item is open or not. */
|
|
11
|
+
description?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Accordion's props in every framework, short of its items and `onChange`. */
|
|
15
|
+
export type AccordionBaseProps<Value extends string = string> = {
|
|
16
|
+
/** The values of the open items. */
|
|
17
|
+
expanded: readonly Value[];
|
|
18
|
+
/** Lets several items be open at once. Without it, opening one closes the others. */
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const ACCORDION_PARTS = {
|
|
23
|
+
/** The title and the description, beside the chevron. */
|
|
24
|
+
text: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
25
|
+
title: "text-xds-body-strong text-xds-text-primary",
|
|
26
|
+
description: "text-xds-detail text-xds-text-secondary",
|
|
27
|
+
// The trigger is a `group`; the chevron turns over while it is expanded.
|
|
28
|
+
chevron:
|
|
29
|
+
"text-xds-accordion-icon transition-transform duration-(--xds-motion-duration-normal) ease-(--xds-motion-easing-standard) group-aria-expanded:rotate-180 motion-reduce:transition-none",
|
|
30
|
+
} as const;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Opens or closes an item's panel (`.{{prefix}}-accordion__panel`): its height moves between zero and the
|
|
34
|
+
* height of what it holds, and it is hidden only once it has finished closing, with
|
|
35
|
+
* `hidden="until-found"`, so the browser's find in page still opens it. Call it on every change
|
|
36
|
+
* of `open`, with `animate` false the first time, when there is nothing to move from. Returns
|
|
37
|
+
* the function that stops the change from settling: call it before the next change, which
|
|
38
|
+
* takes over.
|
|
39
|
+
*/
|
|
40
|
+
export function setPanelOpen(panel: HTMLElement, open: boolean, animate: boolean): () => void {
|
|
41
|
+
const height = (value: string) => panel.style.setProperty("--accordion-panel-height", value);
|
|
42
|
+
if (!animate) {
|
|
43
|
+
if (open) panel.removeAttribute("hidden");
|
|
44
|
+
else panel.setAttribute("hidden", "until-found");
|
|
45
|
+
height(open ? "auto" : "0px");
|
|
46
|
+
return () => {};
|
|
47
|
+
}
|
|
48
|
+
if (open) {
|
|
49
|
+
panel.removeAttribute("hidden");
|
|
50
|
+
height(`${panel.scrollHeight}px`);
|
|
51
|
+
return afterAnimations([panel], () => height("auto"));
|
|
52
|
+
}
|
|
53
|
+
height(`${panel.scrollHeight}px`);
|
|
54
|
+
// Computes the style now, so the change to zero starts a transition.
|
|
55
|
+
void getComputedStyle(panel).height;
|
|
56
|
+
height("0px");
|
|
57
|
+
return afterAnimations([panel], () => panel.setAttribute("hidden", "until-found"));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* For a click on an item's title, ahead of Zag's handler. Zag toggles the item only while its
|
|
62
|
+
* title has the focus, which a press gives it but a click from a script or from assistive
|
|
63
|
+
* technology does not. Focused here first, the title takes those clicks too.
|
|
64
|
+
*/
|
|
65
|
+
export function focusTitleOnClick(event: { currentTarget: EventTarget | null }): void {
|
|
66
|
+
if (event.currentTarget instanceof HTMLElement) focusWithoutRing(event.currentTarget);
|
|
67
|
+
}
|