wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
25 lines • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importDefault(require("react"));
var queryString = tslib_1.__importStar(require("query-string"));
var AutoExample_1 = tslib_1.__importDefault(require("../AutoExample"));
var StoryPage_1 = tslib_1.__importDefault(require("../StoryPage"));
var RemountHoc_1 = tslib_1.__importDefault(require("./RemountHoc"));
var utils_1 = require("../utils");
var utils_2 = require("./utils");
(0, utils_2.scrollToElementByHash)();
exports.default = (function (_a) {
var _config = _a._config, _metadata = _a._metadata, storyConfig = tslib_1.__rest(_a, ["_config", "_metadata"]);
return _config
.storiesOf(storyConfig.category, module)
.addParameters(storyConfig.parameters || {})
.add(storyConfig.storyName || _metadata.displayName, function () {
return utils_1.isE2E ? (react_1.default.createElement("div", null,
react_1.default.createElement(RemountHoc_1.default, null,
react_1.default.createElement(AutoExample_1.default, { isInteractive: false, ref: function (ref) { return (global.autoexample = ref); }, component: storyConfig.component, componentWrapper: storyConfig.componentWrapper, componentProps: storyConfig.componentProps, parsedSource: _metadata })),
queryString.parse(window.location.search).withExamples !==
undefined && storyConfig.examples)) : (react_1.default.createElement(StoryPage_1.default, tslib_1.__assign({}, tslib_1.__assign(tslib_1.__assign({}, tslib_1.__assign(tslib_1.__assign({}, storyConfig), { hints: (0, utils_1.getComponentsHints)(_config.playgroundComponents) })), { metadata: _metadata, config: _config }))));
});
});
//# sourceMappingURL=index.js.map