Skip to content

Commit 55922ba

Browse files
committed
fix: types
1 parent 2669d02 commit 55922ba

File tree

9 files changed

+25
-29
lines changed

9 files changed

+25
-29
lines changed

src/packages/dialog/content.taro.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const defaultContentProps: ContentProps = {
99
header: null,
1010
footer: null,
1111
close: '',
12-
footerDirection: '',
12+
footerDirection: 'horizontal',
1313
onClick: () => {},
1414
}
1515

@@ -39,7 +39,7 @@ export const Content: FunctionComponent<
3939
footer && (
4040
<View
4141
className={classNames(`${classPrefix}-footer`, {
42-
[footerDirection as any]: footerDirection,
42+
[footerDirection]: footerDirection,
4343
})}
4444
>
4545
{footer}
@@ -65,9 +65,7 @@ export const Content: FunctionComponent<
6565
style={{ display: visible ? 'flex' : 'none' }}
6666
>
6767
{renderHeader()}
68-
<View className={`${classPrefix}-content`}>
69-
<>{children}</>
70-
</View>
68+
<View className={`${classPrefix}-content`}>{children}</View>
7169
{renderFooter()}
7270
</View>
7371
</View>

src/packages/dialog/content.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const defaultContentProps: ContentProps = {
88
header: '',
99
footer: '',
1010
close: '',
11-
footerDirection: '',
11+
footerDirection: 'horizontal',
1212
onClick: () => {},
1313
}
1414

@@ -23,24 +23,24 @@ export const Content: FunctionComponent<
2323
footer,
2424
close,
2525
footerDirection,
26-
onClick,
2726
children,
2827
style,
2928
className,
29+
onClick,
3030
} = { ...defaultContentProps, ...props }
3131

3232
const classPrefix = 'nut-dialog'
3333

3434
const renderHeader = () => {
35-
return title ? <div className={`${classPrefix}-header`}>{title}</div> : null
35+
return title && <div className={`${classPrefix}-header`}>{title}</div>
3636
}
3737

3838
const renderFooter = () => {
3939
return (
4040
footer && (
4141
<div
4242
className={classNames(`${classPrefix}-footer`, {
43-
[footerDirection as any]: footerDirection,
43+
[footerDirection]: footerDirection,
4444
})}
4545
>
4646
{footer}
@@ -66,9 +66,7 @@ export const Content: FunctionComponent<
6666
style={{ display: visible ? 'flex' : 'none' }}
6767
>
6868
{renderHeader()}
69-
<div className={`${classPrefix}-content`}>
70-
<>{children}</>
71-
</div>
69+
<div className={`${classPrefix}-content`}>{children}</div>
7270
{renderFooter()}
7371
</div>
7472
</div>

src/packages/dialog/dialog.taro.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export const BaseDialog: FunctionComponent<Partial<DialogBasicProps>> & {
182182
)
183183
}
184184

185-
const onHandleClickOverlay = (e: any) => {
185+
const onHandleClickOverlay = (e: React.MouseEvent<HTMLElement>) => {
186186
if (closeOnOverlayClick && visible && e.target === e.currentTarget) {
187187
const closed = onOverlayClick && onOverlayClick(e)
188188
closed && onClose && onClose()

src/packages/dialog/dialogwrap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const DialogWrap: FunctionComponent<
3434
...restProps
3535
} = { ...defaultDialogWrapProps, ...props }
3636

37-
const onHandleClickOverlay = (e: any) => {
37+
const onHandleClickOverlay = (e: React.MouseEvent<HTMLElement>) => {
3838
if (closeOnOverlayClick && visible && e.target === e.currentTarget) {
3939
const closed = onOverlayClick && onOverlayClick(e)
4040
closed && onClose?.()

src/packages/dialog/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ export type DialogConfigType = {
99
}
1010

1111
export type DialogCloseIconPosition = 'top-right' | 'top-left' | 'bottom'
12-
12+
export type DialogFooterDirection = 'horizontal' | 'vertical'
1313
export interface ContentProps extends BasicComponent {
1414
visible: boolean
1515
title: ReactNode
1616
header: ReactNode
1717
footer: ReactNode
1818
close: ReactNode
19-
footerDirection: string
20-
onClick: (event: any) => void
19+
footerDirection: DialogFooterDirection
20+
onClick: (event: MouseEvent<HTMLElement>) => void
2121
}
2222
export type DialogWrapProps = OverlayProps &
2323
ContentProps & {
@@ -27,7 +27,7 @@ export type DialogWrapProps = OverlayProps &
2727
overlayClassName: string
2828
onCancel: () => void
2929
onClose: () => void
30-
onOverlayClick: (e: MouseEvent) => boolean | void
30+
onOverlayClick: (e: MouseEvent<HTMLElement>) => boolean | void
3131
}
3232

3333
export type DialogBasicProps = DialogWrapProps &

src/packages/fixednav/demos/taro/demo1.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react'
2-
import { FixedNav } from '@nutui/nutui-react-taro'
2+
import { FixedNav, FixedNavItem } from '@nutui/nutui-react-taro'
33

44
const Demo1 = () => {
55
const list = [
@@ -29,7 +29,10 @@ const Demo1 = () => {
2929
const change = (value: boolean) => {
3030
setVisible(value)
3131
}
32-
const selected = (item: any, event: any) => {
32+
const selected = (
33+
item: FixedNavItem,
34+
event: React.MouseEvent<HTMLDivElement, MouseEvent>
35+
) => {
3336
console.log(item, event)
3437
}
3538
return (

src/packages/overlay/overlay.taro.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ export const defaultOverlayProps: OverlayProps = {
1919
afterClose: () => {},
2020
}
2121
export const Overlay: FunctionComponent<
22-
Partial<OverlayProps> &
23-
Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'> & {
24-
onClick: (event: React.MouseEvent | ITouchEvent) => void
25-
}
22+
Partial<OverlayProps> & Omit<React.HTMLAttributes<HTMLDivElement>, 'onClick'>
2623
> = (props) => {
2724
const {
2825
children,

src/packages/overlay/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface OverlayProps extends BasicComponent {
66
closeOnOverlayClick: boolean
77
visible: boolean
88
lockScroll: boolean
9-
onClick: (event: React.MouseEvent) => void
9+
onClick: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
1010
afterShow: () => void
1111
afterClose: () => void
1212
}

src/packages/toast/demos/taro/demo4.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ const Demo4 = () => {
1616
duration?: number,
1717
title?: string
1818
) => {
19-
const changeState = Object.assign(state, {
19+
setState({
20+
...state,
2021
icon,
2122
content,
22-
duration,
23-
title,
23+
duration: duration || 0,
24+
title: title || '',
2425
})
25-
setState(changeState)
2626
}
2727
return (
2828
<>

0 commit comments

Comments
 (0)