sykj 0.1.9 → 0.2.0

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 (34) hide show
  1. package/README.md +10 -10
  2. package/lib/common.ts +29 -12
  3. package/main/index.ts +1 -1
  4. package/main/utils/withInstall.ts +10 -0
  5. package/package.json +67 -54
  6. package/packages/button/index.ts +5 -0
  7. package/packages/button/src/index.vue +138 -0
  8. package/packages/dialog/index.ts +5 -0
  9. package/packages/dialog/src/index.vue +142 -0
  10. package/packages/keyboard/index.ts +11 -6
  11. package/packages/keyboard/src/Keyboardcon.vue +464 -401
  12. package/packages/keyboard/src/theme.scss +2 -2
  13. package/packages/keyboard/src/utils/focus.ts +34 -0
  14. package/packages/keyboard/src/utils/store.ts +19 -0
  15. package/packages/loading/index.ts +5 -12
  16. package/packages/loading/{Loading1.vue → src/Loading1.vue} +2 -2
  17. package/packages/loading/{Loading2.vue → src/Loading2.vue} +6 -6
  18. package/packages/loading/src/index.vue +38 -0
  19. package/packages/message/index.ts +128 -0
  20. package/packages/message/src/index.vue +177 -0
  21. package/packages/message-box/index.ts +59 -0
  22. package/packages/message-box/src/assets/error.png +0 -0
  23. package/packages/message-box/src/assets/error.svg +3 -0
  24. package/packages/message-box/src/assets/tip.png +0 -0
  25. package/packages/message-box/src/assets/tip.svg +3 -0
  26. package/packages/message-box/src/assets/warning.png +0 -0
  27. package/packages/message-box/src/assets/warning.svg +3 -0
  28. package/packages/message-box/src/index.vue +195 -0
  29. package/types/component.d.ts +9 -3
  30. package/types/global.d.ts +3 -3
  31. package/types/index.d.ts +1 -1
  32. package/lib/focus.ts +0 -36
  33. package/lib/store.ts +0 -5
  34. package/packages/loading/index.vue +0 -39
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  <h1 align="center" >SYKJ</h1>
2
2
 
3
- - 🤓 SY_UI
4
- - 💪 Vue 3 Composition API
5
- - 🔥 Written in TypeScript
3
+ - 🤓 SY_UI
4
+ - 💪 Vue 3 Composition API
5
+ - 🔥 Written in TypeScript
6
6
 
7
7
  ## 快速开始
8
8
 
@@ -23,14 +23,14 @@ $ pnpm install sykj
23
23
 
24
24
  ```typescript
25
25
  // main.ts
26
- import { createApp } from "vue";
27
- import sykj from "sykj";
28
- import App from "./App.vue";
26
+ import { createApp } from 'vue'
27
+ import sykj from 'sykj'
28
+ import App from './App.vue'
29
29
 
30
- const app = createApp(App);
30
+ const app = createApp(App)
31
31
 
32
- app.use(sykj);
33
- app.mount("#app");
32
+ app.use(sykj)
33
+ app.mount('#app')
34
34
  ```
35
35
 
36
36
  ```vue
@@ -38,7 +38,7 @@ app.mount("#app");
38
38
  <template>
39
39
  <div class="app">
40
40
  <input type="text" />
41
- <SyKeyboard />
41
+ <sy-keyboard />
42
42
  </div>
43
43
  </template>
44
44
  ```
package/lib/common.ts CHANGED
@@ -1,16 +1,33 @@
1
- import "./store";
2
- import "./focus";
1
+ // import './store'
2
+ // import './focus'
3
+ import type { App } from 'vue'
4
+ // 导入所有组件
5
+ import { SyKeyboard } from '../packages/keyboard'
6
+ import { SyLoading } from '../packages/loading'
7
+ import { SyMessage } from '../packages/message'
8
+ import { SyMessageBox } from '../packages/message-box'
9
+ import { SyDialog } from '../packages/dialog'
10
+ import { SyButton } from '../packages/button'
3
11
 
4
- import SyKeyboard from "../packages/keyboard/index.ts"; // 引入封装好的组件
5
- // import * as SyLoading from "../packages/loading/index.ts"; // 引入封装好的组件
6
- import { SyLoading } from "../packages/loading/index.ts"; // 一键导出所有组件
12
+ // 组件集合
13
+ const components = [SyKeyboard, SyLoading, SyMessage, SyDialog, SyButton]
7
14
 
8
- const a = () => {
9
- console.log(123);
10
- };
15
+ // 插件对象(提供 install 方法)
16
+ const sykJPlugin = {
17
+ install(app: App) {
18
+ components.forEach((component) => {
19
+ // 如果组件本身带 install(推荐),直接 app.use
20
+ if ((component as any).install) {
21
+ app.use(component as any)
22
+ } else if ((component as any).name) {
23
+ // 否则按组件注册
24
+ app.component((component as any).name, component as any)
25
+ }
26
+ })
27
+ }
28
+ }
11
29
 
12
- // 使用命名导出
13
- export { SyKeyboard as default };
14
- export { SyLoading };
30
+ export default sykJPlugin
15
31
 
16
- export { a };
32
+ // 也导出单个组件(按需导入)
33
+ export { SyKeyboard, SyLoading, SyMessage, SyMessageBox, SyDialog, SyButton }
package/main/index.ts CHANGED
@@ -1 +1 @@
1
- export default {}
1
+ export default {}
@@ -0,0 +1,10 @@
1
+ import type { App, Plugin } from 'vue'
2
+
3
+ export const withInstall = <T>(comp: T & { name?: string }) => {
4
+ ;(comp as T & Plugin).install = (app: App) => {
5
+ if (comp.name) {
6
+ app.component(comp.name, comp as any)
7
+ }
8
+ }
9
+ return comp as T & Plugin
10
+ }
package/package.json CHANGED
@@ -1,55 +1,68 @@
1
1
  {
2
- "name": "sykj",
3
- "version": "0.1.9",
4
- "description": "rem adaptation🚀",
5
- "main": "lib/common.ts",
6
- "files": [
7
- "lib",
8
- "packages",
9
- "main",
10
- "types"
11
- ],
12
- "types": "/types/index.d.ts",
13
- "scripts": {
14
- "dev": "vite --host",
15
- "build": "run-p type-check \"build-only {@}\" --",
16
- "preview": "vite preview",
17
- "build-only": "vite build ",
18
- "type-check": "vue-tsc --build --force",
19
- "package": "vite build && cp -r ./dist/* ./sykj",
20
- "docs:dev": "vitepress dev docs --host",
21
- "docs:build": "vitepress build docs",
22
- "docs:preview": "vitepress preview docs"
23
- },
24
- "dependencies": {
25
- "@element-plus/icons-vue": "^2.3.1",
26
- "amfe-flexible": "^2.2.1",
27
- "axios": "^1.6.8",
28
- "element-plus": "^2.7.2",
29
- "lottie-web": "^5.12.2",
30
- "pinia": "^2.1.7",
31
- "vitepress": "^1.3.1",
32
- "vue": "^3.4.21",
33
- "vue-router": "^4.3.0"
34
- },
35
- "devDependencies": {
36
- "@tsconfig/node20": "^20.1.4",
37
- "@types/node": "^20.12.5",
38
- "@vitejs/plugin-vue": "^5.0.4",
39
- "@vue/tsconfig": "^0.5.1",
40
- "npm-run-all2": "^6.1.2",
41
- "postcss": "^8.4.38",
42
- "postcss-pxtorem": "^6.1.0",
43
- "sass": "^1.77.1",
44
- "typescript": "~5.4.5",
45
- "vite": "^5.2.11",
46
- "vue-tsc": "^2.0.11"
47
- },
48
- "keywords": [
49
- "keyboard",
50
- "vue",
51
- "ui"
52
- ],
53
- "author": "IUHua",
54
- "license": "MIT"
55
- }
2
+ "name": "sykj",
3
+ "version": "0.2.0",
4
+ "description": "rem adaptation🚀",
5
+ "main": "lib/common.ts",
6
+ "files": [
7
+ "lib",
8
+ "packages",
9
+ "main",
10
+ "types"
11
+ ],
12
+ "types": "/types/index.d.ts",
13
+ "type": "module",
14
+ "scripts": {
15
+ "dev": "vite --host",
16
+ "build": "run-p type-check \"build-only {@}\" --",
17
+ "preview": "vite preview",
18
+ "build-only": "vite build ",
19
+ "type-check": "vue-tsc --build --force",
20
+ "package": "vite build && cp -r ./dist/* ./sykj",
21
+ "docs:dev": "vitepress dev docs --host",
22
+ "docs:build": "vitepress build docs",
23
+ "docs:preview": "vitepress preview docs",
24
+ "lint": "eslint --ext .js,.vue src",
25
+ "lint:fix": "eslint --ext .js,.vue src --fix",
26
+ "format": "prettier --write ."
27
+ },
28
+ "dependencies": {
29
+ "@element-plus/icons-vue": "^2.3.1",
30
+ "amfe-flexible": "^2.2.1",
31
+ "axios": "^1.6.8",
32
+ "element-plus": "^2.7.2",
33
+ "lottie-web": "^5.12.2",
34
+ "pinia": "^2.1.7",
35
+ "vitepress": "^1.3.1",
36
+ "vue": "^3.4.21",
37
+ "vue-router": "^4.3.0"
38
+ },
39
+ "devDependencies": {
40
+ "@babel/eslint-parser": "^7.28.0",
41
+ "@tsconfig/node20": "^20.1.4",
42
+ "@types/node": "^20.12.5",
43
+ "@typescript-eslint/eslint-plugin": "^8.39.1",
44
+ "@typescript-eslint/parser": "^8.39.1",
45
+ "@vitejs/plugin-vue": "^5.0.4",
46
+ "@vue/eslint-config-prettier": "^10.2.0",
47
+ "@vue/tsconfig": "^0.5.1",
48
+ "eslint": "^9.33.0",
49
+ "eslint-plugin-prettier": "^5.5.4",
50
+ "eslint-plugin-vue": "^10.4.0",
51
+ "npm-run-all2": "^6.1.2",
52
+ "postcss": "^8.4.38",
53
+ "postcss-pxtorem": "^6.1.0",
54
+ "prettier": "^3.6.2",
55
+ "sass": "^1.77.1",
56
+ "typescript": "~5.4.5",
57
+ "vite": "^5.2.11",
58
+ "vue-eslint-parser": "^10.2.0",
59
+ "vue-tsc": "^2.0.11"
60
+ },
61
+ "keywords": [
62
+ "keyboard",
63
+ "vue",
64
+ "ui"
65
+ ],
66
+ "author": "IUHua",
67
+ "license": "MIT"
68
+ }
@@ -0,0 +1,5 @@
1
+ import _SyButton from './src/index.vue'
2
+ import { withInstall } from '../../main/utils/withInstall'
3
+ _SyButton.name = 'SyButton'
4
+ export const SyButton = withInstall(_SyButton)
5
+ export default SyButton
@@ -0,0 +1,138 @@
1
+ <template>
2
+ <button
3
+ class="my-btn"
4
+ :class="[
5
+ `my-btn--${type}`,
6
+ size ? `my-btn--${size}` : '',
7
+ { 'is-plain': plain, 'is-round': round, 'is-disabled': disabled }
8
+ ]"
9
+ :disabled="disabled"
10
+ @click="$emit('click', $event)"
11
+ @touchstart="onTouchStart"
12
+ @touchend="onTouchEnd"
13
+ >
14
+ <slot />
15
+ </button>
16
+ </template>
17
+
18
+ <script setup lang="ts">
19
+ interface Props {
20
+ type?: 'info' | 'primary' | 'success' | 'warning' | 'danger'
21
+ size?: 'small' | 'medium' | 'large'
22
+ plain?: boolean
23
+ round?: boolean
24
+ disabled?: boolean
25
+ }
26
+ withDefaults(defineProps<Props>(), {
27
+ type: 'primary',
28
+ size: 'medium',
29
+ plain: false,
30
+ round: false,
31
+ disabled: false
32
+ })
33
+
34
+ defineEmits<{
35
+ (e: 'click', evt: MouseEvent): void
36
+ }>()
37
+
38
+ function onTouchStart() {
39
+ // SyMessage.success('点击')
40
+ }
41
+
42
+ function onTouchEnd() {}
43
+ </script>
44
+
45
+ <style scoped>
46
+ .my-btn {
47
+ display: inline-flex;
48
+ align-items: center;
49
+ justify-content: center;
50
+ font-size: 14px;
51
+ line-height: 1;
52
+ padding: 8px 15px;
53
+ border-radius: 4px;
54
+ border: 1px solid transparent;
55
+ cursor: pointer;
56
+ transition: all 0.25s ease;
57
+ user-select: none;
58
+ }
59
+ .my-btn.is-disabled {
60
+ cursor: not-allowed;
61
+ opacity: 0.6;
62
+ }
63
+
64
+ /* --- type --- */
65
+ .my-btn--info {
66
+ background: #f3f3f3;
67
+ color: #606266;
68
+ border-color: #dcdfe6;
69
+ }
70
+ .my-btn--primary {
71
+ background: #409eff;
72
+ color: #fff;
73
+ }
74
+ .my-btn--success {
75
+ background: #67c23a;
76
+ color: #fff;
77
+ }
78
+ .my-btn--warning {
79
+ background: #e6a23c;
80
+ color: #fff;
81
+ }
82
+ .my-btn--danger {
83
+ background: #f56c6c;
84
+ color: #fff;
85
+ }
86
+
87
+ /* plain(朴素) */
88
+ .my-btn.is-plain.my-btn--info {
89
+ background: #f3f3f320;
90
+ color: #f3f3f3;
91
+ border-color: #a8a8a890;
92
+ }
93
+ .my-btn.is-plain.my-btn--primary {
94
+ background: #ecf5ff20;
95
+ color: #409eff;
96
+ border-color: #b3d8ff90;
97
+ }
98
+ .my-btn.is-plain.my-btn--success {
99
+ background: #f0f9eb20;
100
+ color: #67c23a;
101
+ border-color: #c2e7b090;
102
+ }
103
+ .my-btn.is-plain.my-btn--warning {
104
+ background: #fdf6ec20;
105
+ color: #e6a23c;
106
+ border-color: #f5dab190;
107
+ }
108
+ .my-btn.is-plain.my-btn--danger {
109
+ background: #fef0f020;
110
+ color: #f56c6c;
111
+ border-color: #fbc4c490;
112
+ }
113
+
114
+ /* hover */
115
+ .my-btn:not(.is-disabled):hover {
116
+ filter: brightness(0.95);
117
+ }
118
+
119
+ /* round */
120
+ .my-btn.is-round {
121
+ border-radius: 20px;
122
+ padding: 8px 18px;
123
+ }
124
+
125
+ /* --- size --- */
126
+ .my-btn--small {
127
+ font-size: 12px;
128
+ padding: 6px 12px;
129
+ }
130
+ .my-btn--medium {
131
+ font-size: 14px;
132
+ padding: 8px 15px;
133
+ }
134
+ .my-btn--large {
135
+ font-size: 16px;
136
+ padding: 10px 20px;
137
+ }
138
+ </style>
@@ -0,0 +1,5 @@
1
+ import _SyDialog from './src/index.vue'
2
+ import { withInstall } from '../../main/utils/withInstall'
3
+ _SyDialog.name = 'SyDialog'
4
+ export const SyDialog = withInstall(_SyDialog)
5
+ export default SyDialog
@@ -0,0 +1,142 @@
1
+ <template>
2
+ <teleport to="body">
3
+ <transition name="dialog-fade" appear>
4
+ <div
5
+ v-if="modelValue"
6
+ class="dialog-mask"
7
+ @click.self="handleClose"
8
+ >
9
+ <div class="dialog-box" role="dialog" aria-modal="true">
10
+ <header
11
+ class="dialog-header"
12
+ :style="`text-align: ${titleAlign};`"
13
+ v-if="$slots.header || title"
14
+ >
15
+ <slot name="header">
16
+ <span>{{ title }}</span>
17
+ </slot>
18
+ </header>
19
+
20
+ <section class="dialog-body">
21
+ <slot />
22
+ </section>
23
+
24
+ <footer class="dialog-footer" v-if="$slots.footer">
25
+ <slot name="footer" />
26
+ </footer>
27
+ </div>
28
+ </div>
29
+ </transition>
30
+ </teleport>
31
+ </template>
32
+
33
+ <script setup lang="ts">
34
+ export interface Props {
35
+ modelValue: boolean
36
+ title?: string
37
+ closeOnClickMask?: boolean
38
+ titleAlign?: 'left' | 'center' | 'right'
39
+ }
40
+
41
+ const props = defineProps<Props>()
42
+ console.log('🚀 ~ props:', props)
43
+ const emit = defineEmits(['update:modelValue', 'open', 'close'])
44
+
45
+ function handleClose() {
46
+ if (props.closeOnClickMask === false) return
47
+ emit('update:modelValue', false)
48
+ emit('close')
49
+ }
50
+ </script>
51
+
52
+ <style scoped lang="scss">
53
+ /* 遮罩 */
54
+ .dialog-mask {
55
+ position: fixed;
56
+ inset: 0;
57
+ background: rgba(0, 0, 0, 0.45);
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ z-index: 2000;
62
+ }
63
+
64
+ /* 弹窗主体 */
65
+ .dialog-box {
66
+ min-width: 60%;
67
+ max-width: 80%;
68
+ // width: 500px;
69
+ max-width: 90%;
70
+ background: #fff;
71
+ border-radius: 8px;
72
+ box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
73
+ overflow: hidden;
74
+ display: flex;
75
+ flex-direction: column;
76
+ animation: dialog-pop 0.25s ease;
77
+ padding: 20px 10px;
78
+ }
79
+
80
+ .dialog-header {
81
+ display: flex;
82
+ justify-content: space-between;
83
+ align-items: center;
84
+ padding: 12px 16px;
85
+ font-weight: 600;
86
+ // border-bottom: 1px solid #f0f0f0;
87
+ font-size: 1.4rem;
88
+ span {
89
+ width: 100%;
90
+ opacity: 0.7;
91
+ }
92
+ }
93
+
94
+ .dialog-close {
95
+ border: none;
96
+ background: none;
97
+ font-size: 20px;
98
+ cursor: pointer;
99
+ }
100
+
101
+ .dialog-body {
102
+ padding: 16px;
103
+ flex: 1;
104
+ }
105
+
106
+ .dialog-footer {
107
+ padding: 10px 16px;
108
+ // border-top: 1px solid #f0f0f0;
109
+ text-align: right;
110
+ }
111
+
112
+ /* 过渡动画 */
113
+ .dialog-fade-enter-from,
114
+ .dialog-fade-leave-to {
115
+ opacity: 0;
116
+ }
117
+ .dialog-fade-enter-active,
118
+ .dialog-fade-leave-active {
119
+ transition: opacity 0.25s ease;
120
+ }
121
+ .dialog-fade-enter-from .dialog-box,
122
+ .dialog-fade-leave-to .dialog-box {
123
+ transform: scale(0.92);
124
+ opacity: 0;
125
+ }
126
+ .dialog-fade-enter-active .dialog-box,
127
+ .dialog-fade-leave-active .dialog-box {
128
+ transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
129
+ }
130
+
131
+ /* 初次弹出的缩放效果 */
132
+ @keyframes dialog-pop {
133
+ from {
134
+ transform: scale(0.92);
135
+ opacity: 0;
136
+ }
137
+ to {
138
+ transform: scale(1);
139
+ opacity: 1;
140
+ }
141
+ }
142
+ </style>
@@ -1,8 +1,13 @@
1
- import SyKeyboard from "./src/Keyboardcon.vue";
2
- import type { App } from "vue";
1
+ // import type { App } from 'vue'
2
+ import './src/utils/store'
3
+ import './src/utils/focus'
4
+
5
+ import SyKeyboard from './src/Keyboardcon.vue'
6
+
7
+ SyKeyboard.name = 'SyKeyboard'
3
8
  /* istanbul ignore next */
4
- SyKeyboard.install = function (Vue: App) {
5
- Vue.component(SyKeyboard.name, SyKeyboard);
6
- };
9
+ // Keyboard.install = function (Vue: App) {
10
+ // Vue.component(Keyboard.name || 'SyKeyboard', Keyboard)
11
+ // }
7
12
 
8
- export default SyKeyboard;
13
+ export { SyKeyboard }