impact-ui 4.0.12-alpha.2 → 4.0.13-alpha.1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "generatedAt": "2026-09-08T12:19:09.118Z",
3
+ "generatedAt": "2026-09-11T11:28:56.317Z",
4
4
  "components": {
5
5
  "Menu": {
6
6
  "title": "Components/Menu",
@@ -1 +1 @@
1
- {"version":3,"file":"ShortcutManager.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/ShortcutManager.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,oBAAoB,EAEpB,eAAe,EAChB,MAAM,SAAS,CAAC;AAYjB,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgC;IAEvD,OAAO,CAAC,aAAa,CAA2C;IAChE,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,YAAY,CAAuC;IAE3D,OAAO;IAOP,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,eAAe;IAO5F,MAAM,CAAC,aAAa,IAAI,IAAI;IAK5B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,aAAa,CA6CnB;IAEF,QAAQ,CAAC,YAAY,EAAE,oBAAoB,GAAG,IAAI;IAuBlD;;;OAGG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO;IAe1D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAS5B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AE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,OAAO;IAe1D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAS5B,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIjC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAO/B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAYhC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIpC,eAAe,IAAI,eAAe,EAAE;IAUpC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,EAAE;IAWpE,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhC,OAAO,IAAI,IAAI;IAWf,OAAO,CAAC,QAAQ;CAajB"}
@@ -19,9 +19,7 @@ const _ShortcutManager = class _ShortcutManager {
19
19
  const isInInput = INPUT_ELEMENTS.has(target.tagName) || target.isContentEditable;
20
20
  const sorted = this.getSorted();
21
21
  const active = sorted.filter((e) => this.isScopeActive(e.scope ?? "global"));
22
- const sequenceEntries = active.filter(
23
- (e) => e.parsed.type === "sequence" && (e.allowInInput === true || !isInInput)
24
- ).map((e) => ({ ...e, steps: e.parsed.steps }));
22
+ const sequenceEntries = active.filter((e) => e.parsed.isSequence && (e.allowInInput === true || !isInInput)).map((e) => ({ ...e, steps: e.parsed.combos }));
25
23
  if (sequenceEntries.length > 0 || this._sequenceTracker.hasActiveSequences) {
26
24
  const seqMatch = this._sequenceTracker.advance(event, sequenceEntries);
27
25
  if (seqMatch) {
@@ -35,11 +33,12 @@ const _ShortcutManager = class _ShortcutManager {
35
33
  }
36
34
  }
37
35
  const comboEntries = active.filter(
38
- (e) => e.parsed.type === "chord" && (e.allowInInput === true || !isInInput)
36
+ (e) => !e.parsed.isSequence && (e.allowInInput === true || !isInInput)
39
37
  );
40
38
  for (const entry of comboEntries) {
41
- if (entry.parsed.type !== "chord") continue;
42
- if (matchShortcut(event, entry.parsed.combo)) {
39
+ const combo = entry.parsed.combos[0];
40
+ if (!combo) continue;
41
+ if (matchShortcut(event, combo)) {
43
42
  if (entry.preventDefault !== false) event.preventDefault();
44
43
  this.debugLog(event, entry);
45
44
  entry.handler(event);
@@ -1,7 +1,7 @@
1
1
  interface FormatOptions {
2
2
  separator?: string;
3
3
  }
4
- /** Human-readable platform-aware label for UI badges. */
4
+ /** Human-readable platform-aware label for UI badges (JS-compatible output). */
5
5
  export declare function formatShortcutDisplay(keys: string, options?: FormatOptions): string;
6
6
  export {};
7
7
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/format.ts"],"names":[],"mappings":"AAuBA,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAoBD,yDAAyD;AACzD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAOvF"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/format.ts"],"names":[],"mappings":"AAuCA,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CAQvF"}
@@ -1,5 +1,18 @@
1
1
  import { parseShortcutString } from "./parse.js";
2
2
  import { isMac } from "./platform.js";
3
+ const MAC_SYMBOLS = {
4
+ meta: "⌘",
5
+ ctrl: "⌃",
6
+ alt: "⌥",
7
+ shift: "⇧"
8
+ };
9
+ const WIN_SYMBOLS = {
10
+ meta: "Win",
11
+ ctrl: "Ctrl",
12
+ alt: "Alt",
13
+ shift: "Shift"
14
+ };
15
+ const MODIFIER_ORDER = ["ctrl", "alt", "shift", "meta"];
3
16
  const SPECIAL_KEY_DISPLAY = {
4
17
  arrowup: "↑",
5
18
  arrowdown: "↓",
@@ -17,27 +30,16 @@ function formatKey(key) {
17
30
  if (key.length === 1) return key.toUpperCase();
18
31
  return key.charAt(0).toUpperCase() + key.slice(1);
19
32
  }
20
- function formatCombo(combo, separator) {
21
- const parts = [];
22
- const { modifiers, key } = combo;
23
- if (modifiers.mod) {
24
- parts.push(isMac ? "⌘" : "Ctrl");
25
- } else {
26
- if (modifiers.ctrl) parts.push(isMac ? "⌃" : "Ctrl");
27
- if (modifiers.meta) parts.push("⌘");
28
- }
29
- if (modifiers.alt) parts.push(isMac ? "⌥" : "Alt");
30
- if (modifiers.shift) parts.push(isMac ? "⇧" : "Shift");
31
- if (key) parts.push(formatKey(key));
32
- return parts.join(separator);
33
+ function formatCombo(combo, symbols, separator) {
34
+ const modParts = MODIFIER_ORDER.filter((m) => combo.modifiers.has(m)).map((m) => symbols[m]);
35
+ const keyPart = formatKey(combo.key);
36
+ return [...modParts, keyPart].join(separator);
33
37
  }
34
38
  function formatShortcutDisplay(keys, options = {}) {
39
+ const symbols = isMac ? MAC_SYMBOLS : WIN_SYMBOLS;
35
40
  const separator = options.separator ?? (isMac ? "" : "+");
36
41
  const parsed = parseShortcutString(keys);
37
- if (parsed.type === "sequence") {
38
- return parsed.steps.map((c) => formatCombo(c, separator)).join(" then ");
39
- }
40
- return formatCombo(parsed.combo, separator);
42
+ return parsed.combos.map((combo) => formatCombo(combo, symbols, separator)).join(" then ");
41
43
  }
42
44
  export {
43
45
  formatShortcutDisplay
@@ -6,5 +6,5 @@ export { normalizeShortcutString, parseShortcutString } from './parse';
6
6
  export { SequenceTracker } from './sequence';
7
7
  export type { SequenceEntry } from './sequence';
8
8
  export { ShortcutManager } from './ShortcutManager';
9
- export type { ParsedShortcut, ShortcutBinding, ShortcutChord, ShortcutCombo, ShortcutRegistration, ShortcutSequence, ShortcutSummary, } from './types';
9
+ export type { Modifier, ParsedShortcut, ShortcutBinding, ShortcutCombo, ShortcutRegistration, ShortcutSummary, } from './types';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,cAAc,EACd,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,cAAc,EACd,WAAW,EACX,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,QAAQ,EACR,cAAc,EACd,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,eAAe,GAChB,MAAM,SAAS,CAAC"}
@@ -4,6 +4,9 @@ import { ShortcutCombo } from './types';
4
4
  export declare function normalizeKey(key: string): string;
5
5
  /** Map `KeyboardEvent.code` to normalized key (fixes macOS Option+letter). */
6
6
  export declare function normalizedPhysicalKey(code: string): string | null;
7
- /** Low-level test: does this keyboard event match the combo? */
7
+ /**
8
+ * Test whether a KeyboardEvent matches a ShortcutCombo exactly
9
+ * (same modifiers, no more / no fewer, and matching key).
10
+ */
8
11
  export declare function matchShortcut(event: KeyboardEvent, combo: ShortcutCombo): boolean;
9
12
  //# sourceMappingURL=match.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/match.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsDjE;AAsCD,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAGjF"}
1
+ {"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/match.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvD,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsDjE;AAYD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAcjF"}
@@ -1,5 +1,4 @@
1
1
  import { KEY_ALIASES } from "./constants.js";
2
- import { isMac } from "./platform.js";
3
2
  function normalizeKey(key) {
4
3
  const lower = key.toLowerCase();
5
4
  return KEY_ALIASES[lower] ?? lower;
@@ -54,40 +53,24 @@ function normalizedPhysicalKey(code) {
54
53
  }
55
54
  return null;
56
55
  }
57
- function modifiersMatch(event, combo) {
58
- const wantsMod = combo.modifiers.mod;
59
- const modPressed = isMac ? event.metaKey : event.ctrlKey;
60
- const wantsCtrl = combo.modifiers.ctrl;
61
- const wantsMeta = combo.modifiers.meta;
62
- const wantsAlt = combo.modifiers.alt;
63
- const wantsShift = combo.modifiers.shift;
64
- if (wantsMod) {
65
- if (!modPressed) return false;
66
- if (wantsAlt && !event.altKey) return false;
67
- if (wantsShift && !event.shiftKey) return false;
68
- if (!wantsAlt && event.altKey) return false;
69
- if (!wantsShift && event.shiftKey) return false;
70
- if (wantsCtrl && !event.ctrlKey) return false;
71
- if (wantsMeta && !event.metaKey) return false;
72
- return true;
73
- }
74
- if (wantsCtrl !== event.ctrlKey) return false;
75
- if (wantsMeta !== event.metaKey) return false;
76
- if (wantsAlt !== event.altKey) return false;
77
- if (wantsShift !== event.shiftKey) return false;
78
- return true;
79
- }
80
- function keyMatch(event, expectedKey) {
81
- if (!expectedKey) return true;
82
- const normalized = normalizeKey(event.key);
83
- if (normalized === expectedKey) return true;
84
- const physical = normalizedPhysicalKey(event.code);
85
- if (physical !== null && physical === expectedKey) return true;
86
- return false;
56
+ function getActiveModifiers(event) {
57
+ const mods = /* @__PURE__ */ new Set();
58
+ if (event.ctrlKey) mods.add("ctrl");
59
+ if (event.metaKey) mods.add("meta");
60
+ if (event.altKey) mods.add("alt");
61
+ if (event.shiftKey) mods.add("shift");
62
+ return mods;
87
63
  }
88
64
  function matchShortcut(event, combo) {
89
- if (!modifiersMatch(event, combo)) return false;
90
- return keyMatch(event, combo.key);
65
+ const pressed = getActiveModifiers(event);
66
+ if (pressed.size !== combo.modifiers.size) return false;
67
+ for (const mod of combo.modifiers) {
68
+ if (!pressed.has(mod)) return false;
69
+ }
70
+ const fromKey = normalizeKey(event.key);
71
+ if (fromKey === combo.key) return true;
72
+ const fromCode = normalizedPhysicalKey(event.code);
73
+ return fromCode !== null && fromCode === combo.key;
91
74
  }
92
75
  export {
93
76
  matchShortcut,
@@ -1,13 +1,13 @@
1
1
  import { ParsedShortcut } from './types';
2
2
 
3
3
  /**
4
- * Parse a shortcut string into chord or sequence structure.
5
- * `mod+k` → chord; `g i` → sequence of two single-key chords.
4
+ * Parse a shortcut string into the JS-compatible `{ isSequence, combos }` shape.
5
+ * `mod+k` → single combo (mod resolved to ctrl/meta); `g i` → sequence.
6
6
  */
7
- export declare function parseShortcutString(keys: string): ParsedShortcut;
7
+ export declare function parseShortcutString(shortcutStr: string): ParsedShortcut;
8
8
  /**
9
9
  * Normalize shortcut string for blacklist / dedup / comparison.
10
- * Parses, sorts modifiers alphabetically, and reconstructs.
10
+ * Modifiers are sorted alphabetically; `mod` is already platform-resolved.
11
11
  */
12
- export declare function normalizeShortcutString(keys: string): string;
12
+ export declare function normalizeShortcutString(shortcutStr: string): string;
13
13
  //# sourceMappingURL=parse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AAmC7D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAmBhE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkB5D"}
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/parse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,cAAc,EAAiB,MAAM,SAAS,CAAC;AA8CvE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAYvE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQnE"}
@@ -1,62 +1,48 @@
1
1
  import { KEY_ALIASES } from "./constants.js";
2
- function normalizeToken(token) {
3
- const lower = token.trim().toLowerCase();
4
- return KEY_ALIASES[lower] ?? lower;
2
+ import { isMac } from "./platform.js";
3
+ const MODIFIER_SET = /* @__PURE__ */ new Set(["ctrl", "meta", "alt", "shift", "mod"]);
4
+ function resolveModifier(mod) {
5
+ if (mod === "mod") return isMac ? "meta" : "ctrl";
6
+ return mod;
5
7
  }
6
- function parseComboPart(part) {
7
- const tokens = part.split("+").map((t) => t.trim().toLowerCase()).filter(Boolean);
8
- const modifiers = {
9
- ctrl: false,
10
- meta: false,
11
- alt: false,
12
- shift: false,
13
- mod: false
14
- };
8
+ function canonicalModifierToken(token) {
9
+ if (token === "control") return "ctrl";
10
+ if (token === "cmd" || token === "command") return "meta";
11
+ if (token === "option") return "alt";
12
+ if (MODIFIER_SET.has(token)) return token;
13
+ return null;
14
+ }
15
+ function parseCombo(comboStr) {
16
+ const parts = comboStr.toLowerCase().split("+").map((p) => p.trim()).filter(Boolean);
17
+ const modifiers = /* @__PURE__ */ new Set();
15
18
  let key = "";
16
- for (const token of tokens) {
17
- if (token === "mod") modifiers.mod = true;
18
- else if (token === "ctrl" || token === "control") modifiers.ctrl = true;
19
- else if (token === "meta" || token === "cmd" || token === "command") modifiers.meta = true;
20
- else if (token === "alt" || token === "option") modifiers.alt = true;
21
- else if (token === "shift") modifiers.shift = true;
22
- else key = normalizeToken(token);
19
+ for (const part of parts) {
20
+ const modToken = canonicalModifierToken(part);
21
+ if (modToken !== null) {
22
+ modifiers.add(resolveModifier(modToken));
23
+ } else {
24
+ key = KEY_ALIASES[part] ?? part;
25
+ }
23
26
  }
24
27
  return { modifiers, key };
25
28
  }
26
- function parseShortcutString(keys) {
27
- const trimmed = keys.trim();
28
- if (trimmed.includes(" ") && !trimmed.includes("+")) {
29
- const parts = trimmed.split(/\s+/).filter(Boolean);
30
- return {
31
- type: "sequence",
32
- steps: parts.map((p) => parseComboPart(p))
33
- };
34
- }
35
- if (/\s+\S/.test(trimmed) && trimmed.includes("+")) {
36
- const parts = trimmed.split(/\s+/).filter(Boolean);
37
- return {
38
- type: "sequence",
39
- steps: parts.map((p) => parseComboPart(p))
40
- };
29
+ function parseShortcutString(shortcutStr) {
30
+ const trimmed = shortcutStr.trim();
31
+ const parts = trimmed.split(/\s+/).filter(Boolean);
32
+ if (parts.length <= 1) {
33
+ return { isSequence: false, combos: [parseCombo(parts[0] ?? "")] };
41
34
  }
42
- return { type: "chord", combo: parseComboPart(trimmed) };
35
+ return {
36
+ isSequence: true,
37
+ combos: parts.map(parseCombo)
38
+ };
43
39
  }
44
- function normalizeShortcutString(keys) {
45
- const parsed = parseShortcutString(keys);
46
- function normCombo(combo) {
47
- const mods = [];
48
- if (combo.modifiers.mod) mods.push("mod");
49
- if (combo.modifiers.ctrl) mods.push("ctrl");
50
- if (combo.modifiers.meta) mods.push("meta");
51
- if (combo.modifiers.alt) mods.push("alt");
52
- if (combo.modifiers.shift) mods.push("shift");
53
- mods.sort();
40
+ function normalizeShortcutString(shortcutStr) {
41
+ const parsed = parseShortcutString(shortcutStr);
42
+ return parsed.combos.map((combo) => {
43
+ const mods = [...combo.modifiers].sort();
54
44
  return mods.length > 0 ? [...mods, combo.key].join("+") : combo.key;
55
- }
56
- if (parsed.type === "sequence") {
57
- return parsed.steps.map(normCombo).join(" ");
58
- }
59
- return normCombo(parsed.combo);
45
+ }).join(" ");
60
46
  }
61
47
  export {
62
48
  normalizeShortcutString,
@@ -1,22 +1,23 @@
1
+ /** Platform modifier after `mod` is resolved at parse time. */
2
+ export type Modifier = 'ctrl' | 'meta' | 'alt' | 'shift';
3
+ /**
4
+ * A single key combination (e.g. Mod+Shift+K).
5
+ * JS-compatible: `modifiers` is a Set (no unresolved `mod` token).
6
+ */
1
7
  export interface ShortcutCombo {
2
- modifiers: {
3
- ctrl: boolean;
4
- meta: boolean;
5
- alt: boolean;
6
- shift: boolean;
7
- mod: boolean;
8
- };
8
+ modifiers: Set<Modifier>;
9
+ /** Normalized lowercase key (e.g. 'k', 'enter', 'arrowup') */
9
10
  key: string;
10
11
  }
11
- export interface ShortcutSequence {
12
- type: 'sequence';
13
- steps: ShortcutCombo[];
12
+ /**
13
+ * Parsed shortcut — single combo or sequence of combos.
14
+ * JS-compatible shape used by consumers of the previous JS package.
15
+ */
16
+ export interface ParsedShortcut {
17
+ isSequence: boolean;
18
+ /** Single-element for simple chords; multi for sequences like `g i` */
19
+ combos: ShortcutCombo[];
14
20
  }
15
- export interface ShortcutChord {
16
- type: 'chord';
17
- combo: ShortcutCombo;
18
- }
19
- export type ParsedShortcut = ShortcutSequence | ShortcutChord;
20
21
  export interface ShortcutRegistration {
21
22
  id: string;
22
23
  keys: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/shortcuts/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE;QACT,IAAI,EAAE,OAAO,CAAC;QACd,IAAI,EAAE,OAAO,CAAC;QACd,GAAG,EAAE,OAAO,CAAC;QACb,KAAK,EAAE,OAAO,CAAC;QACf,GAAG,EAAE,OAAO,CAAC;KACd,CAAC;IACF,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,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AC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impact-ui",
3
- "version": "4.0.12-alpha.2",
3
+ "version": "4.0.13-alpha.1",
4
4
  "description": "Impact Analytics UI library",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",