@dvrd/dvr-controls 1.0.55 → 1.0.57

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.55",
3
+ "version": "1.0.57",
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.3.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",
@@ -29,7 +29,7 @@ interface Props {
29
29
  placeholder?: string;
30
30
  }
31
31
 
32
- export type GroupedSelectRef = { open: VoidFunction; close: VoidFunction; }
32
+ export type GroupedSelectRef = { open: VoidFunction; close: VoidFunction; toggle: (forcedValue?: boolean) => void };
33
33
 
34
34
  function findInItems(items: Array<GroupedSelectItem>, value: string | number): GroupedSelectItem | null {
35
35
  for (const item of items) {
@@ -64,6 +64,13 @@ 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) {
@@ -129,6 +136,7 @@ function DVRDGroupedSelect(props: Props, ref: ForwardedRef<GroupedSelectRef>) {
129
136
  {placeholderHidden ? 'placeholder' : placeholder}</label>
130
137
  }
131
138
  <AwesomeIcon name={chevIcon} className='chev-icon'/>
139
+ <div style={{height: 0, visibility: 'hidden'}}>{longestValue}</div>
132
140
  </div>
133
141
  );
134
142
  }
@@ -200,7 +208,7 @@ function DVRDGroupedSelect(props: Props, ref: ForwardedRef<GroupedSelectRef>) {
200
208
  }, [open]);
201
209
 
202
210
  useImperativeHandle(ref, () => ({
203
- open: onOpen, close: onClose
211
+ open: onOpen, close: onClose, toggle: onToggleOpen
204
212
  }));
205
213
 
206
214
  return (
@@ -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 components to close the item container.
221
+ * Function for external component to close the item container.
222
222
  */
223
223
  closeItems = () => {
224
224
  this.setState({itemsOpen: false, isFocused: false});
@@ -34,7 +34,6 @@
34
34
  background-color: white;
35
35
 
36
36
  .grouped-select-placeholder, .grouped-select-value {
37
- font-family: avenir-light, sans-serif;
38
37
  user-select: none;
39
38
  vertical-align: middle;
40
39
  }
@@ -63,7 +62,7 @@
63
62
  background-color: white;
64
63
  position: absolute;
65
64
  left: 1px;
66
- width: calc(100% - 2px);
65
+ min-width: calc(100% - 2px);
67
66
  transition: visibility .2s ease-in-out, opacity .2s ease-in-out;
68
67
  visibility: hidden;
69
68
  opacity: 0;