@dvrd/dvr-controls 1.0.25 → 1.0.27
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvrd/dvr-controls",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "Custom web controls",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"files": [
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"1": "not dead",
|
|
18
18
|
"2": "ie >= 11"
|
|
19
19
|
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react-router-dom": "6.8.1"
|
|
22
|
+
},
|
|
20
23
|
"dependencies": {
|
|
21
24
|
"@fortawesome/fontawesome-svg-core": "6.3.0",
|
|
22
25
|
"@fortawesome/free-brands-svg-icons": "6.3.0",
|
|
@@ -42,7 +45,6 @@
|
|
|
42
45
|
"react-color": "2.19.3",
|
|
43
46
|
"react-dom": "18.2.0",
|
|
44
47
|
"react-rnd": "10.4.1",
|
|
45
|
-
"react-router-dom": "6.8.1",
|
|
46
48
|
"typescript": "4.9.5",
|
|
47
49
|
"uuid": "9.0.0"
|
|
48
50
|
}
|
|
@@ -52,7 +52,7 @@ export default function DvrdDatePicker(props: Props) {
|
|
|
52
52
|
<label className='field-label'>{label}</label>
|
|
53
53
|
<div className='value-container' onClick={onClickContainer}>
|
|
54
54
|
<label className={classNames('value', !value && 'placeholder')}>{value?.format(format) ?? placeholder ??
|
|
55
|
-
|
|
55
|
+
''}</label>
|
|
56
56
|
<AwesomeIcon name='calendar-alt' className='calendar-icon'/>
|
|
57
57
|
</div>
|
|
58
58
|
<Picker onClose={onClosePicker} onChange={onChangePicker} open={pickerOpen} value={value}
|
|
@@ -104,7 +104,7 @@ class Picker extends PureComponent<PickerProps> {
|
|
|
104
104
|
|
|
105
105
|
onSelectDay = (day: number, month?: number, year?: number) => () => {
|
|
106
106
|
const {onChange, value} = this.props, pickerValue = this.getPickerValue();
|
|
107
|
-
if (day
|
|
107
|
+
if (day || value === null) {
|
|
108
108
|
pickerValue.date(day);
|
|
109
109
|
if (month !== undefined) pickerValue.month(month);
|
|
110
110
|
if (year !== undefined) pickerValue.year(year);
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Copyright (c) 2021. Dave van Rijn Development
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import React from "react";
|
|
5
|
+
import React, {useEffect, useRef} from "react";
|
|
6
6
|
import {debug} from "./miscUtil";
|
|
7
7
|
import {getScreenHeight, getScreenWidth} from "./responsiveUtil";
|
|
8
8
|
import {generateUUID} from "./controlUtil";
|
|
9
|
+
import {addCustomEventListener, removeCustomEventListener} from "./eventUtil";
|
|
9
10
|
|
|
10
11
|
export const generateComponentId = (id?: string | null, lettersOnly: boolean = true): string => {
|
|
11
12
|
if (id !== null && id !== undefined) return id;
|
|
@@ -56,4 +57,17 @@ export const getElementTop = (element: string | HTMLElement | null): number => {
|
|
|
56
57
|
return box.top + scrollTop;
|
|
57
58
|
}
|
|
58
59
|
return 0;
|
|
59
|
-
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export function useEvent(eventName: string, handler: Function, ...deps: any): string {
|
|
63
|
+
const id = useRef<string>(generateComponentId());
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
addCustomEventListener(id.current, eventName, handler);
|
|
67
|
+
return function () {
|
|
68
|
+
removeCustomEventListener(id.current, eventName);
|
|
69
|
+
}
|
|
70
|
+
}, [...deps])
|
|
71
|
+
|
|
72
|
+
return id.current;
|
|
73
|
+
}
|
package/src/js/util/eventUtil.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import {DialogActions} from "../dialog/dialogController";
|
|
7
|
-
import {DialogConfig
|
|
7
|
+
import {DialogConfig} from "./interfaces";
|
|
8
8
|
|
|
9
9
|
interface ListenerShape {
|
|
10
10
|
component: string,
|
|
@@ -14,6 +14,10 @@ interface ListenerShape {
|
|
|
14
14
|
|
|
15
15
|
const listeners: ListenerShape[] = [];
|
|
16
16
|
|
|
17
|
+
export function getCurrentListeners(): Array<ListenerShape> {
|
|
18
|
+
return listeners;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
export const addCustomEventListener = (componentName: string, eventName: string, eventHandler: Function): boolean => {
|
|
18
22
|
if (listenerExists(componentName, eventName)) return false;
|
|
19
23
|
listeners.push({component: componentName, eventName, eventHandler});
|