@star-ai/star-ui 0.1.6 → 0.1.8
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/components/Button/index.js +8 -0
- package/lib/components/Input/index.js +8 -0
- package/lib/index.js +24 -451
- package/package.json +1 -1
- package/packages/index.js +3 -40
- package/lib/index.esm.js +0 -450
- package/lib/package.json +0 -28
- package/lib/star-ui.umd.js +0 -464
package/lib/index.js
CHANGED
|
@@ -1,455 +1,28 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.StarUI = factory());
|
|
5
|
-
}(this, (function () {
|
|
6
|
-
'use strict';
|
|
7
1
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// Button 组件
|
|
11
|
-
const StarButton = {
|
|
12
|
-
template: '<view
|
|
13
|
-
class="star-button"
|
|
14
|
-
:class="[
|
|
15
|
-
\`star-button--${type}\`,
|
|
16
|
-
\`star-button--${size}\`,
|
|
17
|
-
{
|
|
18
|
-
\'star-button--disabled\': disabled,
|
|
19
|
-
\'star-button--loading\': loading,
|
|
20
|
-
\'star-button--block\': block,
|
|
21
|
-
\'star-button--plain\': plain
|
|
22
|
-
}
|
|
23
|
-
]"
|
|
24
|
-
:style="[customStyle]"
|
|
25
|
-
@click="handleClick"
|
|
26
|
-
>
|
|
27
|
-
<!-- 加载状态 -->
|
|
28
|
-
<view v-if="loading" class="star-button__loading">
|
|
29
|
-
<view class="star-button__loading-spinner"></view>
|
|
30
|
-
</view>
|
|
31
|
-
|
|
32
|
-
<!-- 图标 -->
|
|
33
|
-
<text
|
|
34
|
-
v-if="icon && !loading"
|
|
35
|
-
class="star-button__icon"
|
|
36
|
-
:class="icon"
|
|
37
|
-
></text>
|
|
38
|
-
|
|
39
|
-
<!-- 文字内容 -->
|
|
40
|
-
<text class="star-button__text">
|
|
41
|
-
<slot></slot>
|
|
42
|
-
</text>
|
|
43
|
-
|
|
44
|
-
<!-- 右侧图标 -->
|
|
45
|
-
<text
|
|
46
|
-
v-if="rightIcon && !loading"
|
|
47
|
-
class="star-button__right-icon"
|
|
48
|
-
:class="rightIcon"
|
|
49
|
-
></text>
|
|
50
|
-
</view>',
|
|
2
|
+
// 自动导入所有组件
|
|
3
|
+
const components = []
|
|
51
4
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Vue.component(this.name, this)
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
// 组件属性定义
|
|
60
|
-
props: {
|
|
61
|
-
// 按钮类型
|
|
62
|
-
type: {
|
|
63
|
-
type: String,
|
|
64
|
-
default: 'default',
|
|
65
|
-
validator: (value) => {
|
|
66
|
-
return ['default', 'primary', 'success', 'warning', 'error', 'info'].includes(value)
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
// 按钮大小
|
|
71
|
-
size: {
|
|
72
|
-
type: String,
|
|
73
|
-
default: 'medium',
|
|
74
|
-
validator: (value) => {
|
|
75
|
-
return ['mini', 'small', 'medium', 'large'].includes(value)
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
// 是否禁用
|
|
80
|
-
disabled: {
|
|
81
|
-
type: Boolean,
|
|
82
|
-
default: false
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
// 是否加载中
|
|
86
|
-
loading: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: false
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
// 是否为朴素按钮
|
|
92
|
-
plain: {
|
|
93
|
-
type: Boolean,
|
|
94
|
-
default: false
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
// 是否为块级按钮
|
|
98
|
-
block: {
|
|
99
|
-
type: Boolean,
|
|
100
|
-
default: false
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
// 左侧图标
|
|
104
|
-
icon: {
|
|
105
|
-
type: String,
|
|
106
|
-
default: ''
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
// 右侧图标
|
|
110
|
-
rightIcon: {
|
|
111
|
-
type: String,
|
|
112
|
-
default: ''
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
// 自定义样式
|
|
116
|
-
customStyle: {
|
|
117
|
-
type: Object,
|
|
118
|
-
default: () => ({})
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
// 点击防抖时间(毫秒)
|
|
122
|
-
debounce: {
|
|
123
|
-
type: Number,
|
|
124
|
-
default: 0
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
data() {
|
|
129
|
-
return {
|
|
130
|
-
canClick: true
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
methods: {
|
|
135
|
-
handleClick(event) {
|
|
136
|
-
// 防抖处理
|
|
137
|
-
if (!this.canClick) return
|
|
138
|
-
|
|
139
|
-
if (this.debounce > 0) {
|
|
140
|
-
this.canClick = false
|
|
141
|
-
setTimeout(() => {
|
|
142
|
-
this.canClick = true
|
|
143
|
-
}, this.debounce)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// 触发点击事件
|
|
147
|
-
if (!this.disabled && !this.loading) {
|
|
148
|
-
this.$emit('click', event)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
StarButton.name = 'StarButton'; // 确保name属性存在
|
|
154
|
-
StarButton.install = function(Vue) {
|
|
155
|
-
Vue.component(StarButton.name, StarButton);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// Input 组件
|
|
159
|
-
const StarInput = {
|
|
160
|
-
template: '<view class="star-input" :class="inputClasses">
|
|
161
|
-
<!-- 前置内容 -->
|
|
162
|
-
<view v-if="$slots.prepend || prepend" class="star-input__prepend">
|
|
163
|
-
<slot name="prepend">
|
|
164
|
-
<text v-if="prepend" class="star-input__prepend-text">{{ prepend }}</text>
|
|
165
|
-
</slot>
|
|
166
|
-
</view>
|
|
167
|
-
|
|
168
|
-
<!-- 输入框主体 -->
|
|
169
|
-
<view class="star-input__wrapper">
|
|
170
|
-
<!-- 前置图标 -->
|
|
171
|
-
<text
|
|
172
|
-
v-if="prefixIcon"
|
|
173
|
-
class="star-input__prefix-icon"
|
|
174
|
-
:class="prefixIcon"
|
|
175
|
-
@click="handlePrefixIconClick"
|
|
176
|
-
></text>
|
|
177
|
-
|
|
178
|
-
<!-- 输入框 -->
|
|
179
|
-
<input
|
|
180
|
-
class="star-input__inner"
|
|
181
|
-
:type="showPassword ? (passwordVisible ? \'text\' : \'password\') : type"
|
|
182
|
-
:value="currentValue"
|
|
183
|
-
:placeholder="placeholder"
|
|
184
|
-
:disabled="disabled"
|
|
185
|
-
:maxlength="maxlength"
|
|
186
|
-
:focus="focus"
|
|
187
|
-
:confirm-type="confirmType"
|
|
188
|
-
:placeholder-style="placeholderStyle"
|
|
189
|
-
:placeholder-class="placeholderClass"
|
|
190
|
-
:cursor-spacing="cursorSpacing"
|
|
191
|
-
@input="handleInput"
|
|
192
|
-
@focus="handleFocus"
|
|
193
|
-
@blur="handleBlur"
|
|
194
|
-
@confirm="handleConfirm"
|
|
195
|
-
@keyboardheightchange="handleKeyboardHeightChange"
|
|
196
|
-
/>
|
|
197
|
-
|
|
198
|
-
<!-- 清除按钮 -->
|
|
199
|
-
<view
|
|
200
|
-
v-if="clearable && currentValue && !disabled"
|
|
201
|
-
class="star-input__clear"
|
|
202
|
-
@click="handleClear"
|
|
203
|
-
>
|
|
204
|
-
<text class="star-icon-close"></text>
|
|
205
|
-
</view>
|
|
206
|
-
|
|
207
|
-
<!-- 密码可见切换按钮 -->
|
|
208
|
-
<view
|
|
209
|
-
v-if="showPassword && currentValue"
|
|
210
|
-
class="star-input__password-toggle"
|
|
211
|
-
@click="togglePasswordVisible"
|
|
212
|
-
>
|
|
213
|
-
<text :class="passwordVisible ? \'star-icon-eye-open\' : \'star-icon-eye-close\'"></text>
|
|
214
|
-
</view>
|
|
215
|
-
|
|
216
|
-
<!-- 后置图标 -->
|
|
217
|
-
<text
|
|
218
|
-
v-if="suffixIcon"
|
|
219
|
-
class="star-input__suffix-icon"
|
|
220
|
-
:class="suffixIcon"
|
|
221
|
-
@click="handleSuffixIconClick"
|
|
222
|
-
></text>
|
|
223
|
-
</view>
|
|
224
|
-
|
|
225
|
-
<!-- 后置内容 -->
|
|
226
|
-
<view v-if="$slots.append || append" class="star-input__append">
|
|
227
|
-
<slot name="append">
|
|
228
|
-
<text v-if="append" class="star-input__append-text">{{ append }}</text>
|
|
229
|
-
</slot>
|
|
230
|
-
</view>
|
|
231
|
-
</view>',
|
|
232
|
-
|
|
233
|
-
name: 'StarInput',
|
|
234
|
-
|
|
235
|
-
// 为组件添加 install 方法,用于 Vue.use()
|
|
236
|
-
install: function(Vue) {
|
|
237
|
-
Vue.component(this.name, this)
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
props: {
|
|
241
|
-
// 输入框类型
|
|
242
|
-
type: {
|
|
243
|
-
type: String,
|
|
244
|
-
default: 'text'
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
// 绑定值
|
|
248
|
-
value: {
|
|
249
|
-
type: [String, Number],
|
|
250
|
-
default: ''
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
// 原生属性
|
|
254
|
-
placeholder: {
|
|
255
|
-
type: String,
|
|
256
|
-
default: ''
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
disabled: {
|
|
260
|
-
type: Boolean,
|
|
261
|
-
default: false
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
maxlength: {
|
|
265
|
-
type: [String, Number],
|
|
266
|
-
default: 140
|
|
267
|
-
},
|
|
268
|
-
|
|
269
|
-
focus: {
|
|
270
|
-
type: Boolean,
|
|
271
|
-
default: false
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
confirmType: {
|
|
275
|
-
type: String,
|
|
276
|
-
default: 'done'
|
|
277
|
-
},
|
|
278
|
-
|
|
279
|
-
placeholderStyle: {
|
|
280
|
-
type: String,
|
|
281
|
-
default: ''
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
placeholderClass: {
|
|
285
|
-
type: String,
|
|
286
|
-
default: ''
|
|
287
|
-
},
|
|
288
|
-
|
|
289
|
-
cursorSpacing: {
|
|
290
|
-
type: [String, Number],
|
|
291
|
-
default: 0
|
|
292
|
-
},
|
|
293
|
-
|
|
294
|
-
// 自定义属性
|
|
295
|
-
size: {
|
|
296
|
-
type: String,
|
|
297
|
-
default: 'medium',
|
|
298
|
-
validator: (value) => ['mini', 'small', 'medium', 'large'].includes(value)
|
|
299
|
-
},
|
|
300
|
-
|
|
301
|
-
clearable: {
|
|
302
|
-
type: Boolean,
|
|
303
|
-
default: false
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
showPassword: {
|
|
307
|
-
type: Boolean,
|
|
308
|
-
default: false
|
|
309
|
-
},
|
|
310
|
-
|
|
311
|
-
prefixIcon: {
|
|
312
|
-
type: String,
|
|
313
|
-
default: ''
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
suffixIcon: {
|
|
317
|
-
type: String,
|
|
318
|
-
default: ''
|
|
319
|
-
},
|
|
320
|
-
|
|
321
|
-
prepend: {
|
|
322
|
-
type: String,
|
|
323
|
-
default: ''
|
|
324
|
-
},
|
|
325
|
-
|
|
326
|
-
append: {
|
|
327
|
-
type: String,
|
|
328
|
-
default: ''
|
|
329
|
-
},
|
|
330
|
-
|
|
331
|
-
readonly: {
|
|
332
|
-
type: Boolean,
|
|
333
|
-
default: false
|
|
334
|
-
}
|
|
335
|
-
},
|
|
5
|
+
const install = function(Vue, opts = {}) {
|
|
6
|
+
components.forEach(component => {
|
|
7
|
+
Vue.component(component.name, component)
|
|
8
|
+
})
|
|
336
9
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
passwordVisible: false
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
computed: {
|
|
346
|
-
inputClasses() {
|
|
347
|
-
return [
|
|
348
|
-
`star-input--${this.size}`,
|
|
349
|
-
{
|
|
350
|
-
'star-input--disabled': this.disabled,
|
|
351
|
-
'star-input--focused': this.isFocused,
|
|
352
|
-
'star-input--with-prepend': this.prepend || this.$slots.prepend,
|
|
353
|
-
'star-input--with-append': this.append || this.$slots.append,
|
|
354
|
-
'star-input--readonly': this.readonly
|
|
355
|
-
}
|
|
356
|
-
]
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
|
|
360
|
-
watch: {
|
|
361
|
-
value(newVal) {
|
|
362
|
-
this.currentValue = newVal
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
|
|
366
|
-
methods: {
|
|
367
|
-
handleInput(event) {
|
|
368
|
-
const value = event.detail.value
|
|
369
|
-
this.currentValue = value
|
|
370
|
-
this.$emit('input', value)
|
|
371
|
-
this.$emit('change', value)
|
|
372
|
-
},
|
|
373
|
-
|
|
374
|
-
handleFocus(event) {
|
|
375
|
-
this.isFocused = true
|
|
376
|
-
this.$emit('focus', event)
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
handleBlur(event) {
|
|
380
|
-
this.isFocused = false
|
|
381
|
-
this.$emit('blur', event)
|
|
382
|
-
},
|
|
383
|
-
|
|
384
|
-
handleConfirm(event) {
|
|
385
|
-
this.$emit('confirm', event)
|
|
386
|
-
},
|
|
387
|
-
|
|
388
|
-
handleKeyboardHeightChange(event) {
|
|
389
|
-
this.$emit('keyboardheightchange', event)
|
|
390
|
-
},
|
|
391
|
-
|
|
392
|
-
handleClear() {
|
|
393
|
-
this.currentValue = ''
|
|
394
|
-
this.$emit('input', '')
|
|
395
|
-
this.$emit('change', '')
|
|
396
|
-
this.$emit('clear')
|
|
397
|
-
},
|
|
398
|
-
|
|
399
|
-
togglePasswordVisible() {
|
|
400
|
-
this.passwordVisible = !this.passwordVisible
|
|
401
|
-
},
|
|
402
|
-
|
|
403
|
-
handlePrefixIconClick() {
|
|
404
|
-
this.$emit('click-prefix')
|
|
405
|
-
},
|
|
406
|
-
|
|
407
|
-
handleSuffixIconClick() {
|
|
408
|
-
this.$emit('click-suffix')
|
|
409
|
-
}
|
|
10
|
+
// 挂载全局方法
|
|
11
|
+
Vue.prototype.$MY_UI = {
|
|
12
|
+
size: opts.size || '',
|
|
13
|
+
zIndex: opts.zIndex || 2000
|
|
410
14
|
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const install = function(Vue, opts = {}) {
|
|
426
|
-
components.forEach(component => {
|
|
427
|
-
// 直接注册组件,确保name属性存在
|
|
428
|
-
if (component.name) {
|
|
429
|
-
Vue.component(component.name, component);
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
// 挂载全局方法
|
|
434
|
-
Vue.prototype.$MY_UI = {
|
|
435
|
-
size: opts.size || '',
|
|
436
|
-
zIndex: opts.zIndex || 2000
|
|
437
|
-
};
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
// 如果是浏览器环境且已引入Vue,则自动安装
|
|
441
|
-
if (typeof window !== 'undefined' && window.Vue) {
|
|
442
|
-
install(window.Vue);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
// 创建导出对象
|
|
446
|
-
const StarUI = {
|
|
447
|
-
version: '0.1.6',
|
|
448
|
-
install,
|
|
449
|
-
// 导出所有组件
|
|
450
|
-
StarButton,
|
|
451
|
-
StarInput
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
return StarUI;
|
|
455
|
-
})));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 如果是浏览器环境且已引入Vue,则自动安装
|
|
18
|
+
if (typeof window !== 'undefined' && window.Vue) {
|
|
19
|
+
install(window.Vue)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
version: '0.1.8',
|
|
24
|
+
install,
|
|
25
|
+
// 按需导出所有组件
|
|
26
|
+
Button: require('./components/Button').default,
|
|
27
|
+
Input: require('./components/Input').default
|
|
28
|
+
}
|
package/package.json
CHANGED
package/packages/index.js
CHANGED
|
@@ -23,47 +23,10 @@ const install = function(Vue, opts = {}) {
|
|
|
23
23
|
Vue.component(component.name, component)
|
|
24
24
|
}
|
|
25
25
|
})
|
|
26
|
-
|
|
27
|
-
// 挂载全局方法
|
|
28
|
-
Vue.prototype.$MY_UI = {
|
|
29
|
-
size: opts.size || '',
|
|
30
|
-
zIndex: opts.zIndex || 2000
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 如果是浏览器环境且已引入Vue,则自动安装
|
|
35
|
-
if (typeof window !== 'undefined' && window.Vue) {
|
|
36
|
-
install(window.Vue)
|
|
37
26
|
}
|
|
38
27
|
|
|
39
28
|
// 创建导出对象
|
|
40
|
-
|
|
29
|
+
export default {
|
|
41
30
|
version: packageJson.version,
|
|
42
|
-
install
|
|
43
|
-
|
|
44
|
-
StarButton,
|
|
45
|
-
StarInput
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 导出模块
|
|
49
|
-
if (typeof module !== 'undefined' && module.exports) {
|
|
50
|
-
// CommonJS 导出
|
|
51
|
-
module.exports = StarUI
|
|
52
|
-
module.exports.default = StarUI
|
|
53
|
-
// 为每个组件添加单独的导出(支持按需导入)
|
|
54
|
-
components.forEach(component => {
|
|
55
|
-
if (component.name) {
|
|
56
|
-
module.exports[component.name] = component
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
} else if (typeof define === 'function' && define.amd) {
|
|
60
|
-
// AMD 导出
|
|
61
|
-
define(() => StarUI)
|
|
62
|
-
} else if (typeof window !== 'undefined') {
|
|
63
|
-
// 浏览器全局变量导出
|
|
64
|
-
window.StarUI = StarUI
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// ES模块导出
|
|
68
|
-
export default StarUI
|
|
69
|
-
export { StarButton, StarInput }
|
|
31
|
+
install
|
|
32
|
+
}
|