mtrl-addons 0.3.6 → 0.3.8
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.
- package/dist/components/vlist/features/keyboard.d.ts +18 -0
- package/dist/components/vlist/index.d.ts +1 -1
- package/dist/components/vlist/types.d.ts +31 -0
- package/dist/core/viewport/types.d.ts +6 -0
- package/dist/index.js +380 -17
- package/dist/index.mjs +372 -9
- package/dist/styles.css +9 -1
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
- package/src/styles/components/_vlist.scss +12 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard Navigation Feature for VList
|
|
3
|
+
*
|
|
4
|
+
* Implements Material Design 3 accessibility guidelines for lists:
|
|
5
|
+
* - Arrow keys (Up/Down/Left/Right) navigate between items with wrapping
|
|
6
|
+
* - Space/Enter activates/selects the focused item
|
|
7
|
+
* - Tab moves focus to/from the list
|
|
8
|
+
* - Home/End jump to first/last item
|
|
9
|
+
* - Page Up/Down skip multiple items
|
|
10
|
+
*
|
|
11
|
+
* @see https://m3.material.io/components/lists/accessibility
|
|
12
|
+
*/
|
|
13
|
+
import type { VListConfig, VListComponent, VListItem } from "../types";
|
|
14
|
+
/**
|
|
15
|
+
* Adds keyboard navigation and accessibility to VList component
|
|
16
|
+
*/
|
|
17
|
+
export declare const withKeyboard: <T extends VListItem = VListItem>(config: VListConfig<T>) => (component: VListComponent<T>) => VListComponent<T>;
|
|
18
|
+
export default withKeyboard;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* feature directly without the list-manager layer.
|
|
6
6
|
*/
|
|
7
7
|
export { createVList } from "./vlist";
|
|
8
|
-
export type { RemoveItemOptions, VListConfig, VListComponent, VListItem, VListAPI, VListState, VListEvents, } from "./types";
|
|
8
|
+
export type { RemoveItemOptions, VListConfig, VListComponent, VListItem, VListAPI, VListState, VListEvents, ListKeyboardConfig, } from "./types";
|
|
@@ -150,6 +150,34 @@ export interface ListSelectionConfig {
|
|
|
150
150
|
/** Automatically select first item after initial load (default: false) */
|
|
151
151
|
autoSelectFirst?: boolean;
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Keyboard navigation configuration
|
|
155
|
+
*
|
|
156
|
+
* Follows Material Design 3 accessibility guidelines:
|
|
157
|
+
* - Arrow keys (Up/Down/Left/Right) navigate with wrapping
|
|
158
|
+
* - Space/Enter activates/selects items
|
|
159
|
+
* - Home/End jump to first/last
|
|
160
|
+
*
|
|
161
|
+
* @see https://m3.material.io/components/lists/accessibility
|
|
162
|
+
*/
|
|
163
|
+
export interface ListKeyboardConfig {
|
|
164
|
+
/** Enable keyboard navigation (default: true when selection is enabled) */
|
|
165
|
+
enabled?: boolean;
|
|
166
|
+
/** Enable Home/End keys (default: true) */
|
|
167
|
+
homeEnd?: boolean;
|
|
168
|
+
/** Enable Page Up/Down keys (default: true) */
|
|
169
|
+
pageUpDown?: boolean;
|
|
170
|
+
/** Number of items to skip with Page Up/Down (default: 10) */
|
|
171
|
+
pageSize?: number;
|
|
172
|
+
/** Enable type-ahead search (default: false) */
|
|
173
|
+
typeAhead?: boolean;
|
|
174
|
+
/** Type-ahead search timeout in ms (default: 500) */
|
|
175
|
+
typeAheadTimeout?: number;
|
|
176
|
+
/** Wrap around when reaching start/end (default: true per MD3 spec) */
|
|
177
|
+
wrap?: boolean;
|
|
178
|
+
/** Callback when keyboard navigation occurs */
|
|
179
|
+
onNavigate?: (index: number, key: string) => void;
|
|
180
|
+
}
|
|
153
181
|
/**
|
|
154
182
|
* List orientation configuration
|
|
155
183
|
*/
|
|
@@ -561,6 +589,8 @@ export interface VListConfig<T extends ListItem = ListItem> {
|
|
|
561
589
|
prefix?: string;
|
|
562
590
|
ariaLabel?: string;
|
|
563
591
|
debug?: boolean;
|
|
592
|
+
/** Automatically select first item after initial load (default: false) */
|
|
593
|
+
autoSelectFirst?: boolean;
|
|
564
594
|
initialScrollIndex?: number;
|
|
565
595
|
selectId?: string | number;
|
|
566
596
|
autoLoad?: boolean;
|
|
@@ -613,6 +643,7 @@ export interface VListConfig<T extends ListItem = ListItem> {
|
|
|
613
643
|
maintainDomOrder?: boolean;
|
|
614
644
|
};
|
|
615
645
|
selection?: ListSelectionConfig;
|
|
646
|
+
keyboard?: ListKeyboardConfig;
|
|
616
647
|
on?: ListEventHandlers<T>;
|
|
617
648
|
}
|
|
618
649
|
export type VListComponent<T extends ListItem = ListItem> = ListComponent<T> & {
|
|
@@ -37,6 +37,12 @@ export interface ViewportConfig {
|
|
|
37
37
|
element?: HTMLElement;
|
|
38
38
|
className?: string;
|
|
39
39
|
debug?: boolean;
|
|
40
|
+
/** ID of item to select after initial load completes */
|
|
41
|
+
selectId?: string | number;
|
|
42
|
+
/** Whether to automatically load data on initialization (default: true) */
|
|
43
|
+
autoLoad?: boolean;
|
|
44
|
+
/** Automatically select first item after initial load (default: false) */
|
|
45
|
+
autoSelectFirst?: boolean;
|
|
40
46
|
template?: (item: any, index: number) => string | HTMLElement | any[] | Record<string, any>;
|
|
41
47
|
collection?: {
|
|
42
48
|
adapter?: any;
|