uview-pro 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.
- package/changelog.md +6 -0
- package/components/u-action-sheet/u-action-sheet.vue +205 -0
- package/components/u-alert-tips/u-alert-tips.vue +241 -0
- package/components/u-avatar/u-avatar.vue +220 -0
- package/components/u-avatar-cropper/u-avatar-cropper.vue +329 -0
- package/components/u-avatar-cropper/weCropper.d.ts +54 -0
- package/components/u-avatar-cropper/weCropper.js +1267 -0
- package/components/u-avatar-cropper/weCropper.ts +1254 -0
- package/components/u-back-top/u-back-top.vue +156 -0
- package/components/u-badge/u-badge.vue +189 -0
- package/components/u-button/u-button.vue +562 -0
- package/components/u-calendar/u-calendar.vue +725 -0
- package/components/u-car-keyboard/u-car-keyboard.vue +236 -0
- package/components/u-card/u-card.vue +240 -0
- package/components/u-cell-group/u-cell-group.vue +56 -0
- package/components/u-cell-item/u-cell-item.vue +245 -0
- package/components/u-checkbox/u-checkbox.vue +310 -0
- package/components/u-checkbox-group/u-checkbox-group.vue +134 -0
- package/components/u-circle-progress/u-circle-progress.vue +210 -0
- package/components/u-col/u-col.vue +135 -0
- package/components/u-collapse/u-collapse.vue +82 -0
- package/components/u-collapse-item/u-collapse-item.vue +190 -0
- package/components/u-column-notice/u-column-notice.vue +264 -0
- package/components/u-count-down/u-count-down.vue +333 -0
- package/components/u-count-to/u-count-to.vue +297 -0
- package/components/u-divider/u-divider.vue +141 -0
- package/components/u-dropdown/u-dropdown.vue +311 -0
- package/components/u-dropdown-item/u-dropdown-item.vue +135 -0
- package/components/u-empty/u-empty.vue +111 -0
- package/components/u-field/u-field.vue +469 -0
- package/components/u-form/u-form.vue +162 -0
- package/components/u-form-item/u-form-item.vue +476 -0
- package/components/u-full-screen/u-full-screen.vue +80 -0
- package/components/u-gap/u-gap.vue +48 -0
- package/components/u-grid/u-grid.vue +101 -0
- package/components/u-grid-item/u-grid-item.vue +136 -0
- package/components/u-icon/u-icon.vue +389 -0
- package/components/u-image/types.ts +48 -0
- package/components/u-image/u-image.vue +218 -0
- package/components/u-index-anchor/u-index-anchor.vue +101 -0
- package/components/u-index-list/u-index-list.vue +376 -0
- package/components/u-input/u-input.vue +462 -0
- package/components/u-keyboard/u-keyboard.vue +188 -0
- package/components/u-lazy-load/u-lazy-load.vue +288 -0
- package/components/u-line/u-line.vue +71 -0
- package/components/u-line-progress/u-line-progress.vue +128 -0
- package/components/u-link/u-link.vue +87 -0
- package/components/u-loading/u-loading.vue +111 -0
- package/components/u-loadmore/u-loadmore.vue +205 -0
- package/components/u-mask/u-mask.vue +137 -0
- package/components/u-message-input/u-message-input.vue +315 -0
- package/components/u-modal/u-modal.vue +284 -0
- package/components/u-navbar/u-navbar.vue +314 -0
- package/components/u-no-network/image.ts +2 -0
- package/components/u-no-network/u-no-network.vue +311 -0
- package/components/u-notice-bar/u-notice-bar.vue +274 -0
- package/components/u-number-box/u-number-box.vue +344 -0
- package/components/u-number-keyboard/u-number-keyboard.vue +170 -0
- package/components/u-parse/libs/CssHandler.js +100 -0
- package/components/u-parse/libs/MpHtmlParser.js +580 -0
- package/components/u-parse/libs/config.js +80 -0
- package/components/u-parse/libs/handler.wxs +22 -0
- package/components/u-parse/libs/trees.vue +505 -0
- package/components/u-parse/u-parse.vue +645 -0
- package/components/u-picker/u-picker.vue +808 -0
- package/components/u-popup/u-popup.vue +404 -0
- package/components/u-radio/u-radio.vue +272 -0
- package/components/u-radio-group/u-radio-group.vue +116 -0
- package/components/u-rate/u-rate.vue +349 -0
- package/components/u-read-more/u-read-more.vue +199 -0
- package/components/u-row/u-row.vue +95 -0
- package/components/u-row-notice/u-row-notice.vue +273 -0
- package/components/u-search/u-search.vue +298 -0
- package/components/u-section/u-section.vue +175 -0
- package/components/u-select/u-select.vue +387 -0
- package/components/u-skeleton/u-skeleton.vue +230 -0
- package/components/u-slider/u-slider.vue +293 -0
- package/components/u-steps/u-steps.vue +200 -0
- package/components/u-sticky/u-sticky.vue +189 -0
- package/components/u-subsection/u-subsection.vue +388 -0
- package/components/u-swipe-action/u-swipe-action.vue +289 -0
- package/components/u-swiper/u-swiper.vue +305 -0
- package/components/u-switch/u-switch.vue +146 -0
- package/components/u-tabbar/u-tabbar.vue +347 -0
- package/components/u-table/u-table.vue +104 -0
- package/components/u-tabs/u-tabs.vue +322 -0
- package/components/u-tabs-swiper/u-tabs-swiper.vue +426 -0
- package/components/u-tag/u-tag.vue +270 -0
- package/components/u-td/u-td.vue +76 -0
- package/components/u-th/u-th.vue +70 -0
- package/components/u-time-line/u-time-line.vue +39 -0
- package/components/u-time-line-item/u-time-line-item.vue +88 -0
- package/components/u-toast/types.ts +4 -0
- package/components/u-toast/u-toast.vue +238 -0
- package/components/u-top-tips/u-top-tips.vue +118 -0
- package/components/u-tr/u-tr.vue +24 -0
- package/components/u-upload/u-upload.vue +600 -0
- package/components/u-verification-code/u-verification-code.vue +194 -0
- package/components/u-waterfall/u-waterfall.vue +186 -0
- package/iconfont.css +910 -0
- package/index.scss +23 -0
- package/index.ts +166 -0
- package/libs/config/config.ts +26 -0
- package/libs/config/zIndex.ts +37 -0
- package/libs/css/color.scss +155 -0
- package/libs/css/common.scss +176 -0
- package/libs/css/style.components.scss +7 -0
- package/libs/css/style.h5.scss +8 -0
- package/libs/css/style.mp.scss +72 -0
- package/libs/css/style.nvue.scss +3 -0
- package/libs/css/style.vue.scss +175 -0
- package/libs/function/$parent.ts +22 -0
- package/libs/function/addUnit.ts +13 -0
- package/libs/function/color.ts +37 -0
- package/libs/function/colorGradient.ts +123 -0
- package/libs/function/debounce.ts +28 -0
- package/libs/function/deepClone.ts +39 -0
- package/libs/function/deepMerge.ts +34 -0
- package/libs/function/getParent.ts +59 -0
- package/libs/function/getRect.ts +26 -0
- package/libs/function/guid.ts +42 -0
- package/libs/function/md5.ts +397 -0
- package/libs/function/parent.ts +21 -0
- package/libs/function/queryParams.ts +60 -0
- package/libs/function/random.ts +16 -0
- package/libs/function/randomArray.ts +11 -0
- package/libs/function/route.ts +118 -0
- package/libs/function/sys.ts +15 -0
- package/libs/function/test.ts +229 -0
- package/libs/function/throttle.ts +31 -0
- package/libs/function/timeFormat.ts +54 -0
- package/libs/function/timeFrom.ts +48 -0
- package/libs/function/toast.ts +14 -0
- package/libs/function/trim.ts +21 -0
- package/libs/function/type2icon.ts +36 -0
- package/libs/hooks/useEmitter.ts +77 -0
- package/libs/hooks/useParent.ts +29 -0
- package/libs/request/index.ts +237 -0
- package/libs/store/index.ts +88 -0
- package/libs/util/area.ts +1 -0
- package/libs/util/async-validator.js +1356 -0
- package/libs/util/city.ts +1 -0
- package/libs/util/emitter.ts +112 -0
- package/libs/util/mitt.ts +118 -0
- package/libs/util/parent.ts +20 -0
- package/libs/util/province.ts +1 -0
- package/package.json +98 -0
- package/readme.md +165 -0
- package/theme.scss +38 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-keyboard" @touchmove.stop.prevent="() => {}">
|
|
3
|
+
<view class="u-keyboard-grids">
|
|
4
|
+
<view
|
|
5
|
+
class="u-keyboard-grids-item"
|
|
6
|
+
:class="[btnBgGray(index) ? 'u-bg-gray' : '', index <= 2 ? 'u-border-top' : '', index < 9 ? 'u-border-bottom' : '', (index + 1) % 3 != 0 ? 'u-border-right' : '']"
|
|
7
|
+
:style="[itemStyle(index)]"
|
|
8
|
+
v-for="(item, index) in numList"
|
|
9
|
+
:key="index"
|
|
10
|
+
:hover-class="hoverClass(index)"
|
|
11
|
+
:hover-stay-time="100"
|
|
12
|
+
@tap="keyboardClick(item)"
|
|
13
|
+
>
|
|
14
|
+
<view class="u-keyboard-grids-btn">{{ item }}</view>
|
|
15
|
+
</view>
|
|
16
|
+
<view class="u-keyboard-grids-item u-bg-gray" hover-class="u-hover-class" :hover-stay-time="100" @touchstart.stop="backspaceClick" @touchend="clearTimer">
|
|
17
|
+
<view class="u-keyboard-back u-keyboard-grids-btn">
|
|
18
|
+
<u-icon name="backspace" :size="38" :bold="true"></u-icon>
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
</view>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { computed } from 'vue';
|
|
27
|
+
import { $u } from '../..';
|
|
28
|
+
|
|
29
|
+
defineOptions({
|
|
30
|
+
name: 'u-number-keyboard'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* u-number-keyboard 数字/身份证键盘
|
|
35
|
+
* @description 支持数字、身份证、带小数点等多种模式,支持乱序,支持长按退格。
|
|
36
|
+
* @property {String} mode 键盘的类型,number-数字键盘,card-身份证键盘
|
|
37
|
+
* @property {Boolean} dotEnabled 是否显示"."按键,只在mode=number时有效(默认true)
|
|
38
|
+
* @property {Boolean} random 是否打乱键盘按键的顺序(默认false)
|
|
39
|
+
* @event {Function} change 按键被点击
|
|
40
|
+
* @event {Function} backspace 退格键被点击
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
/** 键盘的类型,number-数字键盘,card-身份证键盘 */
|
|
45
|
+
mode: { type: String, default: 'number' },
|
|
46
|
+
/** 是否显示键盘的"."符号 */
|
|
47
|
+
dotEnabled: { type: Boolean, default: true },
|
|
48
|
+
/** 是否打乱键盘按键的顺序 */
|
|
49
|
+
random: { type: Boolean, default: false }
|
|
50
|
+
});
|
|
51
|
+
const emit = defineEmits(['change', 'backspace']);
|
|
52
|
+
|
|
53
|
+
const backspace = 'backspace'; // 退格键内容
|
|
54
|
+
const dot = '.'; // 点
|
|
55
|
+
const cardX = 'X'; // 身份证的X符号
|
|
56
|
+
let timer: ReturnType<typeof setInterval> | null = null;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 键盘需要显示的内容
|
|
60
|
+
*/
|
|
61
|
+
const numList = computed(() => {
|
|
62
|
+
if (!props.dotEnabled && props.mode == 'number') {
|
|
63
|
+
if (!props.random) {
|
|
64
|
+
return [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
|
|
65
|
+
} else {
|
|
66
|
+
return $u.randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]);
|
|
67
|
+
}
|
|
68
|
+
} else if (props.dotEnabled && props.mode == 'number') {
|
|
69
|
+
if (!props.random) {
|
|
70
|
+
return [1, 2, 3, 4, 5, 6, 7, 8, 9, dot, 0];
|
|
71
|
+
} else {
|
|
72
|
+
return $u.randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, dot, 0]);
|
|
73
|
+
}
|
|
74
|
+
} else if (props.mode == 'card') {
|
|
75
|
+
if (!props.random) {
|
|
76
|
+
return [1, 2, 3, 4, 5, 6, 7, 8, 9, cardX, 0];
|
|
77
|
+
} else {
|
|
78
|
+
return $u.randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, cardX, 0]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 按键的样式,在非乱序&&数字键盘&&不显示点按钮时,index为9时,按键占位两个空间
|
|
85
|
+
*/
|
|
86
|
+
const itemStyle = (index: number) => {
|
|
87
|
+
let style: Record<string, string> = {};
|
|
88
|
+
if (props.mode == 'number' && !props.dotEnabled && index == 9) style.flex = '0 0 66.6666666666%';
|
|
89
|
+
return style;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 是否让按键显示灰色,只在非乱序&&数字键盘&&且允许点按键的时候
|
|
94
|
+
*/
|
|
95
|
+
const btnBgGray = (index: number) => {
|
|
96
|
+
if (!props.random && index == 9 && (props.mode != 'number' || (props.mode == 'number' && props.dotEnabled))) return true;
|
|
97
|
+
else return false;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 按键 hover class
|
|
102
|
+
*/
|
|
103
|
+
const hoverClass = (index: number) => {
|
|
104
|
+
if (!props.random && index == 9 && ((props.mode == 'number' && props.dotEnabled) || props.mode == 'card')) return 'u-hover-class';
|
|
105
|
+
else return 'u-keyboard-hover';
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 点击退格键
|
|
110
|
+
*/
|
|
111
|
+
function backspaceClick() {
|
|
112
|
+
emit('backspace');
|
|
113
|
+
if (timer) clearInterval(timer); //再次清空定时器,防止重复注册定时器
|
|
114
|
+
timer = setInterval(() => {
|
|
115
|
+
emit('backspace');
|
|
116
|
+
}, 250);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function clearTimer() {
|
|
120
|
+
if (timer) clearInterval(timer);
|
|
121
|
+
timer = null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 获取键盘显示的内容
|
|
126
|
+
*/
|
|
127
|
+
function keyboardClick(val: string | number) {
|
|
128
|
+
// 允许键盘显示点模式和触发非点按键时,将内容转为数字类型
|
|
129
|
+
if (props.dotEnabled && val != dot && val != cardX) val = Number(val);
|
|
130
|
+
emit('change', val);
|
|
131
|
+
}
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<style lang="scss" scoped>
|
|
135
|
+
@import '../../libs/css/style.components.scss';
|
|
136
|
+
|
|
137
|
+
.u-keyboard {
|
|
138
|
+
position: relative;
|
|
139
|
+
z-index: 1003;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.u-keyboard-grids {
|
|
143
|
+
@include vue-flex;
|
|
144
|
+
flex-wrap: wrap;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.u-keyboard-grids-item {
|
|
148
|
+
flex: 0 0 33.3333333333%;
|
|
149
|
+
text-align: center;
|
|
150
|
+
font-size: 50rpx;
|
|
151
|
+
color: #333;
|
|
152
|
+
@include vue-flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
justify-content: center;
|
|
155
|
+
height: 110rpx;
|
|
156
|
+
font-weight: 500;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.u-bg-gray {
|
|
160
|
+
background-color: $u-border-color;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.u-keyboard-back {
|
|
164
|
+
font-size: 36rpx;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.u-keyboard-hover {
|
|
168
|
+
background-color: #e7e6eb;
|
|
169
|
+
}
|
|
170
|
+
</style>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const cfg = require('./config.js'),
|
|
2
|
+
isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
|
3
|
+
|
|
4
|
+
function CssHandler(tagStyle) {
|
|
5
|
+
var styles = Object.assign(Object.create(null), cfg.userAgentStyles);
|
|
6
|
+
for (var item in tagStyle)
|
|
7
|
+
styles[item] = (styles[item] ? styles[item] + ';' : '') + tagStyle[item];
|
|
8
|
+
this.styles = styles;
|
|
9
|
+
}
|
|
10
|
+
CssHandler.prototype.getStyle = function(data) {
|
|
11
|
+
this.styles = new parser(data, this.styles).parse();
|
|
12
|
+
}
|
|
13
|
+
CssHandler.prototype.match = function(name, attrs) {
|
|
14
|
+
var tmp, matched = (tmp = this.styles[name]) ? tmp + ';' : '';
|
|
15
|
+
if (attrs.class) {
|
|
16
|
+
var items = attrs.class.split(' ');
|
|
17
|
+
for (var i = 0, item; item = items[i]; i++)
|
|
18
|
+
if (tmp = this.styles['.' + item])
|
|
19
|
+
matched += tmp + ';';
|
|
20
|
+
}
|
|
21
|
+
if (tmp = this.styles['#' + attrs.id])
|
|
22
|
+
matched += tmp + ';';
|
|
23
|
+
return matched;
|
|
24
|
+
}
|
|
25
|
+
module.exports = CssHandler;
|
|
26
|
+
|
|
27
|
+
function parser(data, init) {
|
|
28
|
+
this.data = data;
|
|
29
|
+
this.floor = 0;
|
|
30
|
+
this.i = 0;
|
|
31
|
+
this.list = [];
|
|
32
|
+
this.res = init;
|
|
33
|
+
this.state = this.Space;
|
|
34
|
+
}
|
|
35
|
+
parser.prototype.parse = function() {
|
|
36
|
+
for (var c; c = this.data[this.i]; this.i++)
|
|
37
|
+
this.state(c);
|
|
38
|
+
return this.res;
|
|
39
|
+
}
|
|
40
|
+
parser.prototype.section = function() {
|
|
41
|
+
return this.data.substring(this.start, this.i);
|
|
42
|
+
}
|
|
43
|
+
// 状态机
|
|
44
|
+
parser.prototype.Space = function(c) {
|
|
45
|
+
if (c == '.' || c == '#' || isLetter(c)) {
|
|
46
|
+
this.start = this.i;
|
|
47
|
+
this.state = this.Name;
|
|
48
|
+
} else if (c == '/' && this.data[this.i + 1] == '*')
|
|
49
|
+
this.Comment();
|
|
50
|
+
else if (!cfg.blankChar[c] && c != ';')
|
|
51
|
+
this.state = this.Ignore;
|
|
52
|
+
}
|
|
53
|
+
parser.prototype.Comment = function() {
|
|
54
|
+
this.i = this.data.indexOf('*/', this.i) + 1;
|
|
55
|
+
if (!this.i) this.i = this.data.length;
|
|
56
|
+
this.state = this.Space;
|
|
57
|
+
}
|
|
58
|
+
parser.prototype.Ignore = function(c) {
|
|
59
|
+
if (c == '{') this.floor++;
|
|
60
|
+
else if (c == '}' && !--this.floor) {
|
|
61
|
+
this.list = [];
|
|
62
|
+
this.state = this.Space;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
parser.prototype.Name = function(c) {
|
|
66
|
+
if (cfg.blankChar[c]) {
|
|
67
|
+
this.list.push(this.section());
|
|
68
|
+
this.state = this.NameSpace;
|
|
69
|
+
} else if (c == '{') {
|
|
70
|
+
this.list.push(this.section());
|
|
71
|
+
this.Content();
|
|
72
|
+
} else if (c == ',') {
|
|
73
|
+
this.list.push(this.section());
|
|
74
|
+
this.Comma();
|
|
75
|
+
} else if (!isLetter(c) && (c < '0' || c > '9') && c != '-' && c != '_')
|
|
76
|
+
this.state = this.Ignore;
|
|
77
|
+
}
|
|
78
|
+
parser.prototype.NameSpace = function(c) {
|
|
79
|
+
if (c == '{') this.Content();
|
|
80
|
+
else if (c == ',') this.Comma();
|
|
81
|
+
else if (!cfg.blankChar[c]) this.state = this.Ignore;
|
|
82
|
+
}
|
|
83
|
+
parser.prototype.Comma = function() {
|
|
84
|
+
while (cfg.blankChar[this.data[++this.i]]);
|
|
85
|
+
if (this.data[this.i] == '{') this.Content();
|
|
86
|
+
else {
|
|
87
|
+
this.start = this.i--;
|
|
88
|
+
this.state = this.Name;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
parser.prototype.Content = function() {
|
|
92
|
+
this.start = ++this.i;
|
|
93
|
+
if ((this.i = this.data.indexOf('}', this.i)) == -1) this.i = this.data.length;
|
|
94
|
+
var content = this.section();
|
|
95
|
+
for (var i = 0, item; item = this.list[i++];)
|
|
96
|
+
if (this.res[item]) this.res[item] += ';' + content;
|
|
97
|
+
else this.res[item] = content;
|
|
98
|
+
this.list = [];
|
|
99
|
+
this.state = this.Space;
|
|
100
|
+
}
|