@dvrd/dvr-controls 1.1.30 → 1.1.31
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.
- package/index.ts +2 -1
- package/package.json +1 -1
- package/src/js/dialog/dialog.tsx +77 -172
- package/src/js/dialog/dialogController.tsx +25 -55
- package/src/js/dialog/inlineDialog.tsx +10 -10
- package/src/js/dialog/style/dialog.scss +6 -6
- package/src/js/util/eventUtil.ts +4 -4
- package/src/js/util/interfaces.ts +29 -7
- package/src/js/util/types.ts +7 -0
package/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ library.add(fab, far, fas);
|
|
|
13
13
|
|
|
14
14
|
import ButtonController from './src/js/button/buttonController';
|
|
15
15
|
import CheckboxController from './src/js/checkbox/checkboxController';
|
|
16
|
-
import DialogController
|
|
16
|
+
import DialogController from './src/js/dialog/dialogController';
|
|
17
17
|
import InlineDialog from './src/js/dialog/inlineDialog';
|
|
18
18
|
import PasswordInput from './src/js/input/password/passwordInput';
|
|
19
19
|
import PasswordRules from './src/js/input/password/passwordRules';
|
|
@@ -59,6 +59,7 @@ import FileUpload from './src/js/fileUpload/fileUpload';
|
|
|
59
59
|
import DvrdRadioController from './src/js/radio/dvrdRadioController';
|
|
60
60
|
import MobileNavigation from './src/js/navigation/mobileNavigation';
|
|
61
61
|
import NumberString from './src/js/util/numberString';
|
|
62
|
+
import { DialogActionShape } from './src/js/util/interfaces';
|
|
62
63
|
|
|
63
64
|
export {
|
|
64
65
|
// Components
|
package/package.json
CHANGED
package/src/js/dialog/dialog.tsx
CHANGED
|
@@ -4,204 +4,109 @@
|
|
|
4
4
|
|
|
5
5
|
import './style/dialog.scss';
|
|
6
6
|
|
|
7
|
-
import React, {
|
|
7
|
+
import React, {CSSProperties, useContext, useEffect, useMemo} from 'react';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import ButtonController from "../button/buttonController";
|
|
10
10
|
import {ControlContext} from "../util/controlContext";
|
|
11
|
-
import {enterPressed
|
|
11
|
+
import {enterPressed} from "../util/controlUtil";
|
|
12
12
|
import {colorIsWhite, convertColor} from "../util/colorUtil";
|
|
13
|
-
import {ControlVariant} from "../util/interfaces";
|
|
14
|
-
import {DialogActions
|
|
13
|
+
import {ControlVariant, DialogActionShape, DialogDataShapeWithID} from "../util/interfaces";
|
|
14
|
+
import {DialogActions} from '../util/types';
|
|
15
15
|
|
|
16
16
|
interface Props {
|
|
17
|
-
onClose
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
onClose: (id: string) => VoidFunction;
|
|
18
|
+
data: DialogDataShapeWithID;
|
|
19
|
+
className?: string;
|
|
20
|
+
backgroundClassName?: string;
|
|
21
|
+
zIndex?: number | string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export default class Dialog extends React.Component<Props, State> {
|
|
43
|
-
declare context: React.ContextType<typeof ControlContext>;
|
|
44
|
-
static contextType = ControlContext;
|
|
45
|
-
static defaultProps = {
|
|
46
|
-
className: '',
|
|
47
|
-
};
|
|
48
|
-
private buttonVariant: ControlVariant = ControlVariant.OUTLINED;
|
|
49
|
-
|
|
50
|
-
onClose = () => {
|
|
51
|
-
const {onClose, id} = this.props;
|
|
52
|
-
this.removeKeyListener();
|
|
53
|
-
this.setState({open: false}, () => {
|
|
54
|
-
if (onClose) onClose(id);
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
getDefaultAction = (): DialogActions => ['Oke'];
|
|
59
|
-
|
|
60
|
-
state: State = {
|
|
61
|
-
open: false,
|
|
62
|
-
message: '',
|
|
63
|
-
content: null,
|
|
64
|
-
title: 'Bericht van het systeem',
|
|
65
|
-
actions: this.getDefaultAction(),
|
|
66
|
-
transparent: false,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
dialog: HTMLElement | null = null;
|
|
70
|
-
id = generateUUID();
|
|
71
|
-
persistent = false;
|
|
72
|
-
|
|
73
|
-
onClickBackground = () => {
|
|
74
|
-
if (!this.persistent && this.dialog !== null && !hasHover(this.dialog))
|
|
75
|
-
this.onClose();
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// =============== NOTE Use function below to open the dialog
|
|
79
|
-
onOpen = (data: DataShape) => {
|
|
80
|
-
const message = data.message, title = data.title === undefined ? 'Bericht van het systeem' : data.title,
|
|
81
|
-
actions = data.actions === undefined ? this.getDefaultAction() : data.actions,
|
|
82
|
-
transparent = data.transparent === undefined ? false : data.transparent;
|
|
83
|
-
this.persistent = data.persistent === undefined ? true : data.persistent;
|
|
84
|
-
if (data.buttonVariant) this.buttonVariant = data.buttonVariant;
|
|
85
|
-
this.setState({message, title, actions, transparent}, () => {
|
|
86
|
-
this.setState({open: true});
|
|
87
|
-
});
|
|
88
|
-
this.addKeyListener();
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
onEnterPressed = (evt: KeyboardEvent) => {
|
|
92
|
-
evt.stopPropagation();
|
|
93
|
-
const {actions} = this.state;
|
|
94
|
-
if (actions)
|
|
95
|
-
for (const action of actions) {
|
|
96
|
-
if (typeof (action) === 'string' || action.primary) {
|
|
97
|
-
if (typeof action === 'string') this.onClose();
|
|
98
|
-
else if (action.onClick) action.onClick(evt as any as React.MouseEvent);
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
24
|
+
export default function Dialog(props: Props) {
|
|
25
|
+
const {baseColor, contrastColor} = useContext(ControlContext);
|
|
26
|
+
const {onClose, data, className, backgroundClassName} = props;
|
|
27
|
+
const actions: DialogActions = useMemo(() => {
|
|
28
|
+
return data.actions ?? ['Oke'];
|
|
29
|
+
}, [data.actions]);
|
|
30
|
+
const colorStyle: CSSProperties = useMemo(() => ({
|
|
31
|
+
color: convertColor(colorIsWhite(baseColor) ? contrastColor : baseColor),
|
|
32
|
+
}), [baseColor, contrastColor])
|
|
33
|
+
const zIndex = useMemo(() => {
|
|
34
|
+
return data.zIndex ?? props.zIndex;
|
|
35
|
+
}, [props.zIndex, data.zIndex])
|
|
36
|
+
|
|
37
|
+
function onClickBackground(evt: React.MouseEvent) {
|
|
38
|
+
if (data.persistent) return;
|
|
39
|
+
if (evt.target !== evt.currentTarget) return;
|
|
40
|
+
onClose(data.id)();
|
|
102
41
|
}
|
|
103
42
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
43
|
+
function extendOnClick(action: DialogActionShape) {
|
|
44
|
+
return function(evt: React.MouseEvent) {
|
|
45
|
+
if (!action.keepOpen) onClose(data.id)();
|
|
46
|
+
action.onClick?.(evt);
|
|
107
47
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
addKeyListener = () => {
|
|
111
|
-
document.addEventListener('keydown', this.keyListener);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
removeKeyListener = () => {
|
|
115
|
-
document.removeEventListener('keydown', this.keyListener);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
getColorStyle = (): object => {
|
|
119
|
-
const {baseColor, contrastColor} = this.context,
|
|
120
|
-
color = colorIsWhite(baseColor) ? contrastColor : baseColor;
|
|
121
|
-
return {color: convertColor(color)};
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
extendOnClick = (action: DialogActionShape): MouseEventHandler => (evt: any) => {
|
|
125
|
-
if (!action.keepOpen)
|
|
126
|
-
this.onClose();
|
|
127
|
-
action.onClick?.(evt);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
getActions = () => {
|
|
131
|
-
const {actions} = this.state;
|
|
132
|
-
if (actions === undefined || actions === null) return this.generateDefaultAction();
|
|
133
|
-
if (Array.isArray(actions))
|
|
134
|
-
return actions.map(this.renderAction);
|
|
135
|
-
return this.renderAction(actions);
|
|
136
|
-
};
|
|
48
|
+
}
|
|
137
49
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
50
|
+
function keyListener(evt: KeyboardEvent) {
|
|
51
|
+
if (!enterPressed(evt) || !actions) return;
|
|
52
|
+
const primaryAction = actions.find(action => typeof action === 'string' || action.primary);
|
|
53
|
+
if (!primaryAction) return;
|
|
141
54
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<ButtonController {...keyProp} label={action} onClick={this.onClose}
|
|
146
|
-
type={this.buttonVariant} containerClass='dialogButton'/>
|
|
147
|
-
);
|
|
148
|
-
return (
|
|
149
|
-
<ButtonController {...keyProp} label={action.label} onClick={this.extendOnClick(action)}
|
|
150
|
-
type={this.buttonVariant} containerClass='dialogButton' primary={action.primary}/>
|
|
151
|
-
);
|
|
152
|
-
};
|
|
55
|
+
if (typeof primaryAction === 'string') onClose(data.id)();
|
|
56
|
+
else if (primaryAction.onClick) primaryAction.onClick(evt);
|
|
57
|
+
}
|
|
153
58
|
|
|
154
|
-
renderTitle
|
|
155
|
-
const {title} = this.state;
|
|
59
|
+
function renderTitle() {
|
|
156
60
|
return (
|
|
157
|
-
<div className='
|
|
158
|
-
<label className='
|
|
61
|
+
<div className='dialog-title-container'>
|
|
62
|
+
<label className='dialog-title' style={colorStyle}>{data.title}</label>
|
|
159
63
|
</div>
|
|
160
64
|
)
|
|
161
|
-
}
|
|
65
|
+
}
|
|
162
66
|
|
|
163
|
-
renderMessage
|
|
164
|
-
const
|
|
67
|
+
function renderMessage() {
|
|
68
|
+
const message = data.message;
|
|
165
69
|
return (
|
|
166
|
-
<div className='
|
|
167
|
-
{typeof message === 'string' ? <p className='
|
|
70
|
+
<div className='dialog-message-container'>
|
|
71
|
+
{typeof message === 'string' ? <p className='dialog-message'>{message}</p> : message}
|
|
168
72
|
</div>
|
|
169
73
|
)
|
|
170
|
-
}
|
|
74
|
+
}
|
|
171
75
|
|
|
172
|
-
renderActions
|
|
173
|
-
const actions = this.getActions();
|
|
76
|
+
function renderActions() {
|
|
174
77
|
return (
|
|
175
|
-
<div className='
|
|
176
|
-
{actions}
|
|
78
|
+
<div className='dialog-actions-container'>
|
|
79
|
+
{actions.map(renderAction)}
|
|
177
80
|
</div>
|
|
178
81
|
)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
componentDidMount = () => {
|
|
182
|
-
const {open, data} = this.props;
|
|
183
|
-
if (open && data) this.onOpen(data);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
componentWillUnmount = () => {
|
|
187
|
-
this.removeKeyListener();
|
|
188
|
-
};
|
|
82
|
+
}
|
|
189
83
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
84
|
+
function renderAction(action: DialogActionShape | string, index: number) {
|
|
85
|
+
if (typeof action === 'string') return (
|
|
86
|
+
<ButtonController key={index} label={action} onClick={onClose(data.id)} type={ControlVariant.OUTLINED}
|
|
87
|
+
containerClass='dialog-button'/>
|
|
88
|
+
);
|
|
193
89
|
return (
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this.dialog = ref
|
|
198
|
-
}}>
|
|
199
|
-
{this.renderTitle()}
|
|
200
|
-
{this.renderMessage()}
|
|
201
|
-
{this.renderActions()}
|
|
202
|
-
</div>
|
|
203
|
-
</div>
|
|
204
|
-
// </WithEvents>
|
|
205
|
-
)
|
|
90
|
+
<ButtonController key={index} label={action.label} onClick={extendOnClick(action)}
|
|
91
|
+
type={ControlVariant.OUTLINED} containerClass='dialog-button' primary={action.primary}/>
|
|
92
|
+
);
|
|
206
93
|
}
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
document.addEventListener('keydown', keyListener);
|
|
97
|
+
return () => {
|
|
98
|
+
document.removeEventListener('keydown', keyListener);
|
|
99
|
+
}
|
|
100
|
+
}, [keyListener]);
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<div className={classNames('dialog-container', backgroundClassName)} style={{zIndex}}
|
|
104
|
+
onClick={onClickBackground}>
|
|
105
|
+
<div className={classNames('dvr-dialog', className)}>
|
|
106
|
+
{renderTitle()}
|
|
107
|
+
{renderMessage()}
|
|
108
|
+
{renderActions()}
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
)
|
|
207
112
|
}
|
|
@@ -1,71 +1,41 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2024. Dave van Rijn Development
|
|
2
|
+
* Copyright (c) 2024 - 2026. Dave van Rijn Development
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import {useState} from 'react';
|
|
7
|
+
import {DialogDataShape, DialogDataShapeWithID} from '../util/interfaces';
|
|
8
|
+
import {generateComponentId, useEvent} from "../util/componentUtil";
|
|
8
9
|
import Dialog from './dialog';
|
|
9
|
-
import {generateComponentId} from "../util/componentUtil";
|
|
10
|
-
import {WithEvents} from "../../../index";
|
|
11
|
-
|
|
12
|
-
export interface DialogActionShape {
|
|
13
|
-
label: string;
|
|
14
|
-
onClick?: MouseEventHandler;
|
|
15
|
-
primary?: boolean;
|
|
16
|
-
keepOpen?: true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type DialogActions = (DialogActionShape | string)[];
|
|
20
10
|
|
|
21
11
|
interface Props {
|
|
22
12
|
className?: string;
|
|
13
|
+
backgroundClassName?: string;
|
|
14
|
+
zIndex?: number | string;
|
|
23
15
|
}
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
interface DataShape {
|
|
30
|
-
message: string | React.ReactElement;
|
|
31
|
-
title?: string;
|
|
32
|
-
actions?: DialogActions;
|
|
33
|
-
transparent?: boolean;
|
|
34
|
-
persistent?: boolean;
|
|
35
|
-
buttonVariant?: ControlVariant;
|
|
36
|
-
}
|
|
17
|
+
export default function DialogController(props: Props) {
|
|
18
|
+
const {className, backgroundClassName, zIndex} = props;
|
|
19
|
+
const [dialogs, setDialogs] = useState<Array<DialogDataShapeWithID>>([]);
|
|
20
|
+
useEvent('onOpenDialog', onOpen);
|
|
37
21
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
onClose = (id?: string) => {
|
|
44
|
-
if (id) {
|
|
45
|
-
const dialogs = Object.assign({}, this.state.dialogs);
|
|
46
|
-
delete dialogs[id];
|
|
47
|
-
this.setState({dialogs});
|
|
22
|
+
function onClose(id: string) {
|
|
23
|
+
return function() {
|
|
24
|
+
setDialogs(dialogs.filter(dialog => dialog.id !== id));
|
|
48
25
|
}
|
|
49
26
|
}
|
|
50
27
|
|
|
51
|
-
onOpen
|
|
52
|
-
const
|
|
53
|
-
dialogs
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
getEvents = (): CustomAppEvent[] => [
|
|
58
|
-
{eventName: 'onOpenDialog', handler: this.onOpen},
|
|
59
|
-
];
|
|
28
|
+
function onOpen(data: DialogDataShape) {
|
|
29
|
+
const id = generateComponentId();
|
|
30
|
+
setDialogs([...dialogs, {id, ...data}]);
|
|
31
|
+
}
|
|
60
32
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{React.cloneElement(element, {className})}
|
|
67
|
-
</Fragment>
|
|
68
|
-
))}
|
|
69
|
-
</WithEvents>
|
|
33
|
+
function renderDialog(data: DialogDataShapeWithID) {
|
|
34
|
+
return (
|
|
35
|
+
<Dialog onClose={onClose} data={data} zIndex={zIndex} className={className}
|
|
36
|
+
backgroundClassName={backgroundClassName} key={data.id}/>
|
|
37
|
+
)
|
|
70
38
|
}
|
|
71
|
-
|
|
39
|
+
|
|
40
|
+
return dialogs.map(renderDialog);
|
|
41
|
+
}
|
|
@@ -10,7 +10,7 @@ import ButtonController from "../button/buttonController";
|
|
|
10
10
|
import {ControlContext} from "../util/controlContext";
|
|
11
11
|
import {generateUUID, hasHover} from "../util/controlUtil";
|
|
12
12
|
import {colorIsWhite, convertColor} from "../util/colorUtil";
|
|
13
|
-
import {DialogActionShape} from
|
|
13
|
+
import {DialogActionShape} from '../util/interfaces';
|
|
14
14
|
|
|
15
15
|
interface DialogProps {
|
|
16
16
|
onClose: Function,
|
|
@@ -29,7 +29,7 @@ export default class InlineDialog extends React.Component<DialogProps> {
|
|
|
29
29
|
static contextType = ControlContext;
|
|
30
30
|
|
|
31
31
|
static defaultProps = {
|
|
32
|
-
title: 'Bericht van
|
|
32
|
+
title: 'Bericht van het systeem',
|
|
33
33
|
actions: null,
|
|
34
34
|
transparent: false,
|
|
35
35
|
persistent: true,
|
|
@@ -72,19 +72,19 @@ export default class InlineDialog extends React.Component<DialogProps> {
|
|
|
72
72
|
if (Array.isArray(actions))
|
|
73
73
|
return actions.map((action: DialogActionShape, key: any) => (
|
|
74
74
|
<ButtonController key={key} label={action.label} onClick={this.onClickAction(action.onClick)}
|
|
75
|
-
type='outlined' containerClass='
|
|
75
|
+
type='outlined' containerClass='dialog-button'/>
|
|
76
76
|
));
|
|
77
77
|
return <ButtonController label={actions.label} onClick={this.onClickAction(actions.onClick)} type='outlined'/>
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
generateDefaultAction = (): React.ReactNode => <ButtonController label={'Oke'} onClick={this.onClickDefault}
|
|
81
|
-
type='outlined' containerClass='
|
|
81
|
+
type='outlined' containerClass='dialog-button'/>;
|
|
82
82
|
|
|
83
83
|
renderTitle = (): React.ReactNode => {
|
|
84
84
|
const {title} = this.props;
|
|
85
85
|
return (
|
|
86
|
-
<div className='
|
|
87
|
-
<label className='
|
|
86
|
+
<div className='dialog-title-container'>
|
|
87
|
+
<label className='dialog-title' style={this.getColorStyle()}>{title}</label>
|
|
88
88
|
</div>
|
|
89
89
|
)
|
|
90
90
|
};
|
|
@@ -92,8 +92,8 @@ export default class InlineDialog extends React.Component<DialogProps> {
|
|
|
92
92
|
renderMessage = (): React.ReactNode => {
|
|
93
93
|
const {message, content} = this.props;
|
|
94
94
|
return (
|
|
95
|
-
<div className='
|
|
96
|
-
<p className='
|
|
95
|
+
<div className='dialog-message-container'>
|
|
96
|
+
<p className='dialog-message'>{message}</p>
|
|
97
97
|
{content !== undefined && content}
|
|
98
98
|
</div>
|
|
99
99
|
)
|
|
@@ -102,7 +102,7 @@ export default class InlineDialog extends React.Component<DialogProps> {
|
|
|
102
102
|
renderActions = (): React.ReactNode => {
|
|
103
103
|
const actions = this.getActions();
|
|
104
104
|
return (
|
|
105
|
-
<div className='
|
|
105
|
+
<div className='dialog-actions-container'>
|
|
106
106
|
{actions}
|
|
107
107
|
</div>
|
|
108
108
|
)
|
|
@@ -112,7 +112,7 @@ export default class InlineDialog extends React.Component<DialogProps> {
|
|
|
112
112
|
const {open, transparent, containerClass} = this.props;
|
|
113
113
|
if (!open) return null;
|
|
114
114
|
return (
|
|
115
|
-
<div className={classNames('
|
|
115
|
+
<div className={classNames('dialog-container', transparent && 'transparent', containerClass)}
|
|
116
116
|
onClick={this.onClickBackground}>
|
|
117
117
|
<div className='dialog' ref={ref => {
|
|
118
118
|
this.dialog = ref
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
@use '../../../style/colors';
|
|
7
7
|
@use '../../../style/display-breakpoints' as breakpoints;
|
|
8
8
|
|
|
9
|
-
.
|
|
9
|
+
.dialog-container {
|
|
10
10
|
@include commons.popupContainer;
|
|
11
11
|
z-index: commons.$z-index-dialog;
|
|
12
12
|
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
padding: 1.5rem 2rem;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
.
|
|
27
|
+
.dialog-title-container {
|
|
28
28
|
|
|
29
|
-
.
|
|
29
|
+
.dialog-title {
|
|
30
30
|
font-size: 1.2rem;
|
|
31
31
|
user-select: none;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
.
|
|
35
|
+
.dialog-message-container {
|
|
36
36
|
padding: 1.5rem 0;
|
|
37
37
|
|
|
38
38
|
.dialogMessage {
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.
|
|
44
|
+
.dialog-actions-container {
|
|
45
45
|
display: flex;
|
|
46
46
|
justify-content: flex-end;
|
|
47
47
|
align-items: center;
|
|
48
48
|
flex-wrap: wrap;
|
|
49
49
|
|
|
50
|
-
.
|
|
50
|
+
.dialog-button {
|
|
51
51
|
margin-right: .5rem;
|
|
52
52
|
|
|
53
53
|
&:last-child {
|
package/src/js/util/eventUtil.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import {DialogActions} from "../dialog/dialogController";
|
|
7
6
|
import {SnackConfig} from "./interfaces";
|
|
7
|
+
import {DialogActions} from './types';
|
|
8
8
|
|
|
9
9
|
interface ListenerShape {
|
|
10
10
|
component: string,
|
|
@@ -59,9 +59,9 @@ const listenerExists = (componentName: string, eventName: string) => {
|
|
|
59
59
|
//==========================
|
|
60
60
|
|
|
61
61
|
export const showDialog = (message: string | React.ReactElement, title: string = 'Bericht van het systeem',
|
|
62
|
-
actions?: DialogActions | null,
|
|
63
|
-
|
|
64
|
-
dispatchCustomEvent('onOpenDialog', {message, title, actions, transparent, persistent});
|
|
62
|
+
actions?: DialogActions | null, persistent?: boolean, transparent?: boolean,
|
|
63
|
+
zIndex?: string | number) => {
|
|
64
|
+
dispatchCustomEvent('onOpenDialog', {message, title, actions, transparent, persistent, zIndex});
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
export const showSnackbar = (text: string | React.ReactElement, config?: SnackConfig) => {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import React, {CSSProperties, MouseEventHandler, ReactElement} from 'react';
|
|
6
|
+
import {DialogActions} from './types';
|
|
6
7
|
|
|
7
8
|
// =========== INTERFACES
|
|
8
9
|
|
|
@@ -99,6 +100,27 @@ export interface HeaderItem {
|
|
|
99
100
|
target?: '_blank';
|
|
100
101
|
}
|
|
101
102
|
|
|
103
|
+
export interface DialogDataShape {
|
|
104
|
+
message: string | React.ReactElement;
|
|
105
|
+
title?: string;
|
|
106
|
+
actions?: DialogActions;
|
|
107
|
+
transparent?: boolean;
|
|
108
|
+
persistent?: boolean;
|
|
109
|
+
buttonVariant?: ControlVariant;
|
|
110
|
+
zIndex?: string | number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface DialogDataShapeWithID extends DialogDataShape {
|
|
114
|
+
id: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface DialogActionShape {
|
|
118
|
+
label: string;
|
|
119
|
+
onClick?: ((evt: KeyboardEvent | React.MouseEvent) => void);
|
|
120
|
+
primary?: boolean;
|
|
121
|
+
keepOpen?: true;
|
|
122
|
+
}
|
|
123
|
+
|
|
102
124
|
// =========== ENUMS
|
|
103
125
|
|
|
104
126
|
export enum ModeEnum {DETAIL = 'detail', EDIT = 'edit', NEW = 'new'}
|
|
@@ -172,21 +194,21 @@ export type CustomAppEvent = {
|
|
|
172
194
|
export type ChangeFunction<T = any> = (value: T, evt?: React.ChangeEvent) => void;
|
|
173
195
|
export type ChangeKeyFunction<K = string, V = any> = (key: K) => ChangeFunction<V>;
|
|
174
196
|
export type ModelResponse<T> = (obj: T, success: boolean | undefined, data: ResponseData) => void;
|
|
175
|
-
export type StrengthGauge = {
|
|
176
|
-
export type PDFSetting = {
|
|
197
|
+
export type StrengthGauge = {validator: (password: string) => boolean};
|
|
198
|
+
export type PDFSetting = {key: string; label: string; type: PDFSettingType; value: any};
|
|
177
199
|
|
|
178
200
|
export type PDFElementParams<T extends PDFElementType, O extends IndexedObject<any>> = {
|
|
179
201
|
key: string;
|
|
180
202
|
type: T;
|
|
181
203
|
sub_type?: PDFElementSubType | null;
|
|
182
|
-
dimensions: {
|
|
204
|
+
dimensions: {left: number; top: number; width: number; height: number};
|
|
183
205
|
options: O;
|
|
184
206
|
persistent?: PDFElementPersist;
|
|
185
207
|
linkedID?: string;
|
|
186
208
|
}
|
|
187
209
|
export type DefaultPDFElementParams<T extends PDFElementType, O extends IndexedObject<any>> = Partial<{
|
|
188
210
|
type: T;
|
|
189
|
-
dimensions: Partial<{
|
|
211
|
+
dimensions: Partial<{left: number; top: number; width: number; height: number}>;
|
|
190
212
|
options: O;
|
|
191
213
|
persistent?: PDFElementPersist;
|
|
192
214
|
key: string;
|
|
@@ -222,14 +244,14 @@ export type PDFInvoiceTableParams = {
|
|
|
222
244
|
alignment?: ElementPosition;
|
|
223
245
|
persistent: PDFElementPersist;
|
|
224
246
|
};
|
|
225
|
-
export type PDFInvoiceWidths = {
|
|
247
|
+
export type PDFInvoiceWidths = {name: number; price: number; quantity: number; subtotal: number}
|
|
226
248
|
export type PDFTextVariables = {
|
|
227
249
|
company: IndexedObject<string>;
|
|
228
250
|
client: IndexedObject<string>;
|
|
229
251
|
invoice: IndexedObject<string>;
|
|
230
252
|
}
|
|
231
253
|
export type PDFSubmitHandler = (items: PDFElementParams<any, any>[], callback?: VoidFunction) => void;
|
|
232
|
-
export type PDFElementDimensions = {
|
|
254
|
+
export type PDFElementDimensions = {left: number; top: number; width: number; height: number};
|
|
233
255
|
|
|
234
256
|
export type SidebarItem = {
|
|
235
257
|
label: string; icon?: string | React.ReactElement<any, any>;
|
|
@@ -242,7 +264,7 @@ export type SidebarItem = {
|
|
|
242
264
|
asNavLink?: true;
|
|
243
265
|
}
|
|
244
266
|
export type ResponseCallback = (data: ResponseData) => void;
|
|
245
|
-
export type RNDDimensions = {
|
|
267
|
+
export type RNDDimensions = {x: number, y: number, height: number, width: number};
|
|
246
268
|
export type HTMLVideoEvent = (evt: React.SyntheticEvent<HTMLVideoElement, Event>) => void;
|
|
247
269
|
export type RenderFile = {
|
|
248
270
|
filename: string;
|