56
56
</view >
57
57
</template >
58
58
<script lang="ts">
59
- import { PropType , ref , reactive , computed , onMounted , watch , ComputedRef , h } from ' vue' ;
59
+ import Taro from ' @tarojs/taro' ;
60
+ import { MaskClose } from ' @nutui/icons-vue-taro' ;
61
+ import { ref , reactive , computed , onMounted , watch , h , toRef } from ' vue' ;
60
62
import { createComponent } from ' @/packages/utils/create' ;
61
63
import { formatNumber } from ' ./util' ;
62
- import { MaskClose } from ' @nutui/icons-vue-taro' ;
63
- import Taro from ' @tarojs/taro' ;
64
+ import { useFormDisabled } from ' ../form/common' ;
64
65
66
+ import type { PropType , ComputedRef } from ' vue' ;
65
67
import type { InputType , InputAlignType , InputFormatTrigger , InputTarget , ConfirmTextType , InputEvent } from ' ./type' ;
66
68
67
69
const { componentName, create } = createComponent (' input' );
@@ -158,6 +160,7 @@ export default create({
158
160
emits: [' update:modelValue' , ' blur' , ' focus' , ' clear' , ' keypress' , ' click' , ' clickInput' , ' confirm' ],
159
161
160
162
setup(props , { emit }) {
163
+ const disabled = useFormDisabled (toRef (props , ' disabled' ));
161
164
const active = ref (false );
162
165
163
166
const inputRef = ref ();
@@ -193,7 +196,7 @@ export default create({
193
196
const prefixCls = componentName ;
194
197
return {
195
198
[prefixCls ]: true ,
196
- [` ${prefixCls }--disabled ` ]: props . disabled ,
199
+ [` ${prefixCls }--disabled ` ]: disabled . value ,
197
200
[` ${prefixCls }--required ` ]: props .required ,
198
201
[` ${prefixCls }--error ` ]: props .error ,
199
202
[` ${prefixCls }--border ` ]: props .border ,
@@ -243,7 +246,7 @@ export default create({
243
246
};
244
247
245
248
const onFocus = (event : Event ) => {
246
- if (props . disabled || props .readonly ) {
249
+ if (disabled . value || props .readonly ) {
247
250
return ;
248
251
}
249
252
active .value = true ;
@@ -252,7 +255,7 @@ export default create({
252
255
};
253
256
254
257
const onBlur = (event : Event ) => {
255
- if (props . disabled || props .readonly ) {
258
+ if (disabled . value || props .readonly ) {
256
259
return ;
257
260
}
258
261
setTimeout (() => {
@@ -271,7 +274,7 @@ export default create({
271
274
272
275
const clear = (event : Event ) => {
273
276
event .stopPropagation ();
274
- if (props . disabled ) return ;
277
+ if (disabled . value ) return ;
275
278
emit (' update:modelValue' , ' ' , event );
276
279
// emit('change', '', event);
277
280
emit (' clear' , ' ' , event );
@@ -285,7 +288,7 @@ export default create({
285
288
};
286
289
287
290
const onClickInput = (event : MouseEvent ) => {
288
- if (props . disabled ) {
291
+ if (disabled . value ) {
289
292
return ;
290
293
}
291
294
emit (' clickInput' , event );
@@ -341,6 +344,7 @@ export default create({
341
344
active ,
342
345
classes ,
343
346
styles ,
347
+ disabled ,
344
348
onInput ,
345
349
onFocus ,
346
350
onBlur ,
0 commit comments