@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,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React, {PureComponent, ReactElement} from 'react';
|
|
6
|
+
import DVRCarousel from "./DVRCarousel";
|
|
7
|
+
import {debug} from "../../..";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
children: ReactElement[];
|
|
11
|
+
showControls: boolean;
|
|
12
|
+
infinite: boolean;
|
|
13
|
+
lazy: boolean;
|
|
14
|
+
autoPlay: boolean;
|
|
15
|
+
variableWidth: boolean;
|
|
16
|
+
visibleItems?: number;
|
|
17
|
+
slidePer: number;
|
|
18
|
+
autoPlayInterval: number;
|
|
19
|
+
className: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface State {
|
|
23
|
+
currentIndex: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default class DVRCarouselController extends PureComponent<Props, State> {
|
|
27
|
+
static defaultProps = {
|
|
28
|
+
showControls: true,
|
|
29
|
+
infinite: true,
|
|
30
|
+
lazy: true,
|
|
31
|
+
autoPlay: false,
|
|
32
|
+
variableWidth: true,
|
|
33
|
+
autoPlayInterval: 3000,
|
|
34
|
+
className: '',
|
|
35
|
+
slidePer: 1,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
state: State = {
|
|
39
|
+
currentIndex: 0,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
private playTimeout: number | null = null;
|
|
43
|
+
|
|
44
|
+
onClickNext = () => {
|
|
45
|
+
const {children, slidePer} = this.props, {currentIndex} = this.state;
|
|
46
|
+
let nextIndex = currentIndex + slidePer;
|
|
47
|
+
if (currentIndex + this.getActualVisibleItems() > children.length) nextIndex = 0;
|
|
48
|
+
this.setState({currentIndex: nextIndex});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
onClickPrev = () => {
|
|
52
|
+
const {slidePer} = this.props, {currentIndex} = this.state;
|
|
53
|
+
this.setState({currentIndex: Math.max(0, currentIndex - slidePer)});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
getActualVisibleItems = (): number => {
|
|
57
|
+
const {visibleItems, children} = this.props;
|
|
58
|
+
return visibleItems === undefined ? Math.min(children.length, 3) : visibleItems;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
play = () => {
|
|
62
|
+
const {autoPlayInterval} = this.props;
|
|
63
|
+
this.playTimeout = window.setTimeout(this.slide, autoPlayInterval);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
stop = () => {
|
|
67
|
+
if (this.playTimeout !== null) {
|
|
68
|
+
window.clearTimeout(this.playTimeout);
|
|
69
|
+
this.playTimeout = null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
slide = () => {
|
|
74
|
+
this.onClickNext();
|
|
75
|
+
if (this.props.autoPlay) this.play();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
componentDidMount = () => {
|
|
79
|
+
if (this.props.autoPlay) this.play();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
componentWillUnmount = () => {
|
|
83
|
+
this.stop();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
render = () => {
|
|
87
|
+
const {currentIndex} = this.state, {variableWidth, lazy, className, showControls, infinite, children} = this.props;
|
|
88
|
+
return (
|
|
89
|
+
<DVRCarousel onClickNext={this.onClickNext} onClickPrev={this.onClickPrev} currentIndex={currentIndex}
|
|
90
|
+
visibleItems={this.getActualVisibleItems()} lazy={lazy} className={className}
|
|
91
|
+
showControls={showControls} variableWidth={variableWidth}
|
|
92
|
+
infinite={infinite}>{children}</DVRCarousel>
|
|
93
|
+
)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@import '../../../style/variables';
|
|
6
|
+
|
|
7
|
+
.dvr-carousel {
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: 2rem auto 2rem;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-items: center;
|
|
12
|
+
|
|
13
|
+
.carousel-control {
|
|
14
|
+
color: $color-gray-5;
|
|
15
|
+
font-size: 1rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.carousel-items-container {
|
|
19
|
+
//transition: width .2s ease-in-out;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
|
|
22
|
+
.items-container {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
transition: transform .2s ease-in-out;
|
|
26
|
+
|
|
27
|
+
.carousel-item {
|
|
28
|
+
padding: .5rem;
|
|
29
|
+
transition: visibility;
|
|
30
|
+
|
|
31
|
+
&.hidden {
|
|
32
|
+
visibility: hidden;
|
|
33
|
+
transition-delay: .2s;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import './style/checkbox.scss';
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import {MouseEventHandler} from 'react';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import AwesomeIcon from '../icon/awesomeIcon';
|
|
11
|
+
import {findDarkestColor, convertColor, editColor} from "../util/colorUtil";
|
|
12
|
+
import {isNotNull, isNull} from "../util/controlUtil";
|
|
13
|
+
import {ControlContext} from "../util/controlContext";
|
|
14
|
+
import { IconName } from '@fortawesome/fontawesome-svg-core';
|
|
15
|
+
|
|
16
|
+
interface CheckboxProps {
|
|
17
|
+
onCheck: MouseEventHandler;
|
|
18
|
+
onMouseEnter: any,
|
|
19
|
+
onMouseLeave: any,
|
|
20
|
+
checked: boolean,
|
|
21
|
+
disabled: boolean,
|
|
22
|
+
isHovered: boolean,
|
|
23
|
+
label: string,
|
|
24
|
+
labelPosition: 'left' | 'right',
|
|
25
|
+
containerClass: string,
|
|
26
|
+
labelClass: string,
|
|
27
|
+
checkboxClass: string,
|
|
28
|
+
checkClass: string,
|
|
29
|
+
errorClass: string,
|
|
30
|
+
id: string,
|
|
31
|
+
error: string | null,
|
|
32
|
+
checkIcon: IconName | React.ReactNode
|
|
33
|
+
baseColor?: string;
|
|
34
|
+
contrastColor?: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
useDarkestColor: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class Checkbox extends React.Component<CheckboxProps> {
|
|
40
|
+
declare context: React.ContextType<typeof ControlContext>;
|
|
41
|
+
static contextType = ControlContext;
|
|
42
|
+
|
|
43
|
+
getContainerClass = (): string => {
|
|
44
|
+
const {disabled, containerClass, error, label} = this.props, classes = ['checkboxContainer'];
|
|
45
|
+
|
|
46
|
+
if (disabled) classes.push('disabled');
|
|
47
|
+
if (isNotNull(error)) classes.push('error');
|
|
48
|
+
if (!label.length) classes.push('no-label');
|
|
49
|
+
|
|
50
|
+
classes.push(containerClass);
|
|
51
|
+
return classNames(classes);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
getLabelClass = (position: 'left' | 'right'): string => {
|
|
55
|
+
const {disabled, labelClass, error} = this.props, classes = ['checkboxLabel', position];
|
|
56
|
+
if (disabled) classes.push('disabled');
|
|
57
|
+
if (isNotNull(error)) classes.push('error');
|
|
58
|
+
classes.push(labelClass);
|
|
59
|
+
return classNames(classes);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
getCheckboxClass = (): string => {
|
|
63
|
+
const {disabled, checkboxClass} = this.props, classes = ['checkbox'];
|
|
64
|
+
if (disabled) classes.push('disabled');
|
|
65
|
+
classes.push(checkboxClass);
|
|
66
|
+
return classNames(classes);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
getCheckClass = (): string => {
|
|
70
|
+
const {disabled, checkClass, checked} = this.props, classes = ['checkbox-check'];
|
|
71
|
+
if (disabled) classes.push('disabled');
|
|
72
|
+
if (checked) classes.push('checked');
|
|
73
|
+
classes.push(checkClass);
|
|
74
|
+
return classNames(classes);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
getCheckboxStyle = (): object => {
|
|
78
|
+
const {isHovered, error, disabled, useDarkestColor} = this.props;
|
|
79
|
+
let color: string;
|
|
80
|
+
if (isNotNull(error)) color = 'red';
|
|
81
|
+
else if (disabled) color = 'color-gray-4';
|
|
82
|
+
else {
|
|
83
|
+
if (useDarkestColor)
|
|
84
|
+
color = findDarkestColor(this.getBaseColor(), this.getContrastColor());
|
|
85
|
+
else color = this.getBaseColor();
|
|
86
|
+
if (isHovered) color = editColor(-.2, color);
|
|
87
|
+
}
|
|
88
|
+
return {borderColor: convertColor(color)};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
getCheckStyle = (): object => {
|
|
92
|
+
const {error, disabled, useDarkestColor} = this.props;
|
|
93
|
+
let color: string;
|
|
94
|
+
if (isNotNull(error)) color = 'red';
|
|
95
|
+
else if (disabled) color = 'color-gray-4';
|
|
96
|
+
else if (useDarkestColor) color = findDarkestColor(this.getBaseColor(), this.getContrastColor());
|
|
97
|
+
else color = this.getBaseColor();
|
|
98
|
+
return {color: convertColor(color)};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
getBaseColor = (): string => convertColor(this.props.baseColor || this.context.baseColor);
|
|
102
|
+
getContrastColor = (): string => convertColor(this.props.contrastColor || this.context.contrastColor);
|
|
103
|
+
|
|
104
|
+
getMainColor = () => this.props.useDarkestColor ? findDarkestColor(this.getBaseColor(), this.getContrastColor()) : this.getBaseColor();
|
|
105
|
+
|
|
106
|
+
renderLabel = (position: 'left' | 'right'): React.ReactNode => {
|
|
107
|
+
const {label, labelPosition} = this.props;
|
|
108
|
+
if (isNull(label) || labelPosition !== position) return null;
|
|
109
|
+
return <label className={this.getLabelClass(position)}>{label}</label>
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
renderCheckbox = (): React.ReactNode => {
|
|
113
|
+
return (
|
|
114
|
+
<div className={this.getCheckboxClass()} style={this.getCheckboxStyle()}>
|
|
115
|
+
<div className='ripple' style={{backgroundColor: this.getMainColor()}}/>
|
|
116
|
+
{this.renderCheck()}
|
|
117
|
+
</div>
|
|
118
|
+
)
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
renderCheck = () => {
|
|
122
|
+
const {checkIcon} = this.props;
|
|
123
|
+
if (React.isValidElement(checkIcon)) return React.cloneElement((checkIcon as React.ReactElement), {
|
|
124
|
+
className: classNames(checkIcon.props.className, this.getCheckClass()),
|
|
125
|
+
style: {...checkIcon.props.style, ...this.getCheckStyle()}
|
|
126
|
+
});
|
|
127
|
+
const checkName: IconName = typeof checkIcon === 'string' ? checkIcon as IconName : 'check';
|
|
128
|
+
return <AwesomeIcon name={checkName} className={this.getCheckClass()} style={this.getCheckStyle()}/>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
renderError = (): React.ReactNode => {
|
|
132
|
+
const {error, errorClass} = this.props;
|
|
133
|
+
return <label className={classNames('error', errorClass)}>{error}</label>;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
render = () => {
|
|
137
|
+
const {id, onCheck, onMouseLeave, onMouseEnter, title} = this.props;
|
|
138
|
+
return (
|
|
139
|
+
<div className={this.getContainerClass()} id={id} onClick={onCheck} onMouseEnter={onMouseEnter}
|
|
140
|
+
title={title} onMouseLeave={onMouseLeave}>
|
|
141
|
+
{this.renderLabel('left')}
|
|
142
|
+
{this.renderCheckbox()}
|
|
143
|
+
{this.renderLabel('right')}
|
|
144
|
+
{this.renderError()}
|
|
145
|
+
</div>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import {Checkbox} from "./checkbox";
|
|
7
|
+
import {ControlContext} from "../util/controlContext";
|
|
8
|
+
import {generateComponentId} from '../../..';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
onCheck: Function;
|
|
12
|
+
onMouseEnter?: Function;
|
|
13
|
+
onMouseLeave?: Function;
|
|
14
|
+
checked: boolean;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
label: string;
|
|
17
|
+
labelPosition: 'left' | 'right';
|
|
18
|
+
containerClass: string;
|
|
19
|
+
labelClass: string;
|
|
20
|
+
checkboxClass: string;
|
|
21
|
+
checkClass: string;
|
|
22
|
+
errorClass: string;
|
|
23
|
+
baseColor?: string;
|
|
24
|
+
contrastColor?: string;
|
|
25
|
+
error: string | null;
|
|
26
|
+
id?: string;
|
|
27
|
+
checkIcon: React.ReactNode;
|
|
28
|
+
unControlled: boolean;
|
|
29
|
+
title?: string;
|
|
30
|
+
useDarkestColor: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface CheckboxState {
|
|
34
|
+
isHovered: boolean;
|
|
35
|
+
internalValue: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default class CheckboxController extends React.Component<Props, CheckboxState> {
|
|
39
|
+
static contextType = ControlContext;
|
|
40
|
+
|
|
41
|
+
static defaultProps = {
|
|
42
|
+
disabled: false,
|
|
43
|
+
label: '',
|
|
44
|
+
labelPosition: 'right',
|
|
45
|
+
containerClass: '',
|
|
46
|
+
labelClass: '',
|
|
47
|
+
checkboxClass: '',
|
|
48
|
+
checkClass: '',
|
|
49
|
+
errorClass: '',
|
|
50
|
+
checkIcon: null,
|
|
51
|
+
error: null,
|
|
52
|
+
unControlled: false,
|
|
53
|
+
useDarkestColor: true,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
private getContainer = (): HTMLElement | null => {
|
|
57
|
+
return document.getElementById(this.id);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
private getRipple = (): HTMLElement | null => {
|
|
61
|
+
const container = this.getContainer();
|
|
62
|
+
if (container === null) return null;
|
|
63
|
+
return container.querySelector('div.ripple');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
private id: string = generateComponentId(this.props.id);
|
|
67
|
+
|
|
68
|
+
state = {isHovered: false, internalValue: this.props.checked};
|
|
69
|
+
|
|
70
|
+
onCheck = (evt: React.MouseEvent<Element, Event>) => {
|
|
71
|
+
const {checked, onCheck, disabled, unControlled} = this.props;
|
|
72
|
+
if (disabled) return;
|
|
73
|
+
if (unControlled) {
|
|
74
|
+
evt.stopPropagation();
|
|
75
|
+
evt.persist();
|
|
76
|
+
this.setState({internalValue: !this.state.internalValue}, () => {
|
|
77
|
+
onCheck(this.state.internalValue, evt);
|
|
78
|
+
});
|
|
79
|
+
} else onCheck(!checked, evt);
|
|
80
|
+
this.addRipple();
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
onMouseEnter = () => {
|
|
84
|
+
if (this.props.disabled) return;
|
|
85
|
+
this.setState({isHovered: true});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
onMouseLeave = () => {
|
|
89
|
+
if (this.props.disabled) return;
|
|
90
|
+
this.setState({isHovered: false});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
addRipple = () => {
|
|
94
|
+
const container = this.getContainer();
|
|
95
|
+
if (container !== null) {
|
|
96
|
+
const ripple = this.getRipple();
|
|
97
|
+
if (ripple !== null) {
|
|
98
|
+
if (container.classList.contains('rippling'))
|
|
99
|
+
container.classList.remove('rippling');
|
|
100
|
+
ripple.addEventListener('transitionend', this.removeRipple);
|
|
101
|
+
container.classList.add('rippling');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
removeRipple = () => {
|
|
107
|
+
const ripple = this.getRipple();
|
|
108
|
+
const container = this.getContainer();
|
|
109
|
+
if (ripple !== null && container !== null) {
|
|
110
|
+
ripple.removeEventListener('transitionend', this.removeRipple);
|
|
111
|
+
container.classList.remove('rippling');
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
componentWillUnmount = () => {
|
|
116
|
+
this.removeRipple();
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
render = () => {
|
|
120
|
+
const {
|
|
121
|
+
checked, disabled, label, labelPosition, containerClass, labelClass, checkboxClass, checkClass, checkIcon,
|
|
122
|
+
error, errorClass, unControlled, title, baseColor, contrastColor, useDarkestColor,
|
|
123
|
+
} = this.props, {isHovered, internalValue} = this.state, isChecked = unControlled ? internalValue : checked;
|
|
124
|
+
return <Checkbox onCheck={this.onCheck} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}
|
|
125
|
+
checked={isChecked} disabled={disabled} isHovered={isHovered} label={label}
|
|
126
|
+
labelPosition={labelPosition} containerClass={containerClass} labelClass={labelClass}
|
|
127
|
+
checkboxClass={checkboxClass} checkClass={checkClass} id={this.id} checkIcon={checkIcon}
|
|
128
|
+
error={error} errorClass={errorClass} title={title} baseColor={baseColor}
|
|
129
|
+
contrastColor={contrastColor} useDarkestColor={useDarkestColor}/>
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@import '../../../style/variables';
|
|
6
|
+
|
|
7
|
+
.checkboxContainer {
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: 22px auto;
|
|
10
|
+
grid-column-gap: .5rem;
|
|
11
|
+
align-items: center;
|
|
12
|
+
//padding: .2rem;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
position: relative;
|
|
15
|
+
margin-bottom: 0;
|
|
16
|
+
transition: margin-bottom .2s ease-in-out;
|
|
17
|
+
|
|
18
|
+
.checkboxLabel {
|
|
19
|
+
font-size: .9rem;
|
|
20
|
+
color: $color-gray-5;
|
|
21
|
+
cursor: inherit;
|
|
22
|
+
user-select: none;
|
|
23
|
+
transition: color .2s ease;
|
|
24
|
+
margin-bottom: -.2rem;
|
|
25
|
+
|
|
26
|
+
&.error {
|
|
27
|
+
color: red;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.checkbox {
|
|
32
|
+
@include borderRadius(.2rem);
|
|
33
|
+
position: relative;
|
|
34
|
+
height: 22px;
|
|
35
|
+
width: 22px;
|
|
36
|
+
border: 2px solid;
|
|
37
|
+
cursor: inherit;
|
|
38
|
+
background-color: white;
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
|
|
41
|
+
.checkboxCheck, .checkbox-check {
|
|
42
|
+
@include centerXY;
|
|
43
|
+
top: 55%;
|
|
44
|
+
font-size: .9rem;
|
|
45
|
+
cursor: inherit;
|
|
46
|
+
visibility: hidden;
|
|
47
|
+
opacity: 0;
|
|
48
|
+
transition: opacity .1s ease-in-out, visibility .1s ease-in-out;
|
|
49
|
+
user-select: none;
|
|
50
|
+
|
|
51
|
+
&.checked {
|
|
52
|
+
visibility: visible;
|
|
53
|
+
opacity: 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ripple {
|
|
58
|
+
@include centerXY;
|
|
59
|
+
@include borderRadius(50%);
|
|
60
|
+
opacity: 1;
|
|
61
|
+
width: 8px;
|
|
62
|
+
height: 8px;
|
|
63
|
+
visibility: hidden;
|
|
64
|
+
pointer-events: none;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.error {
|
|
69
|
+
position: absolute;
|
|
70
|
+
left: 0;
|
|
71
|
+
bottom: -1.4rem;
|
|
72
|
+
color: red;
|
|
73
|
+
font-size: .9rem;
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
visibility: hidden;
|
|
76
|
+
opacity: 0;
|
|
77
|
+
transition: visibility .2s ease-in-out, opacity .2s ease-in-out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&.rippling {
|
|
81
|
+
.checkbox {
|
|
82
|
+
.ripple {
|
|
83
|
+
width: 56px;
|
|
84
|
+
height: 56px;
|
|
85
|
+
visibility: visible;
|
|
86
|
+
opacity: 0;
|
|
87
|
+
transition: opacity .5s ease-in-out, opacity .5s ease, width .5s ease-in-out, height .5s ease-in-out;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&.disabled {
|
|
93
|
+
cursor: not-allowed;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&.error {
|
|
97
|
+
margin-bottom: 1.4rem;
|
|
98
|
+
|
|
99
|
+
.error {
|
|
100
|
+
visibility: visible;
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&.no-label {
|
|
106
|
+
grid-template-columns: 22px;
|
|
107
|
+
grid-column-gap: unset;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import './style/colorPicker.scss';
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import {MouseEventHandler, PureComponent} from 'react';
|
|
9
|
+
import {
|
|
10
|
+
BlockPicker, ChromePicker, CirclePicker, Color, ColorPickerProps, ColorResult, CompactPicker, PhotoshopPicker,
|
|
11
|
+
SketchPicker, TwitterPicker,
|
|
12
|
+
} from "react-color";
|
|
13
|
+
import {ColorPickerResultType, ColorPickerType} from "../util/interfaces";
|
|
14
|
+
import WithBackground from "../popup/withBackground";
|
|
15
|
+
import {Button} from "../../../index";
|
|
16
|
+
|
|
17
|
+
interface Props extends ColorPickerProps<any> {
|
|
18
|
+
onSubmit: (color: Color) => void;
|
|
19
|
+
onPreChange?: (color: Color) => void;
|
|
20
|
+
onClose: MouseEventHandler;
|
|
21
|
+
pickerType: ColorPickerType;
|
|
22
|
+
resultType: ColorPickerResultType;
|
|
23
|
+
visible: boolean;
|
|
24
|
+
transparent: boolean;
|
|
25
|
+
closeable: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface State {
|
|
29
|
+
color: Color;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default class ColorPicker extends PureComponent<Props, State> {
|
|
33
|
+
static defaultProps = {
|
|
34
|
+
pickerType: ColorPickerType.SKETCH,
|
|
35
|
+
resultType: ColorPickerResultType.HEX,
|
|
36
|
+
transparent: false,
|
|
37
|
+
closeable: true,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
state: State = {
|
|
41
|
+
color: this.props.color || '#000',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
onSubmit = () => {
|
|
45
|
+
const {onSubmit} = this.props, {color} = this.state;
|
|
46
|
+
onSubmit(color);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
onChange = (color: ColorResult) => {
|
|
50
|
+
let newColor: Color;
|
|
51
|
+
switch (this.props.resultType) {
|
|
52
|
+
case ColorPickerResultType.HEX:
|
|
53
|
+
newColor = color.hex;
|
|
54
|
+
break;
|
|
55
|
+
case ColorPickerResultType.HSL:
|
|
56
|
+
newColor = color.hsl;
|
|
57
|
+
break;
|
|
58
|
+
case ColorPickerResultType.RGB:
|
|
59
|
+
newColor = color.rgb;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
this.setState({color: newColor});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
onPreChange = (color: ColorResult) => {
|
|
66
|
+
const {onPreChange} = this.props;
|
|
67
|
+
if (!onPreChange) return;
|
|
68
|
+
switch (this.props.resultType) {
|
|
69
|
+
case ColorPickerResultType.HEX:
|
|
70
|
+
onPreChange(color.hex);
|
|
71
|
+
break;
|
|
72
|
+
case ColorPickerResultType.HSL:
|
|
73
|
+
onPreChange(color.hsl);
|
|
74
|
+
break;
|
|
75
|
+
case ColorPickerResultType.RGB:
|
|
76
|
+
onPreChange(color.rgb);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
getPicker = () => {
|
|
82
|
+
const {pickerType} = this.props, {color} = this.state,
|
|
83
|
+
props = {color, onChangeComplete: this.onChange, onChange: this.onPreChange};
|
|
84
|
+
switch (pickerType) {
|
|
85
|
+
case ColorPickerType.BLOCK:
|
|
86
|
+
return <BlockPicker {...props}/>;
|
|
87
|
+
case ColorPickerType.CHROME:
|
|
88
|
+
return <ChromePicker {...props}/>;
|
|
89
|
+
case ColorPickerType.CIRCLE:
|
|
90
|
+
return <CirclePicker {...props}/>;
|
|
91
|
+
case ColorPickerType.COMPACT:
|
|
92
|
+
return <CompactPicker {...props}/>;
|
|
93
|
+
case ColorPickerType.PHOTOSHOP:
|
|
94
|
+
return <PhotoshopPicker {...props}/>;
|
|
95
|
+
case ColorPickerType.SKETCH:
|
|
96
|
+
return <SketchPicker {...props}/>;
|
|
97
|
+
case ColorPickerType.TWITTER:
|
|
98
|
+
return <TwitterPicker {...props}/>;
|
|
99
|
+
default:
|
|
100
|
+
return <SketchPicker {...props}/>;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
render = () => {
|
|
105
|
+
const {onClose, visible, transparent, className, closeable} = this.props;
|
|
106
|
+
return (
|
|
107
|
+
<WithBackground onClose={onClose} active={visible} transparent={transparent} backgroundClass={className}>
|
|
108
|
+
<div className='color-picker-container'>
|
|
109
|
+
{this.getPicker()}
|
|
110
|
+
<div className='buttons-container'>
|
|
111
|
+
{closeable && <Button onClick={onClose} label='Sluit' type='outlined'/>}
|
|
112
|
+
<Button onClick={this.onSubmit} label='Kies' containerClass='submit-color'/>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</WithBackground>
|
|
116
|
+
)
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@import '../../../style/variables';
|
|
6
|
+
|
|
7
|
+
.color-picker-container {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
|
|
11
|
+
.buttons-container {
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
padding: .5rem;
|
|
15
|
+
margin-top: -.2rem;
|
|
16
|
+
background-color: rgba(white, 1);
|
|
17
|
+
border-bottom-left-radius: .25rem;
|
|
18
|
+
border-bottom-right-radius: .25rem;
|
|
19
|
+
}
|
|
20
|
+
}
|