Browse Source

fix(searchbar): textalign types

suzigang 3 years ago
parent
commit
8314e19556

+ 2 - 2
package.json

@@ -116,10 +116,10 @@
     "transliteration": "^2.2.0",
     "ts-jest": "^26.5.5",
     "typescript": "4.6.4",
-    "vite": "^2.9.12",
+    "vite": "2.9.0",
     "vite-plugin-dts": "^1.0.5",
     "vite-plugin-md": "^0.11.8",
-    "vue": "3.2.24",
+    "vue": "^3.2.24",
     "vue-jest": "^5.0.0-alpha.7"
   },
   "eslintConfig": {

+ 6 - 15
src/packages/__VUE/searchbar/index.taro.vue

@@ -24,15 +24,10 @@
             @focus="valueFocus"
             @blur="valueBlur"
             @confirm="handleSubmit"
-            :style="(styleSearchbar as CSSProperties)"
+            :style="styleSearchbar"
           />
         </form>
-        <view
-          @click="handleClear"
-          class="nut-searchbar__input-clear"
-          v-if="clearable"
-          v-show="(modelValue as string).length > 0"
-        >
+        <view @click="handleClear" class="nut-searchbar__input-clear" v-if="clearable" v-show="modelValue.length > 0">
           <nut-icon :name="clearIcon" size="12" color="#555"></nut-icon>
         </view>
       </view>
@@ -50,10 +45,6 @@
 import { toRefs, reactive, computed, ref, onMounted, PropType, Ref, CSSProperties } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 const { create, translate } = createComponent('searchbar');
-// interface Events {
-//   eventName: 'change' | 'focus' | 'blur' | 'clear' | 'update:modelValue';
-//   params: (string | number | Event)[];
-// }
 export type confirmTextType = 'send' | 'search' | 'next' | 'go' | 'done';
 
 export default create({
@@ -202,12 +193,12 @@ export default create({
     };
 
     const styleSearchbar = computed(() => {
-      return {
-        style: {
-          textAlign: props.inputAlign
-        }
+      const style: CSSProperties = {
+        textAlign: props.inputAlign as import('./type').TextAlign
       };
+      return style;
     });
+
     const inputsearch: Ref<HTMLElement | null> = ref(null);
     onMounted(() => {
       if (props.autofocus) {

+ 1 - 2
src/packages/__VUE/searchbar/index.vue

@@ -56,7 +56,6 @@
 <script lang="ts">
 import { toRefs, reactive, computed, onMounted, ref, Ref, CSSProperties } from 'vue';
 import { createComponent } from '@/packages/utils/create';
-import { TextAlignProperty } from 'csstype';
 const { create, translate } = createComponent('searchbar');
 // interface Events {
 //   eventName: 'change' | 'focus' | 'blur' | 'clear' | 'update:modelValue';
@@ -209,7 +208,7 @@ export default create({
 
     const styleSearchbar = computed(() => {
       const style: CSSProperties = {
-        textAlign: props.inputAlign as TextAlignProperty
+        textAlign: props.inputAlign as import('./type').TextAlign
       };
       return style;
     });

+ 1 - 0
src/packages/__VUE/searchbar/type.ts

@@ -0,0 +1 @@
+export type TextAlign = 'start' | 'end' | 'left' | 'right' | 'center' | 'justify' | 'match-parent';