@agnos-ui/svelte-bootstrap 0.7.0 → 0.7.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.
|
@@ -5,7 +5,43 @@ import {BROWSER as __AgnosUISveltePreprocess__BROWSER} from 'esm-env';
|
|
|
5
5
|
import type {SliderSlotHandleContext} from './slider.gen';
|
|
6
6
|
|
|
7
7
|
let {item, directives}: SliderSlotHandleContext = $props();
|
|
8
|
+
|
|
9
|
+
let refocusElement: HTMLElement | undefined = $state(undefined);
|
|
10
|
+
let updateTimeout: NodeJS.Timeout;
|
|
11
|
+
|
|
12
|
+
// Manually keep focus as scheduling goal elements are re-ordered.
|
|
13
|
+
// Svelte currently does not retain focus as elements are moved, even when keyed.
|
|
14
|
+
// See discussion here: https://github.com/sveltejs/svelte/issues/3973
|
|
15
|
+
$effect(() => {
|
|
16
|
+
if (refocusElement) {
|
|
17
|
+
updateTimeout = setTimeout(() => {
|
|
18
|
+
refocusElement?.focus();
|
|
19
|
+
refocusElement = undefined;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Key handler that sets the refocus element only on the key strokes that move
|
|
26
|
+
* the element up the DOM
|
|
27
|
+
* @param event object containting key stroke and the target element
|
|
28
|
+
*/
|
|
29
|
+
function onkeydown(event: KeyboardEvent) {
|
|
30
|
+
switch (event.key) {
|
|
31
|
+
case 'ArrowUp':
|
|
32
|
+
case 'ArrowRight':
|
|
33
|
+
case 'End':
|
|
34
|
+
case 'ArrowDown':
|
|
35
|
+
case 'ArrowLeft':
|
|
36
|
+
case 'Home':
|
|
37
|
+
refocusElement = event.target as HTMLElement;
|
|
38
|
+
clearTimeout(updateTimeout);
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
8
44
|
</script>
|
|
9
45
|
|
|
10
46
|
<!-- svelte-ignore a11y_consider_explicit_label -->
|
|
11
|
-
<button use:directives.handleDirective={{item}} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes([directives.handleDirective, {item}])}> </button>
|
|
47
|
+
<button {onkeydown} use:directives.handleDirective={{item}} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes([directives.handleDirective, {item}])}> </button>
|
|
@@ -165,28 +165,35 @@ export interface SliderState {
|
|
|
165
165
|
export interface SliderProps {
|
|
166
166
|
/**
|
|
167
167
|
* Return the value for the 'aria-label' attribute for the handle
|
|
168
|
-
* @param value - value of the handle
|
|
169
168
|
* @param sortedIndex - index of the handle in the sorted list
|
|
170
|
-
* @param index - index of the handle in the original list
|
|
171
169
|
*
|
|
172
170
|
* @defaultValue
|
|
173
171
|
* ```ts
|
|
174
|
-
* (
|
|
172
|
+
* () => 'Value'
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
ariaLabel: (sortedIndex: number) => string;
|
|
176
|
+
/**
|
|
177
|
+
* Return the value for the 'aria-labelledBy' attribute for the handle
|
|
178
|
+
* @param sortedIndex - index of the handle in the sorted list
|
|
179
|
+
*
|
|
180
|
+
* @defaultValue
|
|
181
|
+
* ```ts
|
|
182
|
+
* () => ''
|
|
175
183
|
* ```
|
|
176
184
|
*/
|
|
177
|
-
|
|
185
|
+
ariaLabelledBy: (sortedIndex: number) => string;
|
|
178
186
|
/**
|
|
179
187
|
* Return the value for the 'aria-valuetext' attribute for the handle
|
|
180
188
|
* @param value - value of the handle
|
|
181
189
|
* @param sortedIndex - index of the handle in the sorted list
|
|
182
|
-
* @param index - index of the handle in the original list
|
|
183
190
|
*
|
|
184
191
|
* @defaultValue
|
|
185
192
|
* ```ts
|
|
186
|
-
* (value: number) => ''
|
|
193
|
+
* (value: number) => ''
|
|
187
194
|
* ```
|
|
188
195
|
*/
|
|
189
|
-
ariaValueText: (value: number, sortedIndex: number
|
|
196
|
+
ariaValueText: (value: number, sortedIndex: number) => string;
|
|
190
197
|
/**
|
|
191
198
|
* An event emitted when slider values are changed
|
|
192
199
|
*
|
|
@@ -354,11 +361,15 @@ export interface SliderHandle {
|
|
|
354
361
|
/**
|
|
355
362
|
* ariaLabel of the handle
|
|
356
363
|
*/
|
|
357
|
-
ariaLabel: string;
|
|
364
|
+
ariaLabel: string | undefined;
|
|
358
365
|
/**
|
|
359
366
|
* ariaValueText of the handle
|
|
360
367
|
*/
|
|
361
|
-
ariaValueText: string;
|
|
368
|
+
ariaValueText: string | undefined;
|
|
369
|
+
/**
|
|
370
|
+
* aria-labelledBy of the handle
|
|
371
|
+
*/
|
|
372
|
+
ariaLabelledBy: string | undefined;
|
|
362
373
|
}
|
|
363
374
|
/**
|
|
364
375
|
* Interface representing various directives used in the slider component.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agnos-ui/svelte-bootstrap",
|
|
3
3
|
"description": "Bootstrap-based component library for Svelte.",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.js",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@agnos-ui/core-bootstrap": "0.7.
|
|
53
|
-
"@agnos-ui/svelte-headless": "0.7.
|
|
52
|
+
"@agnos-ui/core-bootstrap": "0.7.1",
|
|
53
|
+
"@agnos-ui/svelte-headless": "0.7.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@amadeus-it-group/tansu": "^2.0.0",
|