@star-ai/star-ui 0.1.7 → 0.1.9

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.
@@ -0,0 +1,8 @@
1
+
2
+ import StarButton from './StarButton.vue'
3
+
4
+ StarButton.install = function(Vue) {
5
+ Vue.component(StarButton.name, StarButton)
6
+ }
7
+
8
+ export default StarButton
@@ -0,0 +1,8 @@
1
+
2
+ import StarInput from './StarInput.vue'
3
+
4
+ StarInput.install = function(Vue) {
5
+ Vue.component(StarInput.name, StarInput)
6
+ }
7
+
8
+ export default StarInput
package/lib/index.js CHANGED
@@ -1,346 +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 \\n class="star-button"\\n :class="[\\n \`star-button--${type}\`,\\n \`star-button--${size}\`,\\n {\\n \'star-button--disabled\': disabled,\\n \'star-button--loading\': loading,\\n \'star-button--block\': block,\\n \'star-button--plain\': plain\\n }\\n ]"\\n :style="[customStyle]"\\n @click="handleClick"\\n >\\n <!-- 加载状态 -->\\n <view v-if="loading" class="star-button__loading">\\n <view class="star-button__loading-spinner"></view>\\n </view>\\n \\n <!-- 图标 -->\\n <text \\n v-if="icon && !loading" \\n class="star-button__icon" \\n :class="icon"\\n ></text>\\n \\n <!-- 文字内容 -->\\n <text class="star-button__text">\\n <slot></slot>\\n </text>\\n \\n <!-- 右侧图标 -->\\n <text \\n v-if="rightIcon && !loading" \\n class="star-button__right-icon" \\n :class="rightIcon"\\n ></text>\\n </view>',
2
+ // 自动导入所有组件
3
+ const components = []
13
4
 
14
- name: 'StarButton',
15
-
16
- // 为组件添加 install 方法,用于 Vue.use()
17
- install: function(Vue) {
18
- Vue.component(this.name, this)
19
- },
20
-
21
- // 组件属性定义
22
- props: {
23
- // 按钮类型
24
- type: {
25
- type: String,
26
- default: 'default',
27
- validator: (value) => {
28
- return ['default', 'primary', 'success', 'warning', 'error', 'info'].includes(value)
29
- }
30
- },
31
-
32
- // 按钮大小
33
- size: {
34
- type: String,
35
- default: 'medium',
36
- validator: (value) => {
37
- return ['mini', 'small', 'medium', 'large'].includes(value)
38
- }
39
- },
40
-
41
- // 是否禁用
42
- disabled: {
43
- type: Boolean,
44
- default: false
45
- },
46
-
47
- // 是否加载中
48
- loading: {
49
- type: Boolean,
50
- default: false
51
- },
52
-
53
- // 是否为朴素按钮
54
- plain: {
55
- type: Boolean,
56
- default: false
57
- },
58
-
59
- // 是否为块级按钮
60
- block: {
61
- type: Boolean,
62
- default: false
63
- },
64
-
65
- // 左侧图标
66
- icon: {
67
- type: String,
68
- default: ''
69
- },
70
-
71
- // 右侧图标
72
- rightIcon: {
73
- type: String,
74
- default: ''
75
- },
76
-
77
- // 自定义样式
78
- customStyle: {
79
- type: Object,
80
- default: () => ({})
81
- },
82
-
83
- // 点击防抖时间(毫秒)
84
- debounce: {
85
- type: Number,
86
- default: 0
87
- }
88
- },
89
-
90
- data() {
91
- return {
92
- canClick: true
93
- }
94
- },
95
-
96
- methods: {
97
- handleClick(event) {
98
- // 防抖处理
99
- if (!this.canClick) return
100
-
101
- if (this.debounce > 0) {
102
- this.canClick = false
103
- setTimeout(() => {
104
- this.canClick = true
105
- }, this.debounce)
106
- }
107
-
108
- // 触发点击事件
109
- if (!this.disabled && !this.loading) {
110
- this.$emit('click', event)
111
- }
112
- }
113
- }
114
- };
115
- StarButton.name = 'StarButton'; // 确保name属性存在
116
- StarButton.install = function(Vue) {
117
- Vue.component(StarButton.name, StarButton);
118
- };
119
-
120
- // Input 组件
121
- const StarInput = {
122
- template: '<view class="star-input" :class="inputClasses">\\n <!-- 前置内容 -->\\n <view v-if="$slots.prepend || prepend" class="star-input__prepend">\\n <slot name="prepend">\\n <text v-if="prepend" class="star-input__prepend-text">{{ prepend }}</text>\\n </slot>\\n </view>\\n \\n <!-- 输入框主体 -->\\n <view class="star-input__wrapper">\\n <!-- 前置图标 -->\\n <text \\n v-if="prefixIcon" \\n class="star-input__prefix-icon" \\n :class="prefixIcon"\\n @click="handlePrefixIconClick"\\n ></text>\\n \\n <!-- 输入框 -->\\n <input\\n class="star-input__inner"\\n :type="showPassword ? (passwordVisible ? \'text\' : \'password\') : type"\\n :value="currentValue"\\n :placeholder="placeholder"\\n :disabled="disabled"\\n :maxlength="maxlength"\\n :focus="focus"\\n :confirm-type="confirmType"\\n :placeholder-style="placeholderStyle"\\n :placeholder-class="placeholderClass"\\n :cursor-spacing="cursorSpacing"\\n @input="handleInput"\\n @focus="handleFocus"\\n @blur="handleBlur"\\n @confirm="handleConfirm"\\n @keyboardheightchange="handleKeyboardHeightChange"\\n />\\n \\n <!-- 清除按钮 -->\\n <view \\n v-if="clearable && currentValue && !disabled" \\n class="star-input__clear"\\n @click="handleClear"\\n >\\n <text class="star-icon-close"></text>\\n </view>\\n \\n <!-- 密码可见切换按钮 -->\\n <view \\n v-if="showPassword && currentValue" \\n class="star-input__password-toggle"\\n @click="togglePasswordVisible"\\n >\\n <text :class="passwordVisible ? \'star-icon-eye-open\' : \'star-icon-eye-close\'"></text>\\n </view>\\n \\n <!-- 后置图标 -->\\n <text \\n v-if="suffixIcon" \\n class="star-input__suffix-icon" \\n :class="suffixIcon"\\n @click="handleSuffixIconClick"\\n ></text>\\n </view>\\n \\n <!-- 后置内容 -->\\n <view v-if="$slots.append || append" class="star-input__append">\\n <slot name="append">\\n <text v-if="append" class="star-input__append-text">{{ append }}</text>\\n </slot>\\n </view>\\n </view>',
123
-
124
- name: 'StarInput',
125
-
126
- // 为组件添加 install 方法,用于 Vue.use()
127
- install: function(Vue) {
128
- Vue.component(this.name, this)
129
- },
130
-
131
- props: {
132
- // 输入框类型
133
- type: {
134
- type: String,
135
- default: 'text'
136
- },
137
-
138
- // 绑定值
139
- value: {
140
- type: [String, Number],
141
- default: ''
142
- },
143
-
144
- // 原生属性
145
- placeholder: {
146
- type: String,
147
- default: ''
148
- },
149
-
150
- disabled: {
151
- type: Boolean,
152
- default: false
153
- },
154
-
155
- maxlength: {
156
- type: [String, Number],
157
- default: 140
158
- },
159
-
160
- focus: {
161
- type: Boolean,
162
- default: false
163
- },
164
-
165
- confirmType: {
166
- type: String,
167
- default: 'done'
168
- },
169
-
170
- placeholderStyle: {
171
- type: String,
172
- default: ''
173
- },
174
-
175
- placeholderClass: {
176
- type: String,
177
- default: ''
178
- },
179
-
180
- cursorSpacing: {
181
- type: [String, Number],
182
- default: 0
183
- },
184
-
185
- // 自定义属性
186
- size: {
187
- type: String,
188
- default: 'medium',
189
- validator: (value) => ['mini', 'small', 'medium', 'large'].includes(value)
190
- },
191
-
192
- clearable: {
193
- type: Boolean,
194
- default: false
195
- },
196
-
197
- showPassword: {
198
- type: Boolean,
199
- default: false
200
- },
201
-
202
- prefixIcon: {
203
- type: String,
204
- default: ''
205
- },
206
-
207
- suffixIcon: {
208
- type: String,
209
- default: ''
210
- },
211
-
212
- prepend: {
213
- type: String,
214
- default: ''
215
- },
216
-
217
- append: {
218
- type: String,
219
- default: ''
220
- },
221
-
222
- readonly: {
223
- type: Boolean,
224
- default: false
225
- }
226
- },
5
+ const install = function(Vue, opts = {}) {
6
+ components.forEach(component => {
7
+ Vue.component(component.name, component)
8
+ })
227
9
 
228
- data() {
229
- return {
230
- currentValue: this.value,
231
- isFocused: false,
232
- passwordVisible: false
233
- }
234
- },
235
-
236
- computed: {
237
- inputClasses() {
238
- return [
239
- `star-input--${this.size}`,
240
- {
241
- 'star-input--disabled': this.disabled,
242
- 'star-input--focused': this.isFocused,
243
- 'star-input--with-prepend': this.prepend || this.$slots.prepend,
244
- 'star-input--with-append': this.append || this.$slots.append,
245
- 'star-input--readonly': this.readonly
246
- }
247
- ]
248
- }
249
- },
250
-
251
- watch: {
252
- value(newVal) {
253
- this.currentValue = newVal
254
- }
255
- },
256
-
257
- methods: {
258
- handleInput(event) {
259
- const value = event.detail.value
260
- this.currentValue = value
261
- this.$emit('input', value)
262
- this.$emit('change', value)
263
- },
264
-
265
- handleFocus(event) {
266
- this.isFocused = true
267
- this.$emit('focus', event)
268
- },
269
-
270
- handleBlur(event) {
271
- this.isFocused = false
272
- this.$emit('blur', event)
273
- },
274
-
275
- handleConfirm(event) {
276
- this.$emit('confirm', event)
277
- },
278
-
279
- handleKeyboardHeightChange(event) {
280
- this.$emit('keyboardheightchange', event)
281
- },
282
-
283
- handleClear() {
284
- this.currentValue = ''
285
- this.$emit('input', '')
286
- this.$emit('change', '')
287
- this.$emit('clear')
288
- },
289
-
290
- togglePasswordVisible() {
291
- this.passwordVisible = !this.passwordVisible
292
- },
293
-
294
- handlePrefixIconClick() {
295
- this.$emit('click-prefix')
296
- },
297
-
298
- handleSuffixIconClick() {
299
- this.$emit('click-suffix')
300
- }
10
+ // 挂载全局方法
11
+ Vue.prototype.$MY_UI = {
12
+ size: opts.size || '',
13
+ zIndex: opts.zIndex || 2000
301
14
  }
302
- };
303
- StarInput.name = 'StarInput'; // 确保name属性存在
304
- StarInput.install = function(Vue) {
305
- Vue.component(StarInput.name, StarInput);
306
- };
307
-
308
-
309
- // 组件列表
310
- const components = [
311
- StarButton,
312
- StarInput
313
- ];
314
-
315
- // 安装函数
316
- const install = function(Vue, opts = {}) {
317
- components.forEach(component => {
318
- // 直接注册组件,确保name属性存在
319
- if (component.name) {
320
- Vue.component(component.name, component);
321
- }
322
- });
323
-
324
- // 挂载全局方法
325
- Vue.prototype.$MY_UI = {
326
- size: opts.size || '',
327
- zIndex: opts.zIndex || 2000
328
- };
329
- };
330
-
331
- // 如果是浏览器环境且已引入Vue,则自动安装
332
- if (typeof window !== 'undefined' && window.Vue) {
333
- install(window.Vue);
334
- }
335
-
336
- // 创建导出对象
337
- const StarUI = {
338
- version: '0.1.7',
339
- install,
340
- // 导出所有组件
341
- StarButton,
342
- StarInput
343
- };
344
-
345
- return StarUI;
346
- })));
15
+ }
16
+
17
+ // 如果是浏览器环境且已引入Vue,则自动安装
18
+ if (typeof window !== 'undefined' && window.Vue) {
19
+ install(window.Vue)
20
+ }
21
+
22
+ export default {
23
+ version: '0.1.9',
24
+ install,
25
+ // 按需导出所有组件
26
+ StarButton: require('./components/StarButton').default,
27
+ StarInput: require('./components/StarInput').default
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@star-ai/star-ui",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "基于Uniapp的Vue2组件库",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
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/Button.vue'
6
- import StarInput from './components/Input/Input.vue'
5
+ import StarButton from './components/StarButton/StarButton.vue'
6
+ import StarInput from './components/StarInput/StarInput.vue'
7
7
 
8
8
  // 组件列表
9
9
  const components = [
@@ -14,56 +14,16 @@ const components = [
14
14
  // 安装函数
15
15
  const install = function(Vue, opts = {}) {
16
16
  components.forEach(component => {
17
- // 如果组件有install方法,使用install方法注册
18
- if (component.install) {
17
+ if(component.install) {
19
18
  Vue.use(component)
20
- }
21
- // 如果组件是Vue组件对象,直接注册
22
- else if (component.name) {
19
+ } else if (component.name) {
23
20
  Vue.component(component.name, component)
24
21
  }
25
22
  })
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
23
  }
38
24
 
39
25
  // 创建导出对象
40
- const StarUI = {
26
+ export default {
41
27
  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 }
28
+ install
29
+ }
package/lib/index.esm.js DELETED
@@ -1,341 +0,0 @@
1
- // ES模块入口文件
2
- // 组件定义
3
-
4
- // Button 组件
5
- const StarButton = {
6
- template: '<view \\n class="star-button"\\n :class="[\\n \`star-button--${type}\`,\\n \`star-button--${size}\`,\\n {\\n \'star-button--disabled\': disabled,\\n \'star-button--loading\': loading,\\n \'star-button--block\': block,\\n \'star-button--plain\': plain\\n }\\n ]"\\n :style="[customStyle]"\\n @click="handleClick"\\n >\\n <!-- 加载状态 -->\\n <view v-if="loading" class="star-button__loading">\\n <view class="star-button__loading-spinner"></view>\\n </view>\\n \\n <!-- 图标 -->\\n <text \\n v-if="icon && !loading" \\n class="star-button__icon" \\n :class="icon"\\n ></text>\\n \\n <!-- 文字内容 -->\\n <text class="star-button__text">\\n <slot></slot>\\n </text>\\n \\n <!-- 右侧图标 -->\\n <text \\n v-if="rightIcon && !loading" \\n class="star-button__right-icon" \\n :class="rightIcon"\\n ></text>\\n </view>',
7
-
8
- name: 'StarButton',
9
-
10
- // 为组件添加 install 方法,用于 Vue.use()
11
- install: function(Vue) {
12
- Vue.component(this.name, this)
13
- },
14
-
15
- // 组件属性定义
16
- props: {
17
- // 按钮类型
18
- type: {
19
- type: String,
20
- default: 'default',
21
- validator: (value) => {
22
- return ['default', 'primary', 'success', 'warning', 'error', 'info'].includes(value)
23
- }
24
- },
25
-
26
- // 按钮大小
27
- size: {
28
- type: String,
29
- default: 'medium',
30
- validator: (value) => {
31
- return ['mini', 'small', 'medium', 'large'].includes(value)
32
- }
33
- },
34
-
35
- // 是否禁用
36
- disabled: {
37
- type: Boolean,
38
- default: false
39
- },
40
-
41
- // 是否加载中
42
- loading: {
43
- type: Boolean,
44
- default: false
45
- },
46
-
47
- // 是否为朴素按钮
48
- plain: {
49
- type: Boolean,
50
- default: false
51
- },
52
-
53
- // 是否为块级按钮
54
- block: {
55
- type: Boolean,
56
- default: false
57
- },
58
-
59
- // 左侧图标
60
- icon: {
61
- type: String,
62
- default: ''
63
- },
64
-
65
- // 右侧图标
66
- rightIcon: {
67
- type: String,
68
- default: ''
69
- },
70
-
71
- // 自定义样式
72
- customStyle: {
73
- type: Object,
74
- default: () => ({})
75
- },
76
-
77
- // 点击防抖时间(毫秒)
78
- debounce: {
79
- type: Number,
80
- default: 0
81
- }
82
- },
83
-
84
- data() {
85
- return {
86
- canClick: true
87
- }
88
- },
89
-
90
- methods: {
91
- handleClick(event) {
92
- // 防抖处理
93
- if (!this.canClick) return
94
-
95
- if (this.debounce > 0) {
96
- this.canClick = false
97
- setTimeout(() => {
98
- this.canClick = true
99
- }, this.debounce)
100
- }
101
-
102
- // 触发点击事件
103
- if (!this.disabled && !this.loading) {
104
- this.$emit('click', event)
105
- }
106
- }
107
- }
108
- };
109
- StarButton.name = 'StarButton'; // 确保name属性存在
110
- StarButton.install = function(Vue) {
111
- Vue.component(StarButton.name, StarButton);
112
- };
113
-
114
- // Input 组件
115
- const StarInput = {
116
- template: '<view class="star-input" :class="inputClasses">\\n <!-- 前置内容 -->\\n <view v-if="$slots.prepend || prepend" class="star-input__prepend">\\n <slot name="prepend">\\n <text v-if="prepend" class="star-input__prepend-text">{{ prepend }}</text>\\n </slot>\\n </view>\\n \\n <!-- 输入框主体 -->\\n <view class="star-input__wrapper">\\n <!-- 前置图标 -->\\n <text \\n v-if="prefixIcon" \\n class="star-input__prefix-icon" \\n :class="prefixIcon"\\n @click="handlePrefixIconClick"\\n ></text>\\n \\n <!-- 输入框 -->\\n <input\\n class="star-input__inner"\\n :type="showPassword ? (passwordVisible ? \'text\' : \'password\') : type"\\n :value="currentValue"\\n :placeholder="placeholder"\\n :disabled="disabled"\\n :maxlength="maxlength"\\n :focus="focus"\\n :confirm-type="confirmType"\\n :placeholder-style="placeholderStyle"\\n :placeholder-class="placeholderClass"\\n :cursor-spacing="cursorSpacing"\\n @input="handleInput"\\n @focus="handleFocus"\\n @blur="handleBlur"\\n @confirm="handleConfirm"\\n @keyboardheightchange="handleKeyboardHeightChange"\\n />\\n \\n <!-- 清除按钮 -->\\n <view \\n v-if="clearable && currentValue && !disabled" \\n class="star-input__clear"\\n @click="handleClear"\\n >\\n <text class="star-icon-close"></text>\\n </view>\\n \\n <!-- 密码可见切换按钮 -->\\n <view \\n v-if="showPassword && currentValue" \\n class="star-input__password-toggle"\\n @click="togglePasswordVisible"\\n >\\n <text :class="passwordVisible ? \'star-icon-eye-open\' : \'star-icon-eye-close\'"></text>\\n </view>\\n \\n <!-- 后置图标 -->\\n <text \\n v-if="suffixIcon" \\n class="star-input__suffix-icon" \\n :class="suffixIcon"\\n @click="handleSuffixIconClick"\\n ></text>\\n </view>\\n \\n <!-- 后置内容 -->\\n <view v-if="$slots.append || append" class="star-input__append">\\n <slot name="append">\\n <text v-if="append" class="star-input__append-text">{{ append }}</text>\\n </slot>\\n </view>\\n </view>',
117
-
118
- name: 'StarInput',
119
-
120
- // 为组件添加 install 方法,用于 Vue.use()
121
- install: function(Vue) {
122
- Vue.component(this.name, this)
123
- },
124
-
125
- props: {
126
- // 输入框类型
127
- type: {
128
- type: String,
129
- default: 'text'
130
- },
131
-
132
- // 绑定值
133
- value: {
134
- type: [String, Number],
135
- default: ''
136
- },
137
-
138
- // 原生属性
139
- placeholder: {
140
- type: String,
141
- default: ''
142
- },
143
-
144
- disabled: {
145
- type: Boolean,
146
- default: false
147
- },
148
-
149
- maxlength: {
150
- type: [String, Number],
151
- default: 140
152
- },
153
-
154
- focus: {
155
- type: Boolean,
156
- default: false
157
- },
158
-
159
- confirmType: {
160
- type: String,
161
- default: 'done'
162
- },
163
-
164
- placeholderStyle: {
165
- type: String,
166
- default: ''
167
- },
168
-
169
- placeholderClass: {
170
- type: String,
171
- default: ''
172
- },
173
-
174
- cursorSpacing: {
175
- type: [String, Number],
176
- default: 0
177
- },
178
-
179
- // 自定义属性
180
- size: {
181
- type: String,
182
- default: 'medium',
183
- validator: (value) => ['mini', 'small', 'medium', 'large'].includes(value)
184
- },
185
-
186
- clearable: {
187
- type: Boolean,
188
- default: false
189
- },
190
-
191
- showPassword: {
192
- type: Boolean,
193
- default: false
194
- },
195
-
196
- prefixIcon: {
197
- type: String,
198
- default: ''
199
- },
200
-
201
- suffixIcon: {
202
- type: String,
203
- default: ''
204
- },
205
-
206
- prepend: {
207
- type: String,
208
- default: ''
209
- },
210
-
211
- append: {
212
- type: String,
213
- default: ''
214
- },
215
-
216
- readonly: {
217
- type: Boolean,
218
- default: false
219
- }
220
- },
221
-
222
- data() {
223
- return {
224
- currentValue: this.value,
225
- isFocused: false,
226
- passwordVisible: false
227
- }
228
- },
229
-
230
- computed: {
231
- inputClasses() {
232
- return [
233
- `star-input--${this.size}`,
234
- {
235
- 'star-input--disabled': this.disabled,
236
- 'star-input--focused': this.isFocused,
237
- 'star-input--with-prepend': this.prepend || this.$slots.prepend,
238
- 'star-input--with-append': this.append || this.$slots.append,
239
- 'star-input--readonly': this.readonly
240
- }
241
- ]
242
- }
243
- },
244
-
245
- watch: {
246
- value(newVal) {
247
- this.currentValue = newVal
248
- }
249
- },
250
-
251
- methods: {
252
- handleInput(event) {
253
- const value = event.detail.value
254
- this.currentValue = value
255
- this.$emit('input', value)
256
- this.$emit('change', value)
257
- },
258
-
259
- handleFocus(event) {
260
- this.isFocused = true
261
- this.$emit('focus', event)
262
- },
263
-
264
- handleBlur(event) {
265
- this.isFocused = false
266
- this.$emit('blur', event)
267
- },
268
-
269
- handleConfirm(event) {
270
- this.$emit('confirm', event)
271
- },
272
-
273
- handleKeyboardHeightChange(event) {
274
- this.$emit('keyboardheightchange', event)
275
- },
276
-
277
- handleClear() {
278
- this.currentValue = ''
279
- this.$emit('input', '')
280
- this.$emit('change', '')
281
- this.$emit('clear')
282
- },
283
-
284
- togglePasswordVisible() {
285
- this.passwordVisible = !this.passwordVisible
286
- },
287
-
288
- handlePrefixIconClick() {
289
- this.$emit('click-prefix')
290
- },
291
-
292
- handleSuffixIconClick() {
293
- this.$emit('click-suffix')
294
- }
295
- }
296
- };
297
- StarInput.name = 'StarInput'; // 确保name属性存在
298
- StarInput.install = function(Vue) {
299
- Vue.component(StarInput.name, StarInput);
300
- };
301
-
302
-
303
- // 组件列表
304
- const components = [
305
- StarButton,
306
- StarInput
307
- ];
308
-
309
- // 安装函数
310
- const install = function(Vue, opts = {}) {
311
- components.forEach(component => {
312
- // 直接注册组件,确保name属性存在
313
- if (component.name) {
314
- Vue.component(component.name, component);
315
- }
316
- });
317
-
318
- // 挂载全局方法
319
- Vue.prototype.$MY_UI = {
320
- size: opts.size || '',
321
- zIndex: opts.zIndex || 2000
322
- };
323
- };
324
-
325
- // 如果是浏览器环境且已引入Vue,则自动安装
326
- if (typeof window !== 'undefined' && window.Vue) {
327
- install(window.Vue);
328
- }
329
-
330
- // 创建导出对象
331
- const StarUI = {
332
- version: '0.1.7',
333
- install,
334
- // 导出所有组件
335
- StarButton,
336
- StarInput
337
- };
338
-
339
- export default StarUI;
340
- export const StarButton = StarButton;
341
- export const StarInput = StarInput;
package/lib/package.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "name": "@star-ai/star-ui",
3
- "version": "0.1.7",
4
- "description": "基于Uniapp的Vue2组件库",
5
- "main": "index.js",
6
- "module": "index.js",
7
- "browser": "star-ui.umd.js",
8
- "dependencies": {
9
- "@vue/shared": "^3.0.0",
10
- "core-js": "^3.8.3"
11
- },
12
- "peerDependencies": {
13
- "vue": ">= 2.6.14 < 4"
14
- },
15
- "keywords": [
16
- "uniapp",
17
- "vue2",
18
- "component",
19
- "ui",
20
- "mobile"
21
- ],
22
- "author": "DengChengBo",
23
- "license": "MIT",
24
- "repository": {
25
- "type": "git",
26
- "url": "git+https://gitee.com/chengboDeng/star-ui-library.git"
27
- }
28
- }
@@ -1,355 +0,0 @@
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
-
8
- // 组件定义
9
-
10
- // Button 组件
11
- const StarButton = {
12
- template: '<view \\n class="star-button"\\n :class="[\\n \`star-button--${type}\`,\\n \`star-button--${size}\`,\\n {\\n \'star-button--disabled\': disabled,\\n \'star-button--loading\': loading,\\n \'star-button--block\': block,\\n \'star-button--plain\': plain\\n }\\n ]"\\n :style="[customStyle]"\\n @click="handleClick"\\n >\\n <!-- 加载状态 -->\\n <view v-if="loading" class="star-button__loading">\\n <view class="star-button__loading-spinner"></view>\\n </view>\\n \\n <!-- 图标 -->\\n <text \\n v-if="icon && !loading" \\n class="star-button__icon" \\n :class="icon"\\n ></text>\\n \\n <!-- 文字内容 -->\\n <text class="star-button__text">\\n <slot></slot>\\n </text>\\n \\n <!-- 右侧图标 -->\\n <text \\n v-if="rightIcon && !loading" \\n class="star-button__right-icon" \\n :class="rightIcon"\\n ></text>\\n </view>',
13
-
14
- name: 'StarButton',
15
-
16
- // 为组件添加 install 方法,用于 Vue.use()
17
- install: function(Vue) {
18
- Vue.component(this.name, this)
19
- },
20
-
21
- // 组件属性定义
22
- props: {
23
- // 按钮类型
24
- type: {
25
- type: String,
26
- default: 'default',
27
- validator: (value) => {
28
- return ['default', 'primary', 'success', 'warning', 'error', 'info'].includes(value)
29
- }
30
- },
31
-
32
- // 按钮大小
33
- size: {
34
- type: String,
35
- default: 'medium',
36
- validator: (value) => {
37
- return ['mini', 'small', 'medium', 'large'].includes(value)
38
- }
39
- },
40
-
41
- // 是否禁用
42
- disabled: {
43
- type: Boolean,
44
- default: false
45
- },
46
-
47
- // 是否加载中
48
- loading: {
49
- type: Boolean,
50
- default: false
51
- },
52
-
53
- // 是否为朴素按钮
54
- plain: {
55
- type: Boolean,
56
- default: false
57
- },
58
-
59
- // 是否为块级按钮
60
- block: {
61
- type: Boolean,
62
- default: false
63
- },
64
-
65
- // 左侧图标
66
- icon: {
67
- type: String,
68
- default: ''
69
- },
70
-
71
- // 右侧图标
72
- rightIcon: {
73
- type: String,
74
- default: ''
75
- },
76
-
77
- // 自定义样式
78
- customStyle: {
79
- type: Object,
80
- default: () => ({})
81
- },
82
-
83
- // 点击防抖时间(毫秒)
84
- debounce: {
85
- type: Number,
86
- default: 0
87
- }
88
- },
89
-
90
- data() {
91
- return {
92
- canClick: true
93
- }
94
- },
95
-
96
- methods: {
97
- handleClick(event) {
98
- // 防抖处理
99
- if (!this.canClick) return
100
-
101
- if (this.debounce > 0) {
102
- this.canClick = false
103
- setTimeout(() => {
104
- this.canClick = true
105
- }, this.debounce)
106
- }
107
-
108
- // 触发点击事件
109
- if (!this.disabled && !this.loading) {
110
- this.$emit('click', event)
111
- }
112
- }
113
- }
114
- };
115
- StarButton.install = function(Vue) {
116
- Vue.component(StarButton.name, StarButton);
117
- };
118
-
119
- // Input 组件
120
- const StarInput = {
121
- template: '<view class="star-input" :class="inputClasses">\\n <!-- 前置内容 -->\\n <view v-if="$slots.prepend || prepend" class="star-input__prepend">\\n <slot name="prepend">\\n <text v-if="prepend" class="star-input__prepend-text">{{ prepend }}</text>\\n </slot>\\n </view>\\n \\n <!-- 输入框主体 -->\\n <view class="star-input__wrapper">\\n <!-- 前置图标 -->\\n <text \\n v-if="prefixIcon" \\n class="star-input__prefix-icon" \\n :class="prefixIcon"\\n @click="handlePrefixIconClick"\\n ></text>\\n \\n <!-- 输入框 -->\\n <input\\n class="star-input__inner"\\n :type="showPassword ? (passwordVisible ? \'text\' : \'password\') : type"\\n :value="currentValue"\\n :placeholder="placeholder"\\n :disabled="disabled"\\n :maxlength="maxlength"\\n :focus="focus"\\n :confirm-type="confirmType"\\n :placeholder-style="placeholderStyle"\\n :placeholder-class="placeholderClass"\\n :cursor-spacing="cursorSpacing"\\n @input="handleInput"\\n @focus="handleFocus"\\n @blur="handleBlur"\\n @confirm="handleConfirm"\\n @keyboardheightchange="handleKeyboardHeightChange"\\n />\\n \\n <!-- 清除按钮 -->\\n <view \\n v-if="clearable && currentValue && !disabled" \\n class="star-input__clear"\\n @click="handleClear"\\n >\\n <text class="star-icon-close"></text>\\n </view>\\n \\n <!-- 密码可见切换按钮 -->\\n <view \\n v-if="showPassword && currentValue" \\n class="star-input__password-toggle"\\n @click="togglePasswordVisible"\\n >\\n <text :class="passwordVisible ? \'star-icon-eye-open\' : \'star-icon-eye-close\'"></text>\\n </view>\\n \\n <!-- 后置图标 -->\\n <text \\n v-if="suffixIcon" \\n class="star-input__suffix-icon" \\n :class="suffixIcon"\\n @click="handleSuffixIconClick"\\n ></text>\\n </view>\\n \\n <!-- 后置内容 -->\\n <view v-if="$slots.append || append" class="star-input__append">\\n <slot name="append">\\n <text v-if="append" class="star-input__append-text">{{ append }}</text>\\n </slot>\\n </view>\\n </view>',
122
-
123
- name: 'StarInput',
124
-
125
- // 为组件添加 install 方法,用于 Vue.use()
126
- install: function(Vue) {
127
- Vue.component(this.name, this)
128
- },
129
-
130
- props: {
131
- // 输入框类型
132
- type: {
133
- type: String,
134
- default: 'text'
135
- },
136
-
137
- // 绑定值
138
- value: {
139
- type: [String, Number],
140
- default: ''
141
- },
142
-
143
- // 原生属性
144
- placeholder: {
145
- type: String,
146
- default: ''
147
- },
148
-
149
- disabled: {
150
- type: Boolean,
151
- default: false
152
- },
153
-
154
- maxlength: {
155
- type: [String, Number],
156
- default: 140
157
- },
158
-
159
- focus: {
160
- type: Boolean,
161
- default: false
162
- },
163
-
164
- confirmType: {
165
- type: String,
166
- default: 'done'
167
- },
168
-
169
- placeholderStyle: {
170
- type: String,
171
- default: ''
172
- },
173
-
174
- placeholderClass: {
175
- type: String,
176
- default: ''
177
- },
178
-
179
- cursorSpacing: {
180
- type: [String, Number],
181
- default: 0
182
- },
183
-
184
- // 自定义属性
185
- size: {
186
- type: String,
187
- default: 'medium',
188
- validator: (value) => ['mini', 'small', 'medium', 'large'].includes(value)
189
- },
190
-
191
- clearable: {
192
- type: Boolean,
193
- default: false
194
- },
195
-
196
- showPassword: {
197
- type: Boolean,
198
- default: false
199
- },
200
-
201
- prefixIcon: {
202
- type: String,
203
- default: ''
204
- },
205
-
206
- suffixIcon: {
207
- type: String,
208
- default: ''
209
- },
210
-
211
- prepend: {
212
- type: String,
213
- default: ''
214
- },
215
-
216
- append: {
217
- type: String,
218
- default: ''
219
- },
220
-
221
- readonly: {
222
- type: Boolean,
223
- default: false
224
- }
225
- },
226
-
227
- data() {
228
- return {
229
- currentValue: this.value,
230
- isFocused: false,
231
- passwordVisible: false
232
- }
233
- },
234
-
235
- computed: {
236
- inputClasses() {
237
- return [
238
- `star-input--${this.size}`,
239
- {
240
- 'star-input--disabled': this.disabled,
241
- 'star-input--focused': this.isFocused,
242
- 'star-input--with-prepend': this.prepend || this.$slots.prepend,
243
- 'star-input--with-append': this.append || this.$slots.append,
244
- 'star-input--readonly': this.readonly
245
- }
246
- ]
247
- }
248
- },
249
-
250
- watch: {
251
- value(newVal) {
252
- this.currentValue = newVal
253
- }
254
- },
255
-
256
- methods: {
257
- handleInput(event) {
258
- const value = event.detail.value
259
- this.currentValue = value
260
- this.$emit('input', value)
261
- this.$emit('change', value)
262
- },
263
-
264
- handleFocus(event) {
265
- this.isFocused = true
266
- this.$emit('focus', event)
267
- },
268
-
269
- handleBlur(event) {
270
- this.isFocused = false
271
- this.$emit('blur', event)
272
- },
273
-
274
- handleConfirm(event) {
275
- this.$emit('confirm', event)
276
- },
277
-
278
- handleKeyboardHeightChange(event) {
279
- this.$emit('keyboardheightchange', event)
280
- },
281
-
282
- handleClear() {
283
- this.currentValue = ''
284
- this.$emit('input', '')
285
- this.$emit('change', '')
286
- this.$emit('clear')
287
- },
288
-
289
- togglePasswordVisible() {
290
- this.passwordVisible = !this.passwordVisible
291
- },
292
-
293
- handlePrefixIconClick() {
294
- this.$emit('click-prefix')
295
- },
296
-
297
- handleSuffixIconClick() {
298
- this.$emit('click-suffix')
299
- }
300
- }
301
- };
302
- StarInput.install = function(Vue) {
303
- Vue.component(StarInput.name, StarInput);
304
- };
305
-
306
-
307
- // 组件列表
308
- const components = [
309
- StarButton,
310
- StarInput
311
- ];
312
-
313
- // 安装函数
314
- const install = function(Vue, opts = {}) {
315
- components.forEach(component => {
316
- // 如果组件有install方法,使用install方法注册
317
- if (component.install) {
318
- Vue.use(component);
319
- }
320
- // 如果组件是Vue组件对象,直接注册
321
- else if (component.name) {
322
- Vue.component(component.name, component);
323
- }
324
- });
325
-
326
- // 挂载全局方法
327
- Vue.prototype.$MY_UI = {
328
- size: opts.size || '',
329
- zIndex: opts.zIndex || 2000
330
- };
331
- };
332
-
333
- // 如果是浏览器环境且已引入Vue,则自动安装
334
- if (typeof window !== 'undefined' && window.Vue) {
335
- install(window.Vue);
336
- }
337
-
338
- // 创建导出对象
339
- const StarUI = {
340
- version: '0.1.7',
341
- install,
342
- // 导出所有组件
343
- StarButton,
344
- StarInput
345
- };
346
-
347
- // 浏览器全局变量导出
348
- if (typeof window !== 'undefined') {
349
- window.StarUI = StarUI;
350
- window.StarButton = StarButton;
351
- window.StarInput = StarInput;
352
- }
353
-
354
- return StarUI;
355
- })));