a11y-elements 0.2.0 → 0.3.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/README.md +259 -16
- package/dist/a11y.css +200 -0
- package/dist/browser/components/anchor/define.js +13 -1
- package/dist/browser/components/anchor/define.js.map +1 -1
- package/dist/browser/components/avatar/define.js +13 -1
- package/dist/browser/components/avatar/define.js.map +1 -1
- package/dist/browser/components/checkbox/define.js +13 -1
- package/dist/browser/components/checkbox/define.js.map +1 -1
- package/dist/browser/components/checkbox-group/define.js +394 -0
- package/dist/browser/components/checkbox-group/define.js.map +1 -0
- package/dist/browser/components/file-input/define.js +1069 -0
- package/dist/browser/components/file-input/define.js.map +1 -0
- package/dist/browser/components/focusable/define.js +13 -1
- package/dist/browser/components/focusable/define.js.map +1 -1
- package/dist/browser/components/input/define.js +34 -6
- package/dist/browser/components/input/define.js.map +1 -1
- package/dist/browser/components/label/define.js +13 -1
- package/dist/browser/components/label/define.js.map +1 -1
- package/dist/browser/components/picture/define.js +171 -3
- package/dist/browser/components/picture/define.js.map +1 -1
- package/dist/browser/components/progress/define.js +13 -1
- package/dist/browser/components/progress/define.js.map +1 -1
- package/dist/browser/components/radio-group/define.js +15 -1
- package/dist/browser/components/radio-group/define.js.map +1 -1
- package/dist/browser/components/select/define.js +13 -1
- package/dist/browser/components/select/define.js.map +1 -1
- package/dist/browser/components/skeleton/define.js +13 -1
- package/dist/browser/components/skeleton/define.js.map +1 -1
- package/dist/browser/components/spinner/define.js +13 -1
- package/dist/browser/components/spinner/define.js.map +1 -1
- package/dist/browser/components/switch/define.js +13 -1
- package/dist/browser/components/switch/define.js.map +1 -1
- package/dist/browser/components/textarea/define.js +34 -6
- package/dist/browser/components/textarea/define.js.map +1 -1
- package/dist/browser/components/visually-hidden/define.js +13 -1
- package/dist/browser/components/visually-hidden/define.js.map +1 -1
- package/dist/browser/overlays/blocking-loader/define.js +13 -1
- package/dist/browser/overlays/blocking-loader/define.js.map +1 -1
- package/dist/browser/overlays/context-menu/define.js +19 -3
- package/dist/browser/overlays/context-menu/define.js.map +1 -1
- package/dist/browser/overlays/drawer/define.js +18 -2
- package/dist/browser/overlays/drawer/define.js.map +1 -1
- package/dist/browser/overlays/dropdown/define.js +19 -3
- package/dist/browser/overlays/dropdown/define.js.map +1 -1
- package/dist/browser/overlays/emergency-dialog/define.js +18 -2
- package/dist/browser/overlays/emergency-dialog/define.js.map +1 -1
- package/dist/browser/overlays/modal/define.js +18 -2
- package/dist/browser/overlays/modal/define.js.map +1 -1
- package/dist/browser/overlays/notification-banner/define.js +13 -1
- package/dist/browser/overlays/notification-banner/define.js.map +1 -1
- package/dist/browser/overlays/popover/define.js +18 -2
- package/dist/browser/overlays/popover/define.js.map +1 -1
- package/dist/browser/overlays/snackbar/define.js +13 -1
- package/dist/browser/overlays/snackbar/define.js.map +1 -1
- package/dist/browser/overlays/tooltip/define.js +18 -2
- package/dist/browser/overlays/tooltip/define.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.element.d.ts +51 -0
- package/dist/components/checkbox-group/checkbox-group.element.js +189 -0
- package/dist/components/checkbox-group/checkbox-group.element.js.map +1 -0
- package/dist/components/checkbox-group/define.d.ts +8 -0
- package/dist/components/checkbox-group/define.js +8 -0
- package/dist/components/checkbox-group/define.js.map +1 -0
- package/dist/components/file-input/define.d.ts +9 -0
- package/dist/components/file-input/define.js +9 -0
- package/dist/components/file-input/define.js.map +1 -0
- package/dist/components/file-input/file-input.element.d.ts +95 -0
- package/dist/components/file-input/file-input.element.js +471 -0
- package/dist/components/file-input/file-input.element.js.map +1 -0
- package/dist/components/label/label.element.d.ts +1 -1
- package/dist/components/label/label.element.js +1 -1
- package/dist/components/picture/define.d.ts +1 -0
- package/dist/components/picture/define.js.map +1 -1
- package/dist/components/picture/picture.element.d.ts +72 -6
- package/dist/components/picture/picture.element.js +201 -9
- package/dist/components/picture/picture.element.js.map +1 -1
- package/dist/components/radio-group/radio-group.element.js +4 -0
- package/dist/components/radio-group/radio-group.element.js.map +1 -1
- package/dist/core/a11y-field-element.d.ts +17 -7
- package/dist/core/a11y-field-element.js +25 -5
- package/dist/core/a11y-field-element.js.map +1 -1
- package/dist/core/focus-trap.d.ts +8 -0
- package/dist/core/focus-trap.js +13 -1
- package/dist/core/focus-trap.js.map +1 -1
- package/dist/core/strings.d.ts +24 -0
- package/dist/core/strings.js +12 -0
- package/dist/core/strings.js.map +1 -1
- package/dist/overlays/core/a11y-menu-overlay-element.js +2 -2
- package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,7 +9,19 @@ var DEFAULT_STRINGS = Object.freeze({
|
|
|
9
9
|
avatar: "Avatar",
|
|
10
10
|
characterCount: "{count} / {max}",
|
|
11
11
|
charactersRemaining: "{count} characters remaining",
|
|
12
|
-
characterRemaining: "{count} character remaining"
|
|
12
|
+
characterRemaining: "{count} character remaining",
|
|
13
|
+
selectAll: "Select all",
|
|
14
|
+
browseFiles: "Browse files",
|
|
15
|
+
dropFiles: "or drop files here",
|
|
16
|
+
selectedFiles: "Selected files",
|
|
17
|
+
remove: "Remove",
|
|
18
|
+
removeFile: "Remove {name}",
|
|
19
|
+
fileAdded: "{name} added",
|
|
20
|
+
filesAdded: "{count} files added",
|
|
21
|
+
fileRemoved: "{name} removed",
|
|
22
|
+
fileTypeRejected: "{name} wasn\u2019t added: this type of file isn\u2019t allowed",
|
|
23
|
+
fileSizeRejected: "{name} wasn\u2019t added: it\u2019s larger than {maxSize}",
|
|
24
|
+
fileCountRejected: "{name} wasn\u2019t added: too many files (maximum {max})"
|
|
13
25
|
});
|
|
14
26
|
var STRINGS_CHANGE_EVENT = "a11y-strings-change";
|
|
15
27
|
var STRINGS_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/strings");
|
|
@@ -203,6 +215,9 @@ var A11yWrapperElement = class extends A11yElement {
|
|
|
203
215
|
};
|
|
204
216
|
|
|
205
217
|
// src/core/dom-sync.ts
|
|
218
|
+
function syncText(el, text) {
|
|
219
|
+
if (el.textContent !== text) el.textContent = text;
|
|
220
|
+
}
|
|
206
221
|
function syncAttr(el, name, value) {
|
|
207
222
|
if (value == null) {
|
|
208
223
|
if (el.hasAttribute(name)) el.removeAttribute(name);
|
|
@@ -215,21 +230,174 @@ function syncClass(el, name, present) {
|
|
|
215
230
|
}
|
|
216
231
|
|
|
217
232
|
// src/components/picture/picture.element.ts
|
|
233
|
+
var GENERATED = "data-a11y-generated";
|
|
218
234
|
var PictureElement = class extends A11yWrapperElement {
|
|
235
|
+
static get observedAttributes() {
|
|
236
|
+
return ["src", "alt", "sources", "caption", "width", "height", "loading", "sizes"];
|
|
237
|
+
}
|
|
238
|
+
/** Sources set as a property; `null` falls back to the `sources` attribute. */
|
|
239
|
+
_sources = null;
|
|
240
|
+
/** The `sources` attribute value last parsed, and the result — parsed (and warned about) once per value. */
|
|
241
|
+
_parsed = [null, []];
|
|
242
|
+
_warnedAlt = false;
|
|
243
|
+
/** The fallback image. Setting it switches to generated mode. */
|
|
244
|
+
get src() {
|
|
245
|
+
return this.stringAttr("src");
|
|
246
|
+
}
|
|
247
|
+
set src(value) {
|
|
248
|
+
this._setOptionalAttr("src", value);
|
|
249
|
+
}
|
|
250
|
+
get alt() {
|
|
251
|
+
return this.stringAttr("alt");
|
|
252
|
+
}
|
|
253
|
+
set alt(value) {
|
|
254
|
+
if (value == null) this.removeAttribute("alt");
|
|
255
|
+
else this.setAttribute("alt", value);
|
|
256
|
+
}
|
|
257
|
+
get caption() {
|
|
258
|
+
return this.stringAttr("caption");
|
|
259
|
+
}
|
|
260
|
+
set caption(value) {
|
|
261
|
+
this._setOptionalAttr("caption", value);
|
|
262
|
+
}
|
|
263
|
+
get width() {
|
|
264
|
+
return this._optionalNumber("width");
|
|
265
|
+
}
|
|
266
|
+
set width(value) {
|
|
267
|
+
this._setOptionalAttr("width", value);
|
|
268
|
+
}
|
|
269
|
+
get height() {
|
|
270
|
+
return this._optionalNumber("height");
|
|
271
|
+
}
|
|
272
|
+
set height(value) {
|
|
273
|
+
this._setOptionalAttr("height", value);
|
|
274
|
+
}
|
|
275
|
+
get loading() {
|
|
276
|
+
return this.getAttribute("loading") === "eager" ? "eager" : "lazy";
|
|
277
|
+
}
|
|
278
|
+
set loading(value) {
|
|
279
|
+
this._setOptionalAttr("loading", value);
|
|
280
|
+
}
|
|
281
|
+
/** Set as a property, or parsed from the `sources` attribute (`url type` pairs, comma-separated). */
|
|
282
|
+
get sources() {
|
|
283
|
+
if (this._sources) return this._sources;
|
|
284
|
+
const value = this.getAttribute("sources");
|
|
285
|
+
if (this._parsed[0] !== value) this._parsed = [value, parseSources(value)];
|
|
286
|
+
return this._parsed[1];
|
|
287
|
+
}
|
|
288
|
+
/** Overrides the `sources` attribute until it changes. Needed for srcset descriptors, `media` or `sizes`. */
|
|
289
|
+
set sources(value) {
|
|
290
|
+
this._sources = value ? value.map((source) => ({ ...source })) : null;
|
|
291
|
+
if (this._connected) this._sync();
|
|
292
|
+
}
|
|
293
|
+
/** Sets the whole picture at once — sources, fallback, alt and the optional fields — in one sync. */
|
|
294
|
+
set image(image) {
|
|
295
|
+
this._sources = (image.sources ?? []).map((source) => ({ ...source }));
|
|
296
|
+
const connected = this._connected;
|
|
297
|
+
this._connected = false;
|
|
298
|
+
try {
|
|
299
|
+
this.src = image.fallback;
|
|
300
|
+
this.alt = image.alt;
|
|
301
|
+
this.caption = image.caption ?? "";
|
|
302
|
+
this.width = image.width;
|
|
303
|
+
this.height = image.height;
|
|
304
|
+
this.loading = image.loading ?? "lazy";
|
|
305
|
+
} finally {
|
|
306
|
+
this._connected = connected;
|
|
307
|
+
}
|
|
308
|
+
if (connected) this._sync();
|
|
309
|
+
}
|
|
310
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
311
|
+
if (name === "sources" && oldValue !== newValue) this._sources = null;
|
|
312
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
313
|
+
}
|
|
219
314
|
observerInit() {
|
|
220
315
|
return { childList: true, subtree: true, attributes: true, attributeFilter: ["alt"] };
|
|
221
316
|
}
|
|
222
317
|
_sync() {
|
|
223
|
-
const
|
|
318
|
+
const generated = this.hasAttribute("src");
|
|
319
|
+
if (generated) this._syncGenerated();
|
|
320
|
+
else this._removeGenerated();
|
|
321
|
+
const img = generated ? this.querySelector(`:scope > picture[${GENERATED}] > img`) : this.querySelector("img");
|
|
224
322
|
if (!img) return;
|
|
225
323
|
syncClass(this, "a11y-picture", true);
|
|
226
324
|
syncAttr(this, "role", "figure");
|
|
227
|
-
const caption = this.querySelector("figcaption");
|
|
325
|
+
const caption = generated ? this.querySelector(`:scope > figcaption[${GENERATED}]`) : this.querySelector("figcaption");
|
|
228
326
|
const hasCaption = !!caption?.textContent?.trim();
|
|
229
327
|
const isDecorative = img.getAttribute("alt") === "" && !hasCaption;
|
|
230
328
|
syncAttr(this, "aria-hidden", isDecorative ? "true" : null);
|
|
231
329
|
}
|
|
330
|
+
/** Builds `<picture>` (sources, then the fallback `<img>`) and the caption from this element's attributes/properties. */
|
|
331
|
+
_syncGenerated() {
|
|
332
|
+
let picture = this.querySelector(`:scope > picture[${GENERATED}]`);
|
|
333
|
+
if (!picture) {
|
|
334
|
+
picture = document.createElement("picture");
|
|
335
|
+
picture.setAttribute(GENERATED, "");
|
|
336
|
+
picture.append(document.createElement("img"));
|
|
337
|
+
this.prepend(picture);
|
|
338
|
+
}
|
|
339
|
+
const img = picture.querySelector(":scope > img");
|
|
340
|
+
const sources = this.sources.filter((source) => source.src);
|
|
341
|
+
let elements = [...picture.querySelectorAll(":scope > source")];
|
|
342
|
+
while (elements.length < sources.length) {
|
|
343
|
+
const source = document.createElement("source");
|
|
344
|
+
img.before(source);
|
|
345
|
+
elements.push(source);
|
|
346
|
+
}
|
|
347
|
+
for (const extra of elements.splice(sources.length)) extra.remove();
|
|
348
|
+
sources.forEach((source, i) => {
|
|
349
|
+
const el = elements[i];
|
|
350
|
+
syncAttr(el, "srcset", source.src);
|
|
351
|
+
syncAttr(el, "type", source.type || null);
|
|
352
|
+
syncAttr(el, "media", source.media || null);
|
|
353
|
+
syncAttr(el, "sizes", source.sizes || null);
|
|
354
|
+
});
|
|
355
|
+
syncAttr(img, "sizes", this.getAttribute("sizes"));
|
|
356
|
+
syncAttr(img, "width", this.getAttribute("width"));
|
|
357
|
+
syncAttr(img, "height", this.getAttribute("height"));
|
|
358
|
+
syncAttr(img, "loading", this.loading);
|
|
359
|
+
syncAttr(img, "decoding", "async");
|
|
360
|
+
syncAttr(img, "alt", this.getAttribute("alt") ?? "");
|
|
361
|
+
syncAttr(img, "src", this.src);
|
|
362
|
+
if (!this.hasAttribute("alt") && !this._warnedAlt) {
|
|
363
|
+
this._warnedAlt = true;
|
|
364
|
+
console.warn('<a11y-picture> has no alt \u2014 describe the image, or set alt="" if it is decorative.');
|
|
365
|
+
}
|
|
366
|
+
let caption = this.querySelector(`:scope > figcaption[${GENERATED}]`);
|
|
367
|
+
const text = this.caption.trim();
|
|
368
|
+
if (!text) {
|
|
369
|
+
caption?.remove();
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (!caption) {
|
|
373
|
+
caption = document.createElement("figcaption");
|
|
374
|
+
caption.setAttribute(GENERATED, "");
|
|
375
|
+
}
|
|
376
|
+
if (caption.previousElementSibling !== picture) picture.after(caption);
|
|
377
|
+
syncText(caption, text);
|
|
378
|
+
}
|
|
379
|
+
_removeGenerated() {
|
|
380
|
+
for (const el of this.querySelectorAll(`:scope > [${GENERATED}]`)) el.remove();
|
|
381
|
+
}
|
|
382
|
+
_setOptionalAttr(name, value) {
|
|
383
|
+
if (value == null || value === "") this.removeAttribute(name);
|
|
384
|
+
else this.setAttribute(name, String(value));
|
|
385
|
+
}
|
|
386
|
+
_optionalNumber(name) {
|
|
387
|
+
const value = Number(this.getAttribute(name) ?? NaN);
|
|
388
|
+
return Number.isNaN(value) ? void 0 : value;
|
|
389
|
+
}
|
|
232
390
|
};
|
|
391
|
+
function parseSources(value) {
|
|
392
|
+
if (!value) return [];
|
|
393
|
+
const sources = [];
|
|
394
|
+
for (const entry of value.split(",").map((part) => part.trim()).filter(Boolean)) {
|
|
395
|
+
const match = entry.match(/^(\S+)\s+([\w-]+\/[\w.+-]+)$/);
|
|
396
|
+
if (match) sources.push({ src: match[1], type: match[2] });
|
|
397
|
+
else console.warn(`<a11y-picture> ignored the source "${entry}": write "url type", e.g. "hero.avif image/avif".`);
|
|
398
|
+
}
|
|
399
|
+
return sources;
|
|
400
|
+
}
|
|
233
401
|
|
|
234
402
|
// src/components/picture/define.ts
|
|
235
403
|
if (!customElements.get("a11y-picture")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/strings.ts","../../../../src/core/a11y-element.ts","../../../../src/core/a11y-wrapper-element.ts","../../../../src/core/dom-sync.ts","../../../../src/components/picture/picture.element.ts","../../../../src/components/picture/define.ts"],"sourcesContent":["/**\n * The library's built-in, user-facing strings — text that ends up in\n * accessible names and announcements — so a consumer can translate them.\n *\n * Precedence, per element: an instance attribute (e.g. `close-label`) wins,\n * then whatever `setStrings()` set, then these English defaults.\n */\nexport interface A11yStrings {\n /** Appended to a new-tab link's accessible name by `<a11y-anchor>`. */\n opensInNewTab: string;\n /** `<a11y-anchor>`'s same-page jump announcement; `{name}` is the target's name. */\n navigatedTo: string;\n /** The close button of `<a11y-modal>`, `<a11y-drawer>` and `<a11y-emergency-dialog>`. */\n closeDialog: string;\n /** The close button of each `<a11y-notification-banner>` item. */\n dismiss: string;\n /** Default label of `<a11y-spinner>` and `<a11y-blocking-loader>`. */\n loading: string;\n /** Default accessible name of `<a11y-progress>`. */\n progress: string;\n /** Last-resort accessible name of `<a11y-avatar>`. */\n avatar: string;\n /** Visible text of an `<a11y-counter>`; `{count}` is the current length, `{max}` the `maxlength`. */\n characterCount: string;\n /** What an `<a11y-counter>` announces near the limit; `{count}` is the number of characters left. */\n charactersRemaining: string;\n /** `charactersRemaining` when exactly one character is left. */\n characterRemaining: string;\n}\n\nexport const DEFAULT_STRINGS: Readonly<A11yStrings> = Object.freeze({\n opensInNewTab: '(opens in new tab)',\n navigatedTo: 'Navigated to {name}',\n closeDialog: 'Close dialog',\n dismiss: 'Dismiss',\n loading: 'Loading',\n progress: 'Progress',\n avatar: 'Avatar',\n characterCount: '{count} / {max}',\n charactersRemaining: '{count} characters remaining',\n characterRemaining: '{count} character remaining',\n});\n\n/** Dispatched on `document` whenever `setStrings()`/`resetStrings()` runs, so mounted elements can relabel themselves. */\nexport const STRINGS_CHANGE_EVENT = 'a11y-strings-change';\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone `dist/browser/**\\/define.js` bundle inlines its own copy of\n * this module, and `setStrings()` called through one bundle must reach the\n * elements every other bundle defined.\n */\nconst STRINGS_KEY = Symbol.for('a11y-elements/strings');\nconst store = globalThis as unknown as Record<symbol, A11yStrings | undefined>;\nconst strings: A11yStrings = (store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS });\n// A store created by an older bundle on the same page predates newer keys.\nfor (const [key, value] of Object.entries(DEFAULT_STRINGS) as [keyof A11yStrings, string][]) strings[key] ??= value;\n\n/** Overrides some or all built-in strings, page-wide. Elements already on the page update right away. */\nexport function setStrings(partial: Partial<A11yStrings>): void {\n for (const [key, value] of Object.entries(partial) as [keyof A11yStrings, string | undefined][]) {\n if (key in DEFAULT_STRINGS && typeof value === 'string') strings[key] = value;\n }\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\n/** Restores every built-in string to its English default. */\nexport function resetStrings(): void {\n Object.assign(strings, DEFAULT_STRINGS);\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\nexport function getString(key: keyof A11yStrings): string {\n return strings[key];\n}\n\n/** Replaces each `{key}` placeholder with `values[key]`; placeholders without a value are left as is. */\nexport function formatString(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? values[key]! : match));\n}\n","import { STRINGS_CHANGE_EVENT } from './strings.js';\nimport type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n * setStrings() -> onStringsChange(), for subclasses that define it\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */\n private _cssVarOwned = new Map<string, string>();\n /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */\n private _stringsListener: EventListener | null = null;\n\n connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n this._stringsListener = null;\n this.onDisconnect?.();\n }\n\n /**\n * Connect-time setup shared by every base class. Every `connectedCallback`\n * override that doesn't call super must call this itself, before setting\n * `_connected` (so replayed setters only write attributes, and the normal\n * connect path then acts on them).\n */\n protected _initConnect(): void {\n this._upgradeProperties();\n this._watchStrings();\n }\n\n /**\n * A property set on the element before its class was defined (e.g.\n * `el.open = true` before a lazy-loaded bundle runs) is an own property\n * that shadows the class accessor. Replay each one through the setter.\n */\n private _upgradeProperties(): void {\n for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;\n const self = this as unknown as Record<string, unknown>;\n const value = self[name];\n delete self[name];\n self[name] = value;\n }\n }\n }\n\n /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */\n private _watchStrings(): void {\n if (!this.onStringsChange || this._stringsListener) return;\n this._stringsListener = () => {\n if (this._connected) this.onStringsChange?.();\n };\n document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /** Runs after `setStrings()`/`resetStrings()` while connected. Define it to re-apply any built-in string this element shows. */\n protected onStringsChange?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /**\n * Sets a CSS custom property on this element while `value` is truthy. When\n * it isn't, only a property this method set itself is undone — restored to\n * the consumer's own inline value from before (or removed if there was\n * none) — so a consumer's `style=\"--a11y-…: …\"` survives when the matching\n * attribute is absent.\n */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) {\n if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));\n this.style.setProperty(name, value);\n return;\n }\n if (!this._cssVarOwned.has(name)) return;\n const previous = this._cssVarOwned.get(name)!;\n this._cssVarOwned.delete(name);\n if (previous) this.style.setProperty(name, previous);\n else this.style.removeProperty(name);\n }\n}\n","import { A11yElement } from './a11y-element.js';\n\n/**\n * Base for elements that enhance real, consumer-authored light-DOM children\n * instead of generating their own markup from a template string — e.g. a\n * `<a11y-picture>` wrapping a real `<picture>`/`<img>`/`<figcaption>`, or\n * `<a11y-select>` wrapping a real `<select>`/`<option>`s.\n *\n * Unlike `A11yElement`, this never sets `innerHTML` from a `render()`\n * string — that would destroy the author's children — so it opts out of the\n * normal render pipeline and instead re-syncs (`_sync()`) from two sources:\n *\n * - **This element's own observed attributes** (e.g. `label`, `legend`),\n * listed via `static observedAttributes` same as any other element —\n * these re-sync *synchronously*, matching every other element in this\n * library, so `el.setAttribute('label', 'x')` takes effect immediately.\n * - **Everything else** (children added/removed, an attribute changing on\n * one of *those* children) — light DOM has no `slotchange`, so a\n * `MutationObserver` is the equivalent, necessarily asynchronous (a real\n * microtask/task delay after the mutation).\n *\n * `_sync()` runs inside that `MutationObserver` callback, so every DOM write\n * it makes must be guarded (see `core/dom-sync.ts`) — `setAttribute`/\n * `classList.add`/`textContent =` all queue a mutation record even when the\n * value is unchanged, and an unguarded write would retrigger the observer\n * forever.\n */\nexport abstract class A11yWrapperElement extends A11yElement {\n private _observer: MutationObserver | null = null;\n /** Nodes already given their listeners since the last connect — see `wireOnce()`. */\n private _wiredNodes = new WeakSet<Node>();\n\n override connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this._sync();\n this._observer = new MutationObserver(() => this._sync());\n this._observer.observe(this, this.observerInit());\n }\n\n override disconnectedCallback(): void {\n this._observer?.disconnect();\n this._observer = null;\n super.disconnectedCallback(); // removes every `listen()` listener…\n this._wiredNodes = new WeakSet(); // …so the next connect must wire them again\n }\n\n override attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this._sync();\n }\n\n /**\n * Runs `wire` the first time `node` is seen since this element was last\n * connected. `_sync()` runs on every mutation, so listener setup must be\n * idempotent — but those listeners (added via `listen()`) are all removed\n * on disconnect, so the \"already wired\" memory must reset with them, or a\n * reparented element (disconnect + connect) would silently stop firing.\n */\n protected wireOnce(node: Node, wire: () => void): void {\n if (this._wiredNodes.has(node)) return;\n this._wiredNodes.add(node);\n wire();\n }\n\n /** What to watch for changes worth re-syncing on. Override for a narrower/wider scope. */\n protected observerInit(): MutationObserverInit {\n return { childList: true, subtree: true, attributes: true };\n }\n\n /** Re-derive this element's own attributes/classes from its current children. */\n protected abstract _sync(): void;\n\n /** Unused — content is the author's own children, never replaced. */\n protected override render(): string {\n return '';\n }\n}\n","/**\n * Guarded DOM writes for use inside `A11yWrapperElement._sync()` methods (or\n * anywhere else re-syncing against a live MutationObserver).\n *\n * `setAttribute`/`removeAttribute`/`classList.add`/`classList.remove`/\n * `textContent =` all queue a mutation record unconditionally — even when\n * the value being written is identical to what's already there. Call one of\n * these unguarded inside a MutationObserver callback that's itself watching\n * the element being written to, and every \"no-op\" write retriggers the\n * observer, forever. These helpers check first, so a `_sync()` call that\n * changes nothing produces zero mutations and the observer loop terminates.\n */\n\nexport function syncText(el: Element, text: string): void {\n if (el.textContent !== text) el.textContent = text;\n}\n\nexport function syncAttr(el: Element, name: string, value: string | null | undefined): void {\n if (value == null) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else if (el.getAttribute(name) !== value) {\n el.setAttribute(name, value);\n }\n}\n\nexport function syncClass(el: Element, name: string, present: boolean): void {\n if (el.classList.contains(name) !== present) el.classList.toggle(name, present);\n}\n\n/**\n * Adds or removes one id in an id-reference list attribute (`aria-describedby`,\n * `aria-labelledby`, …), keeping every other token — typically ids the\n * consumer set — in place. Removes the attribute once the list is empty.\n */\nexport function syncIdRef(el: Element, name: string, id: string, present: boolean): void {\n const ids = (el.getAttribute(name) ?? '').split(/\\s+/).filter(Boolean);\n const has = ids.includes(id);\n if (has === present) return;\n const next = present ? [...ids, id] : ids.filter((token) => token !== id);\n syncAttr(el, name, next.length ? next.join(' ') : null);\n}\n","import { A11yWrapperElement } from '../../core/a11y-wrapper-element.js';\nimport { syncAttr, syncClass } from '../../core/dom-sync.js';\n\n/**\n * An accessible figure wrapper around a real `<picture>`/`<img>` (and an\n * optional `<figcaption>`) authored directly by the consumer — native HTML\n * already handles responsive source selection via real `<source>` children,\n * so this element's only job is accessibility: it toggles `aria-hidden`\n * automatically when the image is decorative (an empty `alt` and no\n * caption), the same rule the old framework-driven version used.\n *\n * ```html\n * <a11y-picture>\n * <picture>\n * <source srcset=\"hero.webp\" type=\"image/webp\">\n * <img src=\"hero.jpg\" alt=\"Sunset over the Rockies\" loading=\"lazy\" decoding=\"async\">\n * </picture>\n * <figcaption>Sunset over the Rockies</figcaption>\n * </a11y-picture>\n * ```\n */\nexport class PictureElement extends A11yWrapperElement {\n protected override observerInit(): MutationObserverInit {\n return { childList: true, subtree: true, attributes: true, attributeFilter: ['alt'] };\n }\n\n protected override _sync(): void {\n const img = this.querySelector('img');\n if (!img) return;\n\n // Guarded writes: this runs inside a MutationObserver callback watching\n // this subtree, and setAttribute/classList.add queue a mutation record\n // even when the value is unchanged — unguarded, that retriggers the\n // observer forever. The attributeFilter above already keeps this element's\n // own writes (role/class/aria-hidden) out of scope, but staying guarded\n // here too means that isn't load-bearing for correctness.\n syncClass(this, 'a11y-picture', true);\n syncAttr(this, 'role', 'figure');\n\n const caption = this.querySelector('figcaption');\n const hasCaption = !!caption?.textContent?.trim();\n const isDecorative = img.getAttribute('alt') === '' && !hasCaption;\n\n syncAttr(this, 'aria-hidden', isDecorative ? 'true' : null);\n }\n}\n","import { PictureElement } from './picture.element.js';\n\nif (!customElements.get('a11y-picture')) {\n customElements.define('a11y-picture', PictureElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-picture': PictureElement;\n }\n}\n\nexport { PictureElement };\n// Re-exported so zero-build `<script type=\"module\">` users can reach them too.\nexport { resetStrings, setStrings } from '../../core/strings.js';\n"],"mappings":";AA8BO,IAAM,kBAAyC,OAAO,OAAO;AAAA,EAClE,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AACtB,CAAC;AAGM,IAAM,uBAAuB;AAQpC,IAAM,cAAc,uBAAO,IAAI,uBAAuB;AACtD,IAAM,QAAQ;AACd,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,MAAM,QAAQ,QAAQ;AAE/B,UAAM,UAAU,KAAK,cAAc,YAAY;AAC/C,UAAM,aAAa,CAAC,CAAC,SAAS,aAAa,KAAK;AAChD,UAAM,eAAe,IAAI,aAAa,KAAK,MAAM,MAAM,CAAC;AAExD,aAAS,MAAM,eAAe,eAAe,SAAS,IAAI;AAAA,EAC5D;AACF;;;AC3CA,IAAI,CAAC,eAAe,IAAI,cAAc,GAAG;AACvC,iBAAe,OAAO,gBAAgB,cAAc;AACtD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/strings.ts","../../../../src/core/a11y-element.ts","../../../../src/core/a11y-wrapper-element.ts","../../../../src/core/dom-sync.ts","../../../../src/components/picture/picture.element.ts","../../../../src/components/picture/define.ts"],"sourcesContent":["/**\n * The library's built-in, user-facing strings — text that ends up in\n * accessible names and announcements — so a consumer can translate them.\n *\n * Precedence, per element: an instance attribute (e.g. `close-label`) wins,\n * then whatever `setStrings()` set, then these English defaults.\n */\nexport interface A11yStrings {\n /** Appended to a new-tab link's accessible name by `<a11y-anchor>`. */\n opensInNewTab: string;\n /** `<a11y-anchor>`'s same-page jump announcement; `{name}` is the target's name. */\n navigatedTo: string;\n /** The close button of `<a11y-modal>`, `<a11y-drawer>` and `<a11y-emergency-dialog>`. */\n closeDialog: string;\n /** The close button of each `<a11y-notification-banner>` item. */\n dismiss: string;\n /** Default label of `<a11y-spinner>` and `<a11y-blocking-loader>`. */\n loading: string;\n /** Default accessible name of `<a11y-progress>`. */\n progress: string;\n /** Last-resort accessible name of `<a11y-avatar>`. */\n avatar: string;\n /** Visible text of an `<a11y-counter>`; `{count}` is the current length, `{max}` the `maxlength`. */\n characterCount: string;\n /** What an `<a11y-counter>` announces near the limit; `{count}` is the number of characters left. */\n charactersRemaining: string;\n /** `charactersRemaining` when exactly one character is left. */\n characterRemaining: string;\n /** The generated \"Select all\" checkbox of `<a11y-checkbox-group select-all>`. */\n selectAll: string;\n /** The browse button of `<a11y-file-input>`. */\n browseFiles: string;\n /** The drag & drop prompt next to `<a11y-file-input>`'s browse button. */\n dropFiles: string;\n /** Accessible name of `<a11y-file-input>`'s list of selected files. */\n selectedFiles: string;\n /** Visible text of each remove button of `<a11y-file-input>`. */\n remove: string;\n /** Accessible name of each remove button of `<a11y-file-input>`; `{name}` is the file name. */\n removeFile: string;\n /** Announced when `<a11y-file-input>` adds one file; `{name}` is its name. */\n fileAdded: string;\n /** Announced when `<a11y-file-input>` adds several files; `{count}` is how many. */\n filesAdded: string;\n /** Announced when `<a11y-file-input>` removes a file; `{name}` is its name. */\n fileRemoved: string;\n /** Shown and announced for a file `accept` rules out; `{name}` is its name. */\n fileTypeRejected: string;\n /** Shown and announced for a file over `max-size`; `{name}`, `{maxSize}`. */\n fileSizeRejected: string;\n /** Shown and announced for a file past `max-files`; `{name}`, `{max}`. */\n fileCountRejected: string;\n}\n\nexport const DEFAULT_STRINGS: Readonly<A11yStrings> = Object.freeze({\n opensInNewTab: '(opens in new tab)',\n navigatedTo: 'Navigated to {name}',\n closeDialog: 'Close dialog',\n dismiss: 'Dismiss',\n loading: 'Loading',\n progress: 'Progress',\n avatar: 'Avatar',\n characterCount: '{count} / {max}',\n charactersRemaining: '{count} characters remaining',\n characterRemaining: '{count} character remaining',\n selectAll: 'Select all',\n browseFiles: 'Browse files',\n dropFiles: 'or drop files here',\n selectedFiles: 'Selected files',\n remove: 'Remove',\n removeFile: 'Remove {name}',\n fileAdded: '{name} added',\n filesAdded: '{count} files added',\n fileRemoved: '{name} removed',\n fileTypeRejected: '{name} wasn’t added: this type of file isn’t allowed',\n fileSizeRejected: '{name} wasn’t added: it’s larger than {maxSize}',\n fileCountRejected: '{name} wasn’t added: too many files (maximum {max})',\n});\n\n/** Dispatched on `document` whenever `setStrings()`/`resetStrings()` runs, so mounted elements can relabel themselves. */\nexport const STRINGS_CHANGE_EVENT = 'a11y-strings-change';\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone `dist/browser/**\\/define.js` bundle inlines its own copy of\n * this module, and `setStrings()` called through one bundle must reach the\n * elements every other bundle defined.\n */\nconst STRINGS_KEY = Symbol.for('a11y-elements/strings');\nconst store = globalThis as unknown as Record<symbol, A11yStrings | undefined>;\nconst strings: A11yStrings = (store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS });\n// A store created by an older bundle on the same page predates newer keys.\nfor (const [key, value] of Object.entries(DEFAULT_STRINGS) as [keyof A11yStrings, string][]) strings[key] ??= value;\n\n/** Overrides some or all built-in strings, page-wide. Elements already on the page update right away. */\nexport function setStrings(partial: Partial<A11yStrings>): void {\n for (const [key, value] of Object.entries(partial) as [keyof A11yStrings, string | undefined][]) {\n if (key in DEFAULT_STRINGS && typeof value === 'string') strings[key] = value;\n }\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\n/** Restores every built-in string to its English default. */\nexport function resetStrings(): void {\n Object.assign(strings, DEFAULT_STRINGS);\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\nexport function getString(key: keyof A11yStrings): string {\n return strings[key];\n}\n\n/** Replaces each `{key}` placeholder with `values[key]`; placeholders without a value are left as is. */\nexport function formatString(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? values[key]! : match));\n}\n","import { STRINGS_CHANGE_EVENT } from './strings.js';\nimport type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n * setStrings() -> onStringsChange(), for subclasses that define it\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */\n private _cssVarOwned = new Map<string, string>();\n /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */\n private _stringsListener: EventListener | null = null;\n\n connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n this._stringsListener = null;\n this.onDisconnect?.();\n }\n\n /**\n * Connect-time setup shared by every base class. Every `connectedCallback`\n * override that doesn't call super must call this itself, before setting\n * `_connected` (so replayed setters only write attributes, and the normal\n * connect path then acts on them).\n */\n protected _initConnect(): void {\n this._upgradeProperties();\n this._watchStrings();\n }\n\n /**\n * A property set on the element before its class was defined (e.g.\n * `el.open = true` before a lazy-loaded bundle runs) is an own property\n * that shadows the class accessor. Replay each one through the setter.\n */\n private _upgradeProperties(): void {\n for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;\n const self = this as unknown as Record<string, unknown>;\n const value = self[name];\n delete self[name];\n self[name] = value;\n }\n }\n }\n\n /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */\n private _watchStrings(): void {\n if (!this.onStringsChange || this._stringsListener) return;\n this._stringsListener = () => {\n if (this._connected) this.onStringsChange?.();\n };\n document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /** Runs after `setStrings()`/`resetStrings()` while connected. Define it to re-apply any built-in string this element shows. */\n protected onStringsChange?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /**\n * Sets a CSS custom property on this element while `value` is truthy. When\n * it isn't, only a property this method set itself is undone — restored to\n * the consumer's own inline value from before (or removed if there was\n * none) — so a consumer's `style=\"--a11y-…: …\"` survives when the matching\n * attribute is absent.\n */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) {\n if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));\n this.style.setProperty(name, value);\n return;\n }\n if (!this._cssVarOwned.has(name)) return;\n const previous = this._cssVarOwned.get(name)!;\n this._cssVarOwned.delete(name);\n if (previous) this.style.setProperty(name, previous);\n else this.style.removeProperty(name);\n }\n}\n","import { A11yElement } from './a11y-element.js';\n\n/**\n * Base for elements that enhance real, consumer-authored light-DOM children\n * instead of generating their own markup from a template string — e.g. a\n * `<a11y-picture>` wrapping a real `<picture>`/`<img>`/`<figcaption>`, or\n * `<a11y-select>` wrapping a real `<select>`/`<option>`s.\n *\n * Unlike `A11yElement`, this never sets `innerHTML` from a `render()`\n * string — that would destroy the author's children — so it opts out of the\n * normal render pipeline and instead re-syncs (`_sync()`) from two sources:\n *\n * - **This element's own observed attributes** (e.g. `label`, `legend`),\n * listed via `static observedAttributes` same as any other element —\n * these re-sync *synchronously*, matching every other element in this\n * library, so `el.setAttribute('label', 'x')` takes effect immediately.\n * - **Everything else** (children added/removed, an attribute changing on\n * one of *those* children) — light DOM has no `slotchange`, so a\n * `MutationObserver` is the equivalent, necessarily asynchronous (a real\n * microtask/task delay after the mutation).\n *\n * `_sync()` runs inside that `MutationObserver` callback, so every DOM write\n * it makes must be guarded (see `core/dom-sync.ts`) — `setAttribute`/\n * `classList.add`/`textContent =` all queue a mutation record even when the\n * value is unchanged, and an unguarded write would retrigger the observer\n * forever.\n */\nexport abstract class A11yWrapperElement extends A11yElement {\n private _observer: MutationObserver | null = null;\n /** Nodes already given their listeners since the last connect — see `wireOnce()`. */\n private _wiredNodes = new WeakSet<Node>();\n\n override connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this._sync();\n this._observer = new MutationObserver(() => this._sync());\n this._observer.observe(this, this.observerInit());\n }\n\n override disconnectedCallback(): void {\n this._observer?.disconnect();\n this._observer = null;\n super.disconnectedCallback(); // removes every `listen()` listener…\n this._wiredNodes = new WeakSet(); // …so the next connect must wire them again\n }\n\n override attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this._sync();\n }\n\n /**\n * Runs `wire` the first time `node` is seen since this element was last\n * connected. `_sync()` runs on every mutation, so listener setup must be\n * idempotent — but those listeners (added via `listen()`) are all removed\n * on disconnect, so the \"already wired\" memory must reset with them, or a\n * reparented element (disconnect + connect) would silently stop firing.\n */\n protected wireOnce(node: Node, wire: () => void): void {\n if (this._wiredNodes.has(node)) return;\n this._wiredNodes.add(node);\n wire();\n }\n\n /** What to watch for changes worth re-syncing on. Override for a narrower/wider scope. */\n protected observerInit(): MutationObserverInit {\n return { childList: true, subtree: true, attributes: true };\n }\n\n /** Re-derive this element's own attributes/classes from its current children. */\n protected abstract _sync(): void;\n\n /** Unused — content is the author's own children, never replaced. */\n protected override render(): string {\n return '';\n }\n}\n","/**\n * Guarded DOM writes for use inside `A11yWrapperElement._sync()` methods (or\n * anywhere else re-syncing against a live MutationObserver).\n *\n * `setAttribute`/`removeAttribute`/`classList.add`/`classList.remove`/\n * `textContent =` all queue a mutation record unconditionally — even when\n * the value being written is identical to what's already there. Call one of\n * these unguarded inside a MutationObserver callback that's itself watching\n * the element being written to, and every \"no-op\" write retriggers the\n * observer, forever. These helpers check first, so a `_sync()` call that\n * changes nothing produces zero mutations and the observer loop terminates.\n */\n\nexport function syncText(el: Element, text: string): void {\n if (el.textContent !== text) el.textContent = text;\n}\n\nexport function syncAttr(el: Element, name: string, value: string | null | undefined): void {\n if (value == null) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else if (el.getAttribute(name) !== value) {\n el.setAttribute(name, value);\n }\n}\n\nexport function syncClass(el: Element, name: string, present: boolean): void {\n if (el.classList.contains(name) !== present) el.classList.toggle(name, present);\n}\n\n/**\n * Adds or removes one id in an id-reference list attribute (`aria-describedby`,\n * `aria-labelledby`, …), keeping every other token — typically ids the\n * consumer set — in place. Removes the attribute once the list is empty.\n */\nexport function syncIdRef(el: Element, name: string, id: string, present: boolean): void {\n const ids = (el.getAttribute(name) ?? '').split(/\\s+/).filter(Boolean);\n const has = ids.includes(id);\n if (has === present) return;\n const next = present ? [...ids, id] : ids.filter((token) => token !== id);\n syncAttr(el, name, next.length ? next.join(' ') : null);\n}\n","import { A11yWrapperElement } from '../../core/a11y-wrapper-element.js';\nimport { syncAttr, syncClass, syncText } from '../../core/dom-sync.js';\n\n/** Marks the markup this element builds itself (in generated mode), so it never mixes it up with the consumer's. */\nconst GENERATED = 'data-a11y-generated';\n\n/** One `<source>` of a generated `<picture>`. */\nexport interface PictureSource {\n /** A URL, or a full srcset (`s.avif 1x, s@2x.avif 2x`). */\n src: string;\n /** The MIME type (`image/avif`), so the browser skips formats it can't decode. */\n type?: string;\n media?: string;\n sizes?: string;\n}\n\n/** Everything a generated picture needs, in one object — see `PictureElement.image`. */\nexport interface PictureImage {\n /** Tried in order: put the most efficient format first. */\n sources?: PictureSource[];\n /** The `<img>` src, used when no source's type is supported. */\n fallback: string;\n alt: string;\n caption?: string;\n width?: number;\n height?: number;\n loading?: 'lazy' | 'eager';\n}\n\n/**\n * An accessible figure around a picture: `role=\"figure\"`, and hidden from\n * assistive tech (`aria-hidden`) when the image is decorative — an empty\n * `alt` and no caption.\n *\n * The picture is either authored by the consumer — native HTML already\n * handles format and responsive selection through real `<source>` children:\n *\n * ```html\n * <a11y-picture>\n * <picture>\n * <source srcset=\"hero.webp\" type=\"image/webp\">\n * <img src=\"hero.jpg\" alt=\"Sunset over the Rockies\" loading=\"lazy\" decoding=\"async\">\n * </picture>\n * <figcaption>Sunset over the Rockies</figcaption>\n * </a11y-picture>\n * ```\n *\n * …or generated from attributes/properties, as soon as there's a `src` (the\n * fallback image). The browser uses the first source whose `type` it\n * supports, else the fallback:\n *\n * ```html\n * <a11y-picture src=\"s.jpg\" alt=\"S illustration\" sources=\"s.avif image/avif, s.webp image/webp\"></a11y-picture>\n * ```\n *\n * ```js\n * el.image = { sources: [{ src: 's.avif', type: 'image/avif' }], fallback: 's.jpg', alt: 'S illustration' };\n * ```\n *\n * Use one or the other: in generated mode, authored children are ignored.\n */\nexport class PictureElement extends A11yWrapperElement {\n static get observedAttributes(): string[] {\n return ['src', 'alt', 'sources', 'caption', 'width', 'height', 'loading', 'sizes'];\n }\n\n /** Sources set as a property; `null` falls back to the `sources` attribute. */\n private _sources: PictureSource[] | null = null;\n /** The `sources` attribute value last parsed, and the result — parsed (and warned about) once per value. */\n private _parsed: [value: string | null, sources: PictureSource[]] = [null, []];\n private _warnedAlt = false;\n\n /** The fallback image. Setting it switches to generated mode. */\n get src(): string {\n return this.stringAttr('src');\n }\n\n set src(value: string) {\n this._setOptionalAttr('src', value);\n }\n\n get alt(): string {\n return this.stringAttr('alt');\n }\n\n set alt(value: string) {\n // `''` is meaningful (decorative), so only null/undefined remove it.\n if (value == null) this.removeAttribute('alt');\n else this.setAttribute('alt', value);\n }\n\n get caption(): string {\n return this.stringAttr('caption');\n }\n\n set caption(value: string) {\n this._setOptionalAttr('caption', value);\n }\n\n get width(): number | undefined {\n return this._optionalNumber('width');\n }\n\n set width(value: number | undefined) {\n this._setOptionalAttr('width', value);\n }\n\n get height(): number | undefined {\n return this._optionalNumber('height');\n }\n\n set height(value: number | undefined) {\n this._setOptionalAttr('height', value);\n }\n\n get loading(): 'lazy' | 'eager' {\n return this.getAttribute('loading') === 'eager' ? 'eager' : 'lazy';\n }\n\n set loading(value: 'lazy' | 'eager') {\n this._setOptionalAttr('loading', value);\n }\n\n /** Set as a property, or parsed from the `sources` attribute (`url type` pairs, comma-separated). */\n get sources(): PictureSource[] {\n if (this._sources) return this._sources;\n const value = this.getAttribute('sources');\n if (this._parsed[0] !== value) this._parsed = [value, parseSources(value)];\n return this._parsed[1];\n }\n\n /** Overrides the `sources` attribute until it changes. Needed for srcset descriptors, `media` or `sizes`. */\n set sources(value: PictureSource[]) {\n this._sources = value ? value.map((source) => ({ ...source })) : null;\n if (this._connected) this._sync();\n }\n\n /** Sets the whole picture at once — sources, fallback, alt and the optional fields — in one sync. */\n set image(image: PictureImage) {\n this._sources = (image.sources ?? []).map((source) => ({ ...source }));\n const connected = this._connected;\n this._connected = false; // one sync at the end, not one per attribute\n try {\n this.src = image.fallback;\n this.alt = image.alt;\n this.caption = image.caption ?? '';\n this.width = image.width;\n this.height = image.height;\n this.loading = image.loading ?? 'lazy';\n } finally {\n this._connected = connected;\n }\n if (connected) this._sync();\n }\n\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (name === 'sources' && oldValue !== newValue) this._sources = null; // the attribute set last wins\n super.attributeChangedCallback(name, oldValue, newValue);\n }\n\n protected override observerInit(): MutationObserverInit {\n return { childList: true, subtree: true, attributes: true, attributeFilter: ['alt'] };\n }\n\n protected override _sync(): void {\n const generated = this.hasAttribute('src');\n if (generated) this._syncGenerated();\n else this._removeGenerated();\n\n const img = generated\n ? this.querySelector<HTMLImageElement>(`:scope > picture[${GENERATED}] > img`)\n : this.querySelector('img');\n if (!img) return;\n\n // Guarded writes: this runs inside a MutationObserver callback watching\n // this subtree, and setAttribute/classList.add queue a mutation record\n // even when the value is unchanged — unguarded, that retriggers the\n // observer forever. The attributeFilter above already keeps this element's\n // own writes (role/class/aria-hidden) out of scope, but staying guarded\n // here too means that isn't load-bearing for correctness.\n syncClass(this, 'a11y-picture', true);\n syncAttr(this, 'role', 'figure');\n\n const caption = generated ? this.querySelector(`:scope > figcaption[${GENERATED}]`) : this.querySelector('figcaption');\n const hasCaption = !!caption?.textContent?.trim();\n const isDecorative = img.getAttribute('alt') === '' && !hasCaption;\n\n syncAttr(this, 'aria-hidden', isDecorative ? 'true' : null);\n }\n\n /** Builds `<picture>` (sources, then the fallback `<img>`) and the caption from this element's attributes/properties. */\n private _syncGenerated(): void {\n let picture = this.querySelector<HTMLPictureElement>(`:scope > picture[${GENERATED}]`);\n if (!picture) {\n picture = document.createElement('picture');\n picture.setAttribute(GENERATED, '');\n picture.append(document.createElement('img'));\n this.prepend(picture);\n }\n const img = picture.querySelector<HTMLImageElement>(':scope > img')!;\n\n const sources = this.sources.filter((source) => source.src);\n let elements = [...picture.querySelectorAll<HTMLSourceElement>(':scope > source')];\n // Add or remove only the difference, so unchanged sources aren't reloaded.\n while (elements.length < sources.length) {\n const source = document.createElement('source');\n img.before(source);\n elements.push(source);\n }\n for (const extra of elements.splice(sources.length)) extra.remove();\n sources.forEach((source, i) => {\n const el = elements[i]!;\n syncAttr(el, 'srcset', source.src);\n syncAttr(el, 'type', source.type || null);\n syncAttr(el, 'media', source.media || null);\n syncAttr(el, 'sizes', source.sizes || null);\n });\n\n // Sizes first: the browser picks from srcset/src with them already known.\n syncAttr(img, 'sizes', this.getAttribute('sizes'));\n syncAttr(img, 'width', this.getAttribute('width'));\n syncAttr(img, 'height', this.getAttribute('height'));\n syncAttr(img, 'loading', this.loading);\n syncAttr(img, 'decoding', 'async');\n syncAttr(img, 'alt', this.getAttribute('alt') ?? '');\n syncAttr(img, 'src', this.src);\n if (!this.hasAttribute('alt') && !this._warnedAlt) {\n this._warnedAlt = true;\n console.warn('<a11y-picture> has no alt — describe the image, or set alt=\"\" if it is decorative.');\n }\n\n let caption = this.querySelector<HTMLElement>(`:scope > figcaption[${GENERATED}]`);\n const text = this.caption.trim();\n if (!text) {\n caption?.remove();\n return;\n }\n if (!caption) {\n caption = document.createElement('figcaption');\n caption.setAttribute(GENERATED, '');\n }\n if (caption.previousElementSibling !== picture) picture.after(caption);\n syncText(caption, text);\n }\n\n private _removeGenerated(): void {\n for (const el of this.querySelectorAll(`:scope > [${GENERATED}]`)) el.remove();\n }\n\n private _setOptionalAttr(name: string, value: string | number | null | undefined): void {\n if (value == null || value === '') this.removeAttribute(name);\n else this.setAttribute(name, String(value));\n }\n\n private _optionalNumber(name: string): number | undefined {\n const value = Number(this.getAttribute(name) ?? NaN);\n return Number.isNaN(value) ? undefined : value;\n }\n}\n\n/** `\"s.avif image/avif, s.webp image/webp\"` → sources. Entries that aren't `url type` are skipped, with a warning. */\nfunction parseSources(value: string | null): PictureSource[] {\n if (!value) return [];\n const sources: PictureSource[] = [];\n for (const entry of value.split(',').map((part) => part.trim()).filter(Boolean)) {\n const match = entry.match(/^(\\S+)\\s+([\\w-]+\\/[\\w.+-]+)$/);\n if (match) sources.push({ src: match[1]!, type: match[2]! });\n else console.warn(`<a11y-picture> ignored the source \"${entry}\": write \"url type\", e.g. \"hero.avif image/avif\".`);\n }\n return sources;\n}\n","import { PictureElement } from './picture.element.js';\n\nif (!customElements.get('a11y-picture')) {\n customElements.define('a11y-picture', PictureElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-picture': PictureElement;\n }\n}\n\nexport { PictureElement };\nexport type { PictureImage, PictureSource } from './picture.element.js';\n// Re-exported so zero-build `<script type=\"module\">` users can reach them too.\nexport { resetStrings, setStrings } from '../../core/strings.js';\n"],"mappings":";AAsDO,IAAM,kBAAyC,OAAO,OAAO;AAAA,EAClE,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,WAAW;AAAA,EACX,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA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MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EAAE,OAAO,OAAO,GAAG;AAC/E,UAAM,QAAQ,MAAM,MAAM,8BAA8B;AACxD,QAAI,MAAO,SAAQ,KAAK,EAAE,KAAK,MAAM,CAAC,GAAI,MAAM,MAAM,CAAC,EAAG,CAAC;AAAA,QACtD,SAAQ,KAAK,sCAAsC,KAAK,mDAAmD;AAAA,EAClH;AACA,SAAO;AACT;;;AC5QA,IAAI,CAAC,eAAe,IAAI,cAAc,GAAG;AACvC,iBAAe,OAAO,gBAAgB,cAAc;AACtD;","names":[]}
|
|
@@ -9,7 +9,19 @@ var DEFAULT_STRINGS = Object.freeze({
|
|
|
9
9
|
avatar: "Avatar",
|
|
10
10
|
characterCount: "{count} / {max}",
|
|
11
11
|
charactersRemaining: "{count} characters remaining",
|
|
12
|
-
characterRemaining: "{count} character remaining"
|
|
12
|
+
characterRemaining: "{count} character remaining",
|
|
13
|
+
selectAll: "Select all",
|
|
14
|
+
browseFiles: "Browse files",
|
|
15
|
+
dropFiles: "or drop files here",
|
|
16
|
+
selectedFiles: "Selected files",
|
|
17
|
+
remove: "Remove",
|
|
18
|
+
removeFile: "Remove {name}",
|
|
19
|
+
fileAdded: "{name} added",
|
|
20
|
+
filesAdded: "{count} files added",
|
|
21
|
+
fileRemoved: "{name} removed",
|
|
22
|
+
fileTypeRejected: "{name} wasn\u2019t added: this type of file isn\u2019t allowed",
|
|
23
|
+
fileSizeRejected: "{name} wasn\u2019t added: it\u2019s larger than {maxSize}",
|
|
24
|
+
fileCountRejected: "{name} wasn\u2019t added: too many files (maximum {max})"
|
|
13
25
|
});
|
|
14
26
|
var STRINGS_CHANGE_EVENT = "a11y-strings-change";
|
|
15
27
|
var STRINGS_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/strings");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/strings.ts","../../../../src/core/a11y-element.ts","../../../../src/core/template.ts","../../../../src/components/progress/progress.element.ts","../../../../src/components/progress/define.ts"],"sourcesContent":["/**\n * The library's built-in, user-facing strings — text that ends up in\n * accessible names and announcements — so a consumer can translate them.\n *\n * Precedence, per element: an instance attribute (e.g. `close-label`) wins,\n * then whatever `setStrings()` set, then these English defaults.\n */\nexport interface A11yStrings {\n /** Appended to a new-tab link's accessible name by `<a11y-anchor>`. */\n opensInNewTab: string;\n /** `<a11y-anchor>`'s same-page jump announcement; `{name}` is the target's name. */\n navigatedTo: string;\n /** The close button of `<a11y-modal>`, `<a11y-drawer>` and `<a11y-emergency-dialog>`. */\n closeDialog: string;\n /** The close button of each `<a11y-notification-banner>` item. */\n dismiss: string;\n /** Default label of `<a11y-spinner>` and `<a11y-blocking-loader>`. */\n loading: string;\n /** Default accessible name of `<a11y-progress>`. */\n progress: string;\n /** Last-resort accessible name of `<a11y-avatar>`. */\n avatar: string;\n /** Visible text of an `<a11y-counter>`; `{count}` is the current length, `{max}` the `maxlength`. */\n characterCount: string;\n /** What an `<a11y-counter>` announces near the limit; `{count}` is the number of characters left. */\n charactersRemaining: string;\n /** `charactersRemaining` when exactly one character is left. */\n characterRemaining: string;\n}\n\nexport const DEFAULT_STRINGS: Readonly<A11yStrings> = Object.freeze({\n opensInNewTab: '(opens in new tab)',\n navigatedTo: 'Navigated to {name}',\n closeDialog: 'Close dialog',\n dismiss: 'Dismiss',\n loading: 'Loading',\n progress: 'Progress',\n avatar: 'Avatar',\n characterCount: '{count} / {max}',\n charactersRemaining: '{count} characters remaining',\n characterRemaining: '{count} character remaining',\n});\n\n/** Dispatched on `document` whenever `setStrings()`/`resetStrings()` runs, so mounted elements can relabel themselves. */\nexport const STRINGS_CHANGE_EVENT = 'a11y-strings-change';\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone `dist/browser/**\\/define.js` bundle inlines its own copy of\n * this module, and `setStrings()` called through one bundle must reach the\n * elements every other bundle defined.\n */\nconst STRINGS_KEY = Symbol.for('a11y-elements/strings');\nconst store = globalThis as unknown as Record<symbol, A11yStrings | undefined>;\nconst strings: A11yStrings = (store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS });\n// A store created by an older bundle on the same page predates newer keys.\nfor (const [key, value] of Object.entries(DEFAULT_STRINGS) as [keyof A11yStrings, string][]) strings[key] ??= value;\n\n/** Overrides some or all built-in strings, page-wide. Elements already on the page update right away. */\nexport function setStrings(partial: Partial<A11yStrings>): void {\n for (const [key, value] of Object.entries(partial) as [keyof A11yStrings, string | undefined][]) {\n if (key in DEFAULT_STRINGS && typeof value === 'string') strings[key] = value;\n }\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\n/** Restores every built-in string to its English default. */\nexport function resetStrings(): void {\n Object.assign(strings, DEFAULT_STRINGS);\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\nexport function getString(key: keyof A11yStrings): string {\n return strings[key];\n}\n\n/** Replaces each `{key}` placeholder with `values[key]`; placeholders without a value are left as is. */\nexport function formatString(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? values[key]! : match));\n}\n","import { STRINGS_CHANGE_EVENT } from './strings.js';\nimport type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n * setStrings() -> onStringsChange(), for subclasses that define it\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */\n private _cssVarOwned = new Map<string, string>();\n /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */\n private _stringsListener: EventListener | null = null;\n\n connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n this._stringsListener = null;\n this.onDisconnect?.();\n }\n\n /**\n * Connect-time setup shared by every base class. Every `connectedCallback`\n * override that doesn't call super must call this itself, before setting\n * `_connected` (so replayed setters only write attributes, and the normal\n * connect path then acts on them).\n */\n protected _initConnect(): void {\n this._upgradeProperties();\n this._watchStrings();\n }\n\n /**\n * A property set on the element before its class was defined (e.g.\n * `el.open = true` before a lazy-loaded bundle runs) is an own property\n * that shadows the class accessor. Replay each one through the setter.\n */\n private _upgradeProperties(): void {\n for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;\n const self = this as unknown as Record<string, unknown>;\n const value = self[name];\n delete self[name];\n self[name] = value;\n }\n }\n }\n\n /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */\n private _watchStrings(): void {\n if (!this.onStringsChange || this._stringsListener) return;\n this._stringsListener = () => {\n if (this._connected) this.onStringsChange?.();\n };\n document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /** Runs after `setStrings()`/`resetStrings()` while connected. Define it to re-apply any built-in string this element shows. */\n protected onStringsChange?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /**\n * Sets a CSS custom property on this element while `value` is truthy. When\n * it isn't, only a property this method set itself is undone — restored to\n * the consumer's own inline value from before (or removed if there was\n * none) — so a consumer's `style=\"--a11y-…: …\"` survives when the matching\n * attribute is absent.\n */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) {\n if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));\n this.style.setProperty(name, value);\n return;\n }\n if (!this._cssVarOwned.has(name)) return;\n const previous = this._cssVarOwned.get(name)!;\n this._cssVarOwned.delete(name);\n if (previous) this.style.setProperty(name, previous);\n else this.style.removeProperty(name);\n }\n}\n","/**\n * Pre-trusted HTML: opts out of auto-escaping when interpolated into an\n * `html` tagged template, and stringifies back to that exact markup when\n * assigned to `innerHTML` or concatenated. `html\\`...\\`` itself returns one\n * of these, which is what makes nesting `html` calls inside another `html`\n * call safe by construction — the inner result is never re-escaped, no\n * caller discipline (remembering to wrap it) required.\n */\nexport interface Raw {\n readonly __html: string;\n toString(): string;\n}\n\n/** Wraps a string as pre-trusted HTML. Use only for markup you built yourself — never for raw user input. */\nexport function raw(value: string): Raw {\n return { __html: value, toString: () => value };\n}\n\nfunction isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && '__html' in value;\n}\n\nfunction escape(value: unknown): string {\n if (value == null || value === false) return '';\n if (isRaw(value)) return value.__html;\n if (Array.isArray(value)) return value.map(escape).join('');\n return String(value)\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n\n/**\n * Tagged template for building element markup. Literal template parts are\n * trusted structure; every interpolated value is HTML-escaped by default\n * (falsy values render as nothing, so `${cond && '<span>…</span>'}`-style\n * conditionals work without a directive attribute). Returns a `Raw`, so\n * nesting `html\\`...\\`` inside another `html\\`...\\`` template composes\n * safely without needing an explicit `raw()` wrapper.\n */\nexport function html(strings: TemplateStringsArray, ...values: unknown[]): Raw {\n return raw(strings.reduce((out, part, i) => out + part + escape(values[i]), ''));\n}\n\n/**\n * A `name=\"value\"` HTML attribute, with a leading space, escaped — or\n * nothing at all when `value` is `null`/`undefined`/`false`/`''`. Meant for\n * building conditional attribute lists inline:\n * `` html`<input${attr('id', id)}${flag('disabled', disabled)}>` ``\n */\nexport function attr(name: string, value: unknown): Raw {\n if (value == null || value === false || value === '') return raw('');\n return raw(` ${name}=\"${escape(value)}\"`);\n}\n\n/** A bare boolean attribute (e.g. `disabled`, `checked`), with a leading space, present only when `condition` is true. */\nexport function flag(name: string, condition: boolean | undefined): Raw {\n return raw(condition ? ` ${name}` : '');\n}\n","import { A11yElement } from '../../core/a11y-element.js';\nimport { getString } from '../../core/strings.js';\nimport { html } from '../../core/template.js';\n\nlet uidCounter = 0;\nconst nextLabelId = (): string => `a11y-progress-label-${++uidCounter}`;\n\n/**\n * A progress bar. `<a11y-progress value=\"50\" max=\"100\" label=\"Uploading…\"></a11y-progress>`\n *\n * The old version rendered a real `<label>` wrapping the `<progress>`, relying\n * on HTML's implicit label-wraps-control naming. A custom element can't\n * itself *be* a `<label>`, so the same accessible-name relationship is\n * expressed explicitly instead, via `aria-labelledby` pointing at the visible\n * label text — an equally robust, arguably more explicit equivalent.\n */\nexport class ProgressElement extends A11yElement {\n static get observedAttributes(): string[] {\n return ['value', 'max', 'label', 'aria-label'];\n }\n\n private _labelId = nextLabelId();\n\n get value(): number | undefined {\n const v = this.getAttribute('value');\n return v == null ? undefined : Number(v);\n }\n set value(v: number | undefined) {\n v == null ? this.removeAttribute('value') : this.setAttribute('value', String(v));\n }\n\n get max(): number {\n return this.numberAttr('max', 100);\n }\n set max(v: number) {\n this.setAttribute('max', String(v));\n }\n\n protected override onBeforeRender(): void {\n this.classList.add('a11y-progress');\n }\n\n protected override onStringsChange(): void {\n this.update();\n }\n\n protected override render(): string {\n const { value, max } = this;\n const label = this.optionalStringAttr('label');\n const ariaLabel = this.optionalStringAttr('aria-label');\n\n const labelMarkup = label ? html`<span class=\"a11y-progress__label\" id=\"${this._labelId}\">${label}</span>` : '';\n const progressAttrs = html`class=\"a11y-progress__bar\"${value !== undefined ? html` value=\"${value}\"` : ''} max=\"${max}\"${\n label ? html` aria-labelledby=\"${this._labelId}\"` : ariaLabel ? html` aria-label=\"${ariaLabel}\"` : html` aria-label=\"${getString('progress')}\"`\n }`;\n\n return `${labelMarkup}<progress ${progressAttrs}></progress>`;\n }\n}\n","import { ProgressElement } from './progress.element.js';\n\nif (!customElements.get('a11y-progress')) {\n customElements.define('a11y-progress', ProgressElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-progress': ProgressElement;\n }\n}\n\nexport { ProgressElement };\n// Re-exported so zero-build `<script type=\"module\">` users can reach them too.\nexport { resetStrings, setStrings } from '../../core/strings.js';\n"],"mappings":";AA8BO,IAAM,kBAAyC,OAAO,OAAO;AAAA,EAClE,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AACtB,CAAC;AAGM,IAAM,uBAAuB;AAQpC,IAAM,cAAc,uBAAO,IAAI,uBAAuB;AACtD,IAAM,QAAQ;AACd,IAAM,UAAwB,MAAM,WAAW,MAAM,EAAE,GAAG,gBAAgB;AAE1E,WAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,eAAe,EAAoC,SAAQ,GAAG,MAAM;AAGvG,SAAS,WAAW,SAAqC;AAC9D,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAgD;AAC/F,QAAI,OAAO,mBAAmB,OAAO,UAAU,SAAU,SAAQ,GAAG,IAAI;AAAA,EAC1E;AACA,WAAS,cAAc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AoB,SAAS,MAAM,oBAAoB,UAAU,UAAU,CAAC,GAC9I;AAEA,WAAO,GAAG,WAAW,aAAa,aAAa;AAAA,EACjD;AACF;;;ACxDA,IAAI,CAAC,eAAe,IAAI,eAAe,GAAG;AACxC,iBAAe,OAAO,iBAAiB,eAAe;AACxD;","names":["strings"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/strings.ts","../../../../src/core/a11y-element.ts","../../../../src/core/template.ts","../../../../src/components/progress/progress.element.ts","../../../../src/components/progress/define.ts"],"sourcesContent":["/**\n * The library's built-in, user-facing strings — text that ends up in\n * accessible names and announcements — so a consumer can translate them.\n *\n * Precedence, per element: an instance attribute (e.g. `close-label`) wins,\n * then whatever `setStrings()` set, then these English defaults.\n */\nexport interface A11yStrings {\n /** Appended to a new-tab link's accessible name by `<a11y-anchor>`. */\n opensInNewTab: string;\n /** `<a11y-anchor>`'s same-page jump announcement; `{name}` is the target's name. */\n navigatedTo: string;\n /** The close button of `<a11y-modal>`, `<a11y-drawer>` and `<a11y-emergency-dialog>`. */\n closeDialog: string;\n /** The close button of each `<a11y-notification-banner>` item. */\n dismiss: string;\n /** Default label of `<a11y-spinner>` and `<a11y-blocking-loader>`. */\n loading: string;\n /** Default accessible name of `<a11y-progress>`. */\n progress: string;\n /** Last-resort accessible name of `<a11y-avatar>`. */\n avatar: string;\n /** Visible text of an `<a11y-counter>`; `{count}` is the current length, `{max}` the `maxlength`. */\n characterCount: string;\n /** What an `<a11y-counter>` announces near the limit; `{count}` is the number of characters left. */\n charactersRemaining: string;\n /** `charactersRemaining` when exactly one character is left. */\n characterRemaining: string;\n /** The generated \"Select all\" checkbox of `<a11y-checkbox-group select-all>`. */\n selectAll: string;\n /** The browse button of `<a11y-file-input>`. */\n browseFiles: string;\n /** The drag & drop prompt next to `<a11y-file-input>`'s browse button. */\n dropFiles: string;\n /** Accessible name of `<a11y-file-input>`'s list of selected files. */\n selectedFiles: string;\n /** Visible text of each remove button of `<a11y-file-input>`. */\n remove: string;\n /** Accessible name of each remove button of `<a11y-file-input>`; `{name}` is the file name. */\n removeFile: string;\n /** Announced when `<a11y-file-input>` adds one file; `{name}` is its name. */\n fileAdded: string;\n /** Announced when `<a11y-file-input>` adds several files; `{count}` is how many. */\n filesAdded: string;\n /** Announced when `<a11y-file-input>` removes a file; `{name}` is its name. */\n fileRemoved: string;\n /** Shown and announced for a file `accept` rules out; `{name}` is its name. */\n fileTypeRejected: string;\n /** Shown and announced for a file over `max-size`; `{name}`, `{maxSize}`. */\n fileSizeRejected: string;\n /** Shown and announced for a file past `max-files`; `{name}`, `{max}`. */\n fileCountRejected: string;\n}\n\nexport const DEFAULT_STRINGS: Readonly<A11yStrings> = Object.freeze({\n opensInNewTab: '(opens in new tab)',\n navigatedTo: 'Navigated to {name}',\n closeDialog: 'Close dialog',\n dismiss: 'Dismiss',\n loading: 'Loading',\n progress: 'Progress',\n avatar: 'Avatar',\n characterCount: '{count} / {max}',\n charactersRemaining: '{count} characters remaining',\n characterRemaining: '{count} character remaining',\n selectAll: 'Select all',\n browseFiles: 'Browse files',\n dropFiles: 'or drop files here',\n selectedFiles: 'Selected files',\n remove: 'Remove',\n removeFile: 'Remove {name}',\n fileAdded: '{name} added',\n filesAdded: '{count} files added',\n fileRemoved: '{name} removed',\n fileTypeRejected: '{name} wasn’t added: this type of file isn’t allowed',\n fileSizeRejected: '{name} wasn’t added: it’s larger than {maxSize}',\n fileCountRejected: '{name} wasn’t added: too many files (maximum {max})',\n});\n\n/** Dispatched on `document` whenever `setStrings()`/`resetStrings()` runs, so mounted elements can relabel themselves. */\nexport const STRINGS_CHANGE_EVENT = 'a11y-strings-change';\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone `dist/browser/**\\/define.js` bundle inlines its own copy of\n * this module, and `setStrings()` called through one bundle must reach the\n * elements every other bundle defined.\n */\nconst STRINGS_KEY = Symbol.for('a11y-elements/strings');\nconst store = globalThis as unknown as Record<symbol, A11yStrings | undefined>;\nconst strings: A11yStrings = (store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS });\n// A store created by an older bundle on the same page predates newer keys.\nfor (const [key, value] of Object.entries(DEFAULT_STRINGS) as [keyof A11yStrings, string][]) strings[key] ??= value;\n\n/** Overrides some or all built-in strings, page-wide. Elements already on the page update right away. */\nexport function setStrings(partial: Partial<A11yStrings>): void {\n for (const [key, value] of Object.entries(partial) as [keyof A11yStrings, string | undefined][]) {\n if (key in DEFAULT_STRINGS && typeof value === 'string') strings[key] = value;\n }\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\n/** Restores every built-in string to its English default. */\nexport function resetStrings(): void {\n Object.assign(strings, DEFAULT_STRINGS);\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\nexport function getString(key: keyof A11yStrings): string {\n return strings[key];\n}\n\n/** Replaces each `{key}` placeholder with `values[key]`; placeholders without a value are left as is. */\nexport function formatString(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? values[key]! : match));\n}\n","import { STRINGS_CHANGE_EVENT } from './strings.js';\nimport type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n * setStrings() -> onStringsChange(), for subclasses that define it\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */\n private _cssVarOwned = new Map<string, string>();\n /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */\n private _stringsListener: EventListener | null = null;\n\n connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n this._stringsListener = null;\n this.onDisconnect?.();\n }\n\n /**\n * Connect-time setup shared by every base class. Every `connectedCallback`\n * override that doesn't call super must call this itself, before setting\n * `_connected` (so replayed setters only write attributes, and the normal\n * connect path then acts on them).\n */\n protected _initConnect(): void {\n this._upgradeProperties();\n this._watchStrings();\n }\n\n /**\n * A property set on the element before its class was defined (e.g.\n * `el.open = true` before a lazy-loaded bundle runs) is an own property\n * that shadows the class accessor. Replay each one through the setter.\n */\n private _upgradeProperties(): void {\n for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;\n const self = this as unknown as Record<string, unknown>;\n const value = self[name];\n delete self[name];\n self[name] = value;\n }\n }\n }\n\n /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */\n private _watchStrings(): void {\n if (!this.onStringsChange || this._stringsListener) return;\n this._stringsListener = () => {\n if (this._connected) this.onStringsChange?.();\n };\n document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /** Runs after `setStrings()`/`resetStrings()` while connected. Define it to re-apply any built-in string this element shows. */\n protected onStringsChange?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /**\n * Sets a CSS custom property on this element while `value` is truthy. When\n * it isn't, only a property this method set itself is undone — restored to\n * the consumer's own inline value from before (or removed if there was\n * none) — so a consumer's `style=\"--a11y-…: …\"` survives when the matching\n * attribute is absent.\n */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) {\n if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));\n this.style.setProperty(name, value);\n return;\n }\n if (!this._cssVarOwned.has(name)) return;\n const previous = this._cssVarOwned.get(name)!;\n this._cssVarOwned.delete(name);\n if (previous) this.style.setProperty(name, previous);\n else this.style.removeProperty(name);\n }\n}\n","/**\n * Pre-trusted HTML: opts out of auto-escaping when interpolated into an\n * `html` tagged template, and stringifies back to that exact markup when\n * assigned to `innerHTML` or concatenated. `html\\`...\\`` itself returns one\n * of these, which is what makes nesting `html` calls inside another `html`\n * call safe by construction — the inner result is never re-escaped, no\n * caller discipline (remembering to wrap it) required.\n */\nexport interface Raw {\n readonly __html: string;\n toString(): string;\n}\n\n/** Wraps a string as pre-trusted HTML. Use only for markup you built yourself — never for raw user input. */\nexport function raw(value: string): Raw {\n return { __html: value, toString: () => value };\n}\n\nfunction isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && '__html' in value;\n}\n\nfunction escape(value: unknown): string {\n if (value == null || value === false) return '';\n if (isRaw(value)) return value.__html;\n if (Array.isArray(value)) return value.map(escape).join('');\n return String(value)\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n\n/**\n * Tagged template for building element markup. Literal template parts are\n * trusted structure; every interpolated value is HTML-escaped by default\n * (falsy values render as nothing, so `${cond && '<span>…</span>'}`-style\n * conditionals work without a directive attribute). Returns a `Raw`, so\n * nesting `html\\`...\\`` inside another `html\\`...\\`` template composes\n * safely without needing an explicit `raw()` wrapper.\n */\nexport function html(strings: TemplateStringsArray, ...values: unknown[]): Raw {\n return raw(strings.reduce((out, part, i) => out + part + escape(values[i]), ''));\n}\n\n/**\n * A `name=\"value\"` HTML attribute, with a leading space, escaped — or\n * nothing at all when `value` is `null`/`undefined`/`false`/`''`. Meant for\n * building conditional attribute lists inline:\n * `` html`<input${attr('id', id)}${flag('disabled', disabled)}>` ``\n */\nexport function attr(name: string, value: unknown): Raw {\n if (value == null || value === false || value === '') return raw('');\n return raw(` ${name}=\"${escape(value)}\"`);\n}\n\n/** A bare boolean attribute (e.g. `disabled`, `checked`), with a leading space, present only when `condition` is true. */\nexport function flag(name: string, condition: boolean | undefined): Raw {\n return raw(condition ? ` ${name}` : '');\n}\n","import { A11yElement } from '../../core/a11y-element.js';\nimport { getString } from '../../core/strings.js';\nimport { html } from '../../core/template.js';\n\nlet uidCounter = 0;\nconst nextLabelId = (): string => `a11y-progress-label-${++uidCounter}`;\n\n/**\n * A progress bar. `<a11y-progress value=\"50\" max=\"100\" label=\"Uploading…\"></a11y-progress>`\n *\n * The old version rendered a real `<label>` wrapping the `<progress>`, relying\n * on HTML's implicit label-wraps-control naming. A custom element can't\n * itself *be* a `<label>`, so the same accessible-name relationship is\n * expressed explicitly instead, via `aria-labelledby` pointing at the visible\n * label text — an equally robust, arguably more explicit equivalent.\n */\nexport class ProgressElement extends A11yElement {\n static get observedAttributes(): string[] {\n return ['value', 'max', 'label', 'aria-label'];\n }\n\n private _labelId = nextLabelId();\n\n get value(): number | undefined {\n const v = this.getAttribute('value');\n return v == null ? undefined : Number(v);\n }\n set value(v: number | undefined) {\n v == null ? this.removeAttribute('value') : this.setAttribute('value', String(v));\n }\n\n get max(): number {\n return this.numberAttr('max', 100);\n }\n set max(v: number) {\n this.setAttribute('max', String(v));\n }\n\n protected override onBeforeRender(): void {\n this.classList.add('a11y-progress');\n }\n\n protected override onStringsChange(): void {\n this.update();\n }\n\n protected override render(): string {\n const { value, max } = this;\n const label = this.optionalStringAttr('label');\n const ariaLabel = this.optionalStringAttr('aria-label');\n\n const labelMarkup = label ? html`<span class=\"a11y-progress__label\" id=\"${this._labelId}\">${label}</span>` : '';\n const progressAttrs = html`class=\"a11y-progress__bar\"${value !== undefined ? html` value=\"${value}\"` : ''} max=\"${max}\"${\n label ? html` aria-labelledby=\"${this._labelId}\"` : ariaLabel ? html` aria-label=\"${ariaLabel}\"` : html` aria-label=\"${getString('progress')}\"`\n }`;\n\n return `${labelMarkup}<progress ${progressAttrs}></progress>`;\n }\n}\n","import { ProgressElement } from './progress.element.js';\n\nif (!customElements.get('a11y-progress')) {\n customElements.define('a11y-progress', ProgressElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-progress': ProgressElement;\n }\n}\n\nexport { ProgressElement };\n// Re-exported so zero-build `<script type=\"module\">` users can reach them too.\nexport { resetStrings, setStrings } from '../../core/strings.js';\n"],"mappings":";AAsDO,IAAM,kBAAyC,OAAO,OAAO;AAAA,EAClE,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,aAAa;AAAA,EACb,WAAW;AAAA,EACX,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,mBAAmB;AACrB,CAAC;AAGM,IAAM,uBAAuB;AAQpC,IAAM,cAAc,uBAAO,IAAI,uBAAuB;AACtD,IAAM,QAAQ;AACd,IAAM,UAAwB,MAAM,WAAW,MAAM,EAAE,GAAG,gBAAgB;AAE1E,WAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,eAAe,EAAoC,SAAQ,GAAG,MAAM;AAGvG,SAAS,WAAW,SAAqC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AAK,QAAQ,KAAK,KAAK,YAAY;AAC7G,UAAM,gBAAgB,iCAAiC,UAAU,SAAY,eAAe,KAAK,MAAM,EAAE,SAAS,GAAG,IACnH,QAAQ,yBAAyB,KAAK,QAAQ,MAAM,YAAY,oBAAoB,SAAS,MAAM,oBAAoB,UAAU,UAAU,CAAC,GAC9I;AAEA,WAAO,GAAG,WAAW,aAAa,aAAa;AAAA,EACjD;AACF;;;ACxDA,IAAI,CAAC,eAAe,IAAI,eAAe,GAAG;AACxC,iBAAe,OAAO,iBAAiB,eAAe;AACxD;","names":["strings"]}
|
|
@@ -9,7 +9,19 @@ var DEFAULT_STRINGS = Object.freeze({
|
|
|
9
9
|
avatar: "Avatar",
|
|
10
10
|
characterCount: "{count} / {max}",
|
|
11
11
|
charactersRemaining: "{count} characters remaining",
|
|
12
|
-
characterRemaining: "{count} character remaining"
|
|
12
|
+
characterRemaining: "{count} character remaining",
|
|
13
|
+
selectAll: "Select all",
|
|
14
|
+
browseFiles: "Browse files",
|
|
15
|
+
dropFiles: "or drop files here",
|
|
16
|
+
selectedFiles: "Selected files",
|
|
17
|
+
remove: "Remove",
|
|
18
|
+
removeFile: "Remove {name}",
|
|
19
|
+
fileAdded: "{name} added",
|
|
20
|
+
filesAdded: "{count} files added",
|
|
21
|
+
fileRemoved: "{name} removed",
|
|
22
|
+
fileTypeRejected: "{name} wasn\u2019t added: this type of file isn\u2019t allowed",
|
|
23
|
+
fileSizeRejected: "{name} wasn\u2019t added: it\u2019s larger than {maxSize}",
|
|
24
|
+
fileCountRejected: "{name} wasn\u2019t added: too many files (maximum {max})"
|
|
13
25
|
});
|
|
14
26
|
var STRINGS_CHANGE_EVENT = "a11y-strings-change";
|
|
15
27
|
var STRINGS_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/strings");
|
|
@@ -239,6 +251,8 @@ var RadioGroupElement = class extends A11yWrapperElement {
|
|
|
239
251
|
const fieldset = this._ensureFieldset();
|
|
240
252
|
for (const input of fieldset.querySelectorAll('input[type="radio"]')) {
|
|
241
253
|
syncClass(input, "a11y-radio__input", true);
|
|
254
|
+
const label = input.closest("label");
|
|
255
|
+
if (label && fieldset.contains(label)) syncClass(label, "a11y-radio-group__option", true);
|
|
242
256
|
}
|
|
243
257
|
syncAttr(fieldset, "disabled", this.boolAttr("disabled") ? "" : null);
|
|
244
258
|
this._syncLegend(fieldset);
|