sykj 0.1.0 → 0.1.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.
- package/README.md +0 -13
- package/lib/{common.js → common.ts} +5 -5
- package/lib/focus.ts +35 -0
- package/package.json +1 -1
- package/packages/keyboard/{index.js → index.ts} +2 -2
- package/packages/keyboard/src/Keyboardcon.vue +944 -987
- package/packages/loading/{index.js → index.ts} +2 -2
- package/types/global.d.ts +11 -0
- package/types/index.d.ts +4 -0
- package/lib/focus.js +0 -34
- /package/lib/{store.js → store.ts} +0 -0
package/README.md
CHANGED
|
@@ -41,19 +41,6 @@ app.mount("#app");
|
|
|
41
41
|
<SyKeyboard />
|
|
42
42
|
</div>
|
|
43
43
|
</template>
|
|
44
|
-
|
|
45
|
-
<script setup>
|
|
46
|
-
import SyKeyboard from "sykj";
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<style lang="scss" scoped>
|
|
50
|
-
.app {
|
|
51
|
-
height: 100vh;
|
|
52
|
-
display: flex;
|
|
53
|
-
justify-content: center;
|
|
54
|
-
align-items: center;
|
|
55
|
-
}
|
|
56
|
-
</style>
|
|
57
44
|
```
|
|
58
45
|
|
|
59
46
|
```vue
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "./store";
|
|
2
2
|
|
|
3
|
-
import "
|
|
3
|
+
import "./focus";
|
|
4
4
|
|
|
5
|
-
import SyKeyboard from "
|
|
6
|
-
import SyLoading from "
|
|
5
|
+
import SyKeyboard from "../packages/keyboard/index.ts"; // 引入封装好的组件
|
|
6
|
+
import SyLoading from "../packages/loading/index.ts";
|
|
7
7
|
|
|
8
8
|
// export { SyKeyboard as default };
|
|
9
9
|
// export { SyLoading };
|
|
@@ -19,7 +19,7 @@ const components = [
|
|
|
19
19
|
// 其他组件...
|
|
20
20
|
];
|
|
21
21
|
|
|
22
|
-
const install = function (Vue) {
|
|
22
|
+
const install = function (Vue: { component: (arg0: any, arg1: any) => void }) {
|
|
23
23
|
components.forEach((component) => {
|
|
24
24
|
Vue.component(component.name, component);
|
|
25
25
|
});
|
package/lib/focus.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// import { useKeyStore } from "./store";
|
|
2
|
+
// console.log("🚀 ~ file: focus.ts:3 ~ useKeyStore:", useKeyStore)
|
|
3
|
+
const globalKey = window.$sy.key;
|
|
4
|
+
// const keyStore = useKeyStore()
|
|
5
|
+
|
|
6
|
+
let st = null;
|
|
7
|
+
document.addEventListener("focusin", (event) => {
|
|
8
|
+
const target = event.target as HTMLElement;
|
|
9
|
+
if (target?.tagName === "INPUT" || target?.tagName === "TEXTAREA") {
|
|
10
|
+
if (!isEditableFormComponent(event.target)) return;
|
|
11
|
+
clearTimeout(st);
|
|
12
|
+
globalKey.open();
|
|
13
|
+
globalKey.currentElement = event.target;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
document.addEventListener("focusout", (event) => {
|
|
17
|
+
st = setTimeout(() => {
|
|
18
|
+
globalKey.close();
|
|
19
|
+
// globalKey.currentElement = null;
|
|
20
|
+
}, 100);
|
|
21
|
+
const target = event.target as HTMLElement;
|
|
22
|
+
if (target?.tagName === "INPUT" || target?.tagName === "TEXTAREA") {
|
|
23
|
+
// window.showKeyboard()
|
|
24
|
+
//
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// 是否展示输入法
|
|
29
|
+
const isEditableFormComponent = (el: EventTarget): Boolean => {
|
|
30
|
+
if (el instanceof HTMLInputElement && el.readOnly) {
|
|
31
|
+
return false;
|
|
32
|
+
} else {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
};
|
package/package.json
CHANGED