Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support forwarding modal props #61

Merged
merged 4 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ jobs:
react: 17
steps:
- uses: actions/checkout@v2
- uses: pnpm/[email protected]
with:
version: 8.10.5
- name: Use Node.js LTS
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- run: npm ci
- run: npm run build --if-present
- run: npm test -- --coverage
- run: pnpm i
- run: pnpm run build --if-present
- run: pnpm run test --coverage
env:
RSUITE_VERSION: ${{ matrix.rsuite }}
REACT_VERSION: ${{ matrix.react }}
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm ci
- uses: pnpm/[email protected]
with:
version: 8.10.5
- run: pnpm i
- name: Semantic Release
run: npx semantic-release
run: pnpm semantic-release
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

pnpm lint-staged
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ alert(
modalConfig?: AlertModalProps
): Promise<void>;

interface AlertModalProps {
interface WrappedModalProps {
modalProps: ModalProps;
}

interface AlertModalProps extends WrappedModalProps {
okButtonText?: string;
onOk?: (() => void) | (() => Promise<any>);
}
Expand Down Expand Up @@ -68,8 +72,12 @@ confirm(
modalConfig?: ConfirmModalProps
): Promise<boolean>;

interface ConfirmModalProps {
interface WrappedModalProps {
modalProps: ModalProps;
}
interface ConfirmModalProps extends WrappedModalProps {
okButtonText?: string;
okButtonDangerous?: boolean;
cancelButtonText?: string;
onOk?: (() => void) | (() => Promise<any>);
onCancel?: (isSubmitLoading?: boolean) => any;
Expand Down Expand Up @@ -106,10 +114,14 @@ prompt(
modalConfig?: PromptModalProps
): Promise<string | null>;

interface PromptModalProps {
interface WrappedModalProps {
modalProps: ModalProps;
}
interface PromptModalProps extends WrappedModalProps {
okButtonText?: string;
okButtonDangerous?: boolean;
cancelButtonText?: string;
valdiate?: (inputValue: string) => void;
validate?: (inputValue: string) => boolean;
onOk?: ((inputVal?: string) => void) | ((inputVal: string) => Promise<any>);
onCancel?: (isSubmitLoading?: boolean) => any;
canCancelOnLoading?: boolean;
Expand Down
14 changes: 14 additions & 0 deletions demo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ function App() {
}
}, []);

const forwardsModalProps = () => {
confirm('forwards modal props', {
modalProps: {
size: 'lg',
},
});
};

return (
<div className="page">
<h1>RSuite Interactions</h1>
Expand Down Expand Up @@ -198,6 +206,12 @@ function App() {
<Button onClick={confirmSmashPhoneCancelAsync}>Then smash it!</Button>
</ButtonToolbar>
</Panel>
<Divider />
<Panel header="forward modal's props" bordered>
<ButtonToolbar>
<Button onClick={forwardsModalProps}>forwards modal props</Button>
</ButtonToolbar>
</Panel>
</div>
);
}
Expand Down
12 changes: 8 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import * as React from 'react';
import type { InputProps } from 'rsuite';
import type { InputProps, ModalProps } from 'rsuite';

interface AlertModalProps {
interface WrappedModalProps {
modalProps: ModalProps;
}

interface AlertModalProps extends WrappedModalProps {
okButtonText?: string;
onOk?: (() => void) | (() => Promise<any>);
}

interface ConfirmModalProps {
interface ConfirmModalProps extends WrappedModalProps {
okButtonText?: string;
okButtonDangerous?: boolean;
cancelButtonText?: string;
Expand All @@ -15,7 +19,7 @@ interface ConfirmModalProps {
canCancelOnLoading?: boolean;
}

interface PromptModalProps {
interface PromptModalProps extends WrappedModalProps {
okButtonText?: string;
okButtonDangerous?: boolean;
cancelButtonText?: string;
Expand Down
Loading
Loading