zavadil-react-common 1.1.24 → 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BasicDialogProps } from "./DialogProps";
|
|
2
|
+
export declare class ConfirmDialogContextData {
|
|
3
|
+
setProps: (props?: ConfirmDialogProps) => any;
|
|
4
|
+
constructor(setProps: (props?: ConfirmDialogProps) => any);
|
|
5
|
+
confirm(name: string, text: string, onConfirmed: () => any): void;
|
|
6
|
+
}
|
|
7
|
+
export type ConfirmDialogProps = BasicDialogProps & {
|
|
8
|
+
onConfirm: () => any;
|
|
9
|
+
};
|
|
10
|
+
export declare function ConfirmDialog({ name, text, onClose, onConfirm }: ConfirmDialogProps): import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {Button, Modal, Stack} from "react-bootstrap";
|
|
2
|
+
import {BasicDialogProps} from "./DialogProps";
|
|
3
|
+
|
|
4
|
+
export class ConfirmDialogContextData {
|
|
5
|
+
setProps: (props?: ConfirmDialogProps) => any;
|
|
6
|
+
|
|
7
|
+
constructor(setProps: (props?: ConfirmDialogProps) => any) {
|
|
8
|
+
this.setProps = setProps;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
confirm(name: string, text: string, onConfirmed: () => any) {
|
|
12
|
+
this.setProps(
|
|
13
|
+
{
|
|
14
|
+
name: name,
|
|
15
|
+
text: text,
|
|
16
|
+
onConfirm: () => {
|
|
17
|
+
onConfirmed();
|
|
18
|
+
this.setProps(undefined);
|
|
19
|
+
},
|
|
20
|
+
onClose: () => this.setProps(undefined)
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
export const ConfirmDialogContext = createContext<ConfirmDialogContextData>(new ConfirmDialogContextData(() => undefined));
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export type ConfirmDialogProps = BasicDialogProps & {
|
|
31
|
+
onConfirm: () => any;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function ConfirmDialog({name, text, onClose, onConfirm}: ConfirmDialogProps) {
|
|
35
|
+
return (
|
|
36
|
+
<Modal show={true}>
|
|
37
|
+
<Modal.Header>{name || 'Confirm'}</Modal.Header>
|
|
38
|
+
<Modal.Body>{text}</Modal.Body>
|
|
39
|
+
<Modal.Footer>
|
|
40
|
+
<Stack direction="horizontal">
|
|
41
|
+
<Button variant="link" onClick={onClose}>Zpět</Button>
|
|
42
|
+
<Button variant="primary" onClick={onConfirm}>Ano</Button>
|
|
43
|
+
</Stack>
|
|
44
|
+
</Modal.Footer>
|
|
45
|
+
</Modal>
|
|
46
|
+
);
|
|
47
|
+
}
|