@vectojs/core 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +60 -55
- package/dist/index.mjs +60 -55
- package/dist/tree/DOMPortalEntity.d.ts +1 -1
- package/dist/tree/Scene.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1214,6 +1214,13 @@ var Scene = (_class2 = class _Scene {
|
|
|
1214
1214
|
}
|
|
1215
1215
|
/** True when any node in the subtree has a pending animation. */
|
|
1216
1216
|
/** True when any node in the subtree is interactive (drives a11y sync). */
|
|
1217
|
+
syncOptionalAttribute(element, name, value) {
|
|
1218
|
+
if (value === void 0) {
|
|
1219
|
+
if (element.hasAttribute(name)) element.removeAttribute(name);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
if (element.getAttribute(name) !== value) element.setAttribute(name, value);
|
|
1223
|
+
}
|
|
1217
1224
|
syncA11y(node) {
|
|
1218
1225
|
if (!this.a11yRoot) return;
|
|
1219
1226
|
if (node.isDOMPortal) {
|
|
@@ -1380,12 +1387,8 @@ var Scene = (_class2 = class _Scene {
|
|
|
1380
1387
|
this.a11yElements.set(node.id, el);
|
|
1381
1388
|
this.a11yNeedsReorder = true;
|
|
1382
1389
|
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
if (attrs.label !== void 0 && el.getAttribute("aria-label") !== attrs.label) {
|
|
1387
|
-
el.setAttribute("aria-label", attrs.label);
|
|
1388
|
-
}
|
|
1390
|
+
this.syncOptionalAttribute(el, "role", attrs.role);
|
|
1391
|
+
this.syncOptionalAttribute(el, "aria-label", attrs.label);
|
|
1389
1392
|
const semanticPointerEvents = _nullishCoalesce(attrs.pointerEvents, () => ( "auto"));
|
|
1390
1393
|
if (el.style.pointerEvents !== semanticPointerEvents) {
|
|
1391
1394
|
el.style.pointerEvents = semanticPointerEvents;
|
|
@@ -1397,58 +1400,58 @@ var Scene = (_class2 = class _Scene {
|
|
|
1397
1400
|
} else if (el.getAttribute("tabindex") !== String(desiredTabIndex)) {
|
|
1398
1401
|
el.setAttribute("tabindex", String(desiredTabIndex));
|
|
1399
1402
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (el.placeholder !== attrs.placeholder) el.placeholder = attrs.placeholder;
|
|
1403
|
+
this.syncOptionalAttribute(el, "type", attrs.inputType);
|
|
1404
|
+
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
1405
|
+
const placeholder = _nullishCoalesce(attrs.placeholder, () => ( ""));
|
|
1406
|
+
if (el.placeholder !== placeholder) el.placeholder = placeholder;
|
|
1405
1407
|
}
|
|
1406
|
-
if (
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1408
|
+
if (el instanceof HTMLAnchorElement) {
|
|
1409
|
+
this.syncOptionalAttribute(
|
|
1410
|
+
el,
|
|
1411
|
+
"href",
|
|
1412
|
+
attrs.href === void 0 ? void 0 : _chunkBPMNCGU7js.sanitizeUrl.call(void 0, attrs.href)
|
|
1413
|
+
);
|
|
1414
|
+
this.syncOptionalAttribute(el, "target", attrs.target);
|
|
1412
1415
|
}
|
|
1413
1416
|
if (el instanceof HTMLImageElement) {
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
if (attrs.checked !== void 0) {
|
|
1418
|
-
if (el instanceof HTMLInputElement) {
|
|
1419
|
-
if (el.checked !== attrs.checked) el.checked = attrs.checked;
|
|
1420
|
-
} else if (el.getAttribute("aria-checked") !== String(attrs.checked)) {
|
|
1421
|
-
el.setAttribute("aria-checked", String(attrs.checked));
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
if (attrs.disabled !== void 0) {
|
|
1425
|
-
if ("disabled" in el) {
|
|
1426
|
-
if (el.disabled !== attrs.disabled) el.disabled = attrs.disabled;
|
|
1427
|
-
} else if (el.getAttribute("aria-disabled") !== String(attrs.disabled)) {
|
|
1428
|
-
el.setAttribute("aria-disabled", String(attrs.disabled));
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
if (attrs.expanded !== void 0 && el.getAttribute("aria-expanded") !== String(attrs.expanded)) {
|
|
1432
|
-
el.setAttribute("aria-expanded", String(attrs.expanded));
|
|
1417
|
+
this.syncOptionalAttribute(el, "src", attrs.src);
|
|
1418
|
+
this.syncOptionalAttribute(el, "alt", attrs.alt);
|
|
1433
1419
|
}
|
|
1434
|
-
if (
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
if (attrs.activedescendant !== void 0 && el.getAttribute("aria-activedescendant") !== attrs.activedescendant) {
|
|
1444
|
-
el.setAttribute("aria-activedescendant", attrs.activedescendant);
|
|
1445
|
-
}
|
|
1446
|
-
if (attrs.valuemin !== void 0 && el.getAttribute("aria-valuemin") !== attrs.valuemin) {
|
|
1447
|
-
el.setAttribute("aria-valuemin", attrs.valuemin);
|
|
1420
|
+
if (el instanceof HTMLInputElement) {
|
|
1421
|
+
const checked = _nullishCoalesce(attrs.checked, () => ( false));
|
|
1422
|
+
if (el.checked !== checked) el.checked = checked;
|
|
1423
|
+
} else {
|
|
1424
|
+
this.syncOptionalAttribute(
|
|
1425
|
+
el,
|
|
1426
|
+
"aria-checked",
|
|
1427
|
+
attrs.checked === void 0 ? void 0 : String(attrs.checked)
|
|
1428
|
+
);
|
|
1448
1429
|
}
|
|
1449
|
-
if (
|
|
1450
|
-
|
|
1430
|
+
if ("disabled" in el) {
|
|
1431
|
+
const disabled = _nullishCoalesce(attrs.disabled, () => ( false));
|
|
1432
|
+
if (el.disabled !== disabled) el.disabled = disabled;
|
|
1433
|
+
} else {
|
|
1434
|
+
this.syncOptionalAttribute(
|
|
1435
|
+
el,
|
|
1436
|
+
"aria-disabled",
|
|
1437
|
+
attrs.disabled === void 0 ? void 0 : String(attrs.disabled)
|
|
1438
|
+
);
|
|
1451
1439
|
}
|
|
1440
|
+
this.syncOptionalAttribute(
|
|
1441
|
+
el,
|
|
1442
|
+
"aria-expanded",
|
|
1443
|
+
attrs.expanded === void 0 ? void 0 : String(attrs.expanded)
|
|
1444
|
+
);
|
|
1445
|
+
this.syncOptionalAttribute(el, "aria-controls", attrs.controls);
|
|
1446
|
+
this.syncOptionalAttribute(el, "aria-haspopup", attrs.haspopup);
|
|
1447
|
+
this.syncOptionalAttribute(
|
|
1448
|
+
el,
|
|
1449
|
+
"aria-selected",
|
|
1450
|
+
attrs.selected === void 0 ? void 0 : String(attrs.selected)
|
|
1451
|
+
);
|
|
1452
|
+
this.syncOptionalAttribute(el, "aria-activedescendant", attrs.activedescendant);
|
|
1453
|
+
this.syncOptionalAttribute(el, "aria-valuemin", attrs.valuemin);
|
|
1454
|
+
this.syncOptionalAttribute(el, "aria-valuemax", attrs.valuemax);
|
|
1452
1455
|
if (attrs.value !== void 0) {
|
|
1453
1456
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
1454
1457
|
if (el.value !== attrs.value) {
|
|
@@ -1458,9 +1461,11 @@ var Scene = (_class2 = class _Scene {
|
|
|
1458
1461
|
el._lastSyncedValue = attrs.value;
|
|
1459
1462
|
}
|
|
1460
1463
|
}
|
|
1461
|
-
} else
|
|
1462
|
-
|
|
1464
|
+
} else {
|
|
1465
|
+
this.syncOptionalAttribute(el, "aria-valuenow", attrs.value);
|
|
1463
1466
|
}
|
|
1467
|
+
} else if (!(el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement)) {
|
|
1468
|
+
this.syncOptionalAttribute(el, "aria-valuenow", void 0);
|
|
1464
1469
|
}
|
|
1465
1470
|
if (attrs.textInputStyle !== void 0 && (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement)) {
|
|
1466
1471
|
const textStyle = attrs.textInputStyle;
|
|
@@ -3402,7 +3407,7 @@ var DOMPortalEntity = (_class7 = class extends _chunkGKLTTGBRjs.Entity {
|
|
|
3402
3407
|
if (!local) return false;
|
|
3403
3408
|
return local.x >= 0 && local.x <= w && local.y >= 0 && local.y <= h;
|
|
3404
3409
|
}
|
|
3405
|
-
add(
|
|
3410
|
+
add(..._children) {
|
|
3406
3411
|
console.warn(`DOMPortalEntity (${this.id}) is a leaf node. Child entities are not supported.`);
|
|
3407
3412
|
return this;
|
|
3408
3413
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1214,6 +1214,13 @@ var Scene = class _Scene {
|
|
|
1214
1214
|
}
|
|
1215
1215
|
/** True when any node in the subtree has a pending animation. */
|
|
1216
1216
|
/** True when any node in the subtree is interactive (drives a11y sync). */
|
|
1217
|
+
syncOptionalAttribute(element, name, value) {
|
|
1218
|
+
if (value === void 0) {
|
|
1219
|
+
if (element.hasAttribute(name)) element.removeAttribute(name);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
if (element.getAttribute(name) !== value) element.setAttribute(name, value);
|
|
1223
|
+
}
|
|
1217
1224
|
syncA11y(node) {
|
|
1218
1225
|
if (!this.a11yRoot) return;
|
|
1219
1226
|
if (node.isDOMPortal) {
|
|
@@ -1380,12 +1387,8 @@ var Scene = class _Scene {
|
|
|
1380
1387
|
this.a11yElements.set(node.id, el);
|
|
1381
1388
|
this.a11yNeedsReorder = true;
|
|
1382
1389
|
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
if (attrs.label !== void 0 && el.getAttribute("aria-label") !== attrs.label) {
|
|
1387
|
-
el.setAttribute("aria-label", attrs.label);
|
|
1388
|
-
}
|
|
1390
|
+
this.syncOptionalAttribute(el, "role", attrs.role);
|
|
1391
|
+
this.syncOptionalAttribute(el, "aria-label", attrs.label);
|
|
1389
1392
|
const semanticPointerEvents = attrs.pointerEvents ?? "auto";
|
|
1390
1393
|
if (el.style.pointerEvents !== semanticPointerEvents) {
|
|
1391
1394
|
el.style.pointerEvents = semanticPointerEvents;
|
|
@@ -1397,58 +1400,58 @@ var Scene = class _Scene {
|
|
|
1397
1400
|
} else if (el.getAttribute("tabindex") !== String(desiredTabIndex)) {
|
|
1398
1401
|
el.setAttribute("tabindex", String(desiredTabIndex));
|
|
1399
1402
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (el.placeholder !== attrs.placeholder) el.placeholder = attrs.placeholder;
|
|
1403
|
+
this.syncOptionalAttribute(el, "type", attrs.inputType);
|
|
1404
|
+
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
1405
|
+
const placeholder = attrs.placeholder ?? "";
|
|
1406
|
+
if (el.placeholder !== placeholder) el.placeholder = placeholder;
|
|
1405
1407
|
}
|
|
1406
|
-
if (
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1408
|
+
if (el instanceof HTMLAnchorElement) {
|
|
1409
|
+
this.syncOptionalAttribute(
|
|
1410
|
+
el,
|
|
1411
|
+
"href",
|
|
1412
|
+
attrs.href === void 0 ? void 0 : sanitizeUrl(attrs.href)
|
|
1413
|
+
);
|
|
1414
|
+
this.syncOptionalAttribute(el, "target", attrs.target);
|
|
1412
1415
|
}
|
|
1413
1416
|
if (el instanceof HTMLImageElement) {
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
if (attrs.checked !== void 0) {
|
|
1418
|
-
if (el instanceof HTMLInputElement) {
|
|
1419
|
-
if (el.checked !== attrs.checked) el.checked = attrs.checked;
|
|
1420
|
-
} else if (el.getAttribute("aria-checked") !== String(attrs.checked)) {
|
|
1421
|
-
el.setAttribute("aria-checked", String(attrs.checked));
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
if (attrs.disabled !== void 0) {
|
|
1425
|
-
if ("disabled" in el) {
|
|
1426
|
-
if (el.disabled !== attrs.disabled) el.disabled = attrs.disabled;
|
|
1427
|
-
} else if (el.getAttribute("aria-disabled") !== String(attrs.disabled)) {
|
|
1428
|
-
el.setAttribute("aria-disabled", String(attrs.disabled));
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
if (attrs.expanded !== void 0 && el.getAttribute("aria-expanded") !== String(attrs.expanded)) {
|
|
1432
|
-
el.setAttribute("aria-expanded", String(attrs.expanded));
|
|
1417
|
+
this.syncOptionalAttribute(el, "src", attrs.src);
|
|
1418
|
+
this.syncOptionalAttribute(el, "alt", attrs.alt);
|
|
1433
1419
|
}
|
|
1434
|
-
if (
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
if (attrs.activedescendant !== void 0 && el.getAttribute("aria-activedescendant") !== attrs.activedescendant) {
|
|
1444
|
-
el.setAttribute("aria-activedescendant", attrs.activedescendant);
|
|
1445
|
-
}
|
|
1446
|
-
if (attrs.valuemin !== void 0 && el.getAttribute("aria-valuemin") !== attrs.valuemin) {
|
|
1447
|
-
el.setAttribute("aria-valuemin", attrs.valuemin);
|
|
1420
|
+
if (el instanceof HTMLInputElement) {
|
|
1421
|
+
const checked = attrs.checked ?? false;
|
|
1422
|
+
if (el.checked !== checked) el.checked = checked;
|
|
1423
|
+
} else {
|
|
1424
|
+
this.syncOptionalAttribute(
|
|
1425
|
+
el,
|
|
1426
|
+
"aria-checked",
|
|
1427
|
+
attrs.checked === void 0 ? void 0 : String(attrs.checked)
|
|
1428
|
+
);
|
|
1448
1429
|
}
|
|
1449
|
-
if (
|
|
1450
|
-
|
|
1430
|
+
if ("disabled" in el) {
|
|
1431
|
+
const disabled = attrs.disabled ?? false;
|
|
1432
|
+
if (el.disabled !== disabled) el.disabled = disabled;
|
|
1433
|
+
} else {
|
|
1434
|
+
this.syncOptionalAttribute(
|
|
1435
|
+
el,
|
|
1436
|
+
"aria-disabled",
|
|
1437
|
+
attrs.disabled === void 0 ? void 0 : String(attrs.disabled)
|
|
1438
|
+
);
|
|
1451
1439
|
}
|
|
1440
|
+
this.syncOptionalAttribute(
|
|
1441
|
+
el,
|
|
1442
|
+
"aria-expanded",
|
|
1443
|
+
attrs.expanded === void 0 ? void 0 : String(attrs.expanded)
|
|
1444
|
+
);
|
|
1445
|
+
this.syncOptionalAttribute(el, "aria-controls", attrs.controls);
|
|
1446
|
+
this.syncOptionalAttribute(el, "aria-haspopup", attrs.haspopup);
|
|
1447
|
+
this.syncOptionalAttribute(
|
|
1448
|
+
el,
|
|
1449
|
+
"aria-selected",
|
|
1450
|
+
attrs.selected === void 0 ? void 0 : String(attrs.selected)
|
|
1451
|
+
);
|
|
1452
|
+
this.syncOptionalAttribute(el, "aria-activedescendant", attrs.activedescendant);
|
|
1453
|
+
this.syncOptionalAttribute(el, "aria-valuemin", attrs.valuemin);
|
|
1454
|
+
this.syncOptionalAttribute(el, "aria-valuemax", attrs.valuemax);
|
|
1452
1455
|
if (attrs.value !== void 0) {
|
|
1453
1456
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
1454
1457
|
if (el.value !== attrs.value) {
|
|
@@ -1458,9 +1461,11 @@ var Scene = class _Scene {
|
|
|
1458
1461
|
el._lastSyncedValue = attrs.value;
|
|
1459
1462
|
}
|
|
1460
1463
|
}
|
|
1461
|
-
} else
|
|
1462
|
-
|
|
1464
|
+
} else {
|
|
1465
|
+
this.syncOptionalAttribute(el, "aria-valuenow", attrs.value);
|
|
1463
1466
|
}
|
|
1467
|
+
} else if (!(el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement)) {
|
|
1468
|
+
this.syncOptionalAttribute(el, "aria-valuenow", void 0);
|
|
1464
1469
|
}
|
|
1465
1470
|
if (attrs.textInputStyle !== void 0 && (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement)) {
|
|
1466
1471
|
const textStyle = attrs.textInputStyle;
|
|
@@ -3402,7 +3407,7 @@ var DOMPortalEntity = class extends Entity {
|
|
|
3402
3407
|
if (!local) return false;
|
|
3403
3408
|
return local.x >= 0 && local.x <= w && local.y >= 0 && local.y <= h;
|
|
3404
3409
|
}
|
|
3405
|
-
add(
|
|
3410
|
+
add(..._children) {
|
|
3406
3411
|
console.warn(`DOMPortalEntity (${this.id}) is a leaf node. Child entities are not supported.`);
|
|
3407
3412
|
return this;
|
|
3408
3413
|
}
|
|
@@ -13,7 +13,7 @@ export declare class DOMPortalEntity extends Entity {
|
|
|
13
13
|
lastOpacity: string;
|
|
14
14
|
constructor(domElement: HTMLElement, width?: number, height?: number, id?: string);
|
|
15
15
|
isPointInside(globalX: number, globalY: number): boolean;
|
|
16
|
-
add(
|
|
16
|
+
add(..._children: Entity[]): this;
|
|
17
17
|
render(): void;
|
|
18
18
|
destroy(): void;
|
|
19
19
|
}
|
package/dist/tree/Scene.d.ts
CHANGED
|
@@ -309,6 +309,7 @@ export declare class Scene {
|
|
|
309
309
|
markDirty(): void;
|
|
310
310
|
/** True when any node in the subtree has a pending animation. */
|
|
311
311
|
/** True when any node in the subtree is interactive (drives a11y sync). */
|
|
312
|
+
private syncOptionalAttribute;
|
|
312
313
|
private syncA11y;
|
|
313
314
|
/**
|
|
314
315
|
* Mirror one entity's static text ({@link Entity.getContentProjection}) as a
|