@dvrd/dvr-controls 1.0.56 → 1.0.58
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.58",
|
|
4
4
|
"description": "Custom web controls",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"files": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/react-color": "2.13.5",
|
|
49
49
|
"@types/react-dom": "^18.0.11",
|
|
50
50
|
"@types/uuid": "9.0.0",
|
|
51
|
-
"classnames": "2.
|
|
51
|
+
"classnames": "2.5.1",
|
|
52
52
|
"dompurify": "3.0.0",
|
|
53
53
|
"js-cookie": "3.0.1",
|
|
54
54
|
"lodash.defer": "^4.1.0",
|
|
@@ -11,7 +11,7 @@ import defer from 'lodash.defer';
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
interface Props {
|
|
14
|
-
onChange: (value: SelectValueType, evt
|
|
14
|
+
onChange: (value: SelectValueType, evt?: React.MouseEvent | React.ChangeEvent) => void;
|
|
15
15
|
items: Array<GroupedSelectItem>;
|
|
16
16
|
value: SelectValueType;
|
|
17
17
|
label?: string;
|
|
@@ -64,14 +64,20 @@ function DVRDGroupedSelect(props: Props, ref: ForwardedRef<GroupedSelectRef>) {
|
|
|
64
64
|
if (!selectedItem) return null;
|
|
65
65
|
return selectedItem.valueLabel ?? selectedItem.label ?? '';
|
|
66
66
|
}, [value, items]);
|
|
67
|
+
const longestValue = useMemo(() => {
|
|
68
|
+
let longest: string = '';
|
|
69
|
+
for (const item of items)
|
|
70
|
+
if (item.label.toString().length > longest.length)
|
|
71
|
+
longest = item.label.toString();
|
|
72
|
+
return longest;
|
|
73
|
+
}, [items]);
|
|
67
74
|
const itemsContainer = useRef<HTMLDivElement>(null);
|
|
68
75
|
|
|
69
76
|
function onSelectItem(item: GroupedSelectItem) {
|
|
70
77
|
return function (evt: React.MouseEvent) {
|
|
71
78
|
evt.stopPropagation();
|
|
72
79
|
if (item.value !== undefined) {
|
|
73
|
-
|
|
74
|
-
onChange(item.value, evt);
|
|
80
|
+
onChange(item.value, evt);
|
|
75
81
|
onToggleOpen(false);
|
|
76
82
|
}
|
|
77
83
|
}
|
|
@@ -129,6 +135,7 @@ function DVRDGroupedSelect(props: Props, ref: ForwardedRef<GroupedSelectRef>) {
|
|
|
129
135
|
{placeholderHidden ? 'placeholder' : placeholder}</label>
|
|
130
136
|
}
|
|
131
137
|
<AwesomeIcon name={chevIcon} className='chev-icon'/>
|
|
138
|
+
<div style={{height: 0, visibility: 'hidden'}}>{longestValue}</div>
|
|
132
139
|
</div>
|
|
133
140
|
);
|
|
134
141
|
}
|
|
@@ -218,7 +218,7 @@ export default class SelectController extends React.Component<SelectProps, State
|
|
|
218
218
|
|
|
219
219
|
// noinspection JSUnusedGlobalSymbols
|
|
220
220
|
/**
|
|
221
|
-
* Function for external
|
|
221
|
+
* Function for external component to close the item container.
|
|
222
222
|
*/
|
|
223
223
|
closeItems = () => {
|
|
224
224
|
this.setState({itemsOpen: false, isFocused: false});
|