@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
36 lines • 1.94 kB
JavaScript
import * as tslib_1 from "tslib";
import * as React from 'react';
import { PureComponent, Children } from 'react';
import { ResourcedTaskItem as AkTaskItem } from '@atlaskit/task-decision';
import { default as ProviderFactory, WithProviders } from '../../../providerFactory';
var TaskItem = (function (_super) {
tslib_1.__extends(TaskItem, _super);
function TaskItem(props) {
var _this = _super.call(this, props) || this;
_this.renderWithProvider = function (providers) {
var taskDecisionProvider = providers.taskDecisionProvider;
var _a = _this.props, children = _a.children, localId = _a.localId, state = _a.state, rendererContext = _a.rendererContext;
var _b = rendererContext || { objectAri: '', containerAri: '' }, objectAri = _b.objectAri, containerAri = _b.containerAri;
return (React.createElement(AkTaskItem, { taskId: localId, isDone: state === 'DONE', objectAri: objectAri, containerAri: containerAri, taskDecisionProvider: taskDecisionProvider }, children));
};
_this.providerFactory = props.providers || new ProviderFactory();
return _this;
}
TaskItem.prototype.componentWillUnmount = function () {
if (!this.props.providers) {
// new ProviderFactory is created if no `providers` has been set
// in this case when component is unmounted it's safe to destroy this providerFactory
this.providerFactory.destroy();
}
};
TaskItem.prototype.render = function () {
var children = this.props.children;
if (Children.count(children) === 0) {
return null;
}
return (React.createElement(WithProviders, { providers: ['taskDecisionProvider'], providerFactory: this.providerFactory, renderNode: this.renderWithProvider }));
};
return TaskItem;
}(PureComponent));
export default TaskItem;
//# sourceMappingURL=taskItem.js.map