@amsterdam/amsterdam-react-final-form
Advanced tools
Comparing version 0.1.112 to 0.1.113
@@ -65,3 +65,2 @@ "use strict"; | ||
}), _c = _b.input, onChange = _c.onChange, value = _c.value, meta = _b.meta; | ||
var _d = react_1.useState({}), mappedOptions = _d[0], setMappedOptions = _d[1]; | ||
// We map complex objects in a 'simple' structure `UnboundSelectField` understands. | ||
@@ -76,10 +75,11 @@ // | ||
// Whenever a change happens, we map back to the original object and call onChange with it. | ||
react_1.useEffect(function () { setMappedOptions(options.reduce(function (acc, option, index) { | ||
var mappedOptions = options.reduce(function (acc, option, index) { | ||
var _a; | ||
return (__assign((_a = {}, _a[index] = option[optionLabelField], _a), acc)); | ||
}, {})); }, [options, optionLabelField, setMappedOptions]); | ||
}, {}); | ||
// On change, map back to original object: | ||
var handleChange = react_1.useCallback(function (e) { onChange(options[e.target.value]); }, [onChange, options]); | ||
return react_1["default"].createElement(UnboundSelectField_1["default"], __assign({ name: name, error: meta.modified && meta.error, options: mappedOptions, onChange: handleChange, value: findIndex_1.findIndex(options, value).toString() }, restProps)); | ||
var handleChange = react_1.useCallback(function (e) { return onChange(options[e.target.value]); }, [onChange, options]); | ||
var index = findIndex_1.findIndex(options, value); | ||
return react_1["default"].createElement(UnboundSelectField_1["default"], __assign({ name: name, error: meta.modified && meta.error, options: mappedOptions, onChange: handleChange, value: index > -1 ? index.toString() : undefined }, restProps)); | ||
} | ||
exports["default"] = ComplexSelectField; |
{ | ||
"name": "@amsterdam/amsterdam-react-final-form", | ||
"version": "0.1.112", | ||
"version": "0.1.113", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/amsterdam/amsterdam-react-final-form.git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150602