@star-ai/star-ui 0.1.1 → 0.1.3
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 +87 -5
- package/lib/index.esm.js +337 -0
- package/lib/index.js +299 -10
- package/lib/package.json +1 -1
- package/lib/star-ui.umd.js +1 -1
- package/package.json +1 -1
- package/packages/index.js +2 -2
package/README.md
CHANGED
|
@@ -32,11 +32,11 @@ import '@star-ai/star-ui/lib/styles/index.scss'
|
|
|
32
32
|
Vue.use(StarUI)
|
|
33
33
|
|
|
34
34
|
// 按需引入
|
|
35
|
-
import {
|
|
35
|
+
import { StarButton, StarInput } from '@star-ai/star-ui'
|
|
36
36
|
import '@star-ai/star-ui/lib/styles/index.scss'
|
|
37
37
|
|
|
38
|
-
Vue.use(
|
|
39
|
-
Vue.use(
|
|
38
|
+
Vue.use(StarButton)
|
|
39
|
+
Vue.use(StarInput)
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## 组件文档
|
|
@@ -44,15 +44,97 @@ Vue.use(Input)
|
|
|
44
44
|
### Button 按钮
|
|
45
45
|
|
|
46
46
|
```vue
|
|
47
|
-
<
|
|
47
|
+
<star-button type="primary">主要按钮</star-button>
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
### Input 输入框
|
|
51
51
|
|
|
52
52
|
```vue
|
|
53
|
-
<
|
|
53
|
+
<star-input v-model="value" placeholder="请输入内容"></star-input>
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
## Uni-app 特别说明
|
|
57
|
+
|
|
58
|
+
### 在 Uni-app 中使用
|
|
59
|
+
|
|
60
|
+
1. **全局引入(推荐)**:
|
|
61
|
+
|
|
62
|
+
在 `main.js` 中:
|
|
63
|
+
```javascript
|
|
64
|
+
import Vue from 'vue'
|
|
65
|
+
import App from './App'
|
|
66
|
+
import StarUI from '@star-ai/star-ui'
|
|
67
|
+
import '@star-ai/star-ui/lib/styles/index.scss'
|
|
68
|
+
|
|
69
|
+
Vue.use(StarUI)
|
|
70
|
+
|
|
71
|
+
App.mpType = 'app'
|
|
72
|
+
|
|
73
|
+
const app = new Vue({
|
|
74
|
+
...App
|
|
75
|
+
})
|
|
76
|
+
app.$mount()
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
2. **按需引入**:
|
|
80
|
+
|
|
81
|
+
```vue
|
|
82
|
+
<template>
|
|
83
|
+
<view>
|
|
84
|
+
<star-button type="primary">按钮</star-button>
|
|
85
|
+
<star-input v-model="value"></star-input>
|
|
86
|
+
</view>
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<script>
|
|
90
|
+
import { StarButton, StarInput } from '@star-ai/star-ui'
|
|
91
|
+
|
|
92
|
+
export default {
|
|
93
|
+
components: {
|
|
94
|
+
StarButton,
|
|
95
|
+
StarInput
|
|
96
|
+
},
|
|
97
|
+
data() {
|
|
98
|
+
return {
|
|
99
|
+
value: ''
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<style>
|
|
106
|
+
/* 引入全局样式 */
|
|
107
|
+
@import '@star-ai/star-ui/lib/styles/index.scss';
|
|
108
|
+
</style>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
3. **直接引入组件**:
|
|
112
|
+
|
|
113
|
+
```vue
|
|
114
|
+
<template>
|
|
115
|
+
<view>
|
|
116
|
+
<star-button type="primary">按钮</star-button>
|
|
117
|
+
</view>
|
|
118
|
+
</template>
|
|
119
|
+
|
|
120
|
+
<script>
|
|
121
|
+
import StarButton from '@star-ai/star-ui/lib/components/Button/Button.vue'
|
|
122
|
+
|
|
123
|
+
export default {
|
|
124
|
+
components: {
|
|
125
|
+
StarButton
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
</script>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 注意事项
|
|
132
|
+
|
|
133
|
+
1. **组件名称**:所有组件以 `star-` 为前缀,如 `star-button`、`star-input`
|
|
134
|
+
2. **样式引入**:确保引入了组件库的样式文件
|
|
135
|
+
3. **Vue 版本**:组件库基于 Vue 2.x 开发,与 Uni-app 保持兼容
|
|
136
|
+
4. **编译平台**:支持 H5、小程序、App 等多端编译
|
|
137
|
+
|
|
56
138
|
## 开发指南
|
|
57
139
|
|
|
58
140
|
### 项目结构
|
package/lib/index.esm.js
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
// ES模块入口文件
|
|
2
|
+
// 组件定义
|
|
3
|
+
|
|
4
|
+
// Button 组件
|
|
5
|
+
const StarButton = {
|
|
6
|
+
name: 'StarButton',
|
|
7
|
+
|
|
8
|
+
// 为组件添加 install 方法,用于 Vue.use()
|
|
9
|
+
install: function(Vue) {
|
|
10
|
+
Vue.component(this.name, this)
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
// 组件属性定义
|
|
14
|
+
props: {
|
|
15
|
+
// 按钮类型
|
|
16
|
+
type: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: 'default',
|
|
19
|
+
validator: (value) => {
|
|
20
|
+
return ['default', 'primary', 'success', 'warning', 'error', 'info'].includes(value)
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
// 按钮大小
|
|
25
|
+
size: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'medium',
|
|
28
|
+
validator: (value) => {
|
|
29
|
+
return ['mini', 'small', 'medium', 'large'].includes(value)
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
// 是否禁用
|
|
34
|
+
disabled: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
// 是否加载中
|
|
40
|
+
loading: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// 是否为朴素按钮
|
|
46
|
+
plain: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// 是否为块级按钮
|
|
52
|
+
block: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// 左侧图标
|
|
58
|
+
icon: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: ''
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// 右侧图标
|
|
64
|
+
rightIcon: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: ''
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// 自定义样式
|
|
70
|
+
customStyle: {
|
|
71
|
+
type: Object,
|
|
72
|
+
default: () => ({})
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// 点击防抖时间(毫秒)
|
|
76
|
+
debounce: {
|
|
77
|
+
type: Number,
|
|
78
|
+
default: 0
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
data() {
|
|
83
|
+
return {
|
|
84
|
+
canClick: true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
methods: {
|
|
89
|
+
handleClick(event) {
|
|
90
|
+
// 防抖处理
|
|
91
|
+
if (!this.canClick) return
|
|
92
|
+
|
|
93
|
+
if (this.debounce > 0) {
|
|
94
|
+
this.canClick = false
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
this.canClick = true
|
|
97
|
+
}, this.debounce)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 触发点击事件
|
|
101
|
+
if (!this.disabled && !this.loading) {
|
|
102
|
+
this.$emit('click', event)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
StarButton.name = 'StarButton'; // 确保name属性存在
|
|
108
|
+
StarButton.install = function(Vue) {
|
|
109
|
+
Vue.component(StarButton.name, StarButton);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Input 组件
|
|
113
|
+
const StarInput = {
|
|
114
|
+
name: 'StarInput',
|
|
115
|
+
|
|
116
|
+
// 为组件添加 install 方法,用于 Vue.use()
|
|
117
|
+
install: function(Vue) {
|
|
118
|
+
Vue.component(this.name, this)
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
props: {
|
|
122
|
+
// 输入框类型
|
|
123
|
+
type: {
|
|
124
|
+
type: String,
|
|
125
|
+
default: 'text'
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
// 绑定值
|
|
129
|
+
value: {
|
|
130
|
+
type: [String, Number],
|
|
131
|
+
default: ''
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// 原生属性
|
|
135
|
+
placeholder: {
|
|
136
|
+
type: String,
|
|
137
|
+
default: ''
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
disabled: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
default: false
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
maxlength: {
|
|
146
|
+
type: [String, Number],
|
|
147
|
+
default: 140
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
focus: {
|
|
151
|
+
type: Boolean,
|
|
152
|
+
default: false
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
confirmType: {
|
|
156
|
+
type: String,
|
|
157
|
+
default: 'done'
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
placeholderStyle: {
|
|
161
|
+
type: String,
|
|
162
|
+
default: ''
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
placeholderClass: {
|
|
166
|
+
type: String,
|
|
167
|
+
default: ''
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
cursorSpacing: {
|
|
171
|
+
type: [String, Number],
|
|
172
|
+
default: 0
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
// 自定义属性
|
|
176
|
+
size: {
|
|
177
|
+
type: String,
|
|
178
|
+
default: 'medium',
|
|
179
|
+
validator: (value) => ['mini', 'small', 'medium', 'large'].includes(value)
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
clearable: {
|
|
183
|
+
type: Boolean,
|
|
184
|
+
default: false
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
showPassword: {
|
|
188
|
+
type: Boolean,
|
|
189
|
+
default: false
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
prefixIcon: {
|
|
193
|
+
type: String,
|
|
194
|
+
default: ''
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
suffixIcon: {
|
|
198
|
+
type: String,
|
|
199
|
+
default: ''
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
prepend: {
|
|
203
|
+
type: String,
|
|
204
|
+
default: ''
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
append: {
|
|
208
|
+
type: String,
|
|
209
|
+
default: ''
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
readonly: {
|
|
213
|
+
type: Boolean,
|
|
214
|
+
default: false
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
data() {
|
|
219
|
+
return {
|
|
220
|
+
currentValue: this.value,
|
|
221
|
+
isFocused: false,
|
|
222
|
+
passwordVisible: false
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
computed: {
|
|
227
|
+
inputClasses() {
|
|
228
|
+
return [
|
|
229
|
+
`star-input--${this.size}`,
|
|
230
|
+
{
|
|
231
|
+
'star-input--disabled': this.disabled,
|
|
232
|
+
'star-input--focused': this.isFocused,
|
|
233
|
+
'star-input--with-prepend': this.prepend || this.$slots.prepend,
|
|
234
|
+
'star-input--with-append': this.append || this.$slots.append,
|
|
235
|
+
'star-input--readonly': this.readonly
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
watch: {
|
|
242
|
+
value(newVal) {
|
|
243
|
+
this.currentValue = newVal
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
methods: {
|
|
248
|
+
handleInput(event) {
|
|
249
|
+
const value = event.detail.value
|
|
250
|
+
this.currentValue = value
|
|
251
|
+
this.$emit('input', value)
|
|
252
|
+
this.$emit('change', value)
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
handleFocus(event) {
|
|
256
|
+
this.isFocused = true
|
|
257
|
+
this.$emit('focus', event)
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
handleBlur(event) {
|
|
261
|
+
this.isFocused = false
|
|
262
|
+
this.$emit('blur', event)
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
handleConfirm(event) {
|
|
266
|
+
this.$emit('confirm', event)
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
handleKeyboardHeightChange(event) {
|
|
270
|
+
this.$emit('keyboardheightchange', event)
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
handleClear() {
|
|
274
|
+
this.currentValue = ''
|
|
275
|
+
this.$emit('input', '')
|
|
276
|
+
this.$emit('change', '')
|
|
277
|
+
this.$emit('clear')
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
togglePasswordVisible() {
|
|
281
|
+
this.passwordVisible = !this.passwordVisible
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
handlePrefixIconClick() {
|
|
285
|
+
this.$emit('click-prefix')
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
handleSuffixIconClick() {
|
|
289
|
+
this.$emit('click-suffix')
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
StarInput.name = 'StarInput'; // 确保name属性存在
|
|
294
|
+
StarInput.install = function(Vue) {
|
|
295
|
+
Vue.component(StarInput.name, StarInput);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
// 组件列表
|
|
300
|
+
const components = [
|
|
301
|
+
StarButton,
|
|
302
|
+
StarInput
|
|
303
|
+
];
|
|
304
|
+
|
|
305
|
+
// 安装函数
|
|
306
|
+
const install = function(Vue, opts = {}) {
|
|
307
|
+
components.forEach(component => {
|
|
308
|
+
// 直接注册组件,确保name属性存在
|
|
309
|
+
if (component.name) {
|
|
310
|
+
Vue.component(component.name, component);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// 挂载全局方法
|
|
315
|
+
Vue.prototype.$MY_UI = {
|
|
316
|
+
size: opts.size || '',
|
|
317
|
+
zIndex: opts.zIndex || 2000
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// 如果是浏览器环境且已引入Vue,则自动安装
|
|
322
|
+
if (typeof window !== 'undefined' && window.Vue) {
|
|
323
|
+
install(window.Vue);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// 创建导出对象
|
|
327
|
+
const StarUI = {
|
|
328
|
+
version: '0.1.3',
|
|
329
|
+
install,
|
|
330
|
+
// 导出所有组件
|
|
331
|
+
StarButton,
|
|
332
|
+
StarInput
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export default StarUI;
|
|
336
|
+
export const StarButton = StarButton;
|
|
337
|
+
export const StarInput = StarInput;
|
package/lib/index.js
CHANGED
|
@@ -5,9 +5,302 @@
|
|
|
5
5
|
}(this, (function () {
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// 组件定义
|
|
9
|
+
|
|
10
|
+
// Button 组件
|
|
11
|
+
const StarButton = {
|
|
12
|
+
name: 'StarButton',
|
|
13
|
+
|
|
14
|
+
// 为组件添加 install 方法,用于 Vue.use()
|
|
15
|
+
install: function(Vue) {
|
|
16
|
+
Vue.component(this.name, this)
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// 组件属性定义
|
|
20
|
+
props: {
|
|
21
|
+
// 按钮类型
|
|
22
|
+
type: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: 'default',
|
|
25
|
+
validator: (value) => {
|
|
26
|
+
return ['default', 'primary', 'success', 'warning', 'error', 'info'].includes(value)
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
// 按钮大小
|
|
31
|
+
size: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: 'medium',
|
|
34
|
+
validator: (value) => {
|
|
35
|
+
return ['mini', 'small', 'medium', 'large'].includes(value)
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
// 是否禁用
|
|
40
|
+
disabled: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// 是否加载中
|
|
46
|
+
loading: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// 是否为朴素按钮
|
|
52
|
+
plain: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// 是否为块级按钮
|
|
58
|
+
block: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// 左侧图标
|
|
64
|
+
icon: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: ''
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// 右侧图标
|
|
70
|
+
rightIcon: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: ''
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// 自定义样式
|
|
76
|
+
customStyle: {
|
|
77
|
+
type: Object,
|
|
78
|
+
default: () => ({})
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
// 点击防抖时间(毫秒)
|
|
82
|
+
debounce: {
|
|
83
|
+
type: Number,
|
|
84
|
+
default: 0
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
data() {
|
|
89
|
+
return {
|
|
90
|
+
canClick: true
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
methods: {
|
|
95
|
+
handleClick(event) {
|
|
96
|
+
// 防抖处理
|
|
97
|
+
if (!this.canClick) return
|
|
98
|
+
|
|
99
|
+
if (this.debounce > 0) {
|
|
100
|
+
this.canClick = false
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
this.canClick = true
|
|
103
|
+
}, this.debounce)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 触发点击事件
|
|
107
|
+
if (!this.disabled && !this.loading) {
|
|
108
|
+
this.$emit('click', event)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
StarButton.name = 'StarButton'; // 确保name属性存在
|
|
114
|
+
StarButton.install = function(Vue) {
|
|
115
|
+
Vue.component(StarButton.name, StarButton);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Input 组件
|
|
119
|
+
const StarInput = {
|
|
120
|
+
name: 'StarInput',
|
|
121
|
+
|
|
122
|
+
// 为组件添加 install 方法,用于 Vue.use()
|
|
123
|
+
install: function(Vue) {
|
|
124
|
+
Vue.component(this.name, this)
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
props: {
|
|
128
|
+
// 输入框类型
|
|
129
|
+
type: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: 'text'
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// 绑定值
|
|
135
|
+
value: {
|
|
136
|
+
type: [String, Number],
|
|
137
|
+
default: ''
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
// 原生属性
|
|
141
|
+
placeholder: {
|
|
142
|
+
type: String,
|
|
143
|
+
default: ''
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
disabled: {
|
|
147
|
+
type: Boolean,
|
|
148
|
+
default: false
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
maxlength: {
|
|
152
|
+
type: [String, Number],
|
|
153
|
+
default: 140
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
focus: {
|
|
157
|
+
type: Boolean,
|
|
158
|
+
default: false
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
confirmType: {
|
|
162
|
+
type: String,
|
|
163
|
+
default: 'done'
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
placeholderStyle: {
|
|
167
|
+
type: String,
|
|
168
|
+
default: ''
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
placeholderClass: {
|
|
172
|
+
type: String,
|
|
173
|
+
default: ''
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
cursorSpacing: {
|
|
177
|
+
type: [String, Number],
|
|
178
|
+
default: 0
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
// 自定义属性
|
|
182
|
+
size: {
|
|
183
|
+
type: String,
|
|
184
|
+
default: 'medium',
|
|
185
|
+
validator: (value) => ['mini', 'small', 'medium', 'large'].includes(value)
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
clearable: {
|
|
189
|
+
type: Boolean,
|
|
190
|
+
default: false
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
showPassword: {
|
|
194
|
+
type: Boolean,
|
|
195
|
+
default: false
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
prefixIcon: {
|
|
199
|
+
type: String,
|
|
200
|
+
default: ''
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
suffixIcon: {
|
|
204
|
+
type: String,
|
|
205
|
+
default: ''
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
prepend: {
|
|
209
|
+
type: String,
|
|
210
|
+
default: ''
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
append: {
|
|
214
|
+
type: String,
|
|
215
|
+
default: ''
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
readonly: {
|
|
219
|
+
type: Boolean,
|
|
220
|
+
default: false
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
data() {
|
|
225
|
+
return {
|
|
226
|
+
currentValue: this.value,
|
|
227
|
+
isFocused: false,
|
|
228
|
+
passwordVisible: false
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
computed: {
|
|
233
|
+
inputClasses() {
|
|
234
|
+
return [
|
|
235
|
+
`star-input--${this.size}`,
|
|
236
|
+
{
|
|
237
|
+
'star-input--disabled': this.disabled,
|
|
238
|
+
'star-input--focused': this.isFocused,
|
|
239
|
+
'star-input--with-prepend': this.prepend || this.$slots.prepend,
|
|
240
|
+
'star-input--with-append': this.append || this.$slots.append,
|
|
241
|
+
'star-input--readonly': this.readonly
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
watch: {
|
|
248
|
+
value(newVal) {
|
|
249
|
+
this.currentValue = newVal
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
methods: {
|
|
254
|
+
handleInput(event) {
|
|
255
|
+
const value = event.detail.value
|
|
256
|
+
this.currentValue = value
|
|
257
|
+
this.$emit('input', value)
|
|
258
|
+
this.$emit('change', value)
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
handleFocus(event) {
|
|
262
|
+
this.isFocused = true
|
|
263
|
+
this.$emit('focus', event)
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
handleBlur(event) {
|
|
267
|
+
this.isFocused = false
|
|
268
|
+
this.$emit('blur', event)
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
handleConfirm(event) {
|
|
272
|
+
this.$emit('confirm', event)
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
handleKeyboardHeightChange(event) {
|
|
276
|
+
this.$emit('keyboardheightchange', event)
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
handleClear() {
|
|
280
|
+
this.currentValue = ''
|
|
281
|
+
this.$emit('input', '')
|
|
282
|
+
this.$emit('change', '')
|
|
283
|
+
this.$emit('clear')
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
togglePasswordVisible() {
|
|
287
|
+
this.passwordVisible = !this.passwordVisible
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
handlePrefixIconClick() {
|
|
291
|
+
this.$emit('click-prefix')
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
handleSuffixIconClick() {
|
|
295
|
+
this.$emit('click-suffix')
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
StarInput.name = 'StarInput'; // 确保name属性存在
|
|
300
|
+
StarInput.install = function(Vue) {
|
|
301
|
+
Vue.component(StarInput.name, StarInput);
|
|
302
|
+
};
|
|
303
|
+
|
|
11
304
|
|
|
12
305
|
// 组件列表
|
|
13
306
|
const components = [
|
|
@@ -18,12 +311,8 @@ const StarInput = require('./components/Input/Input.vue');
|
|
|
18
311
|
// 安装函数
|
|
19
312
|
const install = function(Vue, opts = {}) {
|
|
20
313
|
components.forEach(component => {
|
|
21
|
-
//
|
|
22
|
-
if (component.
|
|
23
|
-
Vue.use(component);
|
|
24
|
-
}
|
|
25
|
-
// 如果组件是Vue组件对象,直接注册
|
|
26
|
-
else if (component.name) {
|
|
314
|
+
// 直接注册组件,确保name属性存在
|
|
315
|
+
if (component.name) {
|
|
27
316
|
Vue.component(component.name, component);
|
|
28
317
|
}
|
|
29
318
|
});
|
|
@@ -42,7 +331,7 @@ const StarInput = require('./components/Input/Input.vue');
|
|
|
42
331
|
|
|
43
332
|
// 创建导出对象
|
|
44
333
|
const StarUI = {
|
|
45
|
-
version: '0.1.
|
|
334
|
+
version: '0.1.3',
|
|
46
335
|
install,
|
|
47
336
|
// 导出所有组件
|
|
48
337
|
StarButton,
|
package/lib/package.json
CHANGED
package/lib/star-ui.umd.js
CHANGED
package/package.json
CHANGED
package/packages/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import packageJson from '../../package.json'
|
|
3
3
|
|
|
4
4
|
// 静态导入所有组件
|
|
5
|
-
import StarButton from './components/Button/
|
|
6
|
-
import StarInput from './components/Input/
|
|
5
|
+
import StarButton from './components/Button/Button.vue'
|
|
6
|
+
import StarInput from './components/Input/Input.vue'
|
|
7
7
|
|
|
8
8
|
// 组件列表
|
|
9
9
|
const components = [
|