@dvrd/dvr-controls 0.0.37 → 0.0.38

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvrd/dvr-controls",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "description": "Custom web controls",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -5,7 +5,7 @@ import './style/pdfImage.scss';
5
5
 
6
6
  import React, {MouseEventHandler} from 'react';
7
7
  import {
8
- ElementPosition, IndexedObject, PDFElementParams, PDFElementPersist, PDFElementType, PDFImageParams
8
+ ElementPosition, IndexedObject, PDFDisplay, PDFElementParams, PDFElementPersist, PDFElementType, PDFImageParams
9
9
  } from "../../util/interfaces";
10
10
  import {PDFDraggable, PdfElement} from "../element/pdfElement";
11
11
  import {nullify} from "../../util/miscUtil";
@@ -28,7 +28,7 @@ interface Props {
28
28
 
29
29
  interface State {
30
30
  dragging: boolean;
31
- settings: { img: string; persistent: PDFElementPersist; alignment?: ElementPosition; multiPage?: boolean };
31
+ settings: { img: string; persistent: PDFElementPersist; alignment?: ElementPosition; display?: PDFDisplay };
32
32
  }
33
33
 
34
34
  export default class PdfImage extends PdfElement<Props, State> {
@@ -46,7 +46,7 @@ export default class PdfImage extends PdfElement<Props, State> {
46
46
  img: props.values?.default_image || '',
47
47
  persistent: PDFElementPersist.NOT_PERSISTENT,
48
48
  alignment: undefined,
49
- multiPage: false,
49
+ display: PDFDisplay.ALL_PAGES,
50
50
  }, props.defaultSettings),
51
51
  dragging: false,
52
52
  };
@@ -125,7 +125,7 @@ export default class PdfImage extends PdfElement<Props, State> {
125
125
  img: this.image ?? nullify(settings.img),
126
126
  persistent: settings.persistent,
127
127
  alignment: settings.alignment,
128
- multiPage: settings.multiPage,
128
+ display: settings.display,
129
129
  },
130
130
  };
131
131
  };
@@ -151,7 +151,7 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
151
151
  <PDFDraggable dragging={dragging} draggable={draggable} onDragStart={this.onDragStart}
152
152
  alignment={settings.alignment} elementLabel='Factuurregels' onDragEnd={this.onDragEnd}
153
153
  position={defaultPosition} width={width} height={height} onEdit={this.onClick}
154
- onClickBar={this.onClickBar}
154
+ onClickBar={this.onClickBar} matchParentSize
155
155
  forwardRef={(ref: HTMLDivElement) => {
156
156
  this.element = ref
157
157
  }} ref={(ref: PDFDraggable) => {
@@ -5,8 +5,9 @@ import './style/pdfImageSettings.scss';
5
5
 
6
6
  import React, {PureComponent} from 'react';
7
7
  import PdfImage from "../../image/pdfImage";
8
- import {Button, Checkbox, ElementPosition} from "../../../../../index";
8
+ import {Button, DvrdSelect, ElementPosition, SelectItemShape} from "../../../../../index";
9
9
  import IconButton, {IconButtonType} from "../buttons/iconButton";
10
+ import {PDFDisplay} from "../../../util/interfaces";
10
11
 
11
12
  interface Props {
12
13
  element: PdfImage;
@@ -15,25 +16,31 @@ interface Props {
15
16
 
16
17
  interface State {
17
18
  alignment?: ElementPosition;
18
- multiPage: boolean;
19
+ display: PDFDisplay;
19
20
  }
20
21
 
22
+ const displayItems: SelectItemShape[] = [
23
+ {value: PDFDisplay.ALL_PAGES, label: 'Alle pagina\'s'},
24
+ {value: PDFDisplay.FIRST_PAGE, label: 'Alleen eerste pagina'},
25
+ {value: PDFDisplay.LAST_PAGE, label: 'Alleen laatste pagina'},
26
+ ]
27
+
21
28
  export default class PdfImageSettings extends PureComponent<Props, State> {
22
29
  constructor(props: Props) {
23
30
  super(props);
24
31
  const settings = props.element.getSettings();
25
32
  this.state = {
26
33
  alignment: settings.alignment,
27
- multiPage: settings.multiPage ?? false,
34
+ display: settings.display ?? PDFDisplay.ALL_PAGES,
28
35
  };
29
36
  }
30
37
 
31
- onToggleMultiPage = (checked: boolean) => {
38
+ onChangeDisplay = (value: PDFDisplay) => {
32
39
  const {element} = this.props;
33
- element.setSetting('multiPage', checked, () => {
34
- this.setState({multiPage: checked});
40
+ element.setSetting('display', value, () => {
41
+ this.setState({display: value});
35
42
  })
36
- };
43
+ }
37
44
 
38
45
  onToggleAlignment = (type: IconButtonType) => () => {
39
46
  const {alignment} = this.state, {element} = this.props;
@@ -50,12 +57,12 @@ export default class PdfImageSettings extends PureComponent<Props, State> {
50
57
  }
51
58
 
52
59
  render = () => {
53
- const {element, supportMultiPage} = this.props, {alignment, multiPage} = this.state;
60
+ const {element, supportMultiPage} = this.props, {alignment, display} = this.state;
54
61
  return (
55
62
  <div className='pdf-image-settings'>
56
63
  {supportMultiPage && <>
57
64
  <label className='settings-title'>Pagina's</label>
58
- <Checkbox checked={multiPage} onCheck={this.onToggleMultiPage} label={'Toon op alle pagina\'s'}/>
65
+ <DvrdSelect onChange={this.onChangeDisplay} value={display} items={displayItems}/>
59
66
  </>}
60
67
  <div className='divider'/>
61
68
  <label className='settings-title'>Uitlijning</label>
@@ -5,8 +5,16 @@ import './style/pdfTextSettings.scss';
5
5
 
6
6
  import React, {PureComponent} from 'react';
7
7
  import PdfText from "../../text/pdfText";
8
- import {ElementPosition, IndexedObject, PdfFont, PDFTextParams, PDFTextVariables} from "../../../util/interfaces";
9
- import {Checkbox, ColorPicker, fontItems, getPdfVariables, NumberField, Select} from "../../../../../index";
8
+ import {
9
+ ElementPosition,
10
+ IndexedObject,
11
+ PDFDisplay,
12
+ PdfFont,
13
+ PDFTextParams,
14
+ PDFTextVariables,
15
+ SelectItemShape
16
+ } from "../../../util/interfaces";
17
+ import {ColorPicker, DvrdSelect, fontItems, getPdfVariables, NumberField, Select} from "../../../../../index";
10
18
  import classNames from 'classnames';
11
19
  import IconButton, {IconButtonType} from "../buttons/iconButton";
12
20
 
@@ -25,9 +33,15 @@ interface State extends IndexedObject<any> {
25
33
  font: PdfFont;
26
34
  color: string;
27
35
  colorPickerActive: boolean;
28
- multiPage: boolean;
36
+ display: PDFDisplay;
29
37
  }
30
38
 
39
+ const displayItems: SelectItemShape[] = [
40
+ {value: PDFDisplay.ALL_PAGES, label: 'Alle pagina\'s'},
41
+ {value: PDFDisplay.FIRST_PAGE, label: 'Alleen eerste pagina'},
42
+ {value: PDFDisplay.LAST_PAGE, label: 'Alleen laatste pagina'},
43
+ ]
44
+
31
45
  export default class PdfTextSettings extends PureComponent<Props, State> {
32
46
  constructor(props: Props) {
33
47
  super(props);
@@ -41,16 +55,16 @@ export default class PdfTextSettings extends PureComponent<Props, State> {
41
55
  font: settings.font,
42
56
  color: settings.color,
43
57
  colorPickerActive: false,
44
- multiPage: settings.multiPage ?? false,
58
+ display: settings.display ?? PDFDisplay.ALL_PAGES,
45
59
  };
46
60
  }
47
61
 
48
- onToggleMultiPage = (checked: boolean) => {
62
+ onChangeDisplay = (value: PDFDisplay) => {
49
63
  const {element} = this.props;
50
- element.setSetting('multiPage', checked, () => {
51
- this.setState({multiPage: checked});
64
+ element.setSetting('display', value, () => {
65
+ this.setState({display: value});
52
66
  })
53
- };
67
+ }
54
68
 
55
69
  onCloseColorPicker = () => {
56
70
  this.setState({colorPickerActive: false});
@@ -136,13 +150,13 @@ export default class PdfTextSettings extends PureComponent<Props, State> {
136
150
 
137
151
  render = () => {
138
152
  const {element, supportMultiPage} = this.props,
139
- {bold, underline, italic, alignment, colorPickerActive, color, multiPage} = this.state,
153
+ {bold, underline, italic, alignment, colorPickerActive, color, display} = this.state,
140
154
  settings: PDFTextParams = element.getSettings();
141
155
  return (
142
156
  <div className='pdf-text-settings'>
143
157
  {supportMultiPage && <>
144
- <label className='settings-title'>Pagina's</label>
145
- <Checkbox checked={multiPage} onCheck={this.onToggleMultiPage} label={'Toon op alle pagina\'s'}/>
158
+ <label className='settings-title'>Weergave</label>
159
+ <DvrdSelect onChange={this.onChangeDisplay} value={display} items={displayItems}/>
146
160
  </>}
147
161
  <div className='divider'/>
148
162
  <div className='text-settings'>
@@ -5,7 +5,14 @@ import './style/pdfText.scss';
5
5
 
6
6
  import React, {CSSProperties, MouseEventHandler} from 'react';
7
7
  import {
8
- CustomAppEvent, IndexedObject, PDFElementParams, PDFElementPersist, PDFElementType, PdfFont, PDFTextParams,
8
+ CustomAppEvent,
9
+ IndexedObject,
10
+ PDFDisplay,
11
+ PDFElementParams,
12
+ PDFElementPersist,
13
+ PDFElementType,
14
+ PdfFont,
15
+ PDFTextParams,
9
16
  PDFTextVariables
10
17
  } from "../../util/interfaces";
11
18
  import {PDFDraggable, PdfElement} from "../element/pdfElement";
@@ -14,7 +21,7 @@ import {merge} from 'lodash';
14
21
  import {PAGE_WIDTH, pxToPt, setPdfVariables, waitForFonts} from "../../util/pdfUtil";
15
22
  import {directTimeout} from "../../util/componentUtil";
16
23
  import {dispatchCustomEvent, showDialog} from "../../util/eventUtil";
17
- import {WithEvents, remToPx} from "../../../../";
24
+ import {remToPx, WithEvents} from "../../../../";
18
25
 
19
26
  interface Props {
20
27
  onDelete: MouseEventHandler;
@@ -60,7 +67,7 @@ export default class PdfText extends PdfElement<Props, State> {
60
67
  font: props.mainFont,
61
68
  color: '#000',
62
69
  persistent: PDFElementPersist.NOT_PERSISTENT,
63
- multiPage: false,
70
+ display: PDFDisplay.ALL_PAGES,
64
71
  }, props.defaultSettings),
65
72
  dragging: false,
66
73
  focused: false,
@@ -182,13 +189,13 @@ export default class PdfText extends PdfElement<Props, State> {
182
189
 
183
190
  getParams = (convertPixels: boolean = true): PDFElementParams<PDFElementType.TEXT, PDFTextParams> => {
184
191
  const {settings} = this.state,
185
- {bold, italic, text, underline, alignment, font, color, persistent, multiPage} = settings,
192
+ {bold, italic, text, underline, alignment, font, color, persistent, display} = settings,
186
193
  fontSize = convertPixels ? pxToPt(settings.fontSize) : settings.fontSize, {linkedID} = this.props;
187
194
  return {
188
195
  dimensions: this.getDimensions(convertPixels),
189
196
  key: this.id,
190
197
  type: PDFElementType.TEXT,
191
- options: {fontSize: fontSize, bold, italic, text, underline, alignment, font, color, persistent, multiPage},
198
+ options: {fontSize: fontSize, bold, italic, text, underline, alignment, font, color, persistent, display},
192
199
  linkedID: linkedID,
193
200
  };
194
201
  }
@@ -91,15 +91,25 @@ export enum PDFElementSubType {INVOICE_TITLE = 'invoice_title'}
91
91
  export enum PDFElementPersist {CONFIRM = 'confirm', PERSISTENT = 'persistent', NOT_PERSISTENT = 'not-persistent'}
92
92
 
93
93
  export enum PdfFont {
94
- LATO = 'lato', MERRIWEATHER = 'merriweather', NOTO_SANS = 'noto-sans', NOTO_SERIF = 'noto-serif',
95
- OPEN_SANS = 'open-sans', PLAYFAIR = 'playfair', PT_SERIF = 'pt-serif', ROBOTO = 'roboto', ROBOTO_MONO = 'roboto-mono',
96
- HELVETICA = 'helvetica', SOURCE_SANS_PRO = 'source-sans-pro'
94
+ LATO = 'lato',
95
+ MERRIWEATHER = 'merriweather',
96
+ NOTO_SANS = 'noto-sans',
97
+ NOTO_SERIF = 'noto-serif',
98
+ OPEN_SANS = 'open-sans',
99
+ PLAYFAIR = 'playfair',
100
+ PT_SERIF = 'pt-serif',
101
+ ROBOTO = 'roboto',
102
+ ROBOTO_MONO = 'roboto-mono',
103
+ HELVETICA = 'helvetica',
104
+ SOURCE_SANS_PRO = 'source-sans-pro'
97
105
  }
98
106
 
99
107
  export enum MediaType {VIDEO, IMAGE}
100
108
 
101
109
  export enum SideMenuMode {COMPACT, FULL}
102
110
 
111
+ export enum PDFDisplay {FIRST_PAGE = 'first_page', LAST_PAGE = 'last_page', ALL_PAGES = 'all_pages'}
112
+
103
113
  // =========== TYPES
104
114
  export type OptionsMenuItem = {
105
115
  label: string;
@@ -139,8 +149,8 @@ export type DefaultPDFElementParams<T extends PDFElementType, O extends IndexedO
139
149
  key: string;
140
150
  linkedID?: string;
141
151
  }>
142
- export type PDFImageParams = { img: File | string | null, persistent: PDFElementPersist; alignment?: ElementPosition; multiPage?: boolean };
143
- export type PDFTextParams = { bold: boolean; underline: boolean; italic: boolean; fontSize: number; text: string; alignment?: ElementPosition; disabled?: boolean, font: PdfFont, color: string; persistent: PDFElementPersist; multiPage?: boolean };
152
+ export type PDFImageParams = { img: File | string | null, persistent: PDFElementPersist; alignment?: ElementPosition; display?: PDFDisplay };
153
+ 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 };
144
154
  export type PDFInvoiceTableParams = { fontSize: number; widths: number[], font: PdfFont, color: string, alignment?: ElementPosition; persistent: PDFElementPersist };
145
155
  export type PDFInvoiceWidths = { name: number; price: number; quantity: number; subtotal: number }
146
156
  export type PDFTextVariables = { company: IndexedObject<string>; client: IndexedObject<string>; invoice: IndexedObject<string>; }