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.
Files changed (149) hide show
  1. package/changelog.md +6 -0
  2. package/components/u-action-sheet/u-action-sheet.vue +205 -0
  3. package/components/u-alert-tips/u-alert-tips.vue +241 -0
  4. package/components/u-avatar/u-avatar.vue +220 -0
  5. package/components/u-avatar-cropper/u-avatar-cropper.vue +329 -0
  6. package/components/u-avatar-cropper/weCropper.d.ts +54 -0
  7. package/components/u-avatar-cropper/weCropper.js +1267 -0
  8. package/components/u-avatar-cropper/weCropper.ts +1254 -0
  9. package/components/u-back-top/u-back-top.vue +156 -0
  10. package/components/u-badge/u-badge.vue +189 -0
  11. package/components/u-button/u-button.vue +562 -0
  12. package/components/u-calendar/u-calendar.vue +725 -0
  13. package/components/u-car-keyboard/u-car-keyboard.vue +236 -0
  14. package/components/u-card/u-card.vue +240 -0
  15. package/components/u-cell-group/u-cell-group.vue +56 -0
  16. package/components/u-cell-item/u-cell-item.vue +245 -0
  17. package/components/u-checkbox/u-checkbox.vue +310 -0
  18. package/components/u-checkbox-group/u-checkbox-group.vue +134 -0
  19. package/components/u-circle-progress/u-circle-progress.vue +210 -0
  20. package/components/u-col/u-col.vue +135 -0
  21. package/components/u-collapse/u-collapse.vue +82 -0
  22. package/components/u-collapse-item/u-collapse-item.vue +190 -0
  23. package/components/u-column-notice/u-column-notice.vue +264 -0
  24. package/components/u-count-down/u-count-down.vue +333 -0
  25. package/components/u-count-to/u-count-to.vue +297 -0
  26. package/components/u-divider/u-divider.vue +141 -0
  27. package/components/u-dropdown/u-dropdown.vue +311 -0
  28. package/components/u-dropdown-item/u-dropdown-item.vue +135 -0
  29. package/components/u-empty/u-empty.vue +111 -0
  30. package/components/u-field/u-field.vue +469 -0
  31. package/components/u-form/u-form.vue +162 -0
  32. package/components/u-form-item/u-form-item.vue +476 -0
  33. package/components/u-full-screen/u-full-screen.vue +80 -0
  34. package/components/u-gap/u-gap.vue +48 -0
  35. package/components/u-grid/u-grid.vue +101 -0
  36. package/components/u-grid-item/u-grid-item.vue +136 -0
  37. package/components/u-icon/u-icon.vue +389 -0
  38. package/components/u-image/types.ts +48 -0
  39. package/components/u-image/u-image.vue +218 -0
  40. package/components/u-index-anchor/u-index-anchor.vue +101 -0
  41. package/components/u-index-list/u-index-list.vue +376 -0
  42. package/components/u-input/u-input.vue +462 -0
  43. package/components/u-keyboard/u-keyboard.vue +188 -0
  44. package/components/u-lazy-load/u-lazy-load.vue +288 -0
  45. package/components/u-line/u-line.vue +71 -0
  46. package/components/u-line-progress/u-line-progress.vue +128 -0
  47. package/components/u-link/u-link.vue +87 -0
  48. package/components/u-loading/u-loading.vue +111 -0
  49. package/components/u-loadmore/u-loadmore.vue +205 -0
  50. package/components/u-mask/u-mask.vue +137 -0
  51. package/components/u-message-input/u-message-input.vue +315 -0
  52. package/components/u-modal/u-modal.vue +284 -0
  53. package/components/u-navbar/u-navbar.vue +314 -0
  54. package/components/u-no-network/image.ts +2 -0
  55. package/components/u-no-network/u-no-network.vue +311 -0
  56. package/components/u-notice-bar/u-notice-bar.vue +274 -0
  57. package/components/u-number-box/u-number-box.vue +344 -0
  58. package/components/u-number-keyboard/u-number-keyboard.vue +170 -0
  59. package/components/u-parse/libs/CssHandler.js +100 -0
  60. package/components/u-parse/libs/MpHtmlParser.js +580 -0
  61. package/components/u-parse/libs/config.js +80 -0
  62. package/components/u-parse/libs/handler.wxs +22 -0
  63. package/components/u-parse/libs/trees.vue +505 -0
  64. package/components/u-parse/u-parse.vue +645 -0
  65. package/components/u-picker/u-picker.vue +808 -0
  66. package/components/u-popup/u-popup.vue +404 -0
  67. package/components/u-radio/u-radio.vue +272 -0
  68. package/components/u-radio-group/u-radio-group.vue +116 -0
  69. package/components/u-rate/u-rate.vue +349 -0
  70. package/components/u-read-more/u-read-more.vue +199 -0
  71. package/components/u-row/u-row.vue +95 -0
  72. package/components/u-row-notice/u-row-notice.vue +273 -0
  73. package/components/u-search/u-search.vue +298 -0
  74. package/components/u-section/u-section.vue +175 -0
  75. package/components/u-select/u-select.vue +387 -0
  76. package/components/u-skeleton/u-skeleton.vue +230 -0
  77. package/components/u-slider/u-slider.vue +293 -0
  78. package/components/u-steps/u-steps.vue +200 -0
  79. package/components/u-sticky/u-sticky.vue +189 -0
  80. package/components/u-subsection/u-subsection.vue +388 -0
  81. package/components/u-swipe-action/u-swipe-action.vue +289 -0
  82. package/components/u-swiper/u-swiper.vue +305 -0
  83. package/components/u-switch/u-switch.vue +146 -0
  84. package/components/u-tabbar/u-tabbar.vue +347 -0
  85. package/components/u-table/u-table.vue +104 -0
  86. package/components/u-tabs/u-tabs.vue +322 -0
  87. package/components/u-tabs-swiper/u-tabs-swiper.vue +426 -0
  88. package/components/u-tag/u-tag.vue +270 -0
  89. package/components/u-td/u-td.vue +76 -0
  90. package/components/u-th/u-th.vue +70 -0
  91. package/components/u-time-line/u-time-line.vue +39 -0
  92. package/components/u-time-line-item/u-time-line-item.vue +88 -0
  93. package/components/u-toast/types.ts +4 -0
  94. package/components/u-toast/u-toast.vue +238 -0
  95. package/components/u-top-tips/u-top-tips.vue +118 -0
  96. package/components/u-tr/u-tr.vue +24 -0
  97. package/components/u-upload/u-upload.vue +600 -0
  98. package/components/u-verification-code/u-verification-code.vue +194 -0
  99. package/components/u-waterfall/u-waterfall.vue +186 -0
  100. package/iconfont.css +910 -0
  101. package/index.scss +23 -0
  102. package/index.ts +166 -0
  103. package/libs/config/config.ts +26 -0
  104. package/libs/config/zIndex.ts +37 -0
  105. package/libs/css/color.scss +155 -0
  106. package/libs/css/common.scss +176 -0
  107. package/libs/css/style.components.scss +7 -0
  108. package/libs/css/style.h5.scss +8 -0
  109. package/libs/css/style.mp.scss +72 -0
  110. package/libs/css/style.nvue.scss +3 -0
  111. package/libs/css/style.vue.scss +175 -0
  112. package/libs/function/$parent.ts +22 -0
  113. package/libs/function/addUnit.ts +13 -0
  114. package/libs/function/color.ts +37 -0
  115. package/libs/function/colorGradient.ts +123 -0
  116. package/libs/function/debounce.ts +28 -0
  117. package/libs/function/deepClone.ts +39 -0
  118. package/libs/function/deepMerge.ts +34 -0
  119. package/libs/function/getParent.ts +59 -0
  120. package/libs/function/getRect.ts +26 -0
  121. package/libs/function/guid.ts +42 -0
  122. package/libs/function/md5.ts +397 -0
  123. package/libs/function/parent.ts +21 -0
  124. package/libs/function/queryParams.ts +60 -0
  125. package/libs/function/random.ts +16 -0
  126. package/libs/function/randomArray.ts +11 -0
  127. package/libs/function/route.ts +118 -0
  128. package/libs/function/sys.ts +15 -0
  129. package/libs/function/test.ts +229 -0
  130. package/libs/function/throttle.ts +31 -0
  131. package/libs/function/timeFormat.ts +54 -0
  132. package/libs/function/timeFrom.ts +48 -0
  133. package/libs/function/toast.ts +14 -0
  134. package/libs/function/trim.ts +21 -0
  135. package/libs/function/type2icon.ts +36 -0
  136. package/libs/hooks/useEmitter.ts +77 -0
  137. package/libs/hooks/useParent.ts +29 -0
  138. package/libs/request/index.ts +237 -0
  139. package/libs/store/index.ts +88 -0
  140. package/libs/util/area.ts +1 -0
  141. package/libs/util/async-validator.js +1356 -0
  142. package/libs/util/city.ts +1 -0
  143. package/libs/util/emitter.ts +112 -0
  144. package/libs/util/mitt.ts +118 -0
  145. package/libs/util/parent.ts +20 -0
  146. package/libs/util/province.ts +1 -0
  147. package/package.json +98 -0
  148. package/readme.md +165 -0
  149. package/theme.scss +38 -0
@@ -0,0 +1,156 @@
1
+ <template>
2
+ <view
3
+ @tap="backToTop"
4
+ class="u-back-top"
5
+ :class="['u-back-top--mode--' + mode]"
6
+ :style="[
7
+ {
8
+ bottom: bottom + 'rpx',
9
+ right: right + 'rpx',
10
+ borderRadius: mode == 'circle' ? '10000rpx' : '8rpx',
11
+ zIndex: uZIndex,
12
+ opacity: opacity
13
+ },
14
+ customStyle
15
+ ]"
16
+ >
17
+ <view class="u-back-top__content" v-if="!slots.default">
18
+ <u-icon @click="backToTop" :name="icon" :custom-style="iconStyle"></u-icon>
19
+ <view class="u-back-top__content__tips">
20
+ {{ tips }}
21
+ </view>
22
+ </view>
23
+ <slot v-else />
24
+ </view>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { ref, computed, watch, useSlots } from 'vue';
29
+
30
+ defineOptions({
31
+ name: 'u-back-top'
32
+ });
33
+
34
+ /**
35
+ * back-top 返回顶部按钮
36
+ * @description 页面滚动时显示的返回顶部按钮
37
+ * @property {String} mode 返回顶部的形状,circle-圆形,square-方形
38
+ * @property {String} icon 自定义图标
39
+ * @property {String} tips 提示文字
40
+ * @property {Number|String} duration 返回顶部滚动时间
41
+ * @property {Number|String} scrollTop 滚动距离
42
+ * @property {Number|String} top 距离顶部多少距离显示,单位rpx
43
+ * @property {Number|String} bottom 返回顶部按钮到底部的距离,单位rpx
44
+ * @property {Number|String} right 返回顶部按钮到右边的距离,单位rpx
45
+ * @property {Number|String} zIndex 层级
46
+ * @property {Object} iconStyle 图标的样式,对象形式
47
+ * @property {Object} customStyle 整个组件的样式
48
+ */
49
+ const props = defineProps({
50
+ /** 返回顶部的形状,circle-圆形,square-方形 */
51
+ mode: { type: String, default: 'circle' },
52
+ /** 自定义图标 */
53
+ icon: { type: String, default: 'arrow-upward' },
54
+ /** 提示文字 */
55
+ tips: { type: String, default: '' },
56
+ /** 返回顶部滚动时间 */
57
+ duration: { type: [Number, String], default: 100 },
58
+ /** 滚动距离 */
59
+ scrollTop: { type: [Number, String], default: 0 },
60
+ /** 距离顶部多少距离显示,单位rpx */
61
+ top: { type: [Number, String], default: 400 },
62
+ /** 返回顶部按钮到底部的距离,单位rpx */
63
+ bottom: { type: [Number, String], default: 200 },
64
+ /** 返回顶部按钮到右边的距离,单位rpx */
65
+ right: { type: [Number, String], default: 40 },
66
+ /** 层级 */
67
+ zIndex: { type: [Number, String], default: '9' },
68
+ /** 图标的样式,对象形式 */
69
+ iconStyle: {
70
+ type: Object,
71
+ default: () => ({
72
+ color: '#909399',
73
+ fontSize: '38rpx'
74
+ })
75
+ },
76
+ /** 整个组件的样式 */
77
+ customStyle: {
78
+ type: Object,
79
+ default: () => ({})
80
+ }
81
+ });
82
+
83
+ const slots = useSlots();
84
+
85
+ // 不透明度,为了让组件有一个显示和隐藏的过渡动画
86
+ const opacity = ref(0);
87
+ // 组件的z-index值,隐藏时设置为-1,就会看不到
88
+ const uZIndex = ref(-1);
89
+
90
+ /**
91
+ * 计算是否显示返回顶部按钮
92
+ * 由于scrollTop为页面的滚动距离,默认为px单位,这里将用于传入的top(rpx)值
93
+ * 转为px用于比较,如果滚动条到顶的距离大于设定的距离,就显示返回顶部的按钮
94
+ */
95
+ const showBackTop = computed(() => {
96
+ // uni.upx2px 用于将 rpx 转为 px
97
+ return Number(props.scrollTop) > (typeof uni !== 'undefined' && uni.upx2px ? uni.upx2px(Number(props.top)) : Number(props.top));
98
+ // #else
99
+ // return Number(props.scrollTop) > Number(props.top)
100
+ });
101
+
102
+ // 监听组件的显示与隐藏状态,修改组件的层级和不透明度
103
+ // 让组件有显示和消失的动画效果,如果用v-if控制组件状态,将无设置动画效果
104
+ watch(showBackTop, nVal => {
105
+ if (nVal) {
106
+ uZIndex.value = Number(props.zIndex);
107
+ opacity.value = 1;
108
+ } else {
109
+ uZIndex.value = -1;
110
+ opacity.value = 0;
111
+ }
112
+ });
113
+
114
+ /**
115
+ * 返回顶部方法
116
+ */
117
+ function backToTop() {
118
+ // uni.pageScrollTo 用于页面滚动到顶部
119
+ if (typeof uni !== 'undefined' && uni.pageScrollTo) {
120
+ uni.pageScrollTo({
121
+ scrollTop: 0,
122
+ duration: Number(props.duration)
123
+ });
124
+ }
125
+ }
126
+ </script>
127
+
128
+ <style lang="scss" scoped>
129
+ @import '../../libs/css/style.components.scss';
130
+
131
+ .u-back-top {
132
+ width: 80rpx;
133
+ height: 80rpx;
134
+ position: fixed;
135
+ z-index: 9;
136
+ @include vue-flex;
137
+ flex-direction: column;
138
+ justify-content: center;
139
+ background-color: #e1e1e1;
140
+ color: $u-content-color;
141
+ align-items: center;
142
+ transition: opacity 0.4s;
143
+
144
+ &__content {
145
+ @include vue-flex;
146
+ flex-direction: column;
147
+ align-items: center;
148
+
149
+ &__tips {
150
+ font-size: 24rpx;
151
+ transform: scale(0.8);
152
+ line-height: 1;
153
+ }
154
+ }
155
+ }
156
+ </style>
@@ -0,0 +1,189 @@
1
+ <template>
2
+ <view
3
+ v-if="show"
4
+ class="u-badge"
5
+ :class="[isDot ? 'u-badge-dot' : '', size === 'mini' ? 'u-badge-mini' : '', type ? 'u-badge--bg--' + type : '']"
6
+ :style="[
7
+ {
8
+ top: (offset as number[])[0] + 'rpx',
9
+ right: (offset as number[])[1] + 'rpx',
10
+ fontSize: fontSize + 'rpx',
11
+ position: absolute ? 'absolute' : 'static',
12
+ color: color,
13
+ backgroundColor: bgColor
14
+ },
15
+ boxStyle
16
+ ]"
17
+ >
18
+ {{ showText }}
19
+ </view>
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import { computed } from 'vue';
24
+
25
+ defineOptions({
26
+ name: 'u-badge'
27
+ });
28
+
29
+ /**
30
+ * badge 角标
31
+ * @description 本组件一般用于展示头像的地方,如个人中心,或者评论列表页的用户头像展示等场所。
32
+ * @tutorial https://www.uviewui.com/components/badge.html
33
+ * @property {String|Number} count 展示的数字,大于 overflowCount 时显示为 ${overflowCount}+,为0且show-zero为false时隐藏
34
+ * @property {Boolean} is-dot 不展示数字,只有一个小点(默认false)
35
+ * @property {Boolean} absolute 组件是否绝对定位,为true时,offset参数才有效(默认true)
36
+ * @property {String|Number} overflow-count 展示封顶的数字值(默认99)
37
+ * @property {String} type 使用预设的背景颜色(默认error)
38
+ * @property {Boolean} show-zero 当数值为 0 时,是否展示 Badge(默认false)
39
+ * @property {String} size Badge的尺寸,设为mini会得到小一号的Badge(默认default)
40
+ * @property {Array} offset 设置badge的位置偏移,格式为 [x, y],也即设置的为top和right的值,单位rpx。absolute为true时有效(默认[20, 20])
41
+ * @property {String} color 字体颜色(默认#ffffff)
42
+ * @property {String} bgColor 背景颜色,优先级比type高,如设置,type参数会失效
43
+ * @property {Boolean} is-center 组件中心点是否和父组件右上角重合,优先级比offset高,如设置,offset参数会失效(默认false)
44
+ * @example <u-badge type="error" count="7"></u-badge>
45
+ */
46
+
47
+ const props = defineProps({
48
+ /** 使用预设的背景颜色 primary,warning,success,error,info */
49
+ type: { type: String, default: 'error' },
50
+ /** Badge的尺寸,default, mini */
51
+ size: { type: String, default: 'default' },
52
+ /** 是否是圆点 */
53
+ isDot: { type: Boolean, default: false },
54
+ /** 显示的数值内容 */
55
+ count: { type: [Number, String], default: undefined },
56
+ /** 展示封顶的数字值 */
57
+ overflowCount: { type: Number, default: 99 },
58
+ /** 当数值为 0 时,是否展示 Badge */
59
+ showZero: { type: Boolean, default: false },
60
+ /** 位置偏移 [number, number] */
61
+ offset: { type: [Array, Object], default: () => [20, 20] },
62
+ /** 是否开启绝对定位,开启了offset才会起作用 */
63
+ absolute: { type: Boolean, default: true },
64
+ /** 字体大小 */
65
+ fontSize: { type: [String, Number], default: '24' },
66
+ /** 字体颜色 */
67
+ color: { type: String, default: '#ffffff' },
68
+ /** badge的背景颜色 */
69
+ bgColor: { type: String, default: '' },
70
+ /** 是否让badge组件的中心点和父组件右上角重合,配置的话,offset将会失效 */
71
+ isCenter: { type: Boolean, default: false }
72
+ });
73
+
74
+ /**
75
+ * 计算 badge 的定位和变换样式
76
+ */
77
+ const boxStyle = computed(() => {
78
+ let style: Record<string, any> = {};
79
+ if (props.isCenter) {
80
+ style.top = 0;
81
+ style.right = 0;
82
+ // Y轴-50%,意味着badge向上移动了badge自身高度一半,X轴50%,意味着向右移动了自身宽度一半
83
+ style.transform = 'translateY(-50%) translateX(50%)';
84
+ } else {
85
+ style.top = (props.offset as number[])[0] + 'rpx';
86
+ style.right = (props.offset as number[])[1] + 'rpx';
87
+ style.transform = 'translateY(0) translateX(0)';
88
+ }
89
+ // 如果尺寸为mini,后接上scale()
90
+ if (props.size === 'mini') {
91
+ style.transform = style.transform + ' scale(0.8)';
92
+ }
93
+ return style;
94
+ });
95
+
96
+ /**
97
+ * 计算显示的文本内容
98
+ */
99
+ const showText = computed(() => {
100
+ if (props.isDot) return '';
101
+ else {
102
+ if (Number(props.count) > props.overflowCount) return `${props.overflowCount}+`;
103
+ else return props.count;
104
+ }
105
+ });
106
+
107
+ /**
108
+ * 是否显示组件
109
+ */
110
+ const show = computed(() => {
111
+ // 如果count的值为0,并且showZero设置为false,不显示组件
112
+ if (Number(props.count) === 0 && props.showZero === false) return false;
113
+ else return true;
114
+ });
115
+ </script>
116
+
117
+ <style lang="scss" scoped>
118
+ @import '../../libs/css/style.components.scss';
119
+
120
+ .u-badge {
121
+ /* #ifndef APP-NVUE */
122
+ display: inline-flex;
123
+ /* #endif */
124
+ justify-content: center;
125
+ align-items: center;
126
+ line-height: 24rpx;
127
+ padding: 4rpx 8rpx;
128
+ border-radius: 100rpx;
129
+ z-index: 9;
130
+
131
+ &--bg--primary {
132
+ background-color: $u-type-primary;
133
+ }
134
+ &--bg--error {
135
+ background-color: $u-type-error;
136
+ }
137
+ &--bg--success {
138
+ background-color: $u-type-success;
139
+ }
140
+ &--bg--info {
141
+ background-color: $u-type-info;
142
+ }
143
+ &--bg--warning {
144
+ background-color: $u-type-warning;
145
+ }
146
+ }
147
+
148
+ .u-badge-dot {
149
+ height: 16rpx;
150
+ width: 16rpx;
151
+ border-radius: 100rpx;
152
+ line-height: 1;
153
+ }
154
+
155
+ .u-badge-mini {
156
+ transform: scale(0.8);
157
+ transform-origin: center center;
158
+ }
159
+
160
+ // .u-primary {
161
+ // background: $u-type-primary;
162
+ // color: #fff;
163
+ // }
164
+
165
+ // .u-error {
166
+ // background: $u-type-error;
167
+ // color: #fff;
168
+ // }
169
+
170
+ // .u-warning {
171
+ // background: $u-type-warning;
172
+ // color: #fff;
173
+ // }
174
+
175
+ // .u-success {
176
+ // background: $u-type-success;
177
+ // color: #fff;
178
+ // }
179
+
180
+ // .u-black {
181
+ // background: #585858;
182
+ // color: #fff;
183
+ // }
184
+
185
+ .u-info {
186
+ background-color: $u-type-info;
187
+ color: #fff;
188
+ }
189
+ </style>