Browse Source

Merge pull request #2122 from lkjh3214/V4_input

feat(input): 当显示清除按钮时,新增props:input失去焦点后,是否展示清除按钮
eiinu 2 years ago
parent
commit
8c12cac5db

+ 1 - 0
src/packages/__VUE/input/demo.vue

@@ -20,6 +20,7 @@
       clearSize="14"
       clearSize="14"
       show-word-limit
       show-word-limit
       max-length="50"
       max-length="50"
+      :showClearIcon="true"
     >
     >
       <template #clear>
       <template #clear>
         <Close width="12" height="12" @click="clearValue"></Close>
         <Close width="12" height="12" @click="clearValue"></Close>

+ 3 - 1
src/packages/__VUE/input/doc.en-US.md

@@ -131,7 +131,7 @@ Use `readonly` to set the input box to read-only status, and use `disabled` to s
 
 
 ### Show Clear Icon
 ### Show Clear Icon
 
 
-Display the clear icon during the input process by setting `clearable`.
+Display the clear icon during input by setting 'clearable'. The clear button will be hidden after losing focus. You can set the clear button to continue to display after losing focus through 'showClearIcon'.
 
 
 :::demo
 :::demo
 
 
@@ -150,6 +150,7 @@ Display the clear icon during the input process by setting `clearable`.
     clearSize="14"
     clearSize="14"
     show-word-limit
     show-word-limit
     max-length="50"
     max-length="50"
+    :showClearIcon="true"
   >
   >
     <template #clear>
     <template #clear>
       <Close width="12" height="12" @click="clearValue"></Close>
       <Close width="12" height="12" @click="clearValue"></Close>
@@ -416,6 +417,7 @@ After setting the `maxlength` and `show-word-limit` attributes, word count will
 | autofocus    | Whether to auto focus, unsupported in iOS     | boolean        | `false` |
 | autofocus    | Whether to auto focus, unsupported in iOS     | boolean        | `false` |
 | max-length   | Max length of value                  | string | number | - |
 | max-length   | Max length of value                  | string | number | - |
 | clearable    | Whether to be clearable              | boolean        | `false`  |
 | clearable    | Whether to be clearable              | boolean        | `false`  |
+| showClearIcon `4.0.2` | Whether to continue to display the clear button after losing focus, which will take effect when 'clearable' is set | boolean        | `false`  |
 | clear-size   | Clear Icon `font-size`               | string        | `14`  |
 | clear-size   | Clear Icon `font-size`               | string        | `14`  |
 | show-word-limit | Whether to show word limit, need to set the `max-length` prop | boolean | `false`  |
 | show-word-limit | Whether to show word limit, need to set the `max-length` prop | boolean | `false`  |
 | error         | Whether to mark the input content in red   | boolean | `false`  |
 | error         | Whether to mark the input content in red   | boolean | `false`  |

+ 3 - 1
src/packages/__VUE/input/doc.md

@@ -132,7 +132,7 @@ app.use(Button);
 
 
 ### 显示清除图标
 ### 显示清除图标
 
 
-通过设置 `clearable` 在输入过程中展示清除图标。
+通过设置 `clearable` 在输入过程中展示清除图标。清除按钮,在失去焦点后将隐藏,可通过 `showClearIcon` 设置失去焦点后继续展示清除按钮。
 
 
 :::demo
 :::demo
 
 
@@ -151,6 +151,7 @@ app.use(Button);
     clearSize="14"
     clearSize="14"
     show-word-limit
     show-word-limit
     max-length="50"
     max-length="50"
+    :showClearIcon="true"
   >
   >
     <template #clear>
     <template #clear>
       <Close width="12" height="12" @click="clearValue"></Close>
       <Close width="12" height="12" @click="clearValue"></Close>
@@ -419,6 +420,7 @@ app.use(Button);
 | autofocus    | 是否自动获得焦点,`iOS` 系统不支持该属性     | boolean        | `false` |
 | autofocus    | 是否自动获得焦点,`iOS` 系统不支持该属性     | boolean        | `false` |
 | max-length   | 限制最长输入字符                       | string | number | - |
 | max-length   | 限制最长输入字符                       | string | number | - |
 | clearable    | 展示清除 `Icon`                         | boolean        | `false`  |
 | clearable    | 展示清除 `Icon`                         | boolean        | `false`  |
+| showClearIcon `4.0.2` | 是否在失去焦点后,继续展示清除按钮,在设置 `clearable` 时生效 | boolean        | `false`  |
 | clear-size   | 清除图标的 `font-size` 大小           | string        | `14`  |
 | clear-size   | 清除图标的 `font-size` 大小           | string        | `14`  |
 | show-word-limit | 是否显示限制最长输入字符,需要设置 `max-length` 属性 | boolean | `false`  |
 | show-word-limit | 是否显示限制最长输入字符,需要设置 `max-length` 属性 | boolean | `false`  |
 | error         | 是否标红                                | boolean | `false`  |
 | error         | 是否标红                                | boolean | `false`  |

+ 3 - 1
src/packages/__VUE/input/doc.taro.md

@@ -132,7 +132,7 @@ app.use(Button);
 
 
 ### 显示清除图标
 ### 显示清除图标
 
 
-通过设置 `clearable` 在输入过程中展示清除图标。
+通过设置 `clearable` 在输入过程中展示清除图标。清除按钮,在失去焦点后将隐藏,可通过 `showClearIcon` 设置失去焦点后继续展示清除按钮。
 
 
 :::demo
 :::demo
 
 
@@ -151,6 +151,7 @@ app.use(Button);
     clearSize="14"
     clearSize="14"
     show-word-limit
     show-word-limit
     max-length="50"
     max-length="50"
+    :showClearIcon="true"
   >
   >
     <template #clear>
     <template #clear>
       <Close width="12" height="12" size="12" @click="clearValue"></Close>
       <Close width="12" height="12" size="12" @click="clearValue"></Close>
@@ -432,6 +433,7 @@ app.use(Button);
 | autofocus    | 是否自动获得焦点,`iOS` 系统不支持该属性     | boolean        | `false` |
 | autofocus    | 是否自动获得焦点,`iOS` 系统不支持该属性     | boolean        | `false` |
 | max-length      | 限制最长输入字符                       | string | number | - |
 | max-length      | 限制最长输入字符                       | string | number | - |
 | clearable    | 展示清除 `Icon`                         | boolean        | `false`  |
 | clearable    | 展示清除 `Icon`                         | boolean        | `false`  |
+| showClearIcon `4.0.2` | 是否在失去焦点后,继续展示清除按钮,在设置 `clearable` 时生效 | boolean        | `false`  |
 | clear-size   | 清除图标的 `font-size` 大小           | string        | `14`  |
 | clear-size   | 清除图标的 `font-size` 大小           | string        | `14`  |
 | show-word-limit | 是否显示限制最长输入字符,需要设置 `max-length` 属性 | boolean | `false`  |
 | show-word-limit | 是否显示限制最长输入字符,需要设置 `max-length` 属性 | boolean | `false`  |
 | error         | 是否标红                                | boolean | `false`  |
 | error         | 是否标红                                | boolean | `false`  |

+ 5 - 3
src/packages/__VUE/input/index.scss

@@ -110,9 +110,11 @@ textarea {
   }
   }
   &-clear-box {
   &-clear-box {
     height: 100%;
     height: 100%;
-    .nut-input-clear {
-      vertical-align: -2px;
-    }
+    display: flex;
+    align-items: center;
+    // .nut-input-clear {
+    //   vertical-align: -2px;
+    // }
   }
   }
   &-clear {
   &-clear {
     width: 16px;
     width: 16px;

+ 9 - 1
src/packages/__VUE/input/index.taro.vue

@@ -35,7 +35,11 @@
             >/{{ maxLength }}
             >/{{ maxLength }}
           </view>
           </view>
         </view>
         </view>
-        <view class="nut-input-clear-box" v-if="clearable && !readonly" v-show="active && modelValue.length > 0">
+        <view
+          class="nut-input-clear-box"
+          v-if="clearable && !readonly"
+          v-show="(active || showClearIcon) && modelValue.length > 0"
+        >
           <slot name="clear">
           <slot name="clear">
             <MaskClose
             <MaskClose
               class="nut-input-clear"
               class="nut-input-clear"
@@ -153,6 +157,10 @@ export default create({
     alwaysSystem: {
     alwaysSystem: {
       type: Boolean,
       type: Boolean,
       default: false
       default: false
+    },
+    showClearIcon: {
+      type: Boolean,
+      default: false
     }
     }
   },
   },
   components: { MaskClose },
   components: { MaskClose },

+ 9 - 1
src/packages/__VUE/input/index.vue

@@ -32,7 +32,11 @@
             >/{{ maxLength }}
             >/{{ maxLength }}
           </view>
           </view>
         </view>
         </view>
-        <view class="nut-input-clear-box" v-if="clearable && !readonly" v-show="active && modelValue.length > 0">
+        <view
+          class="nut-input-clear-box"
+          v-if="clearable && !readonly"
+          v-show="(active || showClearIcon) && modelValue.length > 0"
+        >
           <slot name="clear">
           <slot name="clear">
             <MaskClose
             <MaskClose
               class="nut-input-clear"
               class="nut-input-clear"
@@ -141,6 +145,10 @@ export default create({
     error: {
     error: {
       type: Boolean,
       type: Boolean,
       default: false
       default: false
+    },
+    showClearIcon: {
+      type: Boolean,
+      default: false
     }
     }
   },
   },
   components: { MaskClose },
   components: { MaskClose },

+ 1 - 0
src/sites/mobile-taro/vue/src/dentry/pages/input/index.vue

@@ -23,6 +23,7 @@
       clearSize="14"
       clearSize="14"
       show-word-limit
       show-word-limit
       max-length="50"
       max-length="50"
+      :showClearIcon="true"
     >
     >
       <template #clear>
       <template #clear>
         <Close width="12" height="12" size="12" @click="clearValue"></Close>
         <Close width="12" height="12" size="12" @click="clearValue"></Close>