wulf.js 1.9.1 → 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.
Files changed (42) hide show
  1. package/README.md +154 -21
  2. package/changelog.md +21 -0
  3. package/dist/focus-trap.global.js +1 -1
  4. package/dist/focus-trap.global.min.js +1 -1
  5. package/dist/index.esm.js +589 -0
  6. package/dist/index.esm.js.map +4 -4
  7. package/dist/index.global.js +590 -1
  8. package/dist/index.global.js.map +4 -4
  9. package/dist/index.global.min.js +3 -3
  10. package/dist/index.global.min.js.map +4 -4
  11. package/dist/mask.global.js +1 -1
  12. package/dist/mask.global.min.js +1 -1
  13. package/dist/masonry.global.js +1 -1
  14. package/dist/masonry.global.min.js +1 -1
  15. package/dist/scroll.global.js +1 -1
  16. package/dist/scroll.global.min.js +1 -1
  17. package/dist/shortcut.esm.js +584 -0
  18. package/dist/shortcut.esm.js.map +7 -0
  19. package/dist/shortcut.global.js +610 -0
  20. package/dist/shortcut.global.js.map +7 -0
  21. package/dist/shortcut.global.min.js +3 -0
  22. package/dist/shortcut.global.min.js.map +7 -0
  23. package/dist/toast.global.js +1 -1
  24. package/dist/toast.global.min.js +1 -1
  25. package/dist/types/index.d.ts +2 -0
  26. package/dist/types/shortcut/ShortcutFormatter.d.ts +31 -0
  27. package/dist/types/shortcut/ShortcutManager.d.ts +91 -0
  28. package/dist/types/shortcut/index.d.ts +4 -0
  29. package/dist/types/shortcut/types.d.ts +101 -0
  30. package/package.json +17 -10
  31. package/dist/focus-trap.cjs.js +0 -430
  32. package/dist/focus-trap.cjs.js.map +0 -7
  33. package/dist/index.cjs.js +0 -5365
  34. package/dist/index.cjs.js.map +0 -7
  35. package/dist/mask.cjs.js +0 -3086
  36. package/dist/mask.cjs.js.map +0 -7
  37. package/dist/masonry.cjs.js +0 -858
  38. package/dist/masonry.cjs.js.map +0 -7
  39. package/dist/scroll.cjs.js +0 -823
  40. package/dist/scroll.cjs.js.map +0 -7
  41. package/dist/toast.cjs.js +0 -715
  42. package/dist/toast.cjs.js.map +0 -7
package/dist/index.esm.js CHANGED
@@ -5323,6 +5323,593 @@ if (typeof window !== "undefined") {
5323
5323
  FocusTrap
5324
5324
  });
5325
5325
  }
5326
+
5327
+ // src/shortcut/index.ts
5328
+ var shortcut_exports = {};
5329
+ __export(shortcut_exports, {
5330
+ ShortcutFormatter: () => ShortcutFormatter,
5331
+ ShortcutManager: () => ShortcutManager,
5332
+ default: () => ShortcutManager
5333
+ });
5334
+
5335
+ // src/shortcut/ShortcutFormatter.ts
5336
+ var ShortcutFormatter = class _ShortcutFormatter {
5337
+ /**
5338
+ * Détecte si l'environnement d'exécution actuel est un environnement Apple (macOS / iOS / iPadOS).
5339
+ */
5340
+ static isApple() {
5341
+ if (typeof navigator === "undefined") {
5342
+ return false;
5343
+ }
5344
+ const uaData = navigator.userAgentData;
5345
+ if (uaData && typeof uaData.platform === "string") {
5346
+ const p = uaData.platform.toLowerCase();
5347
+ if (p.includes("mac") || p.includes("ios")) {
5348
+ return true;
5349
+ }
5350
+ }
5351
+ const platform = (navigator.platform || "").toLowerCase();
5352
+ if (platform.includes("mac") || platform.includes("iphone") || platform.includes("ipad") || platform.includes("ipod")) {
5353
+ return true;
5354
+ }
5355
+ const ua = (navigator.userAgent || "").toLowerCase();
5356
+ return ua.includes("macintosh") || ua.includes("mac os x") || ua.includes("ipad") || ua.includes("iphone");
5357
+ }
5358
+ /**
5359
+ * Normalise un nom de touche unitaire pour les comparaisons.
5360
+ */
5361
+ static normalizeKeyName(key) {
5362
+ const k = key.trim().toLowerCase();
5363
+ switch (k) {
5364
+ case "esc":
5365
+ return "escape";
5366
+ case "return":
5367
+ return "enter";
5368
+ case "space":
5369
+ case "spacebar":
5370
+ return " ";
5371
+ case "del":
5372
+ return "delete";
5373
+ case "ins":
5374
+ return "insert";
5375
+ case "up":
5376
+ return "arrowup";
5377
+ case "down":
5378
+ return "arrowdown";
5379
+ case "left":
5380
+ return "arrowleft";
5381
+ case "right":
5382
+ return "arrowright";
5383
+ default:
5384
+ return k;
5385
+ }
5386
+ }
5387
+ /**
5388
+ * Parse une chaîne de combinaison (ex: "Mod+K", "g i", "Shift+?", "Alt++")
5389
+ * et retourne la liste des étapes normalisées nécessaires au déclenchement.
5390
+ */
5391
+ static parseCombo(combo, isApple = _ShortcutFormatter.isApple()) {
5392
+ const trimmed = combo.trim();
5393
+ if (!trimmed) {
5394
+ return [];
5395
+ }
5396
+ const stepsRaw = trimmed.split(/\s+/);
5397
+ const steps = [];
5398
+ for (const rawStep of stepsRaw) {
5399
+ const tokens = [];
5400
+ let currentToken = "";
5401
+ for (let i = 0; i < rawStep.length; i++) {
5402
+ const char = rawStep[i];
5403
+ if (char === "+") {
5404
+ if (currentToken === "" && tokens.length > 0) {
5405
+ tokens.push("+");
5406
+ } else if (currentToken !== "") {
5407
+ tokens.push(currentToken);
5408
+ currentToken = "";
5409
+ }
5410
+ } else {
5411
+ currentToken += char;
5412
+ }
5413
+ }
5414
+ if (currentToken !== "") {
5415
+ tokens.push(currentToken);
5416
+ }
5417
+ let ctrl = false;
5418
+ let alt = false;
5419
+ let shift = false;
5420
+ let meta = false;
5421
+ let mainKey = "";
5422
+ for (const token of tokens) {
5423
+ const lower = token.trim().toLowerCase();
5424
+ if (lower === "ctrl" || lower === "control") {
5425
+ ctrl = true;
5426
+ } else if (lower === "alt" || lower === "option" || lower === "opt") {
5427
+ alt = true;
5428
+ } else if (lower === "shift" || lower === "maj") {
5429
+ shift = true;
5430
+ } else if (lower === "cmd" || lower === "command" || lower === "meta" || lower === "win" || lower === "super") {
5431
+ meta = true;
5432
+ } else if (lower === "mod" || lower === "$mod") {
5433
+ if (isApple) {
5434
+ meta = true;
5435
+ } else {
5436
+ ctrl = true;
5437
+ }
5438
+ } else {
5439
+ mainKey = _ShortcutFormatter.normalizeKeyName(token);
5440
+ }
5441
+ }
5442
+ steps.push({
5443
+ ctrl,
5444
+ alt,
5445
+ shift,
5446
+ meta,
5447
+ key: mainKey
5448
+ });
5449
+ }
5450
+ return steps;
5451
+ }
5452
+ /**
5453
+ * Formate une combinaison brute en libellé soigné et lisible pour l'OS cible.
5454
+ * Ex: "Mod+Shift+P" -> macOS: "⇧⌘P", Windows: "Ctrl+Shift+P"
5455
+ * Ex: "g i" -> "g puis i" ou "g i"
5456
+ */
5457
+ static format(combo, isApple = _ShortcutFormatter.isApple()) {
5458
+ const steps = _ShortcutFormatter.parseCombo(combo, isApple);
5459
+ if (steps.length === 0) {
5460
+ return combo;
5461
+ }
5462
+ const formattedSteps = steps.map((step) => {
5463
+ const parts = [];
5464
+ if (isApple) {
5465
+ if (step.ctrl) parts.push("\u2303");
5466
+ if (step.alt) parts.push("\u2325");
5467
+ if (step.shift) parts.push("\u21E7");
5468
+ if (step.meta) parts.push("\u2318");
5469
+ const keyDisplay = _ShortcutFormatter.formatKeyDisplay(step.key, true);
5470
+ parts.push(keyDisplay);
5471
+ return parts.join("");
5472
+ } else {
5473
+ if (step.ctrl) parts.push("Ctrl");
5474
+ if (step.alt) parts.push("Alt");
5475
+ if (step.shift) parts.push("Shift");
5476
+ if (step.meta) parts.push("Win");
5477
+ const keyDisplay = _ShortcutFormatter.formatKeyDisplay(step.key, false);
5478
+ parts.push(keyDisplay);
5479
+ return parts.join("+");
5480
+ }
5481
+ });
5482
+ return formattedSteps.join(" ");
5483
+ }
5484
+ /**
5485
+ * Convertit un combo technique vers le format officiel WAI-ARIA `aria-keyshortcuts`.
5486
+ * Standard W3C : les modificateurs sont 'Control', 'Alt', 'Shift', 'Meta' et le séparateur est '+'.
5487
+ */
5488
+ static toAriaKeyShortcuts(combo, isApple = _ShortcutFormatter.isApple()) {
5489
+ const steps = _ShortcutFormatter.parseCombo(combo, isApple);
5490
+ return steps.map((step) => {
5491
+ const parts = [];
5492
+ if (step.ctrl) parts.push("Control");
5493
+ if (step.alt) parts.push("Alt");
5494
+ if (step.shift) parts.push("Shift");
5495
+ if (step.meta) parts.push("Meta");
5496
+ parts.push(_ShortcutFormatter.formatKeyDisplay(step.key, false));
5497
+ return parts.join("+");
5498
+ }).join(" ");
5499
+ }
5500
+ static formatKeyDisplay(key, isApple) {
5501
+ if (!key) return "";
5502
+ switch (key.toLowerCase()) {
5503
+ case "escape":
5504
+ return isApple ? "\u238B" : "Esc";
5505
+ case "enter":
5506
+ return isApple ? "\u21A9" : "Enter";
5507
+ case " ":
5508
+ return isApple ? "\u2423" : "Space";
5509
+ case "tab":
5510
+ return isApple ? "\u21E5" : "Tab";
5511
+ case "backspace":
5512
+ return isApple ? "\u232B" : "Backspace";
5513
+ case "delete":
5514
+ return isApple ? "\u2326" : "Suppr";
5515
+ case "arrowup":
5516
+ return "\u2191";
5517
+ case "arrowdown":
5518
+ return "\u2193";
5519
+ case "arrowleft":
5520
+ return "\u2190";
5521
+ case "arrowright":
5522
+ return "\u2192";
5523
+ default:
5524
+ return key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1);
5525
+ }
5526
+ }
5527
+ };
5528
+
5529
+ // src/shortcut/ShortcutManager.ts
5530
+ var ShortcutManager = class _ShortcutManager {
5531
+ constructor(options) {
5532
+ this.shortcuts = /* @__PURE__ */ new Map();
5533
+ this.scopeStack = [];
5534
+ this.sequenceBuffer = [];
5535
+ this.sequenceTimer = null;
5536
+ this.isListening = true;
5537
+ this.boundListener = null;
5538
+ this.idCounter = 0;
5539
+ this.options = {
5540
+ defaultScope: options?.defaultScope || "global",
5541
+ sequenceTimeout: options?.sequenceTimeout ?? 800,
5542
+ target: options?.target || (typeof window !== "undefined" ? window : {}),
5543
+ onError: options?.onError
5544
+ };
5545
+ this.scopeStack = [this.options.defaultScope];
5546
+ this.initListener();
5547
+ }
5548
+ /**
5549
+ * Vérifie si un élément DOM est une zone d'édition où la saisie de l'utilisateur
5550
+ * ne doit JAMAIS être interrompue ou détournée (Axiome Primordial).
5551
+ */
5552
+ static isEditable(target) {
5553
+ if (!target || typeof target.tagName !== "string") {
5554
+ return false;
5555
+ }
5556
+ const el = target;
5557
+ const tagName = el.tagName.toUpperCase();
5558
+ if (tagName === "INPUT") {
5559
+ const type = el.type?.toLowerCase() || "text";
5560
+ const nonTextTypes = ["button", "checkbox", "radio", "submit", "reset", "range", "color", "file", "image"];
5561
+ return !nonTextTypes.includes(type);
5562
+ }
5563
+ if (tagName === "TEXTAREA" || tagName === "SELECT") {
5564
+ return true;
5565
+ }
5566
+ if (el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "plaintext-only") {
5567
+ return true;
5568
+ }
5569
+ const role = el.getAttribute("role");
5570
+ if (role === "textbox" || role === "searchbox") {
5571
+ return true;
5572
+ }
5573
+ return false;
5574
+ }
5575
+ /**
5576
+ * Enregistre un ou plusieurs raccourcis clavier.
5577
+ * Retourne une fonction de nettoyage pour désenregistrer immédiatement.
5578
+ */
5579
+ bind(definition) {
5580
+ const list = Array.isArray(definition) ? definition : [definition];
5581
+ const registeredIds = [];
5582
+ for (const def of list) {
5583
+ if (!def.combo || typeof def.handler !== "function") {
5584
+ continue;
5585
+ }
5586
+ const id = `wulf_shortcut_${++this.idCounter}`;
5587
+ const normalizedSteps = ShortcutFormatter.parseCombo(def.combo);
5588
+ const isSequence = normalizedSteps.length > 1;
5589
+ const formattedCombo = ShortcutFormatter.format(def.combo);
5590
+ const registered = {
5591
+ ...def,
5592
+ id,
5593
+ scope: def.scope || "global",
5594
+ category: def.category || "G\xE9n\xE9ral",
5595
+ allowInEditable: def.allowInEditable ?? false,
5596
+ preventDefault: def.preventDefault ?? true,
5597
+ stopPropagation: def.stopPropagation ?? true,
5598
+ priority: def.priority ?? 0,
5599
+ formattedCombo,
5600
+ normalizedSteps,
5601
+ isSequence
5602
+ };
5603
+ this.shortcuts.set(id, registered);
5604
+ registeredIds.push(id);
5605
+ }
5606
+ return () => {
5607
+ for (const id of registeredIds) {
5608
+ this.shortcuts.delete(id);
5609
+ }
5610
+ };
5611
+ }
5612
+ /**
5613
+ * Retire tous les raccourcis correspondant à une combinaison et éventuellement un scope.
5614
+ */
5615
+ unbind(combo, scope) {
5616
+ const formatted = ShortcutFormatter.format(combo);
5617
+ for (const [id, s] of this.shortcuts.entries()) {
5618
+ if (s.formattedCombo === formatted || s.combo.trim().toLowerCase() === combo.trim().toLowerCase()) {
5619
+ if (!scope || s.scope === scope) {
5620
+ this.shortcuts.delete(id);
5621
+ }
5622
+ }
5623
+ }
5624
+ }
5625
+ /**
5626
+ * Empile un nouveau scope actif (mode LIFO).
5627
+ * Seuls les raccourcis de ce scope (et les omniprésents '*') seront actifs.
5628
+ */
5629
+ pushScope(scope) {
5630
+ if (scope && typeof scope === "string") {
5631
+ this.scopeStack.push(scope);
5632
+ this.clearSequenceBuffer();
5633
+ }
5634
+ }
5635
+ /**
5636
+ * Dépile le scope actuel et rétablit le précédent.
5637
+ * Si un paramètre `scope` est passé, ne retire que si le scope actuel correspond.
5638
+ */
5639
+ popScope(scope) {
5640
+ if (this.scopeStack.length <= 1) {
5641
+ return this.scopeStack[0];
5642
+ }
5643
+ if (scope) {
5644
+ if (this.getScope() === scope) {
5645
+ const popped2 = this.scopeStack.pop();
5646
+ this.clearSequenceBuffer();
5647
+ return popped2;
5648
+ }
5649
+ return void 0;
5650
+ }
5651
+ const popped = this.scopeStack.pop();
5652
+ this.clearSequenceBuffer();
5653
+ return popped;
5654
+ }
5655
+ /**
5656
+ * Réinitialise brutalement la pile pour activer le scope spécifié.
5657
+ */
5658
+ setScope(scope) {
5659
+ this.scopeStack = [scope || this.options.defaultScope];
5660
+ this.clearSequenceBuffer();
5661
+ }
5662
+ /**
5663
+ * Retourne le scope actuellement actif au sommet de la pile.
5664
+ */
5665
+ getScope() {
5666
+ return this.scopeStack[this.scopeStack.length - 1] || this.options.defaultScope;
5667
+ }
5668
+ /**
5669
+ * Retourne une copie de la pile complète des scopes.
5670
+ */
5671
+ getScopeStack() {
5672
+ return [...this.scopeStack];
5673
+ }
5674
+ /**
5675
+ * Met en pause l'écoute de tous les raccourcis.
5676
+ */
5677
+ pause() {
5678
+ this.isListening = false;
5679
+ this.clearSequenceBuffer();
5680
+ }
5681
+ /**
5682
+ * Réactive l'écoute des raccourcis.
5683
+ */
5684
+ resume() {
5685
+ this.isListening = true;
5686
+ }
5687
+ /**
5688
+ * Indique si le gestionnaire est actif et à l'écoute.
5689
+ */
5690
+ isActive() {
5691
+ return this.isListening;
5692
+ }
5693
+ /**
5694
+ * Retourne le catalogue des raccourcis enregistrés (optionnellement filtré par scope).
5695
+ */
5696
+ getRegistry(scope) {
5697
+ const list = [];
5698
+ for (const shortcut of this.shortcuts.values()) {
5699
+ if (!scope || shortcut.scope === scope || shortcut.scope === "*") {
5700
+ list.push({ ...shortcut });
5701
+ }
5702
+ }
5703
+ return list;
5704
+ }
5705
+ /**
5706
+ * Associe l'attribut standard WAI-ARIA `aria-keyshortcuts` sur un élément DOM.
5707
+ */
5708
+ attachAria(element, combo) {
5709
+ if (element && typeof element.setAttribute === "function") {
5710
+ const ariaValue = ShortcutFormatter.toAriaKeyShortcuts(combo);
5711
+ element.setAttribute("aria-keyshortcuts", ariaValue);
5712
+ }
5713
+ }
5714
+ /**
5715
+ * Formate une combinaison brute selon l'OS courant ("⌘K" ou "Ctrl+K").
5716
+ */
5717
+ static format(combo, isApple) {
5718
+ return ShortcutFormatter.format(combo, isApple);
5719
+ }
5720
+ /**
5721
+ * Détruit le gestionnaire : supprime les écouteurs du DOM et vide toute la mémoire.
5722
+ */
5723
+ destroy() {
5724
+ this.pause();
5725
+ this.removeListener();
5726
+ this.shortcuts.clear();
5727
+ this.scopeStack = [];
5728
+ this.clearSequenceBuffer();
5729
+ }
5730
+ // --- Implémentation Interne ---
5731
+ initListener() {
5732
+ if (typeof window === "undefined" || !this.options.target) {
5733
+ return;
5734
+ }
5735
+ this.boundListener = (event) => this.handleKeyDown(event);
5736
+ const target = this.options.target;
5737
+ if (typeof target.addEventListener === "function") {
5738
+ target.addEventListener("keydown", this.boundListener, false);
5739
+ }
5740
+ }
5741
+ removeListener() {
5742
+ if (this.boundListener && this.options.target) {
5743
+ const target = this.options.target;
5744
+ if (typeof target.removeEventListener === "function") {
5745
+ target.removeEventListener("keydown", this.boundListener, false);
5746
+ }
5747
+ this.boundListener = null;
5748
+ }
5749
+ }
5750
+ handleKeyDown(event) {
5751
+ if (!this.isListening) {
5752
+ return;
5753
+ }
5754
+ const k = (event.key || "").toLowerCase();
5755
+ if (["control", "alt", "shift", "meta"].includes(k)) {
5756
+ return;
5757
+ }
5758
+ const currentScope = this.getScope();
5759
+ const isEditable = _ShortcutManager.isEditable(event.target);
5760
+ const currentStep = {
5761
+ ctrl: event.ctrlKey,
5762
+ alt: event.altKey,
5763
+ shift: event.shiftKey,
5764
+ meta: event.metaKey,
5765
+ key: ShortcutFormatter.normalizeKeyName(event.key || "")
5766
+ };
5767
+ const now = Date.now();
5768
+ if (this.sequenceBuffer.length > 0) {
5769
+ const last = this.sequenceBuffer[this.sequenceBuffer.length - 1];
5770
+ if (now - last.timestamp > this.options.sequenceTimeout) {
5771
+ this.clearSequenceBuffer();
5772
+ }
5773
+ }
5774
+ const activeCandidates = this.getActiveShortcuts(currentScope, isEditable);
5775
+ const proposedSequence = [...this.sequenceBuffer.map((b) => b.step), currentStep];
5776
+ const matchingSequence = this.findMatchingSequence(activeCandidates, proposedSequence);
5777
+ if (matchingSequence) {
5778
+ this.clearSequenceBuffer();
5779
+ this.executeShortcut(matchingSequence, event, currentScope, true);
5780
+ return;
5781
+ }
5782
+ if (this.isPrefixOfAnySequence(activeCandidates, proposedSequence)) {
5783
+ this.sequenceBuffer.push({ step: currentStep, timestamp: now });
5784
+ this.resetSequenceTimer();
5785
+ if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !isEditable) {
5786
+ event.preventDefault();
5787
+ }
5788
+ return;
5789
+ }
5790
+ this.clearSequenceBuffer();
5791
+ const matchingChord = this.findMatchingChord(activeCandidates, currentStep, event);
5792
+ if (matchingChord) {
5793
+ this.executeShortcut(matchingChord, event, currentScope, false);
5794
+ }
5795
+ }
5796
+ getActiveShortcuts(currentScope, isEditable) {
5797
+ const list = [];
5798
+ for (const shortcut of this.shortcuts.values()) {
5799
+ if (shortcut.scope !== currentScope && shortcut.scope !== "*") {
5800
+ continue;
5801
+ }
5802
+ if (isEditable && !shortcut.allowInEditable) {
5803
+ continue;
5804
+ }
5805
+ list.push(shortcut);
5806
+ }
5807
+ return list.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
5808
+ }
5809
+ stepMatches(step, eventStep, rawEvent) {
5810
+ if (step.ctrl !== eventStep.ctrl) return false;
5811
+ if (step.alt !== eventStep.alt) return false;
5812
+ if (step.meta !== eventStep.meta) return false;
5813
+ const keyMatches = step.key === eventStep.key || rawEvent && step.key === rawEvent.key.toLowerCase();
5814
+ if (!keyMatches) return false;
5815
+ if (step.shift === eventStep.shift) {
5816
+ return true;
5817
+ }
5818
+ if (!step.shift && eventStep.shift) {
5819
+ if (rawEvent && rawEvent.key === step.key) {
5820
+ return true;
5821
+ }
5822
+ }
5823
+ return false;
5824
+ }
5825
+ findMatchingChord(candidates, currentStep, rawEvent) {
5826
+ for (const candidate of candidates) {
5827
+ if (candidate.isSequence || candidate.normalizedSteps.length !== 1) {
5828
+ continue;
5829
+ }
5830
+ const step = candidate.normalizedSteps[0];
5831
+ if (this.stepMatches(step, currentStep, rawEvent)) {
5832
+ return candidate;
5833
+ }
5834
+ }
5835
+ return null;
5836
+ }
5837
+ findMatchingSequence(candidates, proposed) {
5838
+ for (const candidate of candidates) {
5839
+ if (!candidate.isSequence || candidate.normalizedSteps.length !== proposed.length) {
5840
+ continue;
5841
+ }
5842
+ let allMatch = true;
5843
+ for (let i = 0; i < proposed.length; i++) {
5844
+ if (!this.stepMatches(candidate.normalizedSteps[i], proposed[i])) {
5845
+ allMatch = false;
5846
+ break;
5847
+ }
5848
+ }
5849
+ if (allMatch) {
5850
+ return candidate;
5851
+ }
5852
+ }
5853
+ return null;
5854
+ }
5855
+ isPrefixOfAnySequence(candidates, proposed) {
5856
+ for (const candidate of candidates) {
5857
+ if (!candidate.isSequence || candidate.normalizedSteps.length <= proposed.length) {
5858
+ continue;
5859
+ }
5860
+ let prefixMatches = true;
5861
+ for (let i = 0; i < proposed.length; i++) {
5862
+ if (!this.stepMatches(candidate.normalizedSteps[i], proposed[i])) {
5863
+ prefixMatches = false;
5864
+ break;
5865
+ }
5866
+ }
5867
+ if (prefixMatches) {
5868
+ return true;
5869
+ }
5870
+ }
5871
+ return false;
5872
+ }
5873
+ executeShortcut(shortcut, event, scope, isSequence) {
5874
+ if (shortcut.preventDefault) {
5875
+ event.preventDefault();
5876
+ }
5877
+ if (shortcut.stopPropagation) {
5878
+ event.stopPropagation();
5879
+ }
5880
+ const info = {
5881
+ combo: shortcut.combo,
5882
+ formattedCombo: shortcut.formattedCombo,
5883
+ scope,
5884
+ target: event.target,
5885
+ isSequence
5886
+ };
5887
+ try {
5888
+ shortcut.handler(event, info);
5889
+ } catch (err) {
5890
+ if (this.options.onError) {
5891
+ this.options.onError(err instanceof Error ? err : new Error(String(err)), shortcut.combo);
5892
+ } else {
5893
+ console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${shortcut.combo}":`, err);
5894
+ }
5895
+ }
5896
+ }
5897
+ resetSequenceTimer() {
5898
+ if (this.sequenceTimer) {
5899
+ clearTimeout(this.sequenceTimer);
5900
+ }
5901
+ this.sequenceTimer = setTimeout(() => {
5902
+ this.clearSequenceBuffer();
5903
+ }, this.options.sequenceTimeout);
5904
+ }
5905
+ clearSequenceBuffer() {
5906
+ this.sequenceBuffer = [];
5907
+ if (this.sequenceTimer) {
5908
+ clearTimeout(this.sequenceTimer);
5909
+ this.sequenceTimer = null;
5910
+ }
5911
+ }
5912
+ };
5326
5913
  export {
5327
5914
  AmountEngine,
5328
5915
  AuditableComponent,
@@ -5339,8 +5926,10 @@ export {
5339
5926
  MaskKeyboard,
5340
5927
  masonry_exports as Masonry,
5341
5928
  scroll_exports as Scroll,
5929
+ shortcut_exports as Shortcut,
5342
5930
  toast_exports as Toast,
5343
5931
  FocusTrap as WulfFocusTrap,
5932
+ ShortcutManager as WulfShortcut,
5344
5933
  createI18nManager,
5345
5934
  mask_default as default,
5346
5935
  resolveMaskConstructorArgs