@dvrd/dvr-controls 1.0.6 → 1.0.7
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,178 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '../style/simpleInput.scss';
|
|
6
|
-
|
|
7
|
-
import React, {CSSProperties, PureComponent} from 'react';
|
|
8
|
-
import classNames from "classnames";
|
|
9
|
-
import {ControlContext} from "../../../util/controlContext";
|
|
10
|
-
import {colorIsWhite, convertColor, editColor} from "../../../util/colorUtil";
|
|
11
|
-
import {ElementPosition, OrnamentShape} from "../../../util/interfaces";
|
|
12
|
-
import AwesomeIcon from '../../../icon/awesomeIcon';
|
|
13
|
-
import {stopPropagation} from "../../../util/controlUtil";
|
|
14
|
-
import {DVRInputProps} from "../../v2/inputController_v2";
|
|
15
|
-
|
|
16
|
-
export default class SimpleInput extends PureComponent<DVRInputProps> {
|
|
17
|
-
declare context: React.ContextType<typeof ControlContext>;
|
|
18
|
-
static contextType = ControlContext;
|
|
19
|
-
|
|
20
|
-
private input: HTMLInputElement | HTMLTextAreaElement | null = null;
|
|
21
|
-
|
|
22
|
-
private onFocus = (evt: React.FocusEvent) => {
|
|
23
|
-
const {onKeyDown, autoSelect, value, onFocus} = this.props;
|
|
24
|
-
if (this.input) {
|
|
25
|
-
if (onKeyDown)
|
|
26
|
-
this.input.addEventListener('keydown', onKeyDown as any);
|
|
27
|
-
if (autoSelect && value.toString().length) {
|
|
28
|
-
this.input.setSelectionRange(0, value.toString().length);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
onFocus(evt);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
private onBlur = (evt: React.FocusEvent) => {
|
|
35
|
-
const {onKeyDown, onBlur} = this.props;
|
|
36
|
-
if (this.input) this.input.removeEventListener('keydown', onKeyDown as any);
|
|
37
|
-
onBlur(evt);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
private getBaseColor = (trueBase: boolean = false): string => {
|
|
41
|
-
const themeColor = this.context.baseColor, {baseColor} = this.props;
|
|
42
|
-
let color: string;
|
|
43
|
-
if (baseColor) color = baseColor;
|
|
44
|
-
else color = themeColor;
|
|
45
|
-
if (colorIsWhite(color) && !trueBase) return this.getContrastColor(false);
|
|
46
|
-
return convertColor(color);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
private getContrastColor = (allowWhite: boolean = true): string => {
|
|
50
|
-
const base = this.getBaseColor(true);
|
|
51
|
-
if (colorIsWhite(base) && allowWhite) return base;
|
|
52
|
-
|
|
53
|
-
const themeColor = this.context.contrastColor, {contrastColor} = this.props;
|
|
54
|
-
let color: string;
|
|
55
|
-
if (contrastColor && contrastColor.length) color = contrastColor;
|
|
56
|
-
else color = themeColor;
|
|
57
|
-
return convertColor(color);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
private getBorderColor = (): string => {
|
|
61
|
-
const {isHovered, isFocused, disabled, error, borderColor} = this.props;
|
|
62
|
-
let color: string;
|
|
63
|
-
if (error) color = 'red';
|
|
64
|
-
else if (disabled) color = 'color-gray-4';
|
|
65
|
-
else if (isFocused) color = this.getBaseColor();
|
|
66
|
-
else if (isHovered) color = editColor(.3, this.getBaseColor());
|
|
67
|
-
else color = borderColor || this.context.borderColor || 'color-gray-3';
|
|
68
|
-
return convertColor(color);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
private getCurrentColor = (): string => {
|
|
72
|
-
const {isHovered, isFocused, disabled, error} = this.props;
|
|
73
|
-
let color: string;
|
|
74
|
-
if (error) color = 'red';
|
|
75
|
-
else if (disabled) color = 'color-gray-4';
|
|
76
|
-
else if (isFocused) color = this.getBaseColor();
|
|
77
|
-
else if (isHovered) color = editColor(.3, this.getBaseColor());
|
|
78
|
-
else color = 'color-gray-3';
|
|
79
|
-
return convertColor(color);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
private getContainerStyle = (): CSSProperties => ({
|
|
83
|
-
borderColor: this.getBorderColor(),
|
|
84
|
-
...this.props.containerStyle,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
private getLabelStyle = (): CSSProperties => ({
|
|
88
|
-
color: this.getCurrentColor(),
|
|
89
|
-
...this.props.labelStyle,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
private getInputStyle = (): CSSProperties => ({
|
|
93
|
-
...this.props.inputStyle,
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
private getInputProps = () => {
|
|
97
|
-
const {placeholder, inputProps, onChange, value, id, disabled, readOnly} = this.props;
|
|
98
|
-
return {
|
|
99
|
-
...inputProps,
|
|
100
|
-
className: classNames('dvr-simple-input', inputProps?.className),
|
|
101
|
-
ref: this.attachRef,
|
|
102
|
-
onBlur: this.onBlur,
|
|
103
|
-
onFocus: this.onFocus,
|
|
104
|
-
style: this.getInputStyle(),
|
|
105
|
-
placeholder,
|
|
106
|
-
onChange,
|
|
107
|
-
value,
|
|
108
|
-
id: `${id}-input`,
|
|
109
|
-
// type,
|
|
110
|
-
disabled,
|
|
111
|
-
readOnly,
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
private attachRef = (ref: HTMLInputElement | HTMLTextAreaElement | null) => {
|
|
116
|
-
this.input = ref;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
private getOrnament = (placement: ElementPosition): OrnamentShape | null => {
|
|
120
|
-
const {ornaments, children} = this.props;
|
|
121
|
-
if (ornaments !== undefined) {
|
|
122
|
-
if (Array.isArray(ornaments)) {
|
|
123
|
-
for (const orn of ornaments)
|
|
124
|
-
if (orn.placement === placement) return orn;
|
|
125
|
-
} else if (ornaments.placement === placement) return ornaments;
|
|
126
|
-
|
|
127
|
-
if (Array.isArray(children)) {
|
|
128
|
-
for (const child of children)
|
|
129
|
-
if (child && child.hasOwnProperty('placement') && (child as OrnamentShape).placement ===
|
|
130
|
-
placement) return child as OrnamentShape;
|
|
131
|
-
} else if (children && children.hasOwnProperty('placement') && (children as OrnamentShape).placement ===
|
|
132
|
-
placement) return children as OrnamentShape;
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
private renderOrnament = (placement: ElementPosition) => {
|
|
138
|
-
const {onClick, clearAble, value, onClear, disabled} = this.props;
|
|
139
|
-
let toRender: OrnamentShape | null = this.getOrnament(placement);
|
|
140
|
-
if (!toRender && placement === ElementPosition.RIGHT && clearAble && !disabled)
|
|
141
|
-
toRender = {
|
|
142
|
-
allowPropagation: false,
|
|
143
|
-
element: <AwesomeIcon name='eraser' onClick={onClear} className={classNames('dvr-simple-input-clear',
|
|
144
|
-
!value.toString().length && 'invis')}/>,
|
|
145
|
-
placement
|
|
146
|
-
};
|
|
147
|
-
if (!toRender) return null;
|
|
148
|
-
else
|
|
149
|
-
return (
|
|
150
|
-
<div className={classNames('dvr-simple-input-ornament', onClick !== undefined && 'clickable')}
|
|
151
|
-
onClick={toRender.allowPropagation ? onClick : stopPropagation}>
|
|
152
|
-
{toRender.element}
|
|
153
|
-
</div>
|
|
154
|
-
)
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
render = () => {
|
|
158
|
-
const {
|
|
159
|
-
className, label, labelClassName, onMouseEnter, onMouseLeave, area, onClick, fullWidth, error, errorClassName,
|
|
160
|
-
errorStyle, disabled, id
|
|
161
|
-
} = this.props;
|
|
162
|
-
return (
|
|
163
|
-
<div className={classNames('dvr-simple-input-container', fullWidth && 'full-width',
|
|
164
|
-
error !== null && 'error', disabled && 'disabled', className)}
|
|
165
|
-
style={this.getContainerStyle()} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}
|
|
166
|
-
onClick={onClick} id={id}>
|
|
167
|
-
<label className={classNames('dvr-simple-input-label', labelClassName)}
|
|
168
|
-
style={this.getLabelStyle()}>{label}</label>
|
|
169
|
-
{this.renderOrnament(ElementPosition.LEFT)}
|
|
170
|
-
{area ? <textarea {...this.getInputProps()}/> : <input {...this.getInputProps()}/>}
|
|
171
|
-
{this.renderOrnament(ElementPosition.RIGHT)}
|
|
172
|
-
{error !== null &&
|
|
173
|
-
<label className={classNames('dvr-simple-input-error', errorClassName)}
|
|
174
|
-
style={errorStyle}>{error}</label>}
|
|
175
|
-
</div>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@import '../../../style/common-variables';
|
|
6
|
-
|
|
7
|
-
.inputContainer {
|
|
8
|
-
position: relative;
|
|
9
|
-
width: 20rem;
|
|
10
|
-
max-width: 100%;
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
background-color: white;
|
|
14
|
-
box-sizing: border-box;
|
|
15
|
-
|
|
16
|
-
&.fullWidth {
|
|
17
|
-
width: 100%;
|
|
18
|
-
.inputFieldContainer{
|
|
19
|
-
width: 100%;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.inputFieldContainer {
|
|
24
|
-
display: flex;
|
|
25
|
-
align-items: center;
|
|
26
|
-
|
|
27
|
-
.inputOrnament {
|
|
28
|
-
max-height: 100%;
|
|
29
|
-
padding: 0 .5rem;
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
|
|
33
|
-
&.clickable {
|
|
34
|
-
cursor: pointer;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.input {
|
|
39
|
-
width: 100%;
|
|
40
|
-
flex: 1;
|
|
41
|
-
box-sizing: border-box;
|
|
42
|
-
border: none !important;
|
|
43
|
-
outline: none !important;
|
|
44
|
-
padding: .5rem;
|
|
45
|
-
font-size: 1rem;
|
|
46
|
-
|
|
47
|
-
&:disabled {
|
|
48
|
-
color: $color-gray-4 !important;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.clearButton {
|
|
53
|
-
font-size: .8rem;
|
|
54
|
-
color: $color-gray-5;
|
|
55
|
-
transition: color .2s ease-in-out;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
margin-right: .3rem;
|
|
58
|
-
padding: 0 .5rem;
|
|
59
|
-
|
|
60
|
-
&:hover {
|
|
61
|
-
color: red;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&.outlined {
|
|
67
|
-
@include borderRadius(.2rem);
|
|
68
|
-
border-width: 2px;
|
|
69
|
-
border-style: solid;
|
|
70
|
-
padding: .2rem;
|
|
71
|
-
position: relative;
|
|
72
|
-
transition: border-color .2s ease-in-out, margin-bottom .2s ease-in-out;
|
|
73
|
-
margin-top: .8rem;
|
|
74
|
-
margin-bottom: 0;
|
|
75
|
-
|
|
76
|
-
.label {
|
|
77
|
-
position: absolute;
|
|
78
|
-
background-color: white;
|
|
79
|
-
padding: .3rem .2rem;
|
|
80
|
-
left: .2rem;
|
|
81
|
-
top: -.9rem;
|
|
82
|
-
font-size: .7rem;
|
|
83
|
-
transition: top .2s ease-in-out, left .2s ease-in-out, font-size .2s ease-in-out, transform .2s ease-in-out, color .2s ease-in-out;
|
|
84
|
-
cursor: text;
|
|
85
|
-
user-select: none;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.input {
|
|
89
|
-
padding-left: .3rem;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.error {
|
|
93
|
-
position: absolute;
|
|
94
|
-
left: .4rem;
|
|
95
|
-
bottom: -1.4rem;
|
|
96
|
-
font-size: .9rem;
|
|
97
|
-
color: red;
|
|
98
|
-
pointer-events: none;
|
|
99
|
-
visibility: hidden;
|
|
100
|
-
opacity: 0;
|
|
101
|
-
transition: visibility .2s ease-in-out, opacity .2s ease-in-out;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
&:not(.focused) {
|
|
105
|
-
.label {
|
|
106
|
-
transition-delay: .2s;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
&:not(.filled) {
|
|
110
|
-
.label {
|
|
111
|
-
@include centerY;
|
|
112
|
-
|
|
113
|
-
&.multiLine {
|
|
114
|
-
top: calc(.2rem + 2px);
|
|
115
|
-
transform: none;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
font-size: .9rem;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
&.error {
|
|
124
|
-
margin-bottom: 2.4rem;
|
|
125
|
-
|
|
126
|
-
.error {
|
|
127
|
-
visibility: visible;
|
|
128
|
-
opacity: 1;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
&.disabled {
|
|
134
|
-
&, & .label, & .inputFieldContainer .input {
|
|
135
|
-
cursor: not-allowed;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
import React, {
|
|
5
|
-
ChangeEventHandler, CSSProperties, EventHandler, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler,
|
|
6
|
-
MouseEventHandler, PureComponent, ReactNode, TextareaHTMLAttributes
|
|
7
|
-
} from 'react';
|
|
8
|
-
import {assert, enterPressed} from "../../util/controlUtil";
|
|
9
|
-
import SimpleInput from "../simple/v2/simpleInputV2";
|
|
10
|
-
import {ControlVariant, ErrorType, OrnamentShape} from "../../util/interfaces";
|
|
11
|
-
import { generateComponentId } from '../../../..';
|
|
12
|
-
|
|
13
|
-
type HTMLProps = Omit<InputHTMLAttributes<any>, 'onChange' | 'step' | 'children'>;
|
|
14
|
-
|
|
15
|
-
export interface DVRInputControllerProps extends HTMLProps {
|
|
16
|
-
// Events
|
|
17
|
-
onChange: (value: string | number, evt: React.ChangeEvent) => void;
|
|
18
|
-
onEnter?: KeyboardEventHandler;
|
|
19
|
-
onFocus?: FocusEventHandler;
|
|
20
|
-
// Theme
|
|
21
|
-
variant: ControlVariant;
|
|
22
|
-
baseColor?: string;
|
|
23
|
-
contrastColor?: string;
|
|
24
|
-
// Classes
|
|
25
|
-
errorClassName: string;
|
|
26
|
-
inputContainerClassName: string;
|
|
27
|
-
labelClassName: string;
|
|
28
|
-
// Styles
|
|
29
|
-
containerStyle?: CSSProperties;
|
|
30
|
-
labelStyle?: CSSProperties;
|
|
31
|
-
errorStyle?: CSSProperties;
|
|
32
|
-
inputStyle?: CSSProperties;
|
|
33
|
-
// Other
|
|
34
|
-
error: ErrorType;
|
|
35
|
-
inputProps?: InputHTMLAttributes<any> & TextareaHTMLAttributes<any>;
|
|
36
|
-
ornaments?: OrnamentShape | OrnamentShape[];
|
|
37
|
-
area: boolean;
|
|
38
|
-
autoSelect: boolean;
|
|
39
|
-
autoFocus: boolean;
|
|
40
|
-
clearAble: boolean;
|
|
41
|
-
fullWidth: boolean;
|
|
42
|
-
defaultValue?: string | number;
|
|
43
|
-
label?: string | number;
|
|
44
|
-
value?: string | number;
|
|
45
|
-
step?: number;
|
|
46
|
-
unControlled?: boolean;
|
|
47
|
-
children?: ReactNode | ReactNode[] | OrnamentShape | OrnamentShape[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface DVRInputProps extends Omit<DVRInputControllerProps, 'value' | 'onChange'> {
|
|
51
|
-
// Events
|
|
52
|
-
onChange: ChangeEventHandler;
|
|
53
|
-
onFocus: FocusEventHandler;
|
|
54
|
-
onBlur: FocusEventHandler;
|
|
55
|
-
onClear: EventHandler<any>;
|
|
56
|
-
onMouseEnter: MouseEventHandler;
|
|
57
|
-
onMouseLeave: MouseEventHandler;
|
|
58
|
-
onKeyDown: KeyboardEventHandler;
|
|
59
|
-
onClick: MouseEventHandler;
|
|
60
|
-
// State
|
|
61
|
-
isFocused: boolean;
|
|
62
|
-
isHovered: boolean;
|
|
63
|
-
// Theme
|
|
64
|
-
variant: ControlVariant;
|
|
65
|
-
baseColor?: string;
|
|
66
|
-
contrastColor?: string;
|
|
67
|
-
borderColor?: string;
|
|
68
|
-
// Classes
|
|
69
|
-
errorClassName: string;
|
|
70
|
-
inputContainerClassName: string;
|
|
71
|
-
labelClassName: string;
|
|
72
|
-
// Styles
|
|
73
|
-
containerStyle?: CSSProperties;
|
|
74
|
-
labelStyle?: CSSProperties;
|
|
75
|
-
errorStyle?: CSSProperties;
|
|
76
|
-
inputStyle?: CSSProperties;
|
|
77
|
-
// Other
|
|
78
|
-
error: ErrorType;
|
|
79
|
-
inputProps?: InputHTMLAttributes<any>;
|
|
80
|
-
ornaments?: OrnamentShape | OrnamentShape[];
|
|
81
|
-
clearAble: boolean;
|
|
82
|
-
fullWidth: boolean;
|
|
83
|
-
label?: string | number;
|
|
84
|
-
value: string | number;
|
|
85
|
-
step?: number;
|
|
86
|
-
unControlled?: boolean;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const DefaultInputProps: Partial<DVRInputProps> = {
|
|
90
|
-
area: false,
|
|
91
|
-
clearAble: true,
|
|
92
|
-
disabled: false,
|
|
93
|
-
autoFocus: false,
|
|
94
|
-
autoSelect: false,
|
|
95
|
-
error: null,
|
|
96
|
-
errorClassName: '',
|
|
97
|
-
fullWidth: true,
|
|
98
|
-
className: '',
|
|
99
|
-
inputContainerClassName: '',
|
|
100
|
-
labelClassName: '',
|
|
101
|
-
readOnly: false,
|
|
102
|
-
type: 'text',
|
|
103
|
-
variant: ControlVariant.SIMPLE,
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
interface State {
|
|
107
|
-
isFocused: boolean;
|
|
108
|
-
isHovered: boolean;
|
|
109
|
-
value: string | number;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export default class InputControllerV2 extends PureComponent<DVRInputControllerProps, State> {
|
|
113
|
-
static defaultProps: Partial<DVRInputProps> = DefaultInputProps;
|
|
114
|
-
private readonly id: string;
|
|
115
|
-
|
|
116
|
-
private getValue = (props: DVRInputControllerProps = this.props): string | number => {
|
|
117
|
-
if (props.value !== undefined) return props.value;
|
|
118
|
-
if (props.defaultValue !== undefined) return props.defaultValue;
|
|
119
|
-
return '';
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private validateProps = (props: DVRInputControllerProps) => {
|
|
123
|
-
if (props.value === undefined && props.defaultValue === undefined)
|
|
124
|
-
return 'value and defaultValue cannot both be undefined.';
|
|
125
|
-
return null;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
constructor(props: DVRInputControllerProps) {
|
|
129
|
-
super(props);
|
|
130
|
-
const error = this.validateProps(props);
|
|
131
|
-
assert(error === null, error);
|
|
132
|
-
this.id = generateComponentId(props.id);
|
|
133
|
-
this.state = {
|
|
134
|
-
isFocused: false,
|
|
135
|
-
isHovered: false,
|
|
136
|
-
value: this.getValue(props),
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
onChange = (evt: React.ChangeEvent<any>) => {
|
|
141
|
-
const {onChange, type, step} = this.props, {value} = evt.target;
|
|
142
|
-
let finalValue: string | number = value;
|
|
143
|
-
if (type === 'number') {
|
|
144
|
-
if (step !== undefined) {
|
|
145
|
-
if (Number.isInteger(step)) finalValue = parseInt(finalValue as string);
|
|
146
|
-
else finalValue = parseFloat(finalValue as string);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
evt.persist();
|
|
150
|
-
this.setState({value: finalValue.toString()}, () => {
|
|
151
|
-
onChange(finalValue, evt);
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
onClear = (evt: any) => {
|
|
156
|
-
const {clearAble, onChange} = this.props;
|
|
157
|
-
if (clearAble) {
|
|
158
|
-
this.setState({value: ''}, () => {
|
|
159
|
-
onChange('', evt);
|
|
160
|
-
this.setInputFocus();
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
onFocus = (evt: React.FocusEvent<any>) => {
|
|
166
|
-
const {onFocus} = this.props;
|
|
167
|
-
this.setState({isFocused: true});
|
|
168
|
-
if (onFocus) onFocus(evt);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
onBlur = (evt: React.FocusEvent<any>) => {
|
|
172
|
-
const {onBlur} = this.props;
|
|
173
|
-
this.setState({isFocused: false});
|
|
174
|
-
if (onBlur) onBlur(evt);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
onClick = (evt: React.MouseEvent<any>) => {
|
|
178
|
-
const {onClick} = this.props, {isFocused} = this.state;
|
|
179
|
-
if (!isFocused) this.setInputFocus();
|
|
180
|
-
if (onClick) onClick(evt);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
onKeyDown = (evt: React.KeyboardEvent<any>) => {
|
|
184
|
-
const {onKeyDown, onEnter} = this.props;
|
|
185
|
-
if (onEnter && enterPressed(evt)) onEnter(evt);
|
|
186
|
-
else if (onKeyDown) onKeyDown(evt);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
onMouseEnter = (evt: React.MouseEvent<any>) => {
|
|
190
|
-
const {onMouseEnter} = this.props;
|
|
191
|
-
this.setState({isHovered: true});
|
|
192
|
-
if (onMouseEnter) onMouseEnter(evt);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
onMouseLeave = (evt: React.MouseEvent<any>) => {
|
|
196
|
-
const {onMouseLeave} = this.props;
|
|
197
|
-
this.setState({isHovered: false});
|
|
198
|
-
if (onMouseLeave) onMouseLeave(evt);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
getInput = (): HTMLInputElement | HTMLTextAreaElement | null => {
|
|
202
|
-
const input = document.getElementById(`${this.id}-input`);
|
|
203
|
-
if (input !== null) return (input as HTMLInputElement | HTMLTextAreaElement);
|
|
204
|
-
return null;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
getViewValue = (): string | number => {
|
|
208
|
-
const {value, unControlled} = this.props;
|
|
209
|
-
if(unControlled || value === undefined) return this.state.value;
|
|
210
|
-
return value;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
setInputFocus = (retryOnNull: boolean = true) => {
|
|
214
|
-
const input = this.getInput();
|
|
215
|
-
if (input === null && retryOnNull)
|
|
216
|
-
window.setTimeout(() => {
|
|
217
|
-
this.setInputFocus(false);
|
|
218
|
-
});
|
|
219
|
-
if (input !== null) {
|
|
220
|
-
input.focus();
|
|
221
|
-
this.setState({isFocused: true});
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
componentDidMount = () => {
|
|
226
|
-
if (this.props.autoFocus) this.setInputFocus();
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
render = () => {
|
|
230
|
-
const {variant, unControlled} = this.props, {isFocused, isHovered} = this.state;
|
|
231
|
-
const props = {
|
|
232
|
-
...this.props,
|
|
233
|
-
onChange: this.onChange,
|
|
234
|
-
onClear: this.onClear,
|
|
235
|
-
onFocus: this.onFocus,
|
|
236
|
-
onBlur: this.onBlur,
|
|
237
|
-
onClick: this.onClick,
|
|
238
|
-
onMouseEnter: this.onMouseEnter,
|
|
239
|
-
onMouseLeave: this.onMouseLeave,
|
|
240
|
-
onKeyDown: this.onKeyDown,
|
|
241
|
-
isFocused,
|
|
242
|
-
isHovered,
|
|
243
|
-
value: this.getViewValue(),
|
|
244
|
-
id: this.id,
|
|
245
|
-
unControlled,
|
|
246
|
-
}
|
|
247
|
-
if (variant === ControlVariant.SIMPLE)
|
|
248
|
-
return <SimpleInput {...props}>{this.props.children}</SimpleInput>
|
|
249
|
-
};
|
|
250
|
-
}
|