@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,46 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@import '../../../style/variables';
|
|
6
|
-
|
|
7
|
-
.snackbar {
|
|
8
|
-
@include backgroundShadow;
|
|
9
|
-
@include borderRadius(.2rem);
|
|
10
|
-
position: fixed;
|
|
11
|
-
left: 50%;
|
|
12
|
-
bottom: 1rem;
|
|
13
|
-
transition: transform .2s ease-in-out;
|
|
14
|
-
z-index: $z-index-dialog;
|
|
15
|
-
max-width: 30vw;
|
|
16
|
-
min-height: 2.5rem;
|
|
17
|
-
overflow-y: auto;
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
justify-content: center;
|
|
21
|
-
transform: translateY(calc(100% + 1rem)) translateX(-50%);
|
|
22
|
-
padding: .3rem 1rem;
|
|
23
|
-
|
|
24
|
-
&, * {
|
|
25
|
-
cursor: pointer;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&.active {
|
|
29
|
-
transform: translateY(0) translateX(-50%);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.snackBarText {
|
|
33
|
-
text-align: center;
|
|
34
|
-
user-select: none;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@include break-xs {
|
|
38
|
-
max-width: 90vw;
|
|
39
|
-
width: 90vw;
|
|
40
|
-
white-space: normal;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@include break-sm {
|
|
44
|
-
width: unset;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
import './style/dvrdSwitch.scss';
|
|
5
|
-
|
|
6
|
-
import classNames from 'classnames';
|
|
7
|
-
import React, {useContext} from 'react';
|
|
8
|
-
import {ControlContext} from "../util/controlContext";
|
|
9
|
-
import {convertColor} from "../util/colorUtil";
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
onChange: (value: boolean, evt: React.MouseEvent) => void;
|
|
13
|
-
value: boolean;
|
|
14
|
-
className?: string;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
activeColor?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default function DvrdSwitch(props: Props) {
|
|
20
|
-
const context = useContext(ControlContext),
|
|
21
|
-
{className, onChange, disabled, value, activeColor} = props;
|
|
22
|
-
|
|
23
|
-
function onToggle(evt: React.MouseEvent) {
|
|
24
|
-
if (!disabled)
|
|
25
|
-
onChange(!value, evt);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getTrackColor(): string {
|
|
29
|
-
let color: string;
|
|
30
|
-
if (disabled) color = 'color-gray-4';
|
|
31
|
-
else if (value) {
|
|
32
|
-
if (activeColor) color = activeColor;
|
|
33
|
-
else color = context.baseColor;
|
|
34
|
-
} else color = 'color-gray-7';
|
|
35
|
-
return convertColor(color);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getHandleColor(): string {
|
|
39
|
-
let color: string;
|
|
40
|
-
if (disabled) color = 'color-gray-3';
|
|
41
|
-
else color = context.contrastColor;
|
|
42
|
-
return convertColor(color);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div className={classNames('dvrd-switch', value && 'active', disabled && 'disabled', className)}
|
|
47
|
-
onClick={onToggle}>
|
|
48
|
-
<div className='track' style={{backgroundColor: getTrackColor()}}>
|
|
49
|
-
<div className='handle' style={{backgroundColor: getHandleColor()}}/>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@import '../../../style/variables';
|
|
6
|
-
|
|
7
|
-
.dvrd-switch {
|
|
8
|
-
$track-height: 14px;
|
|
9
|
-
$handle-size: 18px;
|
|
10
|
-
|
|
11
|
-
.track {
|
|
12
|
-
width: $handle-size * 1.3;
|
|
13
|
-
border-radius: 1rem;
|
|
14
|
-
height: $track-height;
|
|
15
|
-
position: relative;
|
|
16
|
-
|
|
17
|
-
.handle {
|
|
18
|
-
@include backgroundShadow;
|
|
19
|
-
position: absolute;
|
|
20
|
-
left: 0;
|
|
21
|
-
top: 50%;
|
|
22
|
-
transform: translateX(-9px) translateY(-50%);
|
|
23
|
-
border-radius: 100%;
|
|
24
|
-
width: $handle-size;
|
|
25
|
-
height: $handle-size;
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
transition: transform .2s ease-in-out, left .2s ease-in-out;
|
|
28
|
-
will-change: left;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&.active {
|
|
33
|
-
.track {
|
|
34
|
-
.handle {
|
|
35
|
-
left: 100%;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&.disabled {
|
|
41
|
-
.track {
|
|
42
|
-
.handle {
|
|
43
|
-
cursor: default;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@import '../../../style/variables';
|
|
6
|
-
|
|
7
|
-
.switchContainer {
|
|
8
|
-
display: flex;
|
|
9
|
-
padding: 1rem 0;
|
|
10
|
-
align-items: center;
|
|
11
|
-
|
|
12
|
-
.main-label {
|
|
13
|
-
font-size: .9rem;
|
|
14
|
-
color: $color-gray-5;
|
|
15
|
-
//margin-right: .5rem;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.label {
|
|
19
|
-
font-size: .9rem;
|
|
20
|
-
color: $color-gray-5;
|
|
21
|
-
|
|
22
|
-
&.left {
|
|
23
|
-
margin-right: .7rem;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&.right {
|
|
27
|
-
margin-left: .7rem;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.switch-track-container {
|
|
32
|
-
@include borderRadius(1rem);
|
|
33
|
-
display: flex;
|
|
34
|
-
position: relative;
|
|
35
|
-
width: 35px;
|
|
36
|
-
height: 1.2rem;
|
|
37
|
-
cursor: pointer;
|
|
38
|
-
|
|
39
|
-
.track {
|
|
40
|
-
border-radius: inherit;
|
|
41
|
-
cursor: inherit;
|
|
42
|
-
flex: 1;
|
|
43
|
-
height: inherit;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.switch {
|
|
47
|
-
@include centerY;
|
|
48
|
-
box-shadow: 0 1px 3px 0 rgba(0,0,0,0.2), 0 1px 1px 0 rgba(0,0,0,0.14), 0 2px 1px -1px rgba(0,0,0,0.12);
|
|
49
|
-
border-radius: 50%;
|
|
50
|
-
position: absolute;
|
|
51
|
-
left: -5%;
|
|
52
|
-
width: 20px;
|
|
53
|
-
height: 20px;
|
|
54
|
-
transition: transform .2s ease-in-out, background-color .2s ease, left .2s ease-in-out;
|
|
55
|
-
|
|
56
|
-
&.on {
|
|
57
|
-
left: 105%;
|
|
58
|
-
transform: translate(-100%, -50%);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&.lp {
|
|
64
|
-
padding: 2rem 0;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&.sp {
|
|
68
|
-
padding: .8rem 0;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
&.disabled {
|
|
72
|
-
.switch-track-container {
|
|
73
|
-
cursor: not-allowed;
|
|
74
|
-
|
|
75
|
-
.track {
|
|
76
|
-
background-color: $color-gray-7 !important;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.switch {
|
|
80
|
-
background-color: $color-gray-4 !important;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
package/src/js/switch/switch.tsx
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import './style/switch.scss';
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import {isNotNull} from "../util/controlUtil";
|
|
10
|
-
import {convertColor, editColor} from "../util/colorUtil";
|
|
11
|
-
|
|
12
|
-
interface SwitchProps {
|
|
13
|
-
onChange: any,
|
|
14
|
-
onMouseEnter: any,
|
|
15
|
-
onMouseLeave: any,
|
|
16
|
-
value: boolean,
|
|
17
|
-
labels: string[],
|
|
18
|
-
baseColor: string,
|
|
19
|
-
trackColor: string,
|
|
20
|
-
offColor: string,
|
|
21
|
-
id: string,
|
|
22
|
-
containerClass: string,
|
|
23
|
-
labelClass: string,
|
|
24
|
-
switchClass: string,
|
|
25
|
-
trackClass: string,
|
|
26
|
-
mainLabelClass: string;
|
|
27
|
-
padding: 'small' | 'standard' | 'large',
|
|
28
|
-
disabled: boolean,
|
|
29
|
-
isHovered: boolean,
|
|
30
|
-
label: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class Switch extends React.Component<SwitchProps> {
|
|
34
|
-
getContainerClass = (): string => {
|
|
35
|
-
const {containerClass, disabled, padding} = this.props, classes = ['switchContainer'];
|
|
36
|
-
if (disabled) classes.push('disabled');
|
|
37
|
-
|
|
38
|
-
if (padding === 'small') classes.push('sp');
|
|
39
|
-
else if (padding === 'large') classes.push('lp');
|
|
40
|
-
|
|
41
|
-
classes.push(containerClass);
|
|
42
|
-
return classNames(classes);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
getLabelClass = (position: 'left' | 'right'): string => {
|
|
46
|
-
const {labelClass} = this.props;
|
|
47
|
-
return classNames('label', position, labelClass);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
getSwitchClass = (): string => {
|
|
51
|
-
const {switchClass, value} = this.props;
|
|
52
|
-
return classNames('switch', value && 'on', switchClass);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
getTrackClass = (): string => {
|
|
56
|
-
const {trackClass} = this.props;
|
|
57
|
-
return classNames('track', trackClass);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
getSwitchStyle = (): object => {
|
|
61
|
-
const {baseColor, isHovered, value, offColor} = this.props;
|
|
62
|
-
let color;
|
|
63
|
-
if (!value && isNotNull(offColor)) color = convertColor(offColor);
|
|
64
|
-
else {
|
|
65
|
-
color = convertColor(baseColor);
|
|
66
|
-
if (isHovered) color = editColor(-.2, color);
|
|
67
|
-
}
|
|
68
|
-
return {backgroundColor: color};
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
getTrackStyle = (): object => {
|
|
72
|
-
const {trackColor} = this.props;
|
|
73
|
-
return {backgroundColor: convertColor(trackColor)};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
getLabel = (position: 'left' | 'right'): string | null => {
|
|
77
|
-
const {labels} = this.props, positions: { [index: string]: number } = {left: 0, right: 1};
|
|
78
|
-
if (!labels.length || labels.length <= positions[position]) return null;
|
|
79
|
-
return labels[positions[position]];
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
renderMainLabel = () => {
|
|
83
|
-
const {label, mainLabelClass} = this.props;
|
|
84
|
-
if (!label.length) return null;
|
|
85
|
-
return <label className={classNames('main-label', mainLabelClass)}>{label}: </label>
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
renderLabel = (position: 'left' | 'right'): React.ReactNode => {
|
|
89
|
-
const label = this.getLabel(position);
|
|
90
|
-
if (label === null) return null;
|
|
91
|
-
return <label className={this.getLabelClass(position)}>{label}</label>;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
renderSwitch = (): React.ReactNode => {
|
|
95
|
-
const {onChange, onMouseEnter, onMouseLeave} = this.props;
|
|
96
|
-
return (
|
|
97
|
-
<div className='switch-track-container' onClick={onChange} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
|
|
98
|
-
<div className={this.getTrackClass()} style={this.getTrackStyle()}/>
|
|
99
|
-
<div className={this.getSwitchClass()} style={this.getSwitchStyle()}/>
|
|
100
|
-
</div>
|
|
101
|
-
)
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
render = () => {
|
|
105
|
-
const {id} = this.props;
|
|
106
|
-
return (
|
|
107
|
-
<div className={this.getContainerClass()} id={id}>
|
|
108
|
-
{this.renderMainLabel()}
|
|
109
|
-
{this.renderLabel('left')}
|
|
110
|
-
{this.renderSwitch()}
|
|
111
|
-
{this.renderLabel('right')}
|
|
112
|
-
</div>
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import {Switch} from "./switch";
|
|
7
|
-
import {ControlContext} from "../util/controlContext";
|
|
8
|
-
import {generateComponentId} from '../../..';
|
|
9
|
-
|
|
10
|
-
interface SwitchProps {
|
|
11
|
-
onChange: Function,
|
|
12
|
-
onMouseEnter?: Function,
|
|
13
|
-
onMouseLeave?: Function,
|
|
14
|
-
value: boolean,
|
|
15
|
-
labels: string[],
|
|
16
|
-
mainLabel: string;
|
|
17
|
-
baseColor?: string,
|
|
18
|
-
trackColor: string,
|
|
19
|
-
offColor: string,
|
|
20
|
-
containerClass: string,
|
|
21
|
-
labelClass: string,
|
|
22
|
-
switchClass: string,
|
|
23
|
-
trackClass: string,
|
|
24
|
-
mainLabelClass: string;
|
|
25
|
-
id?: string,
|
|
26
|
-
padding: 'small' | 'standard' | 'large',
|
|
27
|
-
disabled: boolean,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
interface SwitchState {
|
|
31
|
-
isHovered: boolean,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// noinspection JSUnusedGlobalSymbols
|
|
35
|
-
export default class SwitchController extends React.Component<SwitchProps, SwitchState> {
|
|
36
|
-
declare context: React.ContextType<typeof ControlContext>
|
|
37
|
-
static contextType = ControlContext;
|
|
38
|
-
|
|
39
|
-
static defaultProps = {
|
|
40
|
-
labels: [],
|
|
41
|
-
trackColor: 'color-gray-4',
|
|
42
|
-
offColor: '',
|
|
43
|
-
containerClass: '',
|
|
44
|
-
labelClass: '',
|
|
45
|
-
switchClass: '',
|
|
46
|
-
trackClass: '',
|
|
47
|
-
mainLabelClass: '',
|
|
48
|
-
padding: 'standard',
|
|
49
|
-
disabled: false,
|
|
50
|
-
mainLabel: '',
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
state = {
|
|
54
|
-
isHovered: false,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
private id: string = generateComponentId(this.props.id);
|
|
58
|
-
|
|
59
|
-
onChange = (evt: any) => {
|
|
60
|
-
const {value, onChange, disabled} = this.props;
|
|
61
|
-
if (!disabled)
|
|
62
|
-
onChange(!value, evt);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
onMouseEnter = (evt: any) => {
|
|
66
|
-
const {onMouseEnter} = this.props;
|
|
67
|
-
this.setState({isHovered: true});
|
|
68
|
-
if (onMouseEnter !== undefined && onMouseEnter !== null)
|
|
69
|
-
onMouseEnter(evt);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
onMouseLeave = (evt: any) => {
|
|
73
|
-
const {onMouseLeave} = this.props;
|
|
74
|
-
this.setState({isHovered: false});
|
|
75
|
-
if (onMouseLeave !== undefined && onMouseLeave !== null)
|
|
76
|
-
onMouseLeave(evt);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
getBaseColor = (): string => {
|
|
80
|
-
const {baseColor} = this.props;
|
|
81
|
-
if (baseColor !== undefined && baseColor !== null) return baseColor;
|
|
82
|
-
// noinspection JSDeprecatedSymbols
|
|
83
|
-
return this.context.baseColor;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
render = () => {
|
|
87
|
-
const {
|
|
88
|
-
value, labels, trackColor, offColor, containerClass, labelClass, trackClass, switchClass,
|
|
89
|
-
padding, disabled, mainLabel, mainLabelClass
|
|
90
|
-
} = this.props, {isHovered} = this.state;
|
|
91
|
-
return <Switch onChange={this.onChange} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}
|
|
92
|
-
value={value} labels={labels} baseColor={this.getBaseColor()} trackColor={trackColor}
|
|
93
|
-
offColor={offColor} id={this.id} containerClass={containerClass} labelClass={labelClass}
|
|
94
|
-
switchClass={switchClass} trackClass={trackClass} padding={padding} disabled={disabled}
|
|
95
|
-
isHovered={isHovered} label={mainLabel} mainLabelClass={mainLabelClass}/>
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
import './style/dvrdInput.scss';
|
|
5
|
-
|
|
6
|
-
import React, {
|
|
7
|
-
ChangeEventHandler, CSSProperties, FocusEventHandler, InputHTMLAttributes, KeyboardEventHandler, MouseEventHandler,
|
|
8
|
-
PureComponent
|
|
9
|
-
} from 'react';
|
|
10
|
-
import classNames from "classnames";
|
|
11
|
-
import {ElementPosition, ErrorType, OrnamentShape} from '../util/interfaces';
|
|
12
|
-
import AwesomeIcon from '../icon/awesomeIcon';
|
|
13
|
-
import {directTimeout} from '../util/componentUtil';
|
|
14
|
-
import {ControlContext} from "../util/controlContext";
|
|
15
|
-
|
|
16
|
-
interface Props {
|
|
17
|
-
onChange: ChangeEventHandler;
|
|
18
|
-
onFocus?: FocusEventHandler;
|
|
19
|
-
onBlur?: FocusEventHandler;
|
|
20
|
-
onKeyDown: KeyboardEventHandler;
|
|
21
|
-
onClearInput?: MouseEventHandler;
|
|
22
|
-
value: string | number;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
autoFocus?: boolean;
|
|
25
|
-
autoSelect?: boolean;
|
|
26
|
-
label?: string;
|
|
27
|
-
ornaments?: OrnamentShape | OrnamentShape[];
|
|
28
|
-
inputProps?: InputHTMLAttributes<any>;
|
|
29
|
-
className?: string;
|
|
30
|
-
inputClassName?: string;
|
|
31
|
-
labelClassName?: string;
|
|
32
|
-
ornamentClassName?: string;
|
|
33
|
-
errorClassName?: string;
|
|
34
|
-
error?: ErrorType;
|
|
35
|
-
id: string;
|
|
36
|
-
fullWidth?: boolean;
|
|
37
|
-
area?: boolean;
|
|
38
|
-
noResize?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface State {
|
|
42
|
-
active: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default class DvrdInput extends PureComponent<Props, State> {
|
|
46
|
-
static contextType = ControlContext;
|
|
47
|
-
private input: HTMLInputElement | HTMLTextAreaElement;
|
|
48
|
-
|
|
49
|
-
state: State = {
|
|
50
|
-
active: this.props.autoFocus === true,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
onClickElement = (evt: React.MouseEvent) => {
|
|
54
|
-
evt.stopPropagation();
|
|
55
|
-
this.focusInput();
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
onFocusInput = (evt: React.FocusEvent) => {
|
|
59
|
-
const {disabled, onFocus, autoSelect, value} = this.props;
|
|
60
|
-
if (!disabled) {
|
|
61
|
-
this.setState({active: true});
|
|
62
|
-
if (autoSelect) {
|
|
63
|
-
this.input.selectionStart = 0;
|
|
64
|
-
this.input.selectionEnd = value.toString().length;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (onFocus)
|
|
68
|
-
onFocus(evt);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
onBlurInput = (evt: React.FocusEvent) => {
|
|
72
|
-
const {disabled, onBlur} = this.props;
|
|
73
|
-
if (!disabled) this.setState({active: false});
|
|
74
|
-
if (onBlur)
|
|
75
|
-
onBlur(evt);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
hasError = (): boolean => this.props.error !== undefined && this.props.error !== null;
|
|
79
|
-
|
|
80
|
-
getContentStyle = (): CSSProperties => {
|
|
81
|
-
const style: CSSProperties = {gridTemplateColumns: '1fr'}, {ornaments, onClearInput} = this.props;
|
|
82
|
-
if (!ornaments || (Array.isArray(ornaments) && !ornaments.length)) style.gridTemplateColumns = '1fr';
|
|
83
|
-
let hasLeft: boolean = false, hasRight: boolean = onClearInput !== undefined;
|
|
84
|
-
if (Array.isArray(ornaments))
|
|
85
|
-
for (const ornament of ornaments) {
|
|
86
|
-
if (!ornament.placement || ornament.placement === ElementPosition.LEFT) hasLeft = true;
|
|
87
|
-
else if (ornament.placement === ElementPosition.RIGHT) hasRight = true;
|
|
88
|
-
if (hasLeft && hasRight) break;
|
|
89
|
-
}
|
|
90
|
-
else if (ornaments) {
|
|
91
|
-
hasLeft = !ornaments.placement || ornaments.placement === ElementPosition.LEFT;
|
|
92
|
-
hasRight = ornaments.placement === ElementPosition.RIGHT;
|
|
93
|
-
}
|
|
94
|
-
let columns: string = '1fr';
|
|
95
|
-
let paddingLeft: string = '';
|
|
96
|
-
let paddingRight: string = '';
|
|
97
|
-
if (hasRight) {
|
|
98
|
-
columns = `${columns} fit-content(100%)`
|
|
99
|
-
paddingRight = '.75rem';
|
|
100
|
-
}
|
|
101
|
-
if (hasLeft) {
|
|
102
|
-
columns = `fit-content(100%) ${columns}`;
|
|
103
|
-
paddingLeft = '.75rem';
|
|
104
|
-
}
|
|
105
|
-
style.gridTemplateColumns = columns;
|
|
106
|
-
style.paddingRight = paddingRight;
|
|
107
|
-
style.paddingLeft = paddingLeft;
|
|
108
|
-
return style;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
focusInput = (retry: boolean = false) => {
|
|
112
|
-
if (this.input) this.input.focus();
|
|
113
|
-
else if (retry) directTimeout(this.focusInput);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
renderLabel = () => {
|
|
117
|
-
const {label, labelClassName} = this.props;
|
|
118
|
-
if (!label) return null;
|
|
119
|
-
return <label className={classNames('dvrd-input-label', labelClassName)}
|
|
120
|
-
onClick={this.onClickElement}>{label}</label>
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
renderInput = () => {
|
|
124
|
-
const {value, onChange, onKeyDown, disabled, inputProps, inputClassName, id, area, noResize} = this.props,
|
|
125
|
-
elementProps = {
|
|
126
|
-
...inputProps,
|
|
127
|
-
value,
|
|
128
|
-
onChange,
|
|
129
|
-
onFocus: this.onFocusInput,
|
|
130
|
-
onBlur: this.onBlurInput,
|
|
131
|
-
onKeyDown,
|
|
132
|
-
disabled,
|
|
133
|
-
className: classNames('dvrd-input', inputClassName, noResize && 'no-resize'),
|
|
134
|
-
id: `${id}-input`,
|
|
135
|
-
ref: (ref: HTMLInputElement & HTMLTextAreaElement) => {
|
|
136
|
-
this.input = ref
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
if (area) return <textarea {...elementProps}/>;
|
|
140
|
-
return <input {...elementProps}/>
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
renderLeftOrnament = () => {
|
|
144
|
-
const {ornaments} = this.props;
|
|
145
|
-
if (!ornaments || (Array.isArray(ornaments) && !ornaments.length)) return null;
|
|
146
|
-
if (Array.isArray(ornaments)) {
|
|
147
|
-
for (const ornament of ornaments) {
|
|
148
|
-
if (!ornament.placement || ornament.placement === ElementPosition.LEFT)
|
|
149
|
-
return this.renderOrnament(ornament);
|
|
150
|
-
}
|
|
151
|
-
} else if (!ornaments.placement || ornaments.placement === ElementPosition.LEFT)
|
|
152
|
-
return this.renderOrnament(ornaments);
|
|
153
|
-
return null;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
renderRightOrnament = () => {
|
|
157
|
-
const {ornaments, onClearInput, value} = this.props;
|
|
158
|
-
if (onClearInput && value) return this.renderOrnament({
|
|
159
|
-
element: <AwesomeIcon onClick={onClearInput} name='backspace' className='clear-btn'/>,
|
|
160
|
-
placement: ElementPosition.RIGHT
|
|
161
|
-
});
|
|
162
|
-
if (!ornaments || (Array.isArray(ornaments) && !ornaments.length)) return null;
|
|
163
|
-
if (Array.isArray(ornaments)) {
|
|
164
|
-
for (const ornament of ornaments) {
|
|
165
|
-
if (ornament.placement === ElementPosition.RIGHT)
|
|
166
|
-
return this.renderOrnament(ornament);
|
|
167
|
-
}
|
|
168
|
-
} else if (ornaments.placement === ElementPosition.RIGHT)
|
|
169
|
-
return this.renderOrnament(ornaments);
|
|
170
|
-
return null;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
renderOrnament = (ornament: OrnamentShape) => {
|
|
174
|
-
const {ornamentClassName} = this.props;
|
|
175
|
-
if (typeof ornament.element === 'string')
|
|
176
|
-
return <span className={classNames('dvrd-input-ornament', ornamentClassName)}
|
|
177
|
-
onClick={this.onClickElement}>{ornament.element}</span>;
|
|
178
|
-
else return React.cloneElement(ornament.element, {
|
|
179
|
-
className: classNames(ornament.element.props.className, ornamentClassName),
|
|
180
|
-
onClick: (evt: React.MouseEvent) => {
|
|
181
|
-
this.onClickElement(evt);
|
|
182
|
-
if (React.isValidElement(ornament.element))
|
|
183
|
-
if (ornament.element.props.onClick) ornament.element.props.onClick(evt);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
renderError = () => {
|
|
189
|
-
const {error, errorClassName} = this.props;
|
|
190
|
-
return <span className={classNames('dvrd-input-error', errorClassName)}>{error}</span>
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
componentDidUpdate = (prevProps: Props) => {
|
|
194
|
-
if (this.props.autoFocus && !prevProps.autoFocus) this.focusInput(true);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
componentDidMount = () => {
|
|
198
|
-
if (this.props.autoFocus) this.focusInput(true);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
render = () => {
|
|
202
|
-
const {disabled, className, id, fullWidth} = this.props, {active} = this.state;
|
|
203
|
-
return (
|
|
204
|
-
<div onClick={this.onClickElement} id={id}
|
|
205
|
-
className={classNames('dvrd-input-container', disabled && 'disabled', this.hasError() && 'error',
|
|
206
|
-
active && 'active', fullWidth && 'full', className)}>
|
|
207
|
-
{this.renderLabel()}
|
|
208
|
-
<div className='content-container' style={this.getContentStyle()}>
|
|
209
|
-
{this.renderLeftOrnament()}
|
|
210
|
-
{this.renderInput()}
|
|
211
|
-
{this.renderRightOrnament()}
|
|
212
|
-
</div>
|
|
213
|
-
{this.renderError()}
|
|
214
|
-
</div>
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
}
|