wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
35 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.code = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var CodeBlock_1 = tslib_1.__importDefault(require("../../CodeBlock"));
var code = function (_a, storyConfig) {
var _b;
var source = _a.source, components = _a.components, _c = _a.compact, compact = _c === void 0 ? false : _c, figmaLink = _a.figmaLink, previewProps = _a.previewProps, _d = _a.interactive, interactive = _d === void 0 ? true : _d, autoRender = _a.autoRender, _e = _a.darkBackground, darkBackground = _e === void 0 ? false : _e, _f = _a.noBackground, noBackground = _f === void 0 ? false : _f, _g = _a.initiallyOpen, initiallyOpen = _g === void 0 ? false : _g, title = _a.title, _h = _a.hideCodeEditor, hideCodeEditor = _h === void 0 ? false : _h;
var playgroundComponents = storyConfig.config.playgroundComponents || {};
if (interactive) {
var LiveCodeExample = React.lazy(function () { return Promise.resolve().then(function () { return tslib_1.__importStar(require('../../LiveCodeExample')); }); });
return (React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") },
React.createElement(LiveCodeExample, tslib_1.__assign({}, {
previewProps: previewProps,
compact: compact,
figmaLink: figmaLink,
autoRender: autoRender,
darkBackground: darkBackground,
noBackground: noBackground,
hideCodeEditor: hideCodeEditor,
scope: tslib_1.__assign(tslib_1.__assign({}, components), playgroundComponents),
initialCode: source.trim(),
initiallyOpen: initiallyOpen,
hints: storyConfig.hints,
title: title,
storyName: storyConfig.storyName,
storage: window.sessionStorage,
examplesPreviewWrapper: (_b = storyConfig.story) === null || _b === void 0 ? void 0 : _b.examplesPreviewWrapper,
}))));
}
return React.createElement(CodeBlock_1.default, { source: source.trim() });
};
exports.code = code;
//# sourceMappingURL=code.js.map