Skip to content

Commit

Permalink
chore(searchbar): improve type def
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu committed Dec 16, 2023
1 parent aec33ce commit 64bbe73
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
11 changes: 5 additions & 6 deletions src/packages/__VUE/searchbar/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@
import { toRefs, reactive, computed, ref, onMounted, PropType, Ref, CSSProperties } from 'vue';
import { createComponent, renderIcon } from '@/packages/utils/create';
import { CircleClose } from '@nutui/icons-vue-taro';
import { TextAlign } from './type';
import { SearchbarConfirmType, SearchbarInputAlign, SearchbarShape } from './types';
import { useLocale } from '@/packages/utils/useLocale';
const { create } = createComponent('searchbar');
export type confirmTextType = 'send' | 'search' | 'next' | 'go' | 'done';
const cN = 'NutSearchbar';
Expand All @@ -74,7 +73,7 @@ export default create({
default: 'text'
},
shape: {
type: String,
type: String as PropType<SearchbarShape>,
default: 'round'
},
maxLength: {
Expand Down Expand Up @@ -118,11 +117,11 @@ export default create({
default: false
},
inputAlign: {
type: String,
type: String as PropType<SearchbarInputAlign>,
default: 'left'
},
confirmType: {
type: String as PropType<confirmTextType>,
type: String as PropType<SearchbarConfirmType>,
default: 'done'
},
safeAreaInsetBottom: {
Expand Down Expand Up @@ -222,7 +221,7 @@ export default create({
const styleSearchbar = computed(() => {
const style: CSSProperties = {
textAlign: props.inputAlign as TextAlign
textAlign: props.inputAlign
};
return style;
});
Expand Down
11 changes: 6 additions & 5 deletions src/packages/__VUE/searchbar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
</template>

<script lang="ts">
import { toRefs, reactive, computed, onMounted, ref, Ref, CSSProperties } from 'vue';
import { toRefs, reactive, computed, onMounted, ref, Ref, CSSProperties, PropType } from 'vue';
import { createComponent, renderIcon } from '@/packages/utils/create';
import { CircleClose } from '@nutui/icons-vue';
import { TextAlign } from './type';
import { SearchbarInputAlign, SearchbarShape } from './types';
import { useLocale } from '@/packages/utils/useLocale';
const { create } = createComponent('searchbar');
Expand All @@ -79,7 +79,7 @@ export default create({
default: ''
},
shape: {
type: String,
type: String as PropType<SearchbarShape>,
default: 'round'
},
maxLength: {
Expand Down Expand Up @@ -123,7 +123,7 @@ export default create({
default: false
},
inputAlign: {
type: String,
type: String as PropType<SearchbarInputAlign>,
default: 'left'
},
safeAreaInsetBottom: {
Expand Down Expand Up @@ -219,7 +219,7 @@ export default create({
const styleSearchbar = computed(() => {
const style: CSSProperties = {
textAlign: props.inputAlign as TextAlign
textAlign: props.inputAlign
};
return style;
});
Expand Down Expand Up @@ -251,3 +251,4 @@ export default create({
}
});
</script>
./types
1 change: 0 additions & 1 deletion src/packages/__VUE/searchbar/type.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/packages/__VUE/searchbar/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type SearchbarInputAlign = 'start' | 'end' | 'left' | 'right' | 'center' | 'justify' | 'match-parent';
export type SearchbarConfirmType = 'send' | 'search' | 'next' | 'go' | 'done';
export type SearchbarShape = 'round' | 'square';

0 comments on commit 64bbe73

Please sign in to comment.