@dvrd/dvr-controls 1.0.17 → 1.0.20
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/package.json +1 -1
- package/src/js/date/dvrdDatePicker.tsx +1 -1
- package/src/js/pdf/invoiceTable/pdfInvoiceTable.tsx +12 -3
- package/src/js/pdf/pdfTemplateCreator.tsx +38 -14
- package/src/js/pdf/settings/image/pdfImageSettings.tsx +3 -3
- package/src/js/pdf/settings/invoiceTable/pdfInvoiceTableSettings.tsx +49 -15
- package/src/js/pdf/settings/invoiceTable/style/pdfInvoiceTableSettings.scss +1 -0
- package/src/js/pdf/settings/pdfElementSettings.tsx +14 -9
- package/src/js/pdf/settings/style/pdfElementSettings.scss +2 -0
- package/src/js/pdf/settings/text/pdfTextSettings.tsx +11 -12
- package/src/js/select/dvrdSelect.tsx +2 -1
- package/src/js/select/dvrdSelectController.tsx +7 -2
- package/src/js/textField/dvrdNumberInput.tsx +21 -6
- package/src/js/util/interfaces.ts +17 -1
package/package.json
CHANGED
|
@@ -41,6 +41,7 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
|
|
|
41
41
|
fontSize: 12,
|
|
42
42
|
font: props.mainFont,
|
|
43
43
|
color: '#000',
|
|
44
|
+
headerColor: '#000',
|
|
44
45
|
alignment: ElementPosition.CENTER,
|
|
45
46
|
persistent: PDFElementPersist.NOT_PERSISTENT,
|
|
46
47
|
}, props.defaultSettings),
|
|
@@ -59,6 +60,7 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
|
|
|
59
60
|
fontSize,
|
|
60
61
|
font: settings.font,
|
|
61
62
|
color: settings.color,
|
|
63
|
+
headerColor: settings.headerColor,
|
|
62
64
|
alignment: settings.alignment,
|
|
63
65
|
persistent: settings.persistent,
|
|
64
66
|
},
|
|
@@ -82,11 +84,12 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
|
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
private getRowStyle = (isHeadRow: boolean = false): React.CSSProperties => {
|
|
85
|
-
const {widths, fontSize, font, color} = this.state.settings,
|
|
87
|
+
const {widths, fontSize, font, color, headerColor} = this.state.settings,
|
|
86
88
|
style: React.CSSProperties = {fontSize, fontFamily: font, color};
|
|
87
89
|
if (isHeadRow) {
|
|
88
90
|
style.fontWeight = font === PdfFont.HELVETICA ? 600 : 500;
|
|
89
91
|
style.borderBottom = '2px solid #d8d8d8';
|
|
92
|
+
style.color = headerColor;
|
|
90
93
|
}
|
|
91
94
|
style.gridTemplateColumns = widths.join('% ') + '%';
|
|
92
95
|
return style;
|
|
@@ -145,7 +148,13 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
|
|
|
145
148
|
};
|
|
146
149
|
|
|
147
150
|
render = () => {
|
|
148
|
-
const {dragging, settings} = this.state, {
|
|
151
|
+
const {dragging, settings} = this.state, {
|
|
152
|
+
draggable,
|
|
153
|
+
defaultPosition,
|
|
154
|
+
width,
|
|
155
|
+
height,
|
|
156
|
+
onSaveHistory
|
|
157
|
+
} = this.props;
|
|
149
158
|
return (
|
|
150
159
|
<WithEvents events={this.event}>
|
|
151
160
|
<PDFDraggable dragging={dragging} draggable={draggable} onDragStart={this.onDragStart}
|
|
@@ -160,7 +169,7 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
|
|
|
160
169
|
onResized={onSaveHistory} onDragged={onSaveHistory}>
|
|
161
170
|
<div className='pdf-invoice-table' onClick={this.onClick}>
|
|
162
171
|
<div className='invoice-line' style={this.getRowStyle(true)}>
|
|
163
|
-
<span>
|
|
172
|
+
<span>Omschrijving</span>
|
|
164
173
|
<span>Aantal</span>
|
|
165
174
|
<span>Bedrag</span>
|
|
166
175
|
<span>BTW</span>
|
|
@@ -5,9 +5,24 @@ import './style/pdfTemplateCreator.scss';
|
|
|
5
5
|
|
|
6
6
|
import React, {Fragment, PureComponent} from 'react';
|
|
7
7
|
import {
|
|
8
|
-
AwesomeIcon,
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
AwesomeIcon,
|
|
9
|
+
DefaultPDFElementParams,
|
|
10
|
+
directTimeout,
|
|
11
|
+
dispatchCustomEvent,
|
|
12
|
+
DvrdButton,
|
|
13
|
+
generateComponentId,
|
|
14
|
+
generateUUID,
|
|
15
|
+
IndexedObject,
|
|
16
|
+
PDFElementParams,
|
|
17
|
+
PDFElementPersist,
|
|
18
|
+
PDFElementType,
|
|
19
|
+
PdfFont,
|
|
20
|
+
PDFOptions,
|
|
21
|
+
PDFSubmitHandler,
|
|
22
|
+
PDFTextVariables,
|
|
23
|
+
ptToPx,
|
|
24
|
+
setElementSettings,
|
|
25
|
+
voidFunction
|
|
11
26
|
} from "../../../";
|
|
12
27
|
import PdfText from "./text/pdfText";
|
|
13
28
|
import classNames from 'classnames';
|
|
@@ -16,7 +31,7 @@ import PdfElementSettings from "./settings/pdfElementSettings";
|
|
|
16
31
|
import PdfImage from "./image/pdfImage";
|
|
17
32
|
import PdfInvoiceTable from "./invoiceTable/pdfInvoiceTable";
|
|
18
33
|
import {addToHistory, canRedo, canUndo, clearHistory, redo, undo} from "./history/pdfHistory";
|
|
19
|
-
import {
|
|
34
|
+
import {IconName} from '@fortawesome/fontawesome-svg-core';
|
|
20
35
|
|
|
21
36
|
interface Props {
|
|
22
37
|
onClickProceed?: PDFSubmitHandler;
|
|
@@ -32,6 +47,7 @@ interface Props {
|
|
|
32
47
|
disableElements: ('text' | 'image' | 'invoiceTable')[];
|
|
33
48
|
maxWidth?: string;
|
|
34
49
|
supportMultiPage: boolean;
|
|
50
|
+
options?: PDFOptions;
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
interface State {
|
|
@@ -174,11 +190,15 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
174
190
|
|
|
175
191
|
getElement = (id: string, config: DefaultPDFElementParams<any, any>,
|
|
176
192
|
convertUnits: boolean = true): React.ReactElement => {
|
|
177
|
-
const {dimensions, linkedID, persistent} = config
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
193
|
+
const {dimensions, linkedID, persistent} = config;
|
|
194
|
+
const position: { x: number; y: number } = {
|
|
195
|
+
x: convertUnits ? ptToPx(dimensions?.left || 0) : (dimensions?.left || 0),
|
|
196
|
+
y: convertUnits ? ptToPx(dimensions?.top || 0) : (dimensions?.top || 0),
|
|
197
|
+
};
|
|
198
|
+
const width = dimensions?.width;
|
|
199
|
+
const height = dimensions?.height;
|
|
200
|
+
const {values, mainFont} = this.props;
|
|
201
|
+
const key: string = generateUUID();
|
|
182
202
|
const sharedProps = {
|
|
183
203
|
defaultPosition: position,
|
|
184
204
|
onDelete: this.onDeleteElement(id),
|
|
@@ -224,17 +244,20 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
224
244
|
render = () => {
|
|
225
245
|
const {elements, focusedElement, canUndo, canRedo,} = this.state,
|
|
226
246
|
{
|
|
227
|
-
customVariables, onPreview, mainFont,
|
|
247
|
+
customVariables, onPreview, mainFont, onClickProceed, maxWidth
|
|
228
248
|
} = this.props;
|
|
249
|
+
const disableElements = this.props.options?.disableElements ?? this.props.disableElements;
|
|
250
|
+
const supportMultiPage = this.props.options?.supportMultiPage ?? this.props.supportMultiPage;
|
|
251
|
+
const enableTableHeaderColor = this.props.options?.enableTableHeaderColor;
|
|
229
252
|
return (
|
|
230
253
|
<div className='pdf-creator' onClick={this.onResetElement}
|
|
231
254
|
style={{maxWidth: maxWidth ?? '100%'}}>
|
|
232
255
|
<div className='footer-container'>
|
|
233
|
-
{onPreview !== undefined ? <
|
|
256
|
+
{onPreview !== undefined ? <DvrdButton onClick={this.onPreview} label='Voorbeeld'/> : <div/>}
|
|
234
257
|
<div>
|
|
235
|
-
<
|
|
258
|
+
<DvrdButton onClick={this.onSubmit} label='Opslaan'/>
|
|
236
259
|
{onClickProceed !== undefined &&
|
|
237
|
-
<
|
|
260
|
+
<DvrdButton onClick={this.onClickProceed} label='Naar volgende stap' className='proceed-btn'/>}
|
|
238
261
|
</div>
|
|
239
262
|
</div>
|
|
240
263
|
<div/>
|
|
@@ -258,7 +281,7 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
258
281
|
</div>
|
|
259
282
|
</div>
|
|
260
283
|
<div className='history-reset'>
|
|
261
|
-
<
|
|
284
|
+
<DvrdButton onClick={this.onReset} label='Reset'/>
|
|
262
285
|
</div>
|
|
263
286
|
</div>
|
|
264
287
|
<div className='pdf-paper' onClick={this.onResetElement}>
|
|
@@ -271,6 +294,7 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
271
294
|
<div className='right-col'>
|
|
272
295
|
<PdfElementSettings element={focusedElement} onReset={this.onResetElement}
|
|
273
296
|
customVariables={customVariables} font={mainFont}
|
|
297
|
+
enableTableHeaderColor={enableTableHeaderColor}
|
|
274
298
|
onChangeFont={this.onChangeFont} supportMultiPage={supportMultiPage}/>
|
|
275
299
|
</div>
|
|
276
300
|
</div>
|
|
@@ -5,7 +5,7 @@ import './style/pdfImageSettings.scss';
|
|
|
5
5
|
|
|
6
6
|
import React, {PureComponent} from 'react';
|
|
7
7
|
import PdfImage from "../../image/pdfImage";
|
|
8
|
-
import {Button, DvrdSelect, ElementPosition, SelectItemShape} from "../../../../../index";
|
|
8
|
+
import {Button, DvrdButton, DvrdSelect, ElementPosition, SelectItemShape} from "../../../../../index";
|
|
9
9
|
import IconButton, {IconButtonType} from "../buttons/iconButton";
|
|
10
10
|
import {PDFDisplay} from "../../../util/interfaces";
|
|
11
11
|
|
|
@@ -62,7 +62,7 @@ export default class PdfImageSettings extends PureComponent<Props, State> {
|
|
|
62
62
|
<div className='pdf-image-settings'>
|
|
63
63
|
{supportMultiPage && <>
|
|
64
64
|
<label className='settings-title'>Pagina's</label>
|
|
65
|
-
<DvrdSelect onChange={this.onChangeDisplay} value={display} items={displayItems}/>
|
|
65
|
+
<DvrdSelect onChange={this.onChangeDisplay} value={display} items={displayItems} unControlled/>
|
|
66
66
|
</>}
|
|
67
67
|
<div className='divider'/>
|
|
68
68
|
<label className='settings-title'>Uitlijning</label>
|
|
@@ -75,7 +75,7 @@ export default class PdfImageSettings extends PureComponent<Props, State> {
|
|
|
75
75
|
type={IconButtonType.RIGHT} title='Rechts'/>
|
|
76
76
|
</div>
|
|
77
77
|
<div className='divider'/>
|
|
78
|
-
<
|
|
78
|
+
<DvrdButton onClick={element.onChooseFile} label='Kies afbeelding'/>
|
|
79
79
|
</div>
|
|
80
80
|
)
|
|
81
81
|
}
|
|
@@ -5,25 +5,27 @@ import './style/pdfInvoiceTableSettings.scss';
|
|
|
5
5
|
|
|
6
6
|
import React, {PureComponent} from 'react';
|
|
7
7
|
import PdfInvoiceTable from "../../invoiceTable/pdfInvoiceTable";
|
|
8
|
-
import NumberInput from "../../../input/number/numberInput";
|
|
9
8
|
import {debug} from "../../../util/miscUtil";
|
|
10
9
|
import {ElementPosition} from "../../../util/interfaces";
|
|
11
10
|
import {fontItems} from "../../../util/pdfUtil";
|
|
12
|
-
import {ColorPicker,
|
|
11
|
+
import {ColorPicker, DvrdNumberInput, DvrdSelect} from "../../../../../index";
|
|
13
12
|
import IconButton, {IconButtonType} from "../buttons/iconButton";
|
|
14
13
|
|
|
15
14
|
interface Props {
|
|
16
15
|
element: PdfInvoiceTable;
|
|
16
|
+
headColorEnabled?: boolean;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
interface State {
|
|
20
20
|
widths: number[];
|
|
21
21
|
color: string;
|
|
22
|
+
headerColor: string;
|
|
22
23
|
colorPickerActive: boolean;
|
|
24
|
+
headColorPickerActive: boolean;
|
|
23
25
|
alignment?: ElementPosition;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
const TITLES = ['
|
|
28
|
+
const TITLES = ['Omschrijving', 'Aantal', 'Prijs', 'BTW', 'Subtotaal'];
|
|
27
29
|
|
|
28
30
|
export default class PdfInvoiceTableSettings extends PureComponent<Props, State> {
|
|
29
31
|
constructor(props: Props) {
|
|
@@ -32,7 +34,9 @@ export default class PdfInvoiceTableSettings extends PureComponent<Props, State>
|
|
|
32
34
|
this.state = {
|
|
33
35
|
widths: settings.widths,
|
|
34
36
|
color: settings.color,
|
|
37
|
+
headerColor: settings.headerColor,
|
|
35
38
|
colorPickerActive: false,
|
|
39
|
+
headColorPickerActive: false,
|
|
36
40
|
alignment: settings.alignment,
|
|
37
41
|
};
|
|
38
42
|
}
|
|
@@ -56,6 +60,25 @@ export default class PdfInvoiceTableSettings extends PureComponent<Props, State>
|
|
|
56
60
|
});
|
|
57
61
|
};
|
|
58
62
|
|
|
63
|
+
onCloseHeadColorPicker = () => {
|
|
64
|
+
this.setState({headColorPickerActive: false});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
onOpenHeadColorPicker = () => {
|
|
68
|
+
this.setState({headColorPickerActive: true});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
onPickHeadColor = (close: boolean = true) => (color: string) => {
|
|
72
|
+
const {element} = this.props;
|
|
73
|
+
if (close)
|
|
74
|
+
this.setState({headColorPickerActive: false, headerColor: color}, () => {
|
|
75
|
+
element.setSetting('headerColor', color)
|
|
76
|
+
});
|
|
77
|
+
else this.setState({headerColor: color}, () => {
|
|
78
|
+
element.setSetting('headerColor', color, undefined, false);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
59
82
|
onChangeWidth = (index: number) => (value: number) => {
|
|
60
83
|
const {element} = this.props, widths = element.getSettings().widths.slice(),
|
|
61
84
|
remainder = this.getRemainingWidth(index);
|
|
@@ -93,18 +116,19 @@ export default class PdfInvoiceTableSettings extends PureComponent<Props, State>
|
|
|
93
116
|
renderWidth = (value: number, index: number) => {
|
|
94
117
|
const title = TITLES[index];
|
|
95
118
|
return (
|
|
96
|
-
<
|
|
119
|
+
<DvrdNumberInput key={index} value={value.toString()} onChange={this.onChangeWidth(index)} label={title}
|
|
97
120
|
ornaments={{
|
|
98
121
|
element: <span style={{cursor: 'text'}}>%</span>,
|
|
99
122
|
placement: ElementPosition.RIGHT,
|
|
100
123
|
allowPropagation: true
|
|
101
|
-
}} asNumber/>
|
|
124
|
+
}} asNumber unControlled/>
|
|
102
125
|
);
|
|
103
126
|
};
|
|
104
127
|
|
|
105
128
|
render = () => {
|
|
106
|
-
const {widths, colorPickerActive, color, alignment
|
|
107
|
-
|
|
129
|
+
const {widths, colorPickerActive, color, alignment, headerColor, headColorPickerActive} = this.state;
|
|
130
|
+
const {element, headColorEnabled} = this.props;
|
|
131
|
+
const settings = element.getSettings();
|
|
108
132
|
return (
|
|
109
133
|
<div className='pdf-invoice-table-settings'>
|
|
110
134
|
<label className='settings-label'>Kolom breedtes</label>
|
|
@@ -119,14 +143,15 @@ export default class PdfInvoiceTableSettings extends PureComponent<Props, State>
|
|
|
119
143
|
{widths.map(this.renderWidth)}
|
|
120
144
|
<div className='divider'/>
|
|
121
145
|
<label className='settings-label'>Tekstgrootte</label>
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
146
|
+
<DvrdSelect items={fontItems} value={settings.font} onChange={element.changeSetting('font')}
|
|
147
|
+
label='Lettertype' optionsContainerHeight='15rem' unControlled/>
|
|
148
|
+
<DvrdNumberInput value={settings.fontSize} onChange={element.changeSetting('fontSize')}
|
|
149
|
+
asNumber
|
|
150
|
+
ornaments={{
|
|
151
|
+
element: <span style={{cursor: 'text'}}>px</span>,
|
|
152
|
+
placement: ElementPosition.RIGHT,
|
|
153
|
+
allowPropagation: true
|
|
154
|
+
}} wholeNumbers unControlled/>
|
|
130
155
|
<div className='settings-color-picker'>
|
|
131
156
|
<label className='picker-label'>Tekstkleur:</label>
|
|
132
157
|
<div className='color-preview' style={{backgroundColor: color}}
|
|
@@ -135,6 +160,15 @@ export default class PdfInvoiceTableSettings extends PureComponent<Props, State>
|
|
|
135
160
|
onPreChange={this.onPickColor(false)} color={settings.color}
|
|
136
161
|
visible={colorPickerActive} className='text-color-picker' transparent/>
|
|
137
162
|
</div>
|
|
163
|
+
{!!headColorEnabled && <div className='settings-color-picker'>
|
|
164
|
+
<label className='picker-label'>Kleur kopregel:</label>
|
|
165
|
+
<div className='color-preview' style={{backgroundColor: headerColor}}
|
|
166
|
+
onClick={this.onOpenHeadColorPicker}/>
|
|
167
|
+
<ColorPicker onClose={this.onCloseHeadColorPicker} onSubmit={this.onPickHeadColor()}
|
|
168
|
+
closeable={false} onPreChange={this.onPickHeadColor(false)}
|
|
169
|
+
color={settings.headerColor} visible={headColorPickerActive}
|
|
170
|
+
className='text-color-picker' transparent/>
|
|
171
|
+
</div>}
|
|
138
172
|
</div>
|
|
139
173
|
)
|
|
140
174
|
}
|
|
@@ -6,21 +6,24 @@ import './style/pdfElementSettings.scss';
|
|
|
6
6
|
import React, {MouseEventHandler, PureComponent} from 'react';
|
|
7
7
|
import {PdfElement} from "../element/pdfElement";
|
|
8
8
|
import PdfText from "../text/pdfText";
|
|
9
|
-
import {PDFElementPersist, PdfFont, PDFTextVariables} from "../../util/interfaces";
|
|
10
|
-
import {
|
|
9
|
+
import {ChangeFunction, PDFElementPersist, PdfFont, PDFTextVariables} from "../../util/interfaces";
|
|
10
|
+
import {fontItems, showDialog, stopPropagation} from "../../../../";
|
|
11
11
|
import PdfTextSettings from "./text/pdfTextSettings";
|
|
12
12
|
import PdfImage from "../image/pdfImage";
|
|
13
13
|
import PdfImageSettings from "./image/pdfImageSettings";
|
|
14
14
|
import PdfInvoiceTable from "../invoiceTable/pdfInvoiceTable";
|
|
15
15
|
import PdfInvoiceTableSettings from "./invoiceTable/pdfInvoiceTableSettings";
|
|
16
|
+
import DvrdButton from "../../button/dvrdButton";
|
|
17
|
+
import DvrdSelect from '../../select/dvrdSelectController';
|
|
16
18
|
|
|
17
19
|
interface Props {
|
|
18
20
|
onReset: MouseEventHandler;
|
|
19
|
-
onChangeFont:
|
|
21
|
+
onChangeFont: ChangeFunction;
|
|
20
22
|
element: PdfElement | null;
|
|
21
23
|
customVariables?: PDFTextVariables;
|
|
22
24
|
font: PdfFont;
|
|
23
25
|
supportMultiPage: boolean;
|
|
26
|
+
enableTableHeaderColor?: boolean;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
export default class PdfElementSettings extends PureComponent<Props> {
|
|
@@ -46,13 +49,14 @@ export default class PdfElementSettings extends PureComponent<Props> {
|
|
|
46
49
|
};
|
|
47
50
|
|
|
48
51
|
renderSettings = () => {
|
|
49
|
-
const {element, customVariables, supportMultiPage} = this.props;
|
|
52
|
+
const {element, customVariables, supportMultiPage, enableTableHeaderColor} = this.props;
|
|
50
53
|
if (element === null) return this.renderMainSettings();
|
|
51
54
|
if (element instanceof PdfText) return <PdfTextSettings element={element} customVariables={customVariables}
|
|
52
55
|
supportMultiPage={supportMultiPage}/>;
|
|
53
56
|
if (element instanceof PdfImage) return <PdfImageSettings element={element}
|
|
54
57
|
supportMultiPage={supportMultiPage}/>;
|
|
55
|
-
if (element instanceof PdfInvoiceTable) return <PdfInvoiceTableSettings element={element}
|
|
58
|
+
if (element instanceof PdfInvoiceTable) return <PdfInvoiceTableSettings element={element}
|
|
59
|
+
headColorEnabled={enableTableHeaderColor}/>
|
|
56
60
|
return null;
|
|
57
61
|
};
|
|
58
62
|
|
|
@@ -60,8 +64,8 @@ export default class PdfElementSettings extends PureComponent<Props> {
|
|
|
60
64
|
const {font, onChangeFont} = this.props;
|
|
61
65
|
return (
|
|
62
66
|
<div className='main-settings'>
|
|
63
|
-
<
|
|
64
|
-
|
|
67
|
+
<DvrdSelect items={fontItems} value={font} onChange={onChangeFont} label='Standaard lettertype'
|
|
68
|
+
unControlled/>
|
|
65
69
|
</div>
|
|
66
70
|
)
|
|
67
71
|
};
|
|
@@ -75,9 +79,10 @@ export default class PdfElementSettings extends PureComponent<Props> {
|
|
|
75
79
|
{this.renderSettings()}
|
|
76
80
|
{element !== null && (
|
|
77
81
|
<div className='buttons-container'>
|
|
78
|
-
<
|
|
82
|
+
<DvrdButton onClick={onReset} label='Oké' className='reset-btn'/>
|
|
79
83
|
{deleteAble &&
|
|
80
|
-
<
|
|
84
|
+
<DvrdButton onClick={this.onClickDelete} label='Verwijderen' customContrastColor='red'
|
|
85
|
+
secondary/>}
|
|
81
86
|
</div>
|
|
82
87
|
)}
|
|
83
88
|
</div>
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
PDFTextVariables,
|
|
15
15
|
SelectItemShape
|
|
16
16
|
} from "../../../util/interfaces";
|
|
17
|
-
import {ColorPicker, DvrdSelect, fontItems, getPdfVariables
|
|
17
|
+
import {ColorPicker, DvrdNumberInput, DvrdSelect, fontItems, getPdfVariables} from "../../../../../index";
|
|
18
18
|
import classNames from 'classnames';
|
|
19
19
|
import IconButton, {IconButtonType} from "../buttons/iconButton";
|
|
20
20
|
|
|
@@ -156,7 +156,7 @@ export default class PdfTextSettings extends PureComponent<Props, State> {
|
|
|
156
156
|
<div className='pdf-text-settings'>
|
|
157
157
|
{supportMultiPage && <>
|
|
158
158
|
<label className='settings-title'>Weergave</label>
|
|
159
|
-
<DvrdSelect onChange={this.onChangeDisplay} value={display} items={displayItems}/>
|
|
159
|
+
<DvrdSelect onChange={this.onChangeDisplay} value={display} items={displayItems} unControlled/>
|
|
160
160
|
</>}
|
|
161
161
|
<div className='divider'/>
|
|
162
162
|
<div className='text-settings'>
|
|
@@ -175,16 +175,15 @@ export default class PdfTextSettings extends PureComponent<Props, State> {
|
|
|
175
175
|
</div>
|
|
176
176
|
<div className='divider'/>
|
|
177
177
|
<div className='font-settings'>
|
|
178
|
-
<
|
|
179
|
-
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
asNumber unControlled/>
|
|
178
|
+
<DvrdSelect items={fontItems} value={settings.font} onChange={element.changeSetting('font')}
|
|
179
|
+
label='Lettertype' optionsContainerHeight='15rem' unControlled/>
|
|
180
|
+
<DvrdNumberInput value={settings.fontSize} onChange={element.changeSetting('fontSize')}
|
|
181
|
+
label='Tekstgrootte' className='font-size'
|
|
182
|
+
ornaments={{
|
|
183
|
+
element: <span style={{cursor: 'text'}}>px</span>,
|
|
184
|
+
placement: ElementPosition.RIGHT,
|
|
185
|
+
allowPropagation: true
|
|
186
|
+
}} wholeNumbers asNumber unControlled/>
|
|
188
187
|
<div className='settings-color-picker'>
|
|
189
188
|
<label className='picker-label'>Tekstkleur:</label>
|
|
190
189
|
<div className='color-preview' style={{backgroundColor: color}}
|
|
@@ -145,7 +145,8 @@ export default class DvrdSelect extends PureComponent<Props, State> {
|
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
renderItem = (item: SelectItemShape, index: number) => {
|
|
148
|
-
const {
|
|
148
|
+
const {value, selectableItemLabel} = item;
|
|
149
|
+
const label = selectableItemLabel ?? item.label;
|
|
149
150
|
const {itemClassName} = this.props;
|
|
150
151
|
if (['number', 'string'].includes(typeof label)) return (
|
|
151
152
|
<label key={index} className={classNames('dvrd-select-item', itemClassName)}
|
|
@@ -24,10 +24,12 @@ interface Props {
|
|
|
24
24
|
itemsPosition: 'top' | 'bottom';
|
|
25
25
|
selectOnly: boolean;
|
|
26
26
|
optionsContainerHeight: number | string;
|
|
27
|
+
unControlled?: boolean;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
interface State {
|
|
30
31
|
searchValue: string;
|
|
32
|
+
value: string | number;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export default class DvrdSelectController extends PureComponent<Props, State> {
|
|
@@ -41,10 +43,12 @@ export default class DvrdSelectController extends PureComponent<Props, State> {
|
|
|
41
43
|
|
|
42
44
|
state: State = {
|
|
43
45
|
searchValue: '',
|
|
46
|
+
value: this.props.value,
|
|
44
47
|
};
|
|
45
48
|
|
|
46
|
-
onChange = (value: string) => () => {
|
|
49
|
+
onChange = (value: string | number) => () => {
|
|
47
50
|
this.props.onChange(value);
|
|
51
|
+
this.setState({value});
|
|
48
52
|
};
|
|
49
53
|
|
|
50
54
|
onChangeSearch = (evt: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -65,8 +69,9 @@ export default class DvrdSelectController extends PureComponent<Props, State> {
|
|
|
65
69
|
render = () => {
|
|
66
70
|
const {
|
|
67
71
|
arrowClassName, label, error, className, labelClassName, valueClassName, itemContainerClassName,
|
|
68
|
-
itemClassName, errorClassName, disabled,
|
|
72
|
+
itemClassName, errorClassName, disabled, itemsPosition, selectOnly, optionsContainerHeight, unControlled
|
|
69
73
|
} = this.props, {searchValue} = this.state;
|
|
74
|
+
const value = !!unControlled ? this.state.value : this.props.value;
|
|
70
75
|
return (
|
|
71
76
|
<DvrdSelect onChange={this.onChange} value={value} items={this.getItems()} disabled={disabled}
|
|
72
77
|
errorClassName={errorClassName} itemClassName={itemClassName}
|
|
@@ -32,21 +32,34 @@ interface Props {
|
|
|
32
32
|
asNumber?: boolean;
|
|
33
33
|
asCurrency: boolean;
|
|
34
34
|
autoSelect?: boolean;
|
|
35
|
+
unControlled?: boolean;
|
|
35
36
|
}
|
|
37
|
+
|
|
36
38
|
// TODO Add option to disable symbols (+,-)
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
interface State {
|
|
41
|
+
value: number | string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default class DvrdNumberInput extends PureComponent<Props, State> {
|
|
39
45
|
static defaultProps = {
|
|
40
46
|
asCurrency: false,
|
|
41
47
|
wholeNumbers: false,
|
|
42
48
|
multipleSeparators: false,
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
constructor(props: Props) {
|
|
52
|
+
super(props);
|
|
53
|
+
this.state = {
|
|
54
|
+
value: props.value,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
45
59
|
onKeyDown = (evt: React.KeyboardEvent) => {
|
|
46
|
-
const {onKeyDown, asCurrency, wholeNumbers, inputProps, asNumber,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} = evt;
|
|
60
|
+
const {onKeyDown, asCurrency, wholeNumbers, inputProps, asNumber, multipleSeparators} = this.props;
|
|
61
|
+
const {value} = this.state;
|
|
62
|
+
const {key, target} = evt;
|
|
50
63
|
let numValue = Number(value);
|
|
51
64
|
// Allow only number and simple edit keys
|
|
52
65
|
if (!/\d|Backspace|ArrowRight|ArrowLeft|ArrowUp|ArrowDown|Escape|Esc|Enter|[,.\-+]|Tab/.test(key) &&
|
|
@@ -134,8 +147,10 @@ export default class DvrdNumberInput extends PureComponent<Props> {
|
|
|
134
147
|
};
|
|
135
148
|
|
|
136
149
|
render = () => {
|
|
150
|
+
const value = this.props.unControlled ? this.state.value : this.props.value;
|
|
137
151
|
return (
|
|
138
|
-
<DvrdInputController {...this.props} onChange={this.onChange} onKeyDown={this.onKeyDown}
|
|
152
|
+
<DvrdInputController {...this.props} value={value} onChange={this.onChange} onKeyDown={this.onKeyDown}
|
|
153
|
+
unControlled={false}/>
|
|
139
154
|
);
|
|
140
155
|
}
|
|
141
156
|
}
|
|
@@ -50,6 +50,7 @@ export interface SelectItemShape {
|
|
|
50
50
|
labelClass?: string;
|
|
51
51
|
labelStyle?: CSSProperties;
|
|
52
52
|
valueLabel?: string;
|
|
53
|
+
selectableItemLabel?: string | number;
|
|
53
54
|
|
|
54
55
|
[key: string]: any,
|
|
55
56
|
}
|
|
@@ -59,6 +60,13 @@ export interface DialogConfig {
|
|
|
59
60
|
textColor?: string;
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
export interface PDFOptions {
|
|
64
|
+
disableElements?: Array<'text' | 'image' | 'invoiceTable'>;
|
|
65
|
+
maxWidth?: number | string;
|
|
66
|
+
supportMultiPage?: boolean;
|
|
67
|
+
enableTableHeaderColor?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
// =========== ENUMS
|
|
63
71
|
|
|
64
72
|
export enum ModeEnum {DETAIL = 'detail', EDIT = 'edit', NEW = 'new'}
|
|
@@ -152,7 +160,15 @@ export type DefaultPDFElementParams<T extends PDFElementType, O extends IndexedO
|
|
|
152
160
|
}>
|
|
153
161
|
export type PDFImageParams = { img: File | string | null, persistent: PDFElementPersist; alignment?: ElementPosition; display?: PDFDisplay };
|
|
154
162
|
export type PDFTextParams = { bold: boolean; underline: boolean; italic: boolean; fontSize: number; text: string; alignment?: ElementPosition; disabled?: boolean, font: PdfFont, color: string; persistent: PDFElementPersist; display?: PDFDisplay };
|
|
155
|
-
export type PDFInvoiceTableParams = {
|
|
163
|
+
export type PDFInvoiceTableParams = {
|
|
164
|
+
fontSize: number;
|
|
165
|
+
widths: number[];
|
|
166
|
+
font: PdfFont;
|
|
167
|
+
color: string;
|
|
168
|
+
headerColor: string;
|
|
169
|
+
alignment?: ElementPosition;
|
|
170
|
+
persistent: PDFElementPersist;
|
|
171
|
+
};
|
|
156
172
|
export type PDFInvoiceWidths = { name: number; price: number; quantity: number; subtotal: number }
|
|
157
173
|
export type PDFTextVariables = { company: IndexedObject<string>; client: IndexedObject<string>; invoice: IndexedObject<string>; }
|
|
158
174
|
export type PDFSubmitHandler = (items: PDFElementParams<any, any>[], callback?: VoidFunction) => void;
|