hy-app 0.5.11 → 0.5.13
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/components/hy-button/hy-button.vue +289 -275
- package/components/hy-button/index.scss +24 -1
- package/components/hy-button/props.ts +143 -135
- package/components/hy-button/typing.d.ts +35 -30
- package/components/hy-coupon/hy-coupon.vue +183 -172
- package/components/hy-coupon/index.scss +20 -23
- package/components/hy-coupon/props.ts +108 -103
- package/components/hy-form/hy-form.vue +220 -220
- package/components/hy-input/hy-input.vue +333 -333
- package/components/hy-input/index.scss +1 -2
- package/components/hy-input/props.ts +186 -186
- package/components/hy-notice-bar/hy-row-notice.vue +121 -121
- package/components/hy-parse/node/node.vue +619 -422
- package/components/hy-parse/parser.js +1253 -1060
- package/components/hy-table/hy-table.vue +579 -358
- package/components/hy-table/index.scss +134 -159
- package/components/hy-table/props.ts +62 -47
- package/components/hy-table/typing.d.ts +29 -34
- package/components/hy-tabs/hy-tabs.vue +335 -335
- package/components/hy-tag/index.scss +1 -0
- package/components/hy-text/hy-text.vue +237 -237
- package/components/hy-text/props.ts +115 -115
- package/components/hy-textarea/hy-textarea.vue +198 -197
- package/components/hy-textarea/index.scss +2 -3
- package/components/hy-toast/hy-toast.vue +190 -190
- package/libs/css/theme.scss +1 -0
- package/libs/css/vars.scss +2 -2
- package/libs/typing/modules/common.d.ts +139 -139
- package/libs/utils/inside.ts +336 -350
- package/package.json +2 -2
- package/web-types.json +1 -1
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<HyOverlay :show="isShow" :zIndex="tmpConfig.overlay ? 10070 : -1" :custom-style="overlayStyle">
|
|
3
|
-
<view :style="[contentStyle]" :class="contentClass">
|
|
4
|
-
<hy-loading
|
|
5
|
-
v-if="tmpConfig.loading"
|
|
6
|
-
:mode="tmpConfig.loadMode || 'circle'"
|
|
7
|
-
:color="loadingIconColor"
|
|
8
|
-
inactiveColor="#F0E6EF"
|
|
9
|
-
size="25"
|
|
10
|
-
:customStyle="{ marginBottom: '20px' }"
|
|
11
|
-
></hy-loading>
|
|
12
|
-
<view
|
|
13
|
-
v-else-if="iconNameCom"
|
|
14
|
-
:class="['hy-toast__content--icon', `hy-toast__content--icon__${tmpConfig.type}`]"
|
|
15
|
-
>
|
|
16
|
-
<hy-icon :name="iconNameCom" size="17" color="#FFFFFF"></hy-icon>
|
|
17
|
-
</view>
|
|
18
|
-
<text
|
|
19
|
-
:class="[
|
|
20
|
-
'hy-toast__content--
|
|
21
|
-
!tmpConfig.icon ? `hy-toast__content--text__${tmpConfig.type}` : ''
|
|
22
|
-
]"
|
|
23
|
-
>
|
|
24
|
-
{{ tmpConfig.message }}
|
|
25
|
-
</text>
|
|
26
|
-
</view>
|
|
27
|
-
</HyOverlay>
|
|
28
|
-
</template>
|
|
29
|
-
|
|
30
|
-
<script lang="ts">
|
|
31
|
-
export default {
|
|
32
|
-
name: 'hy-toast',
|
|
33
|
-
options: {
|
|
34
|
-
addGlobalClass: true,
|
|
35
|
-
virtualHost: true,
|
|
36
|
-
styleIsolation: 'shared'
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<script setup lang="ts">
|
|
42
|
-
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
|
|
43
|
-
import type { CSSProperties } from 'vue'
|
|
44
|
-
import type ToastOptions from './typing'
|
|
45
|
-
import { ColorConfig, iconName, getWindowInfo, hexToRgb } from '../../libs'
|
|
46
|
-
// 组件
|
|
47
|
-
import HyOverlay from '../hy-overlay/hy-overlay.vue'
|
|
48
|
-
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
49
|
-
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Toast 组件主要用于消息通知、加载提示、操作结果提示等醒目提示效果,我们为其提供了多种丰富的API。
|
|
53
|
-
* @displayName hy-toast
|
|
54
|
-
*/
|
|
55
|
-
defineOptions({})
|
|
56
|
-
|
|
57
|
-
const isShow = ref(false)
|
|
58
|
-
const tmpConfig = ref<ToastOptions>({})
|
|
59
|
-
const config: ToastOptions = reactive({
|
|
60
|
-
message: '',
|
|
61
|
-
type: '',
|
|
62
|
-
duration: 2000,
|
|
63
|
-
icon: false,
|
|
64
|
-
position: 'center',
|
|
65
|
-
complete: null,
|
|
66
|
-
overlay: true,
|
|
67
|
-
loading: false
|
|
68
|
-
})
|
|
69
|
-
let timer: any = null
|
|
70
|
-
|
|
71
|
-
const isThemeType = (type: string): boolean =>
|
|
72
|
-
['error', 'warning', 'success', 'primary', 'info'].includes(type)
|
|
73
|
-
|
|
74
|
-
const overlayStyle = computed(() => {
|
|
75
|
-
const style: CSSProperties = {
|
|
76
|
-
justifyContent: 'center',
|
|
77
|
-
alignItems: 'center',
|
|
78
|
-
display: 'flex'
|
|
79
|
-
}
|
|
80
|
-
// 将遮罩设置为100%透明度,避免出现灰色背景
|
|
81
|
-
style.backgroundColor = 'rgba(0, 0, 0, 0)'
|
|
82
|
-
return style
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
const iconNameCom = computed(() => {
|
|
86
|
-
// 只有不为none,并且type为error|warning|succes|info时候,才显示图标
|
|
87
|
-
if (!tmpConfig.value.icon || !tmpConfig.value.type) {
|
|
88
|
-
return ''
|
|
89
|
-
}
|
|
90
|
-
if (tmpConfig.value.icon === true) {
|
|
91
|
-
if (isThemeType(tmpConfig.value.type)) {
|
|
92
|
-
return iconName(tmpConfig.value.type)
|
|
93
|
-
} else {
|
|
94
|
-
return ''
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
return tmpConfig.value.icon
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @description 内容盒子的样式
|
|
103
|
-
* */
|
|
104
|
-
const contentStyle = computed(() => {
|
|
105
|
-
const windowHeight = getWindowInfo().windowHeight,
|
|
106
|
-
style: CSSProperties = {}
|
|
107
|
-
let value = 0
|
|
108
|
-
// 根据top和bottom,对Y轴进行窗体高度的百分比偏移
|
|
109
|
-
if (tmpConfig.value.position === 'top') {
|
|
110
|
-
value = -windowHeight * 0.25
|
|
111
|
-
} else if (tmpConfig.value.position === 'bottom') {
|
|
112
|
-
value = windowHeight * 0.25
|
|
113
|
-
}
|
|
114
|
-
style.transform = `translateY(${value}px)`
|
|
115
|
-
return style
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
const contentClass = computed(() => {
|
|
119
|
-
return [
|
|
120
|
-
'hy-toast__content',
|
|
121
|
-
'hy-toast__' + tmpConfig.value.type,
|
|
122
|
-
tmpConfig.value.loading && 'hy-toast__content--loading'
|
|
123
|
-
]
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
const loadingIconColor = computed(() => {
|
|
127
|
-
let colorTmp = 'rgb(255, 255, 255)'
|
|
128
|
-
if (isThemeType(tmpConfig.value.type!)) {
|
|
129
|
-
// loading-icon组件内部会对color参数进行一个透明度处理,该方法要求传入的颜色值
|
|
130
|
-
// 必须为rgb格式的,所以这里做一个处理
|
|
131
|
-
colorTmp = hexToRgb(ColorConfig[tmpConfig.value.type!]) as string
|
|
132
|
-
}
|
|
133
|
-
return colorTmp
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
onMounted(() => {
|
|
137
|
-
// 监听全局事件
|
|
138
|
-
uni.$on('__hy_toast_open__', show)
|
|
139
|
-
uni.$on('__hy_toast_close__', hide)
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
onUnmounted(() => {
|
|
143
|
-
uni.$off('__hy_toast_open__', show)
|
|
144
|
-
uni.$off('__hy_toast_close__', hide)
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @description 显示toast组件,由父组件通过xxx.show(options)形式调用
|
|
149
|
-
* */
|
|
150
|
-
const show = (options: ToastOptions) => {
|
|
151
|
-
// 不将结果合并到this.config变量,避免多次调用u-toast,前后的配置造成混乱
|
|
152
|
-
tmpConfig.value = Object.assign(config, options)
|
|
153
|
-
// 清除定时器
|
|
154
|
-
clearTimer()
|
|
155
|
-
isShow.value = true
|
|
156
|
-
// -1时不自动关闭
|
|
157
|
-
if (tmpConfig.value.duration !== -1 && !tmpConfig.value.loading) {
|
|
158
|
-
timer = setTimeout(() => {
|
|
159
|
-
// 倒计时结束,清除定时器,隐藏toast组件
|
|
160
|
-
clearTimer()
|
|
161
|
-
// 判断是否存在callback方法,如果存在就执行
|
|
162
|
-
typeof tmpConfig.value.complete === 'function' && tmpConfig.value.complete()
|
|
163
|
-
}, tmpConfig.value.duration)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// 隐藏toast组件,由父组件通过this.$refs.xxx.hide()形式调用
|
|
168
|
-
const hide = () => {
|
|
169
|
-
config.loading = false
|
|
170
|
-
clearTimer()
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* @description 清除定时任务
|
|
174
|
-
* */
|
|
175
|
-
const clearTimer = () => {
|
|
176
|
-
isShow.value = false
|
|
177
|
-
// 清除定时器
|
|
178
|
-
clearTimeout(timer)
|
|
179
|
-
timer = null
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
defineExpose({
|
|
183
|
-
show,
|
|
184
|
-
hide
|
|
185
|
-
})
|
|
186
|
-
</script>
|
|
187
|
-
|
|
188
|
-
<style scoped lang="scss">
|
|
189
|
-
@import './index.scss';
|
|
190
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<HyOverlay :show="isShow" :zIndex="tmpConfig.overlay ? 10070 : -1" :custom-style="overlayStyle">
|
|
3
|
+
<view :style="[contentStyle]" :class="contentClass">
|
|
4
|
+
<hy-loading
|
|
5
|
+
v-if="tmpConfig.loading"
|
|
6
|
+
:mode="tmpConfig.loadMode || 'circle'"
|
|
7
|
+
:color="loadingIconColor"
|
|
8
|
+
inactiveColor="#F0E6EF"
|
|
9
|
+
size="25"
|
|
10
|
+
:customStyle="{ marginBottom: '20px' }"
|
|
11
|
+
></hy-loading>
|
|
12
|
+
<view
|
|
13
|
+
v-else-if="iconNameCom"
|
|
14
|
+
:class="['hy-toast__content--icon', `hy-toast__content--icon__${tmpConfig.type}`]"
|
|
15
|
+
>
|
|
16
|
+
<hy-icon :name="iconNameCom" size="17" color="#FFFFFF"></hy-icon>
|
|
17
|
+
</view>
|
|
18
|
+
<text
|
|
19
|
+
:class="[
|
|
20
|
+
'hy-toast__content--test',
|
|
21
|
+
!tmpConfig.icon ? `hy-toast__content--text__${tmpConfig.type}` : ''
|
|
22
|
+
]"
|
|
23
|
+
>
|
|
24
|
+
{{ tmpConfig.message }}
|
|
25
|
+
</text>
|
|
26
|
+
</view>
|
|
27
|
+
</HyOverlay>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script lang="ts">
|
|
31
|
+
export default {
|
|
32
|
+
name: 'hy-toast',
|
|
33
|
+
options: {
|
|
34
|
+
addGlobalClass: true,
|
|
35
|
+
virtualHost: true,
|
|
36
|
+
styleIsolation: 'shared'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<script setup lang="ts">
|
|
42
|
+
import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
|
|
43
|
+
import type { CSSProperties } from 'vue'
|
|
44
|
+
import type ToastOptions from './typing'
|
|
45
|
+
import { ColorConfig, iconName, getWindowInfo, hexToRgb } from '../../libs'
|
|
46
|
+
// 组件
|
|
47
|
+
import HyOverlay from '../hy-overlay/hy-overlay.vue'
|
|
48
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
49
|
+
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Toast 组件主要用于消息通知、加载提示、操作结果提示等醒目提示效果,我们为其提供了多种丰富的API。
|
|
53
|
+
* @displayName hy-toast
|
|
54
|
+
*/
|
|
55
|
+
defineOptions({})
|
|
56
|
+
|
|
57
|
+
const isShow = ref(false)
|
|
58
|
+
const tmpConfig = ref<ToastOptions>({})
|
|
59
|
+
const config: ToastOptions = reactive({
|
|
60
|
+
message: '',
|
|
61
|
+
type: '',
|
|
62
|
+
duration: 2000,
|
|
63
|
+
icon: false,
|
|
64
|
+
position: 'center',
|
|
65
|
+
complete: null,
|
|
66
|
+
overlay: true,
|
|
67
|
+
loading: false
|
|
68
|
+
})
|
|
69
|
+
let timer: any = null
|
|
70
|
+
|
|
71
|
+
const isThemeType = (type: string): boolean =>
|
|
72
|
+
['error', 'warning', 'success', 'primary', 'info'].includes(type)
|
|
73
|
+
|
|
74
|
+
const overlayStyle = computed(() => {
|
|
75
|
+
const style: CSSProperties = {
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
display: 'flex'
|
|
79
|
+
}
|
|
80
|
+
// 将遮罩设置为100%透明度,避免出现灰色背景
|
|
81
|
+
style.backgroundColor = 'rgba(0, 0, 0, 0)'
|
|
82
|
+
return style
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const iconNameCom = computed(() => {
|
|
86
|
+
// 只有不为none,并且type为error|warning|succes|info时候,才显示图标
|
|
87
|
+
if (!tmpConfig.value.icon || !tmpConfig.value.type) {
|
|
88
|
+
return ''
|
|
89
|
+
}
|
|
90
|
+
if (tmpConfig.value.icon === true) {
|
|
91
|
+
if (isThemeType(tmpConfig.value.type)) {
|
|
92
|
+
return iconName(tmpConfig.value.type)
|
|
93
|
+
} else {
|
|
94
|
+
return ''
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
return tmpConfig.value.icon
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @description 内容盒子的样式
|
|
103
|
+
* */
|
|
104
|
+
const contentStyle = computed(() => {
|
|
105
|
+
const windowHeight = getWindowInfo().windowHeight,
|
|
106
|
+
style: CSSProperties = {}
|
|
107
|
+
let value = 0
|
|
108
|
+
// 根据top和bottom,对Y轴进行窗体高度的百分比偏移
|
|
109
|
+
if (tmpConfig.value.position === 'top') {
|
|
110
|
+
value = -windowHeight * 0.25
|
|
111
|
+
} else if (tmpConfig.value.position === 'bottom') {
|
|
112
|
+
value = windowHeight * 0.25
|
|
113
|
+
}
|
|
114
|
+
style.transform = `translateY(${value}px)`
|
|
115
|
+
return style
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const contentClass = computed(() => {
|
|
119
|
+
return [
|
|
120
|
+
'hy-toast__content',
|
|
121
|
+
'hy-toast__' + tmpConfig.value.type,
|
|
122
|
+
tmpConfig.value.loading && 'hy-toast__content--loading'
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const loadingIconColor = computed(() => {
|
|
127
|
+
let colorTmp = 'rgb(255, 255, 255)'
|
|
128
|
+
if (isThemeType(tmpConfig.value.type!)) {
|
|
129
|
+
// loading-icon组件内部会对color参数进行一个透明度处理,该方法要求传入的颜色值
|
|
130
|
+
// 必须为rgb格式的,所以这里做一个处理
|
|
131
|
+
colorTmp = hexToRgb(ColorConfig[tmpConfig.value.type!]) as string
|
|
132
|
+
}
|
|
133
|
+
return colorTmp
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
onMounted(() => {
|
|
137
|
+
// 监听全局事件
|
|
138
|
+
uni.$on('__hy_toast_open__', show)
|
|
139
|
+
uni.$on('__hy_toast_close__', hide)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
onUnmounted(() => {
|
|
143
|
+
uni.$off('__hy_toast_open__', show)
|
|
144
|
+
uni.$off('__hy_toast_close__', hide)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @description 显示toast组件,由父组件通过xxx.show(options)形式调用
|
|
149
|
+
* */
|
|
150
|
+
const show = (options: ToastOptions) => {
|
|
151
|
+
// 不将结果合并到this.config变量,避免多次调用u-toast,前后的配置造成混乱
|
|
152
|
+
tmpConfig.value = Object.assign(config, options)
|
|
153
|
+
// 清除定时器
|
|
154
|
+
clearTimer()
|
|
155
|
+
isShow.value = true
|
|
156
|
+
// -1时不自动关闭
|
|
157
|
+
if (tmpConfig.value.duration !== -1 && !tmpConfig.value.loading) {
|
|
158
|
+
timer = setTimeout(() => {
|
|
159
|
+
// 倒计时结束,清除定时器,隐藏toast组件
|
|
160
|
+
clearTimer()
|
|
161
|
+
// 判断是否存在callback方法,如果存在就执行
|
|
162
|
+
typeof tmpConfig.value.complete === 'function' && tmpConfig.value.complete()
|
|
163
|
+
}, tmpConfig.value.duration)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// 隐藏toast组件,由父组件通过this.$refs.xxx.hide()形式调用
|
|
168
|
+
const hide = () => {
|
|
169
|
+
config.loading = false
|
|
170
|
+
clearTimer()
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* @description 清除定时任务
|
|
174
|
+
* */
|
|
175
|
+
const clearTimer = () => {
|
|
176
|
+
isShow.value = false
|
|
177
|
+
// 清除定时器
|
|
178
|
+
clearTimeout(timer)
|
|
179
|
+
timer = null
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
defineExpose({
|
|
183
|
+
show,
|
|
184
|
+
hide
|
|
185
|
+
})
|
|
186
|
+
</script>
|
|
187
|
+
|
|
188
|
+
<style scoped lang="scss">
|
|
189
|
+
@import './index.scss';
|
|
190
|
+
</style>
|
package/libs/css/theme.scss
CHANGED
|
@@ -93,4 +93,5 @@ $hy-border-margin-padding-sm: var(--hy-border-margin-padding-sm, 10rpx) !default
|
|
|
93
93
|
$hy-border-margin-padding-base: var(--hy-border-margin-padding-base, 20rpx) !default;
|
|
94
94
|
$hy-border-margin-padding-lg: var(--hy-border-margin-padding-lg, 30rpx) !default;
|
|
95
95
|
/* 底部线条 */
|
|
96
|
+
/* TODO: 边框不能写1rpx否则在某些机型无法显示 */
|
|
96
97
|
$hy-border-line: var(--hy-border-line, 1px solid #e8e8e8) !default;
|
package/libs/css/vars.scss
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
--hy-background-image--mask--two-flanks: linear-gradient(180deg, hsla(0, 0%, 100%, 0.95), hsla(0, 0%, 100%, 0.6)),
|
|
26
26
|
linear-gradient(0deg, hsla(0, 0%, 100%, 0.95), hsla(0, 0%, 100%, 0.6));
|
|
27
27
|
|
|
28
|
-
--hy-border-line:
|
|
28
|
+
--hy-border-line: 1px solid #e8e8e8;
|
|
29
29
|
--hy-border-color: #c2c2c4;
|
|
30
30
|
--hy-border-color--2: #c9cacc;
|
|
31
31
|
}
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
--hy-background-image--mask--two-flanks: linear-gradient(180deg, hsla(0, 0%, 15%, 0.95), hsla(0, 0%, 10%, 0.6)),
|
|
62
62
|
linear-gradient(0deg, hsla(0, 0%, 15%, 0.95), hsla(0, 0%, 10%, 0.6));
|
|
63
63
|
|
|
64
|
-
--hy-border-line:
|
|
64
|
+
--hy-border-line: 1px solid #3c3f44;
|
|
65
65
|
--hy-border-color: #3c3f44;
|
|
66
66
|
--hy-border-color--2: #FFFFFF;
|
|
67
67
|
}
|