@sveltia/ui 0.63.0 → 0.63.1

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.
@@ -220,9 +220,7 @@ button.ghost[aria-pressed=true] {
220
220
  background-color: var(--sui-button-ghost-background-color-pressed, var(--sui-selected-background-color));
221
221
  }
222
222
  button.link {
223
- outline: 0;
224
223
  margin: 0;
225
- border-radius: 0 !important;
226
224
  padding: 0 !important;
227
225
  height: auto !important;
228
226
  color: var(--sui-button-link-foreground-color, var(--sui-primary-accent-color-text));
@@ -237,9 +235,6 @@ button.link .label {
237
235
  :global(:is(:root, :host)[data-underline-links='true']) button.link .label {
238
236
  text-decoration: underline;
239
237
  }
240
- button.link:is(:hover, :focus, :active) .label {
241
- text-decoration: var(--sui-button-link-text-decoration-focus, underline);
242
- }
243
238
  button.small {
244
239
  border-radius: var(--sui-button-small-border-radius);
245
240
  padding: var(--sui-button-small-padding);
@@ -50,6 +50,13 @@
50
50
  /* eslint-enable prefer-const */
51
51
  } = $props();
52
52
 
53
+ /**
54
+ * Fallback `id`, so the option can always be referenced by `aria-activedescendant`. `<Group>`
55
+ * assigns one to each member as it activates, but within a `<Combobox>` that happens while the
56
+ * dropdown is still collapsed and no option has rendered yet.
57
+ */
58
+ const fallbackId = $props.id();
59
+
53
60
  /**
54
61
  * The registry provided by an ancestor `<Combobox>`. This is `undefined` when the option is used
55
62
  * standalone within a `<Listbox>`, in which case it always renders itself.
@@ -126,6 +133,7 @@
126
133
  <Button
127
134
  {...restProps}
128
135
  role="option"
136
+ id={restProps.id ?? fallbackId}
129
137
  tabindex="-1"
130
138
  aria-selected={selected}
131
139
  {label}
@@ -124,11 +124,63 @@
124
124
  onChange?.(new CustomEvent('Change', { detail }));
125
125
  };
126
126
 
127
+ /**
128
+ * The `<Listbox>` rendered for this combobox. It’s reached through {@link optionHost}, which owns
129
+ * it wherever the options currently live, rather than through the popup, which only holds it
130
+ * while the dropdown is expanded.
131
+ * @returns {HTMLElement | null | undefined} Listbox element.
132
+ */
133
+ const getListbox = () => optionHost?.querySelector('[role="listbox"]');
134
+
135
+ /**
136
+ * Make the selected option the starting point of the expanded dropdown: scroll it into view, and
137
+ * mark it as the focused member so the arrow keys carry on from there. A long option list is
138
+ * scrollable, and the dropdown would otherwise open at the top with the current selection nowhere
139
+ * to be seen — and the first arrow key would jump back up to the first option.
140
+ */
141
+ const revealSelectedOption = () => {
142
+ const listbox = getListbox();
143
+
144
+ const option = /** @type {HTMLElement | null | undefined} */ (
145
+ listbox?.querySelector('[role="option"][aria-selected="true"]')
146
+ );
147
+
148
+ if (!listbox || !option) {
149
+ return;
150
+ }
151
+
152
+ // `<Group>` tracks the focused member with this class, and moves it on from there
153
+ option.classList.add('focused');
154
+ listbox.setAttribute('aria-activedescendant', option.id);
155
+
156
+ option.scrollIntoView(true);
157
+ };
158
+
127
159
  // Let the options know whether they should render themselves
128
160
  $effect(() => {
129
161
  registry.expanded = isPopupOpen;
130
162
  });
131
163
 
164
+ // Reveal the selected option once the dropdown is expanded. The options are rendered and moved
165
+ // into the popup by the effects around this one, and the popup is then measured against the space
166
+ // below the anchor to get its height, so there is nothing to scroll until all of that has
167
+ // settled. The popup moves focus onto its first tab stop 100ms in, which scrolls that element
168
+ // into view in turn, so this has to come after it rather than be undone by it.
169
+ $effect(() => {
170
+ if (!isPopupOpen) {
171
+ return undefined;
172
+ }
173
+
174
+ const timer = globalThis.setTimeout(revealSelectedOption, 150);
175
+
176
+ return () => {
177
+ globalThis.clearTimeout(timer);
178
+ // The options are unmounted along with the popup, so the listbox is about to be pointing at
179
+ // an element that no longer exists
180
+ getListbox()?.removeAttribute('aria-activedescendant');
181
+ };
182
+ });
183
+
132
184
  // Move the options into the popup while it’s expanded, and back out before it’s unmounted. Only
133
185
  // the wrapper is moved, never its children, so Svelte keeps full ownership of the subtree.
134
186
  $effect(() => {
@@ -414,6 +466,7 @@
414
466
  }
415
467
 
416
468
  .combobox-inner {
469
+ flex: auto;
417
470
  display: flex;
418
471
  flex-direction: column;
419
472
  overflow: hidden;
@@ -7,7 +7,7 @@ export const SHIKI_VERSION: "4.4.3";
7
7
  /**
8
8
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
9
9
  */
10
- export const UI_VERSION: "0.63.0";
10
+ export const UI_VERSION: "0.63.1";
11
11
  /**
12
12
  * Available syntax highlighting languages, sorted by display name.
13
13
  * @type {{ id: string, name: string, aliases?: string[] }[]}
@@ -10,7 +10,7 @@ export const SHIKI_VERSION = "4.4.3";
10
10
  /**
11
11
  * Version of this package, used to resolve the prebuilt Shiki engine chunk from a CDN.
12
12
  */
13
- export const UI_VERSION = "0.63.0";
13
+ export const UI_VERSION = "0.63.1";
14
14
 
15
15
  /**
16
16
  * Available syntax highlighting languages, sorted by display name.
@@ -247,6 +247,11 @@
247
247
  padding: 0;
248
248
  background-color: transparent;
249
249
  }
250
+ .content.combobox {
251
+ display: flex;
252
+ flex-direction: column;
253
+ overflow: hidden;
254
+ }
250
255
  .content.touch {
251
256
  position: static;
252
257
  border-width: 0 !important;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/ui",
3
- "version": "0.63.0",
3
+ "version": "0.63.1",
4
4
  "description": "A collection of Svelte components and utilities for building user interfaces.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -65,20 +65,20 @@
65
65
  "eslint-plugin-jsdoc": "^64.1.0",
66
66
  "eslint-plugin-package-json": "^1.7.1",
67
67
  "eslint-plugin-svelte": "^3.22.0",
68
- "globals": "^17.10.0",
68
+ "globals": "^17.11.0",
69
69
  "happy-dom": "^20.11.2",
70
70
  "oxlint": "^1.78.0",
71
71
  "postcss": "^8.5.26",
72
72
  "postcss-html": "^2.0.0",
73
73
  "prettier": "^3.9.6",
74
74
  "prettier-plugin-svelte": "^4.1.1",
75
- "rolldown": "^1.2.3",
75
+ "rolldown": "^1.2.4",
76
76
  "sass": "^1.102.0",
77
77
  "shiki": "^4.4.3",
78
78
  "stylelint": "^17.14.1",
79
79
  "stylelint-config-recommended-scss": "^17.0.1",
80
80
  "stylelint-scss": "^7.2.0",
81
- "svelte": "^5.56.8",
81
+ "svelte": "^5.56.9",
82
82
  "svelte-check": "^4.7.5",
83
83
  "svelte-preprocess": "^6.0.5",
84
84
  "tslib": "^2.8.1",