@teambit/compositions 0.0.851 → 0.0.853
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compositions.tsx +6 -4
- package/dist/compositions.js +7 -2
- package/dist/compositions.js.map +1 -1
- package/dist/ui/compositions-panel/compositions-panel.d.ts +17 -1
- package/dist/ui/compositions-panel/compositions-panel.js +5 -3
- package/dist/ui/compositions-panel/compositions-panel.js.map +1 -1
- package/package-tar/teambit-compositions-0.0.853.tgz +0 -0
- package/package.json +12 -12
- package/{preview-1662990602352.js → preview-1663126549096.js} +2 -2
- package/ui/compositions-panel/compositions-panel.tsx +21 -1
- package/package-tar/teambit-compositions-0.0.851.tgz +0 -0
package/compositions.tsx
CHANGED
|
@@ -56,21 +56,22 @@ export function Compositions({ menuBarWidgets, emptyState }: CompositionsProp) {
|
|
|
56
56
|
|
|
57
57
|
const sidebarOpenness = isSidebarOpen ? Layout.row : Layout.left;
|
|
58
58
|
|
|
59
|
-
const compositionUrl = toPreviewUrl(component, 'compositions');
|
|
60
|
-
const
|
|
59
|
+
const compositionUrl = toPreviewUrl(component, 'compositions');
|
|
60
|
+
const isScaling = component?.preview?.isScaling;
|
|
61
|
+
const compositionIdentifierParam = isScaling ? `name=${selected?.identifier}` : selected?.identifier;
|
|
62
|
+
const currentCompositionFullUrl = toPreviewUrl(component, 'compositions', compositionIdentifierParam);
|
|
61
63
|
|
|
62
64
|
const [compositionParams, setCompositionParams] = useState<Record<string, any>>({});
|
|
63
65
|
const queryParams = useMemo(() => queryString.stringify(compositionParams), [compositionParams]);
|
|
64
66
|
|
|
65
67
|
// collapse sidebar when empty, reopen when not
|
|
66
68
|
useEffect(() => setSidebarOpenness(showSidebar), [showSidebar]);
|
|
67
|
-
|
|
68
69
|
return (
|
|
69
70
|
<CompositionContextProvider queryParams={compositionParams} setQueryParams={setCompositionParams}>
|
|
70
71
|
<SplitPane layout={sidebarOpenness} size="85%" className={styles.compositionsPage}>
|
|
71
72
|
<Pane className={styles.left}>
|
|
72
73
|
<CompositionsMenuBar menuBarWidgets={menuBarWidgets} className={styles.menuBar}>
|
|
73
|
-
<Link external href={
|
|
74
|
+
<Link external href={currentCompositionFullUrl} className={styles.openInNewTab}>
|
|
74
75
|
<OptionButton icon="open-tab" />
|
|
75
76
|
</Link>
|
|
76
77
|
</CompositionsMenuBar>
|
|
@@ -100,6 +101,7 @@ export function Compositions({ menuBarWidgets, emptyState }: CompositionsProp) {
|
|
|
100
101
|
</TabList>
|
|
101
102
|
<TabPanel className={styles.tabContent}>
|
|
102
103
|
<CompositionsPanel
|
|
104
|
+
isScaling={isScaling}
|
|
103
105
|
onSelectComposition={selectComposition}
|
|
104
106
|
url={compositionUrl}
|
|
105
107
|
compositions={component.compositions}
|
package/dist/compositions.js
CHANGED
|
@@ -278,6 +278,8 @@ function Compositions({
|
|
|
278
278
|
menuBarWidgets,
|
|
279
279
|
emptyState
|
|
280
280
|
}) {
|
|
281
|
+
var _component$preview;
|
|
282
|
+
|
|
281
283
|
const component = (0, _react().useContext)(_component().ComponentContext);
|
|
282
284
|
const [selected, selectComposition] = (0, _react().useState)((0, _lodash().default)(component.compositions));
|
|
283
285
|
const selectedRef = (0, _react().useRef)(selected);
|
|
@@ -297,7 +299,9 @@ function Compositions({
|
|
|
297
299
|
const [isSidebarOpen, setSidebarOpenness] = (0, _react().useState)(showSidebar);
|
|
298
300
|
const sidebarOpenness = isSidebarOpen ? _baseUiSurfacesSplitPane().Layout.row : _baseUiSurfacesSplitPane().Layout.left;
|
|
299
301
|
const compositionUrl = (0, _previewUi().toPreviewUrl)(component, 'compositions');
|
|
300
|
-
const
|
|
302
|
+
const isScaling = component === null || component === void 0 ? void 0 : (_component$preview = component.preview) === null || _component$preview === void 0 ? void 0 : _component$preview.isScaling;
|
|
303
|
+
const compositionIdentifierParam = isScaling ? `name=${selected === null || selected === void 0 ? void 0 : selected.identifier}` : selected === null || selected === void 0 ? void 0 : selected.identifier;
|
|
304
|
+
const currentCompositionFullUrl = (0, _previewUi().toPreviewUrl)(component, 'compositions', compositionIdentifierParam);
|
|
301
305
|
const [compositionParams, setCompositionParams] = (0, _react().useState)({});
|
|
302
306
|
const queryParams = (0, _react().useMemo)(() => _queryString().default.stringify(compositionParams), [compositionParams]); // collapse sidebar when empty, reopen when not
|
|
303
307
|
|
|
@@ -316,7 +320,7 @@ function Compositions({
|
|
|
316
320
|
className: _compositionsModule().default.menuBar
|
|
317
321
|
}, /*#__PURE__*/_react().default.createElement(_baseReactNavigation().Link, {
|
|
318
322
|
external: true,
|
|
319
|
-
href:
|
|
323
|
+
href: currentCompositionFullUrl,
|
|
320
324
|
className: _compositionsModule().default.openInNewTab
|
|
321
325
|
}, /*#__PURE__*/_react().default.createElement(_designUiInput().OptionButton, {
|
|
322
326
|
icon: "open-tab"
|
|
@@ -344,6 +348,7 @@ function Compositions({
|
|
|
344
348
|
}, /*#__PURE__*/_react().default.createElement(_panels().Tab, null, "compositions"), /*#__PURE__*/_react().default.createElement(_panels().Tab, null, "properties")), /*#__PURE__*/_react().default.createElement(_panels().TabPanel, {
|
|
345
349
|
className: _compositionsModule().default.tabContent
|
|
346
350
|
}, /*#__PURE__*/_react().default.createElement(_compositionsPanel().CompositionsPanel, {
|
|
351
|
+
isScaling: isScaling,
|
|
347
352
|
onSelectComposition: selectComposition,
|
|
348
353
|
url: compositionUrl,
|
|
349
354
|
compositions: component.compositions,
|
package/dist/compositions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Compositions","menuBarWidgets","emptyState","component","useContext","ComponentContext","selected","selectComposition","useState","head","compositions","selectedRef","useRef","current","properties","useDocs","id","useEffect","prevId","identifier","next","find","c","isMobile","useIsMobile","showSidebar","length","isSidebarOpen","setSidebarOpenness","sidebarOpenness","Layout","row","left","compositionUrl","toPreviewUrl","currentCompositionUrl","compositionParams","setCompositionParams","queryParams","useMemo","queryString","stringify","styles","compositionsPage","menuBar","openInNewTab","splitter","e","stopPropagation","x","collapser","right","tabsContainer","tabs","tabContent","compost","CompositionContent","env","environment","EmptyStateTemplate","get","host","noCompositionsPage","title","separator","buildStatus","buildStatusMessage","compositionsIframe"],"sources":["compositions.tsx"],"sourcesContent":["import React, { useContext, useEffect, useState, useMemo, useRef, ReactNode } from 'react';\nimport head from 'lodash.head';\nimport queryString from 'query-string';\nimport { ThemeContext } from '@teambit/documenter.theme.theme-context';\nimport { SplitPane, Pane, Layout } from '@teambit/base-ui.surfaces.split-pane.split-pane';\nimport { HoverSplitter } from '@teambit/base-ui.surfaces.split-pane.hover-splitter';\nimport { ComponentContext, ComponentModel } from '@teambit/component';\nimport { PropTable } from '@teambit/documenter.ui.property-table';\nimport { Tab, TabContainer, TabList, TabPanel } from '@teambit/panels';\nimport { useDocs } from '@teambit/docs.ui.queries.get-docs';\nimport { Collapser } from '@teambit/ui-foundation.ui.buttons.collapser';\nimport { EmptyBox } from '@teambit/design.ui.empty-box';\nimport { toPreviewUrl } from '@teambit/preview.ui.component-preview';\nimport { useIsMobile } from '@teambit/ui-foundation.ui.hooks.use-is-mobile';\nimport { CompositionsMenuBar } from '@teambit/compositions.ui.compositions-menu-bar';\nimport { CompositionContextProvider } from '@teambit/compositions.ui.hooks.use-composition';\nimport { MDXLayout } from '@teambit/mdx.ui.mdx-layout';\nimport { Separator } from '@teambit/design.ui.separator';\nimport { H1 } from '@teambit/documenter.ui.heading';\nimport { AlertCard } from '@teambit/design.ui.alert-card';\nimport { Link } from '@teambit/base-react.navigation.link';\nimport { OptionButton } from '@teambit/design.ui.input.option-button';\nimport { StatusMessageCard } from '@teambit/design.ui.surfaces.status-message-card';\nimport { EmptyStateSlot } from './compositions.ui.runtime';\nimport { Composition } from './composition';\nimport styles from './compositions.module.scss';\nimport { ComponentComposition } from './ui';\nimport { CompositionsPanel } from './ui/compositions-panel/compositions-panel';\nimport type { CompositionsMenuSlot } from './compositions.ui.runtime';\n\nexport type MenuBarWidget = {\n location: 'start' | 'end';\n content: ReactNode;\n};\nexport type CompositionsProp = { menuBarWidgets?: CompositionsMenuSlot; emptyState?: EmptyStateSlot };\n\nexport function Compositions({ menuBarWidgets, emptyState }: CompositionsProp) {\n const component = useContext(ComponentContext);\n const [selected, selectComposition] = useState(head(component.compositions));\n const selectedRef = useRef(selected);\n selectedRef.current = selected;\n\n const properties = useDocs(component.id);\n\n // reset selected composition when component changes.\n // this does trigger renderer, but perf seems to be ok\n useEffect(() => {\n const prevId = selectedRef.current?.identifier;\n const next = component.compositions.find((c) => c.identifier === prevId) || component.compositions[0];\n\n selectComposition(next);\n }, [component]);\n const isMobile = useIsMobile();\n const showSidebar = !isMobile && component.compositions.length > 0;\n const [isSidebarOpen, setSidebarOpenness] = useState(showSidebar);\n\n const sidebarOpenness = isSidebarOpen ? Layout.row : Layout.left;\n\n const compositionUrl = toPreviewUrl(component, 'compositions');\n const currentCompositionUrl = toPreviewUrl(component, 'compositions', selected?.identifier);\n\n const [compositionParams, setCompositionParams] = useState<Record<string, any>>({});\n const queryParams = useMemo(() => queryString.stringify(compositionParams), [compositionParams]);\n\n // collapse sidebar when empty, reopen when not\n useEffect(() => setSidebarOpenness(showSidebar), [showSidebar]);\n\n return (\n <CompositionContextProvider queryParams={compositionParams} setQueryParams={setCompositionParams}>\n <SplitPane layout={sidebarOpenness} size=\"85%\" className={styles.compositionsPage}>\n <Pane className={styles.left}>\n <CompositionsMenuBar menuBarWidgets={menuBarWidgets} className={styles.menuBar}>\n <Link external href={currentCompositionUrl} className={styles.openInNewTab}>\n <OptionButton icon=\"open-tab\" />\n </Link>\n </CompositionsMenuBar>\n <CompositionContent\n emptyState={emptyState}\n component={component}\n selected={selected}\n queryParams={queryParams}\n />\n </Pane>\n <HoverSplitter className={styles.splitter}>\n <Collapser\n placement=\"left\"\n isOpen={isSidebarOpen}\n onMouseDown={(e) => e.stopPropagation()} // avoid split-pane drag\n onClick={() => setSidebarOpenness((x) => !x)}\n tooltipContent={`${isSidebarOpen ? 'Hide' : 'Show'} side compositions`}\n className={styles.collapser}\n />\n </HoverSplitter>\n <Pane className={styles.right}>\n <ThemeContext>\n <TabContainer className={styles.tabsContainer}>\n <TabList className={styles.tabs}>\n <Tab>compositions</Tab>\n <Tab>properties</Tab>\n </TabList>\n <TabPanel className={styles.tabContent}>\n <CompositionsPanel\n onSelectComposition={selectComposition}\n url={compositionUrl}\n compositions={component.compositions}\n active={selected}\n className={styles.compost}\n />\n </TabPanel>\n <TabPanel className={styles.tabContent}>\n {properties && properties.length > 0 ? <PropTable rows={properties} showListView /> : <div />}\n </TabPanel>\n </TabContainer>\n </ThemeContext>\n </Pane>\n </SplitPane>\n </CompositionContextProvider>\n );\n}\n\nexport type CompositionContentProps = {\n component: ComponentModel;\n selected?: Composition;\n queryParams?: string | string[];\n emptyState?: EmptyStateSlot;\n};\n\nexport function CompositionContent({ component, selected, queryParams, emptyState }: CompositionContentProps) {\n const env = component.environment?.id;\n const EmptyStateTemplate = emptyState?.get(env || ''); // || defaultTemplate;\n\n if (component.compositions.length === 0 && component.host === 'teambit.workspace/workspace' && EmptyStateTemplate) {\n return (\n <div className={styles.noCompositionsPage}>\n <div>\n <H1 className={styles.title}>Compositions</H1>\n <Separator isPresentational className={styles.separator} />\n <AlertCard\n level=\"info\"\n title=\"There are no\n compositions for this Component. Learn how to add compositions:\"\n >\n <MDXLayout>\n <EmptyStateTemplate />\n </MDXLayout>\n </AlertCard>\n </div>\n </div>\n );\n }\n\n if (component?.buildStatus === 'pending' && component?.host === 'teambit.scope/scope')\n return (\n <StatusMessageCard className={styles.buildStatusMessage} status=\"PROCESSING\" title=\"component preview pending\">\n this might take some time\n </StatusMessageCard>\n );\n if (component?.buildStatus === 'failed' && component?.host === 'teambit.scope/scope')\n return (\n <StatusMessageCard\n className={styles.buildStatusMessage}\n status=\"FAILURE\"\n title=\"failed to get component preview \"\n ></StatusMessageCard>\n );\n\n // TODO: get the docs domain from the community aspect and pass it here as a prop\n if (component.compositions.length === 0) {\n return (\n <EmptyBox\n title=\"There are no compositions for this component.\"\n linkText=\"Learn how to create compositions\"\n link={`https://bit.dev/docs/dev-services-overview/compositions/compositions-overview`}\n />\n );\n }\n\n return (\n <ComponentComposition\n className={styles.compositionsIframe}\n // TODO: Oded to add control for viewport.\n viewport={null}\n component={component}\n forceHeight=\"100%\"\n composition={selected}\n fullContentHeight\n pubsub={true}\n queryParams={queryParams}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;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,EACE,oBACE,+BAAC,qCAAD;IACE,SAAS,EAAEnB,6BAAA,CAAOwB,kBADpB;IAEE,MAAM,EAAC,SAFT;IAGE,KAAK,EAAC;EAHR,EADF,CA/B0G,CAuC5G;;EACA,IAAI/D,SAAS,CAACO,YAAV,CAAuBgB,MAAvB,KAAkC,CAAtC,EAAyC;IACvC,oBACE,+BAAC,oBAAD;MACE,KAAK,EAAC,+CADR;MAEE,QAAQ,EAAC,kCAFX;MAGE,IAAI,EAAG;IAHT,EADF;EAOD;;EAED,oBACE,+BAAC,0BAAD;IACE,SAAS,EAAEgB,6BAAA,CAAOyB,kBADpB,CAEE;IAFF;IAGE,QAAQ,EAAE,IAHZ;IAIE,SAAS,EAAEhE,SAJb;IAKE,WAAW,EAAC,MALd;IAME,WAAW,EAAEG,QANf;IAOE,iBAAiB,MAPnB;IAQE,MAAM,EAAE,IARV;IASE,WAAW,EAAEgC;EATf,EADF;AAaD"}
|
|
1
|
+
{"version":3,"names":["Compositions","menuBarWidgets","emptyState","component","useContext","ComponentContext","selected","selectComposition","useState","head","compositions","selectedRef","useRef","current","properties","useDocs","id","useEffect","prevId","identifier","next","find","c","isMobile","useIsMobile","showSidebar","length","isSidebarOpen","setSidebarOpenness","sidebarOpenness","Layout","row","left","compositionUrl","toPreviewUrl","isScaling","preview","compositionIdentifierParam","currentCompositionFullUrl","compositionParams","setCompositionParams","queryParams","useMemo","queryString","stringify","styles","compositionsPage","menuBar","openInNewTab","splitter","e","stopPropagation","x","collapser","right","tabsContainer","tabs","tabContent","compost","CompositionContent","env","environment","EmptyStateTemplate","get","host","noCompositionsPage","title","separator","buildStatus","buildStatusMessage","compositionsIframe"],"sources":["compositions.tsx"],"sourcesContent":["import React, { useContext, useEffect, useState, useMemo, useRef, ReactNode } from 'react';\nimport head from 'lodash.head';\nimport queryString from 'query-string';\nimport { ThemeContext } from '@teambit/documenter.theme.theme-context';\nimport { SplitPane, Pane, Layout } from '@teambit/base-ui.surfaces.split-pane.split-pane';\nimport { HoverSplitter } from '@teambit/base-ui.surfaces.split-pane.hover-splitter';\nimport { ComponentContext, ComponentModel } from '@teambit/component';\nimport { PropTable } from '@teambit/documenter.ui.property-table';\nimport { Tab, TabContainer, TabList, TabPanel } from '@teambit/panels';\nimport { useDocs } from '@teambit/docs.ui.queries.get-docs';\nimport { Collapser } from '@teambit/ui-foundation.ui.buttons.collapser';\nimport { EmptyBox } from '@teambit/design.ui.empty-box';\nimport { toPreviewUrl } from '@teambit/preview.ui.component-preview';\nimport { useIsMobile } from '@teambit/ui-foundation.ui.hooks.use-is-mobile';\nimport { CompositionsMenuBar } from '@teambit/compositions.ui.compositions-menu-bar';\nimport { CompositionContextProvider } from '@teambit/compositions.ui.hooks.use-composition';\nimport { MDXLayout } from '@teambit/mdx.ui.mdx-layout';\nimport { Separator } from '@teambit/design.ui.separator';\nimport { H1 } from '@teambit/documenter.ui.heading';\nimport { AlertCard } from '@teambit/design.ui.alert-card';\nimport { Link } from '@teambit/base-react.navigation.link';\nimport { OptionButton } from '@teambit/design.ui.input.option-button';\nimport { StatusMessageCard } from '@teambit/design.ui.surfaces.status-message-card';\nimport { EmptyStateSlot } from './compositions.ui.runtime';\nimport { Composition } from './composition';\nimport styles from './compositions.module.scss';\nimport { ComponentComposition } from './ui';\nimport { CompositionsPanel } from './ui/compositions-panel/compositions-panel';\nimport type { CompositionsMenuSlot } from './compositions.ui.runtime';\n\nexport type MenuBarWidget = {\n location: 'start' | 'end';\n content: ReactNode;\n};\nexport type CompositionsProp = { menuBarWidgets?: CompositionsMenuSlot; emptyState?: EmptyStateSlot };\n\nexport function Compositions({ menuBarWidgets, emptyState }: CompositionsProp) {\n const component = useContext(ComponentContext);\n const [selected, selectComposition] = useState(head(component.compositions));\n const selectedRef = useRef(selected);\n selectedRef.current = selected;\n\n const properties = useDocs(component.id);\n\n // reset selected composition when component changes.\n // this does trigger renderer, but perf seems to be ok\n useEffect(() => {\n const prevId = selectedRef.current?.identifier;\n const next = component.compositions.find((c) => c.identifier === prevId) || component.compositions[0];\n\n selectComposition(next);\n }, [component]);\n const isMobile = useIsMobile();\n const showSidebar = !isMobile && component.compositions.length > 0;\n const [isSidebarOpen, setSidebarOpenness] = useState(showSidebar);\n\n const sidebarOpenness = isSidebarOpen ? Layout.row : Layout.left;\n\n const compositionUrl = toPreviewUrl(component, 'compositions'); \n const isScaling = component?.preview?.isScaling;\n const compositionIdentifierParam = isScaling ? `name=${selected?.identifier}` : selected?.identifier;\n const currentCompositionFullUrl = toPreviewUrl(component, 'compositions', compositionIdentifierParam);\n\n const [compositionParams, setCompositionParams] = useState<Record<string, any>>({});\n const queryParams = useMemo(() => queryString.stringify(compositionParams), [compositionParams]);\n\n // collapse sidebar when empty, reopen when not\n useEffect(() => setSidebarOpenness(showSidebar), [showSidebar]);\n return (\n <CompositionContextProvider queryParams={compositionParams} setQueryParams={setCompositionParams}>\n <SplitPane layout={sidebarOpenness} size=\"85%\" className={styles.compositionsPage}>\n <Pane className={styles.left}>\n <CompositionsMenuBar menuBarWidgets={menuBarWidgets} className={styles.menuBar}>\n <Link external href={currentCompositionFullUrl} className={styles.openInNewTab}>\n <OptionButton icon=\"open-tab\" />\n </Link>\n </CompositionsMenuBar>\n <CompositionContent\n emptyState={emptyState}\n component={component}\n selected={selected}\n queryParams={queryParams}\n />\n </Pane>\n <HoverSplitter className={styles.splitter}>\n <Collapser\n placement=\"left\"\n isOpen={isSidebarOpen}\n onMouseDown={(e) => e.stopPropagation()} // avoid split-pane drag\n onClick={() => setSidebarOpenness((x) => !x)}\n tooltipContent={`${isSidebarOpen ? 'Hide' : 'Show'} side compositions`}\n className={styles.collapser}\n />\n </HoverSplitter>\n <Pane className={styles.right}>\n <ThemeContext>\n <TabContainer className={styles.tabsContainer}>\n <TabList className={styles.tabs}>\n <Tab>compositions</Tab>\n <Tab>properties</Tab>\n </TabList>\n <TabPanel className={styles.tabContent}>\n <CompositionsPanel\n isScaling={isScaling}\n onSelectComposition={selectComposition}\n url={compositionUrl}\n compositions={component.compositions}\n active={selected}\n className={styles.compost}\n />\n </TabPanel>\n <TabPanel className={styles.tabContent}>\n {properties && properties.length > 0 ? <PropTable rows={properties} showListView /> : <div />}\n </TabPanel>\n </TabContainer>\n </ThemeContext>\n </Pane>\n </SplitPane>\n </CompositionContextProvider>\n );\n}\n\nexport type CompositionContentProps = {\n component: ComponentModel;\n selected?: Composition;\n queryParams?: string | string[];\n emptyState?: EmptyStateSlot;\n};\n\nexport function CompositionContent({ component, selected, queryParams, emptyState }: CompositionContentProps) {\n const env = component.environment?.id;\n const EmptyStateTemplate = emptyState?.get(env || ''); // || defaultTemplate;\n\n if (component.compositions.length === 0 && component.host === 'teambit.workspace/workspace' && EmptyStateTemplate) {\n return (\n <div className={styles.noCompositionsPage}>\n <div>\n <H1 className={styles.title}>Compositions</H1>\n <Separator isPresentational className={styles.separator} />\n <AlertCard\n level=\"info\"\n title=\"There are no\n compositions for this Component. Learn how to add compositions:\"\n >\n <MDXLayout>\n <EmptyStateTemplate />\n </MDXLayout>\n </AlertCard>\n </div>\n </div>\n );\n }\n\n if (component?.buildStatus === 'pending' && component?.host === 'teambit.scope/scope')\n return (\n <StatusMessageCard className={styles.buildStatusMessage} status=\"PROCESSING\" title=\"component preview pending\">\n this might take some time\n </StatusMessageCard>\n );\n if (component?.buildStatus === 'failed' && component?.host === 'teambit.scope/scope')\n return (\n <StatusMessageCard\n className={styles.buildStatusMessage}\n status=\"FAILURE\"\n title=\"failed to get component preview \"\n ></StatusMessageCard>\n );\n\n // TODO: get the docs domain from the community aspect and pass it here as a prop\n if (component.compositions.length === 0) {\n return (\n <EmptyBox\n title=\"There are no compositions for this component.\"\n linkText=\"Learn how to create compositions\"\n link={`https://bit.dev/docs/dev-services-overview/compositions/compositions-overview`}\n />\n );\n }\n\n return (\n <ComponentComposition\n className={styles.compositionsIframe}\n // TODO: Oded to add control for viewport.\n viewport={null}\n component={component}\n forceHeight=\"100%\"\n composition={selected}\n fullContentHeight\n pubsub={true}\n queryParams={queryParams}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AAA,SAAS,CAAE6D,IAAX,MAAoB,qBAA/D,EACE,oBACE,+BAAC,qCAAD;IACE,SAAS,EAAEnB,6BAAA,CAAOwB,kBADpB;IAEE,MAAM,EAAC,SAFT;IAGE,KAAK,EAAC;EAHR,EADF,CA/B0G,CAuC5G;;EACA,IAAIlE,SAAS,CAACO,YAAV,CAAuBgB,MAAvB,KAAkC,CAAtC,EAAyC;IACvC,oBACE,+BAAC,oBAAD;MACE,KAAK,EAAC,+CADR;MAEE,QAAQ,EAAC,kCAFX;MAGE,IAAI,EAAG;IAHT,EADF;EAOD;;EAED,oBACE,+BAAC,0BAAD;IACE,SAAS,EAAEmB,6BAAA,CAAOyB,kBADpB,CAEE;IAFF;IAGE,QAAQ,EAAE,IAHZ;IAIE,SAAS,EAAEnE,SAJb;IAKE,WAAW,EAAC,MALd;IAME,WAAW,EAAEG,QANf;IAOE,iBAAiB,MAPnB;IAQE,MAAM,EAAE,IARV;IASE,WAAW,EAAEmC;EATf,EADF;AAaD"}
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Composition } from '../../composition';
|
|
3
3
|
export declare type CompositionsPanelProps = {
|
|
4
|
+
/**
|
|
5
|
+
* list of compositions
|
|
6
|
+
*/
|
|
4
7
|
compositions: Composition[];
|
|
8
|
+
/**
|
|
9
|
+
* select composition to display
|
|
10
|
+
*/
|
|
5
11
|
onSelectComposition: (composition: Composition) => void;
|
|
12
|
+
/**
|
|
13
|
+
* the currently active composition
|
|
14
|
+
*/
|
|
6
15
|
active?: Composition;
|
|
16
|
+
/**
|
|
17
|
+
* the url to the base composition. doesntc contain the current composition params
|
|
18
|
+
*/
|
|
7
19
|
url: string;
|
|
20
|
+
/**
|
|
21
|
+
* checks if a component is using the new preview api. if false, doesnt scale to support new preview
|
|
22
|
+
*/
|
|
23
|
+
isScaling?: boolean;
|
|
8
24
|
} & React.HTMLAttributes<HTMLUListElement>;
|
|
9
|
-
export declare function CompositionsPanel({ url, compositions, onSelectComposition: onSelect, active, className, ...rest }: CompositionsPanelProps): JSX.Element;
|
|
25
|
+
export declare function CompositionsPanel({ url, compositions, isScaling, onSelectComposition: onSelect, active, className, ...rest }: CompositionsPanelProps): JSX.Element;
|
|
@@ -75,18 +75,20 @@ function CompositionsPanel(_ref) {
|
|
|
75
75
|
let {
|
|
76
76
|
url,
|
|
77
77
|
compositions,
|
|
78
|
+
isScaling,
|
|
78
79
|
onSelectComposition: onSelect,
|
|
79
80
|
active,
|
|
80
81
|
className
|
|
81
82
|
} = _ref,
|
|
82
|
-
rest = (0, _objectWithoutProperties2().default)(_ref, ["url", "compositions", "onSelectComposition", "active", "className"]);
|
|
83
|
+
rest = (0, _objectWithoutProperties2().default)(_ref, ["url", "compositions", "isScaling", "onSelectComposition", "active", "className"]);
|
|
83
84
|
const handleSelect = (0, _react().useCallback)(selected => {
|
|
84
85
|
onSelect && onSelect(selected);
|
|
85
86
|
}, [onSelect]);
|
|
86
87
|
return /*#__PURE__*/_react().default.createElement("ul", (0, _extends2().default)({}, rest, {
|
|
87
88
|
className: (0, _classnames().default)(className)
|
|
88
89
|
}), compositions.map(composition => {
|
|
89
|
-
// TODO - move to composition panel node
|
|
90
|
+
const href = isScaling ? `${url}&name=${composition.identifier}` : `${url}&${composition.identifier}`; // TODO - move to composition panel node
|
|
91
|
+
|
|
90
92
|
return /*#__PURE__*/_react().default.createElement("li", {
|
|
91
93
|
key: composition.identifier,
|
|
92
94
|
className: (0, _classnames().default)(_compositionsPanelModule().default.linkWrapper, composition === active && _compositionsPanelModule().default.active)
|
|
@@ -103,7 +105,7 @@ function CompositionsPanel(_ref) {
|
|
|
103
105
|
className: _compositionsPanelModule().default.panelLink,
|
|
104
106
|
target: "_blank",
|
|
105
107
|
rel: "noopener noreferrer",
|
|
106
|
-
href:
|
|
108
|
+
href: href
|
|
107
109
|
}, /*#__PURE__*/_react().default.createElement(_evangelistElements().Icon, {
|
|
108
110
|
className: _compositionsPanelModule().default.icon,
|
|
109
111
|
of: "open-tab"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CompositionsPanel","url","compositions","onSelectComposition","onSelect","active","className","rest","handleSelect","useCallback","selected","classNames","map","composition","identifier","styles","linkWrapper","panelLink","box","name","displayName","right","icon"],"sources":["compositions-panel.tsx"],"sourcesContent":["import { Icon } from '@teambit/evangelist.elements.icon';\nimport classNames from 'classnames';\nimport React, { useCallback } from 'react';\n\nimport { Composition } from '../../composition';\nimport styles from './compositions-panel.module.scss';\n\nexport type CompositionsPanelProps = {\n compositions: Composition[];\n onSelectComposition: (composition: Composition) => void;\n active?: Composition;\n url: string;\n} & React.HTMLAttributes<HTMLUListElement>;\n\nexport function CompositionsPanel({\n url,\n compositions,\n onSelectComposition: onSelect,\n active,\n className,\n ...rest\n}: CompositionsPanelProps) {\n const handleSelect = useCallback(\n (selected: Composition) => {\n onSelect && onSelect(selected);\n },\n [onSelect]\n );\n\n return (\n <ul {...rest} className={classNames(className)}>\n {compositions.map((composition) => {\n // TODO - move to composition panel node\n return (\n <li\n key={composition.identifier}\n className={classNames(styles.linkWrapper, composition === active && styles.active)}\n >\n <a className={styles.panelLink} onClick={() => handleSelect(composition)}>\n <span className={styles.box}></span>\n <span className={styles.name}>{composition.displayName}</span>\n </a>\n <div className={styles.right}>\n <a\n className={styles.panelLink}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={
|
|
1
|
+
{"version":3,"names":["CompositionsPanel","url","compositions","isScaling","onSelectComposition","onSelect","active","className","rest","handleSelect","useCallback","selected","classNames","map","composition","href","identifier","styles","linkWrapper","panelLink","box","name","displayName","right","icon"],"sources":["compositions-panel.tsx"],"sourcesContent":["import { Icon } from '@teambit/evangelist.elements.icon';\nimport classNames from 'classnames';\nimport React, { useCallback } from 'react';\n\nimport { Composition } from '../../composition';\nimport styles from './compositions-panel.module.scss';\n\nexport type CompositionsPanelProps = {\n /**\n * list of compositions\n */\n compositions: Composition[];\n /**\n * select composition to display\n */\n onSelectComposition: (composition: Composition) => void;\n /**\n * the currently active composition\n */\n active?: Composition;\n /**\n * the url to the base composition. doesntc contain the current composition params\n */\n url: string;\n /**\n * checks if a component is using the new preview api. if false, doesnt scale to support new preview\n */\n isScaling?: boolean;\n} & React.HTMLAttributes<HTMLUListElement>;\n\nexport function CompositionsPanel({\n url,\n compositions,\n isScaling,\n onSelectComposition: onSelect,\n active,\n className,\n ...rest\n}: CompositionsPanelProps) {\n const handleSelect = useCallback(\n (selected: Composition) => {\n onSelect && onSelect(selected);\n },\n [onSelect]\n );\n\n return (\n <ul {...rest} className={classNames(className)}>\n {compositions.map((composition) => {\n\n const href = isScaling ? `${url}&name=${composition.identifier}` : `${url}&${composition.identifier}`;\n\n // TODO - move to composition panel node\n return (\n <li\n key={composition.identifier}\n className={classNames(styles.linkWrapper, composition === active && styles.active)}\n >\n <a className={styles.panelLink} onClick={() => handleSelect(composition)}>\n <span className={styles.box}></span>\n <span className={styles.name}>{composition.displayName}</span>\n </a>\n <div className={styles.right}>\n <a\n className={styles.panelLink}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={href}\n >\n <Icon className={styles.icon} of=\"open-tab\" />\n </a>\n </div>\n </li>\n );\n })}\n </ul>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAyBO,SAASA,iBAAT,OAQoB;EAAA,IARO;IAChCC,GADgC;IAEhCC,YAFgC;IAGhCC,SAHgC;IAIhCC,mBAAmB,EAAEC,QAJW;IAKhCC,MALgC;IAMhCC;EANgC,CAQP;EAAA,IADtBC,IACsB;EACzB,MAAMC,YAAY,GAAG,IAAAC,oBAAA,EAClBC,QAAD,IAA2B;IACzBN,QAAQ,IAAI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": "https://bit.dev/teambit/compositions/compositions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.compositions",
|
|
8
8
|
"name": "compositions",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.853"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"graphql-tag": "2.12.1",
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
"classnames": "2.2.6",
|
|
16
16
|
"@babel/runtime": "7.12.18",
|
|
17
17
|
"core-js": "^3.0.0",
|
|
18
|
-
"@teambit/component": "0.0.
|
|
18
|
+
"@teambit/component": "0.0.853",
|
|
19
19
|
"@teambit/compositions.ui.composition-compare": "0.0.81",
|
|
20
20
|
"@teambit/compositions.model.composition-id": "0.0.494",
|
|
21
21
|
"@teambit/harmony": "0.3.3",
|
|
22
|
-
"@teambit/graphql": "0.0.
|
|
22
|
+
"@teambit/graphql": "0.0.853",
|
|
23
23
|
"@teambit/cli": "0.0.566",
|
|
24
|
-
"@teambit/dev-files": "0.0.
|
|
25
|
-
"@teambit/envs": "0.0.
|
|
26
|
-
"@teambit/preview": "0.0.
|
|
27
|
-
"@teambit/schema": "0.0.
|
|
24
|
+
"@teambit/dev-files": "0.0.853",
|
|
25
|
+
"@teambit/envs": "0.0.853",
|
|
26
|
+
"@teambit/preview": "0.0.853",
|
|
27
|
+
"@teambit/schema": "0.0.853",
|
|
28
28
|
"@teambit/toolbox.path.match-patterns": "0.0.7",
|
|
29
|
-
"@teambit/workspace": "0.0.
|
|
29
|
+
"@teambit/workspace": "0.0.853",
|
|
30
30
|
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.494",
|
|
31
31
|
"@teambit/component-id": "0.0.417",
|
|
32
32
|
"@teambit/base-react.navigation.link": "2.0.27",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@teambit/documenter.ui.property-table": "4.1.3",
|
|
46
46
|
"@teambit/mdx.ui.mdx-layout": "0.0.507",
|
|
47
47
|
"@teambit/panels": "0.0.567",
|
|
48
|
-
"@teambit/preview.ui.component-preview": "0.0.
|
|
48
|
+
"@teambit/preview.ui.component-preview": "0.0.502",
|
|
49
49
|
"@teambit/ui-foundation.ui.buttons.collapser": "0.0.201",
|
|
50
50
|
"@teambit/ui-foundation.ui.hooks.use-is-mobile": "0.0.185",
|
|
51
|
-
"@teambit/component-compare": "0.0.
|
|
52
|
-
"@teambit/ui": "0.0.
|
|
51
|
+
"@teambit/component-compare": "0.0.101",
|
|
52
|
+
"@teambit/ui": "0.0.853",
|
|
53
53
|
"@teambit/compositions.model.composition-type": "0.0.495",
|
|
54
54
|
"@teambit/compositions.ui.composition-card": "0.0.502",
|
|
55
55
|
"@teambit/evangelist.elements.icon": "1.0.2"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compositions_compositions@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compositions_compositions@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compositions_compositions@0.0.853/dist/compositions.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compositions_compositions@0.0.853/dist/compositions.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -6,15 +6,32 @@ import { Composition } from '../../composition';
|
|
|
6
6
|
import styles from './compositions-panel.module.scss';
|
|
7
7
|
|
|
8
8
|
export type CompositionsPanelProps = {
|
|
9
|
+
/**
|
|
10
|
+
* list of compositions
|
|
11
|
+
*/
|
|
9
12
|
compositions: Composition[];
|
|
13
|
+
/**
|
|
14
|
+
* select composition to display
|
|
15
|
+
*/
|
|
10
16
|
onSelectComposition: (composition: Composition) => void;
|
|
17
|
+
/**
|
|
18
|
+
* the currently active composition
|
|
19
|
+
*/
|
|
11
20
|
active?: Composition;
|
|
21
|
+
/**
|
|
22
|
+
* the url to the base composition. doesntc contain the current composition params
|
|
23
|
+
*/
|
|
12
24
|
url: string;
|
|
25
|
+
/**
|
|
26
|
+
* checks if a component is using the new preview api. if false, doesnt scale to support new preview
|
|
27
|
+
*/
|
|
28
|
+
isScaling?: boolean;
|
|
13
29
|
} & React.HTMLAttributes<HTMLUListElement>;
|
|
14
30
|
|
|
15
31
|
export function CompositionsPanel({
|
|
16
32
|
url,
|
|
17
33
|
compositions,
|
|
34
|
+
isScaling,
|
|
18
35
|
onSelectComposition: onSelect,
|
|
19
36
|
active,
|
|
20
37
|
className,
|
|
@@ -30,6 +47,9 @@ export function CompositionsPanel({
|
|
|
30
47
|
return (
|
|
31
48
|
<ul {...rest} className={classNames(className)}>
|
|
32
49
|
{compositions.map((composition) => {
|
|
50
|
+
|
|
51
|
+
const href = isScaling ? `${url}&name=${composition.identifier}` : `${url}&${composition.identifier}`;
|
|
52
|
+
|
|
33
53
|
// TODO - move to composition panel node
|
|
34
54
|
return (
|
|
35
55
|
<li
|
|
@@ -45,7 +65,7 @@ export function CompositionsPanel({
|
|
|
45
65
|
className={styles.panelLink}
|
|
46
66
|
target="_blank"
|
|
47
67
|
rel="noopener noreferrer"
|
|
48
|
-
href={
|
|
68
|
+
href={href}
|
|
49
69
|
>
|
|
50
70
|
<Icon className={styles.icon} of="open-tab" />
|
|
51
71
|
</a>
|
|
Binary file
|