@dvrd/dvr-controls 1.1.31 → 1.1.33
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 +0 -2
- package/package.json +5 -1
- package/src/js/pdf/element/pdfElement.tsx +2 -2
- package/src/js/pdf/image/pdfImage.tsx +2 -2
- package/src/js/pdf/pdfTemplateCreator.tsx +7 -8
- package/src/js/pdf/settings/text/pdfTextSettings.tsx +3 -9
- package/src/js/pdf/text/pdfText.tsx +1 -2
- package/src/js/util/interfaces.ts +6 -10
- package/src/js/util/miscUtil.ts +2 -3
- package/src/js/util/pdfUtil.ts +2 -2
package/index.ts
CHANGED
|
@@ -59,7 +59,6 @@ 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';
|
|
63
62
|
|
|
64
63
|
export {
|
|
65
64
|
// Components
|
|
@@ -113,7 +112,6 @@ export {
|
|
|
113
112
|
MobileNavigation,
|
|
114
113
|
|
|
115
114
|
// Interfaces / Enums
|
|
116
|
-
DialogActionShape,
|
|
117
115
|
LabelType,
|
|
118
116
|
BreakType,
|
|
119
117
|
HeaderItem,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvrd/dvr-controls",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.33",
|
|
4
4
|
"description": "Custom web controls",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"files": [
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"author": "Dave van Rijn",
|
|
14
14
|
"license": "ISC",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "yarn typecheck && npm publish",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
15
19
|
"browserslist": {
|
|
16
20
|
"production": [
|
|
17
21
|
">0.2%",
|
|
@@ -6,7 +6,7 @@ import './style/pdfElement.scss';
|
|
|
6
6
|
import React, {MouseEventHandler, PropsWithChildren, PureComponent} from 'react';
|
|
7
7
|
import {DraggableData, HandleClasses, HandleStyles, ResizeEnable, Rnd} from 'react-rnd';
|
|
8
8
|
import {
|
|
9
|
-
CustomAppEvent, ElementPosition,
|
|
9
|
+
CustomAppEvent, ElementPosition, PDFElementDimensions, PDFElementParams, PDFElementPersist, PdfFont,
|
|
10
10
|
RNDDimensions
|
|
11
11
|
} from "../../util/interfaces";
|
|
12
12
|
import {generateComponentId} from "../../util/componentUtil";
|
|
@@ -17,7 +17,7 @@ import NumberString from "../../util/numberString";
|
|
|
17
17
|
|
|
18
18
|
interface State {
|
|
19
19
|
dragging: boolean;
|
|
20
|
-
settings:
|
|
20
|
+
settings: Record<string, any>;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
interface SharedProps {
|
|
@@ -5,7 +5,7 @@ import './style/pdfImage.scss';
|
|
|
5
5
|
|
|
6
6
|
import React, {MouseEventHandler} from 'react';
|
|
7
7
|
import {
|
|
8
|
-
ElementPosition,
|
|
8
|
+
ElementPosition, 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";
|
|
@@ -14,7 +14,7 @@ import {AwesomeIcon, directTimeout, PAGE_HEIGHT, PAGE_WIDTH} from "../../../../i
|
|
|
14
14
|
interface Props {
|
|
15
15
|
onDelete: MouseEventHandler;
|
|
16
16
|
onSaveHistory: VoidFunction;
|
|
17
|
-
values:
|
|
17
|
+
values: Record<string, string>;
|
|
18
18
|
defaultSettings?: Partial<PDFImageParams>;
|
|
19
19
|
id?: string;
|
|
20
20
|
defaultPosition: { x: number; y: number };
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
dispatchCustomEvent,
|
|
12
12
|
DvrdButton,
|
|
13
13
|
generateUUID,
|
|
14
|
-
IndexedObject,
|
|
15
14
|
PDFElementParams,
|
|
16
15
|
PDFElementPersist,
|
|
17
16
|
PDFElementType,
|
|
@@ -37,7 +36,7 @@ interface Props {
|
|
|
37
36
|
onPreview?: PDFSubmitHandler;
|
|
38
37
|
onSubmit: PDFSubmitHandler;
|
|
39
38
|
onChangeFont: (font: PdfFont, callback?: VoidFunction) => void;
|
|
40
|
-
values:
|
|
39
|
+
values: Record<string, string>;
|
|
41
40
|
defaultItems?: DefaultPDFElementParams<any, any>[];
|
|
42
41
|
resetItems: DefaultPDFElementParams<any, any>[];
|
|
43
42
|
customVariables?: PDFTextVariables;
|
|
@@ -53,7 +52,7 @@ interface Props {
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
interface State {
|
|
56
|
-
elements:
|
|
55
|
+
elements: Record<string, { element: React.ReactElement, config: DefaultPDFElementParams<any, any> }>;
|
|
57
56
|
focusedElement: PdfElement | null;
|
|
58
57
|
canUndo: boolean;
|
|
59
58
|
canRedo: boolean;
|
|
@@ -66,12 +65,12 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
66
65
|
supportMultiPage: false,
|
|
67
66
|
singleImage: false,
|
|
68
67
|
};
|
|
69
|
-
private refObjects:
|
|
68
|
+
private refObjects: Record<string, PdfElement>;
|
|
70
69
|
|
|
71
70
|
constructor(props: Props) {
|
|
72
71
|
super(props);
|
|
73
72
|
this.refObjects = {};
|
|
74
|
-
const elements:
|
|
73
|
+
const elements: Record<string, {
|
|
75
74
|
element: React.ReactElement,
|
|
76
75
|
config: DefaultPDFElementParams<any, any>
|
|
77
76
|
}> = this.processItems(props.defaultItems);
|
|
@@ -79,7 +78,7 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
reloadTemplate(items: DefaultPDFElementParams<any, any>[]) {
|
|
82
|
-
const elements:
|
|
81
|
+
const elements: Record<string, {
|
|
83
82
|
element: React.ReactElement,
|
|
84
83
|
config: DefaultPDFElementParams<any, any>
|
|
85
84
|
}> = this.processItems(items);
|
|
@@ -87,11 +86,11 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
processItems = (items?: DefaultPDFElementParams<any, any>[],
|
|
90
|
-
convertUnits: boolean = true):
|
|
89
|
+
convertUnits: boolean = true): Record<string, {
|
|
91
90
|
element: React.ReactElement,
|
|
92
91
|
config: DefaultPDFElementParams<any, any>
|
|
93
92
|
}> => {
|
|
94
|
-
const elements:
|
|
93
|
+
const elements: Record<string, { element: React.ReactElement, config: DefaultPDFElementParams<any, any> }> = {};
|
|
95
94
|
if (items?.length) {
|
|
96
95
|
items = JSON.parse(JSON.stringify(items));
|
|
97
96
|
if (items) {
|
|
@@ -6,13 +6,7 @@ import './style/pdfTextSettings.scss';
|
|
|
6
6
|
import React, {PureComponent} from 'react';
|
|
7
7
|
import PdfText from "../../text/pdfText";
|
|
8
8
|
import {
|
|
9
|
-
ElementPosition,
|
|
10
|
-
IndexedObject,
|
|
11
|
-
PDFDisplay,
|
|
12
|
-
PdfFont,
|
|
13
|
-
PDFTextParams,
|
|
14
|
-
PDFTextVariables,
|
|
15
|
-
SelectItemShape
|
|
9
|
+
ElementPosition, PDFDisplay, PdfFont, PDFTextParams, PDFTextVariables, SelectItemShape
|
|
16
10
|
} from "../../../util/interfaces";
|
|
17
11
|
import {ColorPicker, DVRDNumberInput, DvrdSelect, fontItems, getPdfVariables} from "../../../../../index";
|
|
18
12
|
import classNames from 'classnames';
|
|
@@ -24,7 +18,7 @@ interface Props {
|
|
|
24
18
|
supportMultiPage: boolean;
|
|
25
19
|
}
|
|
26
20
|
|
|
27
|
-
interface State extends
|
|
21
|
+
interface State extends Record<string, any> {
|
|
28
22
|
openVariables: keyof PDFTextVariables;
|
|
29
23
|
bold: boolean;
|
|
30
24
|
underline: boolean;
|
|
@@ -134,7 +128,7 @@ export default class PdfTextSettings extends PureComponent<Props, State> {
|
|
|
134
128
|
)
|
|
135
129
|
};
|
|
136
130
|
|
|
137
|
-
renderVariables = (type: keyof PDFTextVariables, title: string, variables:
|
|
131
|
+
renderVariables = (type: keyof PDFTextVariables, title: string, variables: Record<string, string>) => (
|
|
138
132
|
<div className={classNames('variables-container', this.state.openVariables === type && 'open')}>
|
|
139
133
|
<label className='variables-title' onClick={this.onClickVariablesTitle(type)}>{title}</label>
|
|
140
134
|
<div className='variables-main-container'>
|
|
@@ -6,7 +6,6 @@ import './style/pdfText.scss';
|
|
|
6
6
|
import React, {CSSProperties, MouseEventHandler} from 'react';
|
|
7
7
|
import {
|
|
8
8
|
CustomAppEvent,
|
|
9
|
-
IndexedObject,
|
|
10
9
|
PDFDisplay,
|
|
11
10
|
PDFElementParams,
|
|
12
11
|
PDFElementPersist,
|
|
@@ -25,7 +24,7 @@ import {remToPx, WithEvents} from "../../../../";
|
|
|
25
24
|
interface Props {
|
|
26
25
|
onDelete: MouseEventHandler;
|
|
27
26
|
onSaveHistory: VoidFunction;
|
|
28
|
-
values:
|
|
27
|
+
values: Record<string, string>;
|
|
29
28
|
defaultSettings?: Partial<PDFTextParams>;
|
|
30
29
|
id?: string;
|
|
31
30
|
customVariables?: PDFTextVariables;
|
|
@@ -36,10 +36,6 @@ export interface PasswordRule {
|
|
|
36
36
|
validator: (password: string) => boolean;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export interface IndexedObject<T> {
|
|
40
|
-
[key: string]: T;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
39
|
export interface ColorSet {
|
|
44
40
|
base: string;
|
|
45
41
|
contrast: string;
|
|
@@ -51,7 +47,7 @@ export interface OrnamentShape {
|
|
|
51
47
|
allowPropagation?: boolean;
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
export interface ResponseData extends
|
|
50
|
+
export interface ResponseData extends Record<string, any> {
|
|
55
51
|
status: string;
|
|
56
52
|
message?: string;
|
|
57
53
|
success?: boolean;
|
|
@@ -197,7 +193,7 @@ export type ModelResponse<T> = (obj: T, success: boolean | undefined, data: Resp
|
|
|
197
193
|
export type StrengthGauge = {validator: (password: string) => boolean};
|
|
198
194
|
export type PDFSetting = {key: string; label: string; type: PDFSettingType; value: any};
|
|
199
195
|
|
|
200
|
-
export type PDFElementParams<T extends PDFElementType, O extends
|
|
196
|
+
export type PDFElementParams<T extends PDFElementType, O extends Record<string, any>> = {
|
|
201
197
|
key: string;
|
|
202
198
|
type: T;
|
|
203
199
|
sub_type?: PDFElementSubType | null;
|
|
@@ -206,7 +202,7 @@ export type PDFElementParams<T extends PDFElementType, O extends IndexedObject<a
|
|
|
206
202
|
persistent?: PDFElementPersist;
|
|
207
203
|
linkedID?: string;
|
|
208
204
|
}
|
|
209
|
-
export type DefaultPDFElementParams<T extends PDFElementType, O extends
|
|
205
|
+
export type DefaultPDFElementParams<T extends PDFElementType, O extends Record<string, any>> = Partial<{
|
|
210
206
|
type: T;
|
|
211
207
|
dimensions: Partial<{left: number; top: number; width: number; height: number}>;
|
|
212
208
|
options: O;
|
|
@@ -246,9 +242,9 @@ export type PDFInvoiceTableParams = {
|
|
|
246
242
|
};
|
|
247
243
|
export type PDFInvoiceWidths = {name: number; price: number; quantity: number; subtotal: number}
|
|
248
244
|
export type PDFTextVariables = {
|
|
249
|
-
company:
|
|
250
|
-
client:
|
|
251
|
-
invoice:
|
|
245
|
+
company: Record<string, string>;
|
|
246
|
+
client: Record<string, string>;
|
|
247
|
+
invoice: Record<string, string>;
|
|
252
248
|
}
|
|
253
249
|
export type PDFSubmitHandler = (items: PDFElementParams<any, any>[], callback?: VoidFunction) => void;
|
|
254
250
|
export type PDFElementDimensions = {left: number; top: number; width: number; height: number};
|
package/src/js/util/miscUtil.ts
CHANGED
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import DOMPurify from 'dompurify';
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import {IndexedObject} from './interfaces';
|
|
8
7
|
|
|
9
8
|
declare global {
|
|
10
9
|
// noinspection JSUnusedGlobalSymbols
|
|
11
10
|
interface Window {
|
|
12
11
|
log: Function;
|
|
13
|
-
settings:
|
|
12
|
+
settings: Record<string, any>;
|
|
14
13
|
allowCookies: boolean;
|
|
15
14
|
gtag?: Function;
|
|
16
15
|
gapi?: any;
|
|
@@ -18,7 +17,7 @@ declare global {
|
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
export const getSetting = (name: string): any => {
|
|
21
|
-
const settings:
|
|
20
|
+
const settings: Record<string, any> = window.settings;
|
|
22
21
|
if (settings.hasOwnProperty(name))
|
|
23
22
|
return settings[name];
|
|
24
23
|
console.warn(`Global settings does not contain a value for '${name}'`);
|
package/src/js/util/pdfUtil.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2024. Dave van Rijn Development
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {DefaultPDFElementParams,
|
|
5
|
+
import {DefaultPDFElementParams, PdfFont, PDFTextVariables, SelectItemShape} from "./interfaces";
|
|
6
6
|
|
|
7
7
|
export const mmToPt = (mm: number) => Math.round(pxToPt(mmToPx(mm)));
|
|
8
8
|
export const mmToPx = (mm: number, toTens: boolean = true) => {
|
|
@@ -70,7 +70,7 @@ export const getPdfVariables = (customVariables?: PDFTextVariables): PDFTextVari
|
|
|
70
70
|
return variables;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export const setPdfVariables = (text: string, values:
|
|
73
|
+
export const setPdfVariables = (text: string, values: Record<string, string>) => {
|
|
74
74
|
for (const key of Object.keys(values)) {
|
|
75
75
|
const value = values[key];
|
|
76
76
|
if (text.includes(`{${key}}`) && value.length) text =
|