@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,413 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import './style/header.scss';
|
|
6
|
-
|
|
7
|
-
import React, {CSSProperties, MouseEventHandler, PureComponent} from 'react';
|
|
8
|
-
import classNames from "classnames";
|
|
9
|
-
import {hasHover, remToPx} from "../util/controlUtil";
|
|
10
|
-
import {AwesomeIcon, convertColor, directTimeout, generateComponentId, voidFunction} from "../../../";
|
|
11
|
-
import {ControlContext} from "../util/controlContext";
|
|
12
|
-
import TopButton, {TopButtonProps} from "../topButton/topButton";
|
|
13
|
-
import { getScreenWidth } from '../util/responsiveUtil';
|
|
14
|
-
|
|
15
|
-
export interface HeaderItem {
|
|
16
|
-
label?: string;
|
|
17
|
-
component?: React.ReactElement;
|
|
18
|
-
icon?: string | React.ReactElement;
|
|
19
|
-
iconOnly?: boolean;
|
|
20
|
-
forceBar?: boolean;
|
|
21
|
-
onClick: MouseEventHandler | null;
|
|
22
|
-
route?: string;
|
|
23
|
-
customClass?: string;
|
|
24
|
-
children?: HeaderItem[];
|
|
25
|
-
id?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface RenderAble {
|
|
29
|
-
toRender: React.ReactNode;
|
|
30
|
-
clickHandler: MouseEventHandler | null;
|
|
31
|
-
children?: RenderAble[];
|
|
32
|
-
isComp: boolean;
|
|
33
|
-
id?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface Props {
|
|
37
|
-
items: HeaderItem[];
|
|
38
|
-
forcedMenu: boolean;
|
|
39
|
-
containerClass: string;
|
|
40
|
-
menuContainerClass: string;
|
|
41
|
-
id?: string;
|
|
42
|
-
transparent: boolean;
|
|
43
|
-
fix: boolean;
|
|
44
|
-
leftMenuComp?: React.ReactNode;
|
|
45
|
-
headerColor?: string;
|
|
46
|
-
headerLabelColor?: string;
|
|
47
|
-
menuColor?: string;
|
|
48
|
-
menuLabelColor?: string;
|
|
49
|
-
topControl: boolean;
|
|
50
|
-
topControlProps?: Partial<TopButtonProps>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface State {
|
|
54
|
-
phase: Phase;
|
|
55
|
-
menuOpen: boolean;
|
|
56
|
-
openSubMenus: string[];
|
|
57
|
-
headerHeight: number;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
enum Phase {HEADER = 'header', MENU = 'menu', CALCULATING = 'calculating'}
|
|
61
|
-
|
|
62
|
-
const RESIZE_TIMEOUT = Math.ceil(1000 / 120); // 30 fps
|
|
63
|
-
|
|
64
|
-
export default class DVRHeader extends PureComponent<Props, State> {
|
|
65
|
-
declare context: React.ContextType<typeof ControlContext>;
|
|
66
|
-
static contextType = ControlContext;
|
|
67
|
-
|
|
68
|
-
static defaultProps = {
|
|
69
|
-
forcedMenu: false,
|
|
70
|
-
containerClass: '',
|
|
71
|
-
menuContainerClass: '',
|
|
72
|
-
transparent: false,
|
|
73
|
-
fix: false,
|
|
74
|
-
topControl: false,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
validateProps = (items: HeaderItem[]) => {
|
|
78
|
-
for (const item of items) {
|
|
79
|
-
const canRender = item.label !== undefined || item.component !== undefined || item.icon !== undefined,
|
|
80
|
-
canClick = item.route !== undefined || item.onClick !== undefined,
|
|
81
|
-
usesValidIcon = !item.iconOnly || item.icon !== undefined;
|
|
82
|
-
if (!canRender) throw new TypeError(
|
|
83
|
-
`Cannot render header item without label, component or icon. Invalid item: ${item}`);
|
|
84
|
-
if (!canClick) throw new TypeError(
|
|
85
|
-
`Item can not process click events without route or onClick. invalid item: ${item}`);
|
|
86
|
-
if (!usesValidIcon) throw new TypeError(`Item is forced to use non-existing icon. Invalid item: ${item}`);
|
|
87
|
-
if (item.children && item.children.length)
|
|
88
|
-
this.validateProps(item.children);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
prepIds = (items: HeaderItem[]) => {
|
|
93
|
-
for (const item of items) item.id = generateComponentId(item.id);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
constructor(props: Props) {
|
|
97
|
-
super(props);
|
|
98
|
-
this.validateProps(props.items);
|
|
99
|
-
this.prepIds(props.items);
|
|
100
|
-
this.state = {
|
|
101
|
-
phase: Phase.CALCULATING,
|
|
102
|
-
menuOpen: false,
|
|
103
|
-
openSubMenus: [],
|
|
104
|
-
headerHeight: remToPx(4),
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
menu: HTMLDivElement | null = null;
|
|
109
|
-
id: string = generateComponentId(this.props.id);
|
|
110
|
-
handlingResize: boolean = false;
|
|
111
|
-
resizeTimeout: number | null = null;
|
|
112
|
-
lastKnownHeaderWidth: number = 0;
|
|
113
|
-
lastKnownScreenWidth: number = getScreenWidth(true);
|
|
114
|
-
|
|
115
|
-
onClickBars = () => {
|
|
116
|
-
const {menuOpen} = this.state;
|
|
117
|
-
if (menuOpen) this.closeMenu();
|
|
118
|
-
else this.openMenu();
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
onClick = () => {
|
|
122
|
-
if (!this.menu || !hasHover(this.menu)) this.closeMenu();
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
closeMenu = () => {
|
|
126
|
-
this.setState({menuOpen: false, openSubMenus: []}, this.removeClickListener)
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
onClickChild = (item: RenderAble) => (evt: React.MouseEvent) => {
|
|
130
|
-
evt.stopPropagation();
|
|
131
|
-
if (item.clickHandler)
|
|
132
|
-
item.clickHandler(evt);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
onClickMenuItem = (item: RenderAble) => (evt: React.MouseEvent) => {
|
|
136
|
-
if (item.children && item.id) {
|
|
137
|
-
const openSubMenus = this.state.openSubMenus.slice();
|
|
138
|
-
if (openSubMenus.includes(item.id)) openSubMenus.splice(openSubMenus.indexOf(item.id), 1);
|
|
139
|
-
else openSubMenus.push(item.id);
|
|
140
|
-
this.setState({openSubMenus});
|
|
141
|
-
} else {
|
|
142
|
-
if (item.clickHandler)
|
|
143
|
-
item.clickHandler(evt);
|
|
144
|
-
if (this.state.phase === Phase.MENU)
|
|
145
|
-
this.closeMenu();
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
getBaseColor = (): string => convertColor(this.context.baseColor);
|
|
150
|
-
getContrastColor = (): string => convertColor(this.context.contrastColor);
|
|
151
|
-
|
|
152
|
-
getHeaderStyle = (): CSSProperties => {
|
|
153
|
-
const {transparent, headerColor} = this.props, baseColor = this.getBaseColor();
|
|
154
|
-
let backgroundColor: string;
|
|
155
|
-
if (headerColor && headerColor.length) backgroundColor = headerColor;
|
|
156
|
-
else if (transparent) backgroundColor = 'transparent';
|
|
157
|
-
else backgroundColor = baseColor;
|
|
158
|
-
return {backgroundColor};
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
getHeaderLabelStyle = (): CSSProperties => {
|
|
162
|
-
const {transparent, headerLabelColor} = this.props, contrastColor = this.getContrastColor();
|
|
163
|
-
let color: string;
|
|
164
|
-
if (headerLabelColor) color = headerLabelColor;
|
|
165
|
-
else if (transparent) color = '#3a4044';
|
|
166
|
-
else color = contrastColor;
|
|
167
|
-
return {color};
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
openMenu = () => {
|
|
171
|
-
this.setState({menuOpen: true}, this.addClickListener);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
removeClickListener = () => {
|
|
175
|
-
document.removeEventListener('click', this.onClick);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
addClickListener = () => {
|
|
179
|
-
document.addEventListener('click', this.onClick);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
resizeListener = () => {
|
|
183
|
-
if (!this.handlingResize) {
|
|
184
|
-
this.handlingResize = true;
|
|
185
|
-
this.determineType();
|
|
186
|
-
this.resizeTimeout = window.setTimeout(() => {
|
|
187
|
-
this.handlingResize = false;
|
|
188
|
-
this.resizeTimeout = null;
|
|
189
|
-
}, RESIZE_TIMEOUT)
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
determineType = (initial: boolean = false) => {
|
|
194
|
-
const container = document.getElementById(this.id), {forcedMenu} = this.props, currentPhase = this.state.phase,
|
|
195
|
-
screenWidth = getScreenWidth(true);
|
|
196
|
-
if (screenWidth === this.lastKnownScreenWidth && !initial) return;
|
|
197
|
-
this.lastKnownScreenWidth = screenWidth;
|
|
198
|
-
let phase: Phase.HEADER | Phase.MENU = Phase.HEADER;
|
|
199
|
-
if (forcedMenu) phase = Phase.MENU;
|
|
200
|
-
else if (container) {
|
|
201
|
-
const box = container.getBoundingClientRect(), width = box.width;
|
|
202
|
-
if (currentPhase === Phase.CALCULATING) {
|
|
203
|
-
if (width > screenWidth) {
|
|
204
|
-
phase = Phase.MENU;
|
|
205
|
-
this.lastKnownHeaderWidth = width;
|
|
206
|
-
} else phase = Phase.HEADER;
|
|
207
|
-
} else if (currentPhase === Phase.MENU) {
|
|
208
|
-
if (screenWidth >= this.lastKnownHeaderWidth) phase = Phase.HEADER;
|
|
209
|
-
else phase = Phase.MENU;
|
|
210
|
-
} else if (currentPhase === Phase.HEADER) {
|
|
211
|
-
if (screenWidth < width) {
|
|
212
|
-
this.lastKnownHeaderWidth = width;
|
|
213
|
-
phase = Phase.MENU;
|
|
214
|
-
} else phase = Phase.HEADER;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (currentPhase !== phase) this.setState({phase});
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
getHeaderItems = (): RenderAble[] => {
|
|
221
|
-
const {phase} = this.state, {items} = this.props;
|
|
222
|
-
if (phase !== Phase.MENU) return items.map(this.createHeaderRenderAble);
|
|
223
|
-
return items.filter((item: HeaderItem) => item.forceBar).map(this.createHeaderRenderAble);
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
getMenuItems = (): RenderAble[] => {
|
|
227
|
-
const {items} = this.props;
|
|
228
|
-
return items.filter(item => !item.forceBar).map(this.createMenuRenderAble);
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
createHeaderRenderAble = (item: HeaderItem): RenderAble => {
|
|
232
|
-
const {onClick, component, customClass, icon, iconOnly, label} = item,
|
|
233
|
-
renderAble: RenderAble = {
|
|
234
|
-
toRender: null,
|
|
235
|
-
clickHandler: onClick,
|
|
236
|
-
isComp: false,
|
|
237
|
-
}, className = classNames('dvr-header-item', customClass);
|
|
238
|
-
if (iconOnly) {
|
|
239
|
-
if (typeof icon === 'string') renderAble.toRender = <AwesomeIcon name={icon} className={className}/>;
|
|
240
|
-
// Type casted since props are checked by constructor
|
|
241
|
-
else renderAble.toRender = React.cloneElement((icon as React.ReactElement), {className});
|
|
242
|
-
} else if (component !== undefined) {
|
|
243
|
-
renderAble.isComp = true;
|
|
244
|
-
renderAble.toRender = React.cloneElement(component, {className});
|
|
245
|
-
} else renderAble.toRender = <label className={className}>{label}</label>;
|
|
246
|
-
|
|
247
|
-
if (item.children) renderAble.children = item.children.map(this.createHeaderRenderAble);
|
|
248
|
-
return renderAble;
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
createMenuRenderAble = (item: HeaderItem): RenderAble => {
|
|
252
|
-
const {onClick, component, customClass, icon, label} = item;
|
|
253
|
-
let className = classNames('dvr-menu-item', customClass);
|
|
254
|
-
const renderAble: RenderAble = {
|
|
255
|
-
toRender: null,
|
|
256
|
-
clickHandler: onClick,
|
|
257
|
-
isComp: false,
|
|
258
|
-
id: item.id,
|
|
259
|
-
};
|
|
260
|
-
if (component) {
|
|
261
|
-
className = classNames('dvr-menu-item', 'full', customClass);
|
|
262
|
-
renderAble.toRender = React.cloneElement(component, {className, containerClass: className});
|
|
263
|
-
renderAble.isComp = true;
|
|
264
|
-
} else if (icon && label) {
|
|
265
|
-
const iconComp = typeof icon === 'string' ?
|
|
266
|
-
<AwesomeIcon key='icon' name={icon} className={className}/> :
|
|
267
|
-
React.cloneElement(icon, {className, key: 'icon'});
|
|
268
|
-
const labelComp = <span key='label' className={className}>{label}</span>;
|
|
269
|
-
renderAble.toRender = [iconComp, labelComp];
|
|
270
|
-
} else if (icon) {
|
|
271
|
-
className = classNames('dvr-menu-item', 'full', customClass);
|
|
272
|
-
renderAble.toRender = typeof icon === 'string' ?
|
|
273
|
-
<AwesomeIcon name={icon} className={className}/> : React.cloneElement(icon, {className});
|
|
274
|
-
} else if (label) {
|
|
275
|
-
className = classNames('dvr-menu-item', 'single', customClass);
|
|
276
|
-
renderAble.toRender = <label className={className}>{label}</label>;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (item.children) renderAble.children = item.children.map(this.createMenuRenderAble);
|
|
280
|
-
return renderAble;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
attachRef = (ref: HTMLDivElement) => {
|
|
284
|
-
this.menu = ref;
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
getSubMenuHeight = (item: RenderAble): CSSProperties => {
|
|
288
|
-
const {openSubMenus} = this.state;
|
|
289
|
-
let height: number | string = 0;
|
|
290
|
-
if (item.id && openSubMenus.includes(item.id)) {
|
|
291
|
-
const childContainer = document.getElementById(item.id);
|
|
292
|
-
let totalHeight: number = 0;
|
|
293
|
-
if (childContainer) {
|
|
294
|
-
for (const elem of childContainer.querySelectorAll('div.child-item')) {
|
|
295
|
-
totalHeight += elem.getBoundingClientRect().height;
|
|
296
|
-
}
|
|
297
|
-
height = totalHeight + 'px';
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return {height};
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
setHeaderHeight = () => {
|
|
304
|
-
const header = document.getElementById(this.id);
|
|
305
|
-
let height = remToPx(4);
|
|
306
|
-
if (header)
|
|
307
|
-
height = header.getBoundingClientRect().height;
|
|
308
|
-
this.setState({headerHeight: height});
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
renderHeader = () => {
|
|
312
|
-
const {phase} = this.state, {transparent, leftMenuComp} = this.props;
|
|
313
|
-
return (
|
|
314
|
-
<div className={classNames('dvr-header-container', transparent && 'transparent')} id={this.id}
|
|
315
|
-
style={{...this.getHeaderStyle(), ...this.getHeaderLabelStyle()}}>
|
|
316
|
-
<div className='left-container'>
|
|
317
|
-
{phase === Phase.MENU && <AwesomeIcon name='bars' onClick={this.onClickBars}
|
|
318
|
-
className={classNames('menu-bars')}/>}
|
|
319
|
-
{leftMenuComp !== undefined && leftMenuComp}
|
|
320
|
-
</div>
|
|
321
|
-
<div className='items-container'>
|
|
322
|
-
{this.getHeaderItems().map((item: RenderAble, index: number) => (
|
|
323
|
-
<div key={index} className={classNames('header-item-container', item.isComp && 'comp',
|
|
324
|
-
item.clickHandler === null && 'no-click')}
|
|
325
|
-
onClick={item.clickHandler || voidFunction} style={this.getHeaderLabelStyle()}>
|
|
326
|
-
{item.toRender}
|
|
327
|
-
{item.children && this.renderHeaderChildren(item)}
|
|
328
|
-
</div>
|
|
329
|
-
))}
|
|
330
|
-
</div>
|
|
331
|
-
</div>
|
|
332
|
-
)
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
renderHeaderChildren = (item: RenderAble) => {
|
|
336
|
-
if (!item.children) return null;
|
|
337
|
-
return (
|
|
338
|
-
<div className='children-container'>
|
|
339
|
-
{item.children.map((item: RenderAble, index: number) => (
|
|
340
|
-
<div key={index} className='child-item' onClick={this.onClickChild(item)}>
|
|
341
|
-
{item.toRender}
|
|
342
|
-
</div>
|
|
343
|
-
))}
|
|
344
|
-
</div>
|
|
345
|
-
)
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
renderMenu = () => {
|
|
349
|
-
const {phase, menuOpen} = this.state, {
|
|
350
|
-
forcedMenu,
|
|
351
|
-
menuContainerClass
|
|
352
|
-
} = this.props, {headerHeight} = this.state;
|
|
353
|
-
if (phase !== Phase.MENU && !forcedMenu) return null;
|
|
354
|
-
return (
|
|
355
|
-
<div className={classNames('dvr-menu', menuContainerClass, menuOpen && 'open')} ref={this.attachRef}
|
|
356
|
-
style={{top: headerHeight + 'px'}}>
|
|
357
|
-
{this.getMenuItems().map((item: RenderAble, index: number) => (
|
|
358
|
-
<div key={index} className='menu-item-container' onClick={this.onClickMenuItem(item)}>
|
|
359
|
-
{item.toRender}
|
|
360
|
-
{item.children && this.renderMenuChildren(item)}
|
|
361
|
-
</div>
|
|
362
|
-
))}
|
|
363
|
-
</div>
|
|
364
|
-
);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
renderMenuChildren = (item: RenderAble) => {
|
|
368
|
-
if (!item.children) return null;
|
|
369
|
-
return (
|
|
370
|
-
<div className='children-container' id={item.id} style={this.getSubMenuHeight(item)}>
|
|
371
|
-
{item.children.map((item: RenderAble, index: number) => (
|
|
372
|
-
<div key={index} className='child-item' onClick={this.onClickMenuItem(item)}>
|
|
373
|
-
{item.toRender}
|
|
374
|
-
</div>
|
|
375
|
-
))}
|
|
376
|
-
</div>
|
|
377
|
-
);
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
renderFixedSpace = () => {
|
|
381
|
-
const {fix} = this.props, {headerHeight} = this.state;
|
|
382
|
-
if (!fix) return null;
|
|
383
|
-
return (<div style={{height: headerHeight + 'px'}}/>);
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
componentDidMount = () => {
|
|
387
|
-
this.determineType(true);
|
|
388
|
-
window.addEventListener('resize', this.resizeListener);
|
|
389
|
-
directTimeout(this.setHeaderHeight);
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
componentWillUnmount = () => {
|
|
393
|
-
this.removeClickListener();
|
|
394
|
-
window.removeEventListener('resize', this.resizeListener);
|
|
395
|
-
if (this.resizeTimeout)
|
|
396
|
-
window.clearTimeout(this.resizeTimeout);
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
render = () => {
|
|
400
|
-
const {containerClass, items, fix, topControl, topControlProps} = this.props, {phase} = this.state;
|
|
401
|
-
this.prepIds(items);
|
|
402
|
-
return (
|
|
403
|
-
<>
|
|
404
|
-
{this.renderFixedSpace()}
|
|
405
|
-
<div className={classNames('dvr-header', containerClass, phase, fix && 'fix')}>
|
|
406
|
-
{this.renderHeader()}
|
|
407
|
-
{this.renderMenu()}
|
|
408
|
-
</div>
|
|
409
|
-
{topControl && <TopButton {...topControlProps}/>}
|
|
410
|
-
</>
|
|
411
|
-
)
|
|
412
|
-
};
|
|
413
|
-
}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
@import '../../../style/variables';
|
|
6
|
-
|
|
7
|
-
.dvr-header {
|
|
8
|
-
width: fit-content;
|
|
9
|
-
|
|
10
|
-
&.calculating {
|
|
11
|
-
visibility: hidden;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
&.menu {
|
|
15
|
-
.dvr-header-container {
|
|
16
|
-
box-shadow: 0 1px 5px 0 rgba(black, 0.2), 0 2px 2px 0 rgba(black, 0.14), 0 3px 1px -2px rgba(black, 0.12) !important;
|
|
17
|
-
padding: .5rem 1rem;
|
|
18
|
-
width: 100vw;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&.header {
|
|
23
|
-
.dvr-header-container {
|
|
24
|
-
min-width: 100vw;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
$height: 4rem;
|
|
29
|
-
|
|
30
|
-
.dvr-header-container {
|
|
31
|
-
@include backgroundShadow;
|
|
32
|
-
padding: .5rem 2rem;
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
justify-content: space-between;
|
|
36
|
-
min-height: $height;
|
|
37
|
-
box-sizing: border-box;
|
|
38
|
-
|
|
39
|
-
.left-container {
|
|
40
|
-
display: grid;
|
|
41
|
-
grid-template-columns: auto auto;
|
|
42
|
-
align-items: center;
|
|
43
|
-
|
|
44
|
-
.menu-bars {
|
|
45
|
-
cursor: pointer;
|
|
46
|
-
padding: 1rem;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.items-container {
|
|
51
|
-
display: flex;
|
|
52
|
-
align-items: center;
|
|
53
|
-
|
|
54
|
-
.header-item-container {
|
|
55
|
-
margin: 0 .6rem;
|
|
56
|
-
padding: .2rem;
|
|
57
|
-
cursor: pointer;
|
|
58
|
-
border-bottom: 1px solid transparent;
|
|
59
|
-
transition: border-color .2s ease-in-out;
|
|
60
|
-
position: relative;
|
|
61
|
-
|
|
62
|
-
.children-container {
|
|
63
|
-
@include centerX;
|
|
64
|
-
visibility: hidden;
|
|
65
|
-
opacity: 0;
|
|
66
|
-
transition: visibility .1s ease-in-out, opacity .1s ease-in-out, box-shadow .1s ease-in-out;
|
|
67
|
-
position: absolute;
|
|
68
|
-
top: 100%;
|
|
69
|
-
background-color: white;
|
|
70
|
-
|
|
71
|
-
.child-item {
|
|
72
|
-
padding: .5rem;
|
|
73
|
-
color: $color-gray-header;
|
|
74
|
-
border-bottom: 1px solid $color-gray-4;
|
|
75
|
-
transition: background-color .2s ease-in-out;
|
|
76
|
-
display: flex;
|
|
77
|
-
justify-content: center;
|
|
78
|
-
|
|
79
|
-
label {
|
|
80
|
-
font-size: .9rem;
|
|
81
|
-
color: $color-gray-header;
|
|
82
|
-
font-weight: normal;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&:last-child {
|
|
86
|
-
border-bottom: none;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
&:hover {
|
|
90
|
-
background-color: $color-gray-6;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
&:hover {
|
|
96
|
-
border-color: currentColor;
|
|
97
|
-
|
|
98
|
-
.children-container {
|
|
99
|
-
@include backgroundShadow;
|
|
100
|
-
visibility: visible;
|
|
101
|
-
opacity: 1;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
label.dvr-header-item {
|
|
106
|
-
font-weight: 500;
|
|
107
|
-
white-space: nowrap;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&.comp {
|
|
111
|
-
border-color: transparent !important;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
&.no-click {
|
|
115
|
-
cursor: default;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
&.transparent {
|
|
121
|
-
box-shadow: none;
|
|
122
|
-
background-color: transparent;
|
|
123
|
-
|
|
124
|
-
.items-container .header-item-container {
|
|
125
|
-
color: $color-gray-header;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.dvr-menu {
|
|
131
|
-
@include backgroundShadow;
|
|
132
|
-
position: fixed;
|
|
133
|
-
height: 100%;
|
|
134
|
-
top: $height;
|
|
135
|
-
left: 0;
|
|
136
|
-
transform: translateX(-100%);
|
|
137
|
-
box-shadow: 0 1px 5px 0 rgba(black, 0.2), 0 2px 2px 0 rgba(black, 0.14), 0 3px 1px -2px rgba(black, 0.12);
|
|
138
|
-
transition: transform .2s ease-in-out;
|
|
139
|
-
padding: 1rem;
|
|
140
|
-
background-color: $color-gray-header;
|
|
141
|
-
max-width: 100vw;
|
|
142
|
-
box-sizing: border-box;
|
|
143
|
-
z-index: 9999;
|
|
144
|
-
|
|
145
|
-
&, * {
|
|
146
|
-
user-select: none;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.menu-item-container {
|
|
150
|
-
color: $color-gray-header-text;
|
|
151
|
-
padding: .75rem 1rem;
|
|
152
|
-
cursor: pointer;
|
|
153
|
-
transition: background-color .2s ease-in-out;
|
|
154
|
-
border-radius: .25rem;
|
|
155
|
-
display: grid;
|
|
156
|
-
grid-template-columns: 1rem auto;
|
|
157
|
-
grid-column-gap: 1rem;
|
|
158
|
-
|
|
159
|
-
.dvr-menu-item {
|
|
160
|
-
&.full {
|
|
161
|
-
grid-column-start: span 2;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
&.single {
|
|
165
|
-
grid-column-start: 2;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.combined-label {
|
|
170
|
-
display: flex;
|
|
171
|
-
align-items: center;
|
|
172
|
-
|
|
173
|
-
span:first-child {
|
|
174
|
-
margin-right: 1rem;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.children-container {
|
|
179
|
-
overflow: hidden;
|
|
180
|
-
height: 0;
|
|
181
|
-
transition: height .2s ease-in-out;
|
|
182
|
-
grid-column-start: 2;
|
|
183
|
-
padding-top: .5rem;
|
|
184
|
-
|
|
185
|
-
.child-item {
|
|
186
|
-
padding: .75rem;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
&:hover {
|
|
191
|
-
background-color: darken($color-gray-header, 10%);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
&.open {
|
|
196
|
-
transform: none;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
&.fix {
|
|
201
|
-
position: fixed;
|
|
202
|
-
top: 0;
|
|
203
|
-
left: 0;
|
|
204
|
-
z-index: $z-index-menu + 1;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import '../../style/fonts/fontAwesome/css/all.min.css';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import {CSSProperties} from "react";
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import {IndexedObject} from "../util/interfaces";
|
|
10
|
-
|
|
11
|
-
interface Props extends IndexedObject<any> {
|
|
12
|
-
name: string;
|
|
13
|
-
comp?: 'span' | 'i';
|
|
14
|
-
className?: string;
|
|
15
|
-
prefix?: string;
|
|
16
|
-
style?: CSSProperties;
|
|
17
|
-
id?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default class AwesomeIcon extends React.Component<Props> {
|
|
21
|
-
static defaultProps = {
|
|
22
|
-
comp: 'span',
|
|
23
|
-
prefix: 'fas',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
getRenderProps = () => {
|
|
27
|
-
const props: IndexedObject<any> = {};
|
|
28
|
-
for (const key of Object.keys(this.props)) {
|
|
29
|
-
if (['comp', 'name', 'className', 'prefix'].includes(key)) continue;
|
|
30
|
-
props[key] = this.props[key];
|
|
31
|
-
}
|
|
32
|
-
return props;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
render = () => {
|
|
36
|
-
const {comp, name, className, prefix, style, id} = this.props, idProp = id ? {id} : {};
|
|
37
|
-
switch (comp) {
|
|
38
|
-
case "span":
|
|
39
|
-
return <span {...this.getRenderProps()} className={classNames(prefix, `fa-${name}`, className)}
|
|
40
|
-
style={style} {...idProp}/>;
|
|
41
|
-
case "i":
|
|
42
|
-
return <i {...this.getRenderProps()} className={classNames(prefix, `fa-${name}`, className)}
|
|
43
|
-
style={style} {...idProp}/>;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|