@dvrd/dvr-controls 1.0.73 → 1.0.74

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.73",
3
+ "version": "1.0.74",
4
4
  "description": "Custom web controls",
5
5
  "main": "index.ts",
6
6
  "files": [
@@ -45,8 +45,6 @@ export default function DvrdSelectController(props: Props) {
45
45
  if (!search) return items;
46
46
  return items.filter((item) => stringContains(item.label.toString(), search));
47
47
  }, [items, search]);
48
- const _value = useMemo(() => unControlled ? internalValue : value,
49
- [unControlled, internalValue, value]);
50
48
 
51
49
  function _onChange(value: ValueType, submit: boolean = true) {
52
50
  return function () {
@@ -62,15 +60,18 @@ export default function DvrdSelectController(props: Props) {
62
60
  useEffect(() => {
63
61
  if (multi && !Array.isArray(value)) throw new TypeError('Value must be an array in multi mode');
64
62
  else if (!multi && Array.isArray(value)) throw new TypeError('Value must be a string or number in single mode');
63
+ }, [value, multi]);
64
+
65
+ useEffect(() => {
65
66
  if (!unControlled && value !== internalValue) setInternalValue(value);
66
- }, [value, multi, unControlled]);
67
+ }, [value, unControlled]);
67
68
 
68
69
  const itemsPosition = props.itemsPosition ?? 'bottom';
69
70
  const optionsContainerHeight = props.optionsContainerHeight ?? '15rem';
70
71
  const selectOnly = props.selectOnly !== false;
71
72
  if (multi) return (
72
73
  <DvrdMultiSelect onChange={_onChange} onChangeSearch={onChangeSearch}
73
- selected={_value as Array<string | number>} items={_items} itemsPosition={itemsPosition}
74
+ selected={internalValue as Array<string | number>} items={_items} itemsPosition={itemsPosition}
74
75
  selectOnly={selectOnly} searchValue={search} optionsContainerHeight={optionsContainerHeight}
75
76
  className={className} error={error} label={label} arrowClassName={arrowClassName}
76
77
  errorClassName={errorClassName} itemClassName={itemClassName} submitOnClose={submitOnClose}
@@ -78,7 +79,7 @@ export default function DvrdSelectController(props: Props) {
78
79
  labelClassName={labelClassName} disabled={disabled} placeholder={placeholder}/>
79
80
  );
80
81
  return (
81
- <DvrdSelect onChange={_onChange} onChangeSearch={onChangeSearch} value={_value as number | string}
82
+ <DvrdSelect onChange={_onChange} onChangeSearch={onChangeSearch} value={internalValue as number | string}
82
83
  items={_items} itemsPosition={itemsPosition} selectOnly={selectOnly} searchValue={search}
83
84
  optionsContainerHeight={optionsContainerHeight} className={className} error={error} label={label}
84
85
  arrowClassName={arrowClassName} errorClassName={errorClassName} itemClassName={itemClassName}