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
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/shortcut/index.ts", "../src/shortcut/ShortcutFormatter.ts", "../src/shortcut/ShortcutManager.ts"],
4
+ "sourcesContent": ["export { ShortcutManager } from './ShortcutManager';\nexport { ShortcutFormatter } from './ShortcutFormatter';\nexport * from './types';\nexport { ShortcutManager as default } from './ShortcutManager';\n\n", "import { NormalizedStep } from './types';\n\n/**\n * Utilitaires de d\u00E9tection d'OS, de parsing de cha\u00EEnes et de formatage de raccourcis.\n */\nexport class ShortcutFormatter {\n /**\n * D\u00E9tecte si l'environnement d'ex\u00E9cution actuel est un environnement Apple (macOS / iOS / iPadOS).\n */\n public static isApple(): boolean {\n if (typeof navigator === 'undefined') {\n return false;\n }\n\n // 1. D\u00E9tection moderne via User-Agent Client Hints (si disponible)\n const uaData = (navigator as unknown as { userAgentData?: { platform?: string } }).userAgentData;\n if (uaData && typeof uaData.platform === 'string') {\n const p = uaData.platform.toLowerCase();\n if (p.includes('mac') || p.includes('ios')) {\n return true;\n }\n }\n\n // 2. D\u00E9tection via navigator.platform\n const platform = (navigator.platform || '').toLowerCase();\n if (platform.includes('mac') || platform.includes('iphone') || platform.includes('ipad') || platform.includes('ipod')) {\n return true;\n }\n\n // 3. D\u00E9tection de secours via User-Agent\n const ua = (navigator.userAgent || '').toLowerCase();\n return ua.includes('macintosh') || ua.includes('mac os x') || ua.includes('ipad') || ua.includes('iphone');\n }\n\n /**\n * Normalise un nom de touche unitaire pour les comparaisons.\n */\n public static normalizeKeyName(key: string): string {\n const k = key.trim().toLowerCase();\n switch (k) {\n case 'esc':\n return 'escape';\n case 'return':\n return 'enter';\n case 'space':\n case 'spacebar':\n return ' ';\n case 'del':\n return 'delete';\n case 'ins':\n return 'insert';\n case 'up':\n return 'arrowup';\n case 'down':\n return 'arrowdown';\n case 'left':\n return 'arrowleft';\n case 'right':\n return 'arrowright';\n default:\n return k;\n }\n }\n\n /**\n * Parse une cha\u00EEne de combinaison (ex: \"Mod+K\", \"g i\", \"Shift+?\", \"Alt++\")\n * et retourne la liste des \u00E9tapes normalis\u00E9es n\u00E9cessaires au d\u00E9clenchement.\n */\n public static parseCombo(combo: string, isApple: boolean = ShortcutFormatter.isApple()): NormalizedStep[] {\n const trimmed = combo.trim();\n if (!trimmed) {\n return [];\n }\n\n // D\u00E9coupage en \u00E9tapes pour les s\u00E9quences (ex: \"g i\" -> [\"g\", \"i\"])\n // Attention : on s\u00E9pare par espaces, sauf si l'espace est la touche elle-m\u00EAme (\"space\")\n const stepsRaw = trimmed.split(/\\s+/);\n const steps: NormalizedStep[] = [];\n\n for (const rawStep of stepsRaw) {\n // D\u00E9coupage de chaque accord sur le symbole '+' (gestion du cas '++' pour la touche '+')\n const tokens: string[] = [];\n let currentToken = '';\n\n for (let i = 0; i < rawStep.length; i++) {\n const char = rawStep[i];\n if (char === '+') {\n // Si le token actuel est vide et qu'on a d\u00E9j\u00E0 des tokens, c'est que c'est un '+' litt\u00E9ral (ex: \"Ctrl++\")\n if (currentToken === '' && tokens.length > 0) {\n tokens.push('+');\n } else if (currentToken !== '') {\n tokens.push(currentToken);\n currentToken = '';\n }\n } else {\n currentToken += char;\n }\n }\n if (currentToken !== '') {\n tokens.push(currentToken);\n }\n\n let ctrl = false;\n let alt = false;\n let shift = false;\n let meta = false;\n let mainKey = '';\n\n for (const token of tokens) {\n const lower = token.trim().toLowerCase();\n if (lower === 'ctrl' || lower === 'control') {\n ctrl = true;\n } else if (lower === 'alt' || lower === 'option' || lower === 'opt') {\n alt = true;\n } else if (lower === 'shift' || lower === 'maj') {\n shift = true;\n } else if (lower === 'cmd' || lower === 'command' || lower === 'meta' || lower === 'win' || lower === 'super') {\n meta = true;\n } else if (lower === 'mod' || lower === '$mod') {\n if (isApple) {\n meta = true;\n } else {\n ctrl = true;\n }\n } else {\n // Touche principale\n mainKey = ShortcutFormatter.normalizeKeyName(token);\n }\n }\n\n steps.push({\n ctrl,\n alt,\n shift,\n meta,\n key: mainKey\n });\n }\n\n return steps;\n }\n\n /**\n * Formate une combinaison brute en libell\u00E9 soign\u00E9 et lisible pour l'OS cible.\n * Ex: \"Mod+Shift+P\" -> macOS: \"\u21E7\u2318P\", Windows: \"Ctrl+Shift+P\"\n * Ex: \"g i\" -> \"g puis i\" ou \"g i\"\n */\n public static format(combo: string, isApple: boolean = ShortcutFormatter.isApple()): string {\n const steps = ShortcutFormatter.parseCombo(combo, isApple);\n if (steps.length === 0) {\n return combo;\n }\n\n const formattedSteps = steps.map(step => {\n const parts: string[] = [];\n\n if (isApple) {\n if (step.ctrl) parts.push('\u2303');\n if (step.alt) parts.push('\u2325');\n if (step.shift) parts.push('\u21E7');\n if (step.meta) parts.push('\u2318');\n\n const keyDisplay = ShortcutFormatter.formatKeyDisplay(step.key, true);\n parts.push(keyDisplay);\n return parts.join('');\n } else {\n if (step.ctrl) parts.push('Ctrl');\n if (step.alt) parts.push('Alt');\n if (step.shift) parts.push('Shift');\n if (step.meta) parts.push('Win');\n\n const keyDisplay = ShortcutFormatter.formatKeyDisplay(step.key, false);\n parts.push(keyDisplay);\n return parts.join('+');\n }\n });\n\n return formattedSteps.join(' ');\n }\n\n /**\n * Convertit un combo technique vers le format officiel WAI-ARIA `aria-keyshortcuts`.\n * Standard W3C : les modificateurs sont 'Control', 'Alt', 'Shift', 'Meta' et le s\u00E9parateur est '+'.\n */\n public static toAriaKeyShortcuts(combo: string, isApple: boolean = ShortcutFormatter.isApple()): string {\n const steps = ShortcutFormatter.parseCombo(combo, isApple);\n return steps.map(step => {\n const parts: string[] = [];\n if (step.ctrl) parts.push('Control');\n if (step.alt) parts.push('Alt');\n if (step.shift) parts.push('Shift');\n if (step.meta) parts.push('Meta');\n parts.push(ShortcutFormatter.formatKeyDisplay(step.key, false));\n return parts.join('+');\n }).join(' ');\n }\n\n private static formatKeyDisplay(key: string, isApple: boolean): string {\n if (!key) return '';\n switch (key.toLowerCase()) {\n case 'escape':\n return isApple ? '\u238B' : 'Esc';\n case 'enter':\n return isApple ? '\u21A9' : 'Enter';\n case ' ':\n return isApple ? '\u2423' : 'Space';\n case 'tab':\n return isApple ? '\u21E5' : 'Tab';\n case 'backspace':\n return isApple ? '\u232B' : 'Backspace';\n case 'delete':\n return isApple ? '\u2326' : 'Suppr';\n case 'arrowup':\n return '\u2191';\n case 'arrowdown':\n return '\u2193';\n case 'arrowleft':\n return '\u2190';\n case 'arrowright':\n return '\u2192';\n default:\n return key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1);\n }\n }\n}\n\n", "import {\n ShortcutDefinition,\n ShortcutManagerOptions,\n ShortcutInfo,\n RegisteredShortcut,\n NormalizedStep\n} from './types';\nimport { ShortcutFormatter } from './ShortcutFormatter';\n\n/**\n * Moteur autonome et modulaire de gestion des raccourcis clavier applicatifs (Wulf.Shortcut).\n * Z\u00E9ro d\u00E9pendance. Conforme \u00E0 l'Axiome Primordial de pr\u00E9servation de la saisie utilisateur.\n */\nexport class ShortcutManager {\n private readonly options: Required<Omit<ShortcutManagerOptions, 'onError'>> & {\n onError?: (error: Error, combo: string) => void;\n };\n private readonly shortcuts: Map<string, RegisteredShortcut> = new Map();\n private scopeStack: string[] = [];\n private sequenceBuffer: { step: NormalizedStep; timestamp: number }[] = [];\n private sequenceTimer: ReturnType<typeof setTimeout> | null = null;\n private isListening = true;\n private boundListener: ((event: KeyboardEvent) => void) | null = null;\n private idCounter = 0;\n\n constructor(options?: ShortcutManagerOptions) {\n this.options = {\n defaultScope: options?.defaultScope || 'global',\n sequenceTimeout: options?.sequenceTimeout ?? 800,\n target: options?.target || (typeof window !== 'undefined' ? window : ({} as Window)),\n onError: options?.onError\n };\n\n this.scopeStack = [this.options.defaultScope];\n this.initListener();\n }\n\n /**\n * V\u00E9rifie si un \u00E9l\u00E9ment DOM est une zone d'\u00E9dition o\u00F9 la saisie de l'utilisateur\n * ne doit JAMAIS \u00EAtre interrompue ou d\u00E9tourn\u00E9e (Axiome Primordial).\n */\n public static isEditable(target: EventTarget | null): boolean {\n if (!target || typeof (target as HTMLElement).tagName !== 'string') {\n return false;\n }\n\n const el = target as HTMLElement;\n const tagName = el.tagName.toUpperCase();\n\n // 1. \u00C9l\u00E9ments natifs de formulaire textuel\n if (tagName === 'INPUT') {\n const type = (el as HTMLInputElement).type?.toLowerCase() || 'text';\n // Seuls les types non-textuels ne sont pas consid\u00E9r\u00E9s comme de la saisie libre\n const nonTextTypes = ['button', 'checkbox', 'radio', 'submit', 'reset', 'range', 'color', 'file', 'image'];\n return !nonTextTypes.includes(type);\n }\n if (tagName === 'TEXTAREA' || tagName === 'SELECT') {\n return true;\n }\n\n // 2. \u00C9l\u00E9ments modifiables en ligne (contenteditable)\n if (el.isContentEditable || el.getAttribute('contenteditable') === 'true' || el.getAttribute('contenteditable') === 'plaintext-only') {\n return true;\n }\n\n // 3. R\u00F4les ARIA de saisie\n const role = el.getAttribute('role');\n if (role === 'textbox' || role === 'searchbox') {\n return true;\n }\n\n return false;\n }\n\n /**\n * Enregistre un ou plusieurs raccourcis clavier.\n * Retourne une fonction de nettoyage pour d\u00E9senregistrer imm\u00E9diatement.\n */\n public bind(definition: ShortcutDefinition | ShortcutDefinition[]): () => void {\n const list = Array.isArray(definition) ? definition : [definition];\n const registeredIds: string[] = [];\n\n for (const def of list) {\n if (!def.combo || typeof def.handler !== 'function') {\n continue;\n }\n\n const id = `wulf_shortcut_${++this.idCounter}`;\n const normalizedSteps = ShortcutFormatter.parseCombo(def.combo);\n const isSequence = normalizedSteps.length > 1;\n const formattedCombo = ShortcutFormatter.format(def.combo);\n\n const registered: RegisteredShortcut = {\n ...def,\n id,\n scope: def.scope || 'global',\n category: def.category || 'G\u00E9n\u00E9ral',\n allowInEditable: def.allowInEditable ?? false,\n preventDefault: def.preventDefault ?? true,\n stopPropagation: def.stopPropagation ?? true,\n priority: def.priority ?? 0,\n formattedCombo,\n normalizedSteps,\n isSequence\n };\n\n this.shortcuts.set(id, registered);\n registeredIds.push(id);\n }\n\n // Fonction de d\u00E9sabonnement direct\n return () => {\n for (const id of registeredIds) {\n this.shortcuts.delete(id);\n }\n };\n }\n\n /**\n * Retire tous les raccourcis correspondant \u00E0 une combinaison et \u00E9ventuellement un scope.\n */\n public unbind(combo: string, scope?: string): void {\n const formatted = ShortcutFormatter.format(combo);\n for (const [id, s] of this.shortcuts.entries()) {\n if (s.formattedCombo === formatted || s.combo.trim().toLowerCase() === combo.trim().toLowerCase()) {\n if (!scope || s.scope === scope) {\n this.shortcuts.delete(id);\n }\n }\n }\n }\n\n /**\n * Empile un nouveau scope actif (mode LIFO).\n * Seuls les raccourcis de ce scope (et les omnipr\u00E9sents '*') seront actifs.\n */\n public pushScope(scope: string): void {\n if (scope && typeof scope === 'string') {\n this.scopeStack.push(scope);\n this.clearSequenceBuffer();\n }\n }\n\n /**\n * D\u00E9pile le scope actuel et r\u00E9tablit le pr\u00E9c\u00E9dent.\n * Si un param\u00E8tre `scope` est pass\u00E9, ne retire que si le scope actuel correspond.\n */\n public popScope(scope?: string): string | undefined {\n if (this.scopeStack.length <= 1) {\n return this.scopeStack[0];\n }\n\n if (scope) {\n if (this.getScope() === scope) {\n const popped = this.scopeStack.pop();\n this.clearSequenceBuffer();\n return popped;\n }\n return undefined;\n }\n\n const popped = this.scopeStack.pop();\n this.clearSequenceBuffer();\n return popped;\n }\n\n /**\n * R\u00E9initialise brutalement la pile pour activer le scope sp\u00E9cifi\u00E9.\n */\n public setScope(scope: string): void {\n this.scopeStack = [scope || this.options.defaultScope];\n this.clearSequenceBuffer();\n }\n\n /**\n * Retourne le scope actuellement actif au sommet de la pile.\n */\n public getScope(): string {\n return this.scopeStack[this.scopeStack.length - 1] || this.options.defaultScope;\n }\n\n /**\n * Retourne une copie de la pile compl\u00E8te des scopes.\n */\n public getScopeStack(): string[] {\n return [...this.scopeStack];\n }\n\n /**\n * Met en pause l'\u00E9coute de tous les raccourcis.\n */\n public pause(): void {\n this.isListening = false;\n this.clearSequenceBuffer();\n }\n\n /**\n * R\u00E9active l'\u00E9coute des raccourcis.\n */\n public resume(): void {\n this.isListening = true;\n }\n\n /**\n * Indique si le gestionnaire est actif et \u00E0 l'\u00E9coute.\n */\n public isActive(): boolean {\n return this.isListening;\n }\n\n /**\n * Retourne le catalogue des raccourcis enregistr\u00E9s (optionnellement filtr\u00E9 par scope).\n */\n public getRegistry(scope?: string): RegisteredShortcut[] {\n const list: RegisteredShortcut[] = [];\n for (const shortcut of this.shortcuts.values()) {\n if (!scope || shortcut.scope === scope || shortcut.scope === '*') {\n list.push({ ...shortcut });\n }\n }\n return list;\n }\n\n /**\n * Associe l'attribut standard WAI-ARIA `aria-keyshortcuts` sur un \u00E9l\u00E9ment DOM.\n */\n public attachAria(element: HTMLElement, combo: string): void {\n if (element && typeof element.setAttribute === 'function') {\n const ariaValue = ShortcutFormatter.toAriaKeyShortcuts(combo);\n element.setAttribute('aria-keyshortcuts', ariaValue);\n }\n }\n\n /**\n * Formate une combinaison brute selon l'OS courant (\"\u2318K\" ou \"Ctrl+K\").\n */\n public static format(combo: string, isApple?: boolean): string {\n return ShortcutFormatter.format(combo, isApple);\n }\n\n /**\n * D\u00E9truit le gestionnaire : supprime les \u00E9couteurs du DOM et vide toute la m\u00E9moire.\n */\n public destroy(): void {\n this.pause();\n this.removeListener();\n this.shortcuts.clear();\n this.scopeStack = [];\n this.clearSequenceBuffer();\n }\n\n // --- Impl\u00E9mentation Interne ---\n\n private initListener(): void {\n if (typeof window === 'undefined' || !this.options.target) {\n return;\n }\n\n this.boundListener = (event: KeyboardEvent) => this.handleKeyDown(event);\n const target = this.options.target as EventTarget;\n if (typeof target.addEventListener === 'function') {\n target.addEventListener('keydown', this.boundListener as EventListener, false);\n }\n }\n\n private removeListener(): void {\n if (this.boundListener && this.options.target) {\n const target = this.options.target as EventTarget;\n if (typeof target.removeEventListener === 'function') {\n target.removeEventListener('keydown', this.boundListener as EventListener, false);\n }\n this.boundListener = null;\n }\n }\n\n private handleKeyDown(event: KeyboardEvent): void {\n if (!this.isListening) {\n return;\n }\n\n // Touches modificatrices isol\u00E9es : on ne fait rien\n const k = (event.key || '').toLowerCase();\n if (['control', 'alt', 'shift', 'meta'].includes(k)) {\n return;\n }\n\n const currentScope = this.getScope();\n const isEditable = ShortcutManager.isEditable(event.target);\n\n // Extraction du pas de touche actuel\n const currentStep: NormalizedStep = {\n ctrl: event.ctrlKey,\n alt: event.altKey,\n shift: event.shiftKey,\n meta: event.metaKey,\n key: ShortcutFormatter.normalizeKeyName(event.key || '')\n };\n\n const now = Date.now();\n\n // 1. Purge du buffer de s\u00E9quence si le d\u00E9lai est d\u00E9pass\u00E9\n if (this.sequenceBuffer.length > 0) {\n const last = this.sequenceBuffer[this.sequenceBuffer.length - 1];\n if (now - last.timestamp > this.options.sequenceTimeout) {\n this.clearSequenceBuffer();\n }\n }\n\n // Candidats potentiels actifs pour le scope courant\n const activeCandidates = this.getActiveShortcuts(currentScope, isEditable);\n\n // 2. \u00C9valuation des s\u00E9quences temporelles (Key Sequences)\n const proposedSequence = [...this.sequenceBuffer.map(b => b.step), currentStep];\n const matchingSequence = this.findMatchingSequence(activeCandidates, proposedSequence);\n\n if (matchingSequence) {\n this.clearSequenceBuffer();\n this.executeShortcut(matchingSequence, event, currentScope, true);\n return;\n }\n\n // V\u00E9rifier si le pas actuel peut \u00EAtre le pr\u00E9fixe d'une s\u00E9quence enregistr\u00E9e\n if (this.isPrefixOfAnySequence(activeCandidates, proposedSequence)) {\n this.sequenceBuffer.push({ step: currentStep, timestamp: now });\n this.resetSequenceTimer();\n // On bloque l'\u00E9v\u00E9nement pour ne pas d\u00E9clencher un accord unitaire pendant une s\u00E9quence\n if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !isEditable) {\n event.preventDefault();\n }\n return;\n }\n\n // Si la s\u00E9quence ne m\u00E8ne \u00E0 rien, on vide le buffer\n this.clearSequenceBuffer();\n\n // 3. \u00C9valuation des accords simultan\u00E9s unitaires (Single Chords)\n const matchingChord = this.findMatchingChord(activeCandidates, currentStep, event);\n if (matchingChord) {\n this.executeShortcut(matchingChord, event, currentScope, false);\n }\n }\n\n private getActiveShortcuts(currentScope: string, isEditable: boolean): RegisteredShortcut[] {\n const list: RegisteredShortcut[] = [];\n for (const shortcut of this.shortcuts.values()) {\n // Filtrage de scope\n if (shortcut.scope !== currentScope && shortcut.scope !== '*') {\n continue;\n }\n // R\u00C8GLE ABSOLUE (Axiome Primordial) : Filtrage des \u00E9l\u00E9ments \u00E9ditables\n if (isEditable && !shortcut.allowInEditable) {\n continue;\n }\n list.push(shortcut);\n }\n\n // Tri par priorit\u00E9 d\u00E9croissante\n return list.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }\n\n private stepMatches(step: NormalizedStep, eventStep: NormalizedStep, rawEvent?: KeyboardEvent): boolean {\n if (step.ctrl !== eventStep.ctrl) return false;\n if (step.alt !== eventStep.alt) return false;\n if (step.meta !== eventStep.meta) return false;\n\n // Correspondance de la touche\n const keyMatches =\n step.key === eventStep.key ||\n (rawEvent && step.key === rawEvent.key.toLowerCase());\n\n if (!keyMatches) return false;\n\n // Correspondance Shift :\n // Si la touche sp\u00E9cifie shift: true, l'\u00E9v\u00E9nement doit avoir shiftKey true.\n // Si la touche sp\u00E9cifie shift: false, mais que le caract\u00E8re est un symbole (ex: \"?\")\n // tap\u00E9 avec shift, on tol\u00E8re si la touche correspond exactement.\n if (step.shift === eventStep.shift) {\n return true;\n }\n\n if (!step.shift && eventStep.shift) {\n // Autoris\u00E9 si c'est un caract\u00E8re sp\u00E9cial direct (comme \"?\" ou \"!\")\n if (rawEvent && rawEvent.key === step.key) {\n return true;\n }\n }\n\n return false;\n }\n\n private findMatchingChord(\n candidates: RegisteredShortcut[],\n currentStep: NormalizedStep,\n rawEvent: KeyboardEvent\n ): RegisteredShortcut | null {\n for (const candidate of candidates) {\n if (candidate.isSequence || candidate.normalizedSteps.length !== 1) {\n continue;\n }\n\n const step = candidate.normalizedSteps[0];\n if (this.stepMatches(step, currentStep, rawEvent)) {\n return candidate;\n }\n }\n return null;\n }\n\n private findMatchingSequence(\n candidates: RegisteredShortcut[],\n proposed: NormalizedStep[]\n ): RegisteredShortcut | null {\n for (const candidate of candidates) {\n if (!candidate.isSequence || candidate.normalizedSteps.length !== proposed.length) {\n continue;\n }\n\n let allMatch = true;\n for (let i = 0; i < proposed.length; i++) {\n if (!this.stepMatches(candidate.normalizedSteps[i], proposed[i])) {\n allMatch = false;\n break;\n }\n }\n\n if (allMatch) {\n return candidate;\n }\n }\n return null;\n }\n\n private isPrefixOfAnySequence(candidates: RegisteredShortcut[], proposed: NormalizedStep[]): boolean {\n for (const candidate of candidates) {\n if (!candidate.isSequence || candidate.normalizedSteps.length <= proposed.length) {\n continue;\n }\n\n let prefixMatches = true;\n for (let i = 0; i < proposed.length; i++) {\n if (!this.stepMatches(candidate.normalizedSteps[i], proposed[i])) {\n prefixMatches = false;\n break;\n }\n }\n\n if (prefixMatches) {\n return true;\n }\n }\n return false;\n }\n\n private executeShortcut(\n shortcut: RegisteredShortcut,\n event: KeyboardEvent,\n scope: string,\n isSequence: boolean\n ): void {\n if (shortcut.preventDefault) {\n event.preventDefault();\n }\n if (shortcut.stopPropagation) {\n event.stopPropagation();\n }\n\n const info: ShortcutInfo = {\n combo: shortcut.combo,\n formattedCombo: shortcut.formattedCombo,\n scope,\n target: event.target,\n isSequence\n };\n\n try {\n shortcut.handler(event, info);\n } catch (err) {\n if (this.options.onError) {\n this.options.onError(err instanceof Error ? err : new Error(String(err)), shortcut.combo);\n } else {\n console.error(`[Wulf.Shortcut] Erreur lors de l'ex\u00E9cution du raccourci \"${shortcut.combo}\":`, err);\n }\n }\n }\n\n private resetSequenceTimer(): void {\n if (this.sequenceTimer) {\n clearTimeout(this.sequenceTimer);\n }\n this.sequenceTimer = setTimeout(() => {\n this.clearSequenceBuffer();\n }, this.options.sequenceTimeout);\n }\n\n private clearSequenceBuffer(): void {\n this.sequenceBuffer = [];\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AQ,eAAe;AAAA,IACjC;AAAA,IAEQ,sBAA4B;AAClC,WAAK,iBAAiB,CAAC;AACvB,UAAI,KAAK,eAAe;AACtB,qBAAa,KAAK,aAAa;AAC/B,aAAK,gBAAgB;AAAA,MACvB;AAAA,IACF;AAAA,EACF;",
6
+ "names": ["popped"]
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";var Wulf=(()=>{var S=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var q=(n,e)=>{for(var t in e)S(n,t,{get:e[t],enumerable:!0})},k=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!w.call(n,r)&&r!==t&&S(n,r,{get:()=>e[r],enumerable:!(i=y(e,r))||i.enumerable});return n};var E=n=>k(S({},"__esModule",{value:!0}),n);var L={};q(L,{ShortcutFormatter:()=>l,ShortcutManager:()=>m,default:()=>m});var l=class n{static isApple(){if(typeof navigator>"u")return!1;let e=navigator.userAgentData;if(e&&typeof e.platform=="string"){let r=e.platform.toLowerCase();if(r.includes("mac")||r.includes("ios"))return!0}let t=(navigator.platform||"").toLowerCase();if(t.includes("mac")||t.includes("iphone")||t.includes("ipad")||t.includes("ipod"))return!0;let i=(navigator.userAgent||"").toLowerCase();return i.includes("macintosh")||i.includes("mac os x")||i.includes("ipad")||i.includes("iphone")}static normalizeKeyName(e){let t=e.trim().toLowerCase();switch(t){case"esc":return"escape";case"return":return"enter";case"space":case"spacebar":return" ";case"del":return"delete";case"ins":return"insert";case"up":return"arrowup";case"down":return"arrowdown";case"left":return"arrowleft";case"right":return"arrowright";default:return t}}static parseCombo(e,t=n.isApple()){let i=e.trim();if(!i)return[];let r=i.split(/\s+/),s=[];for(let o of r){let c=[],u="";for(let h=0;h<o.length;h++){let a=o[h];a==="+"?u===""&&c.length>0?c.push("+"):u!==""&&(c.push(u),u=""):u+=a}u!==""&&c.push(u);let f=!1,d=!1,p=!1,g=!1,b="";for(let h of c){let a=h.trim().toLowerCase();a==="ctrl"||a==="control"?f=!0:a==="alt"||a==="option"||a==="opt"?d=!0:a==="shift"||a==="maj"?p=!0:a==="cmd"||a==="command"||a==="meta"||a==="win"||a==="super"?g=!0:a==="mod"||a==="$mod"?t?g=!0:f=!0:b=n.normalizeKeyName(h)}s.push({ctrl:f,alt:d,shift:p,meta:g,key:b})}return s}static format(e,t=n.isApple()){let i=n.parseCombo(e,t);return i.length===0?e:i.map(s=>{let o=[];if(t){s.ctrl&&o.push("\u2303"),s.alt&&o.push("\u2325"),s.shift&&o.push("\u21E7"),s.meta&&o.push("\u2318");let c=n.formatKeyDisplay(s.key,!0);return o.push(c),o.join("")}else{s.ctrl&&o.push("Ctrl"),s.alt&&o.push("Alt"),s.shift&&o.push("Shift"),s.meta&&o.push("Win");let c=n.formatKeyDisplay(s.key,!1);return o.push(c),o.join("+")}}).join(" ")}static toAriaKeyShortcuts(e,t=n.isApple()){return n.parseCombo(e,t).map(r=>{let s=[];return r.ctrl&&s.push("Control"),r.alt&&s.push("Alt"),r.shift&&s.push("Shift"),r.meta&&s.push("Meta"),s.push(n.formatKeyDisplay(r.key,!1)),s.join("+")}).join(" ")}static formatKeyDisplay(e,t){if(!e)return"";switch(e.toLowerCase()){case"escape":return t?"\u238B":"Esc";case"enter":return t?"\u21A9":"Enter";case" ":return t?"\u2423":"Space";case"tab":return t?"\u21E5":"Tab";case"backspace":return t?"\u232B":"Backspace";case"delete":return t?"\u2326":"Suppr";case"arrowup":return"\u2191";case"arrowdown":return"\u2193";case"arrowleft":return"\u2190";case"arrowright":return"\u2192";default:return e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)}}};var m=class n{constructor(e){this.shortcuts=new Map;this.scopeStack=[];this.sequenceBuffer=[];this.sequenceTimer=null;this.isListening=!0;this.boundListener=null;this.idCounter=0;this.options={defaultScope:e?.defaultScope||"global",sequenceTimeout:e?.sequenceTimeout??800,target:e?.target||(typeof window<"u"?window:{}),onError:e?.onError},this.scopeStack=[this.options.defaultScope],this.initListener()}static isEditable(e){if(!e||typeof e.tagName!="string")return!1;let t=e,i=t.tagName.toUpperCase();if(i==="INPUT"){let s=t.type?.toLowerCase()||"text";return!["button","checkbox","radio","submit","reset","range","color","file","image"].includes(s)}if(i==="TEXTAREA"||i==="SELECT"||t.isContentEditable||t.getAttribute("contenteditable")==="true"||t.getAttribute("contenteditable")==="plaintext-only")return!0;let r=t.getAttribute("role");return r==="textbox"||r==="searchbox"}bind(e){let t=Array.isArray(e)?e:[e],i=[];for(let r of t){if(!r.combo||typeof r.handler!="function")continue;let s=`wulf_shortcut_${++this.idCounter}`,o=l.parseCombo(r.combo),c=o.length>1,u=l.format(r.combo),f={...r,id:s,scope:r.scope||"global",category:r.category||"G\xE9n\xE9ral",allowInEditable:r.allowInEditable??!1,preventDefault:r.preventDefault??!0,stopPropagation:r.stopPropagation??!0,priority:r.priority??0,formattedCombo:u,normalizedSteps:o,isSequence:c};this.shortcuts.set(s,f),i.push(s)}return()=>{for(let r of i)this.shortcuts.delete(r)}}unbind(e,t){let i=l.format(e);for(let[r,s]of this.shortcuts.entries())(s.formattedCombo===i||s.combo.trim().toLowerCase()===e.trim().toLowerCase())&&(!t||s.scope===t)&&this.shortcuts.delete(r)}pushScope(e){e&&typeof e=="string"&&(this.scopeStack.push(e),this.clearSequenceBuffer())}popScope(e){if(this.scopeStack.length<=1)return this.scopeStack[0];if(e){if(this.getScope()===e){let i=this.scopeStack.pop();return this.clearSequenceBuffer(),i}return}let t=this.scopeStack.pop();return this.clearSequenceBuffer(),t}setScope(e){this.scopeStack=[e||this.options.defaultScope],this.clearSequenceBuffer()}getScope(){return this.scopeStack[this.scopeStack.length-1]||this.options.defaultScope}getScopeStack(){return[...this.scopeStack]}pause(){this.isListening=!1,this.clearSequenceBuffer()}resume(){this.isListening=!0}isActive(){return this.isListening}getRegistry(e){let t=[];for(let i of this.shortcuts.values())(!e||i.scope===e||i.scope==="*")&&t.push({...i});return t}attachAria(e,t){if(e&&typeof e.setAttribute=="function"){let i=l.toAriaKeyShortcuts(t);e.setAttribute("aria-keyshortcuts",i)}}static format(e,t){return l.format(e,t)}destroy(){this.pause(),this.removeListener(),this.shortcuts.clear(),this.scopeStack=[],this.clearSequenceBuffer()}initListener(){if(typeof window>"u"||!this.options.target)return;this.boundListener=t=>this.handleKeyDown(t);let e=this.options.target;typeof e.addEventListener=="function"&&e.addEventListener("keydown",this.boundListener,!1)}removeListener(){if(this.boundListener&&this.options.target){let e=this.options.target;typeof e.removeEventListener=="function"&&e.removeEventListener("keydown",this.boundListener,!1),this.boundListener=null}}handleKeyDown(e){if(!this.isListening)return;let t=(e.key||"").toLowerCase();if(["control","alt","shift","meta"].includes(t))return;let i=this.getScope(),r=n.isEditable(e.target),s={ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey,meta:e.metaKey,key:l.normalizeKeyName(e.key||"")},o=Date.now();if(this.sequenceBuffer.length>0){let p=this.sequenceBuffer[this.sequenceBuffer.length-1];o-p.timestamp>this.options.sequenceTimeout&&this.clearSequenceBuffer()}let c=this.getActiveShortcuts(i,r),u=[...this.sequenceBuffer.map(p=>p.step),s],f=this.findMatchingSequence(c,u);if(f){this.clearSequenceBuffer(),this.executeShortcut(f,e,i,!0);return}if(this.isPrefixOfAnySequence(c,u)){this.sequenceBuffer.push({step:s,timestamp:o}),this.resetSequenceTimer(),e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&!r&&e.preventDefault();return}this.clearSequenceBuffer();let d=this.findMatchingChord(c,s,e);d&&this.executeShortcut(d,e,i,!1)}getActiveShortcuts(e,t){let i=[];for(let r of this.shortcuts.values())r.scope!==e&&r.scope!=="*"||t&&!r.allowInEditable||i.push(r);return i.sort((r,s)=>(s.priority??0)-(r.priority??0))}stepMatches(e,t,i){return e.ctrl!==t.ctrl||e.alt!==t.alt||e.meta!==t.meta||!(e.key===t.key||i&&e.key===i.key.toLowerCase())?!1:!!(e.shift===t.shift||!e.shift&&t.shift&&i&&i.key===e.key)}findMatchingChord(e,t,i){for(let r of e){if(r.isSequence||r.normalizedSteps.length!==1)continue;let s=r.normalizedSteps[0];if(this.stepMatches(s,t,i))return r}return null}findMatchingSequence(e,t){for(let i of e){if(!i.isSequence||i.normalizedSteps.length!==t.length)continue;let r=!0;for(let s=0;s<t.length;s++)if(!this.stepMatches(i.normalizedSteps[s],t[s])){r=!1;break}if(r)return i}return null}isPrefixOfAnySequence(e,t){for(let i of e){if(!i.isSequence||i.normalizedSteps.length<=t.length)continue;let r=!0;for(let s=0;s<t.length;s++)if(!this.stepMatches(i.normalizedSteps[s],t[s])){r=!1;break}if(r)return!0}return!1}executeShortcut(e,t,i,r){e.preventDefault&&t.preventDefault(),e.stopPropagation&&t.stopPropagation();let s={combo:e.combo,formattedCombo:e.formattedCombo,scope:i,target:t.target,isSequence:r};try{e.handler(t,s)}catch(o){this.options.onError?this.options.onError(o instanceof Error?o:new Error(String(o)),e.combo):console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${e.combo}":`,o)}}resetSequenceTimer(){this.sequenceTimer&&clearTimeout(this.sequenceTimer),this.sequenceTimer=setTimeout(()=>{this.clearSequenceBuffer()},this.options.sequenceTimeout)}clearSequenceBuffer(){this.sequenceBuffer=[],this.sequenceTimer&&(clearTimeout(this.sequenceTimer),this.sequenceTimer=null)}};return E(L);})();
2
+ if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast", "FocusTrap", "Shortcut"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
3
+ //# sourceMappingURL=shortcut.global.min.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/shortcut/index.ts", "../src/shortcut/ShortcutFormatter.ts", "../src/shortcut/ShortcutManager.ts"],
4
+ "sourcesContent": ["export { ShortcutManager } from './ShortcutManager';\nexport { ShortcutFormatter } from './ShortcutFormatter';\nexport * from './types';\nexport { ShortcutManager as default } from './ShortcutManager';\n\n", "import { NormalizedStep } from './types';\n\n/**\n * Utilitaires de d\u00E9tection d'OS, de parsing de cha\u00EEnes et de formatage de raccourcis.\n */\nexport class ShortcutFormatter {\n /**\n * D\u00E9tecte si l'environnement d'ex\u00E9cution actuel est un environnement Apple (macOS / iOS / iPadOS).\n */\n public static isApple(): boolean {\n if (typeof navigator === 'undefined') {\n return false;\n }\n\n // 1. D\u00E9tection moderne via User-Agent Client Hints (si disponible)\n const uaData = (navigator as unknown as { userAgentData?: { platform?: string } }).userAgentData;\n if (uaData && typeof uaData.platform === 'string') {\n const p = uaData.platform.toLowerCase();\n if (p.includes('mac') || p.includes('ios')) {\n return true;\n }\n }\n\n // 2. D\u00E9tection via navigator.platform\n const platform = (navigator.platform || '').toLowerCase();\n if (platform.includes('mac') || platform.includes('iphone') || platform.includes('ipad') || platform.includes('ipod')) {\n return true;\n }\n\n // 3. D\u00E9tection de secours via User-Agent\n const ua = (navigator.userAgent || '').toLowerCase();\n return ua.includes('macintosh') || ua.includes('mac os x') || ua.includes('ipad') || ua.includes('iphone');\n }\n\n /**\n * Normalise un nom de touche unitaire pour les comparaisons.\n */\n public static normalizeKeyName(key: string): string {\n const k = key.trim().toLowerCase();\n switch (k) {\n case 'esc':\n return 'escape';\n case 'return':\n return 'enter';\n case 'space':\n case 'spacebar':\n return ' ';\n case 'del':\n return 'delete';\n case 'ins':\n return 'insert';\n case 'up':\n return 'arrowup';\n case 'down':\n return 'arrowdown';\n case 'left':\n return 'arrowleft';\n case 'right':\n return 'arrowright';\n default:\n return k;\n }\n }\n\n /**\n * Parse une cha\u00EEne de combinaison (ex: \"Mod+K\", \"g i\", \"Shift+?\", \"Alt++\")\n * et retourne la liste des \u00E9tapes normalis\u00E9es n\u00E9cessaires au d\u00E9clenchement.\n */\n public static parseCombo(combo: string, isApple: boolean = ShortcutFormatter.isApple()): NormalizedStep[] {\n const trimmed = combo.trim();\n if (!trimmed) {\n return [];\n }\n\n // D\u00E9coupage en \u00E9tapes pour les s\u00E9quences (ex: \"g i\" -> [\"g\", \"i\"])\n // Attention : on s\u00E9pare par espaces, sauf si l'espace est la touche elle-m\u00EAme (\"space\")\n const stepsRaw = trimmed.split(/\\s+/);\n const steps: NormalizedStep[] = [];\n\n for (const rawStep of stepsRaw) {\n // D\u00E9coupage de chaque accord sur le symbole '+' (gestion du cas '++' pour la touche '+')\n const tokens: string[] = [];\n let currentToken = '';\n\n for (let i = 0; i < rawStep.length; i++) {\n const char = rawStep[i];\n if (char === '+') {\n // Si le token actuel est vide et qu'on a d\u00E9j\u00E0 des tokens, c'est que c'est un '+' litt\u00E9ral (ex: \"Ctrl++\")\n if (currentToken === '' && tokens.length > 0) {\n tokens.push('+');\n } else if (currentToken !== '') {\n tokens.push(currentToken);\n currentToken = '';\n }\n } else {\n currentToken += char;\n }\n }\n if (currentToken !== '') {\n tokens.push(currentToken);\n }\n\n let ctrl = false;\n let alt = false;\n let shift = false;\n let meta = false;\n let mainKey = '';\n\n for (const token of tokens) {\n const lower = token.trim().toLowerCase();\n if (lower === 'ctrl' || lower === 'control') {\n ctrl = true;\n } else if (lower === 'alt' || lower === 'option' || lower === 'opt') {\n alt = true;\n } else if (lower === 'shift' || lower === 'maj') {\n shift = true;\n } else if (lower === 'cmd' || lower === 'command' || lower === 'meta' || lower === 'win' || lower === 'super') {\n meta = true;\n } else if (lower === 'mod' || lower === '$mod') {\n if (isApple) {\n meta = true;\n } else {\n ctrl = true;\n }\n } else {\n // Touche principale\n mainKey = ShortcutFormatter.normalizeKeyName(token);\n }\n }\n\n steps.push({\n ctrl,\n alt,\n shift,\n meta,\n key: mainKey\n });\n }\n\n return steps;\n }\n\n /**\n * Formate une combinaison brute en libell\u00E9 soign\u00E9 et lisible pour l'OS cible.\n * Ex: \"Mod+Shift+P\" -> macOS: \"\u21E7\u2318P\", Windows: \"Ctrl+Shift+P\"\n * Ex: \"g i\" -> \"g puis i\" ou \"g i\"\n */\n public static format(combo: string, isApple: boolean = ShortcutFormatter.isApple()): string {\n const steps = ShortcutFormatter.parseCombo(combo, isApple);\n if (steps.length === 0) {\n return combo;\n }\n\n const formattedSteps = steps.map(step => {\n const parts: string[] = [];\n\n if (isApple) {\n if (step.ctrl) parts.push('\u2303');\n if (step.alt) parts.push('\u2325');\n if (step.shift) parts.push('\u21E7');\n if (step.meta) parts.push('\u2318');\n\n const keyDisplay = ShortcutFormatter.formatKeyDisplay(step.key, true);\n parts.push(keyDisplay);\n return parts.join('');\n } else {\n if (step.ctrl) parts.push('Ctrl');\n if (step.alt) parts.push('Alt');\n if (step.shift) parts.push('Shift');\n if (step.meta) parts.push('Win');\n\n const keyDisplay = ShortcutFormatter.formatKeyDisplay(step.key, false);\n parts.push(keyDisplay);\n return parts.join('+');\n }\n });\n\n return formattedSteps.join(' ');\n }\n\n /**\n * Convertit un combo technique vers le format officiel WAI-ARIA `aria-keyshortcuts`.\n * Standard W3C : les modificateurs sont 'Control', 'Alt', 'Shift', 'Meta' et le s\u00E9parateur est '+'.\n */\n public static toAriaKeyShortcuts(combo: string, isApple: boolean = ShortcutFormatter.isApple()): string {\n const steps = ShortcutFormatter.parseCombo(combo, isApple);\n return steps.map(step => {\n const parts: string[] = [];\n if (step.ctrl) parts.push('Control');\n if (step.alt) parts.push('Alt');\n if (step.shift) parts.push('Shift');\n if (step.meta) parts.push('Meta');\n parts.push(ShortcutFormatter.formatKeyDisplay(step.key, false));\n return parts.join('+');\n }).join(' ');\n }\n\n private static formatKeyDisplay(key: string, isApple: boolean): string {\n if (!key) return '';\n switch (key.toLowerCase()) {\n case 'escape':\n return isApple ? '\u238B' : 'Esc';\n case 'enter':\n return isApple ? '\u21A9' : 'Enter';\n case ' ':\n return isApple ? '\u2423' : 'Space';\n case 'tab':\n return isApple ? '\u21E5' : 'Tab';\n case 'backspace':\n return isApple ? '\u232B' : 'Backspace';\n case 'delete':\n return isApple ? '\u2326' : 'Suppr';\n case 'arrowup':\n return '\u2191';\n case 'arrowdown':\n return '\u2193';\n case 'arrowleft':\n return '\u2190';\n case 'arrowright':\n return '\u2192';\n default:\n return key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1);\n }\n }\n}\n\n", "import {\n ShortcutDefinition,\n ShortcutManagerOptions,\n ShortcutInfo,\n RegisteredShortcut,\n NormalizedStep\n} from './types';\nimport { ShortcutFormatter } from './ShortcutFormatter';\n\n/**\n * Moteur autonome et modulaire de gestion des raccourcis clavier applicatifs (Wulf.Shortcut).\n * Z\u00E9ro d\u00E9pendance. Conforme \u00E0 l'Axiome Primordial de pr\u00E9servation de la saisie utilisateur.\n */\nexport class ShortcutManager {\n private readonly options: Required<Omit<ShortcutManagerOptions, 'onError'>> & {\n onError?: (error: Error, combo: string) => void;\n };\n private readonly shortcuts: Map<string, RegisteredShortcut> = new Map();\n private scopeStack: string[] = [];\n private sequenceBuffer: { step: NormalizedStep; timestamp: number }[] = [];\n private sequenceTimer: ReturnType<typeof setTimeout> | null = null;\n private isListening = true;\n private boundListener: ((event: KeyboardEvent) => void) | null = null;\n private idCounter = 0;\n\n constructor(options?: ShortcutManagerOptions) {\n this.options = {\n defaultScope: options?.defaultScope || 'global',\n sequenceTimeout: options?.sequenceTimeout ?? 800,\n target: options?.target || (typeof window !== 'undefined' ? window : ({} as Window)),\n onError: options?.onError\n };\n\n this.scopeStack = [this.options.defaultScope];\n this.initListener();\n }\n\n /**\n * V\u00E9rifie si un \u00E9l\u00E9ment DOM est une zone d'\u00E9dition o\u00F9 la saisie de l'utilisateur\n * ne doit JAMAIS \u00EAtre interrompue ou d\u00E9tourn\u00E9e (Axiome Primordial).\n */\n public static isEditable(target: EventTarget | null): boolean {\n if (!target || typeof (target as HTMLElement).tagName !== 'string') {\n return false;\n }\n\n const el = target as HTMLElement;\n const tagName = el.tagName.toUpperCase();\n\n // 1. \u00C9l\u00E9ments natifs de formulaire textuel\n if (tagName === 'INPUT') {\n const type = (el as HTMLInputElement).type?.toLowerCase() || 'text';\n // Seuls les types non-textuels ne sont pas consid\u00E9r\u00E9s comme de la saisie libre\n const nonTextTypes = ['button', 'checkbox', 'radio', 'submit', 'reset', 'range', 'color', 'file', 'image'];\n return !nonTextTypes.includes(type);\n }\n if (tagName === 'TEXTAREA' || tagName === 'SELECT') {\n return true;\n }\n\n // 2. \u00C9l\u00E9ments modifiables en ligne (contenteditable)\n if (el.isContentEditable || el.getAttribute('contenteditable') === 'true' || el.getAttribute('contenteditable') === 'plaintext-only') {\n return true;\n }\n\n // 3. R\u00F4les ARIA de saisie\n const role = el.getAttribute('role');\n if (role === 'textbox' || role === 'searchbox') {\n return true;\n }\n\n return false;\n }\n\n /**\n * Enregistre un ou plusieurs raccourcis clavier.\n * Retourne une fonction de nettoyage pour d\u00E9senregistrer imm\u00E9diatement.\n */\n public bind(definition: ShortcutDefinition | ShortcutDefinition[]): () => void {\n const list = Array.isArray(definition) ? definition : [definition];\n const registeredIds: string[] = [];\n\n for (const def of list) {\n if (!def.combo || typeof def.handler !== 'function') {\n continue;\n }\n\n const id = `wulf_shortcut_${++this.idCounter}`;\n const normalizedSteps = ShortcutFormatter.parseCombo(def.combo);\n const isSequence = normalizedSteps.length > 1;\n const formattedCombo = ShortcutFormatter.format(def.combo);\n\n const registered: RegisteredShortcut = {\n ...def,\n id,\n scope: def.scope || 'global',\n category: def.category || 'G\u00E9n\u00E9ral',\n allowInEditable: def.allowInEditable ?? false,\n preventDefault: def.preventDefault ?? true,\n stopPropagation: def.stopPropagation ?? true,\n priority: def.priority ?? 0,\n formattedCombo,\n normalizedSteps,\n isSequence\n };\n\n this.shortcuts.set(id, registered);\n registeredIds.push(id);\n }\n\n // Fonction de d\u00E9sabonnement direct\n return () => {\n for (const id of registeredIds) {\n this.shortcuts.delete(id);\n }\n };\n }\n\n /**\n * Retire tous les raccourcis correspondant \u00E0 une combinaison et \u00E9ventuellement un scope.\n */\n public unbind(combo: string, scope?: string): void {\n const formatted = ShortcutFormatter.format(combo);\n for (const [id, s] of this.shortcuts.entries()) {\n if (s.formattedCombo === formatted || s.combo.trim().toLowerCase() === combo.trim().toLowerCase()) {\n if (!scope || s.scope === scope) {\n this.shortcuts.delete(id);\n }\n }\n }\n }\n\n /**\n * Empile un nouveau scope actif (mode LIFO).\n * Seuls les raccourcis de ce scope (et les omnipr\u00E9sents '*') seront actifs.\n */\n public pushScope(scope: string): void {\n if (scope && typeof scope === 'string') {\n this.scopeStack.push(scope);\n this.clearSequenceBuffer();\n }\n }\n\n /**\n * D\u00E9pile le scope actuel et r\u00E9tablit le pr\u00E9c\u00E9dent.\n * Si un param\u00E8tre `scope` est pass\u00E9, ne retire que si le scope actuel correspond.\n */\n public popScope(scope?: string): string | undefined {\n if (this.scopeStack.length <= 1) {\n return this.scopeStack[0];\n }\n\n if (scope) {\n if (this.getScope() === scope) {\n const popped = this.scopeStack.pop();\n this.clearSequenceBuffer();\n return popped;\n }\n return undefined;\n }\n\n const popped = this.scopeStack.pop();\n this.clearSequenceBuffer();\n return popped;\n }\n\n /**\n * R\u00E9initialise brutalement la pile pour activer le scope sp\u00E9cifi\u00E9.\n */\n public setScope(scope: string): void {\n this.scopeStack = [scope || this.options.defaultScope];\n this.clearSequenceBuffer();\n }\n\n /**\n * Retourne le scope actuellement actif au sommet de la pile.\n */\n public getScope(): string {\n return this.scopeStack[this.scopeStack.length - 1] || this.options.defaultScope;\n }\n\n /**\n * Retourne une copie de la pile compl\u00E8te des scopes.\n */\n public getScopeStack(): string[] {\n return [...this.scopeStack];\n }\n\n /**\n * Met en pause l'\u00E9coute de tous les raccourcis.\n */\n public pause(): void {\n this.isListening = false;\n this.clearSequenceBuffer();\n }\n\n /**\n * R\u00E9active l'\u00E9coute des raccourcis.\n */\n public resume(): void {\n this.isListening = true;\n }\n\n /**\n * Indique si le gestionnaire est actif et \u00E0 l'\u00E9coute.\n */\n public isActive(): boolean {\n return this.isListening;\n }\n\n /**\n * Retourne le catalogue des raccourcis enregistr\u00E9s (optionnellement filtr\u00E9 par scope).\n */\n public getRegistry(scope?: string): RegisteredShortcut[] {\n const list: RegisteredShortcut[] = [];\n for (const shortcut of this.shortcuts.values()) {\n if (!scope || shortcut.scope === scope || shortcut.scope === '*') {\n list.push({ ...shortcut });\n }\n }\n return list;\n }\n\n /**\n * Associe l'attribut standard WAI-ARIA `aria-keyshortcuts` sur un \u00E9l\u00E9ment DOM.\n */\n public attachAria(element: HTMLElement, combo: string): void {\n if (element && typeof element.setAttribute === 'function') {\n const ariaValue = ShortcutFormatter.toAriaKeyShortcuts(combo);\n element.setAttribute('aria-keyshortcuts', ariaValue);\n }\n }\n\n /**\n * Formate une combinaison brute selon l'OS courant (\"\u2318K\" ou \"Ctrl+K\").\n */\n public static format(combo: string, isApple?: boolean): string {\n return ShortcutFormatter.format(combo, isApple);\n }\n\n /**\n * D\u00E9truit le gestionnaire : supprime les \u00E9couteurs du DOM et vide toute la m\u00E9moire.\n */\n public destroy(): void {\n this.pause();\n this.removeListener();\n this.shortcuts.clear();\n this.scopeStack = [];\n this.clearSequenceBuffer();\n }\n\n // --- Impl\u00E9mentation Interne ---\n\n private initListener(): void {\n if (typeof window === 'undefined' || !this.options.target) {\n return;\n }\n\n this.boundListener = (event: KeyboardEvent) => this.handleKeyDown(event);\n const target = this.options.target as EventTarget;\n if (typeof target.addEventListener === 'function') {\n target.addEventListener('keydown', this.boundListener as EventListener, false);\n }\n }\n\n private removeListener(): void {\n if (this.boundListener && this.options.target) {\n const target = this.options.target as EventTarget;\n if (typeof target.removeEventListener === 'function') {\n target.removeEventListener('keydown', this.boundListener as EventListener, false);\n }\n this.boundListener = null;\n }\n }\n\n private handleKeyDown(event: KeyboardEvent): void {\n if (!this.isListening) {\n return;\n }\n\n // Touches modificatrices isol\u00E9es : on ne fait rien\n const k = (event.key || '').toLowerCase();\n if (['control', 'alt', 'shift', 'meta'].includes(k)) {\n return;\n }\n\n const currentScope = this.getScope();\n const isEditable = ShortcutManager.isEditable(event.target);\n\n // Extraction du pas de touche actuel\n const currentStep: NormalizedStep = {\n ctrl: event.ctrlKey,\n alt: event.altKey,\n shift: event.shiftKey,\n meta: event.metaKey,\n key: ShortcutFormatter.normalizeKeyName(event.key || '')\n };\n\n const now = Date.now();\n\n // 1. Purge du buffer de s\u00E9quence si le d\u00E9lai est d\u00E9pass\u00E9\n if (this.sequenceBuffer.length > 0) {\n const last = this.sequenceBuffer[this.sequenceBuffer.length - 1];\n if (now - last.timestamp > this.options.sequenceTimeout) {\n this.clearSequenceBuffer();\n }\n }\n\n // Candidats potentiels actifs pour le scope courant\n const activeCandidates = this.getActiveShortcuts(currentScope, isEditable);\n\n // 2. \u00C9valuation des s\u00E9quences temporelles (Key Sequences)\n const proposedSequence = [...this.sequenceBuffer.map(b => b.step), currentStep];\n const matchingSequence = this.findMatchingSequence(activeCandidates, proposedSequence);\n\n if (matchingSequence) {\n this.clearSequenceBuffer();\n this.executeShortcut(matchingSequence, event, currentScope, true);\n return;\n }\n\n // V\u00E9rifier si le pas actuel peut \u00EAtre le pr\u00E9fixe d'une s\u00E9quence enregistr\u00E9e\n if (this.isPrefixOfAnySequence(activeCandidates, proposedSequence)) {\n this.sequenceBuffer.push({ step: currentStep, timestamp: now });\n this.resetSequenceTimer();\n // On bloque l'\u00E9v\u00E9nement pour ne pas d\u00E9clencher un accord unitaire pendant une s\u00E9quence\n if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !isEditable) {\n event.preventDefault();\n }\n return;\n }\n\n // Si la s\u00E9quence ne m\u00E8ne \u00E0 rien, on vide le buffer\n this.clearSequenceBuffer();\n\n // 3. \u00C9valuation des accords simultan\u00E9s unitaires (Single Chords)\n const matchingChord = this.findMatchingChord(activeCandidates, currentStep, event);\n if (matchingChord) {\n this.executeShortcut(matchingChord, event, currentScope, false);\n }\n }\n\n private getActiveShortcuts(currentScope: string, isEditable: boolean): RegisteredShortcut[] {\n const list: RegisteredShortcut[] = [];\n for (const shortcut of this.shortcuts.values()) {\n // Filtrage de scope\n if (shortcut.scope !== currentScope && shortcut.scope !== '*') {\n continue;\n }\n // R\u00C8GLE ABSOLUE (Axiome Primordial) : Filtrage des \u00E9l\u00E9ments \u00E9ditables\n if (isEditable && !shortcut.allowInEditable) {\n continue;\n }\n list.push(shortcut);\n }\n\n // Tri par priorit\u00E9 d\u00E9croissante\n return list.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }\n\n private stepMatches(step: NormalizedStep, eventStep: NormalizedStep, rawEvent?: KeyboardEvent): boolean {\n if (step.ctrl !== eventStep.ctrl) return false;\n if (step.alt !== eventStep.alt) return false;\n if (step.meta !== eventStep.meta) return false;\n\n // Correspondance de la touche\n const keyMatches =\n step.key === eventStep.key ||\n (rawEvent && step.key === rawEvent.key.toLowerCase());\n\n if (!keyMatches) return false;\n\n // Correspondance Shift :\n // Si la touche sp\u00E9cifie shift: true, l'\u00E9v\u00E9nement doit avoir shiftKey true.\n // Si la touche sp\u00E9cifie shift: false, mais que le caract\u00E8re est un symbole (ex: \"?\")\n // tap\u00E9 avec shift, on tol\u00E8re si la touche correspond exactement.\n if (step.shift === eventStep.shift) {\n return true;\n }\n\n if (!step.shift && eventStep.shift) {\n // Autoris\u00E9 si c'est un caract\u00E8re sp\u00E9cial direct (comme \"?\" ou \"!\")\n if (rawEvent && rawEvent.key === step.key) {\n return true;\n }\n }\n\n return false;\n }\n\n private findMatchingChord(\n candidates: RegisteredShortcut[],\n currentStep: NormalizedStep,\n rawEvent: KeyboardEvent\n ): RegisteredShortcut | null {\n for (const candidate of candidates) {\n if (candidate.isSequence || candidate.normalizedSteps.length !== 1) {\n continue;\n }\n\n const step = candidate.normalizedSteps[0];\n if (this.stepMatches(step, currentStep, rawEvent)) {\n return candidate;\n }\n }\n return null;\n }\n\n private findMatchingSequence(\n candidates: RegisteredShortcut[],\n proposed: NormalizedStep[]\n ): RegisteredShortcut | null {\n for (const candidate of candidates) {\n if (!candidate.isSequence || candidate.normalizedSteps.length !== proposed.length) {\n continue;\n }\n\n let allMatch = true;\n for (let i = 0; i < proposed.length; i++) {\n if (!this.stepMatches(candidate.normalizedSteps[i], proposed[i])) {\n allMatch = false;\n break;\n }\n }\n\n if (allMatch) {\n return candidate;\n }\n }\n return null;\n }\n\n private isPrefixOfAnySequence(candidates: RegisteredShortcut[], proposed: NormalizedStep[]): boolean {\n for (const candidate of candidates) {\n if (!candidate.isSequence || candidate.normalizedSteps.length <= proposed.length) {\n continue;\n }\n\n let prefixMatches = true;\n for (let i = 0; i < proposed.length; i++) {\n if (!this.stepMatches(candidate.normalizedSteps[i], proposed[i])) {\n prefixMatches = false;\n break;\n }\n }\n\n if (prefixMatches) {\n return true;\n }\n }\n return false;\n }\n\n private executeShortcut(\n shortcut: RegisteredShortcut,\n event: KeyboardEvent,\n scope: string,\n isSequence: boolean\n ): void {\n if (shortcut.preventDefault) {\n event.preventDefault();\n }\n if (shortcut.stopPropagation) {\n event.stopPropagation();\n }\n\n const info: ShortcutInfo = {\n combo: shortcut.combo,\n formattedCombo: shortcut.formattedCombo,\n scope,\n target: event.target,\n isSequence\n };\n\n try {\n shortcut.handler(event, info);\n } catch (err) {\n if (this.options.onError) {\n this.options.onError(err instanceof Error ? err : new Error(String(err)), shortcut.combo);\n } else {\n console.error(`[Wulf.Shortcut] Erreur lors de l'ex\u00E9cution du raccourci \"${shortcut.combo}\":`, err);\n }\n }\n }\n\n private resetSequenceTimer(): void {\n if (this.sequenceTimer) {\n clearTimeout(this.sequenceTimer);\n }\n this.sequenceTimer = setTimeout(() => {\n this.clearSequenceBuffer();\n }, this.options.sequenceTimeout);\n }\n\n private clearSequenceBuffer(): void {\n this.sequenceBuffer = [];\n if (this.sequenceTimer) {\n clearTimeout(this.sequenceTimer);\n this.sequenceTimer = null;\n }\n }\n}\n\n"],
5
+ "mappings": "wbAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,oBAAAC,EAAA,YAAAA,ICKO,IAAMC,EAAN,MAAMC,CAAkB,CAI7B,OAAc,SAAmB,CAC/B,GAAI,OAAO,UAAc,IACvB,MAAO,GAIT,IAAMC,EAAU,UAAmE,cACnF,GAAIA,GAAU,OAAOA,EAAO,UAAa,SAAU,CACjD,IAAMC,EAAID,EAAO,SAAS,YAAY,EACtC,GAAIC,EAAE,SAAS,KAAK,GAAKA,EAAE,SAAS,KAAK,EACvC,MAAO,EAEX,CAGA,IAAMC,GAAY,UAAU,UAAY,IAAI,YAAY,EACxD,GAAIA,EAAS,SAAS,KAAK,GAAKA,EAAS,SAAS,QAAQ,GAAKA,EAAS,SAAS,MAAM,GAAKA,EAAS,SAAS,MAAM,EAClH,MAAO,GAIT,IAAMC,GAAM,UAAU,WAAa,IAAI,YAAY,EACnD,OAAOA,EAAG,SAAS,WAAW,GAAKA,EAAG,SAAS,UAAU,GAAKA,EAAG,SAAS,MAAM,GAAKA,EAAG,SAAS,QAAQ,CAC3G,CAKA,OAAc,iBAAiBC,EAAqB,CAClD,IAAMC,EAAID,EAAI,KAAK,EAAE,YAAY,EACjC,OAAQC,EAAG,CACT,IAAK,MACH,MAAO,SACT,IAAK,SACH,MAAO,QACT,IAAK,QACL,IAAK,WACH,MAAO,IACT,IAAK,MACH,MAAO,SACT,IAAK,MACH,MAAO,SACT,IAAK,KACH,MAAO,UACT,IAAK,OACH,MAAO,YACT,IAAK,OACH,MAAO,YACT,IAAK,QACH,MAAO,aACT,QACE,OAAOA,CACX,CACF,CAMA,OAAc,WAAWC,EAAeC,EAAmBR,EAAkB,QAAQ,EAAqB,CACxG,IAAMS,EAAUF,EAAM,KAAK,EAC3B,GAAI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gB,WAAW,IAAM,CACpC,KAAK,oBAAoB,CAC3B,EAAG,KAAK,QAAQ,eAAe,CACjC,CAEQ,qBAA4B,CAClC,KAAK,eAAiB,CAAC,EACnB,KAAK,gBACP,aAAa,KAAK,aAAa,EAC/B,KAAK,cAAgB,KAEzB,CACF",
6
+ "names": ["index_exports", "__export", "ShortcutFormatter", "ShortcutManager", "ShortcutFormatter", "_ShortcutFormatter", "uaData", "p", "platform", "ua", "key", "k", "combo", "isApple", "trimmed", "stepsRaw", "steps", "rawStep", "tokens", "currentToken", "i", "char", "ctrl", "alt", "shift", "meta", "mainKey", "token", "lower", "step", "parts", "keyDisplay", "ShortcutManager", "_ShortcutManager", "options", "target", "el", "tagName", "type", "role", "definition", "list", "registeredIds", "def", "id", "normalizedSteps", "ShortcutFormatter", "isSequence", "formattedCombo", "registered", "combo", "scope", "formatted", "popped", "shortcut", "element", "ariaValue", "isApple", "event", "k", "currentScope", "isEditable", "currentStep", "now", "last", "activeCandidates", "proposedSequence", "b", "matchingSequence", "matchingChord", "a", "step", "eventStep", "rawEvent", "candidates", "candidate", "proposed", "allMatch", "i", "prefixMatches", "info", "err"]
7
+ }
@@ -714,5 +714,5 @@ var Wulf = (() => {
714
714
  }
715
715
  return __toCommonJS(index_exports);
716
716
  })();
717
- if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
717
+ if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast", "FocusTrap", "Shortcut"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
718
718
  //# sourceMappingURL=toast.global.js.map
@@ -2,5 +2,5 @@
2
2
  `+t.map(s=>` - ${s}`).join(`
3
3
  `)+`
4
4
  (${this.getAuditDisableHint()})`),t}checkAriaIdReferences(e,t,s){let i=e.getAttribute(t)?.trim();if(!i)return!1;let r=e.ownerDocument||document,n=i.split(/\s+/).filter(Boolean),c=n.length>0&&n.every(o=>!!r.getElementById(o));return c||s.push(`Attribut ${t}="${i}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),c}};var g=class extends f{static setLocale(e){this._i18n&&this._i18n.setLocale(e)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(e,t){this._i18n&&this._i18n.registerLocale(e,t)}static setI18n(e){this._i18n&&this._i18n.setI18n(e)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(e,t){return this._i18n?this._i18n.t(e,t):String(e)}constructor(e){super(),this.i18nOverrides=e}t(e){let t=this.constructor;return t._i18n?t._i18n.t(e,this.i18nOverrides):String(e)}};var x={closeButton:"Fermer la notification"};var P={closeButton:"Close notification"};var p=w("fr",{fr:x,en:P});var R=1,b=class extends f{constructor(t,s){super();this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${R++}`,this.options=Object.freeze({...t}),this.onDismissCallback=s;let i=t.duration===void 0?4e3:t.duration;typeof i=="number"&&i>0?this.remainingTime=i:this.remainingTime=0,this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(t.audit!==!1)}get isClosed(){return this._isClosed}audit(){let t=[],s=!!(this.options.title&&this.options.title.trim().length>0),i=!!(this.options.message&&this.options.message.trim().length>0);!s&&!i&&t.push("Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3).");let r=this.options.duration===void 0?4e3:this.options.duration;typeof r=="number"&&r>0&&r<5e3&&t.push(`Dur\xE9e d'affichage trop courte (duration: ${r}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let n=this.options.closable??!0;return(r===!1||typeof r=="number"&&r<=0)&&!n&&!this.options.closeOnClick&&t.push("Notification persistante impossible \xE0 fermer : activez closable: true ou closeOnClick: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."),t}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return`#${this.id}`}createDOM(){let t=document.createElement("div");t.id=this.id,t.className="wulf-toast";let s=this.options.role==="alert"?"alert":"status";if(t.setAttribute("role",s),t.setAttribute("aria-live",s==="alert"?"assertive":"polite"),t.setAttribute("aria-atomic","true"),this.options.backgroundColor&&t.style.setProperty("--wulf-toast-bg",this.options.backgroundColor),this.options.titleColor&&t.style.setProperty("--wulf-toast-title-color",this.options.titleColor),this.options.textColor&&t.style.setProperty("--wulf-toast-text-color",this.options.textColor),this.options.iconColor&&t.style.setProperty("--wulf-toast-icon-color",this.options.iconColor),this.options.closeButtonColor&&t.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor),this.options.icon&&this.options.icon.trim()!==""){let n=document.createElement("span");n.className=`wulf-toast-icon ${this.options.icon.trim()}`,n.setAttribute("aria-hidden","true"),t.appendChild(n)}let i=document.createElement("div");if(i.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let n=document.createElement("div");n.className="wulf-toast-title",this.appendTextWithLineBreaks(n,this.options.title),i.appendChild(n)}if(this.options.message&&this.options.message.trim()!==""){let n=document.createElement("div");n.className="wulf-toast-message",this.appendTextWithLineBreaks(n,this.options.message),i.appendChild(n)}if(t.appendChild(i),this.options.closable??!0){let n=document.createElement("button");n.type="button",n.className="wulf-toast-close",n.setAttribute("aria-label",p.t("closeButton",this.options.i18n)),n.setAttribute("tabindex","0");let c=document.createElement("span");c.className="wulf-toast-close-icon",c.setAttribute("aria-hidden","true"),c.textContent="\xD7",n.appendChild(c),n.addEventListener("click",o=>{o.stopPropagation(),this.close("close-button")}),t.appendChild(n)}return t}appendTextWithLineBreaks(t,s){s.split(/\r\n|\r|\n/).forEach((r,n)=>{n>0&&t.appendChild(document.createElement("br")),t.appendChild(document.createTextNode(r))})}bindEvents(){this.element.addEventListener("click",t=>{this.options.onClick&&this.options.onClick(this,t),this.options.closeOnClick&&this.close("toast-click")}),this.element.addEventListener("mouseenter",()=>this.pauseTimer()),this.element.addEventListener("mouseleave",()=>this.resumeTimer()),this.element.addEventListener("focusin",()=>this.pauseTimer()),this.element.addEventListener("focusout",()=>this.resumeTimer())}startTimer(){this._isClosed||this.remainingTime<=0||(this.timerStartTime=Date.now(),this.timerId=window.setTimeout(()=>{this.close("timeout")},this.remainingTime))}pauseTimer(){if(this._isClosed||this.remainingTime<=0||this.isPaused)return;this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null);let t=Date.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-t),this.isPaused=!0}resumeTimer(){this._isClosed||this.remainingTime<=0||!this.isPaused||(this.isPaused=!1,this.startTimer())}destroyImmediate(t="replace"){this._isClosed||(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,t),this.options.onClose&&this.options.onClose(this,t))}close(t="programmatic",s=!1){return this._isClosed?Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),new Promise(i=>{this.element.classList.add(s?"wulf-toast-hiding-fast":"wulf-toast-hiding");let r=()=>{this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,t),this.options.onClose&&this.options.onClose(this,t),i()};if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)r();else if(s)window.setTimeout(r,90);else{let c=!1,o=null,l=()=>{c||(c=!0,o!==null&&(window.clearTimeout(o),o=null),this.element.removeEventListener("animationend",l),this.element.removeEventListener("transitionend",l),r())};this.element.addEventListener("animationend",l,{once:!0}),this.element.addEventListener("transitionend",l,{once:!0}),o=window.setTimeout(l,300)}}))}};var m=class m{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return m.instance||(m.instance=new m),m.instance}add(e){let t=e.options.position||"top-right",s=this.activeToasts.get(t);if(s||(s=[],this.activeToasts.set(t,s)),e.options.replace&&s.length>0){let r=[...s],n=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,n),this.pendingReplacements.add(t);let c=r.map(o=>o.close("replace",!0));Promise.all(c).then(()=>{this.pendingReplacements.delete(t),this.replaceTokens.get(t)===n&&this.mountToast(e,t)});return}let i=typeof e.options.maxToasts=="number"&&e.options.maxToasts>0?e.options.maxToasts:5;if(s.length>=i){let r=s.length-i+1,n=s.splice(0,r);for(let c of n)c.close("max-limit",!0)}this.mountToast(e,t)}mountToast(e,t){let s=this.getOrCreateContainer(t),i=this.activeToasts.get(t);if(i||(i=[],this.activeToasts.set(t,i)),s.appendChild(e.element),i.push(e),e.options.onOpen)try{e.options.onOpen(e)}catch(r){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",r)}e.startTimer()}remove(e,t){let s=e.options.position||"top-right",i=this.activeToasts.get(s);if(i){let r=i.indexOf(e);if(r!==-1&&i.splice(r,1),i.length===0&&!this.pendingReplacements.has(s)){let n=this.containers.get(s);n&&(!n.firstChild||n.children.length===0)&&(n.parentNode&&n.parentNode.removeChild(n),this.containers.delete(s),this.activeToasts.delete(s))}}}clearAll(e){let t=[];if(e){let s=this.activeToasts.get(e);if(s&&s.length>0){let i=[...s];for(let r of i)t.push(r.close("programmatic"))}else{let i=this.containers.get(e);i&&(!i.firstChild||i.children.length===0)&&(i.parentNode&&i.parentNode.removeChild(i),this.containers.delete(e),this.activeToasts.delete(e))}}else{let s=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let i of s)t.push(this.clearAll(i))}return Promise.all(t).then(()=>{if(!e)for(let[s,i]of Array.from(this.containers.entries()))(!i.firstChild||i.children.length===0)&&(i.parentNode&&i.parentNode.removeChild(i),this.containers.delete(s),this.activeToasts.delete(s))})}getOrCreateContainer(e){let t=this.containers.get(e);return(!t||!document.body.contains(t))&&(t=document.createElement("div"),t.className=`wulf-toast-container wulf-toast-${e}`,t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions removals"),document.body.appendChild(t),this.containers.set(e,t)),t}};m.instance=null;var T=m;var u=class extends g{audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(e={}){let t=T.getInstance(),s=new b(e,(i,r)=>{t.remove(i,r)});return t.add(s),s}static clearAll(e){return T.getInstance().clearAll(e)}};u._i18n=p,u.i18n=p;var N=u;if(typeof window<"u"){let a=window,e=a.Wulf||{};a.Wulf=e,e.Toast=Object.assign(u,{Toast:u,i18n:p})}return O(D);})();
5
- if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
5
+ if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast", "FocusTrap", "Shortcut"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
6
6
  //# sourceMappingURL=toast.global.min.js.map
@@ -4,6 +4,8 @@ export * as Masonry from './masonry';
4
4
  export * as Toast from './toast';
5
5
  export * as FocusTrap from './focus-trap';
6
6
  export { FocusTrap as WulfFocusTrap } from './focus-trap';
7
+ export * as Shortcut from './shortcut';
8
+ export { ShortcutManager as WulfShortcut } from './shortcut';
7
9
  export * from './common/i18n';
8
10
  export * from './common/AuditableComponent';
9
11
  export * from './common/LocalizedComponent';
@@ -0,0 +1,31 @@
1
+ import { NormalizedStep } from './types';
2
+ /**
3
+ * Utilitaires de détection d'OS, de parsing de chaînes et de formatage de raccourcis.
4
+ */
5
+ export declare class ShortcutFormatter {
6
+ /**
7
+ * Détecte si l'environnement d'exécution actuel est un environnement Apple (macOS / iOS / iPadOS).
8
+ */
9
+ static isApple(): boolean;
10
+ /**
11
+ * Normalise un nom de touche unitaire pour les comparaisons.
12
+ */
13
+ static normalizeKeyName(key: string): string;
14
+ /**
15
+ * Parse une chaîne de combinaison (ex: "Mod+K", "g i", "Shift+?", "Alt++")
16
+ * et retourne la liste des étapes normalisées nécessaires au déclenchement.
17
+ */
18
+ static parseCombo(combo: string, isApple?: boolean): NormalizedStep[];
19
+ /**
20
+ * Formate une combinaison brute en libellé soigné et lisible pour l'OS cible.
21
+ * Ex: "Mod+Shift+P" -> macOS: "⇧⌘P", Windows: "Ctrl+Shift+P"
22
+ * Ex: "g i" -> "g puis i" ou "g i"
23
+ */
24
+ static format(combo: string, isApple?: boolean): string;
25
+ /**
26
+ * Convertit un combo technique vers le format officiel WAI-ARIA `aria-keyshortcuts`.
27
+ * Standard W3C : les modificateurs sont 'Control', 'Alt', 'Shift', 'Meta' et le séparateur est '+'.
28
+ */
29
+ static toAriaKeyShortcuts(combo: string, isApple?: boolean): string;
30
+ private static formatKeyDisplay;
31
+ }
@@ -0,0 +1,91 @@
1
+ import { ShortcutDefinition, ShortcutManagerOptions, RegisteredShortcut } from './types';
2
+ /**
3
+ * Moteur autonome et modulaire de gestion des raccourcis clavier applicatifs (Wulf.Shortcut).
4
+ * Zéro dépendance. Conforme à l'Axiome Primordial de préservation de la saisie utilisateur.
5
+ */
6
+ export declare class ShortcutManager {
7
+ private readonly options;
8
+ private readonly shortcuts;
9
+ private scopeStack;
10
+ private sequenceBuffer;
11
+ private sequenceTimer;
12
+ private isListening;
13
+ private boundListener;
14
+ private idCounter;
15
+ constructor(options?: ShortcutManagerOptions);
16
+ /**
17
+ * Vérifie si un élément DOM est une zone d'édition où la saisie de l'utilisateur
18
+ * ne doit JAMAIS être interrompue ou détournée (Axiome Primordial).
19
+ */
20
+ static isEditable(target: EventTarget | null): boolean;
21
+ /**
22
+ * Enregistre un ou plusieurs raccourcis clavier.
23
+ * Retourne une fonction de nettoyage pour désenregistrer immédiatement.
24
+ */
25
+ bind(definition: ShortcutDefinition | ShortcutDefinition[]): () => void;
26
+ /**
27
+ * Retire tous les raccourcis correspondant à une combinaison et éventuellement un scope.
28
+ */
29
+ unbind(combo: string, scope?: string): void;
30
+ /**
31
+ * Empile un nouveau scope actif (mode LIFO).
32
+ * Seuls les raccourcis de ce scope (et les omniprésents '*') seront actifs.
33
+ */
34
+ pushScope(scope: string): void;
35
+ /**
36
+ * Dépile le scope actuel et rétablit le précédent.
37
+ * Si un paramètre `scope` est passé, ne retire que si le scope actuel correspond.
38
+ */
39
+ popScope(scope?: string): string | undefined;
40
+ /**
41
+ * Réinitialise brutalement la pile pour activer le scope spécifié.
42
+ */
43
+ setScope(scope: string): void;
44
+ /**
45
+ * Retourne le scope actuellement actif au sommet de la pile.
46
+ */
47
+ getScope(): string;
48
+ /**
49
+ * Retourne une copie de la pile complète des scopes.
50
+ */
51
+ getScopeStack(): string[];
52
+ /**
53
+ * Met en pause l'écoute de tous les raccourcis.
54
+ */
55
+ pause(): void;
56
+ /**
57
+ * Réactive l'écoute des raccourcis.
58
+ */
59
+ resume(): void;
60
+ /**
61
+ * Indique si le gestionnaire est actif et à l'écoute.
62
+ */
63
+ isActive(): boolean;
64
+ /**
65
+ * Retourne le catalogue des raccourcis enregistrés (optionnellement filtré par scope).
66
+ */
67
+ getRegistry(scope?: string): RegisteredShortcut[];
68
+ /**
69
+ * Associe l'attribut standard WAI-ARIA `aria-keyshortcuts` sur un élément DOM.
70
+ */
71
+ attachAria(element: HTMLElement, combo: string): void;
72
+ /**
73
+ * Formate une combinaison brute selon l'OS courant ("⌘K" ou "Ctrl+K").
74
+ */
75
+ static format(combo: string, isApple?: boolean): string;
76
+ /**
77
+ * Détruit le gestionnaire : supprime les écouteurs du DOM et vide toute la mémoire.
78
+ */
79
+ destroy(): void;
80
+ private initListener;
81
+ private removeListener;
82
+ private handleKeyDown;
83
+ private getActiveShortcuts;
84
+ private stepMatches;
85
+ private findMatchingChord;
86
+ private findMatchingSequence;
87
+ private isPrefixOfAnySequence;
88
+ private executeShortcut;
89
+ private resetSequenceTimer;
90
+ private clearSequenceBuffer;
91
+ }
@@ -0,0 +1,4 @@
1
+ export { ShortcutManager } from './ShortcutManager';
2
+ export { ShortcutFormatter } from './ShortcutFormatter';
3
+ export * from './types';
4
+ export { ShortcutManager as default } from './ShortcutManager';
@@ -0,0 +1,101 @@
1
+ export type KeyModifier = 'mod' | 'ctrl' | 'alt' | 'shift' | 'meta';
2
+ export interface ShortcutInfo {
3
+ /** Combinaison d'origine enregistrée (ex: "Mod+K") */
4
+ combo: string;
5
+ /** Combinaison lisible formatée selon l'OS (ex: "⌘K" ou "Ctrl+K") */
6
+ formattedCombo: string;
7
+ /** Scope actif dans lequel le raccourci a été déclenché */
8
+ scope: string;
9
+ /** Cible de l'événement déclencheur */
10
+ target: EventTarget | null;
11
+ /** Indique si le raccourci provient d'une séquence temporelle (ex: "g i") */
12
+ isSequence: boolean;
13
+ }
14
+ export type ShortcutHandler = (event: KeyboardEvent, info: ShortcutInfo) => void;
15
+ export interface ShortcutDefinition {
16
+ /**
17
+ * Combinaison de touches (ex: "Mod+K", "Shift+?", "Alt+F4")
18
+ * ou séquence de frappes consécutives séparées par des espaces (ex: "g i", "d d").
19
+ */
20
+ combo: string;
21
+ /**
22
+ * Fonction exécutée lorsque le raccourci est déclenché.
23
+ */
24
+ handler: ShortcutHandler;
25
+ /**
26
+ * Description lisible pour l'aide ou le cheat sheet (ex: "Ouvrir la recherche").
27
+ */
28
+ description?: string;
29
+ /**
30
+ * Catégorie pour l'organisation de l'aide (ex: "Navigation", "Édition").
31
+ * Défaut: "Général".
32
+ */
33
+ category?: string;
34
+ /**
35
+ * Scope contextuel du raccourci.
36
+ * Utiliser "*" pour un raccourci actif dans tous les scopes.
37
+ * Défaut: "global".
38
+ */
39
+ scope?: string;
40
+ /**
41
+ * Autorise le déclenchement même lorsque le focus est dans un élément éditable
42
+ * (input, textarea, select, contenteditable).
43
+ * Conformément à l'Axiome Primordial, la valeur par défaut est STRICTEMENT false.
44
+ * Défaut: false.
45
+ */
46
+ allowInEditable?: boolean;
47
+ /**
48
+ * Appelle event.preventDefault() si le raccourci correspond et s'exécute.
49
+ * Défaut: true.
50
+ */
51
+ preventDefault?: boolean;
52
+ /**
53
+ * Appelle event.stopPropagation() si le raccourci correspond et s'exécute.
54
+ * Défaut: true.
55
+ */
56
+ stopPropagation?: boolean;
57
+ /**
58
+ * Priorité en cas de collisions multiples pour un même combo dans le même scope.
59
+ * Défaut: 0.
60
+ */
61
+ priority?: number;
62
+ }
63
+ export interface RegisteredShortcut extends ShortcutDefinition {
64
+ /** Identifiant unique interne */
65
+ id: string;
66
+ /** Chaîne lisible formatée pour l'OS (ex: "Ctrl+K" ou "⌘K") */
67
+ formattedCombo: string;
68
+ /** Séquence de pas normalisés pour le moteur de matching */
69
+ normalizedSteps: NormalizedStep[];
70
+ /** Indique s'il s'agit d'une séquence multi-touches */
71
+ isSequence: boolean;
72
+ }
73
+ export interface NormalizedStep {
74
+ ctrl: boolean;
75
+ alt: boolean;
76
+ shift: boolean;
77
+ meta: boolean;
78
+ /** Touche principale normalisée en minuscules (ex: "k", "enter", "escape", "f1") */
79
+ key: string;
80
+ }
81
+ export interface ShortcutManagerOptions {
82
+ /**
83
+ * Scope actif au démarrage du gestionnaire.
84
+ * Défaut: "global".
85
+ */
86
+ defaultScope?: string;
87
+ /**
88
+ * Délai maximal en millisecondes entre deux touches d'une séquence.
89
+ * Défaut: 800.
90
+ */
91
+ sequenceTimeout?: number;
92
+ /**
93
+ * Cible DOM sur laquelle greffer l'écouteur d'événement keydown.
94
+ * Défaut: window (si disponible).
95
+ */
96
+ target?: Window | HTMLElement | Document;
97
+ /**
98
+ * Callback appelé si une exception survient dans un handler de raccourci.
99
+ */
100
+ onError?: (error: Error, combo: string) => void;
101
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "wulf.js",
3
- "version": "1.9.1",
4
- "description": "Suite de composants UI ultra-légers, modulaires, zéro dépendance et hautement accessibles (Mask, Scroll, Masonry, Toast, FocusTrap)",
5
- "main": "dist/index.cjs.js",
3
+ "version": "1.9.2",
4
+ "description": "Suite de composants UI ultra-légers, modulaires, zéro dépendance et hautement accessibles (Mask, Scroll, Masonry, Toast, FocusTrap, Shortcut)",
5
+ "main": "dist/index.esm.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "types": "dist/types/index.d.ts",
8
8
  "files": [
@@ -19,36 +19,41 @@
19
19
  ".": {
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "import": "./dist/index.esm.js",
22
- "require": "./dist/index.cjs.js"
22
+ "default": "./dist/index.esm.js"
23
23
  },
24
24
  "./mask": {
25
25
  "types": "./dist/types/mask/index.d.ts",
26
26
  "import": "./dist/mask.esm.js",
27
- "require": "./dist/mask.cjs.js"
27
+ "default": "./dist/mask.esm.js"
28
28
  },
29
29
  "./mask/css": "./dist/mask.css",
30
30
  "./scroll": {
31
31
  "types": "./dist/types/scroll/index.d.ts",
32
32
  "import": "./dist/scroll.esm.js",
33
- "require": "./dist/scroll.cjs.js"
33
+ "default": "./dist/scroll.esm.js"
34
34
  },
35
35
  "./scroll/css": "./dist/scroll.css",
36
36
  "./masonry": {
37
37
  "types": "./dist/types/masonry/index.d.ts",
38
38
  "import": "./dist/masonry.esm.js",
39
- "require": "./dist/masonry.cjs.js"
39
+ "default": "./dist/masonry.esm.js"
40
40
  },
41
41
  "./masonry/css": "./dist/masonry.css",
42
42
  "./toast": {
43
43
  "types": "./dist/types/toast/index.d.ts",
44
44
  "import": "./dist/toast.esm.js",
45
- "require": "./dist/toast.cjs.js"
45
+ "default": "./dist/toast.esm.js"
46
46
  },
47
47
  "./toast/css": "./dist/toast.css",
48
48
  "./focus-trap": {
49
49
  "types": "./dist/types/focus-trap/index.d.ts",
50
50
  "import": "./dist/focus-trap.esm.js",
51
- "require": "./dist/focus-trap.cjs.js"
51
+ "default": "./dist/focus-trap.esm.js"
52
+ },
53
+ "./shortcut": {
54
+ "types": "./dist/types/shortcut/index.d.ts",
55
+ "import": "./dist/shortcut.esm.js",
56
+ "default": "./dist/shortcut.esm.js"
52
57
  }
53
58
  },
54
59
  "scripts": {
@@ -60,17 +65,19 @@
60
65
  "test:masonry": "npm run build && node scripts/open-tests.mjs masonry",
61
66
  "test:toast": "npm run build && node scripts/open-tests.mjs toast",
62
67
  "test:focus-trap": "npm run build && node scripts/open-tests.mjs focus-trap",
68
+ "test:shortcut": "npm run build && node scripts/open-tests.mjs shortcut",
63
69
  "test:ci": "npm run build && node scripts/run-tests-browser.mjs",
64
70
  "demo": "node scripts/open-demo.mjs",
65
71
  "demo:mask": "node scripts/open-demo.mjs mask",
66
72
  "demo:scroll": "node scripts/open-demo.mjs scroll",
67
73
  "demo:masonry": "node scripts/open-demo.mjs masonry",
68
74
  "demo:toast": "node scripts/open-demo.mjs toast",
75
+ "demo:shortcut": "node scripts/open-demo.mjs shortcut",
69
76
  "dev": "npm run demo",
70
77
  "prepublishOnly": "npm run build && npm run typecheck",
71
78
  "preversion": "npm run typecheck && npm run build && node scripts/run-tests-browser.mjs",
72
79
  "version": "node scripts/update-changelog.mjs && git add changelog.md",
73
- "postversion": "git push && git push --tags && npm publish",
80
+ "postversion": "node scripts/npm-login.mjs && git push && git push --tags && npm publish",
74
81
  "version:patch": "npm version patch",
75
82
  "version:minor": "npm version minor",
76
83
  "version:major": "npm version major"