@bluemarble/bm-components 0.0.20 → 0.0.21

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/dist/esm/index.js CHANGED
@@ -14859,7 +14859,7 @@ function BaseInput(props) {
14859
14859
  return (React__default.createElement(Autocomplete$1, Object.assign({ fullWidth: true, renderInput: (params) => React__default.createElement(TextField, Object.assign({ label: props.label }, params)) }, props)));
14860
14860
  }
14861
14861
  function FormikAutocomplete(_a) {
14862
- var { getOptionValue } = _a, props = __rest(_a, ["getOptionValue"]);
14862
+ var { getOptionValue, option } = _a, props = __rest(_a, ["getOptionValue", "option"]);
14863
14863
  const [_b, , { setValue }] = useField({
14864
14864
  name: props.name,
14865
14865
  }), { value: defaultValue } = _b, field = __rest(_b, ["value"]);
@@ -14871,11 +14871,19 @@ function FormikAutocomplete(_a) {
14871
14871
  else
14872
14872
  setValue(newValue);
14873
14873
  };
14874
+ const getOptionLabel = (item) => {
14875
+ if (props === null || props === void 0 ? void 0 : props.getOptionLabel)
14876
+ return props.getOptionLabel(item);
14877
+ else if (option === null || option === void 0 ? void 0 : option.label)
14878
+ return item[option.label];
14879
+ return "[getOptionLabel] error";
14880
+ };
14874
14881
  useEffect(() => {
14875
- if (!defaultOption.current)
14882
+ if (!defaultOption.current) {
14876
14883
  defaultOption.current = props.options.find((option) => String(Object.values(option)[0]) === String(defaultValue));
14884
+ }
14877
14885
  }, []);
14878
- return (React__default.createElement(Autocomplete$1, Object.assign({}, props, { renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, field, { label: props.label }))), defaultValue: defaultOption.current, onChange: onChange })));
14886
+ return (React__default.createElement(Autocomplete$1, Object.assign({}, props, { getOptionLabel: getOptionLabel, renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, field, { label: props.label }))), defaultValue: defaultOption.current, onChange: onChange })));
14879
14887
  }
14880
14888
 
14881
14889
  const Checkbox = (_a) => {