Skip to content

Commit

Permalink
chore(tabs): improve type def (#2788)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Dec 21, 2023
1 parent 0b22304 commit 5e68145
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
35 changes: 24 additions & 11 deletions src/packages/__VUE/tabs/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,29 @@
</view>
</template>
<script lang="ts">
import { createComponent } from '@/packages/utils/create';
import Taro from '@tarojs/taro';
import {
onMounted,
provide,
VNode,
ref,
Ref,
computed,
onActivated,
watch,
nextTick,
CSSProperties,
PropType
} from 'vue';
import NutScrollView from '../scroll-view/index.taro.vue';
import { JoySmile } from '@nutui/icons-vue-taro';
import { createComponent } from '@/packages/utils/create';
import { pxCheck } from '@/packages/utils/pxCheck';
import { TypeOfFun } from '@/packages/utils/util';
import { onMounted, provide, VNode, ref, Ref, computed, onActivated, watch, nextTick, CSSProperties } from 'vue';
import raf from '@/packages/utils/raf';
import Taro from '@tarojs/taro';
import type { RectItem } from './types';
import { useTabContentTouch } from './hooks';
import { useTaroRect } from '@/packages/utils/useTaroRect';
import NutScrollView from '../scroll-view/index.taro.vue';
import type { RectItem, TabsDirection, TabsSize, TabsType } from './types';
export class Title {
title = '';
Expand All @@ -67,8 +79,9 @@ export class Title {
disabled = false;
constructor() {}
}
export type TabsSize = 'large' | 'normal' | 'small';
const { create } = createComponent('tabs');
export default create({
components: {
JoySmile,
Expand All @@ -84,16 +97,16 @@ export default create({
default: ''
},
direction: {
type: String,
default: 'horizontal' //vertical
type: String as PropType<TabsDirection>,
default: 'horizontal'
},
size: {
type: String as import('vue').PropType<TabsSize>,
type: String as PropType<TabsSize>,
default: 'normal'
},
type: {
type: String,
default: 'line' //card、line、smile
type: String as PropType<TabsType>,
default: 'line'
},
titleScroll: {
type: Boolean,
Expand Down
35 changes: 25 additions & 10 deletions src/packages/__VUE/tabs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,39 @@
</view>
</template>
<script lang="ts">
import {
onMounted,
provide,
VNode,
ref,
Ref,
computed,
onActivated,
watch,
nextTick,
CSSProperties,
PropType
} from 'vue';
import NutSticky from '../sticky/index.vue';
import { JoySmile } from '@nutui/icons-vue';
import { createComponent } from '@/packages/utils/create';
import { pxCheck } from '@/packages/utils/pxCheck';
import { TypeOfFun } from '@/packages/utils/util';
import { useRect } from '@/packages/utils/useRect';
import { onMounted, provide, VNode, ref, Ref, computed, onActivated, watch, nextTick, CSSProperties } from 'vue';
import raf from '@/packages/utils/raf';
import { useTabContentTouch } from './hooks';
import type { TabsDirection, TabsSize, TabsType } from './types';
export class Title {
title = '';
titleSlot?: VNode[];
paneKey = '';
disabled = false;
constructor() {}
}
export type TabsSize = 'large' | 'normal' | 'small';
import NutSticky from '../sticky/index.vue';
const { create } = createComponent('tabs');
import { JoySmile } from '@nutui/icons-vue';
import { useTabContentTouch } from './hooks';
export default create({
components: { NutSticky, JoySmile },
props: {
Expand All @@ -99,16 +114,16 @@ export default create({
default: ''
},
direction: {
type: String,
default: 'horizontal' //vertical
type: String as PropType<TabsDirection>,
default: 'horizontal'
},
size: {
type: String as import('vue').PropType<TabsSize>,
type: String as PropType<TabsSize>,
default: 'normal'
},
type: {
type: String,
default: 'line' //card、line、smile
type: String as PropType<TabsType>,
default: 'line'
},
titleScroll: {
type: Boolean,
Expand Down
3 changes: 3 additions & 0 deletions src/packages/__VUE/tabs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ export type RectItem = {
top: number;
width: number;
};
export type TabsDirection = 'horizontal' | 'vertical';
export type TabsSize = 'large' | 'normal' | 'small';
export type TabsType = 'line' | 'smile';

0 comments on commit 5e68145

Please sign in to comment.