@compa11y/core 0.1.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.
- package/LICENSE +21 -0
- package/README.md +160 -0
- package/dist/announcer/index.cjs +49 -0
- package/dist/announcer/index.cjs.map +1 -0
- package/dist/announcer/index.d.cts +61 -0
- package/dist/announcer/index.d.ts +61 -0
- package/dist/announcer/index.js +4 -0
- package/dist/announcer/index.js.map +1 -0
- package/dist/aria/index.cjs +24 -0
- package/dist/aria/index.cjs.map +1 -0
- package/dist/aria/index.d.cts +176 -0
- package/dist/aria/index.d.ts +176 -0
- package/dist/aria/index.js +3 -0
- package/dist/aria/index.js.map +1 -0
- package/dist/chunk-24U5HHMC.js +309 -0
- package/dist/chunk-24U5HHMC.js.map +1 -0
- package/dist/chunk-2CQOLVQH.js +147 -0
- package/dist/chunk-2CQOLVQH.js.map +1 -0
- package/dist/chunk-2PUYKF2E.js +631 -0
- package/dist/chunk-2PUYKF2E.js.map +1 -0
- package/dist/chunk-2WF5Y6D7.js +175 -0
- package/dist/chunk-2WF5Y6D7.js.map +1 -0
- package/dist/chunk-CQXMBRLD.cjs +657 -0
- package/dist/chunk-CQXMBRLD.cjs.map +1 -0
- package/dist/chunk-HQOFVJFO.cjs +181 -0
- package/dist/chunk-HQOFVJFO.cjs.map +1 -0
- package/dist/chunk-NBGFFCIJ.cjs +314 -0
- package/dist/chunk-NBGFFCIJ.cjs.map +1 -0
- package/dist/chunk-V6TZIZZ4.cjs +158 -0
- package/dist/chunk-V6TZIZZ4.cjs.map +1 -0
- package/dist/chunk-XEGB27QF.cjs +78 -0
- package/dist/chunk-XEGB27QF.cjs.map +1 -0
- package/dist/chunk-Z7K2G6FX.js +66 -0
- package/dist/chunk-Z7K2G6FX.js.map +1 -0
- package/dist/focus/index.cjs +53 -0
- package/dist/focus/index.cjs.map +1 -0
- package/dist/focus/index.d.cts +139 -0
- package/dist/focus/index.d.ts +139 -0
- package/dist/focus/index.js +4 -0
- package/dist/focus/index.js.map +1 -0
- package/dist/index.cjs +573 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +241 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +343 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard/index.cjs +28 -0
- package/dist/keyboard/index.cjs.map +1 -0
- package/dist/keyboard/index.d.cts +102 -0
- package/dist/keyboard/index.d.ts +102 -0
- package/dist/keyboard/index.js +3 -0
- package/dist/keyboard/index.js.map +1 -0
- package/dist/types-DDSPmE8m.d.cts +52 -0
- package/dist/types-DDSPmE8m.d.ts +52 -0
- package/package.json +78 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types used across compa11y
|
|
3
|
+
*/
|
|
4
|
+
type AriaRole = 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'cell' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'navigation' | 'none' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
|
|
5
|
+
type AriaLivePoliteness = 'off' | 'polite' | 'assertive';
|
|
6
|
+
interface FocusableElement extends HTMLElement {
|
|
7
|
+
focus(options?: FocusOptions): void;
|
|
8
|
+
}
|
|
9
|
+
interface KeyboardNavigationOptions {
|
|
10
|
+
/** Whether navigation wraps around at boundaries */
|
|
11
|
+
wrap?: boolean;
|
|
12
|
+
/** Orientation of the navigation */
|
|
13
|
+
orientation?: 'horizontal' | 'vertical' | 'both';
|
|
14
|
+
/** Whether to focus on hover */
|
|
15
|
+
focusOnHover?: boolean;
|
|
16
|
+
/** Custom key handlers */
|
|
17
|
+
keyHandlers?: Record<string, (event: KeyboardEvent) => void>;
|
|
18
|
+
}
|
|
19
|
+
interface FocusTrapOptions {
|
|
20
|
+
/** Element to focus when trap activates */
|
|
21
|
+
initialFocus?: HTMLElement | string | (() => HTMLElement | null);
|
|
22
|
+
/** Element to focus when trap deactivates */
|
|
23
|
+
returnFocus?: HTMLElement | boolean;
|
|
24
|
+
/** Whether clicking outside deactivates the trap */
|
|
25
|
+
clickOutsideDeactivates?: boolean;
|
|
26
|
+
/** Whether pressing Escape deactivates the trap */
|
|
27
|
+
escapeDeactivates?: boolean;
|
|
28
|
+
/** Callback when trap is deactivated */
|
|
29
|
+
onDeactivate?: () => void;
|
|
30
|
+
/** Callback when focus escapes (for portals) */
|
|
31
|
+
onEscapeFocus?: (element: Element) => void;
|
|
32
|
+
}
|
|
33
|
+
interface AnnouncerOptions {
|
|
34
|
+
/** Politeness level for the announcement */
|
|
35
|
+
politeness?: AriaLivePoliteness;
|
|
36
|
+
/** Delay before announcement in ms */
|
|
37
|
+
delay?: number;
|
|
38
|
+
/** Clear previous announcements */
|
|
39
|
+
clearPrevious?: boolean;
|
|
40
|
+
/** Timeout for announcement visibility */
|
|
41
|
+
timeout?: number;
|
|
42
|
+
}
|
|
43
|
+
interface DevWarning {
|
|
44
|
+
type: 'error' | 'warning' | 'info';
|
|
45
|
+
component: string;
|
|
46
|
+
message: string;
|
|
47
|
+
suggestion?: string;
|
|
48
|
+
element?: Element;
|
|
49
|
+
}
|
|
50
|
+
type DevWarningHandler = (warning: DevWarning) => void;
|
|
51
|
+
|
|
52
|
+
export type { AnnouncerOptions as A, DevWarningHandler as D, FocusTrapOptions as F, KeyboardNavigationOptions as K, DevWarning as a, AriaLivePoliteness as b, AriaRole as c, FocusableElement as d };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types used across compa11y
|
|
3
|
+
*/
|
|
4
|
+
type AriaRole = 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'cell' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'navigation' | 'none' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem';
|
|
5
|
+
type AriaLivePoliteness = 'off' | 'polite' | 'assertive';
|
|
6
|
+
interface FocusableElement extends HTMLElement {
|
|
7
|
+
focus(options?: FocusOptions): void;
|
|
8
|
+
}
|
|
9
|
+
interface KeyboardNavigationOptions {
|
|
10
|
+
/** Whether navigation wraps around at boundaries */
|
|
11
|
+
wrap?: boolean;
|
|
12
|
+
/** Orientation of the navigation */
|
|
13
|
+
orientation?: 'horizontal' | 'vertical' | 'both';
|
|
14
|
+
/** Whether to focus on hover */
|
|
15
|
+
focusOnHover?: boolean;
|
|
16
|
+
/** Custom key handlers */
|
|
17
|
+
keyHandlers?: Record<string, (event: KeyboardEvent) => void>;
|
|
18
|
+
}
|
|
19
|
+
interface FocusTrapOptions {
|
|
20
|
+
/** Element to focus when trap activates */
|
|
21
|
+
initialFocus?: HTMLElement | string | (() => HTMLElement | null);
|
|
22
|
+
/** Element to focus when trap deactivates */
|
|
23
|
+
returnFocus?: HTMLElement | boolean;
|
|
24
|
+
/** Whether clicking outside deactivates the trap */
|
|
25
|
+
clickOutsideDeactivates?: boolean;
|
|
26
|
+
/** Whether pressing Escape deactivates the trap */
|
|
27
|
+
escapeDeactivates?: boolean;
|
|
28
|
+
/** Callback when trap is deactivated */
|
|
29
|
+
onDeactivate?: () => void;
|
|
30
|
+
/** Callback when focus escapes (for portals) */
|
|
31
|
+
onEscapeFocus?: (element: Element) => void;
|
|
32
|
+
}
|
|
33
|
+
interface AnnouncerOptions {
|
|
34
|
+
/** Politeness level for the announcement */
|
|
35
|
+
politeness?: AriaLivePoliteness;
|
|
36
|
+
/** Delay before announcement in ms */
|
|
37
|
+
delay?: number;
|
|
38
|
+
/** Clear previous announcements */
|
|
39
|
+
clearPrevious?: boolean;
|
|
40
|
+
/** Timeout for announcement visibility */
|
|
41
|
+
timeout?: number;
|
|
42
|
+
}
|
|
43
|
+
interface DevWarning {
|
|
44
|
+
type: 'error' | 'warning' | 'info';
|
|
45
|
+
component: string;
|
|
46
|
+
message: string;
|
|
47
|
+
suggestion?: string;
|
|
48
|
+
element?: Element;
|
|
49
|
+
}
|
|
50
|
+
type DevWarningHandler = (warning: DevWarning) => void;
|
|
51
|
+
|
|
52
|
+
export type { AnnouncerOptions as A, DevWarningHandler as D, FocusTrapOptions as F, KeyboardNavigationOptions as K, DevWarning as a, AriaLivePoliteness as b, AriaRole as c, FocusableElement as d };
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@compa11y/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-agnostic accessibility primitives",
|
|
5
|
+
"author": "Ivan Trajkovski",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.mjs",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"homepage": "https://github.com/trajkovskiivan/compa11y#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/trajkovskiivan/compa11y/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/trajkovskiivan/compa11y.git",
|
|
21
|
+
"directory": "packages/core"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./focus": {
|
|
30
|
+
"types": "./dist/focus/index.d.ts",
|
|
31
|
+
"import": "./dist/focus/index.js",
|
|
32
|
+
"require": "./dist/focus/index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./keyboard": {
|
|
35
|
+
"types": "./dist/keyboard/index.d.ts",
|
|
36
|
+
"import": "./dist/keyboard/index.js",
|
|
37
|
+
"require": "./dist/keyboard/index.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./announcer": {
|
|
40
|
+
"types": "./dist/announcer/index.d.ts",
|
|
41
|
+
"import": "./dist/announcer/index.js",
|
|
42
|
+
"require": "./dist/announcer/index.cjs"
|
|
43
|
+
},
|
|
44
|
+
"./aria": {
|
|
45
|
+
"types": "./dist/aria/index.d.ts",
|
|
46
|
+
"import": "./dist/aria/index.js",
|
|
47
|
+
"require": "./dist/aria/index.cjs"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
],
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^20.11.0",
|
|
57
|
+
"tsup": "^8.0.0",
|
|
58
|
+
"typescript": "^5.3.0",
|
|
59
|
+
"vitest": "^1.2.0"
|
|
60
|
+
},
|
|
61
|
+
"sideEffects": false,
|
|
62
|
+
"keywords": [
|
|
63
|
+
"accessibility",
|
|
64
|
+
"a11y",
|
|
65
|
+
"focus",
|
|
66
|
+
"keyboard",
|
|
67
|
+
"aria",
|
|
68
|
+
"screen-reader"
|
|
69
|
+
],
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "tsup",
|
|
72
|
+
"dev": "tsup --watch",
|
|
73
|
+
"test": "vitest run",
|
|
74
|
+
"test:watch": "vitest",
|
|
75
|
+
"typecheck": "tsc --noEmit",
|
|
76
|
+
"clean": "rm -rf dist node_modules"
|
|
77
|
+
}
|
|
78
|
+
}
|