cspace-ui
Version:
CollectionSpace user interface for browsers
46 lines (45 loc) • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.ConnectedComboBoxInput = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _reactRedux = require("react-redux");
var _reactIntl = require("react-intl");
var _cspaceInput = require("cspace-input");
var _reducers = require("../../reducers");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const {
ComboBoxInput
} = _cspaceInput.components;
const mapStateToProps = (state, ownProps) => {
const {
intl,
source: optionListName
} = ownProps;
const options = (0, _reducers.getOptionList)(state, optionListName);
return {
options,
formatOptionLabel: option => option.message ? intl.formatMessage(option.message) : option.value
};
};
const mapDispatchToProps = {};
const mergeProps = (stateProps, dispatchProps, ownProps) => {
const {
intl,
source,
...remainingOwnProps
} = ownProps;
return {
...remainingOwnProps,
...stateProps,
...dispatchProps
};
};
const ConnectedComboBoxInput = exports.ConnectedComboBoxInput = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps, mergeProps)(ComboBoxInput);
const IntlizedConnectedComboBoxInput = (0, _reactIntl.injectIntl)(ConnectedComboBoxInput);
IntlizedConnectedComboBoxInput.propTypes = {
...ComboBoxInput.propTypes,
source: _propTypes.default.string
};
var _default = exports.default = IntlizedConnectedComboBoxInput;