@gmcb/uv-ui 0.2.26
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/CHANGELOG.md +295 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/components/uv-action-sheet/props.js +50 -0
- package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
- package/components/uv-album/uv-album.vue +312 -0
- package/components/uv-alert/props.js +45 -0
- package/components/uv-alert/uv-alert.vue +246 -0
- package/components/uv-avatar/props.js +85 -0
- package/components/uv-avatar/uv-avatar.vue +182 -0
- package/components/uv-avatar-group/props.js +53 -0
- package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
- package/components/uv-back-top/props.js +58 -0
- package/components/uv-back-top/uv-back-top.vue +116 -0
- package/components/uv-badge/props.js +73 -0
- package/components/uv-badge/uv-badge.vue +176 -0
- package/components/uv-button/nvue.scss +46 -0
- package/components/uv-button/props.js +163 -0
- package/components/uv-button/uv-button.vue +529 -0
- package/components/uv-button/vue.scss +93 -0
- package/components/uv-calendar/calendar.js +546 -0
- package/components/uv-calendar/header.vue +104 -0
- package/components/uv-calendar/month.vue +616 -0
- package/components/uv-calendar/props.js +145 -0
- package/components/uv-calendar/uv-calendar.vue +390 -0
- package/components/uv-calendars/calendar-body.vue +376 -0
- package/components/uv-calendars/calendar-item.vue +248 -0
- package/components/uv-calendars/calendar.js +546 -0
- package/components/uv-calendars/i18n/en.json +12 -0
- package/components/uv-calendars/i18n/index.js +8 -0
- package/components/uv-calendars/i18n/zh-Hans.json +12 -0
- package/components/uv-calendars/i18n/zh-Hant.json +12 -0
- package/components/uv-calendars/util.js +435 -0
- package/components/uv-calendars/uv-calendars.vue +452 -0
- package/components/uv-cell/props.js +116 -0
- package/components/uv-cell/uv-cell.vue +209 -0
- package/components/uv-cell-group/props.js +15 -0
- package/components/uv-cell-group/uv-cell-group.vue +63 -0
- package/components/uv-checkbox/props.js +70 -0
- package/components/uv-checkbox/uv-checkbox.vue +371 -0
- package/components/uv-checkbox-group/props.js +84 -0
- package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
- package/components/uv-code/props.js +35 -0
- package/components/uv-code/uv-code.vue +136 -0
- package/components/uv-code-input/props.js +83 -0
- package/components/uv-code-input/uv-code-input.vue +272 -0
- package/components/uv-col/props.js +30 -0
- package/components/uv-col/uv-col.vue +165 -0
- package/components/uv-collapse/props.js +20 -0
- package/components/uv-collapse/uv-collapse.vue +86 -0
- package/components/uv-collapse-item/props.js +60 -0
- package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
- package/components/uv-column-notice/props.js +61 -0
- package/components/uv-column-notice/uv-column-notice.vue +176 -0
- package/components/uv-count-down/props.js +25 -0
- package/components/uv-count-down/utils.js +62 -0
- package/components/uv-count-down/uv-count-down.vue +169 -0
- package/components/uv-count-to/props.js +60 -0
- package/components/uv-count-to/uv-count-to.vue +187 -0
- package/components/uv-datetime-picker/props.js +130 -0
- package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
- package/components/uv-divider/props.js +45 -0
- package/components/uv-divider/uv-divider.vue +113 -0
- package/components/uv-drop-down/uv-drop-down.vue +135 -0
- package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
- package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
- package/components/uv-empty/props.js +60 -0
- package/components/uv-empty/uv-empty.vue +126 -0
- package/components/uv-form/props.js +46 -0
- package/components/uv-form/uv-form.vue +209 -0
- package/components/uv-form/valid.js +1343 -0
- package/components/uv-form-item/props.js +49 -0
- package/components/uv-form-item/uv-form-item.vue +226 -0
- package/components/uv-gap/props.js +25 -0
- package/components/uv-gap/uv-gap.vue +36 -0
- package/components/uv-grid/props.js +20 -0
- package/components/uv-grid/uv-grid.vue +100 -0
- package/components/uv-grid-item/props.js +15 -0
- package/components/uv-grid-item/uv-grid-item.vue +223 -0
- package/components/uv-icon/icons.js +160 -0
- package/components/uv-icon/props.js +90 -0
- package/components/uv-icon/uv-icon.vue +226 -0
- package/components/uv-icon/uvicons.ttf +0 -0
- package/components/uv-image/props.js +100 -0
- package/components/uv-image/uv-image.vue +296 -0
- package/components/uv-index-anchor/props.js +30 -0
- package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
- package/components/uv-index-item/uv-index-item.vue +87 -0
- package/components/uv-index-list/props.js +30 -0
- package/components/uv-index-list/uv-index-list.vue +461 -0
- package/components/uv-input/props.js +175 -0
- package/components/uv-input/uv-input.vue +348 -0
- package/components/uv-keyboard/props.js +95 -0
- package/components/uv-keyboard/uv-keyboard.vue +180 -0
- package/components/uv-keyboard-car/props.js +24 -0
- package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
- package/components/uv-keyboard-number/props.js +19 -0
- package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
- package/components/uv-line/props.js +34 -0
- package/components/uv-line/uv-line.vue +60 -0
- package/components/uv-line-progress/props.js +29 -0
- package/components/uv-line-progress/uv-line-progress.vue +146 -0
- package/components/uv-link/props.js +40 -0
- package/components/uv-link/uv-link.vue +83 -0
- package/components/uv-list/uv-list.vue +147 -0
- package/components/uv-list-item/uv-list-item.vue +535 -0
- package/components/uv-load-more/props.js +95 -0
- package/components/uv-load-more/uv-load-more.vue +152 -0
- package/components/uv-loading-icon/props.js +67 -0
- package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
- package/components/uv-loading-page/props.js +55 -0
- package/components/uv-loading-page/uv-loading-page.vue +96 -0
- package/components/uv-modal/props.js +90 -0
- package/components/uv-modal/uv-modal.vue +245 -0
- package/components/uv-navbar/props.js +89 -0
- package/components/uv-navbar/uv-navbar.vue +245 -0
- package/components/uv-no-network/props.js +20 -0
- package/components/uv-no-network/uv-no-network.vue +222 -0
- package/components/uv-notice-bar/props.js +76 -0
- package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
- package/components/uv-notify/props.js +45 -0
- package/components/uv-notify/uv-notify.vue +220 -0
- package/components/uv-number-box/props.js +118 -0
- package/components/uv-number-box/uv-number-box.vue +397 -0
- package/components/uv-overlay/props.js +25 -0
- package/components/uv-overlay/uv-overlay.vue +85 -0
- package/components/uv-parse/node/node.vue +576 -0
- package/components/uv-parse/parser.js +1335 -0
- package/components/uv-parse/uv-parse.vue +498 -0
- package/components/uv-pick-color/colors.js +217 -0
- package/components/uv-pick-color/props.js +47 -0
- package/components/uv-pick-color/uv-pick-color.vue +551 -0
- package/components/uv-picker/props.js +95 -0
- package/components/uv-picker/uv-picker.vue +329 -0
- package/components/uv-popup/keypress.js +45 -0
- package/components/uv-popup/uv-popup.vue +537 -0
- package/components/uv-preview-video/uv-preview-video.vue +52 -0
- package/components/uv-qrcode/cache.js +1 -0
- package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
- package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
- package/components/uv-qrcode/gcanvas/env/image.js +96 -0
- package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
- package/components/uv-qrcode/gcanvas/index.js +39 -0
- package/components/uv-qrcode/props.js +85 -0
- package/components/uv-qrcode/qrcode.js +34 -0
- package/components/uv-qrcode/queue.js +41 -0
- package/components/uv-qrcode/uv-qrcode.vue +1038 -0
- package/components/uv-radio/props.js +65 -0
- package/components/uv-radio/uv-radio.vue +349 -0
- package/components/uv-radio-group/props.js +89 -0
- package/components/uv-radio-group/uv-radio-group.vue +115 -0
- package/components/uv-rate/props.js +73 -0
- package/components/uv-rate/uv-rate.vue +274 -0
- package/components/uv-read-more/props.js +62 -0
- package/components/uv-read-more/uv-read-more.vue +162 -0
- package/components/uv-row/props.js +20 -0
- package/components/uv-row/uv-row.vue +95 -0
- package/components/uv-row-notice/props.js +40 -0
- package/components/uv-row-notice/uv-row-notice.vue +341 -0
- package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
- package/components/uv-scroll-list/nvue.js +29 -0
- package/components/uv-scroll-list/props.js +35 -0
- package/components/uv-scroll-list/scrollWxs.wxs +51 -0
- package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
- package/components/uv-search/props.js +127 -0
- package/components/uv-search/uv-search.vue +311 -0
- package/components/uv-skeleton/props.js +65 -0
- package/components/uv-skeleton/uv-skeleton.vue +250 -0
- package/components/uv-skeletons/uv-skeletons.vue +247 -0
- package/components/uv-slider/props.js +58 -0
- package/components/uv-slider/uv-slider.vue +58 -0
- package/components/uv-status-bar/props.js +8 -0
- package/components/uv-status-bar/uv-status-bar.vue +54 -0
- package/components/uv-steps/props.js +40 -0
- package/components/uv-steps/uv-steps.vue +83 -0
- package/components/uv-steps-item/props.js +25 -0
- package/components/uv-steps-item/uv-steps-item.vue +347 -0
- package/components/uv-sticky/props.js +41 -0
- package/components/uv-sticky/uv-sticky.vue +223 -0
- package/components/uv-subsection/props.js +54 -0
- package/components/uv-subsection/uv-subsection.vue +269 -0
- package/components/uv-swipe-action/props.js +10 -0
- package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
- package/components/uv-swipe-action-item/index - backup.wxs +256 -0
- package/components/uv-swipe-action-item/index.wxs +225 -0
- package/components/uv-swipe-action-item/nvue - backup.js +264 -0
- package/components/uv-swipe-action-item/nvue.js +182 -0
- package/components/uv-swipe-action-item/props.js +40 -0
- package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
- package/components/uv-swipe-action-item/wxs.js +15 -0
- package/components/uv-swiper/props.js +136 -0
- package/components/uv-swiper/uv-swiper.vue +263 -0
- package/components/uv-swiper-indicator/props.js +30 -0
- package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
- package/components/uv-switch/props.js +58 -0
- package/components/uv-switch/uv-switch.vue +182 -0
- package/components/uv-tabbar/props.js +50 -0
- package/components/uv-tabbar/uv-tabbar.vue +146 -0
- package/components/uv-tabbar-item/props.js +40 -0
- package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
- package/components/uv-tabs/props.js +71 -0
- package/components/uv-tabs/uv-tabs.vue +391 -0
- package/components/uv-tags/props.js +104 -0
- package/components/uv-tags/uv-tags.vue +379 -0
- package/components/uv-text/props.js +113 -0
- package/components/uv-text/uv-text.vue +218 -0
- package/components/uv-text/value.js +87 -0
- package/components/uv-textarea/props.js +138 -0
- package/components/uv-textarea/uv-textarea.vue +238 -0
- package/components/uv-toast/uv-toast.vue +292 -0
- package/components/uv-toolbar/props.js +40 -0
- package/components/uv-toolbar/uv-toolbar.vue +109 -0
- package/components/uv-tooltip/props.js +60 -0
- package/components/uv-tooltip/uv-tooltip.vue +372 -0
- package/components/uv-transition/createAnimation.js +131 -0
- package/components/uv-transition/props.js +31 -0
- package/components/uv-transition/uv-transition.vue +320 -0
- package/components/uv-upload/mixin.js +22 -0
- package/components/uv-upload/props.js +130 -0
- package/components/uv-upload/utils.js +151 -0
- package/components/uv-upload/uv-upload.vue +488 -0
- package/components/uv-vtabs/props.js +79 -0
- package/components/uv-vtabs/uv-vtabs.vue +438 -0
- package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
- package/components/uv-waterfall/props.js +69 -0
- package/components/uv-waterfall/uv-waterfall.vue +265 -0
- package/index.js +82 -0
- package/index.scss +7 -0
- package/libs/config/config.js +34 -0
- package/libs/css/color.scss +32 -0
- package/libs/css/common.scss +100 -0
- package/libs/css/components.scss +23 -0
- package/libs/css/variable.scss +111 -0
- package/libs/css/vue.scss +40 -0
- package/libs/function/colorGradient.js +134 -0
- package/libs/function/compress.js +27 -0
- package/libs/function/debounce.js +29 -0
- package/libs/function/digit.js +167 -0
- package/libs/function/index.js +734 -0
- package/libs/function/platform.js +75 -0
- package/libs/function/test.js +287 -0
- package/libs/function/throttle.js +30 -0
- package/libs/luch-request/adapters/index.js +132 -0
- package/libs/luch-request/core/InterceptorManager.js +51 -0
- package/libs/luch-request/core/Request.js +201 -0
- package/libs/luch-request/core/buildFullPath.js +20 -0
- package/libs/luch-request/core/defaults.js +33 -0
- package/libs/luch-request/core/dispatchRequest.js +6 -0
- package/libs/luch-request/core/mergeConfig.js +126 -0
- package/libs/luch-request/core/settle.js +16 -0
- package/libs/luch-request/helpers/buildURL.js +64 -0
- package/libs/luch-request/helpers/combineURLs.js +14 -0
- package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
- package/libs/luch-request/index.d.ts +197 -0
- package/libs/luch-request/index.js +2 -0
- package/libs/luch-request/utils/clone.js +264 -0
- package/libs/luch-request/utils.js +135 -0
- package/libs/mixin/button.js +13 -0
- package/libs/mixin/mixin.js +172 -0
- package/libs/mixin/mpMixin.js +8 -0
- package/libs/mixin/mpShare.js +13 -0
- package/libs/mixin/openType.js +47 -0
- package/libs/mixin/touch.js +59 -0
- package/libs/util/dayjs.js +216 -0
- package/libs/util/route.js +126 -0
- package/package.json +28 -0
- package/theme.scss +43 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { func, date, url } from '../../libs/function/test.js'
|
|
2
|
+
import { error, timeFormat, priceFormat } from '../../libs/function/index.js'
|
|
3
|
+
export default {
|
|
4
|
+
computed: {
|
|
5
|
+
// 经处理后需要显示的值
|
|
6
|
+
value() {
|
|
7
|
+
const {
|
|
8
|
+
text,
|
|
9
|
+
mode,
|
|
10
|
+
format,
|
|
11
|
+
href
|
|
12
|
+
} = this
|
|
13
|
+
// 价格类型
|
|
14
|
+
if (mode === 'price') {
|
|
15
|
+
// 如果text不为金额进行提示
|
|
16
|
+
if (!/^\d+(\.\d+)?$/.test(text)) {
|
|
17
|
+
error('金额模式下,text参数需要为金额格式');
|
|
18
|
+
}
|
|
19
|
+
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理
|
|
20
|
+
if (func(format)) {
|
|
21
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
22
|
+
return format(text)
|
|
23
|
+
}
|
|
24
|
+
// 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
|
|
25
|
+
return priceFormat(text, 2)
|
|
26
|
+
} if (mode === 'date') {
|
|
27
|
+
// 判断是否合法的日期或者时间戳
|
|
28
|
+
!date(text) && error('日期模式下,text参数需要为日期或时间戳格式')
|
|
29
|
+
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
|
|
30
|
+
if (func(format)) {
|
|
31
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
32
|
+
return format(text)
|
|
33
|
+
} if (format) {
|
|
34
|
+
// 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
|
|
35
|
+
return timeFormat(text, format)
|
|
36
|
+
}
|
|
37
|
+
// 如果没有设置format,则设置为默认的时间格式化形式
|
|
38
|
+
return timeFormat(text, 'yyyy-mm-dd')
|
|
39
|
+
} if (mode === 'phone') {
|
|
40
|
+
// 判断是否合法的手机号
|
|
41
|
+
// !mobile(text) && error('手机号模式下,text参数需要为手机号码格式')
|
|
42
|
+
if (func(format)) {
|
|
43
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
44
|
+
return format(text)
|
|
45
|
+
} if (format === 'encrypt') {
|
|
46
|
+
// 如果format为encrypt,则将手机号进行星号加密处理
|
|
47
|
+
return `${text.substr(0, 3)}****${text.substr(7)}`
|
|
48
|
+
}
|
|
49
|
+
return text
|
|
50
|
+
} if (mode === 'name') {
|
|
51
|
+
// 判断是否合法的字符粗
|
|
52
|
+
!(typeof (text) === 'string') && error('姓名模式下,text参数需要为字符串格式')
|
|
53
|
+
if (func(format)) {
|
|
54
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
55
|
+
return format(text)
|
|
56
|
+
} if (format === 'encrypt') {
|
|
57
|
+
// 如果format为encrypt,则将姓名进行星号加密处理
|
|
58
|
+
return this.formatName(text)
|
|
59
|
+
}
|
|
60
|
+
return text
|
|
61
|
+
} if (mode === 'link') {
|
|
62
|
+
// 判断是否合法的字符粗
|
|
63
|
+
!url(href) && error('超链接模式下,href参数需要为URL格式')
|
|
64
|
+
return text
|
|
65
|
+
}
|
|
66
|
+
return text
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
methods: {
|
|
70
|
+
// 默认的姓名脱敏规则
|
|
71
|
+
formatName(name) {
|
|
72
|
+
let value = ''
|
|
73
|
+
if (name.length === 2) {
|
|
74
|
+
value = name.substr(0, 1) + '*'
|
|
75
|
+
} else if (name.length > 2) {
|
|
76
|
+
let char = ''
|
|
77
|
+
for (let i = 0, len = name.length - 2; i < len; i++) {
|
|
78
|
+
char += '*'
|
|
79
|
+
}
|
|
80
|
+
value = name.substr(0, 1) + char + name.substr(-1, 1)
|
|
81
|
+
} else {
|
|
82
|
+
value = name
|
|
83
|
+
}
|
|
84
|
+
return value
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
value: {
|
|
4
|
+
type: [String, Number],
|
|
5
|
+
default: ''
|
|
6
|
+
},
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: [String, Number],
|
|
9
|
+
default: ''
|
|
10
|
+
},
|
|
11
|
+
// 输入框为空时占位符
|
|
12
|
+
placeholder: {
|
|
13
|
+
type: [String, Number],
|
|
14
|
+
default: ''
|
|
15
|
+
},
|
|
16
|
+
// 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/
|
|
17
|
+
placeholderClass: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: 'textarea-placeholder'
|
|
20
|
+
},
|
|
21
|
+
// 指定placeholder的样式
|
|
22
|
+
placeholderStyle: {
|
|
23
|
+
type: [String, Object],
|
|
24
|
+
default: 'color: #c0c4cc'
|
|
25
|
+
},
|
|
26
|
+
// 输入框高度
|
|
27
|
+
height: {
|
|
28
|
+
type: [String, Number],
|
|
29
|
+
default: 70
|
|
30
|
+
},
|
|
31
|
+
// 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效
|
|
32
|
+
confirmType: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'return'
|
|
35
|
+
},
|
|
36
|
+
// 是否禁用
|
|
37
|
+
disabled: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
// 是否显示统计字数
|
|
42
|
+
count: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
},
|
|
46
|
+
// 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现
|
|
47
|
+
focus: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
// 是否自动增加高度
|
|
52
|
+
autoHeight: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
// 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true
|
|
57
|
+
fixed: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false
|
|
60
|
+
},
|
|
61
|
+
// 指定光标与键盘的距离
|
|
62
|
+
cursorSpacing: {
|
|
63
|
+
type: Number,
|
|
64
|
+
default: 0
|
|
65
|
+
},
|
|
66
|
+
// 指定focus时的光标位置
|
|
67
|
+
cursor: {
|
|
68
|
+
type: [String, Number],
|
|
69
|
+
default: ''
|
|
70
|
+
},
|
|
71
|
+
// 是否显示键盘上方带有”完成“按钮那一栏,
|
|
72
|
+
showConfirmBar: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: true
|
|
75
|
+
},
|
|
76
|
+
// 光标起始位置,自动聚焦时有效,需与selection-end搭配使用
|
|
77
|
+
selectionStart: {
|
|
78
|
+
type: Number,
|
|
79
|
+
default: -1
|
|
80
|
+
},
|
|
81
|
+
// 光标结束位置,自动聚焦时有效,需与selection-start搭配使用
|
|
82
|
+
selectionEnd: {
|
|
83
|
+
type: Number,
|
|
84
|
+
default: -1
|
|
85
|
+
},
|
|
86
|
+
// 键盘弹起时,是否自动上推页面
|
|
87
|
+
adjustPosition: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: true
|
|
90
|
+
},
|
|
91
|
+
// 是否去掉 iOS 下的默认内边距,只微信小程序有效
|
|
92
|
+
disableDefaultPadding: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: false
|
|
95
|
+
},
|
|
96
|
+
// focus时,点击页面的时候不收起键盘,只微信小程序有效
|
|
97
|
+
holdKeyboard: {
|
|
98
|
+
type: Boolean,
|
|
99
|
+
default: false
|
|
100
|
+
},
|
|
101
|
+
// 最大输入长度,设置为 -1 的时候不限制最大长度
|
|
102
|
+
maxlength: {
|
|
103
|
+
type: [String, Number],
|
|
104
|
+
default: 140
|
|
105
|
+
},
|
|
106
|
+
// 边框类型,surround-四周边框,bottom-底部边框
|
|
107
|
+
border: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: 'surround'
|
|
110
|
+
},
|
|
111
|
+
// 用于处理或者过滤输入框内容的方法
|
|
112
|
+
formatter: {
|
|
113
|
+
type: [Function, null],
|
|
114
|
+
default: null
|
|
115
|
+
},
|
|
116
|
+
// 是否忽略组件内对文本合成系统事件的处理
|
|
117
|
+
ignoreCompositionEvent: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
default: true
|
|
120
|
+
},
|
|
121
|
+
// 是否忽略组件内对文本合成系统事件的处理
|
|
122
|
+
confirmHold: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: false
|
|
125
|
+
},
|
|
126
|
+
// 文本样式
|
|
127
|
+
textStyle: {
|
|
128
|
+
type: [Object, String],
|
|
129
|
+
default: () => {}
|
|
130
|
+
},
|
|
131
|
+
// 统计数字的样式
|
|
132
|
+
countStyle: {
|
|
133
|
+
type: [Object, String],
|
|
134
|
+
default: () => {}
|
|
135
|
+
},
|
|
136
|
+
...uni.$uv?.props?.textarea
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uv-textarea"
|
|
3
|
+
:class="textareaClass"
|
|
4
|
+
:style="[textareaStyle]">
|
|
5
|
+
<textarea class="uv-textarea__field"
|
|
6
|
+
:value="innerValue"
|
|
7
|
+
:style="[
|
|
8
|
+
{height: autoHeight ? 'auto' :$uv.addUnit(height)},
|
|
9
|
+
$uv.addStyle(textStyle)
|
|
10
|
+
]"
|
|
11
|
+
:placeholder="placeholder"
|
|
12
|
+
:placeholder-style="$uv.addStyle(placeholderStyle, 'string')"
|
|
13
|
+
:placeholder-class="placeholderClass"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
:focus="focus"
|
|
16
|
+
:autoHeight="autoHeight"
|
|
17
|
+
:fixed="fixed"
|
|
18
|
+
:cursorSpacing="cursorSpacing"
|
|
19
|
+
:cursor="cursor"
|
|
20
|
+
:showConfirmBar="showConfirmBar"
|
|
21
|
+
:selectionStart="selectionStart"
|
|
22
|
+
:selectionEnd="selectionEnd"
|
|
23
|
+
:adjustPosition="adjustPosition"
|
|
24
|
+
:disableDefaultPadding="disableDefaultPadding"
|
|
25
|
+
:holdKeyboard="holdKeyboard"
|
|
26
|
+
:maxlength="maxlen"
|
|
27
|
+
:confirmType="confirmType"
|
|
28
|
+
:ignoreCompositionEvent="ignoreCompositionEvent"
|
|
29
|
+
:confirm-hold="confirmHold"
|
|
30
|
+
@focus="onFocus"
|
|
31
|
+
@blur="onBlur"
|
|
32
|
+
@linechange="onLinechange"
|
|
33
|
+
@input="onInput"
|
|
34
|
+
@confirm="onConfirm"
|
|
35
|
+
@keyboardheightchange="onKeyboardheightchange"></textarea>
|
|
36
|
+
<text class="uv-textarea__count"
|
|
37
|
+
:style="[{
|
|
38
|
+
'background-color': disabled ? 'transparent' : '#fff',
|
|
39
|
+
},$uv.addStyle(countStyle)]"
|
|
40
|
+
v-if="count && maxlen!=-1">{{ getCount }}/{{ maxlen }}</text>
|
|
41
|
+
</view>
|
|
42
|
+
</template>
|
|
43
|
+
<script>
|
|
44
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
45
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
46
|
+
import props from "./props.js";
|
|
47
|
+
/**
|
|
48
|
+
* Textarea 文本域
|
|
49
|
+
* @description 文本域此组件满足了可能出现的表单信息补充,编辑等实际逻辑的功能,内置了字数校验等
|
|
50
|
+
* @tutorial https://www.uvui.cn/components/textarea.html
|
|
51
|
+
*
|
|
52
|
+
* @property {String | Number} value / v-model 输入框的内容
|
|
53
|
+
* @property {String | Number} placeholder 输入框为空时占位符
|
|
54
|
+
* @property {String} placeholderClass 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' )
|
|
55
|
+
* @property {String | Object} placeholderStyle 指定placeholder的样式,字符串/对象形式,如"color: red;"
|
|
56
|
+
* @property {String | Number} height 输入框高度(默认 70 )
|
|
57
|
+
* @property {String} confirmType 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效(默认 'done' )
|
|
58
|
+
* @property {Boolean} disabled 是否禁用(默认 false )
|
|
59
|
+
* @property {Boolean} count 是否显示统计字数(默认 false )
|
|
60
|
+
* @property {Boolean} focus 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现(默认 false )
|
|
61
|
+
* @property {Boolean | Function} autoHeight 是否自动增加高度(默认 false )
|
|
62
|
+
* @property {Boolean} fixed 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true(默认 false )
|
|
63
|
+
* @property {Number} cursorSpacing 指定光标与键盘的距离(默认 0 )
|
|
64
|
+
* @property {String | Number} cursor 指定focus时的光标位置
|
|
65
|
+
* @property {Function} formatter 内容式化函数
|
|
66
|
+
* @property {Boolean} showConfirmBar 是否显示键盘上方带有”完成“按钮那一栏,(默认 true )
|
|
67
|
+
* @property {Number} selectionStart 光标起始位置,自动聚焦时有效,需与selection-end搭配使用,(默认 -1 )
|
|
68
|
+
* @property {Number | Number} selectionEnd 光标结束位置,自动聚焦时有效,需与selection-start搭配使用(默认 -1 )
|
|
69
|
+
* @property {Boolean} adjustPosition 键盘弹起时,是否自动上推页面(默认 true )
|
|
70
|
+
* @property {Boolean | Number} disableDefaultPadding 是否去掉 iOS 下的默认内边距,只微信小程序有效(默认 false )
|
|
71
|
+
* @property {Boolean} holdKeyboard focus时,点击页面的时候不收起键盘,只微信小程序有效(默认 false )
|
|
72
|
+
* @property {String | Number} maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认 140 )
|
|
73
|
+
* @property {String} border 边框类型,surround-四周边框,none-无边框,bottom-底部边框(默认 'surround' )
|
|
74
|
+
* @property {Boolean} ignoreCompositionEvent 是否忽略组件内对文本合成系统事件的处理
|
|
75
|
+
* @property {Boolean} confirmHold 点击键盘右下角按钮时是否保持键盘不收起
|
|
76
|
+
* @property {Object} textStyle 文本样式
|
|
77
|
+
* @property {Object} countStyle 统计数字的样式
|
|
78
|
+
*
|
|
79
|
+
* @event {Function(e)} focus 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度
|
|
80
|
+
* @event {Function(e)} blur 输入框失去焦点时触发,event.detail = {value, cursor}
|
|
81
|
+
* @event {Function(e)} linechange 输入框行数变化时调用,event.detail = {height: 0, heightRpx: 0, lineCount: 0}
|
|
82
|
+
* @event {Function(e)} input 当键盘输入时,触发 input 事件
|
|
83
|
+
* @event {Function(e)} confirm 点击完成时, 触发 confirm 事件
|
|
84
|
+
* @event {Function(e)} keyboardheightchange 键盘高度发生变化的时候触发此事件
|
|
85
|
+
* @example <uv--textarea v-model="value1" placeholder="请输入内容" ></uv--textarea>
|
|
86
|
+
*/
|
|
87
|
+
export default {
|
|
88
|
+
name: "uv-textarea",
|
|
89
|
+
mixins: [mpMixin, mixin, props],
|
|
90
|
+
data() {
|
|
91
|
+
return {
|
|
92
|
+
// 输入框的值
|
|
93
|
+
innerValue: "",
|
|
94
|
+
// 是否处于获得焦点状态
|
|
95
|
+
focused: false,
|
|
96
|
+
// 过滤处理方法
|
|
97
|
+
innerFormatter: value => value
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
created() {
|
|
101
|
+
// #ifndef VUE3
|
|
102
|
+
this.innerValue = this.value;
|
|
103
|
+
// #endif
|
|
104
|
+
// #ifdef VUE3
|
|
105
|
+
this.innerValue = this.modelValue;
|
|
106
|
+
// #endif
|
|
107
|
+
},
|
|
108
|
+
watch: {
|
|
109
|
+
value(newVal) {
|
|
110
|
+
this.innerValue = newVal;
|
|
111
|
+
},
|
|
112
|
+
modelValue(newVal) {
|
|
113
|
+
this.innerValue = newVal;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
computed: {
|
|
117
|
+
// 组件的类名
|
|
118
|
+
textareaClass() {
|
|
119
|
+
let classes = [],
|
|
120
|
+
{ border, disabled } = this;
|
|
121
|
+
border === "surround" && (classes = classes.concat(["uv-border", "uv-textarea--radius"]));
|
|
122
|
+
border === "bottom" && (classes = classes.concat(["uv-border-bottom", "uv-textarea--no-radius", ]));
|
|
123
|
+
disabled && classes.push("uv-textarea--disabled");
|
|
124
|
+
return classes.join(" ");
|
|
125
|
+
},
|
|
126
|
+
// 组件的样式
|
|
127
|
+
textareaStyle() {
|
|
128
|
+
const style = {};
|
|
129
|
+
// #ifdef APP-NVUE
|
|
130
|
+
// 由于textarea在安卓nvue上的差异性,需要额外再调整其内边距
|
|
131
|
+
if (this.$uv.os() === "android") {
|
|
132
|
+
style.paddingTop = "6px";
|
|
133
|
+
style.paddingLeft = "9px";
|
|
134
|
+
style.paddingBottom = "3px";
|
|
135
|
+
style.paddingRight = "6px";
|
|
136
|
+
}
|
|
137
|
+
// #endif
|
|
138
|
+
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle));
|
|
139
|
+
},
|
|
140
|
+
maxlen() {
|
|
141
|
+
return this.maxlength < 0 ? this.maxlength < 0 ? -1 : 140 : this.maxlength;
|
|
142
|
+
},
|
|
143
|
+
getCount() {
|
|
144
|
+
try{
|
|
145
|
+
return this.innerValue.length > this.maxlen ? this.maxlen: this.innerValue.length;
|
|
146
|
+
}catch(e){
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
methods: {
|
|
152
|
+
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
153
|
+
setFormatter(e) {
|
|
154
|
+
this.innerFormatter = e
|
|
155
|
+
},
|
|
156
|
+
onFocus(e) {
|
|
157
|
+
this.$emit("focus", e);
|
|
158
|
+
},
|
|
159
|
+
onBlur(e) {
|
|
160
|
+
this.$emit("blur", e);
|
|
161
|
+
// 尝试调用uv-form的验证方法
|
|
162
|
+
this.$uv.formValidate(this, "blur");
|
|
163
|
+
},
|
|
164
|
+
onLinechange(e) {
|
|
165
|
+
this.$emit("linechange", e);
|
|
166
|
+
},
|
|
167
|
+
onInput(e) {
|
|
168
|
+
let { value = "" } = e.detail || {};
|
|
169
|
+
// 格式化过滤方法
|
|
170
|
+
const formatter = this.formatter || this.innerFormatter
|
|
171
|
+
const formatValue = formatter(value)
|
|
172
|
+
// 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在$nextTick中重新赋予设置后的值才有效
|
|
173
|
+
this.innerValue = value
|
|
174
|
+
this.$nextTick(() => {
|
|
175
|
+
this.innerValue = formatValue;
|
|
176
|
+
this.valueChange();
|
|
177
|
+
})
|
|
178
|
+
},
|
|
179
|
+
// 内容发生变化,进行处理
|
|
180
|
+
valueChange() {
|
|
181
|
+
const value = this.innerValue;
|
|
182
|
+
this.$nextTick(() => {
|
|
183
|
+
this.$emit("input", value);
|
|
184
|
+
this.$emit("update:modelValue", value);
|
|
185
|
+
this.$emit("change", value);
|
|
186
|
+
// 尝试调用uv-form的验证方法
|
|
187
|
+
this.$uv.formValidate(this, "change");
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
onConfirm(e) {
|
|
191
|
+
this.$emit("confirm", e);
|
|
192
|
+
},
|
|
193
|
+
onKeyboardheightchange(e) {
|
|
194
|
+
this.$emit("keyboardheightchange", e);
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
</script>
|
|
199
|
+
<style lang="scss" scoped>
|
|
200
|
+
$show-border: 1;
|
|
201
|
+
$show-border-surround: 1;
|
|
202
|
+
$show-border-bottom: 1;
|
|
203
|
+
@import '../../libs/css/variable.scss';
|
|
204
|
+
@import '../../libs/css/components.scss';
|
|
205
|
+
@import '../../libs/css/color.scss';
|
|
206
|
+
.uv-textarea {
|
|
207
|
+
border-radius: 4px;
|
|
208
|
+
background-color: #fff;
|
|
209
|
+
position: relative;
|
|
210
|
+
@include flex;
|
|
211
|
+
flex: 1;
|
|
212
|
+
padding: 9px;
|
|
213
|
+
&--radius {
|
|
214
|
+
border-radius: 4px;
|
|
215
|
+
}
|
|
216
|
+
&--no-radius {
|
|
217
|
+
border-radius: 0;
|
|
218
|
+
}
|
|
219
|
+
&--disabled {
|
|
220
|
+
background-color: #f5f7fa;
|
|
221
|
+
}
|
|
222
|
+
&__field {
|
|
223
|
+
flex: 1;
|
|
224
|
+
font-size: 15px;
|
|
225
|
+
color: $uv-content-color;
|
|
226
|
+
width: 100%;
|
|
227
|
+
}
|
|
228
|
+
&__count {
|
|
229
|
+
position: absolute;
|
|
230
|
+
right: 5px;
|
|
231
|
+
bottom: 2px;
|
|
232
|
+
font-size: 12px;
|
|
233
|
+
color: $uv-tips-color;
|
|
234
|
+
background-color: #ffffff;
|
|
235
|
+
padding: 1px 4px;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
</style>
|