@dvrd/dvr-controls 1.0.30 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dvrd/dvr-controls",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "Custom web controls",
5
5
  "main": "index.ts",
6
6
  "files": [
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import './style/pdfTemplateCreator.scss';
5
5
 
6
- import React, {Fragment, PureComponent} from 'react';
6
+ import React, {Fragment, PureComponent, ReactElement} from 'react';
7
7
  import {
8
8
  AwesomeIcon,
9
9
  DefaultPDFElementParams,
@@ -48,6 +48,7 @@ interface Props {
48
48
  supportMultiPage: boolean;
49
49
  options?: PDFOptions;
50
50
  singleImage: boolean;
51
+ headerButtons?: Array<ReactElement>;
51
52
  }
52
53
 
53
54
  interface State {
@@ -69,12 +70,18 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
69
70
  constructor(props: Props) {
70
71
  super(props);
71
72
  this.refObjects = {};
72
- const elements: IndexedObject<{ element: React.ReactElement, config: DefaultPDFElementParams<any, any> }> = this.processItems(props.defaultItems);
73
+ const elements: IndexedObject<{
74
+ element: React.ReactElement,
75
+ config: DefaultPDFElementParams<any, any>
76
+ }> = this.processItems(props.defaultItems);
73
77
  this.state = {elements, focusedElement: null, canRedo: false, canUndo: false};
74
78
  }
75
79
 
76
80
  processItems = (items?: DefaultPDFElementParams<any, any>[],
77
- convertUnits: boolean = true): IndexedObject<{ element: React.ReactElement, config: DefaultPDFElementParams<any, any> }> => {
81
+ convertUnits: boolean = true): IndexedObject<{
82
+ element: React.ReactElement,
83
+ config: DefaultPDFElementParams<any, any>
84
+ }> => {
78
85
  const elements: IndexedObject<{ element: React.ReactElement, config: DefaultPDFElementParams<any, any> }> = {};
79
86
  if (items?.length) {
80
87
  items = JSON.parse(JSON.stringify(items));
@@ -185,7 +192,10 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
185
192
  };
186
193
 
187
194
  getElement = (id: string, config: DefaultPDFElementParams<any, any>,
188
- convertUnits: boolean = true): { element: React.ReactElement, config: DefaultPDFElementParams<any, any> } => {
195
+ convertUnits: boolean = true): {
196
+ element: React.ReactElement,
197
+ config: DefaultPDFElementParams<any, any>
198
+ } => {
189
199
  const {dimensions, linkedID, persistent} = config;
190
200
  const position: { x: number; y: number } = {
191
201
  x: convertUnits ? ptToPx(dimensions?.left || 0) : (dimensions?.left || 0),
@@ -267,7 +277,10 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
267
277
  <div className='pdf-creator' onClick={this.onResetElement}
268
278
  style={{maxWidth: maxWidth ?? '100%'}}>
269
279
  <div className='footer-container'>
270
- {onPreview !== undefined ? <DvrdButton onClick={this.onPreview} label='Voorbeeld'/> : <div/>}
280
+ <div className='left-buttons'>
281
+ {onPreview !== undefined ? <DvrdButton onClick={this.onPreview} label='Voorbeeld'/> : <div/>}
282
+ {this.props.headerButtons?.map((el: ReactElement, index: number) => React.cloneElement(el, {key: index}))}
283
+ </div>
271
284
  <div>
272
285
  <DvrdButton onClick={this.onSubmit} label='Opslaan'/>
273
286
  {onClickProceed !== undefined &&
@@ -111,6 +111,14 @@
111
111
  justify-content: space-between;
112
112
  align-items: center;
113
113
 
114
+ .left-buttons {
115
+ flex: 1;
116
+ display: grid;
117
+ grid-auto-flow: column;
118
+ grid-auto-columns: fit-content(100%);
119
+ grid-column-gap: 1rem;
120
+ }
121
+
114
122
  .proceed-btn {
115
123
  margin-left: 1rem;
116
124
  }