{"_id":"@composy/hotkey-vue","name":"@composy/hotkey-vue","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@composy/hotkey-vue","version":"0.0.1","description":"Vue 3 适配层 for @composy/hotkey-core","keywords":["hotkey","shortcut","vue","vue3","composable","directive"],"author":{"name":"LDesign Team"},"license":"MIT","type":"module","sideEffects":false,"exports":{".":{"types":"./es/index.d.ts","import":"./es/index.js","require":"./lib/index.cjs","default":"./es/index.js"},"./composables":{"types":"./es/composables/index.d.ts","import":"./es/composables/index.js","require":"./lib/composables/index.cjs","default":"./es/composables/index.js"},"./composables/*":{"types":"./es/composables/*.d.ts","import":"./es/composables/*.js","require":"./lib/composables/*.cjs","default":"./es/composables/*.js"},"./package.json":"./package.json"},"main":"./lib/index.cjs","module":"./es/index.js","types":"./es/index.d.ts","typings":"./es/index.d.ts","unpkg":"./dist/index.min.js","jsdelivr":"./dist/index.min.js","browser":"./dist/index.js","scripts":{"build":"ldesign-builder build && node --experimental-strip-types ../../../../scripts/index.ts workspace:ensure-package-outputs --cwd .. --target vue","dev":"ldesign-builder build --watch","lint":"eslint . --cache","lint:check":"eslint . --cache --max-warnings 0","lint:fix":"eslint . --cache --fix","type-check":"vue-tsc --noEmit","test":"ltesting run:unit","test:run":"ltesting run:unit","test:watch":"ltesting run:unit --watch","test:coverage":"ltesting run:unit --coverage","test:changed":"ltesting run:unit --changed","test:failed":"ltesting run:unit --failed","test:ui":"ltesting dashboard"},"dependencies":{"@composy/hotkey-core":"^0.0.1"},"peerDependencies":{"vue":"^3.5.32"},"devDependencies":{"@antfu/eslint-config":"9.1.0","@composy/builder":"^0.0.1","@composy/testing":"^0.0.1","@vue/test-utils":"^2.4.11","eslint":"10.7.0","fast-check":"^4.9.0","jsdom":"29.1.1","typescript":"5.9.3","vite":"^8.1.4","vue":"3.5.39","vue-tsc":"^3.3.7"},"publishConfig":{"registry":"http://npm.longrise.cn:6286/"},"_id":"@composy/hotkey-vue@0.0.1","_nodeVersion":"23.11.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-7638MLPUwLcP0E4E5Q21Eb/cOcBijygP/7szXJy0HSHuzH01cBDXzrg/4S7/1V0vMT3OHQV37f+zi2SQxvVJ7w==","shasum":"0a840884f5373db453185b9940d5afc15fbeaffb","tarball":"https://registry.npmjs.org/@composy/hotkey-vue/-/hotkey-vue-0.0.1.tgz","fileCount":96,"unpackedSize":210640,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCID1pDvZ3XMzKLRB+OiAtYausIeYS0sB3JfIWIOLB88NMAiAi1E48M5+Nnh/bNzjck0kcuvi28eVO/xS2Owt6o0LMlg=="}]},"_npmUser":{"name":"swimly","email":"979741120@qq.com"},"directories":{},"maintainers":[{"name":"swimly","email":"979741120@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hotkey-vue_0.0.1_1786949132582_0.8388093435698343"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-17T06:45:32.370Z","0.0.1":"2026-08-17T06:45:32.723Z","modified":"2026-08-17T06:45:33.019Z"},"maintainers":[{"name":"swimly","email":"979741120@qq.com"}],"description":"Vue 3 适配层 for @composy/hotkey-core","keywords":["hotkey","shortcut","vue","vue3","composable","directive"],"author":{"name":"LDesign Team"},"license":"MIT","readme":"# @composy/hotkey-vue\n\nVue 3 快捷键管理适配层 — 提供 composable、指令和插件。\n\n## 安装\n\n```bash\npnpm add @composy/hotkey-vue\n```\n\n## 快速开始\n\n```ts\n// main.ts\nimport { createApp } from 'vue'\nimport { createHotkeyPlugin } from '@composy/hotkey-vue'\nimport App from './App.vue'\n\nconst app = createApp(App)\napp.use(createHotkeyPlugin({ scope: 'global' }))\napp.mount('#app')\n```\n\n```vue\n<script setup lang=\"ts\">\nimport { useHotkey, useHotkeyScope, useHotkeyHelp } from '@composy/hotkey-vue'\n\nconst { setScope } = useHotkeyScope('editor')\nconst { toggle } = useHotkeyHelp()\n\nuseHotkey('ctrl+s', () => save(), { description: '保存文件' })\nuseHotkey('ctrl+z', () => undo(), { description: '撤销', scope: 'editor' })\n</script>\n\n<template>\n  <button v-hotkey=\"'ctrl+n'\" @click=\"createNew\">新建</button>\n  <button v-hotkey=\"{ key: 'ctrl+s', handler: save, description: '保存' }\">保存</button>\n  <button @click=\"toggle\">快捷键帮助</button>\n</template>\n```\n\n## API\n\n### `createHotkeyPlugin(options?)`\n\n创建 Vue 插件，提供 manager 注册和 v-hotkey 指令。\n\n```ts\napp.use(createHotkeyPlugin({\n  scope: 'global',\n  preventDefault: true,\n}))\n```\n\n### `useHotkey(key, handler, options?)`\n\n组合式函数，组件生命周期内自动注册/注销快捷键。\n\n```ts\nuseHotkey('ctrl+s', save, {\n  description: '保存',\n  scope: 'editor',\n  preventDefault: true,\n  priority: 10,\n})\n```\n\n### `useHotkeyScope(scope?)`\n\n组合式函数，管理快捷键作用域。组件挂载时切换，卸载时恢复。\n\n```ts\nconst { currentScope, setScope, getBindings } = useHotkeyScope('editor')\n```\n\n### `useHotkeyHelp()`\n\n组合式函数，管理帮助面板。\n\n```ts\nconst { show, hide, toggle } = useHotkeyHelp()\n```\n\n### `v-hotkey` 指令\n\n```vue\n<!-- 简单字符串 -->\n<button v-hotkey=\"'ctrl+s'\">保存</button>\n\n<!-- 带描述 (arg) -->\n<button v-hotkey:保存=\"'ctrl+s'\">保存</button>\n\n<!-- 完整对象 -->\n<button v-hotkey=\"{ key: 'ctrl+s', handler: save, description: '保存' }\">保存</button>\n```\n\n### `HOTKEY_MANAGER_KEY`\n\nVue injection key，用于手动 provide/inject manager。\n\n```ts\nimport { inject } from 'vue'\nimport { HOTKEY_MANAGER_KEY } from '@composy/hotkey-vue'\n\nconst manager = inject(HOTKEY_MANAGER_KEY)\n```\n\n## 重导出 Core\n\n本包重导出所有 `@composy/hotkey-core` 类型和类，无需额外安装 core：\n\n```ts\nimport { HotkeyManager, parseHotkey } from '@composy/hotkey-vue'\n```\n\n## 构建产物\n\n| 目录 | 格式 | 入口 |\n|------|------|------|\n| `es/` | ESM | `index.js` |\n| `esm/` | ESM | `index.js` |\n| `lib/` | CJS | `index.cjs` |\n| `dist/` | UMD | `index.js` / `index.min.js` |\n\n## 验证\n\n```bash\npnpm run type-check\npnpm run lint:check\npnpm run test:run\npnpm run build\n```\n","readmeFilename":"README.md","_rev":"1-da8c0d20cce0872fa4fb67fa57ffea15"}