@zfqh/uview-x 0.0.0-stage → 0.0.1

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 (93) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +127 -3
  4. package/components/uv-badge/props.ts +83 -0
  5. package/components/uv-badge/uv-badge.vue +186 -0
  6. package/components/uv-button/props.ts +148 -0
  7. package/components/uv-button/uv-button.vue +565 -0
  8. package/components/uv-checkbox/props.ts +83 -0
  9. package/components/uv-checkbox/uv-checkbox.vue +403 -0
  10. package/components/uv-checkbox-group/props.ts +97 -0
  11. package/components/uv-checkbox-group/uv-checkbox-group.vue +163 -0
  12. package/components/uv-code/props.ts +48 -0
  13. package/components/uv-code/uv-code.vue +156 -0
  14. package/components/uv-dialog/props.ts +56 -0
  15. package/components/uv-dialog/uv-dialog.vue +492 -0
  16. package/components/uv-form/props.ts +59 -0
  17. package/components/uv-form/uv-form.vue +256 -0
  18. package/components/uv-form/valid.ts +1344 -0
  19. package/components/uv-form-item/props.ts +62 -0
  20. package/components/uv-form-item/uv-form-item.vue +335 -0
  21. package/components/uv-icon/icons.ts +161 -0
  22. package/components/uv-icon/props.ts +91 -0
  23. package/components/uv-icon/uv-icon.vue +204 -0
  24. package/components/uv-icon/uvicons.ttf +0 -0
  25. package/components/uv-input/props.ts +185 -0
  26. package/components/uv-input/uv-input.vue +431 -0
  27. package/components/uv-line/props.ts +42 -0
  28. package/components/uv-line/uv-line.vue +75 -0
  29. package/components/uv-line-progress/props.ts +43 -0
  30. package/components/uv-line-progress/uv-line-progress.vue +166 -0
  31. package/components/uv-loading-icon/props.ts +78 -0
  32. package/components/uv-loading-icon/uv-loading-icon.vue +226 -0
  33. package/components/uv-overlay/props.ts +38 -0
  34. package/components/uv-overlay/uv-overlay.vue +120 -0
  35. package/components/uv-popup/props.ts +101 -0
  36. package/components/uv-popup/uv-popup.vue +371 -0
  37. package/components/uv-safe-bottom/props.ts +18 -0
  38. package/components/uv-safe-bottom/uv-safe-bottom.vue +120 -0
  39. package/components/uv-status-bar/props.ts +22 -0
  40. package/components/uv-status-bar/uv-status-bar.vue +121 -0
  41. package/components/uv-tabs/props.ts +84 -0
  42. package/components/uv-tabs/uv-tabs.vue +432 -0
  43. package/components/uv-transition/props.ts +38 -0
  44. package/components/uv-transition/uv-transition.vue +170 -0
  45. package/hooks/index.ts +5 -0
  46. package/hooks/useDebounce.ts +35 -0
  47. package/hooks/useI18n.ts +95 -0
  48. package/hooks/useThrottle.ts +38 -0
  49. package/index.ts +23 -0
  50. package/libs/dayjs/index.ts +217 -0
  51. package/libs/index.ts +4 -0
  52. package/libs/luch-request/adapters/index.ts +133 -0
  53. package/libs/luch-request/core/InterceptorManager.ts +52 -0
  54. package/libs/luch-request/core/Request.ts +202 -0
  55. package/libs/luch-request/core/buildFullPath.ts +21 -0
  56. package/libs/luch-request/core/defaults.ts +34 -0
  57. package/libs/luch-request/core/dispatchRequest.ts +7 -0
  58. package/libs/luch-request/core/mergeConfig.ts +127 -0
  59. package/libs/luch-request/core/settle.ts +17 -0
  60. package/libs/luch-request/helpers/buildURL.ts +65 -0
  61. package/libs/luch-request/helpers/combineURLs.ts +15 -0
  62. package/libs/luch-request/helpers/isAbsoluteURL.ts +15 -0
  63. package/libs/luch-request/index.d.ts +197 -0
  64. package/libs/luch-request/index.ts +3 -0
  65. package/libs/luch-request/utils/clone.ts +265 -0
  66. package/libs/luch-request/utils.ts +136 -0
  67. package/locales/en.ts +78 -0
  68. package/locales/index.ts +169 -0
  69. package/locales/zh-Hans.ts +78 -0
  70. package/package.json +42 -4
  71. package/styles/color.scss +33 -0
  72. package/styles/common.scss +134 -0
  73. package/styles/components.scss +19 -0
  74. package/styles/index.scss +7 -0
  75. package/styles/theme.scss +44 -0
  76. package/styles/var.module.scss +32 -0
  77. package/styles/vue.scss +39 -0
  78. package/theme.scss +2 -0
  79. package/types/index.d.ts +66 -0
  80. package/utils/colorGradient.ts +139 -0
  81. package/utils/compat.ts +165 -0
  82. package/utils/compress.ts +34 -0
  83. package/utils/config.ts +95 -0
  84. package/utils/debounce.ts +7 -0
  85. package/utils/digit.ts +157 -0
  86. package/utils/function.ts +771 -0
  87. package/utils/http.ts +5 -0
  88. package/utils/index.ts +57 -0
  89. package/utils/locale.ts +296 -0
  90. package/utils/platform.ts +71 -0
  91. package/utils/route.ts +142 -0
  92. package/utils/test.ts +256 -0
  93. package/utils/throttle.ts +7 -0
@@ -0,0 +1,431 @@
1
+ <template>
2
+ <view class="uv-input" :class="inputClass" :style="[wrapperStyle]">
3
+ <view class="uv-input__content">
4
+ <view class="uv-input__content__prefix-icon">
5
+ <slot name="prefix">
6
+ <uv-icon
7
+ v-if="p.prefixIcon"
8
+ :name="p.prefixIcon"
9
+ size="18"
10
+ :custom-style="p.prefixIconStyle"
11
+ ></uv-icon>
12
+ </slot>
13
+ </view>
14
+ <view class="uv-input__content__field-wrapper">
15
+ <input
16
+ ref="inputRef"
17
+ class="uv-input__content__field-wrapper__field"
18
+ :style="[inputStyle]"
19
+ :type="inputType"
20
+ :focus="p.focus"
21
+ :cursor="cursorValue"
22
+ :value="innerValue"
23
+ :disabled="p.disabled || p.readonly"
24
+ :maxlength="maxlengthValue"
25
+ :placeholder="placeholderValue"
26
+ :placeholder-style="placeholderStyleStr"
27
+ :placeholder-class="p.placeholderClass"
28
+ :confirm-type="p.confirmType"
29
+ :confirm-hold="p.confirmHold"
30
+ :hold-keyboard="p.holdKeyboard"
31
+ :cursor-spacing="cursorSpacingValue"
32
+ :adjust-position="p.adjustPosition"
33
+ :selection-end="selectionEndValue"
34
+ :selection-start="selectionStartValue"
35
+ :password="isPassword || undefined"
36
+ @input="onInput"
37
+ @blur="onBlur"
38
+ @focus="onFocus"
39
+ @confirm="onConfirm"
40
+ @keyboardheightchange="onkeyboardheightchange"
41
+ />
42
+ </view>
43
+ <view
44
+ v-if="isShowClear"
45
+ class="uv-input__content__clear"
46
+ @tap="onClear"
47
+ >
48
+ <uv-icon
49
+ name="close"
50
+ size="11"
51
+ color="#ffffff"
52
+ custom-style="line-height: 12px"
53
+ ></uv-icon>
54
+ </view>
55
+ <view class="uv-input__content__subfix-icon">
56
+ <slot name="suffix">
57
+ <uv-icon
58
+ v-if="p.suffixIcon"
59
+ :name="p.suffixIcon"
60
+ size="18"
61
+ :custom-style="p.suffixIconStyle"
62
+ ></uv-icon>
63
+ </slot>
64
+ </view>
65
+ </view>
66
+ </view>
67
+ </template>
68
+
69
+ <script setup lang="ts">
70
+ import { computed, inject, nextTick, ref, watch } from 'vue'
71
+ import { $uv } from '../../utils'
72
+ import props from './props'
73
+
74
+
75
+ defineOptions({
76
+ name: 'uv-input',
77
+ // #ifdef UNI-APP-X
78
+ styleIsolation: 'app-and-page',
79
+ // #endif
80
+ virtualHost: true,
81
+ })
82
+
83
+ /**
84
+ * Input 输入框
85
+ * @description 此组件为一个输入框,默认没有边框和样式,是专门为配合表单组件uv-form而设计的,利用它可以快速实现表单验证,输入内容,下拉选择等功能。
86
+ * @tutorial https://www.uvui.cn/components/input.html
87
+ * @property {String | Number} value 输入的值
88
+ * @property {String} type 输入框类型,见上方说明 ( 默认 'text' )
89
+ * @property {Boolean} disabled 是否禁用输入框 ( 默认 false )
90
+ * @property {String} disabledColor 禁用状态时的背景色( 默认 '#f5f7fa' )
91
+ * @property {Boolean} clearable 是否显示清除控件 ( 默认 false )
92
+ * @property {Boolean} password 是否密码类型 ( 默认 false )
93
+ * @property {String | Number} maxlength 最大输入长度,设置为 -1 的时候不限制最大长度 ( 默认 -1 )
94
+ * @property {String} placeholder 输入框为空时的占位符
95
+ * @property {String} placeholderClass 指定placeholder的样式类 ( 默认 'input-placeholder' )
96
+ * @property {String | Object} placeholderStyle 指定placeholder的样式,字符串/对象形式,如"color: red;"
97
+ * @property {String} confirmType 设置右下角按钮的文字,兼容性详见uni-app文档 ( 默认 'done' )
98
+ * @property {Boolean} confirmHold 点击键盘右下角按钮时是否保持键盘不收起,H5无效 ( 默认 false )
99
+ * @property {Boolean} holdKeyboard focus时,点击页面的时候不收起键盘,微信小程序有效 ( 默认 false )
100
+ * @property {Boolean} focus 自动获取焦点 ( 默认 false )
101
+ * @property {Boolean} autoBlur 键盘收起时,是否自动失去焦点(默认 false,App 端不支持,保留但不生效)
102
+ * @property {String | Number} cursor 指定focus时光标的位置( 默认 -1 )
103
+ * @property {String | Number} cursorSpacing 输入框聚焦时底部与键盘的距离 ( 默认 30 )
104
+ * @property {String | Number} selectionStart 光标起始位置,自动聚集时有效,需与selection-end搭配使用 ( 默认 -1 )
105
+ * @property {String | Number} selectionEnd 光标结束位置,自动聚集时有效,需与selection-start搭配使用 ( 默认 -1 )
106
+ * @property {Boolean} adjustPosition 键盘弹起时,是否自动上推页面 ( 默认 true )
107
+ * @property {String} inputAlign 输入框内容对齐方式( 默认 'left' )
108
+ * @property {String | Number} fontSize 输入框字体的大小 ( 默认 '15px' )
109
+ * @property {String} color 输入框字体颜色 ( 默认 '#303133' )
110
+ * @property {Function} formatter 内容式化函数
111
+ * @property {String} prefixIcon 输入框前置图标
112
+ * @property {String | Object} prefixIconStyle 前置图标样式,对象或字符串
113
+ * @property {String} suffixIcon 输入框后置图标
114
+ * @property {String | Object} suffixIconStyle 后置图标样式,对象或字符串
115
+ * @property {String} border 边框类型,surround-四周边框,bottom-底部边框,none-无边框 ( 默认 'surround' )
116
+ * @property {Boolean} readonly 是否只读 ( 默认 false )
117
+ * @property {String} shape 输入框形状,circle-圆形,square-方形 ( 默认 'square' )
118
+ * @property {Object} customStyle 定义需要用到的外部样式
119
+ * @property {Boolean} ignoreCompositionEvent 是否忽略组件内对文本合成系统事件的处理(App 端不支持,保留但不生效)
120
+ * @event {Function} input 输入时触发
121
+ * @event {Function} change 内容变化时触发
122
+ * @event {Function} focus 聚焦时触发
123
+ * @event {Function} blur 失焦时触发
124
+ * @event {Function} confirm 点击完成时触发
125
+ * @event {Function} clear 点击清空时触发
126
+ * @event {Function} keyboardheightchange 键盘高度变化时触发
127
+ * @example <uv-input v-model="value" :password="true" suffix-icon="lock-fill" />
128
+ */
129
+ const p = defineProps(props)
130
+
131
+ const emit = defineEmits([
132
+ 'input',
133
+ 'update:modelValue',
134
+ 'change',
135
+ 'focus',
136
+ 'blur',
137
+ 'confirm',
138
+ 'clear',
139
+ 'keyboardheightchange'
140
+ ])
141
+
142
+ // 输入框的值
143
+ const innerValue = ref<any>(p.modelValue !== '' ? p.modelValue : p.value)
144
+ const inputRef = ref<any>(null)
145
+ // 是否处于获得焦点状态
146
+ const focused = ref(false)
147
+ // 过滤处理方法
148
+ const innerFormatter = ref<any>((value: any) => value)
149
+
150
+ // 表单域上下文:用于触发表单校验(provide/inject 替代 $parent 链)
151
+ const formItemContext: any = inject('uv-form-item-context', null)
152
+
153
+ watch(
154
+ () => p.modelValue,
155
+ (newVal: any) => {
156
+ innerValue.value = newVal
157
+ }
158
+ )
159
+
160
+ watch(
161
+ () => p.value,
162
+ (newVal: any) => {
163
+ innerValue.value = newVal
164
+ }
165
+ )
166
+
167
+ // x 的 input type 无 password 枚举值,密码由 password 属性控制
168
+ const inputType = computed(() => (p.type === 'password' ? 'text' : p.type))
169
+
170
+ const isPassword = computed(() => p.password || p.type === 'password')
171
+
172
+ const maxlengthValue = computed(() => {
173
+ const maxlength = Number(p.maxlength)
174
+ return isNaN(maxlength) ? -1 : maxlength
175
+ })
176
+
177
+ const cursorValue = computed(() => {
178
+ const cursor = Number(p.cursor)
179
+ return isNaN(cursor) ? -1 : cursor
180
+ })
181
+
182
+ const cursorSpacingValue = computed(() => {
183
+ const cursorSpacing = Number(p.cursorSpacing)
184
+ return isNaN(cursorSpacing) ? 30 : cursorSpacing
185
+ })
186
+
187
+ const selectionStartValue = computed(() => {
188
+ const selectionStart = Number(p.selectionStart)
189
+ return isNaN(selectionStart) ? -1 : selectionStart
190
+ })
191
+
192
+ const selectionEndValue = computed(() => {
193
+ const selectionEnd = Number(p.selectionEnd)
194
+ return isNaN(selectionEnd) ? -1 : selectionEnd
195
+ })
196
+
197
+ const placeholderValue = computed(() => {
198
+ return p.placeholder === null || p.placeholder === undefined ? '' : String(p.placeholder)
199
+ })
200
+
201
+ const placeholderStyleStr = computed(() => $uv.addStyle(p.placeholderStyle, 'string'))
202
+
203
+ // 是否显示清除控件
204
+ const isShowClear = computed(() => {
205
+ return !!p.clearable && !p.readonly && focused.value && innerValue.value !== ''
206
+ })
207
+
208
+ // 组件的类名
209
+ const inputClass = computed(() => {
210
+ const classes: string[] = []
211
+ if (p.border === 'surround') {
212
+ classes.push('uv-border', 'uv-input--radius')
213
+ }
214
+ classes.push(`uv-input--${p.shape}`)
215
+ if (p.border === 'bottom') {
216
+ classes.push('uv-border-bottom', 'uv-input--no-radius')
217
+ }
218
+ if (p.customClass) classes.push(p.customClass)
219
+ return classes
220
+ })
221
+
222
+ // 组件的样式
223
+ const wrapperStyle = computed(() => {
224
+ const style: any = {}
225
+ // 禁用状态下,被背景色加上对应的样式
226
+ if (p.disabled) {
227
+ style.backgroundColor = p.disabledColor
228
+ }
229
+ // 无边框时,去除内边距
230
+ if (p.border === 'none') {
231
+ style.padding = '0'
232
+ } else {
233
+ // 由于uni-app的iOS开发者能力有限,导致需要分开写才有效
234
+ style.paddingTop = '6px'
235
+ style.paddingBottom = '6px'
236
+ style.paddingLeft = '9px'
237
+ style.paddingRight = '9px'
238
+ }
239
+ return $uv.deepMerge(style, $uv.addStyle(p.customStyle))
240
+ })
241
+
242
+ // 输入框的样式
243
+ const inputStyle = computed(() => {
244
+ const style: any = {
245
+ color: p.color,
246
+ fontSize: $uv.addUnit(p.fontSize),
247
+ textAlign: p.inputAlign
248
+ }
249
+ if (p.disabled || p.readonly) {
250
+ // #ifndef APP-NVUE
251
+ style['pointer-events'] = 'none'
252
+ // #endif
253
+ }
254
+ return style
255
+ })
256
+
257
+ // 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
258
+ const setFormatter = (e: any) => {
259
+ innerFormatter.value = e
260
+ }
261
+
262
+ // 当键盘输入时,触发input事件
263
+ const onInput = (e: any) => {
264
+ const value = (e && e.detail ? e.detail.value : '') || ''
265
+ // 格式化过滤方法
266
+ const formatter = p.formatter || innerFormatter.value
267
+ const formatValue = typeof formatter === 'function' ? formatter(value) : value
268
+ // 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在nextTick中重新赋予设置后的值才有效
269
+ innerValue.value = value
270
+ nextTick(() => {
271
+ innerValue.value = formatValue
272
+ valueChange()
273
+ })
274
+ }
275
+
276
+ // 输入框失去焦点时触发
277
+ const onBlur = (event: any) => {
278
+ const value = event && event.detail ? event.detail.value : ''
279
+ emit('blur', value)
280
+ // H5端的blur会先于点击清除控件的点击click事件触发,导致focused
281
+ // 瞬间为false,从而隐藏了清除控件而无法被点击到
282
+ $uv.sleep(100).then(() => {
283
+ focused.value = false
284
+ })
285
+ // 尝试调用uv-form的验证方法
286
+ if (formItemContext) formItemContext.validate('blur')
287
+ }
288
+
289
+ // 输入框聚焦时触发
290
+ const onFocus = () => {
291
+ focused.value = true
292
+ emit('focus')
293
+ }
294
+
295
+ // 点击完成按钮时触发
296
+ const onConfirm = () => {
297
+ emit('confirm', innerValue.value)
298
+ }
299
+
300
+ // 键盘高度发生变化的时候触发此事件
301
+ const onkeyboardheightchange = (e: any) => {
302
+ emit('keyboardheightchange', e)
303
+ }
304
+
305
+ // 内容发生变化,进行处理
306
+ const valueChange = () => {
307
+ const value = innerValue.value
308
+ nextTick(() => {
309
+ emit('input', value)
310
+ emit('update:modelValue', value)
311
+ emit('change', value)
312
+ // 尝试调用uv-form的验证方法
313
+ if (formItemContext) formItemContext.validate('change')
314
+ })
315
+ }
316
+
317
+ // 点击清除控件
318
+ const onClear = () => {
319
+ innerValue.value = ''
320
+ valueChange()
321
+ nextTick(() => {
322
+ emit('clear')
323
+ })
324
+ }
325
+
326
+ const focus = () => {
327
+ inputRef.value?.focus?.()
328
+ }
329
+
330
+ const blur = () => {
331
+ inputRef.value?.blur?.()
332
+ }
333
+
334
+ defineExpose({
335
+ setFormatter,
336
+ focus,
337
+ blur
338
+ })
339
+ </script>
340
+
341
+ <style lang="scss">
342
+ @import '../../styles/components.scss';
343
+ @import '../../styles/color.scss';
344
+
345
+ .uv-input {
346
+ /* #ifndef APP-NVUE */
347
+ display: flex;
348
+ /* #endif */
349
+ flex-direction: row;
350
+ align-items: center;
351
+ justify-content: space-between;
352
+ flex: 1;
353
+ }
354
+
355
+ .uv-input--radius,
356
+ .uv-input--square {
357
+ border-top-left-radius: 4px;
358
+ border-top-right-radius: 4px;
359
+ border-bottom-left-radius: 4px;
360
+ border-bottom-right-radius: 4px;
361
+ }
362
+
363
+ .uv-input--no-radius {
364
+ border-top-left-radius: 0;
365
+ border-top-right-radius: 0;
366
+ border-bottom-left-radius: 0;
367
+ border-bottom-right-radius: 0;
368
+ }
369
+
370
+ .uv-input--circle {
371
+ border-top-left-radius: 100px;
372
+ border-top-right-radius: 100px;
373
+ border-bottom-left-radius: 100px;
374
+ border-bottom-right-radius: 100px;
375
+ }
376
+
377
+ .uv-input__content {
378
+ /* #ifndef APP-NVUE */
379
+ display: flex;
380
+ /* #endif */
381
+ flex-direction: row;
382
+ flex: 1;
383
+ align-items: center;
384
+ justify-content: space-between;
385
+ }
386
+
387
+ .uv-input__content__field-wrapper {
388
+ /* #ifndef APP-NVUE */
389
+ display: flex;
390
+ /* #endif */
391
+ flex-direction: row;
392
+ position: relative;
393
+ margin: 0;
394
+ flex: 1;
395
+ }
396
+
397
+ .uv-input__content__field-wrapper__field {
398
+ line-height: 26px;
399
+ text-align: left;
400
+ color: $uv-main-color;
401
+ height: 24px;
402
+ font-size: 15px;
403
+ flex: 1;
404
+ }
405
+
406
+ .uv-input__content__clear {
407
+ width: 20px;
408
+ height: 20px;
409
+ border-top-left-radius: 100px;
410
+ border-top-right-radius: 100px;
411
+ border-bottom-left-radius: 100px;
412
+ border-bottom-right-radius: 100px;
413
+ background-color: #c6c7cb;
414
+ /* #ifndef APP-NVUE */
415
+ display: flex;
416
+ /* #endif */
417
+ flex-direction: row;
418
+ align-items: center;
419
+ justify-content: center;
420
+ transform: scale(0.82);
421
+ margin-left: 15px;
422
+ }
423
+
424
+ .uv-input__content__subfix-icon {
425
+ margin-left: 4px;
426
+ }
427
+
428
+ .uv-input__content__prefix-icon {
429
+ margin-right: 4px;
430
+ }
431
+ </style>
@@ -0,0 +1,42 @@
1
+ // @ts-nocheck
2
+
3
+ import config from '../../utils/config';
4
+
5
+ const props = {
6
+ color: {
7
+ type: String,
8
+ default: '#d6d7d9',
9
+ },
10
+ length: {
11
+ type: [String, Number],
12
+ default: '100%',
13
+ },
14
+ direction: {
15
+ type: String,
16
+ default: 'row',
17
+ },
18
+ hairline: {
19
+ type: Boolean,
20
+ default: true,
21
+ },
22
+ margin: {
23
+ type: [String, Number],
24
+ default: 0,
25
+ },
26
+ dashed: {
27
+ type: Boolean,
28
+ default: false,
29
+ },
30
+ customStyle: {
31
+ type: [Object, String],
32
+ default: () => ({}),
33
+ },
34
+ customClass: {
35
+ type: String,
36
+ default: '',
37
+ },
38
+
39
+ ...config.props.line,
40
+ };
41
+
42
+ export default props;
@@ -0,0 +1,75 @@
1
+ <template>
2
+ <view
3
+ class="uv-line"
4
+ :class="[p.customClass]"
5
+ :style="[lineStyle]"
6
+ ></view>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { computed } from 'vue'
11
+ import { $uv } from '../../utils'
12
+ import props from './props'
13
+
14
+ defineOptions({
15
+ name: 'uv-line',
16
+ // #ifdef UNI-APP-X
17
+ styleIsolation: 'app-and-page',
18
+ // #endif
19
+ virtualHost: true,
20
+ })
21
+
22
+ /**
23
+ * line 线条
24
+ * @description 此组件一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单
25
+ * @tutorial https://www.uvui.cn/components/line.html
26
+ * @property {String} color 线条的颜色 ( 默认 '#d6d7d9' )
27
+ * @property {String | Number} length 长度,竖向时表现为高度,横向时表现为长度,可以为百分比,带px单位的值等 ( 默认 '100%' )
28
+ * @property {String} direction 线条的方向,row-横向,col-竖向 (默认 'row' )
29
+ * @property {Boolean} hairline 是否显示细线条 (默认 true )
30
+ * @property {String | Number} margin 线条与上下左右元素的间距,字符串形式,如"30px" (默认 0 )
31
+ * @property {Boolean} dashed 是否虚线,true-虚线,false-实线 (默认 false )
32
+ * @property {Object} customStyle 定义需要用到的外部样式
33
+ * @example <uv-line color="red"></uv-line>
34
+ */
35
+ const p = defineProps(props)
36
+
37
+ const lineStyle = computed(() => {
38
+ const style: any = {}
39
+ style.margin = p.margin
40
+ const isPercent = typeof p.length === 'string' && p.length.indexOf('%') > -1
41
+ if (p.direction === 'row') {
42
+ style.borderBottomWidth = '1px'
43
+ style.borderBottomStyle = p.dashed ? 'dashed' : 'solid'
44
+ if (!isPercent) {
45
+ style.width = $uv.addUnit(p.length)
46
+ } else {
47
+ // #ifndef APP-NVUE
48
+ style.width = $uv.addUnit(p.length)
49
+ // #endif
50
+ }
51
+ if (p.hairline) style.transform = 'scaleY(0.5)'
52
+ } else {
53
+ style.borderLeftWidth = '1px'
54
+ style.borderLeftStyle = p.dashed ? 'dashed' : 'solid'
55
+ if (!isPercent) {
56
+ style.height = $uv.addUnit(p.length)
57
+ } else {
58
+ // #ifndef APP-NVUE
59
+ style.height = $uv.addUnit(p.length)
60
+ // #endif
61
+ }
62
+ if (p.hairline) style.transform = 'scaleX(0.5)'
63
+ }
64
+ style.borderColor = p.color
65
+ return $uv.deepMerge(style, $uv.addStyle(p.customStyle))
66
+ })
67
+ </script>
68
+
69
+ <style lang="scss">
70
+ .uv-line {
71
+ /* #ifndef APP-NVUE */
72
+ flex-shrink: 0;
73
+ /* #endif */
74
+ }
75
+ </style>
@@ -0,0 +1,43 @@
1
+ // @ts-nocheck
2
+
3
+ import config from '../../utils/config';
4
+
5
+ const props = {
6
+ // 激活部分的颜色
7
+ activeColor: {
8
+ type: String,
9
+ default: '#19be6b',
10
+ },
11
+ // 背景色
12
+ inactiveColor: {
13
+ type: String,
14
+ default: '#ececec',
15
+ },
16
+ // 进度百分比,数值
17
+ percentage: {
18
+ type: [String, Number],
19
+ default: 0,
20
+ },
21
+ // 是否在进度条内部显示百分比的值
22
+ showText: {
23
+ type: Boolean,
24
+ default: true,
25
+ },
26
+ // 进度条的高度,单位px
27
+ height: {
28
+ type: [String, Number],
29
+ default: 12,
30
+ },
31
+ customStyle: {
32
+ type: [Object, String],
33
+ default: () => ({}),
34
+ },
35
+ customClass: {
36
+ type: String,
37
+ default: '',
38
+ },
39
+
40
+ ...config.props.lineProgress,
41
+ };
42
+
43
+ export default props;