@lessonkit/accessibility 1.0.0 → 1.0.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.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,31 @@
1
1
  type Focusable = {
2
2
  focus: () => void;
3
3
  };
4
+ type VisuallyHiddenStyle = {
5
+ position: "absolute";
6
+ width: string;
7
+ height: string;
8
+ padding: number;
9
+ margin: string;
10
+ overflow: "hidden";
11
+ clip: string;
12
+ whiteSpace: "nowrap";
13
+ border: number;
14
+ };
15
+ type TrapFocusOptions = {
16
+ initialFocus?: HTMLElement | "first";
17
+ restoreFocus?: boolean;
18
+ allowOutsideClick?: boolean;
19
+ };
20
+ type RovingTabIndexOptions = {
21
+ itemCount: number;
22
+ getId?: (index: number) => string;
23
+ orientation?: "horizontal" | "vertical" | "both";
24
+ loop?: boolean;
25
+ initialIndex?: number;
26
+ };
4
27
  /** Screen-reader-only styles (no external CSS required). */
5
- declare const visuallyHiddenStyle: Record<string, string | number>;
28
+ declare const visuallyHiddenStyle: VisuallyHiddenStyle;
6
29
  type FocusContainer = {
7
30
  querySelector<T>(selectors: string): T | null;
8
31
  };
@@ -13,21 +36,11 @@ declare function shouldAnimate(opts?: {
13
36
  }): boolean;
14
37
  declare function focusFirst(container: FocusContainer | null): boolean;
15
38
  declare function getFocusableElements(container: Element): HTMLElement[];
16
- declare function trapFocus(container: HTMLElement, opts?: {
17
- initialFocus?: HTMLElement | "first";
18
- restoreFocus?: boolean;
19
- allowOutsideClick?: boolean;
20
- }): {
39
+ declare function trapFocus(container: HTMLElement, opts?: TrapFocusOptions): {
21
40
  activate: () => void;
22
41
  deactivate: () => void;
23
42
  };
24
- declare function createRovingTabIndex(opts: {
25
- itemCount: number;
26
- getId?: (index: number) => string;
27
- orientation?: "horizontal" | "vertical" | "both";
28
- loop?: boolean;
29
- initialIndex?: number;
30
- }): {
43
+ declare function createRovingTabIndex(opts: RovingTabIndexOptions): {
31
44
  get activeIndex(): number;
32
45
  setActiveIndex: (next: number) => void;
33
46
  getItemProps: (index: number) => {
@@ -41,4 +54,4 @@ declare function createRovingTabIndex(opts: {
41
54
  };
42
55
  };
43
56
 
44
- export { type FocusContainer, type Focusable, createRovingTabIndex, focusFirst, getFocusableElements, getReducedMotionPreference, prefersReducedMotion, shouldAnimate, trapFocus, visuallyHiddenStyle };
57
+ export { type FocusContainer, type Focusable, type RovingTabIndexOptions, type TrapFocusOptions, type VisuallyHiddenStyle, createRovingTabIndex, focusFirst, getFocusableElements, getReducedMotionPreference, prefersReducedMotion, shouldAnimate, trapFocus, visuallyHiddenStyle };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,31 @@
1
1
  type Focusable = {
2
2
  focus: () => void;
3
3
  };
4
+ type VisuallyHiddenStyle = {
5
+ position: "absolute";
6
+ width: string;
7
+ height: string;
8
+ padding: number;
9
+ margin: string;
10
+ overflow: "hidden";
11
+ clip: string;
12
+ whiteSpace: "nowrap";
13
+ border: number;
14
+ };
15
+ type TrapFocusOptions = {
16
+ initialFocus?: HTMLElement | "first";
17
+ restoreFocus?: boolean;
18
+ allowOutsideClick?: boolean;
19
+ };
20
+ type RovingTabIndexOptions = {
21
+ itemCount: number;
22
+ getId?: (index: number) => string;
23
+ orientation?: "horizontal" | "vertical" | "both";
24
+ loop?: boolean;
25
+ initialIndex?: number;
26
+ };
4
27
  /** Screen-reader-only styles (no external CSS required). */
5
- declare const visuallyHiddenStyle: Record<string, string | number>;
28
+ declare const visuallyHiddenStyle: VisuallyHiddenStyle;
6
29
  type FocusContainer = {
7
30
  querySelector<T>(selectors: string): T | null;
8
31
  };
@@ -13,21 +36,11 @@ declare function shouldAnimate(opts?: {
13
36
  }): boolean;
14
37
  declare function focusFirst(container: FocusContainer | null): boolean;
15
38
  declare function getFocusableElements(container: Element): HTMLElement[];
16
- declare function trapFocus(container: HTMLElement, opts?: {
17
- initialFocus?: HTMLElement | "first";
18
- restoreFocus?: boolean;
19
- allowOutsideClick?: boolean;
20
- }): {
39
+ declare function trapFocus(container: HTMLElement, opts?: TrapFocusOptions): {
21
40
  activate: () => void;
22
41
  deactivate: () => void;
23
42
  };
24
- declare function createRovingTabIndex(opts: {
25
- itemCount: number;
26
- getId?: (index: number) => string;
27
- orientation?: "horizontal" | "vertical" | "both";
28
- loop?: boolean;
29
- initialIndex?: number;
30
- }): {
43
+ declare function createRovingTabIndex(opts: RovingTabIndexOptions): {
31
44
  get activeIndex(): number;
32
45
  setActiveIndex: (next: number) => void;
33
46
  getItemProps: (index: number) => {
@@ -41,4 +54,4 @@ declare function createRovingTabIndex(opts: {
41
54
  };
42
55
  };
43
56
 
44
- export { type FocusContainer, type Focusable, createRovingTabIndex, focusFirst, getFocusableElements, getReducedMotionPreference, prefersReducedMotion, shouldAnimate, trapFocus, visuallyHiddenStyle };
57
+ export { type FocusContainer, type Focusable, type RovingTabIndexOptions, type TrapFocusOptions, type VisuallyHiddenStyle, createRovingTabIndex, focusFirst, getFocusableElements, getReducedMotionPreference, prefersReducedMotion, shouldAnimate, trapFocus, visuallyHiddenStyle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lessonkit/accessibility",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "description": "Accessibility utilities for LessonKit packages and apps.",
6
6
  "license": "Apache-2.0",