@agility/plenum-ui 1.2.6 → 1.2.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.
@@ -22,7 +22,7 @@ export interface ComboboxProps<T extends Record<string, unknown>> {
22
22
  isRequired?: boolean;
23
23
  /** Message shown under field */
24
24
  message?: string;
25
- value?: string;
25
+ displayValue?: string;
26
26
  /**
27
27
  * Whether this item is nullable or not.
28
28
  *
@@ -31,4 +31,4 @@ export interface ComboboxProps<T extends Record<string, unknown>> {
31
31
  */
32
32
  nullable?: boolean;
33
33
  }
34
- export declare const Combobox: <T extends Record<string, unknown>>({ label, items, displayProperty, keyProperty, onChange, placeholder, message, isDisabled, isError, isRequired, id, nullable }: ComboboxProps<T>) => JSX.Element;
34
+ export declare const Combobox: <T extends Record<string, unknown>>({ label, items, displayProperty, displayValue, keyProperty, onChange, placeholder, message, isDisabled, isError, isRequired, id, nullable }: ComboboxProps<T>) => JSX.Element;
package/lib/index.esm.js CHANGED
@@ -7158,7 +7158,7 @@ function classNames() {
7158
7158
  }
7159
7159
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
7160
7160
  var Combobox = function (_a) {
7161
- var label = _a.label, items = _a.items, displayProperty = _a.displayProperty, keyProperty = _a.keyProperty, onChange = _a.onChange, placeholder = _a.placeholder, message = _a.message, isDisabled = _a.isDisabled, isError = _a.isError, isRequired = _a.isRequired, id = _a.id, nullable = _a.nullable;
7161
+ var label = _a.label, items = _a.items, displayProperty = _a.displayProperty, displayValue = _a.displayValue, keyProperty = _a.keyProperty, onChange = _a.onChange, placeholder = _a.placeholder, message = _a.message, isDisabled = _a.isDisabled, isError = _a.isError, isRequired = _a.isRequired, id = _a.id, nullable = _a.nullable;
7162
7162
  var _b = useState(""), query = _b[0], setQuery = _b[1];
7163
7163
  var _c = useState(), selectedItem = _c[0], setSelectedItem = _c[1];
7164
7164
  var onChangeValue = function (value) {
@@ -7169,6 +7169,12 @@ var Combobox = function (_a) {
7169
7169
  setSelectedItem(value);
7170
7170
  }
7171
7171
  };
7172
+ useEffect(function () {
7173
+ if (displayValue) {
7174
+ var dv = items.find(function (i) { return i[displayProperty] === displayValue; });
7175
+ setSelectedItem(dv);
7176
+ }
7177
+ }, [displayValue]);
7172
7178
  useEffect(function () {
7173
7179
  typeof onChange === "function" && onChange(selectedItem);
7174
7180
  }, [selectedItem]);