@talend/react-containers
Version:
Provide connected components aka containers for @talend/react-cmf based on @talend/react-components.
81 lines • 2.75 kB
JavaScript
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { cmfConnect } from '@talend/react-cmf';
import { GuidedTour } from "@talend/react-components";
import { omit } from "lodash";
import { jsx as _jsx } from "react/jsx-runtime";
class GuidedTourContainer extends Component {
constructor(...args) {
super(...args);
_defineProperty(this, "state", {
controls: true
});
_defineProperty(this, "getSteps", () => {
const {
steps,
t
} = this.props;
if (steps) {
if (typeof steps === 'function') {
return steps({
showControls: this.showControls,
hideControls: this.hideControls,
t
});
}
return steps;
}
return undefined;
});
_defineProperty(this, "closeTour", () => {
this.showControls();
if (this.props.onClose) {
this.props.onClose();
}
this.props.setState({
show: false
});
});
_defineProperty(this, "showControls", () => {
this.setState({
controls: true
});
});
_defineProperty(this, "hideControls", () => {
this.setState({
controls: false
});
});
}
render() {
const steps = this.getSteps();
if (!steps || !steps.length) {
return /*#__PURE__*/_jsx(Fragment, {});
}
const {
controls
} = this.state;
return /*#__PURE__*/_jsx(GuidedTour, {
isOpen: this.props.state.get('show'),
steps: steps,
onRequestClose: this.closeTour,
showCloseButton: controls,
showButtons: controls,
disableKeyboardNavigation: !controls,
disableAllInteractions: !controls,
...omit(this.props, cmfConnect.INJECTED_PROPS)
});
}
}
_defineProperty(GuidedTourContainer, "displayName", 'Container(GuidedTour)');
_defineProperty(GuidedTourContainer, "propTypes", {
...cmfConnect.propTypes,
show: PropTypes.bool,
steps: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),
onClose: PropTypes.func
});
export default GuidedTourContainer;
//# sourceMappingURL=GuidedTour.container.js.map