@reticular/speakable 1.5.0 → 1.6.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.
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// src/index.ts
|
|
28
|
+
var ADDON_ID = "speakable";
|
|
29
|
+
var PANEL_ID = `${ADDON_ID}/panel`;
|
|
30
|
+
var EVENT_RENDER = `${ADDON_ID}/render`;
|
|
31
|
+
var EVENT_RESULT = `${ADDON_ID}/result`;
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
__commonJS,
|
|
35
|
+
__toESM,
|
|
36
|
+
ADDON_ID,
|
|
37
|
+
PANEL_ID,
|
|
38
|
+
EVENT_RENDER,
|
|
39
|
+
EVENT_RESULT
|
|
40
|
+
};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ADDON_ID,
|
|
3
|
+
EVENT_RESULT,
|
|
4
|
+
PANEL_ID
|
|
5
|
+
} from "./chunk-CL3DJBD7.js";
|
|
6
|
+
|
|
7
|
+
// src/manager.tsx
|
|
8
|
+
import { useState, useEffect } from "react";
|
|
9
|
+
import { addons, types } from "@storybook/manager-api";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
var READER_TABS = [
|
|
12
|
+
{ key: "nvda", label: "NVDA", color: "#3b82f6" },
|
|
13
|
+
{ key: "jaws", label: "JAWS", color: "#8b5cf6" },
|
|
14
|
+
{ key: "voiceover", label: "VoiceOver", color: "#06b6d4" },
|
|
15
|
+
{ key: "narrator", label: "Narrator", color: "#f59e0b" },
|
|
16
|
+
{ key: "audit", label: "Audit", color: "#ef4444" }
|
|
17
|
+
];
|
|
18
|
+
function SpeakablePanel() {
|
|
19
|
+
const [result, setResult] = useState(null);
|
|
20
|
+
const [activeTab, setActiveTab] = useState("nvda");
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const channel = addons.getChannel();
|
|
23
|
+
const handleResult = (data) => {
|
|
24
|
+
setResult(data);
|
|
25
|
+
};
|
|
26
|
+
channel.on(EVENT_RESULT, handleResult);
|
|
27
|
+
return () => channel.off(EVENT_RESULT, handleResult);
|
|
28
|
+
}, []);
|
|
29
|
+
if (!result) {
|
|
30
|
+
return /* @__PURE__ */ jsxs("div", { style: styles.emptyState, children: [
|
|
31
|
+
/* @__PURE__ */ jsx("div", { style: styles.emptyIcon, children: "\u{1F50A}" }),
|
|
32
|
+
/* @__PURE__ */ jsx("p", { style: styles.emptyText, children: "Render a story to see predicted screen reader output" }),
|
|
33
|
+
/* @__PURE__ */ jsx("p", { style: styles.emptySubtext, children: "Powered by Speakable" })
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
const activeLines = activeTab === "audit" ? [] : result[activeTab];
|
|
37
|
+
const auditFindings = result.audit;
|
|
38
|
+
return /* @__PURE__ */ jsxs("div", { style: styles.container, children: [
|
|
39
|
+
/* @__PURE__ */ jsx("div", { style: styles.tabBar, children: READER_TABS.map((tab) => /* @__PURE__ */ jsxs(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
onClick: () => setActiveTab(tab.key),
|
|
43
|
+
style: {
|
|
44
|
+
...styles.tab,
|
|
45
|
+
...activeTab === tab.key ? { ...styles.tabActive, borderBottomColor: tab.color } : { borderBottomColor: "transparent" }
|
|
46
|
+
},
|
|
47
|
+
children: [
|
|
48
|
+
tab.label,
|
|
49
|
+
tab.key === "audit" && auditFindings.length > 0 && /* @__PURE__ */ jsx("span", { style: styles.badge, children: auditFindings.length })
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
tab.key
|
|
53
|
+
)) }),
|
|
54
|
+
/* @__PURE__ */ jsxs("div", { style: styles.statsBar, children: [
|
|
55
|
+
/* @__PURE__ */ jsxs("span", { style: styles.stat, children: [
|
|
56
|
+
result.stats.totalElements,
|
|
57
|
+
" elements"
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ jsxs("span", { style: styles.stat, children: [
|
|
60
|
+
result.stats.interactiveElements,
|
|
61
|
+
" interactive"
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsxs("span", { style: styles.stat, children: [
|
|
64
|
+
result.stats.landmarks,
|
|
65
|
+
" landmarks"
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ jsxs("span", { style: styles.stat, children: [
|
|
68
|
+
result.stats.headings,
|
|
69
|
+
" headings"
|
|
70
|
+
] })
|
|
71
|
+
] }),
|
|
72
|
+
/* @__PURE__ */ jsx("div", { style: styles.content, children: activeTab === "audit" ? /* @__PURE__ */ jsx(AuditView, { findings: auditFindings }) : /* @__PURE__ */ jsx(AnnouncementView, { lines: activeLines, readerKey: activeTab }) }),
|
|
73
|
+
/* @__PURE__ */ jsxs("div", { style: styles.footer, children: [
|
|
74
|
+
/* @__PURE__ */ jsx("span", { style: styles.footerText, children: "Predictions are heuristic-based. Verify with real screen readers before release." }),
|
|
75
|
+
/* @__PURE__ */ jsx("a", { href: "https://getspeakable.dev", target: "_blank", rel: "noopener noreferrer", style: styles.footerLink, children: "getspeakable.dev" })
|
|
76
|
+
] })
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
function AnnouncementView({ lines, readerKey }) {
|
|
80
|
+
if (lines.length === 0) {
|
|
81
|
+
return /* @__PURE__ */ jsx("p", { style: styles.emptyContent, children: "No announcements for this story." });
|
|
82
|
+
}
|
|
83
|
+
return /* @__PURE__ */ jsx("div", { style: styles.lineList, children: lines.map((line, i) => /* @__PURE__ */ jsxs("div", { style: styles.line, children: [
|
|
84
|
+
/* @__PURE__ */ jsx("span", { style: styles.lineNumber, children: i + 1 }),
|
|
85
|
+
/* @__PURE__ */ jsx("span", { style: styles.lineText, children: line })
|
|
86
|
+
] }, `${readerKey}-${i}`)) });
|
|
87
|
+
}
|
|
88
|
+
function AuditView({ findings }) {
|
|
89
|
+
if (findings.length === 0) {
|
|
90
|
+
return /* @__PURE__ */ jsxs("div", { style: styles.auditPass, children: [
|
|
91
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 24 }, children: "\u2713" }),
|
|
92
|
+
/* @__PURE__ */ jsx("p", { style: { margin: 0, fontWeight: 600, color: "#059669" }, children: "No issues found" }),
|
|
93
|
+
/* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: 12, color: "#6b7280" }, children: "All interactive elements have accessible names and heading hierarchy is correct." })
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
return /* @__PURE__ */ jsx("div", { style: styles.lineList, children: findings.map((finding, i) => /* @__PURE__ */ jsxs("div", { style: { ...styles.finding, borderLeftColor: finding.severity === "error" ? "#ef4444" : finding.severity === "warning" ? "#f59e0b" : "#6b7280" }, children: [
|
|
97
|
+
/* @__PURE__ */ jsx("div", { style: styles.findingSeverity, children: finding.severity === "error" ? "\u2717" : finding.severity === "warning" ? "\u26A0" : "\u2139" }),
|
|
98
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
99
|
+
/* @__PURE__ */ jsx("p", { style: styles.findingMessage, children: finding.message }),
|
|
100
|
+
/* @__PURE__ */ jsx("p", { style: styles.findingSelector, children: finding.selector })
|
|
101
|
+
] })
|
|
102
|
+
] }, i)) });
|
|
103
|
+
}
|
|
104
|
+
var styles = {
|
|
105
|
+
container: {
|
|
106
|
+
display: "flex",
|
|
107
|
+
flexDirection: "column",
|
|
108
|
+
height: "100%",
|
|
109
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
110
|
+
fontSize: 13,
|
|
111
|
+
color: "#1e293b",
|
|
112
|
+
background: "#ffffff"
|
|
113
|
+
},
|
|
114
|
+
tabBar: {
|
|
115
|
+
display: "flex",
|
|
116
|
+
borderBottom: "1px solid #e2e8f0",
|
|
117
|
+
padding: "0 12px",
|
|
118
|
+
gap: 0,
|
|
119
|
+
background: "#f8fafc"
|
|
120
|
+
},
|
|
121
|
+
tab: {
|
|
122
|
+
padding: "10px 14px",
|
|
123
|
+
fontSize: 12,
|
|
124
|
+
fontWeight: 600,
|
|
125
|
+
color: "#64748b",
|
|
126
|
+
background: "none",
|
|
127
|
+
borderTop: "none",
|
|
128
|
+
borderLeft: "none",
|
|
129
|
+
borderRight: "none",
|
|
130
|
+
borderBottomWidth: 2,
|
|
131
|
+
borderBottomStyle: "solid",
|
|
132
|
+
borderBottomColor: "transparent",
|
|
133
|
+
cursor: "pointer",
|
|
134
|
+
transition: "color 0.15s, border-color 0.15s",
|
|
135
|
+
display: "flex",
|
|
136
|
+
alignItems: "center",
|
|
137
|
+
gap: 6,
|
|
138
|
+
outline: "none"
|
|
139
|
+
},
|
|
140
|
+
tabActive: {
|
|
141
|
+
color: "#1e293b"
|
|
142
|
+
},
|
|
143
|
+
badge: {
|
|
144
|
+
background: "#ef4444",
|
|
145
|
+
color: "#fff",
|
|
146
|
+
fontSize: 10,
|
|
147
|
+
fontWeight: 700,
|
|
148
|
+
borderRadius: 10,
|
|
149
|
+
padding: "1px 6px",
|
|
150
|
+
minWidth: 18,
|
|
151
|
+
textAlign: "center"
|
|
152
|
+
},
|
|
153
|
+
statsBar: {
|
|
154
|
+
display: "flex",
|
|
155
|
+
gap: 16,
|
|
156
|
+
padding: "8px 16px",
|
|
157
|
+
borderBottom: "1px solid #f1f5f9",
|
|
158
|
+
background: "#f8fafc"
|
|
159
|
+
},
|
|
160
|
+
stat: {
|
|
161
|
+
fontSize: 11,
|
|
162
|
+
color: "#64748b",
|
|
163
|
+
fontWeight: 500
|
|
164
|
+
},
|
|
165
|
+
content: {
|
|
166
|
+
flex: 1,
|
|
167
|
+
overflow: "auto",
|
|
168
|
+
padding: 0
|
|
169
|
+
},
|
|
170
|
+
lineList: {
|
|
171
|
+
padding: "8px 0"
|
|
172
|
+
},
|
|
173
|
+
line: {
|
|
174
|
+
display: "flex",
|
|
175
|
+
alignItems: "flex-start",
|
|
176
|
+
gap: 12,
|
|
177
|
+
padding: "6px 16px",
|
|
178
|
+
borderBottom: "1px solid #f8fafc",
|
|
179
|
+
transition: "background 0.1s"
|
|
180
|
+
},
|
|
181
|
+
lineNumber: {
|
|
182
|
+
fontSize: 10,
|
|
183
|
+
color: "#94a3b8",
|
|
184
|
+
fontFamily: "monospace",
|
|
185
|
+
minWidth: 20,
|
|
186
|
+
textAlign: "right",
|
|
187
|
+
paddingTop: 2
|
|
188
|
+
},
|
|
189
|
+
lineText: {
|
|
190
|
+
fontSize: 13,
|
|
191
|
+
color: "#1e293b",
|
|
192
|
+
fontFamily: "monospace",
|
|
193
|
+
lineHeight: 1.5
|
|
194
|
+
},
|
|
195
|
+
emptyContent: {
|
|
196
|
+
padding: 24,
|
|
197
|
+
textAlign: "center",
|
|
198
|
+
color: "#94a3b8"
|
|
199
|
+
},
|
|
200
|
+
footer: {
|
|
201
|
+
display: "flex",
|
|
202
|
+
justifyContent: "space-between",
|
|
203
|
+
alignItems: "center",
|
|
204
|
+
padding: "8px 16px",
|
|
205
|
+
borderTop: "1px solid #e2e8f0",
|
|
206
|
+
background: "#f8fafc"
|
|
207
|
+
},
|
|
208
|
+
footerText: {
|
|
209
|
+
fontSize: 11,
|
|
210
|
+
color: "#94a3b8",
|
|
211
|
+
fontStyle: "italic"
|
|
212
|
+
},
|
|
213
|
+
footerLink: {
|
|
214
|
+
fontSize: 11,
|
|
215
|
+
color: "#3b82f6",
|
|
216
|
+
textDecoration: "none",
|
|
217
|
+
fontWeight: 600
|
|
218
|
+
},
|
|
219
|
+
emptyState: {
|
|
220
|
+
display: "flex",
|
|
221
|
+
flexDirection: "column",
|
|
222
|
+
alignItems: "center",
|
|
223
|
+
justifyContent: "center",
|
|
224
|
+
height: "100%",
|
|
225
|
+
gap: 8,
|
|
226
|
+
padding: 32
|
|
227
|
+
},
|
|
228
|
+
emptyIcon: {
|
|
229
|
+
fontSize: 32
|
|
230
|
+
},
|
|
231
|
+
emptyText: {
|
|
232
|
+
fontSize: 14,
|
|
233
|
+
fontWeight: 600,
|
|
234
|
+
color: "#475569"
|
|
235
|
+
},
|
|
236
|
+
emptySubtext: {
|
|
237
|
+
fontSize: 12,
|
|
238
|
+
color: "#94a3b8"
|
|
239
|
+
},
|
|
240
|
+
auditPass: {
|
|
241
|
+
display: "flex",
|
|
242
|
+
flexDirection: "column",
|
|
243
|
+
alignItems: "center",
|
|
244
|
+
gap: 8,
|
|
245
|
+
padding: 32,
|
|
246
|
+
color: "#059669"
|
|
247
|
+
},
|
|
248
|
+
finding: {
|
|
249
|
+
display: "flex",
|
|
250
|
+
alignItems: "flex-start",
|
|
251
|
+
gap: 10,
|
|
252
|
+
padding: "10px 16px",
|
|
253
|
+
margin: "4px 12px",
|
|
254
|
+
borderRadius: 4,
|
|
255
|
+
background: "#fefce8"
|
|
256
|
+
},
|
|
257
|
+
findingSeverity: {
|
|
258
|
+
fontSize: 14,
|
|
259
|
+
fontWeight: 700,
|
|
260
|
+
paddingTop: 1
|
|
261
|
+
},
|
|
262
|
+
findingMessage: {
|
|
263
|
+
margin: 0,
|
|
264
|
+
fontSize: 13,
|
|
265
|
+
fontWeight: 500,
|
|
266
|
+
color: "#1e293b"
|
|
267
|
+
},
|
|
268
|
+
findingSelector: {
|
|
269
|
+
margin: "2px 0 0",
|
|
270
|
+
fontSize: 11,
|
|
271
|
+
color: "#64748b",
|
|
272
|
+
fontFamily: "monospace"
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
function SpeakableIcon() {
|
|
276
|
+
return /* @__PURE__ */ jsxs(
|
|
277
|
+
"svg",
|
|
278
|
+
{
|
|
279
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
280
|
+
viewBox: "0 0 32 32",
|
|
281
|
+
fill: "none",
|
|
282
|
+
style: { width: 14, height: 14, marginRight: 4, verticalAlign: "middle" },
|
|
283
|
+
children: [
|
|
284
|
+
/* @__PURE__ */ jsx("rect", { x: "2", y: "4", width: "28", height: "20", rx: "4", fill: "#0D9488" }),
|
|
285
|
+
/* @__PURE__ */ jsx("polygon", { points: "8,24 14,24 10,30", fill: "#0D9488" }),
|
|
286
|
+
/* @__PURE__ */ jsx("path", { d: "M12 11 L12 17", stroke: "white", strokeWidth: "2.5", strokeLinecap: "round" }),
|
|
287
|
+
/* @__PURE__ */ jsx("path", { d: "M16 9 L16 19", stroke: "white", strokeWidth: "2.5", strokeLinecap: "round" }),
|
|
288
|
+
/* @__PURE__ */ jsx("path", { d: "M20 11 L20 17", stroke: "white", strokeWidth: "2.5", strokeLinecap: "round" })
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
addons.register(ADDON_ID, () => {
|
|
294
|
+
addons.add(PANEL_ID, {
|
|
295
|
+
type: types.PANEL,
|
|
296
|
+
title: /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center" }, children: [
|
|
297
|
+
/* @__PURE__ */ jsx(SpeakableIcon, {}),
|
|
298
|
+
"Screen Readers"
|
|
299
|
+
] }),
|
|
300
|
+
render: ({ active }) => active ? /* @__PURE__ */ jsx(SpeakablePanel, {}) : null
|
|
301
|
+
});
|
|
302
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/preset.ts
|
|
21
|
+
var preset_exports = {};
|
|
22
|
+
__export(preset_exports, {
|
|
23
|
+
managerEntries: () => managerEntries,
|
|
24
|
+
previewAnnotations: () => previewAnnotations
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(preset_exports);
|
|
27
|
+
var import_path = require("path");
|
|
28
|
+
function managerEntries(entry = []) {
|
|
29
|
+
return [...entry, (0, import_path.join)(__dirname, "manager.js")];
|
|
30
|
+
}
|
|
31
|
+
function previewAnnotations(entry = []) {
|
|
32
|
+
return [...entry, (0, import_path.join)(__dirname, "preview.js")];
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
managerEntries,
|
|
37
|
+
previewAnnotations
|
|
38
|
+
});
|