swagger-editor
Version:
- [Anonymized analytics](#anonymized-analytics) - [Getting started](#getting-started) - [Prerequisites](#prerequisites) - [Installation](#installation) - [Usage](#usage) - [Development](#development) - [Prerequisites](#prerequisites) - [Setting
91 lines (90 loc) • 2.44 kB
JavaScript
import { Component as e } from "react";
import t from "swagger-ui-react";
import n from "prop-types";
import { jsx as r } from "react/jsx-runtime";
//#region src/plugins/editor-safe-render/components/ErrorBoundary.jsx
var i = class extends e {
static defaultState = {
hasError: !1,
error: null,
editorContent: null
};
static getDerivedStateFromError(e) {
return {
hasError: !0,
error: e
};
}
constructor(...e) {
super(...e), this.state = this.constructor.defaultState;
}
componentDidMount() {
let { editorSelectors: e } = this.props;
this.setState({ editorContent: e.selectContent() });
}
componentDidUpdate(e, t) {
let { editorSelectors: n } = this.props;
if (t.editorContent === n.selectContent()) return;
let r = { editorContent: n.selectContent() };
t.hasError && (r.hasError = !1, r.error = null), this.setState(r);
}
componentDidCatch(e, t) {
let { fn: { componentDidCatch: n } } = this.props;
n(e, t);
}
render() {
let { hasError: e, error: t } = this.state, { getComponent: n, targetName: i, children: a } = this.props;
return e && t ? /* @__PURE__ */ r(n("Fallback"), { name: i }) : a;
}
};
i.propTypes = {
targetName: n.string,
getComponent: n.func.isRequired,
fn: n.shape({ componentDidCatch: n.func.isRequired }).isRequired,
editorSelectors: n.shape({ selectContent: n.func.isRequired }).isRequired,
children: n.oneOfType([n.arrayOf(n.node), n.node])
}, i.defaultProps = {
targetName: "this component",
children: null
};
//#endregion
//#region src/plugins/editor-safe-render/extensions/safe-render/wrap-components/ErrorBoundaryWrapper.jsx
var a = (e, t) => (e) => {
let { editorSelectors: n } = t;
return /* @__PURE__ */ r(i, {
...e,
editorSelectors: n
});
}, o = (e = {}) => {
let n = typeof e.getSystem == "function", r = {
componentList: [],
fullOverride: !1
}, i = n ? r : {
...r,
...e
}, o = () => [() => {
let e = i.fullOverride ? i.componentList : [
"TopBar",
"SwaggerEditorLayout",
"Editor",
"TextareaEditor",
"MonacoEditor",
"EditorPane",
"EditorPaneBarTop",
"EditorPreviewPane",
"ValidationPane",
"AlertDialog",
"ConfirmDialog",
"Dropzone",
...i.componentList
];
return t.plugins.SafeRender({
fullOverride: !0,
componentList: e
});
}, () => ({ wrapComponents: { ErrorBoundary: a } })];
return n ? o(e) : o;
};
//#endregion
export { o as default };
//# sourceMappingURL=index.js.map