@bluemarble/bm-components 0.0.18 → 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,10 +14859,11 @@ 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"]);
|
|
14866
|
+
const defaultOption = useRef();
|
|
14866
14867
|
const onChange = (_, newValue) => {
|
|
14867
14868
|
if (getOptionValue) {
|
|
14868
14869
|
setValue(getOptionValue(newValue));
|
|
@@ -14870,7 +14871,19 @@ function FormikAutocomplete(_a) {
|
|
|
14870
14871
|
else
|
|
14871
14872
|
setValue(newValue);
|
|
14872
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
|
+
};
|
|
14881
|
+
useEffect(() => {
|
|
14882
|
+
if (!defaultOption.current) {
|
|
14883
|
+
defaultOption.current = props.options.find((option) => String(Object.values(option)[0]) === String(defaultValue));
|
|
14884
|
+
}
|
|
14885
|
+
}, []);
|
|
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 })));
|
|
14874
14887
|
}
|
|
14875
14888
|
|
|
14876
14889
|
const Checkbox = (_a) => {
|