@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,165 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
import './style/sidebarMenu.scss';
|
|
5
|
-
|
|
6
|
-
import React, {MouseEventHandler, ReactNode, useContext, useEffect, useRef, useState} from 'react';
|
|
7
|
-
import {useLocation} from 'react-router';
|
|
8
|
-
import {SidebarItem, SideMenuMode} from "../util/interfaces";
|
|
9
|
-
import classNames from 'classnames';
|
|
10
|
-
import {AwesomeIcon, generateComponentId, isAbsoluteLink} from "../../../index";
|
|
11
|
-
import {ControlContext} from "../util/controlContext";
|
|
12
|
-
import {defer} from 'lodash';
|
|
13
|
-
|
|
14
|
-
interface Props {
|
|
15
|
-
onClickItem: (item: SidebarItem) => MouseEventHandler;
|
|
16
|
-
items: SidebarItem[];
|
|
17
|
-
activeItem?: string;
|
|
18
|
-
className?: string;
|
|
19
|
-
baseColor?: string;
|
|
20
|
-
contrastColor?: string;
|
|
21
|
-
controlled?: boolean;
|
|
22
|
-
mode?: SideMenuMode;
|
|
23
|
-
id?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getTopItems(items: SidebarItem[]): SidebarItem[] {
|
|
27
|
-
return items.filter((item: SidebarItem) => !item.onBottom);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getBottomItems(items: SidebarItem[]): SidebarItem[] {
|
|
31
|
-
return items.filter((item: SidebarItem) => item.onBottom)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getActiveItem(items: SidebarItem[], pathname: string): SidebarItem | null {
|
|
35
|
-
for (const item of items) {
|
|
36
|
-
if (itemIsActive(item, pathname)) return item;
|
|
37
|
-
if (Array.isArray(item.children)) {
|
|
38
|
-
const activeItem = getActiveItem(item.children, pathname);
|
|
39
|
-
if (activeItem) return activeItem;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function itemIsActive(item: SidebarItem, pathname: string): boolean {
|
|
46
|
-
if (Array.isArray(item.route) && item.route.includes(pathname)) return true;
|
|
47
|
-
else if (item.route === pathname) return true;
|
|
48
|
-
else if (typeof item.route === 'string' && item.exactRoute === false && pathname.includes(item.route)) return true;
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function itemHasActiveId(item: SidebarItem, activeId: string): boolean {
|
|
53
|
-
if (item.id === activeId) return true;
|
|
54
|
-
else if (Array.isArray(item.children) && item.children.find((child: SidebarItem) => itemHasActiveId(child, activeId))) return true;
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default function SidebarMenu(props: Props) {
|
|
59
|
-
const context = useContext(ControlContext),
|
|
60
|
-
location = useLocation(),
|
|
61
|
-
{className, contrastColor, baseColor, items, onClickItem} = props,
|
|
62
|
-
mode = props.mode ?? SideMenuMode.COMPACT,
|
|
63
|
-
[activeItem, setActiveItem] = useState(props.activeItem ?? ''),
|
|
64
|
-
sideBar = useRef<HTMLDivElement>(null),
|
|
65
|
-
componentId = useRef(generateComponentId(props.id));
|
|
66
|
-
|
|
67
|
-
function _onClickItem(item: SidebarItem) {
|
|
68
|
-
return function (evt: React.MouseEvent) {
|
|
69
|
-
evt.stopPropagation();
|
|
70
|
-
const {route} = item;
|
|
71
|
-
let _route: string | null = null;
|
|
72
|
-
if (route) {
|
|
73
|
-
if (Array.isArray(route) && route.length) _route = route[0];
|
|
74
|
-
else _route = route as string;
|
|
75
|
-
}
|
|
76
|
-
if (_route && !isAbsoluteLink(_route))
|
|
77
|
-
setActiveItem(item.id);
|
|
78
|
-
onClickItem(item)(evt);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function renderItem(isChild: boolean = false) {
|
|
83
|
-
return function (item: SidebarItem) {
|
|
84
|
-
const {className, icon, id, label, children} = item,
|
|
85
|
-
isActive = itemHasActiveId(item, activeItem),
|
|
86
|
-
cls = classNames(className, mode === SideMenuMode.COMPACT ? 'side-bar-item' : 'side-bar-item-full',
|
|
87
|
-
isChild && 'child', children !== undefined && 'with-children');
|
|
88
|
-
return (
|
|
89
|
-
<div key={id} className={cls} onClick={_onClickItem(item)}>
|
|
90
|
-
{renderIcon(isActive, isChild, label, icon)}
|
|
91
|
-
{mode === SideMenuMode.COMPACT && <div className='active-indicator'/>}
|
|
92
|
-
<span className={classNames('item-label', isActive && 'active')}>{label}</span>
|
|
93
|
-
{children !== undefined && (
|
|
94
|
-
<>
|
|
95
|
-
{isActive && <div className='line'/>}
|
|
96
|
-
{renderChildren(isActive)(children)}
|
|
97
|
-
</>
|
|
98
|
-
)}
|
|
99
|
-
</div>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function renderChildren(isActive: boolean) {
|
|
105
|
-
return function (children: SidebarItem[]) {
|
|
106
|
-
const display = isActive ? 'block' : 'none';
|
|
107
|
-
return (
|
|
108
|
-
<div className='children-container' style={{display}}>
|
|
109
|
-
{children.map(renderItem(true))}
|
|
110
|
-
</div>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function renderIcon(isActive: boolean, isChild: boolean, label: string, icon?: string | ReactNode): ReactNode {
|
|
116
|
-
const className = classNames('item-icon', isActive && 'active');
|
|
117
|
-
if (icon) {
|
|
118
|
-
if (typeof icon === 'string') return <AwesomeIcon name={icon} className={className}/>;
|
|
119
|
-
else if (React.isValidElement(icon))
|
|
120
|
-
return React.cloneElement(icon, {className: classNames(className, icon.props.className)});
|
|
121
|
-
}
|
|
122
|
-
if (label.length) {
|
|
123
|
-
if (isChild) return <span/>;
|
|
124
|
-
return <span className={classNames(className, 'letter')}>{label[0]}</span>
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function setColors() {
|
|
130
|
-
const bar = sideBar.current;
|
|
131
|
-
if (bar) {
|
|
132
|
-
const base: string = baseColor || context.baseColor,
|
|
133
|
-
contrast: string = contrastColor || context.contrastColor;
|
|
134
|
-
bar.style.setProperty('--base-color', base);
|
|
135
|
-
bar.style.setProperty('--contrast-color', contrast);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function _setActiveItem() {
|
|
140
|
-
const {pathname} = location;
|
|
141
|
-
const activeItem = getActiveItem(items, pathname);
|
|
142
|
-
if (activeItem) setActiveItem(activeItem.id);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
setColors();
|
|
147
|
-
defer(_setActiveItem);
|
|
148
|
-
}, []);
|
|
149
|
-
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
_setActiveItem()
|
|
152
|
-
}, [location]);
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<div className={classNames(className, 'dvr-side-bar-menu', mode === SideMenuMode.FULL && 'full')}
|
|
156
|
-
ref={sideBar} id={componentId.current}>
|
|
157
|
-
<div>
|
|
158
|
-
{getTopItems(items).map(renderItem())}
|
|
159
|
-
</div>
|
|
160
|
-
<div>
|
|
161
|
-
{getBottomItems(items).map(renderItem())}
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
)
|
|
165
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@import '../../../style/variables';
|
|
6
|
-
|
|
7
|
-
.dvr-side-bar-menu {
|
|
8
|
-
//--base-color: white;
|
|
9
|
-
//--contrast-color: $color-blue-1;
|
|
10
|
-
@include backgroundShadow;
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
justify-content: space-between;
|
|
14
|
-
position: fixed;
|
|
15
|
-
top: 4rem;
|
|
16
|
-
background-color: var(--contrast-color);
|
|
17
|
-
height: calc(100vh - 4rem);
|
|
18
|
-
width: 4rem;
|
|
19
|
-
z-index: $z-index-popup-4;
|
|
20
|
-
|
|
21
|
-
.side-bar-item {
|
|
22
|
-
border-bottom: 1px solid $color-gray-7;
|
|
23
|
-
height: 4rem;
|
|
24
|
-
width: 4rem;
|
|
25
|
-
display: flex;
|
|
26
|
-
justify-content: center;
|
|
27
|
-
align-items: center;
|
|
28
|
-
cursor: pointer;
|
|
29
|
-
position: relative;
|
|
30
|
-
background-color: var(--contrast-color-color);
|
|
31
|
-
transition: background-color .2s ease-in-out;
|
|
32
|
-
color: var(--base-color);
|
|
33
|
-
|
|
34
|
-
.item-icon {
|
|
35
|
-
color: $color-gray-4;
|
|
36
|
-
font-size: 1.5rem;
|
|
37
|
-
transition: color .2s ease-in-out;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.item-label {
|
|
41
|
-
@include centerY;
|
|
42
|
-
border-radius: .5rem;
|
|
43
|
-
position: absolute;
|
|
44
|
-
padding: 4px 6px;
|
|
45
|
-
background-color: rgba(black, .6);
|
|
46
|
-
color: white;
|
|
47
|
-
left: 115%;
|
|
48
|
-
visibility: hidden;
|
|
49
|
-
opacity: 0;
|
|
50
|
-
transition: visibility .2s ease-in-out, opacity .2s ease-in-out;
|
|
51
|
-
font-size: 12px;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.active-indicator {
|
|
55
|
-
position: absolute;
|
|
56
|
-
top: 0;
|
|
57
|
-
right: 0;
|
|
58
|
-
height: 100%;
|
|
59
|
-
width: 3px;
|
|
60
|
-
background-color: var(--base-color);
|
|
61
|
-
visibility: hidden;
|
|
62
|
-
opacity: 0;
|
|
63
|
-
transition: visibility .2s ease-in-out, opacity .2s ease-in-out;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&:hover {
|
|
67
|
-
.item-label {
|
|
68
|
-
visibility: visible;
|
|
69
|
-
opacity: 1;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&.active {
|
|
74
|
-
.active-indicator {
|
|
75
|
-
visibility: visible;
|
|
76
|
-
opacity: 1;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.item-icon {
|
|
80
|
-
color: var(--base-color);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&.full {
|
|
86
|
-
width: unset;
|
|
87
|
-
box-shadow: none;
|
|
88
|
-
background-color: transparent;
|
|
89
|
-
position: sticky;
|
|
90
|
-
display: inline-flex;
|
|
91
|
-
height: calc(100vh - 5rem);
|
|
92
|
-
top: 5rem;
|
|
93
|
-
|
|
94
|
-
.side-bar-item-full {
|
|
95
|
-
display: grid;
|
|
96
|
-
grid-template-columns: 2rem auto;
|
|
97
|
-
grid-column-gap: 1rem;
|
|
98
|
-
margin: 2rem 1rem;
|
|
99
|
-
align-items: center;
|
|
100
|
-
cursor: pointer;
|
|
101
|
-
position: relative;
|
|
102
|
-
|
|
103
|
-
.item-icon {
|
|
104
|
-
color: #686869;
|
|
105
|
-
font-size: 1.5rem;
|
|
106
|
-
transition: color .2s ease-in-out;
|
|
107
|
-
justify-self: center;
|
|
108
|
-
opacity: .5;
|
|
109
|
-
|
|
110
|
-
&.active {
|
|
111
|
-
color: var(--base-color);
|
|
112
|
-
opacity: 1;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.item-label {
|
|
117
|
-
color: #686869;
|
|
118
|
-
transition: color .2s ease-in-out;
|
|
119
|
-
white-space: nowrap;
|
|
120
|
-
|
|
121
|
-
&.active {
|
|
122
|
-
font-weight: 600;
|
|
123
|
-
color: black;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.line {
|
|
128
|
-
width: 2px;
|
|
129
|
-
position: absolute;
|
|
130
|
-
height: calc(100% - 1.5rem);
|
|
131
|
-
top: 2rem;
|
|
132
|
-
left: 1rem;
|
|
133
|
-
background-color: var(--base-color);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
&.child {
|
|
137
|
-
.item-label {
|
|
138
|
-
padding-left: 1rem;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.children-container {
|
|
143
|
-
padding-top: 1rem;
|
|
144
|
-
|
|
145
|
-
.side-bar-item-full {
|
|
146
|
-
margin: 0;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
&:hover {
|
|
151
|
-
.item-label {
|
|
152
|
-
color: black;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
&.with-children {
|
|
157
|
-
margin-bottom: -.5rem;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
import './style/DVRSlider.scss';
|
|
5
|
-
|
|
6
|
-
import React, {CSSProperties, MouseEventHandler, PureComponent} from 'react';
|
|
7
|
-
import {ChangeFunction, Colors, convertColor, generateComponentId} from "../../..";
|
|
8
|
-
import {ElementPosition} from '../util/interfaces';
|
|
9
|
-
import {ControlContext} from "../util/controlContext";
|
|
10
|
-
import classNames from "classnames";
|
|
11
|
-
|
|
12
|
-
interface Props {
|
|
13
|
-
onChange: ChangeFunction;
|
|
14
|
-
onMouseEnter?: MouseEventHandler;
|
|
15
|
-
onMouseLeave?: MouseEventHandler;
|
|
16
|
-
value?: number;
|
|
17
|
-
disabled: boolean;
|
|
18
|
-
id?: string;
|
|
19
|
-
className: string;
|
|
20
|
-
labelClassName: string;
|
|
21
|
-
style?: CSSProperties;
|
|
22
|
-
asNumber?: boolean;
|
|
23
|
-
label?: string;
|
|
24
|
-
labelPosition: ElementPosition;
|
|
25
|
-
inputProps?: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default class DVRSlider extends PureComponent<Props> {
|
|
29
|
-
id: string;
|
|
30
|
-
static defaultProps = {
|
|
31
|
-
min: 0,
|
|
32
|
-
max: 100,
|
|
33
|
-
step: 1,
|
|
34
|
-
disabled: false,
|
|
35
|
-
className: '',
|
|
36
|
-
labelClassName: '',
|
|
37
|
-
labelPosition: ElementPosition.RIGHT,
|
|
38
|
-
};
|
|
39
|
-
declare context: React.ContextType<typeof ControlContext>;
|
|
40
|
-
static contextType = ControlContext;
|
|
41
|
-
|
|
42
|
-
constructor(props: Props) {
|
|
43
|
-
super(props);
|
|
44
|
-
this.id = generateComponentId(props.id);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
onChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
|
|
48
|
-
const {onChange, asNumber} = this.props, {value} = evt.target;
|
|
49
|
-
if (asNumber) onChange(Number(value), evt);
|
|
50
|
-
else onChange(value, evt);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
onMouseEnter = (evt: React.MouseEvent) => {
|
|
54
|
-
const {onMouseEnter} = this.props;
|
|
55
|
-
this.setState({hovered: true});
|
|
56
|
-
if (onMouseEnter) onMouseEnter(evt);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
onMouseLeave = (evt: React.MouseEvent) => {
|
|
60
|
-
const {onMouseLeave} = this.props;
|
|
61
|
-
this.setState({hovered: false});
|
|
62
|
-
if (onMouseLeave) onMouseLeave(evt);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
getInputProps = (): React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> => {
|
|
66
|
-
const {inputProps} = this.props, defaultProps = {min: 0, max: 100, step: 1};
|
|
67
|
-
return Object.assign({}, defaultProps, inputProps);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getTrackColor = () => {
|
|
71
|
-
const {disabled} = this.props;
|
|
72
|
-
if (disabled) return Colors.GRAY4;
|
|
73
|
-
return convertColor(this.context.baseColor);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
getControlColor = () => convertColor(this.context.baseColor);
|
|
77
|
-
|
|
78
|
-
componentDidMount = () => {
|
|
79
|
-
const input = document.getElementById(`${this.id}-input`);
|
|
80
|
-
if (input) {
|
|
81
|
-
window.setTimeout(() => {
|
|
82
|
-
input.style.setProperty('--control-color', this.getControlColor())
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
renderLabel = () => {
|
|
88
|
-
const {label} = this.props;
|
|
89
|
-
if (!label?.length) return null;
|
|
90
|
-
return <label className='dvr-slider-label'>{label}</label>;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
render = () => {
|
|
94
|
-
const {value, disabled, className, style, labelPosition, label} = this.props;
|
|
95
|
-
return (
|
|
96
|
-
<div className={classNames('dvr-slider-container', className, label?.length && labelPosition,
|
|
97
|
-
disabled && 'disabled')}
|
|
98
|
-
id={this.id}>
|
|
99
|
-
{this.renderLabel()}
|
|
100
|
-
<input type='range' value={value} id={`${this.id}-input`} onChange={this.onChange}
|
|
101
|
-
disabled={disabled} className={classNames('dvr-slider', disabled && 'disabled')}
|
|
102
|
-
style={{backgroundColor: this.getTrackColor(), ...style}} onMouseEnter={this.onMouseEnter}
|
|
103
|
-
onMouseLeave={this.onMouseLeave} {...this.getInputProps()}/>
|
|
104
|
-
</div>
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@import '../../../style/variables';
|
|
6
|
-
|
|
7
|
-
.dvr-slider-container {
|
|
8
|
-
.dvr-slider-label {
|
|
9
|
-
white-space: nowrap;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.dvr-slider {
|
|
13
|
-
--control-color: black;
|
|
14
|
-
-webkit-appearance: none;
|
|
15
|
-
appearance: none;
|
|
16
|
-
height: 2px;
|
|
17
|
-
border-radius: .25rem;
|
|
18
|
-
outline: none;
|
|
19
|
-
transition: opacity .2s ease-in-out;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
|
|
22
|
-
&::-webkit-slider-thumb {
|
|
23
|
-
@include backgroundShadow;
|
|
24
|
-
-webkit-appearance: none;
|
|
25
|
-
appearance: none;
|
|
26
|
-
width: .75rem;
|
|
27
|
-
height: .75rem;
|
|
28
|
-
border-radius: 50%;
|
|
29
|
-
background: var(--control-color);
|
|
30
|
-
cursor: pointer;
|
|
31
|
-
transition: width .2s ease-in-out, height .2s ease-in-out;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&::-moz-range-thumb {
|
|
35
|
-
width: .75rem;
|
|
36
|
-
height: .75rem;
|
|
37
|
-
border-radius: 50%;
|
|
38
|
-
background: var(--control-color);
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
transition: width .2s ease-in-out, height .2s ease-in-out;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&:hover {
|
|
44
|
-
opacity: 1;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&.top, &.bottom {
|
|
49
|
-
display: grid;
|
|
50
|
-
grid-template-columns: auto;
|
|
51
|
-
//justify-items: start;
|
|
52
|
-
grid-row-gap: .5rem;
|
|
53
|
-
|
|
54
|
-
.dvr-slider-label {
|
|
55
|
-
padding-left: .2rem;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&.right, &.left {
|
|
60
|
-
display: grid;
|
|
61
|
-
grid-column-gap: .5rem;
|
|
62
|
-
align-items: center;
|
|
63
|
-
//justify-items: start;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&.bottom, &.right {
|
|
67
|
-
.dvr-slider-label {
|
|
68
|
-
grid-area: label;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.dvr-input {
|
|
72
|
-
grid-area: input;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&.bottom {
|
|
77
|
-
grid-template-areas: 'input' 'label';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
&.right {
|
|
81
|
-
grid-template-areas: 'input label';
|
|
82
|
-
grid-template-columns: 1fr min-content;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&.left {
|
|
86
|
-
grid-template-columns: min-content 1fr;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import './style/snackbar.scss';
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import {convertColor} from "../util/colorUtil";
|
|
10
|
-
import {ControlContext} from "../util/controlContext";
|
|
11
|
-
import {Snack} from "../util/interfaces";
|
|
12
|
-
|
|
13
|
-
interface ViewProps {
|
|
14
|
-
onClick: any;
|
|
15
|
-
snack: Snack | null;
|
|
16
|
-
containerClass: string;
|
|
17
|
-
textClass: string;
|
|
18
|
-
backgroundColor?: string;
|
|
19
|
-
textColor?: string;
|
|
20
|
-
active: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class Snackbar extends React.Component<ViewProps> {
|
|
24
|
-
// noinspection JSUnusedGlobalSymbols
|
|
25
|
-
declare context: React.ContextType<typeof ControlContext>;
|
|
26
|
-
static contextType = ControlContext;
|
|
27
|
-
|
|
28
|
-
getBackgroundColor = (): string => {
|
|
29
|
-
const {backgroundColor, snack} = this.props;
|
|
30
|
-
if (snack?.config?.backgroundColor) return convertColor(snack.config.backgroundColor);
|
|
31
|
-
if (backgroundColor) return convertColor(backgroundColor);
|
|
32
|
-
// noinspection JSDeprecatedSymbols
|
|
33
|
-
return convertColor(this.context.baseColor);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
getTextColor = (): string => {
|
|
37
|
-
const {textColor, snack} = this.props;
|
|
38
|
-
if (snack?.config?.textColor) return convertColor(snack.config.textColor);
|
|
39
|
-
if (textColor !== undefined && textColor !== null) return convertColor(textColor);
|
|
40
|
-
// noinspection JSDeprecatedSymbols
|
|
41
|
-
return convertColor(this.context.contrastColor);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
getBackgroundStyle = (): { backgroundColor: string } => ({backgroundColor: this.getBackgroundColor()});
|
|
45
|
-
|
|
46
|
-
getTextStyle = (): { color: string } => ({color: this.getTextColor()});
|
|
47
|
-
|
|
48
|
-
renderText = () => {
|
|
49
|
-
const {snack, textClass} = this.props;
|
|
50
|
-
if (!snack) return null;
|
|
51
|
-
const {text} = snack;
|
|
52
|
-
let element: React.ReactNode = null;
|
|
53
|
-
if (typeof text === 'string') element =
|
|
54
|
-
<label className={classNames('snackBarText', textClass)} style={this.getTextStyle()}>{text}</label>;
|
|
55
|
-
else if (text) {
|
|
56
|
-
const className = Object.assign({}, text.props?.className, classNames('snackBarText', textClass)),
|
|
57
|
-
style = Object.assign({}, text.props?.style, this.getTextStyle());
|
|
58
|
-
element = React.cloneElement(text, {className, style});
|
|
59
|
-
}
|
|
60
|
-
return element;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
render = () => {
|
|
64
|
-
const {containerClass, active, onClick} = this.props;
|
|
65
|
-
return (
|
|
66
|
-
<div className={classNames('snackbar', active && 'active', containerClass)}
|
|
67
|
-
style={this.getBackgroundStyle()} onClick={onClick}>
|
|
68
|
-
{this.renderText()}
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import {Snackbar} from "./snackbar";
|
|
7
|
-
import {CustomAppEvent, DialogConfig, Snack} from "../util/interfaces";
|
|
8
|
-
import WithEvents from '../events/withEvents';
|
|
9
|
-
import {delay} from 'lodash';
|
|
10
|
-
|
|
11
|
-
interface Props {
|
|
12
|
-
containerClass: string;
|
|
13
|
-
textClass: string;
|
|
14
|
-
activeTime: number;
|
|
15
|
-
backgroundColor?: string;
|
|
16
|
-
textColor?: string;
|
|
17
|
-
maxSnacks?: number;
|
|
18
|
-
noDuplicates?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface State {
|
|
22
|
-
active: boolean;
|
|
23
|
-
snack: Snack | null;
|
|
24
|
-
config: DialogConfig;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default class SnackbarController extends React.Component<Props, State> {
|
|
28
|
-
static defaultProps = {
|
|
29
|
-
activeTime: 3000,
|
|
30
|
-
containerClass: '',
|
|
31
|
-
textClass: '',
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
state: State = {
|
|
35
|
-
active: false,
|
|
36
|
-
snack: null,
|
|
37
|
-
config: {}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
snackQueue: Snack[] = [];
|
|
41
|
-
timeout: number | null = null;
|
|
42
|
-
|
|
43
|
-
onAddSnack = (snack: Snack) => {
|
|
44
|
-
const {maxSnacks, noDuplicates} = this.props;
|
|
45
|
-
if (noDuplicates && this.isDuplicate(snack)) return;
|
|
46
|
-
this.snackQueue.push(snack);
|
|
47
|
-
if (maxSnacks !== undefined)
|
|
48
|
-
while (this.snackQueue.length > maxSnacks - 1)
|
|
49
|
-
this.snackQueue.shift();
|
|
50
|
-
if (!this.state.active)
|
|
51
|
-
this.activate();
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
onClick = () => {
|
|
55
|
-
if (this.timeout !== null)
|
|
56
|
-
window.clearTimeout(this.timeout);
|
|
57
|
-
this.deactivate();
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
isDuplicate = (snack: Snack): boolean => {
|
|
61
|
-
return this.state.snack?.text === snack.text || this.snackQueue.pop()?.text === snack.text;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
deactivate = () => {
|
|
65
|
-
this.setState({active: false}, () => {
|
|
66
|
-
delay(() => {
|
|
67
|
-
// Clear snack after 200ms (css transition)
|
|
68
|
-
this.setState({snack: null}, () => {
|
|
69
|
-
if (this.snackQueue.length > 0)
|
|
70
|
-
this.timeout = window.setTimeout(this.activate, 500);
|
|
71
|
-
})
|
|
72
|
-
}, 200);
|
|
73
|
-
})
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
activate = () => {
|
|
77
|
-
const snack: Snack | undefined = this.snackQueue.pop();
|
|
78
|
-
if (snack) {
|
|
79
|
-
this.setState({snack}, () => {
|
|
80
|
-
this.setState({active: true});
|
|
81
|
-
this.timeout = window.setTimeout(this.deactivate, this.props.activeTime);
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
componentWillUnmount = () => {
|
|
87
|
-
if (this.timeout !== null)
|
|
88
|
-
window.clearTimeout(this.timeout);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
getEvents = (): CustomAppEvent[] => [
|
|
92
|
-
{eventName: 'onShowSnackbar', handler: this.onAddSnack}
|
|
93
|
-
];
|
|
94
|
-
|
|
95
|
-
render = () => {
|
|
96
|
-
const {snack, active} = this.state, {containerClass, textClass, textColor, backgroundColor} = this.props;
|
|
97
|
-
return (
|
|
98
|
-
<WithEvents events={this.getEvents()}>
|
|
99
|
-
<Snackbar snack={snack} containerClass={containerClass} textClass={textClass} active={active}
|
|
100
|
-
onClick={this.onClick} textColor={textColor} backgroundColor={backgroundColor}/>
|
|
101
|
-
</WithEvents>
|
|
102
|
-
)
|
|
103
|
-
};
|
|
104
|
-
}
|