-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
126 lines (123 loc) · 3.28 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* Returns all the available data for the specified bullet point or throws
* an error if the given bullet point doesn't exist.
*
* @throws When the success criterion not exist.
* @param version
* @param chapter
* @param section
* @param subsection
* @returns All available data for the specified criterion
*
* @example
* ```
* import { getCriterionData } from 'wcag-reference';
*
* const data = getCriterionData('2.1', 2, 1, 1);
* // → {
* // id: 'keyboard',
* // handle: '2.1.1 Keyboard',
* // quickReference: 'https://www.w3.org/WAI/WCAG21/quickref/#keyboard',
* // detailedReference: 'https://www.w3.org/WAI/WCAG21/Understanding/keyboard.html',
* // level: 1, // → 1: A, 2: AA, 3: AAA
* // wcagUrl: 'https://www.w3.org/TR/WCAG21/'
* // }
* ```
*/
export function getCriterionData(
version: '2.0' | '2.1' | '2.2',
chapter: number,
section: number,
subsection: number
): {
id: string;
handle: string;
quickReference: string;
detailedReference: string;
level: 1 | 2 | 3;
wcagUrl: string;
} | Error;
/**
* Returns a link with an anchor to the specified bullet point or throws
* an error if the given bullet point doesn't exist.
*
* @throws When the success criterion not exist.
* @param version
* @param chapter
* @param section
* @param subsection
* @returns Link with an anchor pointing to the criterion
*
* @example
* ```
* import { getLinkToCriterion } from 'wcag-reference';
*
* const link = getLinkToCriterion('2.2', 3, 3, 4);
* // → 'https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data'
* ```
*/
export function getLinkToCriterion(
version: '2.0' | '2.1' | '2.2',
chapter: number,
section: number,
subsection: number
): string;
/**
* Returns all the available data for the specified technique or throws an
* error if the given technique doesn't exist.
*
* @throws When the technique not exist.
* @param version
* @param technique
* @returns All available data for the specified technique
*
* @example
* ```
* import { getTechniqueData } from 'wcag-reference';
*
* const data21 = getTechniqueData('2.1', 'G57');
* // → {
* // text: 'G57: Ordering the content in a meaningful sequence',
* // techniquesUrl: 'https://www.w3.org/WAI/WCAG21/Techniques/',
* // groupId: 'general',
* // groupPage: undefined
* // }
* const data20 = getTechniqueData('2.0', 'G57');
* // → {
* // text: 'G57: Ordering the content in a meaningful sequence',
* // techniquesUrl: 'https://www.w3.org/TR/WCAG20-TECHS/',
* // groupId: undefined,
* // groupPage: 'general.html'
* // }
* ```
*/
export function getTechniqueData(
version: '2.0' | '2.1' | '2.2',
technique: string
): {
text: string;
techniquesUrl: string;
groupId?: string;
groupPage?: string;
} | Error;
/**
* Returns a link with an anchor to the specified technique or throws
* an error if the given technique doesn't exist.
*
* @throws When the technique not exist.
* @param version
* @param technique
* @returns Link with an anchor pointing to the technique
*
* @example
* ```
* import { getLinkToTechnique } from 'wcag-reference';
*
* const link = getLinkToTechnique('2.0', 'SCR27');
* // → 'https://www.w3.org/TR/WCAG20-TECHS/SCR27.html'
* ```
*/
export function getLinkToTechnique(
version: '2.0' | '2.1' | '2.2',
technique: string
): string;