Skip to content

Commit

Permalink
feat: support forwarding modal props (#61)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
myNameIsDu authored Dec 24, 2024
1 parent bc86577 commit f624840
Show file tree
Hide file tree
Showing 11 changed files with 11,296 additions and 38,791 deletions.
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

0 comments on commit f624840

Please sign in to comment.