-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathDialogContent.tsx
More file actions
121 lines (105 loc) · 3.84 KB
/
Copy pathDialogContent.tsx
File metadata and controls
121 lines (105 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { If } from "@mendix/widget-plugin-component-kit/If";
import classNames from "classnames";
import { createElement, Fragment, PropsWithChildren, ReactElement } from "react";
interface PropsWithChildrenWithClass extends PropsWithChildren {
className?: string;
}
export interface DialogContentProps extends PropsWithChildrenWithClass {
formOrientation: "horizontal" | "vertical";
}
export function DialogContent(props: DialogContentProps): ReactElement {
const { children, className, formOrientation } = props;
return (
<div
className={classNames(
"widget-rich-text-modal-body modal-dialog mx-window mx-window-active",
{ "form-vertical": formOrientation === "vertical" },
className
)}
>
<div className="modal-content mx-window-content">{children}</div>
</div>
);
}
export interface DialogHeaderProps extends PropsWithChildrenWithClass {
onClose(): void;
}
export function DialogHeader(props: DialogHeaderProps): ReactElement {
const { children, onClose, className } = props;
return (
<Fragment>
<div className={classNames("widget-rich-text-modal-header modal-header", className)}>
<button type="button" className="close" title="close" aria-label="close" onClick={onClose}>
×
</button>
<h4>{children}</h4>
</div>
<div className="hide">{children}</div>
</Fragment>
);
}
export interface DialogBodyProps extends PropsWithChildrenWithClass {
formOrientation: "horizontal" | "vertical";
}
export function DialogBody(props: DialogBodyProps): ReactElement {
const { children, className, formOrientation } = props;
return (
<div
className={classNames(
"widget-rich-text-modal-content",
{
"form-vertical": formOrientation === "vertical",
"form-horizontal": formOrientation !== "vertical"
},
className
)}
>
{children}
</div>
);
}
export interface FormControlProps extends PropsWithChildrenWithClass {
label?: string;
formOrientation: "horizontal" | "vertical";
inputId?: string;
}
export function FormControl(props: FormControlProps): ReactElement {
const { children, className, label, formOrientation, inputId } = props;
return (
<If condition={children !== undefined && children !== null}>
<div className={classNames("form-group", { "no-columns": formOrientation === "vertical" }, className)}>
{label && (
<label
htmlFor={inputId}
id={`${inputId}-label`}
className={classNames("control-label", { "col-sm-3": formOrientation !== "vertical" })}
>
{label}
</label>
)}
{formOrientation === "vertical" ? (
children
) : (
<div className={`col-sm-${label ? "9" : "12"}`}>{children}</div>
)}
</div>
</If>
);
}
export interface DialogFooterProps extends PropsWithChildrenWithClass {
onClose(): void;
onSubmit(...args: any[]): void;
}
export function DialogFooter(props: DialogFooterProps): ReactElement {
const { onSubmit, onClose, className } = props;
return (
<div className={classNames("mx-dataview-controls", className)}>
<button type="button" className="btn mx-button btn-success" onClick={onSubmit}>
Save
</button>
<button type="button" className="btn mx-button btn-default" onClick={onClose}>
Cancel
</button>
</div>
);
}