sia-reactor 0.0.31 → 0.0.32
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/adapters/react.cjs +5 -1
- package/dist/adapters/react.js +2 -2
- package/dist/adapters/vanilla.cjs +22 -18
- package/dist/adapters/vanilla.js +2 -2
- package/dist/{chunk-RVYL3OLW.js → chunk-RI45W4O6.js} +26 -21
- package/dist/{chunk-UYRDN3OX.js → chunk-XNYVGOKB.js} +1 -1
- package/dist/super.d.ts +23 -2
- package/dist/super.global.js +23 -18
- package/dist/utils.cjs +24 -18
- package/dist/utils.d.cts +22 -2
- package/dist/utils.d.ts +22 -2
- package/dist/utils.js +3 -1
- package/package.json +1 -1
package/dist/adapters/react.cjs
CHANGED
|
@@ -1132,6 +1132,10 @@ function assignEl(el, props, dataset, styles) {
|
|
|
1132
1132
|
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
1133
1133
|
}
|
|
1134
1134
|
}
|
|
1135
|
+
function getActiveEl(root) {
|
|
1136
|
+
const activeEl = (root ?? document).activeElement;
|
|
1137
|
+
return !activeEl ? null : activeEl.shadowRoot ? getActiveEl(activeEl.shadowRoot) : activeEl;
|
|
1138
|
+
}
|
|
1135
1139
|
|
|
1136
1140
|
// src/ts/utils/keys.ts
|
|
1137
1141
|
function stringifyKeyEvent(e) {
|
|
@@ -1173,7 +1177,7 @@ function getTermsForKey(combo, settings) {
|
|
|
1173
1177
|
return terms;
|
|
1174
1178
|
}
|
|
1175
1179
|
function keyEventAllowed(e, settings) {
|
|
1176
|
-
if (settings.disabled || (e.key === " " || e.key === "Enter") && (e.target?.ownerDocument
|
|
1180
|
+
if (settings.disabled || (e.key === " " || e.key === "Enter") && getActiveEl(e.target?.ownerDocument)?.matches("button,input,textarea,[contenteditable='true']")) return false;
|
|
1177
1181
|
const combo = stringifyKeyEvent(e), { override, block, action, whitelisted } = getTermsForKey(combo, settings);
|
|
1178
1182
|
if (block) return false;
|
|
1179
1183
|
if (override) e.preventDefault();
|
package/dist/adapters/react.js
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
Autotracker,
|
|
3
3
|
TimeTravelOverlay,
|
|
4
4
|
withTracker
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-XNYVGOKB.js";
|
|
6
6
|
import "../chunk-PLYS4CVP.js";
|
|
7
7
|
import "../chunk-GD7HZBXA.js";
|
|
8
8
|
import {
|
|
9
9
|
getReactor
|
|
10
10
|
} from "../chunk-AKQSBLBX.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-RI45W4O6.js";
|
|
12
12
|
import "../chunk-3OT72G7R.js";
|
|
13
13
|
import {
|
|
14
14
|
CTX,
|
|
@@ -878,6 +878,27 @@ function getReactor(target, create = false, build) {
|
|
|
878
878
|
return (target instanceof Reactor ? target : target.__Reactor__) || (create ? new Reactor(target, build) : void 0);
|
|
879
879
|
}
|
|
880
880
|
|
|
881
|
+
// src/ts/utils/dom.ts
|
|
882
|
+
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
883
|
+
return assignEl(el, props, dataset, styles), el;
|
|
884
|
+
}
|
|
885
|
+
function assignEl(el, props, dataset, styles) {
|
|
886
|
+
if (!el) return;
|
|
887
|
+
if (props) {
|
|
888
|
+
for (const k of Object.keys(props)) if (props[k] !== void 0) el[k] = props[k];
|
|
889
|
+
}
|
|
890
|
+
if (dataset) {
|
|
891
|
+
for (const k of Object.keys(dataset)) if (dataset[k] !== void 0) el.dataset[k] = String(dataset[k]);
|
|
892
|
+
}
|
|
893
|
+
if (styles) {
|
|
894
|
+
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
function getActiveEl(root) {
|
|
898
|
+
const activeEl = (root ?? document).activeElement;
|
|
899
|
+
return !activeEl ? null : activeEl.shadowRoot ? getActiveEl(activeEl.shadowRoot) : activeEl;
|
|
900
|
+
}
|
|
901
|
+
|
|
881
902
|
// src/ts/utils/keys.ts
|
|
882
903
|
function stringifyKeyEvent(e) {
|
|
883
904
|
const parts = [];
|
|
@@ -918,7 +939,7 @@ function getTermsForKey(combo, settings) {
|
|
|
918
939
|
return terms;
|
|
919
940
|
}
|
|
920
941
|
function keyEventAllowed(e, settings) {
|
|
921
|
-
if (settings.disabled || (e.key === " " || e.key === "Enter") && (e.target?.ownerDocument
|
|
942
|
+
if (settings.disabled || (e.key === " " || e.key === "Enter") && getActiveEl(e.target?.ownerDocument)?.matches("button,input,textarea,[contenteditable='true']")) return false;
|
|
922
943
|
const combo = stringifyKeyEvent(e), { override, block, action, whitelisted } = getTermsForKey(combo, settings);
|
|
923
944
|
if (block) return false;
|
|
924
945
|
if (override) e.preventDefault();
|
|
@@ -932,23 +953,6 @@ function parseForARIAKS(s, formatted = true) {
|
|
|
932
953
|
return (formatted && !Array.isArray(s) ? s : formatKeyForDisplay(s)).toLowerCase().replace(/[()]/g, "").replace(/\bor\b/g, " ").replace(/\w+/g, (k) => m[k] || k).replace(/\s+/g, " ").trim();
|
|
933
954
|
}
|
|
934
955
|
|
|
935
|
-
// src/ts/utils/dom.ts
|
|
936
|
-
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
937
|
-
return assignEl(el, props, dataset, styles), el;
|
|
938
|
-
}
|
|
939
|
-
function assignEl(el, props, dataset, styles) {
|
|
940
|
-
if (!el) return;
|
|
941
|
-
if (props) {
|
|
942
|
-
for (const k of Object.keys(props)) if (props[k] !== void 0) el[k] = props[k];
|
|
943
|
-
}
|
|
944
|
-
if (dataset) {
|
|
945
|
-
for (const k of Object.keys(dataset)) if (dataset[k] !== void 0) el.dataset[k] = String(dataset[k]);
|
|
946
|
-
}
|
|
947
|
-
if (styles) {
|
|
948
|
-
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
|
|
952
956
|
// src/ts/modules/base.ts
|
|
953
957
|
var wpArr = ["*"];
|
|
954
958
|
|
package/dist/adapters/vanilla.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
TimeTravelOverlay,
|
|
4
4
|
effect,
|
|
5
5
|
withTracker
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-XNYVGOKB.js";
|
|
7
7
|
import "../chunk-PLYS4CVP.js";
|
|
8
8
|
import "../chunk-GD7HZBXA.js";
|
|
9
9
|
import "../chunk-AKQSBLBX.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-RI45W4O6.js";
|
|
11
11
|
import "../chunk-3OT72G7R.js";
|
|
12
12
|
import "../chunk-EZ4VRGYI.js";
|
|
13
13
|
export {
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
// src/ts/utils/dom.ts
|
|
2
|
+
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
3
|
+
return assignEl(el, props, dataset, styles), el;
|
|
4
|
+
}
|
|
5
|
+
function assignEl(el, props, dataset, styles) {
|
|
6
|
+
if (!el) return;
|
|
7
|
+
if (props) {
|
|
8
|
+
for (const k of Object.keys(props)) if (props[k] !== void 0) el[k] = props[k];
|
|
9
|
+
}
|
|
10
|
+
if (dataset) {
|
|
11
|
+
for (const k of Object.keys(dataset)) if (dataset[k] !== void 0) el.dataset[k] = String(dataset[k]);
|
|
12
|
+
}
|
|
13
|
+
if (styles) {
|
|
14
|
+
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function getActiveEl(root) {
|
|
18
|
+
const activeEl = (root ?? document).activeElement;
|
|
19
|
+
return !activeEl ? null : activeEl.shadowRoot ? getActiveEl(activeEl.shadowRoot) : activeEl;
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
// src/ts/utils/keys.ts
|
|
2
23
|
function parseKeyCombo(combo) {
|
|
3
24
|
const parts = cleanKeyCombo(combo).toLowerCase().split("+");
|
|
@@ -42,7 +63,7 @@ function getTermsForKey(combo, settings) {
|
|
|
42
63
|
return terms;
|
|
43
64
|
}
|
|
44
65
|
function keyEventAllowed(e, settings) {
|
|
45
|
-
if (settings.disabled || (e.key === " " || e.key === "Enter") && (e.target?.ownerDocument
|
|
66
|
+
if (settings.disabled || (e.key === " " || e.key === "Enter") && getActiveEl(e.target?.ownerDocument)?.matches("button,input,textarea,[contenteditable='true']")) return false;
|
|
46
67
|
const combo = stringifyKeyEvent(e), { override, block, action, whitelisted } = getTermsForKey(combo, settings);
|
|
47
68
|
if (block) return false;
|
|
48
69
|
if (override) e.preventDefault();
|
|
@@ -61,24 +82,10 @@ function parseForARIAKS(s, formatted = true) {
|
|
|
61
82
|
return (formatted && !Array.isArray(s) ? s : formatKeyForDisplay(s)).toLowerCase().replace(/[()]/g, "").replace(/\bor\b/g, " ").replace(/\w+/g, (k) => m[k] || k).replace(/\s+/g, " ").trim();
|
|
62
83
|
}
|
|
63
84
|
|
|
64
|
-
// src/ts/utils/dom.ts
|
|
65
|
-
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
66
|
-
return assignEl(el, props, dataset, styles), el;
|
|
67
|
-
}
|
|
68
|
-
function assignEl(el, props, dataset, styles) {
|
|
69
|
-
if (!el) return;
|
|
70
|
-
if (props) {
|
|
71
|
-
for (const k of Object.keys(props)) if (props[k] !== void 0) el[k] = props[k];
|
|
72
|
-
}
|
|
73
|
-
if (dataset) {
|
|
74
|
-
for (const k of Object.keys(dataset)) if (dataset[k] !== void 0) el.dataset[k] = String(dataset[k]);
|
|
75
|
-
}
|
|
76
|
-
if (styles) {
|
|
77
|
-
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
85
|
export {
|
|
86
|
+
createEl,
|
|
87
|
+
assignEl,
|
|
88
|
+
getActiveEl,
|
|
82
89
|
parseKeyCombo,
|
|
83
90
|
stringifyKeyEvent,
|
|
84
91
|
cleanKeyCombo,
|
|
@@ -87,7 +94,5 @@ export {
|
|
|
87
94
|
keyEventAllowed,
|
|
88
95
|
formatKeyForDisplay,
|
|
89
96
|
formatKeyShortcutsForDisplay,
|
|
90
|
-
parseForARIAKS
|
|
91
|
-
createEl,
|
|
92
|
-
assignEl
|
|
97
|
+
parseForARIAKS
|
|
93
98
|
};
|
package/dist/super.d.ts
CHANGED
|
@@ -1365,7 +1365,7 @@ declare function getTermsForKey(combo: string, settings: keysSettings): {
|
|
|
1365
1365
|
*/
|
|
1366
1366
|
declare function keyEventAllowed(e: KeyboardEvent, settings: keysSettings): false | string;
|
|
1367
1367
|
/**
|
|
1368
|
-
* Formats one or many combos for human-readable UI labels.
|
|
1368
|
+
* Formats one or many combos for human-readable UI labels, prepends " " for fluid appending.
|
|
1369
1369
|
* @param combo Combo or combo list.
|
|
1370
1370
|
* @returns Display label (for example: `" (ctrl+z) or (meta+z)"`).
|
|
1371
1371
|
*/
|
|
@@ -1394,10 +1394,30 @@ declare function parseForARIAKS(s: string | string[], formatted?: boolean): stri
|
|
|
1394
1394
|
|
|
1395
1395
|
type Dataset = Record<string, string | number>;
|
|
1396
1396
|
type Style = Partial<CSSStyleDeclaration>;
|
|
1397
|
+
/**
|
|
1398
|
+
* Creates an HTML element with the specified tag and properties.
|
|
1399
|
+
* @param tag The tag name of the element to create.
|
|
1400
|
+
* @param props Optional properties to set on the element.
|
|
1401
|
+
* @param dataset Optional dataset attributes for the element.
|
|
1402
|
+
* @param styles Optional CSS styles for the element.
|
|
1403
|
+
* @returns The created HTML element.
|
|
1404
|
+
*/
|
|
1397
1405
|
declare function createEl<K extends keyof HTMLElementTagNameMap>(tag: K, props?: Partial<HTMLElementTagNameMap[K]>, dataset?: Dataset, styles?: Style): HTMLElementTagNameMap[K];
|
|
1398
1406
|
declare function createEl(tag: string, props?: Partial<HTMLElement>, dataset?: Dataset, styles?: Style): HTMLElement | null;
|
|
1407
|
+
/**
|
|
1408
|
+
* Assigns properties, dataset attributes, and styles to an HTML element.
|
|
1409
|
+
* @param el The HTML element to assign properties to.
|
|
1410
|
+
* @param props Optional properties to set on the element.
|
|
1411
|
+
* @param dataset Optional dataset attributes for the element.
|
|
1412
|
+
* @param styles Optional CSS styles for the element.
|
|
1413
|
+
*/
|
|
1399
1414
|
declare function assignEl<K extends keyof HTMLElementTagNameMap>(el?: HTMLElementTagNameMap[K], props?: Partial<HTMLElementTagNameMap[K]>, dataset?: Dataset, styles?: Style): void;
|
|
1400
1415
|
declare function assignEl(el?: HTMLElement | null, props?: Partial<HTMLElement>, dataset?: Dataset, styles?: Style): void;
|
|
1416
|
+
/** Get the currently active element, traversing into shadow roots if necessary.
|
|
1417
|
+
* @param root Root node to start searching from, defaults to the main document.
|
|
1418
|
+
* @returns The active element or null if none found.
|
|
1419
|
+
*/
|
|
1420
|
+
declare function getActiveEl(root?: Document | ShadowRoot | null): Element | null;
|
|
1401
1421
|
|
|
1402
1422
|
type utils_FanoutTuple = FanoutTuple;
|
|
1403
1423
|
type utils_KeyStruct = KeyStruct;
|
|
@@ -1414,6 +1434,7 @@ declare const utils_fanout: typeof fanout;
|
|
|
1414
1434
|
declare const utils_fanoutOptsArr: typeof fanoutOptsArr;
|
|
1415
1435
|
declare const utils_formatKeyForDisplay: typeof formatKeyForDisplay;
|
|
1416
1436
|
declare const utils_formatKeyShortcutsForDisplay: typeof formatKeyShortcutsForDisplay;
|
|
1437
|
+
declare const utils_getActiveEl: typeof getActiveEl;
|
|
1417
1438
|
declare const utils_getAny: typeof getAny;
|
|
1418
1439
|
declare const utils_getTermsForKey: typeof getTermsForKey;
|
|
1419
1440
|
declare const utils_getTrailRecords: typeof getTrailRecords;
|
|
@@ -1438,7 +1459,7 @@ declare const utils_setInterval: typeof setInterval;
|
|
|
1438
1459
|
declare const utils_setTimeout: typeof setTimeout;
|
|
1439
1460
|
declare const utils_stringifyKeyEvent: typeof stringifyKeyEvent;
|
|
1440
1461
|
declare namespace utils {
|
|
1441
|
-
export { type utils_FanoutTuple as FanoutTuple, type utils_KeyStruct as KeyStruct, utils_arrRegex as arrRegex, utils_assignEl as assignEl, utils_bindAllMethods as bindAllMethods, utils_canHandle as canHandle, utils_clamp as clamp, utils_cleanKeyCombo as cleanKeyCombo, utils_createEl as createEl, utils_deepClone as deepClone, utils_deleteAny as deleteAny, utils_fanout as fanout, utils_fanoutOptsArr as fanoutOptsArr, utils_formatKeyForDisplay as formatKeyForDisplay, utils_formatKeyShortcutsForDisplay as formatKeyShortcutsForDisplay, utils_getAny as getAny, utils_getTermsForKey as getTermsForKey, utils_getTrailRecords as getTrailRecords, utils_guardAllMethods as guardAllMethods, utils_guardMethod as guardMethod, utils_inAny as inAny, utils_isObj as isObj, utils_isPOJO as isPOJO, utils_keyEventAllowed as keyEventAllowed, type utils_keysSettings as keysSettings, utils_matchKeys as matchKeys, utils_mergeObjs as mergeObjs, utils_nuke as nuke, utils_onAllMethods as onAllMethods, utils_parseAnyObj as parseAnyObj, utils_parseEvtOpts as parseEvtOpts, utils_parseForARIAKS as parseForARIAKS, utils_parseKeyCombo as parseKeyCombo, utils_requestAnimationFrame as requestAnimationFrame, utils_setAny as setAny, utils_setInterval as setInterval, utils_setTimeout as setTimeout, utils_stringifyKeyEvent as stringifyKeyEvent };
|
|
1462
|
+
export { type utils_FanoutTuple as FanoutTuple, type utils_KeyStruct as KeyStruct, utils_arrRegex as arrRegex, utils_assignEl as assignEl, utils_bindAllMethods as bindAllMethods, utils_canHandle as canHandle, utils_clamp as clamp, utils_cleanKeyCombo as cleanKeyCombo, utils_createEl as createEl, utils_deepClone as deepClone, utils_deleteAny as deleteAny, utils_fanout as fanout, utils_fanoutOptsArr as fanoutOptsArr, utils_formatKeyForDisplay as formatKeyForDisplay, utils_formatKeyShortcutsForDisplay as formatKeyShortcutsForDisplay, utils_getActiveEl as getActiveEl, utils_getAny as getAny, utils_getTermsForKey as getTermsForKey, utils_getTrailRecords as getTrailRecords, utils_guardAllMethods as guardAllMethods, utils_guardMethod as guardMethod, utils_inAny as inAny, utils_isObj as isObj, utils_isPOJO as isPOJO, utils_keyEventAllowed as keyEventAllowed, type utils_keysSettings as keysSettings, utils_matchKeys as matchKeys, utils_mergeObjs as mergeObjs, utils_nuke as nuke, utils_onAllMethods as onAllMethods, utils_parseAnyObj as parseAnyObj, utils_parseEvtOpts as parseEvtOpts, utils_parseForARIAKS as parseForARIAKS, utils_parseKeyCombo as parseKeyCombo, utils_requestAnimationFrame as requestAnimationFrame, utils_setAny as setAny, utils_setInterval as setInterval, utils_setTimeout as setTimeout, utils_stringifyKeyEvent as stringifyKeyEvent };
|
|
1442
1463
|
}
|
|
1443
1464
|
|
|
1444
1465
|
type JSONReplacer = ((this: any, key: string, value: any) => any) | (number | string)[] | null;
|
package/dist/super.global.js
CHANGED
|
@@ -1019,6 +1019,7 @@ var sia = (() => {
|
|
|
1019
1019
|
fanoutOptsArr: () => fanoutOptsArr,
|
|
1020
1020
|
formatKeyForDisplay: () => formatKeyForDisplay,
|
|
1021
1021
|
formatKeyShortcutsForDisplay: () => formatKeyShortcutsForDisplay,
|
|
1022
|
+
getActiveEl: () => getActiveEl,
|
|
1022
1023
|
getAny: () => getAny,
|
|
1023
1024
|
getTermsForKey: () => getTermsForKey,
|
|
1024
1025
|
getTrailRecords: () => getTrailRecords,
|
|
@@ -1103,6 +1104,27 @@ var sia = (() => {
|
|
|
1103
1104
|
});
|
|
1104
1105
|
}
|
|
1105
1106
|
|
|
1107
|
+
// src/ts/utils/dom.ts
|
|
1108
|
+
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
1109
|
+
return assignEl(el, props, dataset, styles), el;
|
|
1110
|
+
}
|
|
1111
|
+
function assignEl(el, props, dataset, styles) {
|
|
1112
|
+
if (!el) return;
|
|
1113
|
+
if (props) {
|
|
1114
|
+
for (const k of Object.keys(props)) if (props[k] !== void 0) el[k] = props[k];
|
|
1115
|
+
}
|
|
1116
|
+
if (dataset) {
|
|
1117
|
+
for (const k of Object.keys(dataset)) if (dataset[k] !== void 0) el.dataset[k] = String(dataset[k]);
|
|
1118
|
+
}
|
|
1119
|
+
if (styles) {
|
|
1120
|
+
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
function getActiveEl(root) {
|
|
1124
|
+
const activeEl = (root ?? document).activeElement;
|
|
1125
|
+
return !activeEl ? null : activeEl.shadowRoot ? getActiveEl(activeEl.shadowRoot) : activeEl;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1106
1128
|
// src/ts/utils/keys.ts
|
|
1107
1129
|
function parseKeyCombo(combo) {
|
|
1108
1130
|
const parts = cleanKeyCombo(combo).toLowerCase().split("+");
|
|
@@ -1147,7 +1169,7 @@ var sia = (() => {
|
|
|
1147
1169
|
return terms;
|
|
1148
1170
|
}
|
|
1149
1171
|
function keyEventAllowed(e, settings) {
|
|
1150
|
-
if (settings.disabled || (e.key === " " || e.key === "Enter") && (e.target?.ownerDocument
|
|
1172
|
+
if (settings.disabled || (e.key === " " || e.key === "Enter") && getActiveEl(e.target?.ownerDocument)?.matches("button,input,textarea,[contenteditable='true']")) return false;
|
|
1151
1173
|
const combo = stringifyKeyEvent(e), { override, block, action, whitelisted } = getTermsForKey(combo, settings);
|
|
1152
1174
|
if (block) return false;
|
|
1153
1175
|
if (override) e.preventDefault();
|
|
@@ -1166,23 +1188,6 @@ var sia = (() => {
|
|
|
1166
1188
|
return (formatted && !Array.isArray(s) ? s : formatKeyForDisplay(s)).toLowerCase().replace(/[()]/g, "").replace(/\bor\b/g, " ").replace(/\w+/g, (k) => m[k] || k).replace(/\s+/g, " ").trim();
|
|
1167
1189
|
}
|
|
1168
1190
|
|
|
1169
|
-
// src/ts/utils/dom.ts
|
|
1170
|
-
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
1171
|
-
return assignEl(el, props, dataset, styles), el;
|
|
1172
|
-
}
|
|
1173
|
-
function assignEl(el, props, dataset, styles) {
|
|
1174
|
-
if (!el) return;
|
|
1175
|
-
if (props) {
|
|
1176
|
-
for (const k of Object.keys(props)) if (props[k] !== void 0) el[k] = props[k];
|
|
1177
|
-
}
|
|
1178
|
-
if (dataset) {
|
|
1179
|
-
for (const k of Object.keys(dataset)) if (dataset[k] !== void 0) el.dataset[k] = String(dataset[k]);
|
|
1180
|
-
}
|
|
1181
|
-
if (styles) {
|
|
1182
|
-
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
1191
|
// src/ts/modules.ts
|
|
1187
1192
|
var modules_exports = {};
|
|
1188
1193
|
__export(modules_exports, {
|
package/dist/utils.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(utils_exports, {
|
|
|
33
33
|
fanoutOptsArr: () => fanoutOptsArr,
|
|
34
34
|
formatKeyForDisplay: () => formatKeyForDisplay,
|
|
35
35
|
formatKeyShortcutsForDisplay: () => formatKeyShortcutsForDisplay,
|
|
36
|
+
getActiveEl: () => getActiveEl,
|
|
36
37
|
getAny: () => getAny,
|
|
37
38
|
getTermsForKey: () => getTermsForKey,
|
|
38
39
|
getTrailRecords: () => getTrailRecords,
|
|
@@ -309,6 +310,27 @@ function guardMethod(fn, onError = (e) => console.error(e)) {
|
|
|
309
310
|
});
|
|
310
311
|
}
|
|
311
312
|
|
|
313
|
+
// src/ts/utils/dom.ts
|
|
314
|
+
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
315
|
+
return assignEl(el, props, dataset, styles), el;
|
|
316
|
+
}
|
|
317
|
+
function assignEl(el, props, dataset, styles) {
|
|
318
|
+
if (!el) return;
|
|
319
|
+
if (props) {
|
|
320
|
+
for (const k of Object.keys(props)) if (props[k] !== void 0) el[k] = props[k];
|
|
321
|
+
}
|
|
322
|
+
if (dataset) {
|
|
323
|
+
for (const k of Object.keys(dataset)) if (dataset[k] !== void 0) el.dataset[k] = String(dataset[k]);
|
|
324
|
+
}
|
|
325
|
+
if (styles) {
|
|
326
|
+
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function getActiveEl(root) {
|
|
330
|
+
const activeEl = (root ?? document).activeElement;
|
|
331
|
+
return !activeEl ? null : activeEl.shadowRoot ? getActiveEl(activeEl.shadowRoot) : activeEl;
|
|
332
|
+
}
|
|
333
|
+
|
|
312
334
|
// src/ts/utils/keys.ts
|
|
313
335
|
function parseKeyCombo(combo) {
|
|
314
336
|
const parts = cleanKeyCombo(combo).toLowerCase().split("+");
|
|
@@ -353,7 +375,7 @@ function getTermsForKey(combo, settings) {
|
|
|
353
375
|
return terms;
|
|
354
376
|
}
|
|
355
377
|
function keyEventAllowed(e, settings) {
|
|
356
|
-
if (settings.disabled || (e.key === " " || e.key === "Enter") && (e.target?.ownerDocument
|
|
378
|
+
if (settings.disabled || (e.key === " " || e.key === "Enter") && getActiveEl(e.target?.ownerDocument)?.matches("button,input,textarea,[contenteditable='true']")) return false;
|
|
357
379
|
const combo = stringifyKeyEvent(e), { override, block, action, whitelisted } = getTermsForKey(combo, settings);
|
|
358
380
|
if (block) return false;
|
|
359
381
|
if (override) e.preventDefault();
|
|
@@ -371,23 +393,6 @@ function parseForARIAKS(s, formatted = true) {
|
|
|
371
393
|
const m = { ctrl: "Control", cmd: "Meta", space: "Space", plus: "+" };
|
|
372
394
|
return (formatted && !Array.isArray(s) ? s : formatKeyForDisplay(s)).toLowerCase().replace(/[()]/g, "").replace(/\bor\b/g, " ").replace(/\w+/g, (k) => m[k] || k).replace(/\s+/g, " ").trim();
|
|
373
395
|
}
|
|
374
|
-
|
|
375
|
-
// src/ts/utils/dom.ts
|
|
376
|
-
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
377
|
-
return assignEl(el, props, dataset, styles), el;
|
|
378
|
-
}
|
|
379
|
-
function assignEl(el, props, dataset, styles) {
|
|
380
|
-
if (!el) return;
|
|
381
|
-
if (props) {
|
|
382
|
-
for (const k of Object.keys(props)) if (props[k] !== void 0) el[k] = props[k];
|
|
383
|
-
}
|
|
384
|
-
if (dataset) {
|
|
385
|
-
for (const k of Object.keys(dataset)) if (dataset[k] !== void 0) el.dataset[k] = String(dataset[k]);
|
|
386
|
-
}
|
|
387
|
-
if (styles) {
|
|
388
|
-
for (const k of Object.keys(styles)) if (styles[k] !== void 0) el.style[k] = styles[k];
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
396
|
// Annotate the CommonJS export names for ESM import in node:
|
|
392
397
|
0 && (module.exports = {
|
|
393
398
|
arrRegex,
|
|
@@ -403,6 +408,7 @@ function assignEl(el, props, dataset, styles) {
|
|
|
403
408
|
fanoutOptsArr,
|
|
404
409
|
formatKeyForDisplay,
|
|
405
410
|
formatKeyShortcutsForDisplay,
|
|
411
|
+
getActiveEl,
|
|
406
412
|
getAny,
|
|
407
413
|
getTermsForKey,
|
|
408
414
|
getTrailRecords,
|
package/dist/utils.d.cts
CHANGED
|
@@ -141,7 +141,7 @@ declare function getTermsForKey(combo: string, settings: keysSettings): {
|
|
|
141
141
|
*/
|
|
142
142
|
declare function keyEventAllowed(e: KeyboardEvent, settings: keysSettings): false | string;
|
|
143
143
|
/**
|
|
144
|
-
* Formats one or many combos for human-readable UI labels.
|
|
144
|
+
* Formats one or many combos for human-readable UI labels, prepends " " for fluid appending.
|
|
145
145
|
* @param combo Combo or combo list.
|
|
146
146
|
* @returns Display label (for example: `" (ctrl+z) or (meta+z)"`).
|
|
147
147
|
*/
|
|
@@ -170,9 +170,29 @@ declare function parseForARIAKS(s: string | string[], formatted?: boolean): stri
|
|
|
170
170
|
|
|
171
171
|
type Dataset = Record<string, string | number>;
|
|
172
172
|
type Style = Partial<CSSStyleDeclaration>;
|
|
173
|
+
/**
|
|
174
|
+
* Creates an HTML element with the specified tag and properties.
|
|
175
|
+
* @param tag The tag name of the element to create.
|
|
176
|
+
* @param props Optional properties to set on the element.
|
|
177
|
+
* @param dataset Optional dataset attributes for the element.
|
|
178
|
+
* @param styles Optional CSS styles for the element.
|
|
179
|
+
* @returns The created HTML element.
|
|
180
|
+
*/
|
|
173
181
|
declare function createEl<K extends keyof HTMLElementTagNameMap>(tag: K, props?: Partial<HTMLElementTagNameMap[K]>, dataset?: Dataset, styles?: Style): HTMLElementTagNameMap[K];
|
|
174
182
|
declare function createEl(tag: string, props?: Partial<HTMLElement>, dataset?: Dataset, styles?: Style): HTMLElement | null;
|
|
183
|
+
/**
|
|
184
|
+
* Assigns properties, dataset attributes, and styles to an HTML element.
|
|
185
|
+
* @param el The HTML element to assign properties to.
|
|
186
|
+
* @param props Optional properties to set on the element.
|
|
187
|
+
* @param dataset Optional dataset attributes for the element.
|
|
188
|
+
* @param styles Optional CSS styles for the element.
|
|
189
|
+
*/
|
|
175
190
|
declare function assignEl<K extends keyof HTMLElementTagNameMap>(el?: HTMLElementTagNameMap[K], props?: Partial<HTMLElementTagNameMap[K]>, dataset?: Dataset, styles?: Style): void;
|
|
176
191
|
declare function assignEl(el?: HTMLElement | null, props?: Partial<HTMLElement>, dataset?: Dataset, styles?: Style): void;
|
|
192
|
+
/** Get the currently active element, traversing into shadow roots if necessary.
|
|
193
|
+
* @param root Root node to start searching from, defaults to the main document.
|
|
194
|
+
* @returns The active element or null if none found.
|
|
195
|
+
*/
|
|
196
|
+
declare function getActiveEl(root?: Document | ShadowRoot | null): Element | null;
|
|
177
197
|
|
|
178
|
-
export { type KeyStruct, assignEl, bindAllMethods, clamp, cleanKeyCombo, createEl, formatKeyForDisplay, formatKeyShortcutsForDisplay, getTermsForKey, guardAllMethods, guardMethod, keyEventAllowed, type keysSettings, matchKeys, onAllMethods, parseForARIAKS, parseKeyCombo, requestAnimationFrame, setInterval, setTimeout, stringifyKeyEvent };
|
|
198
|
+
export { type KeyStruct, assignEl, bindAllMethods, clamp, cleanKeyCombo, createEl, formatKeyForDisplay, formatKeyShortcutsForDisplay, getActiveEl, getTermsForKey, guardAllMethods, guardMethod, keyEventAllowed, type keysSettings, matchKeys, onAllMethods, parseForARIAKS, parseKeyCombo, requestAnimationFrame, setInterval, setTimeout, stringifyKeyEvent };
|
package/dist/utils.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ declare function getTermsForKey(combo: string, settings: keysSettings): {
|
|
|
141
141
|
*/
|
|
142
142
|
declare function keyEventAllowed(e: KeyboardEvent, settings: keysSettings): false | string;
|
|
143
143
|
/**
|
|
144
|
-
* Formats one or many combos for human-readable UI labels.
|
|
144
|
+
* Formats one or many combos for human-readable UI labels, prepends " " for fluid appending.
|
|
145
145
|
* @param combo Combo or combo list.
|
|
146
146
|
* @returns Display label (for example: `" (ctrl+z) or (meta+z)"`).
|
|
147
147
|
*/
|
|
@@ -170,9 +170,29 @@ declare function parseForARIAKS(s: string | string[], formatted?: boolean): stri
|
|
|
170
170
|
|
|
171
171
|
type Dataset = Record<string, string | number>;
|
|
172
172
|
type Style = Partial<CSSStyleDeclaration>;
|
|
173
|
+
/**
|
|
174
|
+
* Creates an HTML element with the specified tag and properties.
|
|
175
|
+
* @param tag The tag name of the element to create.
|
|
176
|
+
* @param props Optional properties to set on the element.
|
|
177
|
+
* @param dataset Optional dataset attributes for the element.
|
|
178
|
+
* @param styles Optional CSS styles for the element.
|
|
179
|
+
* @returns The created HTML element.
|
|
180
|
+
*/
|
|
173
181
|
declare function createEl<K extends keyof HTMLElementTagNameMap>(tag: K, props?: Partial<HTMLElementTagNameMap[K]>, dataset?: Dataset, styles?: Style): HTMLElementTagNameMap[K];
|
|
174
182
|
declare function createEl(tag: string, props?: Partial<HTMLElement>, dataset?: Dataset, styles?: Style): HTMLElement | null;
|
|
183
|
+
/**
|
|
184
|
+
* Assigns properties, dataset attributes, and styles to an HTML element.
|
|
185
|
+
* @param el The HTML element to assign properties to.
|
|
186
|
+
* @param props Optional properties to set on the element.
|
|
187
|
+
* @param dataset Optional dataset attributes for the element.
|
|
188
|
+
* @param styles Optional CSS styles for the element.
|
|
189
|
+
*/
|
|
175
190
|
declare function assignEl<K extends keyof HTMLElementTagNameMap>(el?: HTMLElementTagNameMap[K], props?: Partial<HTMLElementTagNameMap[K]>, dataset?: Dataset, styles?: Style): void;
|
|
176
191
|
declare function assignEl(el?: HTMLElement | null, props?: Partial<HTMLElement>, dataset?: Dataset, styles?: Style): void;
|
|
192
|
+
/** Get the currently active element, traversing into shadow roots if necessary.
|
|
193
|
+
* @param root Root node to start searching from, defaults to the main document.
|
|
194
|
+
* @returns The active element or null if none found.
|
|
195
|
+
*/
|
|
196
|
+
declare function getActiveEl(root?: Document | ShadowRoot | null): Element | null;
|
|
177
197
|
|
|
178
|
-
export { type KeyStruct, assignEl, bindAllMethods, clamp, cleanKeyCombo, createEl, formatKeyForDisplay, formatKeyShortcutsForDisplay, getTermsForKey, guardAllMethods, guardMethod, keyEventAllowed, type keysSettings, matchKeys, onAllMethods, parseForARIAKS, parseKeyCombo, requestAnimationFrame, setInterval, setTimeout, stringifyKeyEvent };
|
|
198
|
+
export { type KeyStruct, assignEl, bindAllMethods, clamp, cleanKeyCombo, createEl, formatKeyForDisplay, formatKeyShortcutsForDisplay, getActiveEl, getTermsForKey, guardAllMethods, guardMethod, keyEventAllowed, type keysSettings, matchKeys, onAllMethods, parseForARIAKS, parseKeyCombo, requestAnimationFrame, setInterval, setTimeout, stringifyKeyEvent };
|
package/dist/utils.js
CHANGED
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
createEl,
|
|
11
11
|
formatKeyForDisplay,
|
|
12
12
|
formatKeyShortcutsForDisplay,
|
|
13
|
+
getActiveEl,
|
|
13
14
|
getTermsForKey,
|
|
14
15
|
keyEventAllowed,
|
|
15
16
|
matchKeys,
|
|
16
17
|
parseForARIAKS,
|
|
17
18
|
parseKeyCombo,
|
|
18
19
|
stringifyKeyEvent
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-RI45W4O6.js";
|
|
20
21
|
import {
|
|
21
22
|
bindAllMethods,
|
|
22
23
|
guardAllMethods,
|
|
@@ -55,6 +56,7 @@ export {
|
|
|
55
56
|
fanoutOptsArr,
|
|
56
57
|
formatKeyForDisplay,
|
|
57
58
|
formatKeyShortcutsForDisplay,
|
|
59
|
+
getActiveEl,
|
|
58
60
|
getAny,
|
|
59
61
|
getTermsForKey,
|
|
60
62
|
getTrailRecords,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sia-reactor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"description": "The Programmable Data DOM. A high-performance State & Intent Architecture (S.I.A.) Engine with zero-allocation loops, event propagation, and structural sharing.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|