sykj 0.1.5 → 0.1.7

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.
package/lib/common.ts CHANGED
@@ -3,34 +3,4 @@ import "./store";
3
3
  import "./focus";
4
4
 
5
5
  import SyKeyboard from "../packages/keyboard/index.ts"; // 引入封装好的组件
6
- import SyLoading from "../packages/loading/index.ts";
7
-
8
- // export { SyKeyboard as default };
9
- // export { SyLoading };
10
-
11
- // import Vue from "vue";
12
- // import Loading1 from "./Loading1.vue";
13
- // import Loading2 from "./Loading2.vue";
14
- // // 导入其他组件...
15
-
16
- const components = [
17
- ...SyLoading,
18
- SyKeyboard,
19
- // 其他组件...
20
- ];
21
-
22
- const install = function (Vue: { component: (arg0: any, arg1: any) => void }) {
23
- components.forEach((component) => {
24
- Vue.component(component.name, component);
25
- });
26
- };
27
-
28
- // Auto-install when vue is found (eg. in browser via <script> tag)
29
- if (typeof window !== "undefined" && window.Vue) {
30
- install(window.Vue);
31
- }
32
-
33
- export default {
34
- install,
35
- // 其他导出...
36
- };
6
+ export { SyKeyboard as default };
package/lib/focus.ts CHANGED
@@ -3,16 +3,18 @@
3
3
  const globalKey = window.$sy.key;
4
4
  // const keyStore = useKeyStore()
5
5
 
6
- let st = null;
6
+ let st: any = null;
7
+
7
8
  document.addEventListener("focusin", (event) => {
8
9
  const target = event.target as HTMLElement;
9
10
  if (target?.tagName === "INPUT" || target?.tagName === "TEXTAREA") {
10
- if (!isEditableFormComponent(event.target)) return;
11
+ if (!isEditableFormComponent(target)) return;
11
12
  clearTimeout(st);
12
13
  globalKey.open();
13
14
  globalKey.currentElement = event.target;
14
15
  }
15
16
  });
17
+
16
18
  document.addEventListener("focusout", (event) => {
17
19
  st = setTimeout(() => {
18
20
  globalKey.close();
@@ -26,15 +28,12 @@ document.addEventListener("focusout", (event) => {
26
28
  });
27
29
 
28
30
  // 是否展示输入法
29
- const isEditableFormComponent = (el: EventTarget): Boolean => {
30
- const notType = ["checkbox", "radio"];
31
-
32
- if (
33
- (el instanceof HTMLInputElement && el.readOnly) ||
34
- notType.includes(el.type)
35
- ) {
31
+ const isEditableFormComponent = (el: HTMLElement): boolean => {
32
+ const notType: Array<string> = ["checkbox", "radio"];
33
+ if (!(el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement))
34
+ return false; // 类型守卫
35
+ if (el.readOnly || notType.includes(el.type)) {
36
36
  return false;
37
- } else {
38
- return true;
39
37
  }
38
+ return true;
40
39
  };
package/lib/store.ts CHANGED
@@ -1,4 +1,4 @@
1
- window.globalThis.$sy = {
1
+ (window.globalThis as any).$sy = {
2
2
  key: {
3
3
  show_keyboard: false,
4
4
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sykj",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "rem adaptation🚀",
5
5
  "main": "lib/common.ts",
6
6
  "files": [