rrj-astra-ui 1.1.26 → 1.1.28
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/AuiIcon.vue +1 -1
- package/components/AuiInput.vue +51 -11
- package/package.json +1 -1
package/components/AuiIcon.vue
CHANGED
package/components/AuiInput.vue
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
2
|
+
<view
|
|
3
|
+
:class="['aui-input-item',`aui-theme-${theme}`]"
|
|
4
|
+
@click="handleClick"
|
|
5
|
+
<!-- 移除 disabled 对 pointerEvents 的控制,改为通过 clickableWhenDisabled 控制 -->
|
|
6
|
+
:style="{ pointerEvents: (disabled && !clickableWhenDisabled) ? 'none' : 'auto' }"
|
|
7
|
+
>
|
|
3
8
|
<view class="aui-input-befor">
|
|
4
9
|
<slot name="befor"></slot>
|
|
5
10
|
</view>
|
|
@@ -9,11 +14,14 @@
|
|
|
9
14
|
:placeholder="placeholder"
|
|
10
15
|
v-model="inputValue"
|
|
11
16
|
:class="['aui-input', `aui-input-${size}`,`aui-input-align-${textAlign}`]"
|
|
12
|
-
:readonly="readonly"
|
|
13
|
-
:disabled="disabled"
|
|
17
|
+
:readonly="readonly || (disabled && !clickableWhenDisabled)" <!-- 功能禁用逻辑调整 -->
|
|
18
|
+
:disabled="disabled" <!-- 仅控制 input 原生禁用样式,不影响点击 -->
|
|
14
19
|
@input="handleInput"
|
|
15
20
|
:style="`height:${height};line-height:${height}`"
|
|
16
21
|
@blur="handleBlur"
|
|
22
|
+
@click.stop="handleInputClick"
|
|
23
|
+
<!-- 阻止 input 原生 disabled 对点击的拦截 -->
|
|
24
|
+
@mousedown.stop.prevent
|
|
17
25
|
/>
|
|
18
26
|
</view>
|
|
19
27
|
<view class="aui-input-after">
|
|
@@ -26,10 +34,8 @@
|
|
|
26
34
|
import { defineProps, defineEmits, ref, watch } from 'vue';
|
|
27
35
|
const __name = 'AuiInput';
|
|
28
36
|
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
name: __name
|
|
32
|
-
})
|
|
37
|
+
// 新增 click 事件到 emits 定义中
|
|
38
|
+
const emits = defineEmits(['input', 'update:modelValue', 'blur', 'click']);
|
|
33
39
|
|
|
34
40
|
const props = defineProps({
|
|
35
41
|
type: {
|
|
@@ -49,6 +55,11 @@ const props = defineProps({
|
|
|
49
55
|
type: Boolean,
|
|
50
56
|
default: false
|
|
51
57
|
},
|
|
58
|
+
// 新增:控制禁用时是否允许点击
|
|
59
|
+
clickableWhenDisabled: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: false
|
|
62
|
+
},
|
|
52
63
|
modelValue: {
|
|
53
64
|
type: [String, Number],
|
|
54
65
|
default: ''
|
|
@@ -73,8 +84,6 @@ const props = defineProps({
|
|
|
73
84
|
}
|
|
74
85
|
});
|
|
75
86
|
|
|
76
|
-
const emits = defineEmits(['input', 'update:modelValue', 'blur']);
|
|
77
|
-
|
|
78
87
|
const inputValue = ref(props.modelValue);
|
|
79
88
|
|
|
80
89
|
// 监听 props.modelValue 的变化
|
|
@@ -90,7 +99,8 @@ const handleInput = (e) => {
|
|
|
90
99
|
} else {
|
|
91
100
|
newValue = e.target ? e.target.value : undefined;
|
|
92
101
|
}
|
|
93
|
-
|
|
102
|
+
// 禁用状态下不处理输入(即使点击可用,也不能输入)
|
|
103
|
+
if (newValue !== undefined && !props.disabled) {
|
|
94
104
|
inputValue.value = newValue;
|
|
95
105
|
console.log('输入事件触发,新值:', newValue);
|
|
96
106
|
emits('input', newValue);
|
|
@@ -101,6 +111,22 @@ const handleInput = (e) => {
|
|
|
101
111
|
const handleBlur = (e) => {
|
|
102
112
|
emits('blur', e);
|
|
103
113
|
};
|
|
114
|
+
|
|
115
|
+
// 处理根元素的点击事件
|
|
116
|
+
const handleClick = (e) => {
|
|
117
|
+
// 只有当 clickableWhenDisabled 为 true 或未禁用时,才触发点击事件
|
|
118
|
+
if (!props.disabled || props.clickableWhenDisabled) {
|
|
119
|
+
emits('click', e);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// 处理input自身的点击(可选)
|
|
124
|
+
const handleInputClick = (e) => {
|
|
125
|
+
// 禁用时也允许input点击透传
|
|
126
|
+
if (!props.disabled || props.clickableWhenDisabled) {
|
|
127
|
+
emits('click', e);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
104
130
|
</script>
|
|
105
131
|
|
|
106
132
|
<style scoped lang="scss">
|
|
@@ -112,6 +138,7 @@ const handleBlur = (e) => {
|
|
|
112
138
|
border: 1px solid $aui-border-color;
|
|
113
139
|
border-radius: 8px;
|
|
114
140
|
padding: 0 10px;
|
|
141
|
+
cursor: pointer; // 始终显示指针,提示可点击
|
|
115
142
|
}
|
|
116
143
|
.aui-input-befor {
|
|
117
144
|
margin-right: 10px;
|
|
@@ -130,9 +157,23 @@ const handleBlur = (e) => {
|
|
|
130
157
|
transition: border-color 0.3s;
|
|
131
158
|
height: 36px;
|
|
132
159
|
line-height: 36px;
|
|
160
|
+
border: none;
|
|
161
|
+
width: 100%;
|
|
162
|
+
background: transparent;
|
|
133
163
|
&:focus {
|
|
134
164
|
border-color: $aui-primary-color;
|
|
135
165
|
}
|
|
166
|
+
// readonly状态样式
|
|
167
|
+
&[readonly] {
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
background: transparent;
|
|
170
|
+
}
|
|
171
|
+
// disabled状态样式(仅视觉,不影响点击)
|
|
172
|
+
&[disabled] {
|
|
173
|
+
cursor: pointer; // 改为pointer,提示可点击
|
|
174
|
+
color: #9CA3AF; // 保留禁用文字颜色
|
|
175
|
+
background: transparent;
|
|
176
|
+
}
|
|
136
177
|
}
|
|
137
178
|
.aui-theme-flat{
|
|
138
179
|
background-color: #F5F5F5;
|
|
@@ -160,7 +201,6 @@ const handleBlur = (e) => {
|
|
|
160
201
|
.aui-input-small {
|
|
161
202
|
font-size: 12px;
|
|
162
203
|
}
|
|
163
|
-
|
|
164
204
|
.aui-input-large {
|
|
165
205
|
font-size: 18px;
|
|
166
206
|
}
|