@dvrd/dvr-controls 1.0.6 → 1.0.9
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/button/button.tsx +0 -102
- package/src/js/button/buttonController.tsx +0 -179
- package/src/js/button/closeButton.tsx +0 -29
- package/src/js/button/dvrdButton.tsx +0 -128
- package/src/js/button/outlinedButton.tsx +0 -105
- package/src/js/button/simpleButton.tsx +0 -163
- package/src/js/button/style/button.scss +0 -95
- package/src/js/button/style/closeButton.scss +0 -15
- package/src/js/button/style/dvrdButton.scss +0 -30
- package/src/js/button/style/outlinedButton.scss +0 -84
- package/src/js/button/style/simpleButton.scss +0 -80
- package/src/js/carousel/DVRCarousel.tsx +0 -163
- package/src/js/carousel/DVRCarouselController.tsx +0 -95
- package/src/js/carousel/style/DVRCarousel.scss +0 -38
- package/src/js/checkbox/checkbox.tsx +0 -147
- package/src/js/checkbox/checkboxController.tsx +0 -131
- package/src/js/checkbox/style/checkbox.scss +0 -109
- package/src/js/colorPicker/colorPicker.tsx +0 -118
- package/src/js/colorPicker/style/colorPicker.scss +0 -20
- package/src/js/date/dvrdDatePicker.tsx +0 -357
- package/src/js/date/style/dvrdDatePicker.scss +0 -307
- package/src/js/dialog/dialog.tsx +0 -207
- package/src/js/dialog/dialogController.tsx +0 -70
- package/src/js/dialog/inlineDialog.tsx +0 -127
- package/src/js/dialog/style/dialog.scss +0 -61
- package/src/js/events/withEvents.tsx +0 -40
- package/src/js/head/DVRHead.tsx +0 -49
- package/src/js/header/DVRHeader.tsx +0 -413
- package/src/js/header/style/header.scss +0 -206
- package/src/js/icon/awesomeIcon.tsx +0 -46
- package/src/js/image/imageUpload.tsx +0 -69
- package/src/js/image/style/imageUpload.scss +0 -11
- package/src/js/info/info.tsx +0 -136
- package/src/js/info/style/info.scss +0 -39
- package/src/js/input/animated/animatedTextField.tsx +0 -159
- package/src/js/input/date/dateField.tsx +0 -360
- package/src/js/input/date/dateFieldController.tsx +0 -245
- package/src/js/input/date/datePicker/datePicker.tsx +0 -186
- package/src/js/input/date/datePicker/style/datePicker.scss +0 -102
- package/src/js/input/date/input/dateInput.tsx +0 -213
- package/src/js/input/date/style/dateField.scss +0 -40
- package/src/js/input/date/timePicker/style/timePicker.scss +0 -95
- package/src/js/input/date/timePicker/timePicker.tsx +0 -143
- package/src/js/input/editor/DVREditor.tsx +0 -21
- package/src/js/input/number/numberInput.tsx +0 -157
- package/src/js/input/password/passwordInput.tsx +0 -140
- package/src/js/input/password/passwordRules.tsx +0 -48
- package/src/js/input/password/style/passwordInput.scss +0 -39
- package/src/js/input/password/style/passwordRules.scss +0 -41
- package/src/js/input/simple/style/simpleInput.scss +0 -98
- package/src/js/input/simple/v2/simpleInputV2.tsx +0 -178
- package/src/js/input/style/input.scss +0 -138
- package/src/js/input/v2/inputController_v2.tsx +0 -250
- package/src/js/input/v2/input_v2.tsx +0 -7
- package/src/js/label/label.tsx +0 -196
- package/src/js/label/style/label.scss +0 -4
- package/src/js/link/link.tsx +0 -38
- package/src/js/link/style/link.scss +0 -30
- package/src/js/loader/loader.tsx +0 -79
- package/src/js/loader/loaderController.tsx +0 -61
- package/src/js/loader/style/loader.scss +0 -53
- package/src/js/media/media.tsx +0 -72
- package/src/js/navigator/navigator.tsx +0 -51
- package/src/js/optionsList/dvrdOptionsList.tsx +0 -112
- package/src/js/optionsList/style/dvrdOptionsList.scss +0 -84
- package/src/js/optionsMenu/optionsMenu.tsx +0 -187
- package/src/js/optionsMenu/style/optionsMenu.scss +0 -70
- package/src/js/pdf/element/pdfElement.tsx +0 -315
- package/src/js/pdf/element/style/pdfElement.scss +0 -111
- package/src/js/pdf/history/pdfHistory.ts +0 -57
- package/src/js/pdf/image/pdfImage.tsx +0 -175
- package/src/js/pdf/image/style/pdfImage.scss +0 -34
- package/src/js/pdf/invoiceTable/pdfInvoiceTable.tsx +0 -176
- package/src/js/pdf/invoiceTable/style/pdfInvoiceTable.scss +0 -32
- package/src/js/pdf/pdfTemplateCreator.tsx +0 -278
- package/src/js/pdf/settings/buttons/iconButton.tsx +0 -49
- package/src/js/pdf/settings/buttons/style/iconButton.scss +0 -50
- package/src/js/pdf/settings/image/pdfImageSettings.tsx +0 -82
- package/src/js/pdf/settings/image/style/pdfImageSettings.scss +0 -9
- package/src/js/pdf/settings/invoiceTable/pdfInvoiceTableSettings.tsx +0 -141
- package/src/js/pdf/settings/invoiceTable/style/pdfInvoiceTableSettings.scss +0 -38
- package/src/js/pdf/settings/pdfElementSettings.tsx +0 -86
- package/src/js/pdf/settings/style/pdfElementSettings.scss +0 -56
- package/src/js/pdf/settings/text/pdfTextSettings.tsx +0 -202
- package/src/js/pdf/settings/text/style/pdfTextSettings.scss +0 -94
- package/src/js/pdf/style/pdfTemplateCreator.scss +0 -118
- package/src/js/pdf/text/pdfText.tsx +0 -267
- package/src/js/pdf/text/style/pdfText.scss +0 -22
- package/src/js/popup/style/withBackground.scss +0 -29
- package/src/js/popup/withBackground.tsx +0 -102
- package/src/js/select/async/asyncSelect.tsx +0 -46
- package/src/js/select/async/style/asyncSelect.scss +0 -23
- package/src/js/select/dvrdSelect.tsx +0 -185
- package/src/js/select/dvrdSelectController.tsx +0 -81
- package/src/js/select/select.tsx +0 -310
- package/src/js/select/selectController.tsx +0 -341
- package/src/js/select/style/dvrdSelect.scss +0 -140
- package/src/js/select/style/select.scss +0 -199
- package/src/js/sidebarMenu/sidebarMenu.tsx +0 -165
- package/src/js/sidebarMenu/style/sidebarMenu.scss +0 -161
- package/src/js/slider/DVRSlider.tsx +0 -107
- package/src/js/slider/style/DVRSlider.scss +0 -88
- package/src/js/snackbar/snackbar.tsx +0 -72
- package/src/js/snackbar/snackbarController.tsx +0 -104
- package/src/js/snackbar/style/snackbar.scss +0 -46
- package/src/js/switch/dvrdSwitch.tsx +0 -53
- package/src/js/switch/style/dvrdSwitch.scss +0 -47
- package/src/js/switch/style/switch.scss +0 -84
- package/src/js/switch/switch.tsx +0 -115
- package/src/js/switch/switchController.tsx +0 -97
- package/src/js/textField/dvrdInput.tsx +0 -217
- package/src/js/textField/dvrdInputController.tsx +0 -97
- package/src/js/textField/dvrdNumberInput.tsx +0 -141
- package/src/js/textField/dvrdPasswordInput.tsx +0 -40
- package/src/js/textField/style/dvrdInput.scss +0 -114
- package/src/js/textField/style/dvrdPassword.scss +0 -15
- package/src/js/topButton/style/topButton.scss +0 -54
- package/src/js/topButton/topButton.tsx +0 -135
- package/src/js/util/analyticsUtil.ts +0 -41
- package/src/js/util/colorUtil.ts +0 -230
- package/src/js/util/componentUtil.tsx +0 -59
- package/src/js/util/constants.ts +0 -12
- package/src/js/util/controlContext.tsx +0 -46
- package/src/js/util/controlUtil.ts +0 -107
- package/src/js/util/cookieUtil.ts +0 -17
- package/src/js/util/eventUtil.ts +0 -65
- package/src/js/util/googleUtil.ts +0 -88
- package/src/js/util/interfaces.ts +0 -179
- package/src/js/util/jwtUtil.ts +0 -72
- package/src/js/util/miscUtil.ts +0 -170
- package/src/js/util/momentUtil.ts +0 -45
- package/src/js/util/pdfUtil.ts +0 -124
- package/src/js/util/requestUtil.ts +0 -145
- package/src/js/util/responsiveUtil.ts +0 -37
- package/src/js/util/validationUtil.ts +0 -13
- package/src/res/img/lock-handle.png +0 -0
- package/src/res/img/lock-handle.webp +0 -0
- package/src/res/img/lock.png +0 -0
- package/src/res/img/lock.webp +0 -0
- package/src/style/common-icons-variables.scss +0 -140
- package/src/style/common-icons.scss +0 -714
- package/src/style/common-variables.scss +0 -243
- package/src/style/display-breakpoints.scss +0 -141
- package/src/style/fonts/common-icons.eot +0 -0
- package/src/style/fonts/common-icons.svg +0 -150
- package/src/style/fonts/common-icons.ttf +0 -0
- package/src/style/fonts/common-icons.woff +0 -0
- package/src/style/fonts/common-icons.woff2 +0 -0
- package/src/style/fonts/fontAwesome/css/all.css +0 -7003
- package/src/style/fonts/fontAwesome/css/all.min.css +0 -6
- package/src/style/fonts/fontAwesome/css/brands.css +0 -1423
- package/src/style/fonts/fontAwesome/css/brands.min.css +0 -6
- package/src/style/fonts/fontAwesome/css/fontawesome.css +0 -5519
- package/src/style/fonts/fontAwesome/css/fontawesome.min.css +0 -6
- package/src/style/fonts/fontAwesome/css/regular.css +0 -19
- package/src/style/fonts/fontAwesome/css/regular.min.css +0 -6
- package/src/style/fonts/fontAwesome/css/solid.css +0 -19
- package/src/style/fonts/fontAwesome/css/solid.min.css +0 -6
- package/src/style/fonts/fontAwesome/css/svg-with-js.css +0 -634
- package/src/style/fonts/fontAwesome/css/svg-with-js.min.css +0 -6
- package/src/style/fonts/fontAwesome/css/v4-font-face.css +0 -26
- package/src/style/fonts/fontAwesome/css/v4-font-face.min.css +0 -6
- package/src/style/fonts/fontAwesome/css/v4-shims.css +0 -2146
- package/src/style/fonts/fontAwesome/css/v4-shims.min.css +0 -6
- package/src/style/fonts/fontAwesome/css/v5-font-face.css +0 -22
- package/src/style/fonts/fontAwesome/css/v5-font-face.min.css +0 -6
- package/src/style/fonts/fontAwesome/webfonts/fa-brands-400.ttf +0 -0
- package/src/style/fonts/fontAwesome/webfonts/fa-brands-400.woff2 +0 -0
- package/src/style/fonts/fontAwesome/webfonts/fa-regular-400.ttf +0 -0
- package/src/style/fonts/fontAwesome/webfonts/fa-regular-400.woff2 +0 -0
- package/src/style/fonts/fontAwesome/webfonts/fa-solid-900.ttf +0 -0
- package/src/style/fonts/fontAwesome/webfonts/fa-solid-900.woff2 +0 -0
- package/src/style/fonts/fontAwesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/src/style/fonts/fontAwesome/webfonts/fa-v4compatibility.woff2 +0 -0
- package/src/style/variables.scss +0 -11
- package/tsconfig.json +0 -15
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React, {CSSProperties} from 'react';
|
|
6
|
-
|
|
7
|
-
// =========== INTERFACES
|
|
8
|
-
|
|
9
|
-
export interface MenuItem {
|
|
10
|
-
label?: string;
|
|
11
|
-
component?: React.ReactNode;
|
|
12
|
-
subItems?: MenuItem[];
|
|
13
|
-
onClick?: Function;
|
|
14
|
-
normalCase?: boolean;
|
|
15
|
-
id?: string;
|
|
16
|
-
allowPropagation?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface PasswordRule {
|
|
20
|
-
label: string;
|
|
21
|
-
validator: (password: string) => boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface IndexedObject<T> {
|
|
25
|
-
[key: string]: T;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface ColorSet {
|
|
29
|
-
base: string;
|
|
30
|
-
contrast: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface OrnamentShape {
|
|
34
|
-
placement?: ElementPosition;
|
|
35
|
-
element: React.ReactElement | string;
|
|
36
|
-
allowPropagation?: boolean;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface ResponseData extends IndexedObject<any> {
|
|
40
|
-
status: string;
|
|
41
|
-
message?: string;
|
|
42
|
-
success?: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface SelectItemShape {
|
|
46
|
-
value: string | number,
|
|
47
|
-
label: string | number,
|
|
48
|
-
inputLabel?: string,
|
|
49
|
-
selectable?: boolean,
|
|
50
|
-
labelClass?: string;
|
|
51
|
-
labelStyle?: CSSProperties;
|
|
52
|
-
|
|
53
|
-
[key: string]: any,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface DialogConfig {
|
|
57
|
-
backgroundColor?: string;
|
|
58
|
-
textColor?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// =========== ENUMS
|
|
62
|
-
|
|
63
|
-
export enum ModeEnum {DETAIL = 'detail', EDIT = 'edit', NEW = 'new'}
|
|
64
|
-
|
|
65
|
-
export enum Breakpoint {XS = 0, SM = 600, MD = 960, LG = 1280, XL = 1920}
|
|
66
|
-
|
|
67
|
-
export enum MenuPlacement {TOP_LEFT, TOP_RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT}
|
|
68
|
-
|
|
69
|
-
export enum ColorPickerType {
|
|
70
|
-
SKETCH, PHOTOSHOP, CHROME, CIRCLE, TWITTER, BLOCK, COMPACT
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export enum ColorPickerResultType {HEX, RGB, HSL}
|
|
74
|
-
|
|
75
|
-
export enum ControlVariant {OUTLINED = 'outlined', STANDARD = 'standard', SIMPLE = 'simple'}
|
|
76
|
-
|
|
77
|
-
export enum ControlPadding {SMALL = 'sp', NORMAL = 'np', LARGE = 'lp'}
|
|
78
|
-
|
|
79
|
-
export enum ElementPosition {LEFT = 'left', RIGHT = 'right', TOP = 'top', BOTTOM = 'bottom', CENTER = 'center'}
|
|
80
|
-
|
|
81
|
-
export enum EventType {CREATE, UPDATE, DELETE}
|
|
82
|
-
|
|
83
|
-
export enum FetchMethod {GET = 'GET', POST = 'POST', PUT = 'PUT', DELETE = 'DELETE', PATCH = 'PATCH'}
|
|
84
|
-
|
|
85
|
-
export enum PDFSettingType {TEXT, IMAGE}
|
|
86
|
-
|
|
87
|
-
export enum PDFElementType {TEXT = 'text', IMAGE = 'image', INVOICE_TABLE = 'invoice_table'}
|
|
88
|
-
|
|
89
|
-
export enum PDFElementSubType {INVOICE_TITLE = 'invoice_title'}
|
|
90
|
-
|
|
91
|
-
export enum PDFElementPersist {CONFIRM = 'confirm', PERSISTENT = 'persistent', NOT_PERSISTENT = 'not-persistent'}
|
|
92
|
-
|
|
93
|
-
export enum PdfFont {
|
|
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'
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export enum MediaType {VIDEO, IMAGE}
|
|
108
|
-
|
|
109
|
-
export enum SideMenuMode {COMPACT, FULL}
|
|
110
|
-
|
|
111
|
-
export enum PDFDisplay {FIRST_PAGE = 'first_page', LAST_PAGE = 'last_page', ALL_PAGES = 'all_pages'}
|
|
112
|
-
|
|
113
|
-
// =========== TYPES
|
|
114
|
-
export type OptionsMenuItem = {
|
|
115
|
-
label: string;
|
|
116
|
-
icon?: React.ReactNode;
|
|
117
|
-
iconPlacement?: ElementPosition;
|
|
118
|
-
onClick?: Function;
|
|
119
|
-
disabled?: boolean;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export type ErrorType = string | null;
|
|
123
|
-
|
|
124
|
-
export type CustomAppEvent = {
|
|
125
|
-
eventName: string,
|
|
126
|
-
handler: Function,
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export type ChangeFunction<T = any> = (value: T, evt?: React.ChangeEvent) => void;
|
|
130
|
-
export type ChangeKeyFunction<T = any> = (key: T) => ChangeFunction<T>;
|
|
131
|
-
export type ModelResponse<T> = (obj: T, success: boolean | undefined, data: ResponseData) => void;
|
|
132
|
-
export type StrengthGauche = { validator: (password: string) => boolean };
|
|
133
|
-
export type PDFSetting = { key: string; label: string; type: PDFSettingType; value: any };
|
|
134
|
-
|
|
135
|
-
export type PDFElementParams<T extends PDFElementType, O extends IndexedObject<any>> = {
|
|
136
|
-
key: string;
|
|
137
|
-
type: T;
|
|
138
|
-
sub_type?: PDFElementSubType | null;
|
|
139
|
-
dimensions: { left: number; top: number; width: number; height: number };
|
|
140
|
-
options: O;
|
|
141
|
-
persistent?: PDFElementPersist;
|
|
142
|
-
linkedID?: string;
|
|
143
|
-
}
|
|
144
|
-
export type DefaultPDFElementParams<T extends PDFElementType, O extends IndexedObject<any>> = Partial<{
|
|
145
|
-
type: T;
|
|
146
|
-
dimensions: Partial<{ left: number; top: number; width: number; height: number }>;
|
|
147
|
-
options: O;
|
|
148
|
-
persistent?: PDFElementPersist;
|
|
149
|
-
key: string;
|
|
150
|
-
linkedID?: string;
|
|
151
|
-
}>
|
|
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 };
|
|
154
|
-
export type PDFInvoiceTableParams = { fontSize: number; widths: number[], font: PdfFont, color: string, alignment?: ElementPosition; persistent: PDFElementPersist };
|
|
155
|
-
export type PDFInvoiceWidths = { name: number; price: number; quantity: number; subtotal: number }
|
|
156
|
-
export type PDFTextVariables = { company: IndexedObject<string>; client: IndexedObject<string>; invoice: IndexedObject<string>; }
|
|
157
|
-
export type PDFSubmitHandler = (items: PDFElementParams<any, any>[], callback?: VoidFunction) => void;
|
|
158
|
-
export type PDFElementDimensions = { left: number; top: number; width: number; height: number };
|
|
159
|
-
|
|
160
|
-
export type SidebarItem = {
|
|
161
|
-
label: string; icon?: string | React.ReactNode;
|
|
162
|
-
className?: string;
|
|
163
|
-
id: string;
|
|
164
|
-
onBottom?: boolean;
|
|
165
|
-
route?: string | string[];
|
|
166
|
-
exactRoute?: boolean;
|
|
167
|
-
children?: SidebarItem[];
|
|
168
|
-
}
|
|
169
|
-
export type ResponseCallback = (data: ResponseData) => void;
|
|
170
|
-
export type RNDDimensions = { x: number, y: number, height: number, width: number };
|
|
171
|
-
export type HTMLVideoEvent = (evt: React.SyntheticEvent<HTMLVideoElement, Event>) => void;
|
|
172
|
-
export type RenderFile = {
|
|
173
|
-
filename: string;
|
|
174
|
-
src: string;
|
|
175
|
-
}
|
|
176
|
-
export type Snack = {
|
|
177
|
-
text: string | React.ReactElement;
|
|
178
|
-
config?: DialogConfig;
|
|
179
|
-
}
|
package/src/js/util/jwtUtil.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import Cookies, {CookieAttributes} from "js-cookie";
|
|
6
|
-
import {debug, getSetting} from "./miscUtil";
|
|
7
|
-
|
|
8
|
-
let jwtToken: string | null = null;
|
|
9
|
-
|
|
10
|
-
export const getJwt = (): string | null => {
|
|
11
|
-
if (jwtToken && jwtToken.length) return jwtToken;
|
|
12
|
-
|
|
13
|
-
const jwt = getJwtFromStorage();
|
|
14
|
-
if (jwt && jwt.length) return jwt;
|
|
15
|
-
|
|
16
|
-
const cookieJwt = Cookies.get('JWT');
|
|
17
|
-
if (cookieJwt && cookieJwt.length)
|
|
18
|
-
return cookieJwt;
|
|
19
|
-
return null;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const setJwt = (token: string | null, preserveOnNull: boolean = false, includeStorage: boolean = true) => {
|
|
23
|
-
jwtToken = token;
|
|
24
|
-
if (window.allowCookies || !token) {
|
|
25
|
-
if (token) {
|
|
26
|
-
let options: CookieAttributes = {expires: 1, sameSite: 'strict'};
|
|
27
|
-
if (getSetting('mode') !== 'dev') {
|
|
28
|
-
options.secure = true;
|
|
29
|
-
options.sameSite = 'strict';
|
|
30
|
-
}
|
|
31
|
-
Cookies.set('JWT', token, options);
|
|
32
|
-
} else if (!preserveOnNull) removeJwtCookie();
|
|
33
|
-
if (includeStorage)
|
|
34
|
-
setJwtToStorage(token, preserveOnNull);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const setJwtToStorage = (token: string | null, preserveOnNull: boolean = false) => {
|
|
39
|
-
if ((token === null || token === undefined) && !preserveOnNull) removeJwtFromStorage();
|
|
40
|
-
else if (token !== null && token !== undefined) {
|
|
41
|
-
try {
|
|
42
|
-
if (window.localStorage)
|
|
43
|
-
window.localStorage.setItem('JWT', JSON.stringify(token));
|
|
44
|
-
} catch {
|
|
45
|
-
// Localstorage not supported
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const removeJwtFromStorage = () => {
|
|
51
|
-
try {
|
|
52
|
-
if (window.localStorage)
|
|
53
|
-
window.localStorage.removeItem('JWT');
|
|
54
|
-
} catch {
|
|
55
|
-
// Localstorage not supported
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const removeJwtCookie = () => {
|
|
60
|
-
Cookies.remove('JWT');
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const getJwtFromStorage = (): string | null => {
|
|
64
|
-
try {
|
|
65
|
-
if (window.localStorage) {
|
|
66
|
-
const item: string | null = window.localStorage.getItem('JWT');
|
|
67
|
-
if (item === null) return null;
|
|
68
|
-
return JSON.parse(item);
|
|
69
|
-
}
|
|
70
|
-
} catch {}
|
|
71
|
-
return null;
|
|
72
|
-
};
|
package/src/js/util/miscUtil.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {IndexedObject} from "./interfaces";
|
|
6
|
-
import React from "react";
|
|
7
|
-
import DOMPurify from "dompurify";
|
|
8
|
-
|
|
9
|
-
declare global {
|
|
10
|
-
// noinspection JSUnusedGlobalSymbols
|
|
11
|
-
interface Window {
|
|
12
|
-
log: Function;
|
|
13
|
-
settings: IndexedObject<any>;
|
|
14
|
-
allowCookies: boolean;
|
|
15
|
-
gtag?: Function;
|
|
16
|
-
gapi?: any;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const getSetting = (name: string): any => {
|
|
21
|
-
const settings: IndexedObject<any> = window.settings;
|
|
22
|
-
if (settings.hasOwnProperty(name))
|
|
23
|
-
return settings[name];
|
|
24
|
-
console.warn(`Global settings does not contain a value for '${name}'`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const getMode = (): 'prod' | 'test' | 'dev' | 'accept' => {
|
|
28
|
-
return window.settings.mode;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const log = (message: any, obj?: any, force: boolean = false) => {
|
|
32
|
-
if (getMode() !== 'prod' || force) {
|
|
33
|
-
if (obj !== undefined && obj !== null) console.log(message, obj);
|
|
34
|
-
else console.log(message);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const warn = (message: string | number | boolean | object, obj?: any, force: boolean = false) => {
|
|
39
|
-
if (getMode() !== 'prod' || force) {
|
|
40
|
-
if (obj !== undefined && obj !== null) console.warn(message, obj);
|
|
41
|
-
else console.warn(message);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const error = (message: string | number | boolean, obj?: any, force: boolean = false) => {
|
|
46
|
-
if (getMode() !== 'prod' || force) {
|
|
47
|
-
if (obj !== undefined && obj !== null) console.error(message, obj);
|
|
48
|
-
else console.error(message);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const debug = (message: string | number | boolean | object, obj?: any, force: boolean = false) => {
|
|
53
|
-
if (getMode() !== 'prod' || force) {
|
|
54
|
-
if (obj !== undefined && obj !== null) console.debug(message, obj);
|
|
55
|
-
else console.debug(message);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const getRootFontSize = (): number => {
|
|
60
|
-
const root = document.documentElement,
|
|
61
|
-
fontString = window.getComputedStyle(root, null).getPropertyValue('font-size');
|
|
62
|
-
return parseInt(fontString.slice(0, fontString.length - 2), 10);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const roundTo = (number: number, digits: number = 0): string => {
|
|
66
|
-
const isNegative = number < 0, multiplicator = Math.pow(10, digits);
|
|
67
|
-
if (isNegative) number = number * -1;
|
|
68
|
-
number = parseFloat((number * multiplicator).toFixed(11));
|
|
69
|
-
let numberString = (Math.round(number) / multiplicator).toFixed(digits);
|
|
70
|
-
if (isNegative)
|
|
71
|
-
numberString = (parseFloat(numberString) * -1).toFixed(digits);
|
|
72
|
-
return numberString;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const roundToNumber = (number: number, decimals: number = 0): number => {
|
|
76
|
-
return Number(roundTo(number, decimals).replace(',', '.'));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export const parseMoney = (money: number): string => {
|
|
80
|
-
let moneyString: string;
|
|
81
|
-
if (money === 0 || money % 1 === 0) moneyString = money + ',-';
|
|
82
|
-
else moneyString = roundTo(money, 2).replace('.', ',');
|
|
83
|
-
if (/^0+[1-9]/.test(moneyString)) moneyString = moneyString.replace(/^0+/, '');
|
|
84
|
-
return moneyString;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const capitalize = (text: string): string => text.length ?
|
|
88
|
-
text.substr(0, 1).toUpperCase() + text.substr(1) : text;
|
|
89
|
-
|
|
90
|
-
export const getSearchParams = (search?: string, removeQuery: boolean = false): URLSearchParams => {
|
|
91
|
-
search = search === undefined || search === null ? location.search : search;
|
|
92
|
-
const params = new URLSearchParams(search);
|
|
93
|
-
if (removeQuery) window.history.pushState({}, document.title, window.location.pathname);
|
|
94
|
-
return params;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const downloadFile = (blob: Blob, fileName: string) => {
|
|
98
|
-
const link = document.createElement('a');
|
|
99
|
-
link.href = URL.createObjectURL(blob);
|
|
100
|
-
link.type = 'download';
|
|
101
|
-
link.download = fileName;
|
|
102
|
-
link.click();
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const downloadRequiredFile = (path: string | { default: string }, fileName?: string) => {
|
|
106
|
-
if (typeof path !== 'string') path = path.default;
|
|
107
|
-
const name = getFileName(path, fileName);
|
|
108
|
-
const link = document.createElement('a');
|
|
109
|
-
link.href = path;
|
|
110
|
-
link.type = 'download';
|
|
111
|
-
link.download = name;
|
|
112
|
-
link.click();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const getFileName = (path: string, fileName?: string): string => {
|
|
116
|
-
if (fileName?.length) return fileName;
|
|
117
|
-
let pathName = path.substr(path.lastIndexOf('/') + 1, path.length);
|
|
118
|
-
const cacheReg = /-[a-zA-Z\d]+-cache/;
|
|
119
|
-
if (pathName.match(cacheReg))
|
|
120
|
-
pathName = pathName.replace(cacheReg, '');
|
|
121
|
-
return pathName;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export const preventDefault = (evt: Event | React.SyntheticEvent) => {
|
|
125
|
-
evt.preventDefault();
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const shuffleArray = (arr: any[]): any[] => {
|
|
129
|
-
let counter: number = arr.length;
|
|
130
|
-
if (counter === 0) return arr;
|
|
131
|
-
while (counter > 0) {
|
|
132
|
-
const randomIndex = Math.floor(Math.random() * counter--), temp = arr[counter];
|
|
133
|
-
arr[counter] = arr[randomIndex];
|
|
134
|
-
arr[randomIndex] = temp;
|
|
135
|
-
}
|
|
136
|
-
return arr;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export const nullify = <T extends string | Array<any>>(value?: T | null): T | null => {
|
|
140
|
-
return value?.length ? value : null;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const undefine = (value?: string | null): string | undefined => {
|
|
144
|
-
return value?.length ? value : undefined;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export const sanitizeHtml = (html: string) => {
|
|
148
|
-
return DOMPurify().sanitize(html);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const copyToClipboard = (text: string): Promise<void> => {
|
|
152
|
-
return copyClipboard(text);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const copyClipboard = (text: string): Promise<void> => {
|
|
156
|
-
return window.navigator.clipboard.writeText(text);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function webpSupported(): boolean {
|
|
160
|
-
try {
|
|
161
|
-
return document.createElement('canvas').toDataURL('image/webp')
|
|
162
|
-
.indexOf('data:image/webp') === 0;
|
|
163
|
-
} catch {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export function isAbsoluteLink(link: string): boolean {
|
|
169
|
-
return /^(https?|www).*/.test(link);
|
|
170
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import moment, {Moment} from "moment";
|
|
6
|
-
|
|
7
|
-
export const MOMENT_FORMATS: string[] = [
|
|
8
|
-
'MM/DD/YYYY HH:mm:ss',
|
|
9
|
-
'MM-DD-YYYY HH:mm:ss',
|
|
10
|
-
'DD/MM/YYYY HH:mm:ss',
|
|
11
|
-
'DD-MM-YYYY HH:mm:ss',
|
|
12
|
-
'YYYY-MM-DD HH:mm:ss',
|
|
13
|
-
'YYYY/MM/DD HH:mm:ss',
|
|
14
|
-
'DD/MM/YYYYTHH:mm:ss',
|
|
15
|
-
'DD-MM-YYYYTHH:mm:ss',
|
|
16
|
-
'YYYY-MM-DDTHH:mm:ss',
|
|
17
|
-
'MM/DD/YYYY HH:mm',
|
|
18
|
-
'MM-DD-YYYY HH:mm',
|
|
19
|
-
'DD/MM/YYYY HH:mm',
|
|
20
|
-
'DD-MM-YYYY HH:mm',
|
|
21
|
-
'YYYY-MM-DD HH:mm',
|
|
22
|
-
'YYYY/MM/DD HH:mm',
|
|
23
|
-
'DD/MM/YYYYTHH:mm',
|
|
24
|
-
'DD-MM-YYYYTHH:mm',
|
|
25
|
-
'YYYY-MM-DDTHH:mm',
|
|
26
|
-
'YYYY/MM/DDTHH:mm',
|
|
27
|
-
'YYYY-MM-DD',
|
|
28
|
-
'YYYY/MM/DD',
|
|
29
|
-
'MM-DD-YYYY',
|
|
30
|
-
'MM/DD/YYYY',
|
|
31
|
-
'DD-MM-YYYY',
|
|
32
|
-
'DD/MM/YYYY',
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
export const toMoment = (dateValue?: string | Moment | null | Date, formats: string[] | string = MOMENT_FORMATS): Moment => {
|
|
36
|
-
if (moment.isMoment(dateValue)) return dateValue;
|
|
37
|
-
if(dateValue instanceof Date) return moment(dateValue);
|
|
38
|
-
if (!dateValue || !dateValue.length) return moment();
|
|
39
|
-
return moment(dateValue, formats);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const formatMoment = (date?: Moment, format: string = 'YYYY-MM-DDTHH:mm:ss'): string => {
|
|
43
|
-
if (!date) date = toMoment();
|
|
44
|
-
return date.format(format);
|
|
45
|
-
};
|
package/src/js/util/pdfUtil.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {DefaultPDFElementParams, IndexedObject, PdfFont, PDFTextVariables, SelectItemShape} from "./interfaces";
|
|
6
|
-
|
|
7
|
-
export const mmToPt = (mm: number) => Math.round(pxToPt(mmToPx(mm)));
|
|
8
|
-
export const mmToPx = (mm: number, toTens: boolean = true) => {
|
|
9
|
-
const value: number = Math.round(mm / 0.264583333);
|
|
10
|
-
return toTens ? roundToTens(value) : value;
|
|
11
|
-
}
|
|
12
|
-
export const pxToMm = (pixels: number) => Math.round(pixels * 0.264583333);
|
|
13
|
-
export const pxToPt = (px: number) => Math.round(px * .75);
|
|
14
|
-
export const ptToPx = (pt: number, toTens: boolean = true) => {
|
|
15
|
-
const value: number = Math.round(pt / .75);
|
|
16
|
-
return toTens ? roundToTens(value) : value;
|
|
17
|
-
}
|
|
18
|
-
export const ptToMm = (pt: number) => pxToMm(ptToPx(pt));
|
|
19
|
-
export const PAGE_WIDTH = 794, PAGE_HEIGHT = 1122; // In pixels
|
|
20
|
-
|
|
21
|
-
export const PDF_VARIABLES: PDFTextVariables = {
|
|
22
|
-
company: {
|
|
23
|
-
bedrijf_naam: 'Bedrijfsnaam',
|
|
24
|
-
bedrijf_adres: 'Adres',
|
|
25
|
-
bedrijf_postcode: 'Postcode',
|
|
26
|
-
bedrijf_stad: 'Stad',
|
|
27
|
-
bedrijf_land: 'Land',
|
|
28
|
-
bedrijf_email: 'E-mailadres',
|
|
29
|
-
bedrijf_telefoon: 'Telefoonnummer',
|
|
30
|
-
bedrijf_iban: 'IBAN',
|
|
31
|
-
bedrijf_btw: 'BTW-nummer',
|
|
32
|
-
bedrijf_kvk: 'KvK nummer'
|
|
33
|
-
},
|
|
34
|
-
client: {
|
|
35
|
-
klant_naam: 'Klantnaam',
|
|
36
|
-
klant_adres: 'Adres',
|
|
37
|
-
klant_postcode: 'Postcode',
|
|
38
|
-
klant_stad: 'Stad',
|
|
39
|
-
klant_land: 'Land',
|
|
40
|
-
klant_extra: 'Adres toevoeging',
|
|
41
|
-
klant_email: 'E-mailadres',
|
|
42
|
-
klant_telefoon: 'Telefoonnummer',
|
|
43
|
-
// klant_iban: 'IBAN',
|
|
44
|
-
klant_btw: 'BTW-nummer',
|
|
45
|
-
klant_kvk: 'KvK nummer',
|
|
46
|
-
klant_bedrijf: 'Bedrijfsnaam',
|
|
47
|
-
},
|
|
48
|
-
invoice: {
|
|
49
|
-
datum: 'Huidige datum',
|
|
50
|
-
factuurnummer: 'Factuurnummer',
|
|
51
|
-
subtotaal: 'Subtotaal',
|
|
52
|
-
btw_totaal: 'Totaal BTW (\u20ac)',
|
|
53
|
-
factuurtotaal: 'Factuurtotaal',
|
|
54
|
-
factuurdatum: 'Factuur datum',
|
|
55
|
-
factuurref: 'Factuur referentie'
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const getPdfVariables = (customVariables?: PDFTextVariables): PDFTextVariables => {
|
|
60
|
-
const variables = PDF_VARIABLES;
|
|
61
|
-
if (customVariables) {
|
|
62
|
-
const {company, invoice, client} = customVariables;
|
|
63
|
-
for (const key of Object.keys(company))
|
|
64
|
-
variables.company[key] = company[key];
|
|
65
|
-
for (const key of Object.keys(invoice))
|
|
66
|
-
variables.invoice[key] = invoice[key];
|
|
67
|
-
for (const key of Object.keys(client))
|
|
68
|
-
variables.client[key] = client[key];
|
|
69
|
-
}
|
|
70
|
-
return variables;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const setPdfVariables = (text: string, values: IndexedObject<string>) => {
|
|
74
|
-
for (const key of Object.keys(values)) {
|
|
75
|
-
const value = values[key];
|
|
76
|
-
if (text.includes(`{${key}}`) && value.length) text =
|
|
77
|
-
text.replace(new RegExp('\{' + key + '\}', 'g'), value);
|
|
78
|
-
}
|
|
79
|
-
return text;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export const setElementSettings = (element: DefaultPDFElementParams<any, any>, convertUnits: boolean = true) => {
|
|
83
|
-
const {dimensions, options} = element;
|
|
84
|
-
if (convertUnits) {
|
|
85
|
-
if (dimensions?.width) dimensions.width = ptToPx(dimensions.width, false);
|
|
86
|
-
if (dimensions?.height) dimensions.height = ptToPx(dimensions.height, false);
|
|
87
|
-
if (options?.fontSize) options.fontSize = ptToPx(element.options.fontSize, false);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const fontItems: SelectItemShape[] = [
|
|
92
|
-
{label: 'Helvetica', value: PdfFont.HELVETICA, labelStyle: {fontFamily: 'helvetica'}},
|
|
93
|
-
{label: 'Lato', value: PdfFont.LATO, labelStyle: {fontFamily: 'lato'}},
|
|
94
|
-
{label: 'Merriweather', value: PdfFont.MERRIWEATHER, labelStyle: {fontFamily: 'merriweather'}},
|
|
95
|
-
{label: 'Noto Sans', value: PdfFont.NOTO_SANS, labelStyle: {fontFamily: 'noto-sans'}},
|
|
96
|
-
{label: 'Noto Serif', value: PdfFont.NOTO_SERIF, labelStyle: {fontFamily: 'noto-serif'}},
|
|
97
|
-
{label: 'Open Sans', value: PdfFont.OPEN_SANS, labelStyle: {fontFamily: 'open-sans'}},
|
|
98
|
-
{label: 'Playfair Display', value: PdfFont.PLAYFAIR, labelStyle: {fontFamily: 'playfair'}},
|
|
99
|
-
{label: 'PT Serif', value: PdfFont.PT_SERIF, labelStyle: {fontFamily: 'pt-serif'}},
|
|
100
|
-
{label: 'Roboto', value: PdfFont.ROBOTO, labelStyle: {fontFamily: 'roboto'}},
|
|
101
|
-
{label: 'Roboto Mono', value: PdfFont.ROBOTO_MONO, labelStyle: {fontFamily: 'roboto-mono'}},
|
|
102
|
-
{label: 'Source Sans Pro', value: PdfFont.SOURCE_SANS_PRO, labelStyle: {fontFamily: 'source-sans-pro'}}
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
export const parsePrice = (price: number) => {
|
|
106
|
-
return price.toFixed(2).replace('.', ',').replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const roundToTens = (value: number): number => {
|
|
110
|
-
const remainder = value % 10;
|
|
111
|
-
if (remainder === 0) return value;
|
|
112
|
-
if (remainder > 4) return value + (10 - remainder);
|
|
113
|
-
return value - remainder;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const waitForFonts = (callback: Function) => {
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
if (document.fonts && document.fonts.ready) {
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
document.fonts.ready.then(() => {
|
|
121
|
-
callback();
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
};
|