UNPKG

wix-storybook-utils

Version:

Utilities for automated component documentation within Storybook

61 lines 2.28 kB
import { __assign } from "tslib"; import * as React from 'react'; import { sectionWithSiblings } from '../section-with-siblings'; import { importExample } from './import-example'; import { description } from './description'; import { code } from './code'; import { api } from './api'; import { playground } from './playground'; import { testkit } from './testkit'; import { isTab, extractTabs } from '../extract-tabs'; import { columns } from './columns'; import { table } from './table'; import { tabs } from './tabs'; import { mdx } from './mdx'; import { divider } from './divider'; import { header } from './header'; import { title } from './title'; import { plugin } from './plugin'; import { example } from './example'; import { doDont } from './do-dont'; import { includedComponents } from './included-components'; import { demo } from './demo'; import { storyPage } from './story-page'; import styles from '../styles.scss'; import TabbedView from '../../TabbedView'; export var tab = function (section, storyConfig) { var extractedTabs = extractTabs(section); return render(section, extractedTabs, storyConfig); }; var views = { header: header, importExample: importExample, description: description, code: code, api: api, playground: playground, testkit: testkit, tab: tab, columns: columns, table: table, tabs: tabs, mdx: mdx, divider: divider, title: title, plugin: plugin, example: example, doDont: doDont, includedComponents: includedComponents, demo: demo, storyPage: storyPage, }; export var getView = function (type) { return views[type] || (function (i) { return i; }); }; function render(section, tabTitles, storyConfig) { return React.createElement(tabTitles.length ? TabbedView : 'div', __assign(__assign({}, (tabTitles ? { tabs: tabTitles } : {})), { className: styles.tab, children: section.sections.map(function (tabSection, key) { var view = getView(tabSection.type)(tabSection, storyConfig); return (React.createElement("div", { key: key, "data-hook": section.dataHook || null }, isTab(tabSection) ? view : sectionWithSiblings(tabSection, view, true))); }) })); } //# sourceMappingURL=tab.js.map