@dvrd/dvr-controls 1.0.5 → 1.0.8
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 -146
- 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,69 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
import './style/imageUpload.scss';
|
|
5
|
-
|
|
6
|
-
import React, {PureComponent} from "react";
|
|
7
|
-
import classNames from "classnames";
|
|
8
|
-
import {voidFunction} from "../util/controlUtil";
|
|
9
|
-
|
|
10
|
-
interface Props {
|
|
11
|
-
className?: string;
|
|
12
|
-
onChange: (files: FileList | null) => void;
|
|
13
|
-
files: string[] | string;
|
|
14
|
-
disabled: boolean;
|
|
15
|
-
multiple?: boolean;
|
|
16
|
-
accept?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default class ImageUpload extends PureComponent<Props> {
|
|
20
|
-
private input: HTMLInputElement;
|
|
21
|
-
|
|
22
|
-
static defaultProps = {
|
|
23
|
-
multiple: false,
|
|
24
|
-
accept: 'image/*',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
onClickUpload = () => {
|
|
28
|
-
if (this.input) this.input.click();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
onDrag = (evt: React.DragEvent) => {
|
|
32
|
-
evt.preventDefault();
|
|
33
|
-
evt.stopPropagation();
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
onDrop = (evt: React.DragEvent) => {
|
|
37
|
-
evt.preventDefault();
|
|
38
|
-
evt.stopPropagation();
|
|
39
|
-
const {onChange} = this.props, files = evt.dataTransfer.files;
|
|
40
|
-
if (files?.length) {
|
|
41
|
-
onChange(files);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
renderFile = () => {
|
|
46
|
-
const {files} = this.props;
|
|
47
|
-
if (typeof files === 'string') return <img src={files} alt='' className='upload-img'/>;
|
|
48
|
-
else if (files.length) return (
|
|
49
|
-
<div className='files-list'>
|
|
50
|
-
{files.map((file: string, index: number) => <label className='file' key={index}>{file}</label>)}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
render = () => {
|
|
56
|
-
const {disabled, className, multiple, accept} = this.props;
|
|
57
|
-
return (
|
|
58
|
-
<div
|
|
59
|
-
className={classNames('dvr-upload-container', disabled && 'disabled', className)}
|
|
60
|
-
onClick={disabled ? voidFunction : this.onClickUpload} onDrop={this.onDrop} onDragOver={this.onDrag}
|
|
61
|
-
onDrag={this.onDrag}>
|
|
62
|
-
<input alt='' ref={(ref: HTMLInputElement) => {
|
|
63
|
-
this.input = ref
|
|
64
|
-
}} style={{display: 'none'}} type='image' accept={accept} multiple={multiple}/>
|
|
65
|
-
{this.renderFile()}
|
|
66
|
-
</div>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
};
|
package/src/js/info/info.tsx
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
import './style/info.scss';
|
|
5
|
-
|
|
6
|
-
import React, {CSSProperties, MouseEventHandler, PureComponent} from 'react';
|
|
7
|
-
import {ControlContext} from "../util/controlContext";
|
|
8
|
-
import {colorIsWhite, convertColor, editColor} from "../util/colorUtil";
|
|
9
|
-
import classNames from 'classnames';
|
|
10
|
-
import {getScreenHeight, getScreenWidth} from '../util/responsiveUtil';
|
|
11
|
-
import { directTimeout } from '../util/componentUtil';
|
|
12
|
-
import AwesomeIcon from '../icon/awesomeIcon';
|
|
13
|
-
|
|
14
|
-
type LimitBox = Partial<{ top: number, bottom: number, left: number, right: number }>;
|
|
15
|
-
|
|
16
|
-
interface Props {
|
|
17
|
-
onClick?: MouseEventHandler;
|
|
18
|
-
onMouseEnter?: MouseEventHandler;
|
|
19
|
-
onMouseLeave?: MouseEventHandler;
|
|
20
|
-
message: React.ReactNode;
|
|
21
|
-
title?: string;
|
|
22
|
-
className?: string;
|
|
23
|
-
messageClassName?: string;
|
|
24
|
-
iconClassName?: string;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
limitBox?: LimitBox;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface State {
|
|
30
|
-
hovered: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default class Info extends PureComponent<Props, State> {
|
|
34
|
-
declare context: React.ContextType<typeof ControlContext>;
|
|
35
|
-
static contextType = ControlContext;
|
|
36
|
-
|
|
37
|
-
private messageContainer: HTMLDivElement;
|
|
38
|
-
|
|
39
|
-
state: State = {
|
|
40
|
-
hovered: false,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
getColor = (): string => {
|
|
44
|
-
const {baseColor, contrastColor} = this.context, {hovered} = this.state, {disabled} = this.props;
|
|
45
|
-
let color = convertColor(baseColor);
|
|
46
|
-
if (colorIsWhite(color)) color = convertColor(contrastColor);
|
|
47
|
-
if (hovered) color = editColor(-.2, color);
|
|
48
|
-
if (disabled) color = '#ccc';
|
|
49
|
-
return color;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
onMouseEnter = (evt: React.MouseEvent) => {
|
|
53
|
-
const {onMouseEnter} = this.props;
|
|
54
|
-
this.setState({hovered: true});
|
|
55
|
-
if (onMouseEnter) onMouseEnter(evt);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
onMouseLeave = (evt: React.MouseEvent) => {
|
|
59
|
-
const {onMouseLeave} = this.props;
|
|
60
|
-
this.setState({hovered: false});
|
|
61
|
-
if (onMouseLeave) onMouseLeave(evt);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
getIconStyle = (): CSSProperties => {
|
|
65
|
-
return {color: this.getColor()};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
setMessagePosition = () => {
|
|
69
|
-
if (this.messageContainer) {
|
|
70
|
-
let {width, height, bottom, left, right, top} = this.messageContainer.getBoundingClientRect(),
|
|
71
|
-
screenWidth = getScreenWidth(), screenHeight = getScreenHeight(), {limitBox} = this.props;
|
|
72
|
-
top = top - (limitBox?.top || 0);
|
|
73
|
-
left = left - (limitBox?.left || 0);
|
|
74
|
-
bottom = bottom + (limitBox?.bottom || 0);
|
|
75
|
-
right = right + (limitBox?.right || 0);
|
|
76
|
-
let translateX: number = 0, translateY: number = 0;
|
|
77
|
-
if (top < 0) translateY = top;
|
|
78
|
-
else if (bottom > screenHeight) translateY = screenHeight - bottom;
|
|
79
|
-
if (left < 0) translateX = left;
|
|
80
|
-
else if (right > screenWidth) translateX = screenWidth - right;
|
|
81
|
-
|
|
82
|
-
let transform: string = this.messageContainer.style.transform;
|
|
83
|
-
const {x, y} = this.getCurrentTranslates(transform);
|
|
84
|
-
if (translateX) {
|
|
85
|
-
translateX = this.getCalculatedTranslate(x, translateX, width);
|
|
86
|
-
transform = transform.replace(/translateX\(-?\d*(%|px|rem)?\)/, `translateX(${translateX}%)`);
|
|
87
|
-
}
|
|
88
|
-
if (translateY) {
|
|
89
|
-
translateY = this.getCalculatedTranslate(y, translateY, height);
|
|
90
|
-
transform = transform.replace(/translateY\(-?\d*(%|px|rem)?\)/, `translateY(${translateY}%)`);
|
|
91
|
-
}
|
|
92
|
-
this.messageContainer.style.transform = transform;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
getCalculatedTranslate = (initial: number, value: number, dimension: number) => {
|
|
97
|
-
return initial - Math.round((value / dimension) * 100);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
getCurrentTranslates = (transform: string): { x: number, y: number } => {
|
|
101
|
-
let x = 100, y = -100;
|
|
102
|
-
const translateX = transform.match(/translateX\(-?\d*(%|px|rem)?\)/),
|
|
103
|
-
translateY = transform.match(/translateY\(-?\d*(%|px|rem)?\)/);
|
|
104
|
-
if (translateX) x = Number(translateX[0].match(/\(-?\d*(%|px|rem)?\)/)![0].replace(/[()%]|rem|px/g, ''));
|
|
105
|
-
if (translateY) y = Number(translateY[0].match(/\(-?\d*(%|px|rem)?\)/)![0].replace(/[()%]|rem|px/g, ''));
|
|
106
|
-
return {x, y};
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
renderMessage = (): React.ReactNode => {
|
|
110
|
-
const {message} = this.props;
|
|
111
|
-
if (typeof message === 'string') return <p className='dvr-info-message'>{message}</p>;
|
|
112
|
-
return message;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
componentDidUpdate = (prevProps: Props, prevState: State) => {
|
|
116
|
-
const {hovered} = this.state, prevHovered = prevState.hovered;
|
|
117
|
-
if (hovered && hovered !== prevHovered)
|
|
118
|
-
directTimeout(this.setMessagePosition);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
render = () => {
|
|
122
|
-
const {className, messageClassName, iconClassName} = this.props;
|
|
123
|
-
return (
|
|
124
|
-
<div className={classNames('dvr-info-container', className)} onMouseEnter={this.onMouseEnter}
|
|
125
|
-
onMouseLeave={this.onMouseLeave}>
|
|
126
|
-
<AwesomeIcon name='info-circle' style={this.getIconStyle()}
|
|
127
|
-
className={classNames('dvr-info-icon', iconClassName)}/>
|
|
128
|
-
<div className={classNames('dvr-message-container', messageClassName)}
|
|
129
|
-
ref={(ref: HTMLDivElement) => {this.messageContainer = ref}}
|
|
130
|
-
style={{transform: 'translateX(100%) translateY(-100%)'}}>
|
|
131
|
-
{this.renderMessage()}
|
|
132
|
-
</div>
|
|
133
|
-
</div>
|
|
134
|
-
)
|
|
135
|
-
};
|
|
136
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@import '../../../style/variables';
|
|
6
|
-
|
|
7
|
-
.dvr-info-container {
|
|
8
|
-
position: relative;
|
|
9
|
-
display: inline-block;
|
|
10
|
-
justify-self: start;
|
|
11
|
-
|
|
12
|
-
.dvr-info-icon {
|
|
13
|
-
cursor: help;
|
|
14
|
-
transition: color .2s ease-in-out;
|
|
15
|
-
font-size: 1.1rem;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.dvr-message-container {
|
|
19
|
-
@include backgroundShadow;
|
|
20
|
-
padding: .2rem;
|
|
21
|
-
border-radius: .2rem;
|
|
22
|
-
background-color: white;
|
|
23
|
-
position: absolute;
|
|
24
|
-
z-index: $z-index-high;
|
|
25
|
-
top: 0;
|
|
26
|
-
right: 0;
|
|
27
|
-
width: 15rem;
|
|
28
|
-
visibility: hidden;
|
|
29
|
-
opacity: 0;
|
|
30
|
-
transition: visibility .2s ease-in-out, opacity .2s ease-in-out;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&:hover {
|
|
34
|
-
.dvr-message-container {
|
|
35
|
-
visibility: visible;
|
|
36
|
-
opacity: 1;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import {CSSProperties, PureComponent, ReactElement} from 'react';
|
|
7
|
-
import {DefaultInputProps} from "../v2/inputController_v2";
|
|
8
|
-
import {TextField} from "../../../../index";
|
|
9
|
-
import {DVRInputControllerProps} from "../v2/inputController_v2";
|
|
10
|
-
|
|
11
|
-
interface Props extends DVRInputControllerProps {
|
|
12
|
-
animatedTexts: string[];
|
|
13
|
-
typingTime: number;
|
|
14
|
-
randomise: boolean;
|
|
15
|
-
doBackspace: boolean;
|
|
16
|
-
Input?: ReactElement;
|
|
17
|
-
className?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface State {
|
|
21
|
-
value: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default class AnimatedTextField extends PureComponent<Props, State> {
|
|
25
|
-
static defaultProps = {
|
|
26
|
-
...DefaultInputProps,
|
|
27
|
-
typingTime: 150,
|
|
28
|
-
randomise: true,
|
|
29
|
-
doBackspace: true,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
state: State = {
|
|
33
|
-
value: '',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
private timer: null | number = null;
|
|
37
|
-
private currentWord: string = '';
|
|
38
|
-
private words: string[] = [];
|
|
39
|
-
private isFocused: boolean = false;
|
|
40
|
-
|
|
41
|
-
onFocus = (evt: React.FocusEvent) => {
|
|
42
|
-
const {onFocus} = this.props;
|
|
43
|
-
this.isFocused = true;
|
|
44
|
-
this.stopAnimate();
|
|
45
|
-
if (onFocus) onFocus(evt);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
onBlur = (evt: React.FocusEvent) => {
|
|
49
|
-
const {onBlur, value} = this.props;
|
|
50
|
-
this.isFocused = false;
|
|
51
|
-
if(!value?.toString().length) {
|
|
52
|
-
this.animate();
|
|
53
|
-
}
|
|
54
|
-
if (onBlur) onBlur(evt);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
onChangeNative = (evt: React.ChangeEvent<HTMLInputElement>) => {
|
|
58
|
-
const target = evt.target, value = target.value;
|
|
59
|
-
this.onChange(value, evt);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
onChange = (value: string, evt: React.ChangeEvent) => {
|
|
63
|
-
if (value.length) this.stopAnimate();
|
|
64
|
-
else if (!this.isFocused) this.animate();
|
|
65
|
-
this.props.onChange(value, evt);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
getRandomTexts = (): string[] => {
|
|
69
|
-
const texts = this.props.animatedTexts.slice(), randomised: string[] = [];
|
|
70
|
-
while (texts.length > 0)
|
|
71
|
-
randomised.push(texts.splice(Math.round(Math.random() * (texts.length - 1)), 1)[0]);
|
|
72
|
-
return randomised;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
private animate = () => {
|
|
76
|
-
const {randomise, animatedTexts} = this.props;
|
|
77
|
-
if (randomise) this.words = this.getRandomTexts();
|
|
78
|
-
else this.words = animatedTexts.slice();
|
|
79
|
-
this.currentWord = this.words.pop() || '';
|
|
80
|
-
this.doType();
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
private stopAnimate = () => {
|
|
84
|
-
this.setState({value: ''});
|
|
85
|
-
if (this.timer) {
|
|
86
|
-
window.clearTimeout(this.timer);
|
|
87
|
-
this.timer = null;
|
|
88
|
-
}
|
|
89
|
-
this.words = [];
|
|
90
|
-
this.currentWord = '';
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
private randomiseTimeout = () => {
|
|
94
|
-
const {typingTime} = this.props, variations: number[] = [1, .8, .4];
|
|
95
|
-
return typingTime * variations[Math.round(Math.random() * 2)];
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
private doType = () => {
|
|
99
|
-
const {value} = this.state, {doBackspace, randomise, animatedTexts} = this.props;
|
|
100
|
-
let newValue: string, timeout: number = this.randomiseTimeout();
|
|
101
|
-
if (this.currentWord.length === 0) {
|
|
102
|
-
if (value.length > 0) {
|
|
103
|
-
if (doBackspace) {
|
|
104
|
-
newValue = value.substr(0, value.length - 1);
|
|
105
|
-
timeout = Math.round(timeout / 2);
|
|
106
|
-
if (!newValue.length) timeout = 300;
|
|
107
|
-
} else newValue = '';
|
|
108
|
-
} else {
|
|
109
|
-
if (!this.words.length) {
|
|
110
|
-
if (randomise) this.words = this.getRandomTexts();
|
|
111
|
-
else this.words = animatedTexts.slice();
|
|
112
|
-
}
|
|
113
|
-
this.currentWord = this.words.pop() as string;
|
|
114
|
-
newValue = value + this.getNextLetter();
|
|
115
|
-
if (!this.currentWord.length) timeout = 300;
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
newValue = value + this.getNextLetter();
|
|
119
|
-
if (!this.currentWord.length) timeout = 300;
|
|
120
|
-
}
|
|
121
|
-
this.setState({value: newValue});
|
|
122
|
-
this.timer = window.setTimeout(this.doType, timeout);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
private getNextLetter = () => {
|
|
126
|
-
const letter = this.currentWord.substr(0, 1);
|
|
127
|
-
this.currentWord = this.currentWord.substr(1, this.currentWord.length);
|
|
128
|
-
return letter;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
componentDidMount = () => {
|
|
132
|
-
if (!this.props.autoFocus)
|
|
133
|
-
this.animate();
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
componentWillUnmount = () => {
|
|
137
|
-
if (this.timer) {
|
|
138
|
-
window.clearTimeout(this.timer);
|
|
139
|
-
this.timer = null;
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
render = () => {
|
|
144
|
-
const value = this.props.value?.toString(), {Input} = this.props;
|
|
145
|
-
let textValue: string, style: CSSProperties;
|
|
146
|
-
if (value?.length) {
|
|
147
|
-
textValue = value;
|
|
148
|
-
style = {};
|
|
149
|
-
} else {
|
|
150
|
-
textValue = this.state.value + (this.state.value.length > 1 ? '|' : '');
|
|
151
|
-
style = {color: "gray"};
|
|
152
|
-
}
|
|
153
|
-
if (Input)
|
|
154
|
-
return React.cloneElement(Input,
|
|
155
|
-
{onChange: this.onChangeNative, value: textValue, onFocus: this.onFocus, onBlur: this.onBlur, style});
|
|
156
|
-
return <TextField {...this.props} onChange={this.onChange} onFocus={this.onFocus} onBlur={this.onBlur}
|
|
157
|
-
value={textValue} inputProps={{style}}/>;
|
|
158
|
-
};
|
|
159
|
-
}
|