@composy/keyboard-vue 0.0.1 → 0.0.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 (172) hide show
  1. package/README.md +48 -24
  2. package/dist/index.css +552 -560
  3. package/dist/index.js +228 -192
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.css +1 -1
  6. package/dist/index.min.js +954 -1
  7. package/dist/index.min.js.map +1 -0
  8. package/es/.dts-output-manifest.json +1 -0
  9. package/es/.dts.tsbuildinfo +1 -0
  10. package/es/components/KeyboardKey.js +1 -1
  11. package/es/components/KeyboardKey.js.map +1 -1
  12. package/es/components/KeyboardKey.vue_vue_type_script_setup_true_lang.js +16 -7
  13. package/es/components/KeyboardKey.vue_vue_type_script_setup_true_lang.js.map +1 -1
  14. package/es/components/KeyboardPopup.js +1 -1
  15. package/es/components/KeyboardPopup.js.map +1 -1
  16. package/es/components/KeyboardPopup.vue_vue_type_script_setup_true_lang.js +8 -5
  17. package/es/components/KeyboardPopup.vue_vue_type_script_setup_true_lang.js.map +1 -1
  18. package/es/components/LicensePlateKeyboard.js +1 -1
  19. package/es/components/LicensePlateKeyboard.js.map +1 -1
  20. package/es/components/LicensePlateKeyboard.vue_vue_type_script_setup_true_lang.js +2 -2
  21. package/es/components/LicensePlateKeyboard.vue_vue_type_script_setup_true_lang.js.map +1 -1
  22. package/es/components/VirtualKeyboard.js +1 -1
  23. package/es/components/VirtualKeyboard.js.map +1 -1
  24. package/es/components/VirtualKeyboard.vue_vue_type_script_setup_true_lang.js +4 -4
  25. package/es/components/VirtualKeyboard.vue_vue_type_script_setup_true_lang.js.map +1 -1
  26. package/es/components/index.d.ts +1 -2
  27. package/es/components/index.d.ts.map +1 -1
  28. package/es/components/index.js +1 -1
  29. package/es/composables/index.d.ts +0 -1
  30. package/es/composables/index.js +1 -1
  31. package/es/composables/useKeyboard.d.ts +1 -2
  32. package/es/composables/useKeyboard.d.ts.map +1 -1
  33. package/es/composables/useKeyboard.js +8 -15
  34. package/es/composables/useKeyboard.js.map +1 -1
  35. package/es/composables/useKeyboardPopup.d.ts +2 -51
  36. package/es/composables/useKeyboardPopup.d.ts.map +1 -1
  37. package/es/composables/useKeyboardPopup.js +66 -49
  38. package/es/composables/useKeyboardPopup.js.map +1 -1
  39. package/es/directives/index.d.ts +0 -1
  40. package/es/directives/index.js +1 -1
  41. package/es/directives/v-keyboard.d.ts +0 -1
  42. package/es/directives/v-keyboard.d.ts.map +1 -1
  43. package/es/directives/v-keyboard.js +10 -11
  44. package/es/directives/v-keyboard.js.map +1 -1
  45. package/es/index.d.ts +3 -4
  46. package/es/index.d.ts.map +1 -1
  47. package/es/index.js +2 -5
  48. package/es/index.js.map +1 -1
  49. package/es/plugins/engine-plugin.d.ts +0 -1
  50. package/es/plugins/engine-plugin.d.ts.map +1 -1
  51. package/es/plugins/engine-plugin.js +19 -4
  52. package/es/plugins/engine-plugin.js.map +1 -1
  53. package/es/plugins/index.d.ts +0 -1
  54. package/es/plugins/index.js +1 -1
  55. package/es/style/css.js +1 -1
  56. package/es/style/index.css +2 -0
  57. package/es/style/index.js +1 -1
  58. package/es/styles/index.css +391 -0
  59. package/es/styles/keyboard.css +252 -0
  60. package/es/styles/themes.css +137 -0
  61. package/esm/components/KeyboardKey.js +17 -0
  62. package/esm/components/KeyboardKey.js.map +1 -0
  63. package/esm/components/KeyboardKey.vue_vue_type_script_setup_true_lang.js +140 -0
  64. package/esm/components/KeyboardKey.vue_vue_type_script_setup_true_lang.js.map +1 -0
  65. package/esm/components/KeyboardPopup.js +17 -0
  66. package/esm/components/KeyboardPopup.js.map +1 -0
  67. package/esm/components/KeyboardPopup.vue_vue_type_script_setup_true_lang.js +167 -0
  68. package/esm/components/KeyboardPopup.vue_vue_type_script_setup_true_lang.js.map +1 -0
  69. package/esm/components/LicensePlateKeyboard.js +17 -0
  70. package/esm/components/LicensePlateKeyboard.js.map +1 -0
  71. package/esm/components/LicensePlateKeyboard.vue_vue_type_script_setup_true_lang.js +97 -0
  72. package/esm/components/LicensePlateKeyboard.vue_vue_type_script_setup_true_lang.js.map +1 -0
  73. package/esm/components/VirtualKeyboard.js +17 -0
  74. package/esm/components/VirtualKeyboard.js.map +1 -0
  75. package/esm/components/VirtualKeyboard.vue_vue_type_script_setup_true_lang.js +127 -0
  76. package/esm/components/VirtualKeyboard.vue_vue_type_script_setup_true_lang.js.map +1 -0
  77. package/{lib → esm}/components/index.d.ts +1 -1
  78. package/esm/components/index.d.ts.map +1 -0
  79. package/esm/components/index.js +15 -0
  80. package/esm/composables/index.d.ts.map +1 -0
  81. package/esm/composables/index.js +13 -0
  82. package/{lib → esm}/composables/useKeyboard.d.ts +1 -1
  83. package/esm/composables/useKeyboard.d.ts.map +1 -0
  84. package/esm/composables/useKeyboard.js +68 -0
  85. package/esm/composables/useKeyboard.js.map +1 -0
  86. package/esm/composables/useKeyboardPopup.d.ts +25 -0
  87. package/esm/composables/useKeyboardPopup.d.ts.map +1 -0
  88. package/esm/composables/useKeyboardPopup.js +136 -0
  89. package/esm/composables/useKeyboardPopup.js.map +1 -0
  90. package/esm/directives/index.d.ts.map +1 -0
  91. package/esm/directives/index.js +12 -0
  92. package/esm/directives/v-keyboard.d.ts.map +1 -0
  93. package/esm/directives/v-keyboard.js +64 -0
  94. package/esm/directives/v-keyboard.js.map +1 -0
  95. package/esm/index.d.ts +42 -0
  96. package/esm/index.d.ts.map +1 -0
  97. package/esm/index.js +34 -0
  98. package/esm/index.js.map +1 -0
  99. package/esm/plugins/engine-plugin.d.ts.map +1 -0
  100. package/esm/plugins/engine-plugin.js +53 -0
  101. package/esm/plugins/engine-plugin.js.map +1 -0
  102. package/esm/plugins/index.d.ts.map +1 -0
  103. package/esm/plugins/index.js +12 -0
  104. package/esm/style/css.js +1 -0
  105. package/esm/style/index.js +1 -0
  106. package/{es → esm}/style/index.less +1 -1
  107. package/esm/styles/index.less +5 -0
  108. package/esm/styles/keyboard.less +286 -0
  109. package/esm/styles/themes.less +164 -0
  110. package/lib/components/KeyboardKey.cjs +1 -1
  111. package/lib/components/KeyboardKey.cjs.map +1 -1
  112. package/lib/components/KeyboardKey.vue_vue_type_script_setup_true_lang.cjs +16 -7
  113. package/lib/components/KeyboardKey.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  114. package/lib/components/KeyboardPopup.cjs +1 -1
  115. package/lib/components/KeyboardPopup.cjs.map +1 -1
  116. package/lib/components/KeyboardPopup.vue_vue_type_script_setup_true_lang.cjs +8 -5
  117. package/lib/components/KeyboardPopup.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  118. package/lib/components/LicensePlateKeyboard.cjs +1 -1
  119. package/lib/components/LicensePlateKeyboard.cjs.map +1 -1
  120. package/lib/components/LicensePlateKeyboard.vue_vue_type_script_setup_true_lang.cjs +2 -2
  121. package/lib/components/LicensePlateKeyboard.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  122. package/lib/components/VirtualKeyboard.cjs +1 -1
  123. package/lib/components/VirtualKeyboard.cjs.map +1 -1
  124. package/lib/components/VirtualKeyboard.vue_vue_type_script_setup_true_lang.cjs +4 -4
  125. package/lib/components/VirtualKeyboard.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
  126. package/lib/components/index.cjs +1 -1
  127. package/lib/components/index.d.cts +8 -0
  128. package/lib/components/index.d.cts.map +1 -0
  129. package/lib/composables/index.cjs +1 -1
  130. package/lib/composables/index.d.cts +6 -0
  131. package/lib/composables/index.d.cts.map +1 -0
  132. package/lib/composables/useKeyboard.cjs +8 -15
  133. package/lib/composables/useKeyboard.cjs.map +1 -1
  134. package/lib/composables/useKeyboard.d.cts +112 -0
  135. package/lib/composables/useKeyboard.d.cts.map +1 -0
  136. package/lib/composables/useKeyboardPopup.cjs +66 -49
  137. package/lib/composables/useKeyboardPopup.cjs.map +1 -1
  138. package/lib/composables/useKeyboardPopup.d.cts +24 -0
  139. package/lib/composables/useKeyboardPopup.d.cts.map +1 -0
  140. package/lib/directives/index.cjs +1 -1
  141. package/lib/directives/index.d.cts +5 -0
  142. package/lib/directives/index.d.cts.map +1 -0
  143. package/lib/directives/v-keyboard.cjs +10 -11
  144. package/lib/directives/v-keyboard.cjs.map +1 -1
  145. package/lib/directives/v-keyboard.d.cts +35 -0
  146. package/lib/directives/v-keyboard.d.cts.map +1 -0
  147. package/lib/index.cjs +2 -2
  148. package/lib/index.cjs.map +1 -1
  149. package/lib/index.d.cts +41 -0
  150. package/lib/index.d.cts.map +1 -0
  151. package/lib/plugins/engine-plugin.cjs +19 -3
  152. package/lib/plugins/engine-plugin.cjs.map +1 -1
  153. package/lib/plugins/engine-plugin.d.cts +36 -0
  154. package/lib/plugins/engine-plugin.d.cts.map +1 -0
  155. package/lib/plugins/index.cjs +1 -1
  156. package/lib/plugins/index.d.cts +5 -0
  157. package/lib/plugins/index.d.cts.map +1 -0
  158. package/lib/style/index.css +1 -1
  159. package/lib/styles/index.css +357 -195
  160. package/lib/styles/keyboard.css +92 -186
  161. package/lib/styles/themes.css +102 -178
  162. package/package.json +43 -34
  163. package/es/styles/index.less +0 -267
  164. package/es/styles/keyboard.less +0 -399
  165. package/es/styles/themes.less +0 -233
  166. package/lib/composables/useKeyboardPopup.d.ts +0 -73
  167. package/lib/index.d.ts +0 -42
  168. /package/{lib → esm}/composables/index.d.ts +0 -0
  169. /package/{lib → esm}/directives/index.d.ts +0 -0
  170. /package/{lib → esm}/directives/v-keyboard.d.ts +0 -0
  171. /package/{lib → esm}/plugins/engine-plugin.d.ts +0 -0
  172. /package/{lib → esm}/plugins/index.d.ts +0 -0
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * ***********************************
3
+ * @composy/keyboard-vue v0.0.1 *
4
+ * Built with rollup *
5
+ * Build time: 2024-10-12 17:44:15 *
6
+ * Build mode: production *
7
+ * Minified: No *
8
+ * ***********************************
9
+ */
10
+ import { useKeyboard } from "./useKeyboard.js";
11
+ import { useKeyboardPopup } from "./useKeyboardPopup.js";
12
+ export { useKeyboard, useKeyboardPopup };
13
+ /*! End of @composy/keyboard-vue | Powered by @composy/builder */
@@ -2,8 +2,8 @@
2
2
  * 键盘管理 Composable
3
3
  * @module composables/useKeyboard
4
4
  */
5
+ import type { KeyboardConfig, KeyboardEventMap, KeyboardOptions, KeyboardState, KeyboardType, KeyDefinition } from '@composy/keyboard-core';
5
6
  import type { Ref } from 'vue';
6
- import { type KeyboardConfig, type KeyboardEventMap, type KeyboardOptions, type KeyboardState, type KeyboardType, type KeyDefinition } from '@composy/keyboard-core';
7
7
  /**
8
8
  * useKeyboard 选项
9
9
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboard.d.ts","sourceRoot":"","sources":["../../src/composables/useKeyboard.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAI9B;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAErB;;OAEG;IACH,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,CAAA;IAEvB;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAEzB;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAElB;;OAEG;IACH,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAE3B;;OAEG;IACH,MAAM,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAElC;;OAEG;IACH,KAAK,EAAE,aAAa,CAAA;IAEpB;;OAEG;IACH,IAAI,EAAE,CAAC,KAAK,CAAC,E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EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CA4EnB"}
@@ -0,0 +1,68 @@
1
+ /*!
2
+ * ***********************************
3
+ * @composy/keyboard-vue v0.0.1 *
4
+ * Built with rollup *
5
+ * Build time: 2024-10-12 17:44:15 *
6
+ * Build mode: production *
7
+ * Minified: No *
8
+ * ***********************************
9
+ */
10
+ import { onBeforeUnmount, reactive, ref, shallowRef } from "vue";
11
+ import { createKeyboardManager } from "@composy/keyboard-core";
12
+ //#region src/composables/useKeyboard.ts
13
+ function useKeyboard(options = {}) {
14
+ const { immediate = false, ...keyboardOptions } = options;
15
+ const manager = createKeyboardManager(keyboardOptions);
16
+ const initialState = manager.getState();
17
+ const visible = ref(initialState.visible);
18
+ const type = ref(initialState.type);
19
+ const isUpperCase = ref(initialState.isUpperCase);
20
+ const value = ref(initialState.value);
21
+ const cursorPosition = ref(initialState.cursorPosition);
22
+ const layout = shallowRef(manager.getLayout());
23
+ const state = reactive({ ...initialState });
24
+ const syncState = (newState) => {
25
+ visible.value = newState.visible;
26
+ type.value = newState.type;
27
+ isUpperCase.value = newState.isUpperCase;
28
+ value.value = newState.value;
29
+ cursorPosition.value = newState.cursorPosition;
30
+ Object.assign(state, newState);
31
+ };
32
+ manager.on("stateChange", syncState);
33
+ manager.on("switch", () => {
34
+ layout.value = manager.getLayout();
35
+ });
36
+ if (immediate) manager.show();
37
+ onBeforeUnmount(() => {
38
+ manager.destroy();
39
+ });
40
+ return {
41
+ visible,
42
+ type,
43
+ isUpperCase,
44
+ value,
45
+ cursorPosition,
46
+ layout,
47
+ state,
48
+ show: (input) => manager.show(input),
49
+ hide: () => manager.hide(),
50
+ toggle: (input) => manager.toggle(input),
51
+ switchType: (t) => manager.switchType(t),
52
+ toggleShift: () => manager.toggleShift(),
53
+ handleKey: (key) => manager.handleKey(key),
54
+ getKeyLabel: (key) => manager.getKeyLabel(key),
55
+ setValue: (v) => manager.setValue(v),
56
+ appendValue: (text) => manager.appendValue(text),
57
+ setMaxLength: (maxLength) => manager.setMaxLength(maxLength),
58
+ bindInput: (input) => manager.bindInput(input),
59
+ unbindInput: () => manager.unbindInput(),
60
+ on: (event, handler) => manager.on(event, handler),
61
+ once: (event, handler) => manager.once(event, handler),
62
+ destroy: () => manager.destroy()
63
+ };
64
+ }
65
+ //#endregion
66
+ export { useKeyboard };
67
+ /*! End of @composy/keyboard-vue | Powered by @composy/builder */
68
+ //# sourceMappingURL=useKeyboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboard.js","names":[],"sources":["../../src/composables/useKeyboard.ts"],"sourcesContent":["/**\r\n * 键盘管理 Composable\r\n * @module composables/useKeyboard\r\n */\r\n\r\nimport type {\r\n KeyboardConfig,\r\n KeyboardEventMap,\r\n KeyboardOptions,\r\n KeyboardState,\r\n KeyboardType,\r\n KeyDefinition,\r\n} from '@composy/keyboard-core'\r\nimport type { Ref } from 'vue'\r\nimport { createKeyboardManager } from '@composy/keyboard-core'\r\nimport { onBeforeUnmount, reactive, ref, shallowRef } from 'vue'\r\n\r\n/**\r\n * useKeyboard 选项\r\n */\r\nexport interface UseKeyboardOptions extends KeyboardOptions {\r\n /**\r\n * 是否立即显示\r\n */\r\n immediate?: boolean\r\n}\r\n\r\n/**\r\n * useKeyboard 返回值\r\n */\r\nexport interface UseKeyboardReturn {\r\n /**\r\n * 键盘是否可见\r\n */\r\n visible: Ref<boolean>\r\n\r\n /**\r\n * 当前键盘类型\r\n */\r\n type: Ref<KeyboardType>\r\n\r\n /**\r\n * 是否大写状态\r\n */\r\n isUpperCase: Ref<boolean>\r\n\r\n /**\r\n * 当前输入值\r\n */\r\n value: Ref<string>\r\n\r\n /**\r\n * 光标位置\r\n */\r\n cursorPosition: Ref<number>\r\n\r\n /**\r\n * 当前布局配置\r\n */\r\n layout: Ref<KeyboardConfig | null>\r\n\r\n /**\r\n * 完整状态\r\n */\r\n state: KeyboardState\r\n\r\n /**\r\n * 显示键盘\r\n */\r\n show: (input?: HTMLInputElement | HTMLTextAreaElement) => void\r\n\r\n /**\r\n * 隐藏键盘\r\n */\r\n hide: () => void\r\n\r\n /**\r\n * 切换显示/隐藏\r\n */\r\n toggle: (input?: HTMLInputElement | HTMLTextAreaElement) => void\r\n\r\n /**\r\n * 切换键盘类型\r\n */\r\n switchType: (type: KeyboardType | string) => void\r\n\r\n /**\r\n * 切换大小写\r\n */\r\n toggleShift: () => void\r\n\r\n /**\r\n * 处理按键\r\n */\r\n handleKey: (key: KeyDefinition) => void\r\n\r\n /**\r\n * 获取按键显示文本\r\n */\r\n getKeyLabel: (key: KeyDefinition) => string\r\n\r\n /**\r\n * 设置值\r\n */\r\n setValue: (value: string) => void\r\n\r\n /**\r\n * 追加值(在光标位置插入文本)\r\n */\r\n appendValue: (text: string) => void\r\n\r\n /**\r\n * 设置最大长度\r\n */\r\n setMaxLength: (maxLength?: number) => void\r\n\r\n /**\r\n * 绑定输入框\r\n */\r\n bindInput: (input: HTMLInputElement | HTMLTextAreaElement) => void\r\n\r\n /**\r\n * 解绑输入框\r\n */\r\n unbindInput: () => void\r\n\r\n /**\r\n * 事件监听\r\n */\r\n on: <K extends keyof KeyboardEventMap>(\r\n event: K,\r\n handler: (data: KeyboardEventMap[K]) => void\r\n ) => () => void\r\n\r\n /**\r\n * 单次事件监听\r\n */\r\n once: <K extends keyof KeyboardEventMap>(\r\n event: K,\r\n handler: (data: KeyboardEventMap[K]) => void\r\n ) => () => void\r\n\r\n /**\r\n * 销毁\r\n */\r\n destroy: () => void\r\n}\r\n\r\n/**\r\n * 键盘管理 Composable\r\n */\r\nexport function useKeyboard(\r\n options: UseKeyboardOptions = {}\r\n): UseKeyboardReturn {\r\n const { immediate = false, ...keyboardOptions } = options\r\n\r\n // 创建键盘管理器\r\n const manager = createKeyboardManager(keyboardOptions)\r\n const initialState = manager.getState()\r\n\r\n // 响应式状态\r\n const visible = ref(initialState.visible)\r\n const type = ref<KeyboardType>(initialState.type)\r\n const isUpperCase = ref(initialState.isUpperCase)\r\n const value = ref(initialState.value)\r\n const cursorPosition = ref(initialState.cursorPosition)\r\n const layout = shallowRef<KeyboardConfig | null>(manager.getLayout())\r\n\r\n // 完整状态(响应式对象)\r\n const state = reactive<KeyboardState>({\r\n ...initialState,\r\n })\r\n\r\n // 同步管理器状态到 Vue 响应式状态\r\n const syncState = (newState: KeyboardState) => {\r\n visible.value = newState.visible\r\n type.value = newState.type\r\n isUpperCase.value = newState.isUpperCase\r\n value.value = newState.value\r\n cursorPosition.value = newState.cursorPosition\r\n\r\n Object.assign(state, newState)\r\n }\r\n\r\n // 监听状态变化\r\n manager.on('stateChange', syncState)\r\n\r\n // 监听键盘类型切换,更新布局\r\n manager.on('switch', () => {\r\n layout.value = manager.getLayout()\r\n })\r\n\r\n // 立即显示\r\n if (immediate) {\r\n manager.show()\r\n }\r\n\r\n // 组件卸载时销毁\r\n onBeforeUnmount(() => {\r\n manager.destroy()\r\n })\r\n\r\n return {\r\n visible,\r\n type,\r\n isUpperCase,\r\n value,\r\n cursorPosition,\r\n layout,\r\n state,\r\n show: (input?: HTMLInputElement | HTMLTextAreaElement) =>\r\n manager.show(input),\r\n hide: () => manager.hide(),\r\n toggle: (input?: HTMLInputElement | HTMLTextAreaElement) =>\r\n manager.toggle(input),\r\n switchType: (t: KeyboardType | string) => manager.switchType(t),\r\n toggleShift: () => manager.toggleShift(),\r\n handleKey: (key: KeyDefinition) => manager.handleKey(key),\r\n getKeyLabel: (key: KeyDefinition) => manager.getKeyLabel(key),\r\n setValue: (v: string) => manager.setValue(v),\r\n appendValue: (text: string) => manager.appendValue(text),\r\n setMaxLength: (maxLength?: number) => manager.setMaxLength(maxLength),\r\n bindInput: (input: HTMLInputElement | HTMLTextAreaElement) =>\r\n manager.bindInput(input),\r\n unbindInput: () => manager.unbindInput(),\r\n on: (event, handler) => manager.on(event, handler),\r\n once: (event, handler) => manager.once(event, handler),\r\n destroy: () => manager.destroy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AQ,aAAa,SAAS;EACpE,YAAY,UACV,QAAQ,UAAU,KAAK;EACzB,mBAAmB,QAAQ,YAAY;EACvC,KAAK,OAAO,YAAY,QAAQ,GAAG,OAAO,OAAO;EACjD,OAAO,OAAO,YAAY,QAAQ,KAAK,OAAO,OAAO;EACrD,eAAe,QAAQ,QAAQ;CACjC;AACF"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Keyboard popup composable.
3
+ * @module composables/useKeyboardPopup
4
+ */
5
+ import type { PopupPlacement, PopupPositionConfig } from '@composy/keyboard-core';
6
+ import type { CSSProperties, Ref } from 'vue';
7
+ export interface UseKeyboardPopupOptions extends PopupPositionConfig {
8
+ visible?: Ref<boolean>;
9
+ target?: Ref<HTMLElement | null>;
10
+ popup?: Ref<HTMLElement | null>;
11
+ closeOnClickOutside?: boolean;
12
+ onClose?: () => void;
13
+ }
14
+ export interface UseKeyboardPopupReturn {
15
+ popupStyles: Ref<CSSProperties>;
16
+ maskStyles: Ref<CSSProperties>;
17
+ placement: Ref<PopupPlacement>;
18
+ isMobileDevice: Ref<boolean>;
19
+ showMask: Ref<boolean>;
20
+ isAnimating: Ref<boolean>;
21
+ updatePosition: () => void;
22
+ close: () => void;
23
+ }
24
+ export declare function useKeyboardPopup(options?: UseKeyboardPopupOptions): UseKeyboardPopupReturn;
25
+ //# sourceMappingURL=useKeyboardPopup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboardPopup.d.ts","sourceRoot":"","sources":["../../src/composables/useKeyboardPopup.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACpB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAS7C,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,OAAO,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACtB,MAAM,CAAC,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAChC,KAAK,CAAC,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,GAAG,CAAC,aAAa,CAAC,CAAA;IAC/B,UAAU,EAAE,GAAG,CAAC,aAAa,CAAC,CAAA;IAC9B,SAAS,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;IAC9B,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAC5B,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACtB,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACzB,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,uBAA4B,GACpC,sBAAsB,CAwKxB"}
@@ -0,0 +1,136 @@
1
+ /*!
2
+ * ***********************************
3
+ * @composy/keyboard-vue v0.0.1 *
4
+ * Built with rollup *
5
+ * Build time: 2024-10-12 17:44:15 *
6
+ * Build mode: production *
7
+ * Minified: No *
8
+ * ***********************************
9
+ */
10
+ import { onBeforeUnmount, ref, watch } from "vue";
11
+ import { createPositionManager, isMobile, onClickOutside, onViewportChange } from "@composy/keyboard-core";
12
+ //#region src/composables/useKeyboardPopup.ts
13
+ function useKeyboardPopup(options = {}) {
14
+ const { visible = ref(false), target = ref(null), popup = ref(null), closeOnClickOutside = true, onClose, ...positionConfig } = options;
15
+ const positionManager = createPositionManager(positionConfig);
16
+ const popupStyles = ref({});
17
+ const maskStyles = ref({});
18
+ const placement = ref("bottom");
19
+ const isMobileDevice = ref(isMobile());
20
+ const showMask = ref(false);
21
+ const isAnimating = ref(false);
22
+ let cleanupClickOutside = null;
23
+ let cleanupViewportChange = null;
24
+ let cleanupScroll = null;
25
+ let animationFrame = null;
26
+ let visibilitySession = 0;
27
+ const cleanupOpenResources = () => {
28
+ cleanupClickOutside?.();
29
+ cleanupClickOutside = null;
30
+ cleanupViewportChange?.();
31
+ cleanupViewportChange = null;
32
+ cleanupScroll?.();
33
+ cleanupScroll = null;
34
+ };
35
+ const cancelAnimationFrame = () => {
36
+ if (animationFrame === null || typeof window === "undefined") return;
37
+ window.cancelAnimationFrame(animationFrame);
38
+ animationFrame = null;
39
+ };
40
+ const updatePosition = () => {
41
+ const popupElement = popup.value;
42
+ if (!popupElement) return;
43
+ const popupRect = popupElement.getBoundingClientRect();
44
+ const result = positionManager.calculate(target.value, {
45
+ width: Math.max(0, popupRect.width),
46
+ height: Math.max(0, popupRect.height)
47
+ });
48
+ placement.value = result.placement;
49
+ showMask.value = positionManager.shouldShowMask();
50
+ if (result.placement === "bottom-sheet") popupStyles.value = {
51
+ position: "fixed",
52
+ left: "0",
53
+ right: "0",
54
+ bottom: "0",
55
+ maxHeight: result.maxHeight === void 0 ? void 0 : `${result.maxHeight}px`,
56
+ zIndex: 1e3
57
+ };
58
+ else popupStyles.value = {
59
+ position: "fixed",
60
+ left: `${result.position.x}px`,
61
+ top: `${result.position.y}px`,
62
+ maxHeight: result.maxHeight === void 0 ? void 0 : `${result.maxHeight}px`,
63
+ maxWidth: result.maxWidth === void 0 ? void 0 : `${result.maxWidth}px`,
64
+ zIndex: 1e3
65
+ };
66
+ maskStyles.value = showMask.value ? {
67
+ position: "fixed",
68
+ inset: "0",
69
+ backgroundColor: "var(--keyboard-mask-bg)",
70
+ zIndex: 999
71
+ } : {};
72
+ };
73
+ const close = () => {
74
+ if (visible.value) onClose?.();
75
+ };
76
+ watch(visible, (newVisible) => {
77
+ visibilitySession += 1;
78
+ const currentSession = visibilitySession;
79
+ cancelAnimationFrame();
80
+ cleanupOpenResources();
81
+ if (!newVisible) {
82
+ isAnimating.value = false;
83
+ showMask.value = false;
84
+ popupStyles.value = {};
85
+ maskStyles.value = {};
86
+ return;
87
+ }
88
+ isMobileDevice.value = isMobile();
89
+ isAnimating.value = true;
90
+ if (typeof window !== "undefined") animationFrame = window.requestAnimationFrame(() => {
91
+ animationFrame = null;
92
+ if (!visible.value || currentSession !== visibilitySession) return;
93
+ updatePosition();
94
+ isAnimating.value = false;
95
+ if (closeOnClickOutside && popup.value) cleanupClickOutside = onClickOutside(popup.value, (event) => {
96
+ if (target.value && event.target instanceof Node && target.value.contains(event.target)) return;
97
+ close();
98
+ });
99
+ });
100
+ cleanupViewportChange = onViewportChange(() => {
101
+ if (!visible.value) return;
102
+ isMobileDevice.value = isMobile();
103
+ updatePosition();
104
+ });
105
+ if (!isMobileDevice.value && typeof window !== "undefined") {
106
+ const handleScroll = () => {
107
+ if (!visible.value) return;
108
+ window.requestAnimationFrame(updatePosition);
109
+ };
110
+ window.addEventListener("scroll", handleScroll, true);
111
+ cleanupScroll = () => window.removeEventListener("scroll", handleScroll, true);
112
+ }
113
+ }, { immediate: true });
114
+ watch(target, () => {
115
+ if (visible.value) updatePosition();
116
+ });
117
+ onBeforeUnmount(() => {
118
+ visibilitySession += 1;
119
+ cancelAnimationFrame();
120
+ cleanupOpenResources();
121
+ });
122
+ return {
123
+ popupStyles,
124
+ maskStyles,
125
+ placement,
126
+ isMobileDevice,
127
+ showMask,
128
+ isAnimating,
129
+ updatePosition,
130
+ close
131
+ };
132
+ }
133
+ //#endregion
134
+ export { useKeyboardPopup };
135
+ /*! End of @composy/keyboard-vue | Powered by @composy/builder */
136
+ //# sourceMappingURL=useKeyboardPopup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboardPopup.js","names":[],"sources":["../../src/composables/useKeyboardPopup.ts"],"sourcesContent":["/**\r\n * Keyboard popup composable.\r\n * @module composables/useKeyboardPopup\r\n */\r\n\r\nimport type {\r\n PopupPlacement,\r\n PopupPositionConfig,\r\n} from '@composy/keyboard-core'\r\nimport type { CSSProperties, Ref } from 'vue'\r\nimport {\r\n createPositionManager,\r\n isMobile,\r\n onClickOutside,\r\n onViewportChange,\r\n} from '@composy/keyboard-core'\r\nimport { onBeforeUnmount, ref, watch } from 'vue'\r\n\r\nexport interface UseKeyboardPopupOptions extends PopupPositionConfig {\r\n visible?: Ref<boolean>\r\n target?: Ref<HTMLElement | null>\r\n popup?: Ref<HTMLElement | null>\r\n closeOnClickOutside?: boolean\r\n onClose?: () => void\r\n}\r\n\r\nexport interface UseKeyboardPopupReturn {\r\n popupStyles: Ref<CSSProperties>\r\n maskStyles: Ref<CSSProperties>\r\n placement: Ref<PopupPlacement>\r\n isMobileDevice: Ref<boolean>\r\n showMask: Ref<boolean>\r\n isAnimating: Ref<boolean>\r\n updatePosition: () => void\r\n close: () => void\r\n}\r\n\r\nexport function useKeyboardPopup(\r\n options: UseKeyboardPopupOptions = {}\r\n): UseKeyboardPopupReturn {\r\n const {\r\n visible = ref(false),\r\n target = ref(null),\r\n popup = ref(null),\r\n closeOnClickOutside = true,\r\n onClose,\r\n ...positionConfig\r\n } = options\r\n\r\n const positionManager = createPositionManager(positionConfig)\r\n const popupStyles = ref<CSSProperties>({})\r\n const maskStyles = ref<CSSProperties>({})\r\n const placement = ref<PopupPlacement>('bottom')\r\n const isMobileDevice = ref(isMobile())\r\n const showMask = ref(false)\r\n const isAnimating = ref(false)\r\n\r\n let cleanupClickOutside: (() => void) | null = null\r\n let cleanupViewportChange: (() => void) | null = null\r\n let cleanupScroll: (() => void) | null = null\r\n let animationFrame: number | null = null\r\n let visibilitySession = 0\r\n\r\n const cleanupOpenResources = () => {\r\n cleanupClickOutside?.()\r\n cleanupClickOutside = null\r\n cleanupViewportChange?.()\r\n cleanupViewportChange = null\r\n cleanupScroll?.()\r\n cleanupScroll = null\r\n }\r\n\r\n const cancelAnimationFrame = () => {\r\n if (animationFrame === null || typeof window === 'undefined') return\r\n window.cancelAnimationFrame(animationFrame)\r\n animationFrame = null\r\n }\r\n\r\n const updatePosition = () => {\r\n const popupElement = popup.value\r\n if (!popupElement) return\r\n\r\n const popupRect = popupElement.getBoundingClientRect()\r\n const result = positionManager.calculate(target.value, {\r\n width: Math.max(0, popupRect.width),\r\n height: Math.max(0, popupRect.height),\r\n })\r\n\r\n placement.value = result.placement\r\n showMask.value = positionManager.shouldShowMask()\r\n\r\n if (result.placement === 'bottom-sheet') {\r\n popupStyles.value = {\r\n position: 'fixed',\r\n left: '0',\r\n right: '0',\r\n bottom: '0',\r\n maxHeight:\r\n result.maxHeight === undefined ? undefined : `${result.maxHeight}px`,\r\n zIndex: 1000,\r\n }\r\n } else {\r\n popupStyles.value = {\r\n position: 'fixed',\r\n left: `${result.position.x}px`,\r\n top: `${result.position.y}px`,\r\n maxHeight:\r\n result.maxHeight === undefined ? undefined : `${result.maxHeight}px`,\r\n maxWidth:\r\n result.maxWidth === undefined ? undefined : `${result.maxWidth}px`,\r\n zIndex: 1000,\r\n }\r\n }\r\n\r\n maskStyles.value = showMask.value\r\n ? {\r\n position: 'fixed',\r\n inset: '0',\r\n backgroundColor: 'var(--keyboard-mask-bg)',\r\n zIndex: 999,\r\n }\r\n : {}\r\n }\r\n\r\n const close = () => {\r\n if (visible.value) onClose?.()\r\n }\r\n\r\n watch(\r\n visible,\r\n newVisible => {\r\n visibilitySession += 1\r\n const currentSession = visibilitySession\r\n cancelAnimationFrame()\r\n cleanupOpenResources()\r\n\r\n if (!newVisible) {\r\n isAnimating.value = false\r\n showMask.value = false\r\n popupStyles.value = {}\r\n maskStyles.value = {}\r\n return\r\n }\r\n\r\n isMobileDevice.value = isMobile()\r\n isAnimating.value = true\r\n\r\n if (typeof window !== 'undefined') {\r\n animationFrame = window.requestAnimationFrame(() => {\r\n animationFrame = null\r\n if (!visible.value || currentSession !== visibilitySession) return\r\n\r\n updatePosition()\r\n isAnimating.value = false\r\n if (closeOnClickOutside && popup.value) {\r\n cleanupClickOutside = onClickOutside(popup.value, event => {\r\n if (\r\n target.value &&\r\n event.target instanceof Node &&\r\n target.value.contains(event.target)\r\n )\r\n return\r\n close()\r\n })\r\n }\r\n })\r\n }\r\n\r\n cleanupViewportChange = onViewportChange(() => {\r\n if (!visible.value) return\r\n isMobileDevice.value = isMobile()\r\n updatePosition()\r\n })\r\n\r\n if (!isMobileDevice.value && typeof window !== 'undefined') {\r\n const handleScroll = () => {\r\n if (!visible.value) return\r\n window.requestAnimationFrame(updatePosition)\r\n }\r\n window.addEventListener('scroll', handleScroll, true)\r\n cleanupScroll = () =>\r\n window.removeEventListener('scroll', handleScroll, true)\r\n }\r\n },\r\n { immediate: true }\r\n )\r\n\r\n watch(target, () => {\r\n if (visible.value) updatePosition()\r\n })\r\n\r\n onBeforeUnmount(() => {\r\n visibilitySession += 1\r\n cancelAnimationFrame()\r\n cleanupOpenResources()\r\n })\r\n\r\n return {\r\n popupStyles,\r\n maskStyles,\r\n placement,\r\n isMobileDevice,\r\n showMask,\r\n isAnimating,\r\n updatePosition,\r\n close,\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAqCO,SAAS,iBACd,UAAmC,CAAC,GACZ;CACxB,MAAM,EACJ,UAAU,IAAI,KAAK,GACnB,SAAS,IAAI,IAAI,GACjB,QAAQ,IAAI,IAAI,GAChB,sBAAsB,MACtB,SACA,GAAG,mBACD;CAEJ,MAAM,kBAAkB,sBAAsB,cAAc;CAC5D,MAAM,cAAc,IAAmB,CAAC,CAAC;CACzC,MAAM,aAAa,IAAmB,CAAC,CAAC;CACxC,MAAM,YAAY,IAAoB,QAAQ;CAC9C,MAAM,iBAAiB,IAAI,SAAS,CAAC;CACrC,MAAM,WAAW,IAAI,KAAK;CAC1B,MAAM,cAAc,IAAI,KAAK;CAE7B,IAAI,sBAA2C;CAC/C,IAAI,wBAA6C;CACjD,IAAI,gBAAqC;CACzC,IAAI,iBAAgC;CACpC,IAAI,oBAAoB;CAExB,MAAM,6BAA6B;EACjC,sBAAsB;EACtB,sBAAsB;EACtB,wBAAwB;EACxB,wBAAwB;EACxB,gBAAgB;EAChB,gBAAgB;C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,SAAS;EAChC,YAAY,QAAQ;EAEpB,IAAI,OAAO,WAAW,aACpB,iBAAiB,OAAO,4BAA4B;GAClD,iBAAiB;GACjB,IAAI,CAAC,QAAQ,SAAS,mBAAmB,mBAAmB;GAE5D,eAAe;GACf,YAAY,QAAQ;GACpB,IAAI,uBAAuB,MAAM,OAC/B,sBAAsB,eAAe,MAAM,QAAO,UAAS;IACzD,IACE,OAAO,SACP,MAAM,kBAAkB,QACxB,OAAO,MAAM,SAAS,MAAM,MAAM,GAElC;IACF,MAAM;GACR,CAAC;EAEL,CAAC;EAGH,wBAAwB,uBAAuB;GAC7C,IAAI,CAAC,QAAQ,OAAO;GACpB,eAAe,QAAQ,SAAS;GAChC,eAAe;EACjB,CAAC;EAED,IAAI,CAAC,eAAe,SAAS,OAAO,WAAW,aAAa;GAC1D,MAAM,qBAAqB;IACzB,IAAI,CAAC,QAAQ,OAAO;IACpB,OAAO,sBAAsB,cAAc;GAC7C;GACA,OAAO,iBAAiB,UAAU,cAAc,IAAI;GACpD,sBACE,OAAO,oBAAoB,UAAU,cAAc,IAAI;EAC3D;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAEA,MAAM,cAAc;EAClB,IAAI,QAAQ,OAAO,eAAe;CACpC,CAAC;CAED,sBAAsB;EACpB,qBAAqB;EACrB,qBAAqB;EACrB,qBAAqB;CACvB,CAAC;CAED,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/directives/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,cAAc,CAAA"}
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * ***********************************
3
+ * @composy/keyboard-vue v0.0.1 *
4
+ * Built with rollup *
5
+ * Build time: 2024-10-12 17:44:15 *
6
+ * Build mode: production *
7
+ * Minified: No *
8
+ * ***********************************
9
+ */
10
+ import { vKeyboard } from "./v-keyboard.js";
11
+ export { vKeyboard };
12
+ /*! End of @composy/keyboard-vue | Powered by @composy/builder */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v-keyboard.d.ts","sourceRoot":"","sources":["../../src/directives/v-keyboard.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,KAAK,CAAA;AAEtD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW;IACX,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,aAAa;IACb,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,gBAAgB,GAAG,mBAAmB,KAAK,IAAI,CAAA;IAC7D,aAAa;IACb,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAQD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,CAC/B,gBAAgB,GAAG,mBAAmB,EACtC,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAmDpC,CAAA"}
@@ -0,0 +1,64 @@
1
+ /*!
2
+ * ***********************************
3
+ * @composy/keyboard-vue v0.0.1 *
4
+ * Built with rollup *
5
+ * Build time: 2024-10-12 17:44:15 *
6
+ * Build mode: production *
7
+ * Minified: No *
8
+ * ***********************************
9
+ */
10
+ //#region src/directives/v-keyboard.ts
11
+ const directiveStates = /* @__PURE__ */ new WeakMap();
12
+ const vKeyboard = {
13
+ mounted(el, binding) {
14
+ const options = parseBinding(binding);
15
+ if (!options.enabled) return;
16
+ const handleFocus = () => {
17
+ el.blur();
18
+ options.onOpen?.(el);
19
+ };
20
+ el.addEventListener("focus", handleFocus);
21
+ el.setAttribute("inputmode", "none");
22
+ directiveStates.set(el, { cleanup: () => {
23
+ el.removeEventListener("focus", handleFocus);
24
+ el.removeAttribute("inputmode");
25
+ } });
26
+ },
27
+ updated(el, binding) {
28
+ directiveStates.get(el)?.cleanup();
29
+ directiveStates.delete(el);
30
+ const options = parseBinding(binding);
31
+ if (!options.enabled) return;
32
+ const handleFocus = () => {
33
+ el.blur();
34
+ options.onOpen?.(el);
35
+ };
36
+ el.addEventListener("focus", handleFocus);
37
+ el.setAttribute("inputmode", "none");
38
+ directiveStates.set(el, { cleanup: () => {
39
+ el.removeEventListener("focus", handleFocus);
40
+ el.removeAttribute("inputmode");
41
+ } });
42
+ },
43
+ unmounted(el) {
44
+ directiveStates.get(el)?.cleanup();
45
+ directiveStates.delete(el);
46
+ }
47
+ };
48
+ function parseBinding(binding) {
49
+ const value = binding.value;
50
+ if (value === false) return { enabled: false };
51
+ if (value === true || value === void 0) return { enabled: true };
52
+ if (typeof value === "string") return {
53
+ enabled: true,
54
+ type: value
55
+ };
56
+ return {
57
+ enabled: value.enabled !== false,
58
+ ...value
59
+ };
60
+ }
61
+ //#endregion
62
+ export { vKeyboard };
63
+ /*! End of @composy/keyboard-vue | Powered by @composy/builder */
64
+ //# sourceMappingURL=v-keyboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v-keyboard.js","names":[],"sources":["../../src/directives/v-keyboard.ts"],"sourcesContent":["/**\r\n * v-keyboard 指令\r\n * 自动在输入框聚焦时打开虚拟键盘\r\n * @module directives/v-keyboard\r\n */\r\n\r\nimport type { Directive, DirectiveBinding } from 'vue'\r\n\r\n/**\r\n * 指令绑定值\r\n */\r\nexport interface VKeyboardBinding {\r\n /** 键盘类型 */\r\n type?: string\r\n /** 是否启用 */\r\n enabled?: boolean\r\n /** 打开键盘回调 */\r\n onOpen?: (el: HTMLInputElement | HTMLTextAreaElement) => void\r\n /** 关闭键盘回调 */\r\n onClose?: () => void\r\n}\r\n\r\ninterface KeyboardDirectiveState {\r\n cleanup: () => void\r\n}\r\n\r\nconst directiveStates = new WeakMap<HTMLElement, KeyboardDirectiveState>()\r\n\r\n/**\r\n * v-keyboard 指令\r\n *\r\n * @example\r\n * ```html\r\n * <!-- 基础用法 -->\r\n * <input v-keyboard />\r\n *\r\n * <!-- 指定键盘类型 -->\r\n * <input v-keyboard=\"{ type: 'number' }\" />\r\n *\r\n * <!-- 配合回调 -->\r\n * <input v-keyboard=\"{ type: 'phone', onOpen: handleOpen }\" />\r\n * ```\r\n */\r\nexport const vKeyboard: Directive<\r\n HTMLInputElement | HTMLTextAreaElement,\r\n VKeyboardBinding | string | boolean\r\n> = {\r\n mounted(el, binding) {\r\n const options = parseBinding(binding)\r\n if (!options.enabled) return\r\n\r\n const handleFocus = () => {\r\n // 阻止原生键盘\r\n el.blur()\r\n options.onOpen?.(el)\r\n }\r\n\r\n el.addEventListener('focus', handleFocus)\r\n el.setAttribute('inputmode', 'none')\r\n\r\n // 存储清理函数\r\n directiveStates.set(el, {\r\n cleanup: () => {\r\n el.removeEventListener('focus', handleFocus)\r\n el.removeAttribute('inputmode')\r\n },\r\n })\r\n },\r\n\r\n updated(el, binding) {\r\n directiveStates.get(el)?.cleanup()\r\n directiveStates.delete(el)\r\n\r\n const options = parseBinding(binding)\r\n if (!options.enabled) return\r\n\r\n const handleFocus = () => {\r\n el.blur()\r\n options.onOpen?.(el)\r\n }\r\n\r\n el.addEventListener('focus', handleFocus)\r\n el.setAttribute('inputmode', 'none')\r\n\r\n directiveStates.set(el, {\r\n cleanup: () => {\r\n el.removeEventListener('focus', handleFocus)\r\n el.removeAttribute('inputmode')\r\n },\r\n })\r\n },\r\n\r\n unmounted(el) {\r\n directiveStates.get(el)?.cleanup()\r\n directiveStates.delete(el)\r\n },\r\n}\r\n\r\n/**\r\n * 解析指令绑定值\r\n */\r\nfunction parseBinding(\r\n binding: DirectiveBinding<VKeyboardBinding | string | boolean>\r\n): VKeyboardBinding & { enabled: boolean } {\r\n const value = binding.value\r\n\r\n if (value === false) {\r\n return { enabled: false }\r\n }\r\n\r\n if (value === true || value === undefined) {\r\n return { enabled: true }\r\n }\r\n\r\n if (typeof value === 'string') {\r\n return { enabled: true, type: value }\r\n }\r\n\r\n return {\r\n enabled: value.enabled !== false,\r\n ...value,\r\n }\r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}
package/esm/index.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @composy/keyboard-vue
3
+ * LDesign 虚拟键盘 - Vue 3 适配器
4
+ * @packageDocumentation
5
+ */
6
+ import type { Plugin } from 'vue';
7
+ export * from './components';
8
+ export * from './composables';
9
+ export * from './directives';
10
+ export * from './plugins';
11
+ export { amountLayout, amountSimpleLayout, applyFormatter, applyTheme, bankcardLayout, createKeyboardManager, createKeyboardRenderer, createPositionManager, createRandomLetterLayout, createRandomMixedLayout, createRandomNumberLayout, createRandomPinLayout, createTheme, darkTheme, defaultTheme, deleteCharBeforeCursor, EMAIL_SUFFIXES, emailLayout, EventEmitter, formatAmount, formatBankCard, formatIdCard, formatLicensePlate, formatPhone, formatVerifyCode, generateThemeStyle, getAllThemes, getAvailableLayouts, getAvailableThemes, getBoundingRect, getCurrentTheme, getDeviceType, getFormatter, getLayout, getRandomAlphanumeric, getRandomLetters, getRandomNumbers, getTheme, getViewportInfo, hasLayout, idcardLayout, insertTextAtCursor, integerLayout, iosTheme, isMobile, isTouchDevice, KeyboardManager, KeyboardRenderer, licensePlateAlphanumericLayout, licensePlateLayout, licensePlateLetterLayout, licensePlateProvinceLayout, materialTheme, mergeTheme, minimalTheme, miuiTheme, numberLayout, onClickOutside, onViewportChange, phoneLayout, phoneSimpleLayout, PLATE_LETTERS, PositionManager, presetThemes, PROVINCES, punctLayout, qwertyLayout, refreshRandomLayout, registerFormatter, registerLayout, registerLayouts, registerTheme, searchLayout, setCurrentTheme, shuffleArray, symbolLayout, symbolLayout2, themeToCSS, unregisterLayout, urlLayout, verifycodeLayout, vibrate, } from '@composy/keyboard-core';
12
+ export type { BoundingRect, DeviceType, FormatterFunction, KeyboardConfig, KeyboardEventMap, KeyboardOptions, KeyboardRendererOptions, KeyboardRow, KeyboardState, KeyboardType, KeyDefinition, KeyType, PopupPlacement, PopupPositionConfig, PopupPositionResult, Position, Size, ThemeColors, ThemeConfig, ThemeCSSVariables, ThemeEffects, ThemeName, ThemeSizes, ViewportInfo, } from '@composy/keyboard-core';
13
+ /**
14
+ * 键盘插件配置
15
+ */
16
+ export interface KeyboardPluginOptions {
17
+ /**
18
+ * 组件前缀
19
+ * @default 'L'
20
+ */
21
+ prefix?: string;
22
+ }
23
+ /**
24
+ * 原生 Vue 项目键盘插件
25
+ * 用于全局注册键盘组件和指令
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * import { createApp } from 'vue'
30
+ * import { KeyboardVuePlugin } from '@composy/keyboard-vue'
31
+ *
32
+ * const app = createApp(App)
33
+ * app.use(KeyboardVuePlugin, { prefix: 'L' })
34
+ * ```
35
+ */
36
+ export declare const KeyboardVuePlugin: Plugin;
37
+ /**
38
+ * @deprecated 使用 KeyboardVuePlugin 代替
39
+ */
40
+ export declare const KeyboardPlugin: import("vue").ObjectPlugin<any[]>;
41
+ export default KeyboardVuePlugin;
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAO,MAAM,EAAE,MAAM,KAAK,CAAA;AAStC,cAAc,cAAc,CAAA;AAG5B,cAAc,eAAe,CAAA;AAG7B,cAAc,cAAc,CAAA;AAG5B,cAAc,WAAW,CAAA;AAGzB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,cAAc,EAEd,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,cAAc,EACd,WAAW,EAEX,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,kBAAkB,EAElB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,eAAe,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.js ADDED
@@ -0,0 +1,34 @@
1
+ /*!
2
+ * ***********************************
3
+ * @composy/keyboard-vue v0.0.1 *
4
+ * Built with rollup *
5
+ * Build time: 2024-10-12 17:44:15 *
6
+ * Build mode: production *
7
+ * Minified: No *
8
+ * ***********************************
9
+ */
10
+ import KeyboardKey_default from "./components/KeyboardKey.js";
11
+ import { useKeyboard } from "./composables/useKeyboard.js";
12
+ import { useKeyboardPopup } from "./composables/useKeyboardPopup.js";
13
+ import VirtualKeyboard_default from "./components/VirtualKeyboard.js";
14
+ import KeyboardPopup_default from "./components/KeyboardPopup.js";
15
+ import LicensePlateKeyboard_default from "./components/LicensePlateKeyboard.js";
16
+ import "./components/index.js";
17
+ import { vKeyboard } from "./directives/v-keyboard.js";
18
+ import "./composables/index.js";
19
+ import { KeyboardEnginePlugin } from "./plugins/engine-plugin.js";
20
+ import "./plugins/index.js";
21
+ import { EMAIL_SUFFIXES, EventEmitter, KeyboardManager, KeyboardRenderer, PLATE_LETTERS, PROVINCES, PositionManager, amountLayout, amountSimpleLayout, applyFormatter, applyTheme, bankcardLayout, createKeyboardManager, createKeyboardRenderer, createPositionManager, createRandomLetterLayout, createRandomMixedLayout, createRandomNumberLayout, createRandomPinLayout, createTheme, darkTheme, defaultTheme, deleteCharBeforeCursor, emailLayout, formatAmount, formatBankCard, formatIdCard, formatLicensePlate, formatPhone, formatVerifyCode, generateThemeStyle, getAllThemes, getAvailableLayouts, getAvailableThemes, getBoundingRect, getCurrentTheme, getDeviceType, getFormatter, getLayout, getRandomAlphanumeric, getRandomLetters, getRandomNumbers, getTheme, getViewportInfo, hasLayout, idcardLayout, insertTextAtCursor, integerLayout, iosTheme, isMobile, isTouchDevice, licensePlateAlphanumericLayout, licensePlateLayout, licensePlateLetterLayout, licensePlateProvinceLayout, materialTheme, mergeTheme, minimalTheme, miuiTheme, numberLayout, onClickOutside, onViewportChange, phoneLayout, phoneSimpleLayout, presetThemes, punctLayout, qwertyLayout, refreshRandomLayout, registerFormatter, registerLayout, registerLayouts, registerTheme, searchLayout, setCurrentTheme, shuffleArray, symbolLayout, symbolLayout2, themeToCSS, unregisterLayout, urlLayout, verifycodeLayout, vibrate } from "@composy/keyboard-core";
22
+ //#region src/index.ts
23
+ const KeyboardVuePlugin = { install(app, options = {}) {
24
+ const prefix = options.prefix ?? "L";
25
+ app.component(`${prefix}Keyboard`, VirtualKeyboard_default);
26
+ app.component(`${prefix}KeyboardPopup`, KeyboardPopup_default);
27
+ app.component(`${prefix}LicensePlateKeyboard`, LicensePlateKeyboard_default);
28
+ app.directive("keyboard", vKeyboard);
29
+ } };
30
+ const KeyboardPlugin = KeyboardVuePlugin;
31
+ //#endregion
32
+ export { EMAIL_SUFFIXES, EventEmitter, KeyboardEnginePlugin, KeyboardKey_default as KeyboardKey, KeyboardManager, KeyboardPlugin, KeyboardPopup_default as KeyboardPopup, KeyboardRenderer, KeyboardVuePlugin, KeyboardVuePlugin as default, LicensePlateKeyboard_default as LicensePlateKeyboard, PLATE_LETTERS, PROVINCES, PositionManager, VirtualKeyboard_default as VirtualKeyboard, amountLayout, amountSimpleLayout, applyFormatter, applyTheme, bankcardLayout, createKeyboardManager, createKeyboardRenderer, createPositionManager, createRandomLetterLayout, createRandomMixedLayout, createRandomNumberLayout, createRandomPinLayout, createTheme, darkTheme, defaultTheme, deleteCharBeforeCursor, emailLayout, formatAmount, formatBankCard, formatIdCard, formatLicensePlate, formatPhone, formatVerifyCode, generateThemeStyle, getAllThemes, getAvailableLayouts, getAvailableThemes, getBoundingRect, getCurrentTheme, getDeviceType, getFormatter, getLayout, getRandomAlphanumeric, getRandomLetters, getRandomNumbers, getTheme, getViewportInfo, hasLayout, idcardLayout, insertTextAtCursor, integerLayout, iosTheme, isMobile, isTouchDevice, licensePlateAlphanumericLayout, licensePlateLayout, licensePlateLetterLayout, licensePlateProvinceLayout, materialTheme, mergeTheme, minimalTheme, miuiTheme, numberLayout, onClickOutside, onViewportChange, phoneLayout, phoneSimpleLayout, presetThemes, punctLayout, qwertyLayout, refreshRandomLayout, registerFormatter, registerLayout, registerLayouts, registerTheme, searchLayout, setCurrentTheme, shuffleArray, symbolLayout, symbolLayout2, themeToCSS, unregisterLayout, urlLayout, useKeyboard, useKeyboardPopup, vKeyboard, verifycodeLayout, vibrate };
33
+ /*! End of @composy/keyboard-vue | Powered by @composy/builder */
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\r\n * @composy/keyboard-vue\r\n * LDesign 虚拟键盘 - Vue 3 适配器\r\n * @packageDocumentation\r\n */\r\n\r\nimport type { App, Plugin } from 'vue'\r\nimport {\r\n KeyboardPopup,\r\n LicensePlateKeyboard,\r\n VirtualKeyboard,\r\n} from './components'\r\nimport { vKeyboard } from './directives/v-keyboard'\r\n\r\n// 导出组件\r\nexport * from './components'\r\n\r\n// 导出 Composables\r\nexport * from './composables'\r\n\r\n// 导出指令\r\nexport * from './directives'\r\n\r\n// 导出插件\r\nexport * from './plugins'\r\n\r\n// 从核心包重新导出\r\nexport {\r\n amountLayout,\r\n amountSimpleLayout,\r\n applyFormatter,\r\n applyTheme,\r\n bankcardLayout,\r\n // 管理器\r\n createKeyboardManager,\r\n createKeyboardRenderer,\r\n createPositionManager,\r\n createRandomLetterLayout,\r\n createRandomMixedLayout,\r\n createRandomNumberLayout,\r\n createRandomPinLayout,\r\n createTheme,\r\n darkTheme,\r\n defaultTheme,\r\n deleteCharBeforeCursor,\r\n EMAIL_SUFFIXES,\r\n emailLayout,\r\n // 工具函数\r\n EventEmitter,\r\n formatAmount,\r\n formatBankCard,\r\n formatIdCard,\r\n formatLicensePlate,\r\n // 格式化工具\r\n formatPhone,\r\n formatVerifyCode,\r\n generateThemeStyle,\r\n getAllThemes,\r\n getAvailableLayouts,\r\n getAvailableThemes,\r\n getBoundingRect,\r\n getCurrentTheme,\r\n getDeviceType,\r\n getFormatter,\r\n // 布局\r\n getLayout,\r\n getRandomAlphanumeric,\r\n getRandomLetters,\r\n getRandomNumbers,\r\n // 主题系统\r\n getTheme,\r\n getViewportInfo,\r\n hasLayout,\r\n // 场景化键盘\r\n idcardLayout,\r\n insertTextAtCursor,\r\n integerLayout,\r\n iosTheme,\r\n isMobile,\r\n isTouchDevice,\r\n KeyboardManager,\r\n KeyboardRenderer,\r\n licensePlateAlphanumericLayout,\r\n licensePlateLayout,\r\n licensePlateLetterLayout,\r\n licensePlateProvinceLayout,\r\n materialTheme,\r\n mergeTheme,\r\n minimalTheme,\r\n miuiTheme,\r\n numberLayout,\r\n onClickOutside,\r\n onViewportChange,\r\n phoneLayout,\r\n phoneSimpleLayout,\r\n PLATE_LETTERS,\r\n PositionManager,\r\n presetThemes,\r\n PROVINCES,\r\n punctLayout,\r\n qwertyLayout,\r\n refreshRandomLayout,\r\n registerFormatter,\r\n registerLayout,\r\n registerLayouts,\r\n registerTheme,\r\n searchLayout,\r\n setCurrentTheme,\r\n // 随机键盘\r\n shuffleArray,\r\n symbolLayout,\r\n symbolLayout2,\r\n themeToCSS,\r\n unregisterLayout,\r\n urlLayout,\r\n verifycodeLayout,\r\n vibrate,\r\n} from '@composy/keyboard-core'\r\n\r\n// 导出类型\r\nexport type {\r\n BoundingRect,\r\n DeviceType,\r\n // 格式化类型\r\n FormatterFunction,\r\n KeyboardConfig,\r\n KeyboardEventMap,\r\n KeyboardOptions,\r\n // 渲染器类型\r\n KeyboardRendererOptions,\r\n KeyboardRow,\r\n KeyboardState,\r\n KeyboardType,\r\n KeyDefinition,\r\n KeyType,\r\n PopupPlacement,\r\n PopupPositionConfig,\r\n PopupPositionResult,\r\n Position,\r\n Size,\r\n ThemeColors,\r\n ThemeConfig,\r\n ThemeCSSVariables,\r\n ThemeEffects,\r\n // 主题类型\r\n ThemeName,\r\n ThemeSizes,\r\n ViewportInfo,\r\n} from '@composy/keyboard-core'\r\n\r\n/**\r\n * 键盘插件配置\r\n */\r\nexport interface KeyboardPluginOptions {\r\n /**\r\n * 组件前缀\r\n * @default 'L'\r\n */\r\n prefix?: string\r\n}\r\n\r\n/**\r\n * 原生 Vue 项目键盘插件\r\n * 用于全局注册键盘组件和指令\r\n *\r\n * @example\r\n * ```typescript\r\n * import { createApp } from 'vue'\r\n * import { KeyboardVuePlugin } from '@composy/keyboard-vue'\r\n *\r\n * const app = createApp(App)\r\n * app.use(KeyboardVuePlugin, { prefix: 'L' })\r\n * ```\r\n */\r\nexport const KeyboardVuePlugin: Plugin = {\r\n install(app: App, options: KeyboardPluginOptions = {}) {\r\n const prefix = options.prefix ?? 'L'\r\n\r\n // 注册组件\r\n app.component(`${prefix}Keyboard`, VirtualKeyboard)\r\n app.component(`${prefix}KeyboardPopup`, KeyboardPopup)\r\n app.component(`${prefix}LicensePlateKeyboard`, LicensePlateKeyboard)\r\n\r\n // 注册指令\r\n app.directive('keyboard', vKeyboard)\r\n },\r\n}\r\n\r\n/**\r\n * @deprecated 使用 KeyboardVuePlugin 代替\r\n */\r\nexport const KeyboardPlugin = KeyboardVuePlugin\r\n\r\n// 默认导出插件\r\nexport default KeyboardVuePlugin\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8KO,MAAM,oBAA4B,EACvC,QAAQ,KAAU,UAAiC,CAAC,GAAG;CACrD,MAAM,SAAS,QAAQ,UAAU;CAGjC,IAAI,UAAU,GAAG,OAAM,WAAY,uBAAe;CAClD,IAAI,UAAU,GAAG,OAAM,gBAAiB,qBAAa;CACrD,IAAI,UAAU,GAAG,OAAM,uBAAwB,4BAAoB;CAGnE,IAAI,UAAU,YAAY,SAAS;AACrC,EACF;AAKO,MAAM,iBAAiB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/engine-plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiDH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB;;;qBAIR,OAAO,YAAY,2BAA2B;CAyBtE,CAAA"}
@@ -0,0 +1,53 @@
1
+ /*!
2
+ * ***********************************
3
+ * @composy/keyboard-vue v0.0.1 *
4
+ * Built with rollup *
5
+ * Build time: 2024-10-12 17:44:15 *
6
+ * Build mode: production *
7
+ * Minified: No *
8
+ * ***********************************
9
+ */
10
+ import VirtualKeyboard_default from "../components/VirtualKeyboard.js";
11
+ import KeyboardPopup_default from "../components/KeyboardPopup.js";
12
+ import LicensePlateKeyboard_default from "../components/LicensePlateKeyboard.js";
13
+ import "../components/index.js";
14
+ import { vKeyboard } from "../directives/v-keyboard.js";
15
+ //#region src/plugins/engine-plugin.ts
16
+ function isRecord(value) {
17
+ return typeof value === "object" && value !== null;
18
+ }
19
+ function isVueApp(value) {
20
+ return isRecord(value) && typeof value.component === "function" && typeof value.directive === "function";
21
+ }
22
+ function getEngineContext(value) {
23
+ if (!isRecord(value)) return {};
24
+ const framework = isRecord(value.framework) ? value.framework : void 0;
25
+ const container = isRecord(value.container) ? value.container : void 0;
26
+ return {
27
+ framework: isVueApp(framework?.app) ? { app: framework.app } : void 0,
28
+ container: typeof container?.singleton === "function" ? { singleton: container.singleton } : void 0
29
+ };
30
+ }
31
+ const KeyboardEnginePlugin = {
32
+ name: "keyboard",
33
+ version: "0.1.0",
34
+ async install(context, options) {
35
+ const prefix = options?.prefix ?? "L";
36
+ const engineContext = getEngineContext(context);
37
+ const app = engineContext.framework?.app;
38
+ if (app) {
39
+ app.component(`${prefix}Keyboard`, VirtualKeyboard_default);
40
+ app.component(`${prefix}KeyboardPopup`, KeyboardPopup_default);
41
+ app.component(`${prefix}LicensePlateKeyboard`, LicensePlateKeyboard_default);
42
+ app.directive("keyboard", vKeyboard);
43
+ }
44
+ if (engineContext.container?.singleton) engineContext.container.singleton("keyboard", {
45
+ name: "keyboard",
46
+ version: "0.1.0"
47
+ });
48
+ }
49
+ };
50
+ //#endregion
51
+ export { KeyboardEnginePlugin };
52
+ /*! End of @composy/keyboard-vue | Powered by @composy/builder */
53
+ //# sourceMappingURL=engine-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-plugin.js","names":[],"sources":["../../src/plugins/engine-plugin.ts"],"sourcesContent":["/**\r\n * 键盘 Engine 插件\r\n * 适配 @composy/engine-vue 的插件\r\n * @module plugins/engine-plugin\r\n */\r\n\r\nimport type { App } from 'vue'\r\nimport {\r\n KeyboardPopup,\r\n LicensePlateKeyboard,\r\n VirtualKeyboard,\r\n} from '../components'\r\nimport { vKeyboard } from '../directives/v-keyboard'\r\n\r\ninterface KeyboardEngineContext {\r\n framework?: {\r\n app?: App\r\n }\r\n container?: {\r\n singleton?: (name: string, value: { name: string; version: string }) => void\r\n }\r\n}\r\n\r\nfunction isRecord(value: unknown): value is Record<string, unknown> {\r\n return typeof value === 'object' && value !== null\r\n}\r\n\r\nfunction isVueApp(value: unknown): value is App {\r\n return (\r\n isRecord(value) &&\r\n typeof value.component === 'function' &&\r\n typeof value.directive === 'function'\r\n )\r\n}\r\n\r\nfunction getEngineContext(value: unknown): KeyboardEngineContext {\r\n if (!isRecord(value)) return {}\r\n\r\n const framework = isRecord(value.framework) ? value.framework : undefined\r\n const container = isRecord(value.container) ? value.container : undefined\r\n\r\n return {\r\n framework: isVueApp(framework?.app) ? { app: framework.app } : undefined,\r\n container:\r\n typeof container?.singleton === 'function'\r\n ? {\r\n singleton:\r\n container.singleton as KeyboardEngineContext['container']['singleton'],\r\n }\r\n : undefined,\r\n }\r\n}\r\n\r\n/**\r\n * Engine 插件接口(兼容 @composy/engine-core Plugin)\r\n */\r\nexport interface KeyboardEnginePluginOptions {\r\n /**\r\n * 组件前缀\r\n * @default 'L'\r\n */\r\n prefix?: string\r\n}\r\n\r\n/**\r\n * 键盘 Engine 插件\r\n *\r\n * 符合 @composy/engine-core Plugin 接口规范\r\n * 通过 engine.use(KeyboardEnginePlugin) 安装\r\n *\r\n * @example\r\n * ```typescript\r\n * import { createVueEngine } from '@composy/engine-vue'\r\n * import { KeyboardEnginePlugin } from '@composy/keyboard-vue'\r\n *\r\n * const engine = createVueEngine({\r\n * plugins: [KeyboardEnginePlugin],\r\n * })\r\n * ```\r\n */\r\nexport const KeyboardEnginePlugin = {\r\n name: 'keyboard',\r\n version: '0.1.0',\r\n\r\n async install(context: unknown, options?: KeyboardEnginePluginOptions) {\r\n const prefix = options?.prefix ?? 'L'\r\n const engineContext = getEngineContext(context)\r\n\r\n // 获取 Vue 应用实例(从 engine 上下文)\r\n const app = engineContext.framework?.app\r\n\r\n if (app) {\r\n // 注册全局组件\r\n app.component(`${prefix}Keyboard`, VirtualKeyboard)\r\n app.component(`${prefix}KeyboardPopup`, KeyboardPopup)\r\n app.component(`${prefix}LicensePlateKeyboard`, LicensePlateKeyboard)\r\n\r\n // 注册指令\r\n app.directive('keyboard', vKeyboard)\r\n }\r\n\r\n // 注册到服务容器(如果有)\r\n if (engineContext.container?.singleton) {\r\n engineContext.container.singleton('keyboard', {\r\n name: 'keyboard',\r\n version: '0.1.0',\r\n })\r\n }\r\n },\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU;AAChD;AAEA,SAAS,SAAS,OAA8B;CAC9C,OACE,SAAS,KAAK,KACd,OAAO,MAAM,cAAc,cAC3B,OAAO,MAAM,cAAc;AAE/B;AAEA,SAAS,iBAAiB,OAAuC;CAC/D,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO,CAAC;CAE9B,MAAM,YAAY,SAAS,MAAM,SAAS,IAAI,MAAM,YAAY,KAAA;CAChE,MAAM,YAAY,SAAS,MAAM,SAAS,IAAI,MAAM,YAAY,KAAA;CAEhE,OAAO;EACL,WAAW,SAAS,WAAW,GAAG,IAAI,EAAE,KAAK,UAAU,IAAI,IAAI,KAAA;EAC/D,WACE,OAAO,WAAW,cAAc,aAC5B,EACE,WACE,UAAU,UACd,IACA,KAAA;CACR;AACF;AA6BO,MAAM,uBAAuB;CAClC,MAAM;CACN,SAAS;CAET,MAAM,QAAQ,SAAkB,SAAuC;EACrE,MAAM,SAAS,SAAS,UAAU;EAClC,MAAM,gBAAgB,iBAAiB,OAAO;EAG9C,MAAM,MAAM,cAAc,WAAW;EAErC,IAAI,KAAK;GAEP,IAAI,UAAU,GAAG,OAAM,WAAY,uBAAe;GAClD,IAAI,UAAU,GAAG,OAAM,gBAAiB,qBAAa;GACrD,IAAI,UAAU,GAAG,OAAM,uBAAwB,4BAAoB;GAGnE,IAAI,UAAU,YAAY,SAAS;EACrC;EAGA,IAAI,cAAc,WAAW,WAC3B,cAAc,UAAU,UAAU,YAAY;GAC5C,MAAM;GACN,SAAS;EACX,CAAC;CAEL;AACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * ***********************************
3
+ * @composy/keyboard-vue v0.0.1 *
4
+ * Built with rollup *
5
+ * Build time: 2024-10-12 17:44:15 *
6
+ * Build mode: production *
7
+ * Minified: No *
8
+ * ***********************************
9
+ */
10
+ import { KeyboardEnginePlugin } from "./engine-plugin.js";
11
+ export { KeyboardEnginePlugin };
12
+ /*! End of @composy/keyboard-vue | Powered by @composy/builder */
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -1 +1 @@
1
- // @ldesign styles
1
+ // @ldesign styles
@@ -0,0 +1,5 @@
1
+ /**
2
+ * LDesign Keyboard styles
3
+ */
4
+ @import "./keyboard.less";
5
+ @import "./themes.less";