@talend/react-containers
Version:
Provide connected components aka containers for @talend/react-cmf based on @talend/react-components.
50 lines (49 loc) • 2.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.componentId = componentId;
exports.default = void 0;
exports.deleteNotification = deleteNotification;
exports.mergeProps = mergeProps;
var _reactCmf = require("@talend/react-cmf");
var _Notification = _interopRequireWildcard(require("./Notification.container"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function componentId(ownProps) {
return ownProps && ownProps.id || 'Notification';
}
function deleteNotification(indexNotification) {
return function mutator(prevStateProps) {
const notifications = prevStateProps.state.get('notifications');
const index = notifications.indexOf(indexNotification);
if (index > -1) {
const newNotif = notifications.delete(index);
return prevStateProps.state.set('notifications', newNotif);
}
return prevStateProps.state;
};
}
function mergeProps(stateProps, dispatchProps, ownProps) {
return {
deleteNotification(i) {
dispatchProps.setState(deleteNotification(i));
},
...ownProps,
...stateProps,
...dispatchProps
};
}
var _default = exports.default = (0, _reactCmf.cmfConnect)({
componentId,
defaultState: _Notification.DEFAULT_STATE,
defaultProps: {
saga: 'Notification#default'
},
mergeProps,
omitCMFProps: true,
withComponentRegistry: true,
withDispatch: true,
withDispatchActionCreator: true,
withComponentId: true
})(_Notification.default);
//# sourceMappingURL=Notification.connect.js.map