Skip to content

Commit

Permalink
refactor: 类型文件统一为 types,增加 fixednavitem 类型 (#1789)
Browse files Browse the repository at this point in the history
* refactor: 类型文件统一为 types,增加 fixednavitem 类型

* refactor: 类型文件统一为 types,增加 fixednavitem 类型
  • Loading branch information
oasis-cloud authored Dec 15, 2023
1 parent e3c03c8 commit 6efc345
Show file tree
Hide file tree
Showing 34 changed files with 62 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/packages/address/address.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Popup from '@/packages/popup/index.taro'
import { ExistRender } from './existRender.taro'
import { CustomRender } from './customRender.taro'
import { useConfig } from '@/packages/configprovider/configprovider.taro'
import { AddressList } from './type'
import { AddressList } from './types'
import {
CascaderOption,
CascaderOptionKey,
Expand Down
2 changes: 1 addition & 1 deletion src/packages/address/address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Popup from '@/packages/popup'
import { CustomRender } from './customRender'
import { ExistRender } from './existRender'
import { useConfig } from '@/packages/configprovider'
import { AddressList } from './type'
import { AddressList } from './types'
import {
CascaderOption,
CascaderOptionKey,
Expand Down
2 changes: 1 addition & 1 deletion src/packages/address/existRender.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FunctionComponent, MouseEventHandler, ReactNode } from 'react'
import { Check, Location } from '@nutui/icons-react-taro'
import { ScrollView } from '@tarojs/components'
import { useConfig } from '@/packages/configprovider/configprovider.taro'
import { AddressList } from './type'
import { AddressList } from './types'

export interface ExistRenderProps {
type: string
Expand Down
2 changes: 1 addition & 1 deletion src/packages/address/existRender.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FunctionComponent, MouseEventHandler, ReactNode } from 'react'
import { Check, Location } from '@nutui/icons-react'
import { useConfig } from '@/packages/configprovider'
import { AddressList } from './type'
import { AddressList } from './types'

export interface ExistRenderProps {
type: string
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/packages/animate/__tests__/animate.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { render, waitFor, fireEvent } from '@testing-library/react'
import '@testing-library/jest-dom'
import { AnimateType } from '../type'
import { AnimateType } from '../types'

import { Animate } from '../animate'

Expand Down
2 changes: 1 addition & 1 deletion src/packages/animate/animate.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, FunctionComponent } from 'react'
import classNames from 'classnames'
import { AnimateType, AnimateAction } from './type'
import { AnimateType, AnimateAction } from './types'

import { BasicComponent, ComponentDefaults } from '@/utils/typings'

Expand Down
2 changes: 1 addition & 1 deletion src/packages/animate/animate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, FunctionComponent } from 'react'
import classNames from 'classnames'
import { AnimateType, AnimateAction } from './type'
import { AnimateType, AnimateAction } from './types'

import { BasicComponent, ComponentDefaults } from '@/utils/typings'

Expand Down
2 changes: 1 addition & 1 deletion src/packages/animate/index.taro.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Animate } from './animate.taro'

export type { AnimateType, AnimateAction } from './type'
export type { AnimateType, AnimateAction } from './types'
export type { AnimateProps } from './animate.taro'
export default Animate
2 changes: 1 addition & 1 deletion src/packages/animate/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Animate } from './animate'

export type { AnimateType, AnimateAction } from './type'
export type { AnimateType, AnimateAction } from './types'
export type { AnimateProps } from './animate'
export default Animate
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ test('test aysnc value and duration props', async () => {
const listNumbers = container.querySelectorAll('.nut-countup-number')
expect(listNumbers.length).toBe(8)
jest.advanceTimersByTime(CountUp.defaultProps?.delay ?? 0)
expect(listNumbers[0]).toHaveAttribute(
'style',
'transition: transform 1.2s ease-in-out; transform: translate(0, -50%); webkit-transform: translate(0, -50%);'
)
await waitFor(() => {
expect(listNumbers[0]).toHaveAttribute(
'style',
'transition: transform 1.2s ease-in-out; transform: translate(0, -50%); webkit-transform: translate(0, -50%);'
)
})

value = `${Math.floor(Math.random() * 999999)}.${Math.floor(
Math.random() * 89 + 10
)}`
Expand Down
2 changes: 1 addition & 1 deletion src/packages/calendar/calendar.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Popup from '@/packages/popup/index.taro'
import CalendarItem from '@/packages/calendaritem/index.taro'
import { Utils } from '@/utils/date'
import { useConfig } from '@/packages/configprovider/configprovider.taro'
import { Day, SelectedType } from './type'
import { Day, SelectedType } from './types'
import { ComponentDefaults } from '@/utils/typings'

type CalendarRef = {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/calendar/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Popup from '@/packages/popup'
import CalendarItem from '@/packages/calendaritem'
import { Utils } from '@/utils/date'
import { useConfig } from '@/packages/configprovider'
import { Day, SelectedType } from './type'
import { Day, SelectedType } from './types'
import { ComponentDefaults } from '@/utils/typings'

type CalendarRef = {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/packages/calendar/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Utils } from '@/utils/date'
import { Day, MonthInfo } from './type'
import { Day, MonthInfo } from './types'

export const splitDate = (date: string) => {
const split = date.indexOf('-') !== -1 ? '-' : '/'
Expand Down
2 changes: 1 addition & 1 deletion src/packages/calendaritem/calendaritem.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
isEnd,
isStartAndEnd,
} from '../calendar/utils'
import { Day, MonthInfo, InputDate, SelectedType } from '../calendar/type'
import { Day, MonthInfo, InputDate, SelectedType } from '../calendar/types'

type CalendarRef = {
scrollToDate: (date: string) => void
Expand Down
2 changes: 1 addition & 1 deletion src/packages/calendaritem/calendaritem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
isEnd,
isStartAndEnd,
} from '../calendar/utils'
import { Day, MonthInfo, InputDate, SelectedType } from '../calendar/type'
import { Day, MonthInfo, InputDate, SelectedType } from '../calendar/types'

type CalendarRef = {
scrollToDate: (date: string) => void
Expand Down
2 changes: 1 addition & 1 deletion src/packages/checkboxgroup/checkboxgroup.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useImperativeHandle } from 'react'
import classNames from 'classnames'
import { RadioGroupOptionType } from '@/packages/radiogroup/type'
import { RadioGroupOptionType } from '@/packages/radiogroup/types'
import { Checkbox } from '../checkbox/checkbox.taro'
import Context from './context'
import { usePropsValue } from '@/utils/use-props-value'
Expand Down
2 changes: 1 addition & 1 deletion src/packages/checkboxgroup/checkboxgroup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useImperativeHandle } from 'react'
import classNames from 'classnames'
import { RadioGroupOptionType } from '@/packages/radiogroup/type'
import { RadioGroupOptionType } from '@/packages/radiogroup/types'
import { Checkbox } from '../checkbox/checkbox'
import Context from './context'
import { usePropsValue } from '@/utils/use-props-value'
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/packages/fixednav/__tests__/fixednav.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as React from 'react'
import { render, fireEvent, screen } from '@testing-library/react'
import '@testing-library/jest-dom'

import FixedNav from '../index'
import FixedNav, { FixedNavItem } from '../index'

const list = [
const list: FixedNavItem[] = [
{
id: 1,
text: '首页',
Expand Down
13 changes: 6 additions & 7 deletions src/packages/fixednav/fixednav.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import { ArrowLeft } from '@nutui/icons-react-taro'
import Overlay from '@/packages/overlay/index.taro'
import { useConfig } from '@/packages/configprovider/configprovider.taro'
import { BasicComponent, ComponentDefaults } from '@/utils/typings'

export type FixedNavDirection = 'right' | 'left'
export type FixedNavPosition = {
top?: string
bottom?: string
}
import {
FixedNavDirection,
FixedNavItem,
FixedNavPosition,
} from '@/packages/fixednav/types'

export interface FixedNavProps extends BasicComponent {
visible: boolean
overlay: boolean
list: Array<any>
list: Array<FixedNavItem>
activeText: string
inactiveText: string
position: FixedNavPosition
Expand Down
13 changes: 6 additions & 7 deletions src/packages/fixednav/fixednav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import { ArrowLeft } from '@nutui/icons-react'
import Overlay from '@/packages/overlay'
import { useConfig } from '@/packages/configprovider'
import { BasicComponent, ComponentDefaults } from '@/utils/typings'

export type FixedNavDirection = 'right' | 'left'
export type FixedNavPosition = {
top?: string
bottom?: string
}
import {
FixedNavDirection,
FixedNavItem,
FixedNavPosition,
} from '@/packages/fixednav/types'

export interface FixedNavProps extends BasicComponent {
visible: boolean
overlay: boolean
list: Array<any>
list: Array<FixedNavItem>
activeText: string
inactiveText: string
position: FixedNavPosition
Expand Down
8 changes: 3 additions & 5 deletions src/packages/fixednav/index.taro.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FixedNav } from './fixednav.taro'

export type {
FixedNavProps,
FixedNavDirection,
FixedNavPosition,
} from './fixednav.taro'
export type { FixedNavDirection, FixedNavPosition, FixedNavItem } from './types'

export type { FixedNavProps } from './fixednav.taro'
export default FixedNav
8 changes: 3 additions & 5 deletions src/packages/fixednav/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FixedNav } from './fixednav'

export type {
FixedNavProps,
FixedNavDirection,
FixedNavPosition,
} from './fixednav'
export type { FixedNavDirection, FixedNavPosition, FixedNavItem } from './types'

export type { FixedNavProps } from './fixednav'
export default FixedNav
14 changes: 14 additions & 0 deletions src/packages/fixednav/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Key, ReactNode } from 'react'

export type FixedNavDirection = 'right' | 'left'
export type FixedNavPosition = {
top?: string
bottom?: string
}

export interface FixedNavItem {
id: Key
num?: number
text: ReactNode
icon: ReactNode
}
2 changes: 1 addition & 1 deletion src/packages/radiogroup/radiogroup.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback } from 'react'
import classNames from 'classnames'
import { RadioGroupOptionType } from './type'
import { RadioGroupOptionType } from './types'
import RadioContext from './context'
import Radio from '@/packages/radio/index.taro'
import { usePropsValue } from '@/utils/use-props-value'
Expand Down
2 changes: 1 addition & 1 deletion src/packages/radiogroup/radiogroup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback } from 'react'
import classNames from 'classnames'
import { RadioGroupOptionType } from './type'
import { RadioGroupOptionType } from './types'
import RadioContext from './context'
import Radio from '@/packages/radio/index'
import { usePropsValue } from '@/utils/use-props-value'
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/packages/virtuallist/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PositionType, Data } from './type'
import { PositionType, Data } from './types'

// 缓存列表初始化信息
const initPositinoCache = (reaItemSize: number, length = 0): PositionType[] => {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/virtuallist/virtuallist.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, {
import { ScrollView } from '@tarojs/components'
import { getSystemInfoSync } from '@tarojs/taro'
import classNames from 'classnames'
import { Data, PositionType, VirtualListState } from './type'
import { Data, PositionType, VirtualListState } from './types'
import { binarySearch, initPositinoCache, updateItemSize } from './utils'
import { BasicComponent, ComponentDefaults } from '@/utils/typings'

Expand Down
2 changes: 1 addition & 1 deletion src/packages/virtuallist/virtuallist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, {
useState,
} from 'react'
import classNames from 'classnames'
import type { Data, VirtualListState, PositionType } from './type'
import type { Data, VirtualListState, PositionType } from './types'
import {
initPositinoCache,
getListTotalSize,
Expand Down

0 comments on commit 6efc345

Please sign in to comment.