@dvrd/dvr-controls 1.0.14 → 1.0.16
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 +8 -1
- package/package.json +29 -23
- package/src/js/button/button.tsx +102 -0
- package/src/js/button/buttonController.tsx +179 -0
- package/src/js/button/closeButton.tsx +29 -0
- package/src/js/button/dvrdButton.tsx +128 -0
- package/src/js/button/outlinedButton.tsx +105 -0
- package/src/js/button/simpleButton.tsx +163 -0
- package/src/js/button/style/button.scss +95 -0
- package/src/js/button/style/closeButton.scss +15 -0
- package/src/js/button/style/dvrdButton.scss +30 -0
- package/src/js/button/style/outlinedButton.scss +84 -0
- package/src/js/button/style/simpleButton.scss +80 -0
- package/src/js/carousel/DVRCarousel.tsx +163 -0
- package/src/js/carousel/DVRCarouselController.tsx +95 -0
- package/src/js/carousel/style/DVRCarousel.scss +38 -0
- package/src/js/checkbox/checkbox.tsx +148 -0
- package/src/js/checkbox/checkboxController.tsx +131 -0
- package/src/js/checkbox/style/checkbox.scss +109 -0
- package/src/js/colorPicker/colorPicker.tsx +118 -0
- package/src/js/colorPicker/style/colorPicker.scss +20 -0
- package/src/js/date/dvrdDatePicker.tsx +357 -0
- package/src/js/date/style/dvrdDatePicker.scss +307 -0
- package/src/js/dialog/dialog.tsx +207 -0
- package/src/js/dialog/dialogController.tsx +70 -0
- package/src/js/dialog/inlineDialog.tsx +127 -0
- package/src/js/dialog/style/dialog.scss +61 -0
- package/src/js/events/withEvents.tsx +40 -0
- package/src/js/head/DVRHead.tsx +49 -0
- package/src/js/header/DVRHeader.tsx +417 -0
- package/src/js/header/style/header.scss +206 -0
- package/src/js/icon/awesomeIcon.tsx +20 -0
- package/src/js/image/imageUpload.tsx +69 -0
- package/src/js/image/style/imageUpload.scss +11 -0
- package/src/js/info/info.tsx +136 -0
- package/src/js/info/style/info.scss +39 -0
- package/src/js/input/animated/animatedTextField.tsx +159 -0
- package/src/js/input/date/dateField.tsx +360 -0
- package/src/js/input/date/dateFieldController.tsx +245 -0
- package/src/js/input/date/datePicker/datePicker.tsx +186 -0
- package/src/js/input/date/datePicker/style/datePicker.scss +102 -0
- package/src/js/input/date/input/dateInput.tsx +214 -0
- package/src/js/input/date/style/dateField.scss +40 -0
- package/src/js/input/date/timePicker/style/timePicker.scss +95 -0
- package/src/js/input/date/timePicker/timePicker.tsx +143 -0
- package/src/js/input/editor/DVREditor.tsx +21 -0
- package/src/js/input/number/numberInput.tsx +157 -0
- package/src/js/input/password/passwordInput.tsx +140 -0
- package/src/js/input/password/passwordRules.tsx +48 -0
- package/src/js/input/password/style/passwordInput.scss +39 -0
- package/src/js/input/password/style/passwordRules.scss +41 -0
- package/src/js/input/simple/style/simpleInput.scss +98 -0
- package/src/js/input/simple/v2/simpleInputV2.tsx +178 -0
- package/src/js/input/style/input.scss +138 -0
- package/src/js/input/v2/inputController_v2.tsx +250 -0
- package/src/js/input/v2/input_v2.tsx +7 -0
- package/src/js/label/label.tsx +196 -0
- package/src/js/label/style/label.scss +4 -0
- package/src/js/link/link.tsx +38 -0
- package/src/js/link/style/link.scss +30 -0
- package/src/js/loader/loader.tsx +79 -0
- package/src/js/loader/loaderController.tsx +61 -0
- package/src/js/loader/style/loader.scss +53 -0
- package/src/js/media/media.tsx +72 -0
- package/src/js/navigator/navigator.tsx +51 -0
- package/src/js/optionsList/dvrdOptionsList.tsx +112 -0
- package/src/js/optionsList/style/dvrdOptionsList.scss +84 -0
- package/src/js/optionsMenu/optionsMenu.tsx +187 -0
- package/src/js/optionsMenu/style/optionsMenu.scss +70 -0
- package/src/js/pdf/element/pdfElement.tsx +315 -0
- package/src/js/pdf/element/style/pdfElement.scss +111 -0
- package/src/js/pdf/history/pdfHistory.ts +57 -0
- package/src/js/pdf/image/pdfImage.tsx +175 -0
- package/src/js/pdf/image/style/pdfImage.scss +34 -0
- package/src/js/pdf/invoiceTable/pdfInvoiceTable.tsx +176 -0
- package/src/js/pdf/invoiceTable/style/pdfInvoiceTable.scss +32 -0
- package/src/js/pdf/pdfTemplateCreator.tsx +279 -0
- package/src/js/pdf/settings/buttons/iconButton.tsx +49 -0
- package/src/js/pdf/settings/buttons/style/iconButton.scss +50 -0
- package/src/js/pdf/settings/image/pdfImageSettings.tsx +82 -0
- package/src/js/pdf/settings/image/style/pdfImageSettings.scss +9 -0
- package/src/js/pdf/settings/invoiceTable/pdfInvoiceTableSettings.tsx +141 -0
- package/src/js/pdf/settings/invoiceTable/style/pdfInvoiceTableSettings.scss +38 -0
- package/src/js/pdf/settings/pdfElementSettings.tsx +86 -0
- package/src/js/pdf/settings/style/pdfElementSettings.scss +56 -0
- package/src/js/pdf/settings/text/pdfTextSettings.tsx +202 -0
- package/src/js/pdf/settings/text/style/pdfTextSettings.scss +94 -0
- package/src/js/pdf/style/pdfTemplateCreator.scss +118 -0
- package/src/js/pdf/text/pdfText.tsx +267 -0
- package/src/js/pdf/text/style/pdfText.scss +22 -0
- package/src/js/pdf/v2/pdfElement/pdfDraggableElement.tsx +193 -0
- package/src/js/pdf/v2/types/pdfTemplateTypes.ts +27 -0
- package/src/js/popup/style/withBackground.scss +29 -0
- package/src/js/popup/withBackground.tsx +92 -0
- package/src/js/select/async/asyncSelect.tsx +46 -0
- package/src/js/select/async/style/asyncSelect.scss +23 -0
- package/src/js/select/dvrdSelect.tsx +214 -0
- package/src/js/select/dvrdSelectController.tsx +81 -0
- package/src/js/select/select.tsx +310 -0
- package/src/js/select/selectController.tsx +341 -0
- package/src/js/select/style/dvrdSelect.scss +140 -0
- package/src/js/select/style/select.scss +199 -0
- package/src/js/sidebarMenu/sidebarMenu.tsx +167 -0
- package/src/js/sidebarMenu/style/sidebarMenu.scss +167 -0
- package/src/js/slider/DVRSlider.tsx +107 -0
- package/src/js/slider/style/DVRSlider.scss +88 -0
- package/src/js/snackbar/snackbar.tsx +72 -0
- package/src/js/snackbar/snackbarController.tsx +104 -0
- package/src/js/snackbar/style/snackbar.scss +46 -0
- package/src/js/switch/dvrdSwitch.tsx +53 -0
- package/src/js/switch/style/dvrdSwitch.scss +47 -0
- package/src/js/switch/style/switch.scss +84 -0
- package/src/js/switch/switch.tsx +115 -0
- package/src/js/switch/switchController.tsx +97 -0
- package/src/js/textField/dvrdInput.tsx +219 -0
- package/src/js/textField/dvrdInputController.tsx +97 -0
- package/src/js/textField/dvrdNumberInput.tsx +141 -0
- package/src/js/textField/dvrdPasswordInput.tsx +40 -0
- package/src/js/textField/style/dvrdInput.scss +114 -0
- package/src/js/textField/style/dvrdPassword.scss +15 -0
- package/src/js/topButton/style/topButton.scss +54 -0
- package/src/js/topButton/topButton.tsx +136 -0
- package/src/js/util/analyticsUtil.ts +41 -0
- package/src/js/util/colorUtil.ts +230 -0
- package/src/js/util/componentUtil.tsx +59 -0
- package/src/js/util/constants.ts +12 -0
- package/src/js/util/controlContext.tsx +46 -0
- package/src/js/util/controlUtil.ts +107 -0
- package/src/js/util/cookieUtil.ts +17 -0
- package/src/js/util/eventUtil.ts +65 -0
- package/src/js/util/googleUtil.ts +88 -0
- package/src/js/util/interfaces.ts +180 -0
- package/src/js/util/jwtUtil.ts +72 -0
- package/src/js/util/miscUtil.ts +170 -0
- package/src/js/util/momentUtil.ts +45 -0
- package/src/js/util/pdfUtil.ts +124 -0
- package/src/js/util/requestUtil.ts +145 -0
- package/src/js/util/responsiveUtil.ts +37 -0
- package/src/js/util/validationUtil.ts +13 -0
- 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 +140 -0
- package/src/style/common-icons.scss +714 -0
- package/src/style/common-variables.scss +243 -0
- package/src/style/display-breakpoints.scss +141 -0
- package/src/style/fonts/common-icons.eot +0 -0
- package/src/style/fonts/common-icons.svg +150 -0
- 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 +7003 -0
- package/src/style/fonts/fontAwesome/css/all.min.css +6 -0
- package/src/style/fonts/fontAwesome/css/brands.css +1423 -0
- package/src/style/fonts/fontAwesome/css/brands.min.css +6 -0
- package/src/style/fonts/fontAwesome/css/fontawesome.css +5519 -0
- package/src/style/fonts/fontAwesome/css/fontawesome.min.css +6 -0
- package/src/style/fonts/fontAwesome/css/regular.css +19 -0
- package/src/style/fonts/fontAwesome/css/regular.min.css +6 -0
- package/src/style/fonts/fontAwesome/css/solid.css +19 -0
- package/src/style/fonts/fontAwesome/css/solid.min.css +6 -0
- package/src/style/fonts/fontAwesome/css/svg-with-js.css +634 -0
- package/src/style/fonts/fontAwesome/css/svg-with-js.min.css +6 -0
- package/src/style/fonts/fontAwesome/css/v4-font-face.css +26 -0
- package/src/style/fonts/fontAwesome/css/v4-font-face.min.css +6 -0
- package/src/style/fonts/fontAwesome/css/v4-shims.css +2146 -0
- package/src/style/fonts/fontAwesome/css/v4-shims.min.css +6 -0
- package/src/style/fonts/fontAwesome/css/v5-font-face.css +22 -0
- package/src/style/fonts/fontAwesome/css/v5-font-face.min.css +6 -0
- 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 +11 -0
- package/.gitignore +0 -31
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
import './style/timePicker.scss';
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import {PureComponent} from 'react';
|
|
8
|
+
import classNames from "classnames";
|
|
9
|
+
import {DateType} from "../dateFieldController";
|
|
10
|
+
import {pad, remToPx} from "../../../util/controlUtil";
|
|
11
|
+
import {DateNumParts} from "../dateField";
|
|
12
|
+
import {colorIsWhite, convertColor} from "../../../util/colorUtil";
|
|
13
|
+
import {ControlContext} from "../../../util/controlContext";
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
pickerValue: DateNumParts;
|
|
17
|
+
dateType: DateType;
|
|
18
|
+
onChange: (hour: number, minute: number) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SCROLL_TIMEOUT = 120;
|
|
22
|
+
|
|
23
|
+
export default class TimePicker extends PureComponent<Props> {
|
|
24
|
+
declare context: React.ContextType<typeof ControlContext>;
|
|
25
|
+
static contextType = ControlContext;
|
|
26
|
+
|
|
27
|
+
private hourTimeout: number | null = null;
|
|
28
|
+
private minuteTimeout: number | null = null;
|
|
29
|
+
|
|
30
|
+
onScroll = (type: 'hour' | 'minute') => () => {
|
|
31
|
+
const handle: number | null = type === 'hour' ? this.hourTimeout : this.minuteTimeout;
|
|
32
|
+
this.clearTimeout(handle);
|
|
33
|
+
if (type === 'hour') this.hourTimeout = window.setTimeout(this.determineTime, SCROLL_TIMEOUT);
|
|
34
|
+
else this.minuteTimeout = window.setTimeout(this.determineTime, SCROLL_TIMEOUT);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
getBaseColor = (allowWhite: boolean = true): string => {
|
|
38
|
+
let color = convertColor(this.context.baseColor);
|
|
39
|
+
if (!allowWhite && colorIsWhite(color)) color = convertColor(this.context.contrastColor);
|
|
40
|
+
return color;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
getContrastColor = (allowWhiteBase: boolean = true): string => {
|
|
44
|
+
if (!allowWhiteBase) {
|
|
45
|
+
const base = this.getBaseColor(true);
|
|
46
|
+
if (colorIsWhite(base)) return base;
|
|
47
|
+
}
|
|
48
|
+
return convertColor(this.context.contrastColor);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
clearTimeout = (handle: number | null) => {
|
|
52
|
+
if (handle) window.clearTimeout(handle);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
determineTime = () => {
|
|
56
|
+
this.clearTimeout(this.minuteTimeout);
|
|
57
|
+
this.clearTimeout(this.hourTimeout);
|
|
58
|
+
|
|
59
|
+
const {pickerValue, onChange} = this.props, hourContainer = document.getElementById('hour-container'),
|
|
60
|
+
minuteContainer = document.getElementById('minute-container');
|
|
61
|
+
|
|
62
|
+
let hour = pickerValue.hour, minute = pickerValue.minute;
|
|
63
|
+
if (hourContainer)
|
|
64
|
+
hour = Math.floor(hourContainer.scrollTop / remToPx(2));
|
|
65
|
+
|
|
66
|
+
if (minuteContainer)
|
|
67
|
+
minute = Math.floor(minuteContainer.scrollTop / remToPx(2));
|
|
68
|
+
|
|
69
|
+
onChange(hour, minute);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
renderHourSelect = () => {
|
|
73
|
+
const hours: number[] = [];
|
|
74
|
+
for (let i = 0; i < 24; i++)
|
|
75
|
+
hours.push(i);
|
|
76
|
+
return (
|
|
77
|
+
<div className='time-select-background-container'>
|
|
78
|
+
<div className='selected-background'/>
|
|
79
|
+
<div id='hour-container' className='time-select-container' onScroll={this.onScroll('hour')}>
|
|
80
|
+
<div className='time-unit-container invis'>
|
|
81
|
+
<label className='time-unit-label'>0</label>
|
|
82
|
+
</div>
|
|
83
|
+
{hours.map((hour: number, index: number) => (
|
|
84
|
+
<div id={`hour-${pad(hour)}`} key={index} className='time-unit-container'>
|
|
85
|
+
<label className='time-unit-label'>{pad(hour)}</label>
|
|
86
|
+
</div>
|
|
87
|
+
))}
|
|
88
|
+
<div className='time-unit-container invis'>
|
|
89
|
+
<label className='time-unit-label'>0</label>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
)
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
renderMinuteSelect = () => {
|
|
97
|
+
const minutes: number[] = [];
|
|
98
|
+
for (let i = 0; i < 60; i++)
|
|
99
|
+
minutes.push(i);
|
|
100
|
+
return (
|
|
101
|
+
<div className='time-select-background-container'>
|
|
102
|
+
<div className='selected-background'/>
|
|
103
|
+
<div id='minute-container' className='time-select-container' onScroll={this.onScroll('minute')}>
|
|
104
|
+
<div className='time-unit-container invis'>
|
|
105
|
+
<label className='time-unit-label'>0</label>
|
|
106
|
+
</div>
|
|
107
|
+
{minutes.map((minute: number, index: number) => (
|
|
108
|
+
<div id={`minute-${pad(minute)}`} key={index} className='time-unit-container'>
|
|
109
|
+
<label className='time-unit-label'>{pad(minute)}</label>
|
|
110
|
+
</div>
|
|
111
|
+
))}
|
|
112
|
+
<div className='time-unit-container invis'>
|
|
113
|
+
<label className='time-unit-label'>0</label>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
render = () => {
|
|
121
|
+
const {dateType, pickerValue} = this.props;
|
|
122
|
+
return (
|
|
123
|
+
<div className='timepicker-container'>
|
|
124
|
+
<div className='header-container' style={{backgroundColor: this.getBaseColor()}}>
|
|
125
|
+
<label className='header-title' style={{color: this.getContrastColor()}}>Kies tijd</label>
|
|
126
|
+
</div>
|
|
127
|
+
<label className={classNames('date-label', dateType != DateType.DATETIME && 'invis')}>{`${pad(
|
|
128
|
+
pickerValue.day)}-${pad(
|
|
129
|
+
pickerValue.month + 1)}-${pickerValue.year}`}</label>
|
|
130
|
+
<div className='time-body-container'>
|
|
131
|
+
<div className='time-column'>
|
|
132
|
+
<label className='time-col-title'>Uur</label>
|
|
133
|
+
{this.renderHourSelect()}
|
|
134
|
+
</div>
|
|
135
|
+
<div className='time-column'>
|
|
136
|
+
<label className='time-col-title'>Minuut</label>
|
|
137
|
+
{this.renderMinuteSelect()}
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React, { FocusEventHandler, MouseEventHandler, PureComponent, CSSProperties } from 'react';
|
|
6
|
+
import {ChangeFunction} from "../../util/interfaces";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
onChange: ChangeFunction<string>;
|
|
10
|
+
onFocus?: FocusEventHandler;
|
|
11
|
+
onBlur?: FocusEventHandler;
|
|
12
|
+
onClickButton: MouseEventHandler;
|
|
13
|
+
value: string;
|
|
14
|
+
id: string;
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class DVREditor extends PureComponent<Props> {
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React, {InputHTMLAttributes} from 'react';
|
|
6
|
+
import {KeyboardEventHandler} from 'react';
|
|
7
|
+
import {ControlVariant, OrnamentShape} from "../../util/interfaces";
|
|
8
|
+
import TextField, {DefaultInputProps} from '../v2/inputController_v2'
|
|
9
|
+
import {roundTo} from "../../util/miscUtil";
|
|
10
|
+
import {generateComponentId} from '../../../..';
|
|
11
|
+
|
|
12
|
+
interface InputProps {
|
|
13
|
+
onChange: any;
|
|
14
|
+
onFocus?: any;
|
|
15
|
+
onBlur?: any;
|
|
16
|
+
onClick?: any;
|
|
17
|
+
onKeyDown?: any;
|
|
18
|
+
onMouseEnter?: any;
|
|
19
|
+
onMouseLeave?: any;
|
|
20
|
+
onEnter?: KeyboardEventHandler;
|
|
21
|
+
value: string;
|
|
22
|
+
error?: string | null;
|
|
23
|
+
label?: string;
|
|
24
|
+
containerClass?: string;
|
|
25
|
+
inputContainerClass?: string;
|
|
26
|
+
inputClass?: string;
|
|
27
|
+
labelClass?: string;
|
|
28
|
+
errorClass?: string;
|
|
29
|
+
id?: string;
|
|
30
|
+
baseColor?: string;
|
|
31
|
+
variant?: ControlVariant;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
fullWidth?: boolean;
|
|
35
|
+
autoFocus?: boolean;
|
|
36
|
+
inputProps?: InputHTMLAttributes<any>;
|
|
37
|
+
autoSelect?: boolean;
|
|
38
|
+
ornaments?: OrnamentShape | OrnamentShape[];
|
|
39
|
+
asCurrency: boolean;
|
|
40
|
+
clearAble?: boolean;
|
|
41
|
+
wholeNumbers: boolean;
|
|
42
|
+
asNumber?: boolean;
|
|
43
|
+
defaultValue?: string | number;
|
|
44
|
+
unControlled?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface State {
|
|
48
|
+
value: string | number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default class NumberInput extends React.Component<InputProps, State> {
|
|
52
|
+
static defaultProps = Object.assign(DefaultInputProps, {
|
|
53
|
+
asCurrency: false,
|
|
54
|
+
wholeNumbers: false,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
state: State = {
|
|
58
|
+
value: this.props.value,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
private readonly id: string = generateComponentId(this.props.id);
|
|
62
|
+
|
|
63
|
+
onKeyDown = (evt: React.KeyboardEvent) => {
|
|
64
|
+
const {onKeyDown, asCurrency, wholeNumbers, inputProps, asNumber} = this.props, {key, target} = evt,
|
|
65
|
+
value = this.state.value.toString();
|
|
66
|
+
let numValue = Number(value);
|
|
67
|
+
// Allow only number and simple edit keys
|
|
68
|
+
if (!/\d|Backspace|ArrowRight|ArrowLeft|ArrowUp|ArrowDown|Escape|Esc|Enter|[,.\-+]|Tab/.test(key) &&
|
|
69
|
+
!this.isPasting(evt))
|
|
70
|
+
evt.preventDefault();
|
|
71
|
+
|
|
72
|
+
if (key === 'ArrowUp') {
|
|
73
|
+
evt.preventDefault();
|
|
74
|
+
if (!isNaN(numValue)) {
|
|
75
|
+
const step = Number(inputProps?.step || asCurrency ? .01 : 1);
|
|
76
|
+
numValue += step;
|
|
77
|
+
let stringValue = numValue.toString();
|
|
78
|
+
if (asCurrency) stringValue = roundTo(numValue, 2);
|
|
79
|
+
if (asNumber) this.change(Number(stringValue), evt);
|
|
80
|
+
else this.change(stringValue, evt);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (key === 'ArrowDown') {
|
|
85
|
+
evt.preventDefault();
|
|
86
|
+
if (!isNaN(numValue)) {
|
|
87
|
+
const step = Number(inputProps?.step || asCurrency ? .01 : 1);
|
|
88
|
+
numValue -= step;
|
|
89
|
+
let stringValue = numValue.toString();
|
|
90
|
+
if (asCurrency) stringValue = roundTo(numValue, 2);
|
|
91
|
+
if (asNumber) this.change(Number(stringValue), evt);
|
|
92
|
+
else this.change(stringValue, evt);
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const textIsSelected = this.textIsSelected(evt), position = (target as HTMLInputElement).selectionStart;
|
|
98
|
+
if (!textIsSelected) {
|
|
99
|
+
if (/[,.]/.test(key) && /[,.]/.test(value) && asCurrency)
|
|
100
|
+
// Prevent double points or commas
|
|
101
|
+
evt.preventDefault();
|
|
102
|
+
|
|
103
|
+
if (wholeNumbers && /[.,]/.test(key))
|
|
104
|
+
evt.preventDefault();
|
|
105
|
+
else if (asCurrency && /[.,]\d{2}/.test(value) && /\d/.test(key) &&
|
|
106
|
+
this.positionIsAfterComma(position, value))
|
|
107
|
+
// Prevent more than 2 decimals when working with currencies
|
|
108
|
+
evt.preventDefault();
|
|
109
|
+
|
|
110
|
+
if ((position && position !== 0) && /[\-+]/.test(key))
|
|
111
|
+
// Prevent - or + sign after first position
|
|
112
|
+
evt.preventDefault();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (onKeyDown !== undefined && onKeyDown !== null)
|
|
116
|
+
onKeyDown(evt);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
onChange = (value: string, evt: React.ChangeEvent) => {
|
|
120
|
+
const {asNumber} = this.props;
|
|
121
|
+
if (!/^-?[\d.,]*$/.test(value)) evt.preventDefault();
|
|
122
|
+
else {
|
|
123
|
+
let convertValue: number | string = value;
|
|
124
|
+
if (convertValue.startsWith('.') || convertValue.startsWith(',')) convertValue = 0 + convertValue;
|
|
125
|
+
if (asNumber) convertValue = Number(convertValue.replace(',', '.'));
|
|
126
|
+
this.change(convertValue, evt);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
change = (value: string | number, evt: React.ChangeEvent | React.KeyboardEvent) => {
|
|
131
|
+
this.setState({value}, () => {
|
|
132
|
+
this.props.onChange(value, evt);
|
|
133
|
+
})
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
isPasting = (evt: React.KeyboardEvent) => {
|
|
137
|
+
return (evt.metaKey || evt.ctrlKey) && evt.key === 'v';
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
positionIsAfterComma = (position: number | null, value: string) => {
|
|
141
|
+
if (position === null) return true;
|
|
142
|
+
if (value.includes('.')) return position > value.indexOf('.');
|
|
143
|
+
if (value.includes(',')) return position > value.indexOf(',');
|
|
144
|
+
return false;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
textIsSelected = (evt: React.KeyboardEvent) => {
|
|
148
|
+
const target = evt.target as HTMLInputElement, start = target.selectionStart, end = target.selectionEnd;
|
|
149
|
+
return start != end;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
render = () => {
|
|
153
|
+
const {unControlled, value} = this.props;
|
|
154
|
+
return <TextField {...this.props} value={unControlled ? this.state.value : value} onKeyDown={this.onKeyDown}
|
|
155
|
+
onChange={this.onChange} id={this.id} unControlled={false}/>
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import './style/passwordInput.scss';
|
|
6
|
+
|
|
7
|
+
import React, {KeyboardEventHandler, PureComponent} from 'react';
|
|
8
|
+
|
|
9
|
+
import {ControlVariant, ElementPosition, OrnamentShape, StrengthGauche} from "../../util/interfaces";
|
|
10
|
+
import TextField from '../v2/inputController_v2';
|
|
11
|
+
import AwesomeIcon from '../../icon/awesomeIcon';
|
|
12
|
+
import {directTimeout, generateComponentId} from "../../util/componentUtil";
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
onChange: any;
|
|
17
|
+
onFocus?: any;
|
|
18
|
+
onBlur?: any;
|
|
19
|
+
onClick?: any;
|
|
20
|
+
onKeyDown?: any;
|
|
21
|
+
onMouseEnter?: any;
|
|
22
|
+
onMouseLeave?: any;
|
|
23
|
+
onEnter?: KeyboardEventHandler;
|
|
24
|
+
value: string;
|
|
25
|
+
error?: string | null;
|
|
26
|
+
label?: string;
|
|
27
|
+
containerClass?: string;
|
|
28
|
+
inputContainerClass?: string;
|
|
29
|
+
inputClass?: string;
|
|
30
|
+
labelClass?: string;
|
|
31
|
+
errorClass?: string;
|
|
32
|
+
id?: string;
|
|
33
|
+
key?: string;
|
|
34
|
+
baseColor?: string;
|
|
35
|
+
variant?: ControlVariant;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
readOnly?: boolean;
|
|
38
|
+
fullWidth?: boolean;
|
|
39
|
+
autoFocus?: boolean;
|
|
40
|
+
inputProps?: object;
|
|
41
|
+
autoSelect?: boolean;
|
|
42
|
+
strengthGauche?: StrengthGauche[];
|
|
43
|
+
strengthColors: string[];
|
|
44
|
+
strengthLabels: string[];
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface State {
|
|
49
|
+
type: 'password' | 'text';
|
|
50
|
+
passwordStrength: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default class PasswordInput extends PureComponent<Props, State> {
|
|
54
|
+
private id = generateComponentId(this.props.id);
|
|
55
|
+
private meter: HTMLDivElement;
|
|
56
|
+
static defaultProps = {
|
|
57
|
+
strengthColors: ['red', 'gold', '#29A71A'],
|
|
58
|
+
strengthLabels: ['Zwak', 'Matig', 'Sterk'],
|
|
59
|
+
area: false,
|
|
60
|
+
clearAble: true,
|
|
61
|
+
disabled: false,
|
|
62
|
+
autoFocus: false,
|
|
63
|
+
autoSelect: false,
|
|
64
|
+
error: null,
|
|
65
|
+
errorClassName: '',
|
|
66
|
+
fullWidth: true,
|
|
67
|
+
className: '',
|
|
68
|
+
inputContainerClassName: '',
|
|
69
|
+
labelClassName: '',
|
|
70
|
+
readOnly: false,
|
|
71
|
+
type: 'text',
|
|
72
|
+
variant: ControlVariant.SIMPLE,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
state: State = {
|
|
76
|
+
type: 'password' as 'password',
|
|
77
|
+
passwordStrength: 0,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
onClickOrnament = () => {
|
|
81
|
+
const {type} = this.state;
|
|
82
|
+
if (type === 'password') this.setState({type: 'text'});
|
|
83
|
+
else this.setState({type: 'password'});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
getOrnament = (): OrnamentShape => {
|
|
87
|
+
const {type} = this.state, element = type === 'password' ? 'eye' : 'eye-slash';
|
|
88
|
+
return {
|
|
89
|
+
placement: ElementPosition.RIGHT,
|
|
90
|
+
element: <AwesomeIcon name={element} onClick={this.onClickOrnament} className='passwordOrnament'/>
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
getGaucheWidth = (): { width: string, label: string } => {
|
|
95
|
+
const {strengthGauche, value, strengthLabels} = this.props;
|
|
96
|
+
if (!strengthGauche?.length) return {width: '0%', label: strengthLabels[0]};
|
|
97
|
+
const total = strengthGauche.length;
|
|
98
|
+
let passed: number = 0;
|
|
99
|
+
for (let i = 0; i < strengthGauche.length; i++)
|
|
100
|
+
if (strengthGauche[i].validator(value)) passed++;
|
|
101
|
+
const percentage = Math.min(parseInt((passed / total * 100) + ''), 100),
|
|
102
|
+
width = Math.max(percentage, Math.round(100 / total)) + '%';
|
|
103
|
+
|
|
104
|
+
return {width, label: strengthLabels[Math.max(0, Math.min(strengthLabels.length - 1, passed - 1))]};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
setGaucheWidth = () => {
|
|
108
|
+
const input = document.getElementById(this.id);
|
|
109
|
+
if (input && this.meter) this.meter.style.width = input.getBoundingClientRect().width + 'px';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
renderStrengthGauche = () => {
|
|
113
|
+
const {strengthGauche, strengthColors, value} = this.props;
|
|
114
|
+
const hidden = !strengthGauche?.length || !value.length;
|
|
115
|
+
const gaucheVars: { width: string, label: string } = this.getGaucheWidth();
|
|
116
|
+
return (
|
|
117
|
+
<div className={classNames('strength-gauche', hidden && 'hidden')} style={{width: gaucheVars.width}}>
|
|
118
|
+
<div className='meter' ref={(ref: HTMLDivElement) => {this.meter = ref}}
|
|
119
|
+
style={{backgroundImage: `linear-gradient(to right, ${strengthColors.join(', ')})`}}/>
|
|
120
|
+
<label className='gauche-label'>{gaucheVars.label}</label>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
componentDidMount = () => {
|
|
126
|
+
directTimeout(this.setGaucheWidth)
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
render = () => {
|
|
130
|
+
const {type} = this.state, {inputProps} = this.props;
|
|
131
|
+
return (
|
|
132
|
+
<div className='dvr-password-field-container'>
|
|
133
|
+
<TextField {...this.props} inputProps={{...inputProps, type}} id={this.id} unControlled>
|
|
134
|
+
{this.getOrnament()}
|
|
135
|
+
</TextField>
|
|
136
|
+
{this.renderStrengthGauche()}
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import './style/passwordRules.scss';
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import {PasswordRule} from "../../util/interfaces";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
password: string;
|
|
13
|
+
visible: boolean;
|
|
14
|
+
rules: PasswordRule[];
|
|
15
|
+
containerClass?: string;
|
|
16
|
+
ruleClass?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DEFAULT_RULES: PasswordRule[] = [
|
|
20
|
+
{label: 'Minimaal 8 tekens', validator: (password: string) => password.length >= 8},
|
|
21
|
+
{label: 'Maximaal 24 tekens', validator: (password: string) => password.length <= 24},
|
|
22
|
+
{label: 'Minimaal 1 getal', validator: (password: string) => /\d/.test(password)},
|
|
23
|
+
{label: 'Minimaal 1 symbool', validator: (password: string) => /[!?@#$%^&*(),./\[\]{}]/.test(password)},
|
|
24
|
+
{label: 'Minimaal 1 hoofdletter', validator: (password: string) => /[A-Z]/.test(password)},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export default class PasswordRules extends React.Component<Props> {
|
|
28
|
+
static defaultProps = {
|
|
29
|
+
containerClass: '',
|
|
30
|
+
ruleClass: '',
|
|
31
|
+
rules: DEFAULT_RULES,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
renderRule = (rule: PasswordRule, index: number) => {
|
|
35
|
+
const {password, ruleClass} = this.props, rulePassed = rule.validator(password);
|
|
36
|
+
return <label key={index} className={classNames('rule-label', rulePassed && 'passed',
|
|
37
|
+
!rulePassed && 'failed', ruleClass)}>- {rule.label}</label>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
render = () => {
|
|
41
|
+
const {containerClass, visible, password, rules} = this.props, hidden = !visible || !password.length;
|
|
42
|
+
return (
|
|
43
|
+
<div className={classNames('password-rules-container', hidden && 'hidden', containerClass)}>
|
|
44
|
+
{rules.map(this.renderRule)}
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@import '../../../../style/variables';
|
|
6
|
+
|
|
7
|
+
.dvr-password-field-container {
|
|
8
|
+
position: relative;
|
|
9
|
+
|
|
10
|
+
.strength-gauche {
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
margin-top: .5rem;
|
|
13
|
+
transition: width .2s ease-in-out;
|
|
14
|
+
|
|
15
|
+
.meter {
|
|
16
|
+
height: 3px;
|
|
17
|
+
width: 100%;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.gauche-label {
|
|
21
|
+
font-size: .8rem;
|
|
22
|
+
margin-top: .2rem;
|
|
23
|
+
display: inline-block;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.hidden {
|
|
27
|
+
display: none;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.passwordOrnament {
|
|
32
|
+
color: $color-gray-3;
|
|
33
|
+
transition: color .2s ease;
|
|
34
|
+
|
|
35
|
+
&:hover {
|
|
36
|
+
color: $color-gray-5;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@import '../../../../style/variables';
|
|
6
|
+
|
|
7
|
+
.password-rules-container {
|
|
8
|
+
@include borderRadius(.2rem);
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: 100%;
|
|
11
|
+
left: 0;
|
|
12
|
+
background-color: white;
|
|
13
|
+
padding: .3rem;
|
|
14
|
+
border: 1px solid $color-gray-5;
|
|
15
|
+
z-index: 1;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
visibility: visible;
|
|
19
|
+
opacity: 1;
|
|
20
|
+
transition: visibility .2s ease-in-out, opacity .2s ease-in-out;
|
|
21
|
+
transition-delay: .5s;
|
|
22
|
+
|
|
23
|
+
&.hidden {
|
|
24
|
+
visibility: hidden;
|
|
25
|
+
opacity: 0;
|
|
26
|
+
//transition-delay: 0s;
|
|
27
|
+
transition: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.rule-label {
|
|
31
|
+
transition: color .2s ease;
|
|
32
|
+
|
|
33
|
+
&.passed {
|
|
34
|
+
color: $color-green-whatsapp;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&.failed {
|
|
38
|
+
color: red;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@import '../../../../style/variables';
|
|
6
|
+
|
|
7
|
+
.dvr-simple-input-container {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
position: relative;
|
|
10
|
+
border: 2px solid;
|
|
11
|
+
border-radius: .25rem;
|
|
12
|
+
transition: border-color .2s ease-in-out, margin-bottom .2s ease-in-out;
|
|
13
|
+
padding: .25rem;
|
|
14
|
+
align-items: center;
|
|
15
|
+
margin-top: .5rem;
|
|
16
|
+
background-color: white;
|
|
17
|
+
|
|
18
|
+
&, * {
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.dvr-simple-input-label {
|
|
23
|
+
position: absolute;
|
|
24
|
+
font-size: .8rem;
|
|
25
|
+
top: 0;
|
|
26
|
+
left: .25rem;
|
|
27
|
+
transform: translateY(-60%);
|
|
28
|
+
transition: color .2s ease-in-out;
|
|
29
|
+
background-color: white;
|
|
30
|
+
user-select: none;
|
|
31
|
+
padding: 0 .2rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.dvr-simple-input {
|
|
35
|
+
outline: none !important;
|
|
36
|
+
border: none !important;
|
|
37
|
+
padding: .25rem;
|
|
38
|
+
width: 100%;
|
|
39
|
+
|
|
40
|
+
&::placeholder {
|
|
41
|
+
font-size: .9rem;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.dvr-simple-input-ornament {
|
|
46
|
+
color: $color-gray-header;
|
|
47
|
+
|
|
48
|
+
.dvr-simple-input-clear {
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
visibility: visible;
|
|
51
|
+
opacity: 1;
|
|
52
|
+
transition: color .2s ease-in-out, visibility .1s ease-in-out, opacity .1s ease-in-out;
|
|
53
|
+
|
|
54
|
+
&:hover {
|
|
55
|
+
color: red;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&.invis {
|
|
59
|
+
visibility: hidden;
|
|
60
|
+
opacity: 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.clickable {
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.dvr-simple-input-error {
|
|
70
|
+
position: absolute;
|
|
71
|
+
bottom: -1.2rem;
|
|
72
|
+
left: .25rem;
|
|
73
|
+
color: red;
|
|
74
|
+
font-size: .8rem;
|
|
75
|
+
visibility: hidden;
|
|
76
|
+
white-space: nowrap;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&.full-width {
|
|
80
|
+
width: 100%;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&.error {
|
|
84
|
+
margin-bottom: 1rem;
|
|
85
|
+
|
|
86
|
+
.dvr-simple-input-error {
|
|
87
|
+
visibility: visible;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&.disabled {
|
|
92
|
+
cursor: not-allowed;
|
|
93
|
+
|
|
94
|
+
* {
|
|
95
|
+
pointer-events: none;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|