@dvrd/dvr-controls 1.1.2 → 1.1.4
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
CHANGED
|
@@ -13,6 +13,7 @@ import {generateComponentId} from "../../util/componentUtil";
|
|
|
13
13
|
import {PAGE_WIDTH, pxToPt} from "../../util/pdfUtil";
|
|
14
14
|
import classNames from 'classnames';
|
|
15
15
|
import {AwesomeIcon, debug} from "../../../../index";
|
|
16
|
+
import NumberString from "../../util/numberString";
|
|
16
17
|
|
|
17
18
|
interface State {
|
|
18
19
|
dragging: boolean;
|
|
@@ -52,7 +53,7 @@ export abstract class PdfElement<P extends SharedProps = any, S extends State =
|
|
|
52
53
|
this.setState({dragging: false});
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
setFont = (data: {
|
|
56
|
+
setFont = (data: {previousFont: PdfFont, font: PdfFont}) => {
|
|
56
57
|
const {previousFont, font} = data, {settings} = this.state;
|
|
57
58
|
if (settings.hasOwnProperty('font')) {
|
|
58
59
|
if (settings['font'] === previousFont)
|
|
@@ -86,6 +87,7 @@ export abstract class PdfElement<P extends SharedProps = any, S extends State =
|
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
public changeSetting = (key: string) => (value: any) => {
|
|
90
|
+
if (value instanceof NumberString) value = value.nullNumberValue;
|
|
89
91
|
this.setSetting(key, value);
|
|
90
92
|
};
|
|
91
93
|
|
|
@@ -111,9 +113,9 @@ export abstract class PdfElement<P extends SharedProps = any, S extends State =
|
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
interface DraggableProps {
|
|
114
|
-
onDrag?: (position: {
|
|
116
|
+
onDrag?: (position: {x: number; y: number;}) => void;
|
|
115
117
|
onDragStart: VoidFunction;
|
|
116
|
-
onDragEnd: (position: {
|
|
118
|
+
onDragEnd: (position: {x: number; y: number;}) => void;
|
|
117
119
|
onDragged: VoidFunction;
|
|
118
120
|
onResized: VoidFunction;
|
|
119
121
|
onDelete?: MouseEventHandler;
|
|
@@ -128,7 +130,7 @@ interface DraggableProps {
|
|
|
128
130
|
resizeable: boolean;
|
|
129
131
|
resizeHoriz: boolean;
|
|
130
132
|
resizeVert: boolean;
|
|
131
|
-
position?: {
|
|
133
|
+
position?: {x: number; y: number};
|
|
132
134
|
lockAspect?: boolean;
|
|
133
135
|
maxWidth: number;
|
|
134
136
|
maxHeight: number;
|
|
@@ -140,7 +142,7 @@ interface DraggableProps {
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
interface DraggableState {
|
|
143
|
-
position: {
|
|
145
|
+
position: {x: number; y: number};
|
|
144
146
|
width: number | string;
|
|
145
147
|
height: number | string;
|
|
146
148
|
}
|
|
@@ -183,11 +185,11 @@ export class PDFDraggable extends PureComponent<PropsWithChildren<DraggableProps
|
|
|
183
185
|
}
|
|
184
186
|
};
|
|
185
187
|
|
|
186
|
-
public setPosition = (position: {
|
|
188
|
+
public setPosition = (position: {x?: number; y?: number}, callback?: VoidFunction) => {
|
|
187
189
|
this.setState({position: Object.assign({}, this.state.position, position)}, callback);
|
|
188
190
|
};
|
|
189
191
|
|
|
190
|
-
public getPosition = (): {
|
|
192
|
+
public getPosition = (): {x: number; y: number} => this.state.position;
|
|
191
193
|
|
|
192
194
|
onDrag = (evt: any, data: DraggableData) => {
|
|
193
195
|
const {onDrag, alignment} = this.props, {position} = this.state,
|
|
@@ -296,7 +298,7 @@ export class PDFDraggable extends PureComponent<PropsWithChildren<DraggableProps
|
|
|
296
298
|
<div className='options'>
|
|
297
299
|
{onEdit !== undefined && <AwesomeIcon name='pen' onClick={onEdit} className='action'/>}
|
|
298
300
|
{onDelete !== undefined &&
|
|
299
|
-
|
|
301
|
+
<AwesomeIcon name='trash-alt' onClick={onDelete} className='action delete'/>}
|
|
300
302
|
</div>
|
|
301
303
|
</div>
|
|
302
304
|
<div className={classNames('pdf-element', 'rnd', matchParentSize && 'match-size')} ref={forwardRef}
|
|
@@ -10,6 +10,7 @@ import {ElementPosition} from "../../../util/interfaces";
|
|
|
10
10
|
import {fontItems} from "../../../util/pdfUtil";
|
|
11
11
|
import IconButton, {IconButtonType} from "../buttons/iconButton";
|
|
12
12
|
import {ColorPicker, DVRDNumberInput, DvrdSelect} from "../../../../../index";
|
|
13
|
+
import NumberString from "../../../util/numberString";
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
15
16
|
element: PdfInvoiceTable;
|
|
@@ -79,12 +80,13 @@ export default class PdfInvoiceTableSettings extends PureComponent<Props, State>
|
|
|
79
80
|
});
|
|
80
81
|
};
|
|
81
82
|
|
|
82
|
-
onChangeWidth = (index: number) => (value:
|
|
83
|
+
onChangeWidth = (index: number) => (value: NumberString) => {
|
|
83
84
|
const {element} = this.props, widths = element.getSettings().widths.slice(),
|
|
84
85
|
remainder = this.getRemainingWidth(index);
|
|
86
|
+
let numValue = value.numberValue;
|
|
85
87
|
debug('Remainder', {remainder});
|
|
86
|
-
if (
|
|
87
|
-
widths[index] =
|
|
88
|
+
if (numValue > remainder) numValue = remainder;
|
|
89
|
+
widths[index] = numValue;
|
|
88
90
|
element.setSetting('widths', widths);
|
|
89
91
|
this.setState({widths});
|
|
90
92
|
};
|
|
@@ -121,7 +123,7 @@ export default class PdfInvoiceTableSettings extends PureComponent<Props, State>
|
|
|
121
123
|
element: <span style={{cursor: 'text'}}>%</span>,
|
|
122
124
|
placement: ElementPosition.RIGHT,
|
|
123
125
|
allowPropagation: true
|
|
124
|
-
}}
|
|
126
|
+
}} unControlled/>
|
|
125
127
|
);
|
|
126
128
|
};
|
|
127
129
|
|
|
@@ -146,7 +148,6 @@ export default class PdfInvoiceTableSettings extends PureComponent<Props, State>
|
|
|
146
148
|
<DvrdSelect items={fontItems} value={settings.font} onChange={element.changeSetting('font')}
|
|
147
149
|
label='Lettertype' optionsContainerHeight='15rem' unControlled/>
|
|
148
150
|
<DVRDNumberInput value={settings.fontSize} onChange={element.changeSetting('fontSize')}
|
|
149
|
-
asNumber
|
|
150
151
|
ornaments={{
|
|
151
152
|
element: <span style={{cursor: 'text'}}>px</span>,
|
|
152
153
|
placement: ElementPosition.RIGHT,
|
|
@@ -183,7 +183,7 @@ export default class PdfTextSettings extends PureComponent<Props, State> {
|
|
|
183
183
|
element: <span style={{cursor: 'text'}}>px</span>,
|
|
184
184
|
placement: ElementPosition.RIGHT,
|
|
185
185
|
allowPropagation: true
|
|
186
|
-
}} wholeNumbers
|
|
186
|
+
}} wholeNumbers unControlled/>
|
|
187
187
|
<div className='settings-color-picker'>
|
|
188
188
|
<label className='picker-label'>Tekstkleur:</label>
|
|
189
189
|
<div className='color-preview' style={{backgroundColor: color}}
|
|
@@ -27,7 +27,8 @@ export default class NumberString {
|
|
|
27
27
|
if (!nullString) return null;
|
|
28
28
|
const numValue = Number(nullString.replace(',', '.'));
|
|
29
29
|
if (Number.isNaN(numValue)) return null;
|
|
30
|
-
return
|
|
30
|
+
if(!numValue) return this.zeroAsNull ? null : 0;
|
|
31
|
+
return numValue;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
setValue = (value: string | number): NumberString => {
|