Skip to content

Commit f624840

Browse files
authored
feat: support forwarding modal props (#61)
* feat: suppport forwarding modalProps * chore: replace registry of dependences in lockfile * chore: replace npm with pnpm & update husky to fix ci * test: add test case & demo
1 parent bc86577 commit f624840

File tree

11 files changed

+11296
-38791
lines changed

11 files changed

+11296
-38791
lines changed

.github/workflows/node.js.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ jobs:
2626
react: 17
2727
steps:
2828
- uses: actions/checkout@v2
29+
- uses: pnpm/[email protected]
30+
with:
31+
version: 8.10.5
2932
- name: Use Node.js LTS
3033
uses: actions/setup-node@v2
3134
with:
3235
node-version: 'lts/*'
33-
- run: npm ci
34-
- run: npm run build --if-present
35-
- run: npm test -- --coverage
36+
- run: pnpm i
37+
- run: pnpm run build --if-present
38+
- run: pnpm run test --coverage
3639
env:
3740
RSUITE_VERSION: ${{ matrix.rsuite }}
3841
REACT_VERSION: ${{ matrix.react }}

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v2
1717
- uses: actions/setup-node@v2
18-
- run: npm ci
18+
- uses: pnpm/[email protected]
19+
with:
20+
version: 8.10.5
21+
- run: pnpm i
1922
- name: Semantic Release
20-
run: npx semantic-release
23+
run: pnpm semantic-release

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
pnpm lint-staged

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ alert(
3939
modalConfig?: AlertModalProps
4040
): Promise<void>;
4141

42-
interface AlertModalProps {
42+
interface WrappedModalProps {
43+
modalProps: ModalProps;
44+
}
45+
46+
interface AlertModalProps extends WrappedModalProps {
4347
okButtonText?: string;
4448
onOk?: (() => void) | (() => Promise<any>);
4549
}
@@ -68,8 +72,12 @@ confirm(
6872
modalConfig?: ConfirmModalProps
6973
): Promise<boolean>;
7074

71-
interface ConfirmModalProps {
75+
interface WrappedModalProps {
76+
modalProps: ModalProps;
77+
}
78+
interface ConfirmModalProps extends WrappedModalProps {
7279
okButtonText?: string;
80+
okButtonDangerous?: boolean;
7381
cancelButtonText?: string;
7482
onOk?: (() => void) | (() => Promise<any>);
7583
onCancel?: (isSubmitLoading?: boolean) => any;
@@ -106,10 +114,14 @@ prompt(
106114
modalConfig?: PromptModalProps
107115
): Promise<string | null>;
108116

109-
interface PromptModalProps {
117+
interface WrappedModalProps {
118+
modalProps: ModalProps;
119+
}
120+
interface PromptModalProps extends WrappedModalProps {
110121
okButtonText?: string;
122+
okButtonDangerous?: boolean;
111123
cancelButtonText?: string;
112-
valdiate?: (inputValue: string) => void;
124+
validate?: (inputValue: string) => boolean;
113125
onOk?: ((inputVal?: string) => void) | ((inputVal: string) => Promise<any>);
114126
onCancel?: (isSubmitLoading?: boolean) => any;
115127
canCancelOnLoading?: boolean;

demo/index.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ function App() {
155155
}
156156
}, []);
157157

158+
const forwardsModalProps = () => {
159+
confirm('forwards modal props', {
160+
modalProps: {
161+
size: 'lg',
162+
},
163+
});
164+
};
165+
158166
return (
159167
<div className="page">
160168
<h1>RSuite Interactions</h1>
@@ -198,6 +206,12 @@ function App() {
198206
<Button onClick={confirmSmashPhoneCancelAsync}>Then smash it!</Button>
199207
</ButtonToolbar>
200208
</Panel>
209+
<Divider />
210+
<Panel header="forward modal's props" bordered>
211+
<ButtonToolbar>
212+
<Button onClick={forwardsModalProps}>forwards modal props</Button>
213+
</ButtonToolbar>
214+
</Panel>
201215
</div>
202216
);
203217
}

index.d.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import * as React from 'react';
2-
import type { InputProps } from 'rsuite';
2+
import type { InputProps, ModalProps } from 'rsuite';
33

4-
interface AlertModalProps {
4+
interface WrappedModalProps {
5+
modalProps: ModalProps;
6+
}
7+
8+
interface AlertModalProps extends WrappedModalProps {
59
okButtonText?: string;
610
onOk?: (() => void) | (() => Promise<any>);
711
}
812

9-
interface ConfirmModalProps {
13+
interface ConfirmModalProps extends WrappedModalProps {
1014
okButtonText?: string;
1115
okButtonDangerous?: boolean;
1216
cancelButtonText?: string;
@@ -15,7 +19,7 @@ interface ConfirmModalProps {
1519
canCancelOnLoading?: boolean;
1620
}
1721

18-
interface PromptModalProps {
22+
interface PromptModalProps extends WrappedModalProps {
1923
okButtonText?: string;
2024
okButtonDangerous?: boolean;
2125
cancelButtonText?: string;

0 commit comments

Comments
 (0)