@teambit/compositions 1.0.107 → 1.0.109
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/artifacts/preview/teambit_compositions_compositions-preview.js +1 -0
- package/dist/composition.d.ts +8 -8
- package/dist/composition.section.d.ts +3 -3
- package/dist/compositions.composition.d.ts +2 -2
- package/dist/compositions.d.ts +6 -6
- package/dist/compositions.js +8 -10
- package/dist/compositions.js.map +1 -1
- package/dist/compositions.main.runtime.d.ts +2 -5
- package/dist/compositions.main.runtime.js +3 -5
- package/dist/compositions.main.runtime.js.map +1 -1
- package/dist/compositions.preview.runtime.js +2 -2
- package/dist/compositions.preview.runtime.js.map +1 -1
- package/dist/compositions.ui.runtime.d.ts +4 -4
- package/dist/{preview-1703590665075.js → preview-1703698405864.js} +2 -2
- package/dist/ui/composition-preview.d.ts +3 -3
- package/dist/ui/composition-preview.js +3 -4
- package/dist/ui/composition-preview.js.map +1 -1
- package/dist/ui/compositions-panel/compositions-panel.d.ts +2 -2
- package/dist/ui/compositions-panel/compositions-panel.js +2 -2
- package/dist/ui/compositions-panel/compositions-panel.js.map +1 -1
- package/dist/ui/compositions-panel-node/compositions-panel-node.d.ts +2 -2
- package/package.json +25 -32
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports["teambit.compositions/compositions-preview"]=o():e["teambit.compositions/compositions-preview"]=o()}(self,(()=>(()=>{"use strict";var e={15810:(e,o,t)=>{var n={id:"teambit.compositions/compositions@1.0.109",homepage:"https://bit.cloud/teambit/compositions/compositions",exported:!0};function i(){const e=s(t(87363));return i=function(){return e},e}function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(o,"__esModule",{value:!0}),o.Logo=void 0,i.__bit_component=n,s.__bit_component=n;const a=()=>i().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},i().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/compositions.svg"}));a.__bit_component=n,o.Logo=a},96833:(e,o,t)=>{var n={id:"teambit.compositions/aspect-docs/compositions@0.0.165",homepage:"https://bit.cloud/teambit/compositions/aspect-docs/compositions",exported:!0};Object.defineProperty(o,"__esModule",{value:!0}),o.default=f,a(t(87363));var i=t(40040),s=["components"];function a(e){return e&&e.__esModule?e:{default:e}}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var t=arguments[o];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},r.apply(this,arguments)}function p(e,o){if(null==e)return{};var t,n,i=m(e,o);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)t=s[n],o.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}function m(e,o){if(null==e)return{};var t,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)t=s[n],o.indexOf(t)>=0||(i[t]=e[t]);return i}a.__bit_component=n,r.__bit_component=n,p.__bit_component=n,m.__bit_component=n;var c=function(e){return function(o){return console.warn("Component "+e+" was not imported, exported, or provided by MDXProvider as global scope"),(0,i.mdx)("div",o)}};c.__bit_component=n;var l=c("CompositionCard"),d=c("Button"),u={},h="wrapper";function f(e){var o=e.components,t=p(e,s);return(0,i.mdx)(h,r({},u,t,{components:o,mdxType:"MDXLayout"}),(0,i.mdx)("p",null,"The Compositions aspect renders component 'compositions' in isolation and displays them in the Workspace UI and Scope UI.\n'Compositions' are, essentially, small apps that exhibit and test a component in different contexts and variations."),(0,i.mdx)("p",null,'The Compositions aspect is an essential tool to authoring independent components as it renders component instances in "controlled environments", isolated and un-affected by code that was not purposefully included.\nThis sterile environment provides an accurate understanding of their look and behavior, for manual and automated testings.'),(0,i.mdx)("p",null,"Moreover, a component's composition is a way to demonstrate the component for other developers looking to use it, and non-developers, such as designers and product managers, looking to inspect it."),(0,i.mdx)("h4",null,"Features"),(0,i.mdx)("p",null,(0,i.mdx)("strong",{parentName:"p"},"Create component examples with zero configuration:")," Write your compositions the same way you write your components.\nPlace your examples in the component's ",(0,i.mdx)("inlineCode",{parentName:"p"},"*.compositions.*")," file to have them rendered in the Workspace UI with no additional configurations."),(0,i.mdx)("p",null,(0,i.mdx)("strong",{parentName:"p"},"See your components render in all relevant contexts:")," - Render components in the visual context of related and dependant components to learn how changes impact other components during development."),(0,i.mdx)("p",null,(0,i.mdx)("strong",{parentName:"p"},"Hot-reloading in workspace UI:")," - See various instances of a component render live to reflect most recent changes. Get immediate feedbacks to changes in your component's code."),(0,i.mdx)("p",null,(0,i.mdx)("strong",{parentName:"p"},"Compositions as visual documentation:")," - Compositions play an essential part in a component documentation. They demonstrate potential behaviors and use cases for that component. Compositions are another step in promoting components' discoverability, both in your local workspace and in remote scopes."),(0,i.mdx)("p",null,(0,i.mdx)("strong",{parentName:"p"},"Compositions as test samples for your CI")," - Use your compositions as samples for automated integration and unit tests, to track and view the impact of changes on all affected components in your different scopes."),(0,i.mdx)("p",null,(0,i.mdx)("strong",{parentName:"p"},"Developer-Designers collaboration")," - Make visual compositions accessible to designers (and everyone else) to include them in the development and release process of web applications, in a visual way."),(0,i.mdx)("h2",null,"Quickstart & configurations"),(0,i.mdx)("p",null,"Compositions require no configuration. Any ",(0,i.mdx)("inlineCode",{parentName:"p"},"*.compositions.*")," or ",(0,i.mdx)("inlineCode",{parentName:"p"},"*.composition.*")," file will be loaded and displayed in the workspace UI.\nAny tagged version of a component will have its composition included in its build artifacts, to be used as part of the component's preview."),(0,i.mdx)("p",null,"To add your own file pattern for compositions (to be automatically loaded and displayed by the Compositions aspect):"),(0,i.mdx)("pre",null,(0,i.mdx)("code",{parentName:"pre",className:"language-json"},'// In the workspace configuration file\n{\n "teambit.compositions/compositions": {\n "compositionFilePattern": ["**.my-pattern.tsx", "**.my-pattern-2.jsx"]\n }\n}\n')),(0,i.mdx)("h2",null,"Creating compositions"),(0,i.mdx)("blockquote",null,(0,i.mdx)("p",{parentName:"blockquote"},"This document uses React code as snippets.")),(0,i.mdx)("p",null,"Writing a composition does not require any configuration. Import the component to the component's ",(0,i.mdx)("inlineCode",{parentName:"p"},"*.compositions.tsx")," file, use it to build a composition and export the new component (a.k.a, the composition) with a named export."),(0,i.mdx)("p",null,"The name of the export will be converted from PascalCase/camelCase and used for the composition name (e.g, ",(0,i.mdx)("inlineCode",{parentName:"p"},'"CompositionName" --\x3e "Composition name"'),")."),(0,i.mdx)("p",null,(0,i.mdx)("strong",{parentName:"p"},"For example"),", we'll create two compositions, 'Primary button' and 'Secondary button', each of which demonstrates a different variant or usage of that component.\nBoth compositions will be in themed (i.e, displayed in a specific context)."),(0,i.mdx)("p",null,"First, we'll create a new composition file in the component's directory:"),(0,i.mdx)("pre",null,(0,i.mdx)("code",{parentName:"pre",className:"language-bash"},"touch path/to/component/directory/<component-name>.compositions.tsx\n")),(0,i.mdx)("p",null,"Then, we'll import the component and use it to create the compositions:"),(0,i.mdx)("pre",null,(0,i.mdx)("code",{parentName:"pre",className:"language-jsx{}[button.compositions.jsx]"},"import React from 'react';\nimport { IrisTheme } from '@my-organization/design-system/iris-theme';\nimport { Button } from './button';\n\nexport const PrimaryButton = () => {\n return (\n <IrisTheme>\n <Button importance=\"cta\" style={{ width: 120 }}>\n Primary\n </Button>\n </IrisTheme>\n );\n};\n\nexport const SecondaryButton = () => {\n return (\n <IrisTheme>\n <Button importance=\"ghost\" style={{ width: 120 }}>\n Secondary\n </Button>\n </IrisTheme>\n );\n};\n")),(0,i.mdx)("div",{style:{width:450,display:"flex",justifyContent:"space-between"}},(0,i.mdx)(l,{Composition:function(){return(0,i.mdx)(d,{importance:"cta",style:{width:120},mdxType:"Button"},"Primary")},name:"Primary",mdxType:"CompositionCard"}),(0,i.mdx)(l,{Composition:function(){return(0,i.mdx)(d,{importance:"ghost",style:{width:120},mdxType:"Button"},"Secondary")},name:"Secondary",mdxType:"CompositionCard"})),(0,i.mdx)("h2",null,"Loading compositions"),(0,i.mdx)("p",null,"The Environment in use will automatically detect the composition file for each component and use it to load its compositions to the workspace UI."),(0,i.mdx)("h2",null,"Viewing component compositions"),(0,i.mdx)("p",null,"To explore compositions in your Workspace UI, start the local development server for your workspace (",(0,i.mdx)("inlineCode",{parentName:"p"},"bit start"),"),\nbrowse to a specific component and select the ",(0,i.mdx)("strong",{parentName:"p"},"compositions")," tab.\nThere, you will see the full list of compositions available for that component, along with additional component meta-data."),(0,i.mdx)("h2",null,"Using compositions for automated testings"),(0,i.mdx)("p",null,"Component compositions can be used in automated testing as well as manual examinations. To do that, simply import the compositions in your test file to run the appropriate tests."),(0,i.mdx)("p",null,"For example, the below snapshot test checks the 'Button' component when the 'variant' prop is set to 'primary'.\nIn addition to simple unit tests, compositions play an important role in integration test as they provide feedback as to how a change to the component may affect potential usages."),(0,i.mdx)("pre",null,(0,i.mdx)("code",{parentName:"pre",className:"language-jsx"},"import React from 'react';\nimport testRenderer from 'react-test-renderer';\nimport { PrimaryButton } from './button.compositions.tsx';\n\ndescribe('Button', () => {\n it('renders correctly as \"primary\"', () => {\n const component = testRenderer.create(<PrimaryButton>test primary variant</PrimaryButton>);\n const tree = component.toJSON();\n expect(tree).toMatchSnapshot();\n });\n});\n")),(0,i.mdx)("h2",null,"Setting providers for all your compositions"),(0,i.mdx)("p",null,"Extend the React environment to customize its list of providers with your own composition providers.\nThe extended environment will then wrap every composition with these providers to make sure your themes or mock data are accessible to all of them,\nwithout you having to repeat that task ever again."),(0,i.mdx)("h2",null,"Compositions and storybook"),(0,i.mdx)("p",null,"Storybook displays individual components in different states and variations.\nIt is designed to help in authoring and displaying standalone components, each of which is usually part of a design system.\nIn contrast, 'Compositions' is mainly about examining how an independent component looks and behaves when used with other components.\nThese component integrations serve as a way to examine compositions that are likely to be part of real applications, using manual and automated testing."),(0,i.mdx)("p",null,"If you're looking for a Storybook-like solution, you can find that either in the Storybook extension (currently in development) or by using 'Compositions' for that use-case as well."))}f.__bit_component=n,f.isMDXComponent=!0},31862:(e,o,t)=>{Object.defineProperty(o,"T",{enumerable:!0,get:function(){return n.default}});var n=i(t(96833));function i(e){return e&&e.__esModule?e:{default:e}}i.__bit_component={id:"teambit.compositions/aspect-docs/compositions@0.0.165",homepage:"https://bit.cloud/teambit/compositions/aspect-docs/compositions",exported:!0}},40040:e=>{e.exports=MdxJsReact},87363:e=>{e.exports=React}},o={};function t(n){var i=o[n];if(void 0!==i)return i.exports;var s=o[n]={exports:{}};return e[n](s,s.exports,t),s.exports}t.d=(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},t.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{t.r(n),t.d(n,{compositions:()=>d,compositions_metadata:()=>h,overview:()=>u});var e={};t.r(e),t.d(e,{default:()=>l});var o=t(15810),i=(t(87363),t(40040));const s=TeambitMdxUiMdxScopeContext;var a=t(31862),r=["components"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var t=arguments[o];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},p.apply(this,arguments)}var m={},c="wrapper";function l(e){var o=e.components,t=function(e,o){if(null==e)return{};var t,n,i=function(e,o){if(null==e)return{};var t,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)t=s[n],o.indexOf(t)>=0||(i[t]=e[t]);return i}(e,o);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)t=s[n],o.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}(e,r);return(0,i.mdx)(c,p({},m,t,{components:o,mdxType:"MDXLayout"}),(0,i.mdx)(s.MDXScopeProvider,{components:{Compositions:a.T},mdxType:"MDXScopeProvider"},(0,i.mdx)(a.T,{mdxType:"Compositions"})))}l.isMDXComponent=!0;const d=[o],u=[e],h={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),n})()));
|
package/dist/composition.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type CompositionProps = {
|
|
2
2
|
identifier: string;
|
|
3
3
|
filepath?: string;
|
|
4
4
|
displayName?: string;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type CompositionBrowserMetadata = {
|
|
7
7
|
displayName?: string;
|
|
8
8
|
identifier: string;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type CompositionBrowserMetadataObject = {
|
|
11
11
|
compositions: CompositionBrowserMetadata[];
|
|
12
12
|
};
|
|
13
13
|
export declare class Composition {
|
|
@@ -18,7 +18,7 @@ export declare class Composition {
|
|
|
18
18
|
/**
|
|
19
19
|
* file path in which the composition is contained.
|
|
20
20
|
*/
|
|
21
|
-
readonly filepath?: string
|
|
21
|
+
readonly filepath?: string;
|
|
22
22
|
/**
|
|
23
23
|
* set explicit display name
|
|
24
24
|
*/
|
|
@@ -31,16 +31,16 @@ export declare class Composition {
|
|
|
31
31
|
/**
|
|
32
32
|
* file path in which the composition is contained.
|
|
33
33
|
*/
|
|
34
|
-
filepath?: string
|
|
34
|
+
filepath?: string,
|
|
35
35
|
/**
|
|
36
36
|
* set explicit display name
|
|
37
37
|
*/
|
|
38
|
-
_displayName?: string
|
|
38
|
+
_displayName?: string);
|
|
39
39
|
get displayName(): string;
|
|
40
40
|
toObject(): {
|
|
41
41
|
identifier: string;
|
|
42
|
-
filepath: string
|
|
43
|
-
displayName: string
|
|
42
|
+
filepath: string;
|
|
43
|
+
displayName: string;
|
|
44
44
|
};
|
|
45
45
|
toBrowserMetaDataObject(): CompositionBrowserMetadata;
|
|
46
46
|
static fromArray(compositions: CompositionProps[]): Composition[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { Section } from '@teambit/component';
|
|
2
|
-
import React from 'react';
|
|
3
3
|
import type { CompositionsUI, CompositionsMenuSlot, EmptyStateSlot } from './compositions.ui.runtime';
|
|
4
|
-
|
|
4
|
+
type Options = {
|
|
5
5
|
menuBarWidgetSlot: CompositionsMenuSlot;
|
|
6
6
|
};
|
|
7
7
|
export declare class CompositionsSection implements Section {
|
|
@@ -22,7 +22,7 @@ export declare class CompositionsSection implements Section {
|
|
|
22
22
|
};
|
|
23
23
|
route: {
|
|
24
24
|
path: string;
|
|
25
|
-
element:
|
|
25
|
+
element: JSX.Element;
|
|
26
26
|
};
|
|
27
27
|
order: number;
|
|
28
28
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const Logo: () =>
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Logo: () => JSX.Element;
|
package/dist/compositions.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { ComponentModel } from '@teambit/component';
|
|
3
3
|
import { EmptyStateSlot } from './compositions.ui.runtime';
|
|
4
4
|
import { Composition } from './composition';
|
|
5
5
|
import type { CompositionsMenuSlot } from './compositions.ui.runtime';
|
|
6
6
|
import { ComponentCompositionProps } from './ui/composition-preview';
|
|
7
|
-
export
|
|
7
|
+
export type MenuBarWidget = {
|
|
8
8
|
location: 'start' | 'end';
|
|
9
9
|
content: ReactNode;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type CompositionsProp = {
|
|
12
12
|
menuBarWidgets?: CompositionsMenuSlot;
|
|
13
13
|
emptyState?: EmptyStateSlot;
|
|
14
14
|
};
|
|
15
|
-
export declare function Compositions({ menuBarWidgets, emptyState }: CompositionsProp):
|
|
16
|
-
export
|
|
15
|
+
export declare function Compositions({ menuBarWidgets, emptyState }: CompositionsProp): JSX.Element;
|
|
16
|
+
export type CompositionContentProps = {
|
|
17
17
|
component: ComponentModel;
|
|
18
18
|
selected?: Composition;
|
|
19
19
|
queryParams?: string | string[];
|
|
20
20
|
emptyState?: EmptyStateSlot;
|
|
21
21
|
} & ComponentCompositionProps;
|
|
22
|
-
export declare function CompositionContent({ component, selected, queryParams, emptyState, ...componentCompositionProps }: CompositionContentProps):
|
|
22
|
+
export declare function CompositionContent({ component, selected, queryParams, emptyState, ...componentCompositionProps }: CompositionContentProps): JSX.Element;
|
package/dist/compositions.js
CHANGED
|
@@ -205,7 +205,6 @@ function Compositions({
|
|
|
205
205
|
menuBarWidgets,
|
|
206
206
|
emptyState
|
|
207
207
|
}) {
|
|
208
|
-
var _component$preview, _component$preview2, _component$preview3;
|
|
209
208
|
const component = (0, _react().useContext)(_component().ComponentContext);
|
|
210
209
|
// const [searchParams, setSearchParams] = useSearchParams();
|
|
211
210
|
const params = (0, _reactRouterDom().useParams)();
|
|
@@ -232,9 +231,9 @@ function Compositions({
|
|
|
232
231
|
const [isSidebarOpen, setSidebarOpenness] = (0, _react().useState)(showSidebar);
|
|
233
232
|
const sidebarOpenness = isSidebarOpen ? _baseUiSurfacesSplitPane().Layout.row : _baseUiSurfacesSplitPane().Layout.left;
|
|
234
233
|
const compositionUrl = (0, _previewUi().toPreviewUrl)(component, 'compositions');
|
|
235
|
-
const isScaling = component
|
|
236
|
-
const includesEnvTemplates = component
|
|
237
|
-
const compositionIdentifierParam = isScaling && includesEnvTemplates === false ? `name=${currentComposition
|
|
234
|
+
const isScaling = component?.preview?.isScaling;
|
|
235
|
+
const includesEnvTemplates = component?.preview?.includesEnvTemplate;
|
|
236
|
+
const compositionIdentifierParam = isScaling && includesEnvTemplates === false ? `name=${currentComposition?.identifier}` : currentComposition?.identifier;
|
|
238
237
|
const currentCompositionFullUrl = (0, _previewUi().toPreviewUrl)(component, 'compositions', compositionIdentifierParam);
|
|
239
238
|
const [compositionParams, setCompositionParams] = (0, _react().useState)({});
|
|
240
239
|
const queryParams = (0, _react().useMemo)(() => _queryString().default.stringify(compositionParams), [compositionParams]);
|
|
@@ -285,7 +284,7 @@ function Compositions({
|
|
|
285
284
|
className: _compositionsModule().default.tabContent
|
|
286
285
|
}, /*#__PURE__*/_react().default.createElement(_compositionsPanel().CompositionsPanel, {
|
|
287
286
|
isScaling: isScaling,
|
|
288
|
-
includesEnvTemplate:
|
|
287
|
+
includesEnvTemplate: component.preview?.includesEnvTemplate,
|
|
289
288
|
onSelectComposition: composition => {
|
|
290
289
|
if (!currentComposition || !location) return;
|
|
291
290
|
if (location.pathname.includes(currentComposition.identifier.toLowerCase())) {
|
|
@@ -312,7 +311,6 @@ function Compositions({
|
|
|
312
311
|
}) : /*#__PURE__*/_react().default.createElement("div", null)))))));
|
|
313
312
|
}
|
|
314
313
|
function CompositionContent(_ref) {
|
|
315
|
-
var _component$environmen;
|
|
316
314
|
let {
|
|
317
315
|
component,
|
|
318
316
|
selected,
|
|
@@ -320,8 +318,8 @@ function CompositionContent(_ref) {
|
|
|
320
318
|
emptyState
|
|
321
319
|
} = _ref,
|
|
322
320
|
componentCompositionProps = _objectWithoutProperties(_ref, _excluded);
|
|
323
|
-
const env =
|
|
324
|
-
const EmptyStateTemplate = emptyState
|
|
321
|
+
const env = component.environment?.id;
|
|
322
|
+
const EmptyStateTemplate = emptyState?.get(env || ''); // || defaultTemplate;
|
|
325
323
|
|
|
326
324
|
if (component.compositions.length === 0 && component.host === 'teambit.workspace/workspace' && EmptyStateTemplate) {
|
|
327
325
|
return /*#__PURE__*/_react().default.createElement("div", {
|
|
@@ -336,12 +334,12 @@ function CompositionContent(_ref) {
|
|
|
336
334
|
title: "There are no compositions for this Component. Learn how to add compositions:"
|
|
337
335
|
}, /*#__PURE__*/_react().default.createElement(_mdxUi().MDXLayout, null, /*#__PURE__*/_react().default.createElement(EmptyStateTemplate, null)))));
|
|
338
336
|
}
|
|
339
|
-
if (
|
|
337
|
+
if (component?.buildStatus === 'pending' && component?.host === 'teambit.scope/scope') return /*#__PURE__*/_react().default.createElement(_designUiSurfaces().StatusMessageCard, {
|
|
340
338
|
className: _compositionsModule().default.buildStatusMessage,
|
|
341
339
|
status: "PROCESSING",
|
|
342
340
|
title: "component preview pending"
|
|
343
341
|
}, "this might take some time");
|
|
344
|
-
if (
|
|
342
|
+
if (component?.buildStatus === 'failed' && component?.host === 'teambit.scope/scope') return /*#__PURE__*/_react().default.createElement(_designUiSurfaces().StatusMessageCard, {
|
|
345
343
|
className: _compositionsModule().default.buildStatusMessage,
|
|
346
344
|
status: "FAILURE",
|
|
347
345
|
title: "failed to get component preview "
|
package/dist/compositions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_reactRouterDom","_lodash","_interopRequireDefault","_queryString","_documenterTheme","_baseUiSurfacesSplitPane","_baseUiSurfacesSplitPane2","_component","_documenterUi","_panels","_docsUiQueries","_uiFoundationUiButtons","_designUi","_previewUi","_uiFoundationUiHooks","_compositionsUi","_compositionsUiHooks","_mdxUi","_designUi2","_documenterUi2","_designUi3","_baseReactNavigation","_designUiInput","_designUiSurfaces","_compositionsModule","_ui","_compositionsPanel","_excluded","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","Compositions","menuBarWidgets","emptyState","_component$preview","_component$preview2","_component$preview3","component","useContext","ComponentContext","params","useParams","navigate","useNavigate","location","useLocation","currentCompositionName","currentComposition","compositions","find","composition","identifier","toLowerCase","head","selectedRef","useRef","current","properties","useDocs","id","isMobile","useIsMobile","showSidebar","isSidebarOpen","setSidebarOpenness","useState","sidebarOpenness","Layout","row","left","compositionUrl","toPreviewUrl","isScaling","preview","includesEnvTemplates","includesEnvTemplate","compositionIdentifierParam","currentCompositionFullUrl","compositionParams","setCompositionParams","queryParams","useMemo","queryString","stringify","useEffect","createElement","CompositionContextProvider","setQueryParams","SplitPane","layout","size","className","styles","compositionsPage","Pane","CompositionsMenuBar","menuBar","Link","external","href","openInNewTab","OptionButton","icon","CompositionContent","compositionPanel","selected","HoverSplitter","splitter","Collapser","placement","isOpen","onMouseDown","stopPropagation","onClick","x","tooltipContent","collapser","right","ThemeContext","TabContainer","tabsContainer","TabList","tabs","Tab","TabPanel","tabContent","CompositionsPanel","onSelectComposition","pathname","includes","path","replace","nextPath","concat","url","active","PropTable","rows","showListView","_ref","_component$environmen","componentCompositionProps","env","environment","EmptyStateTemplate","host","noCompositionsPage","H1","title","Separator","isPresentational","separator","AlertCard","level","MDXLayout","buildStatus","StatusMessageCard","buildStatusMessage","status","EmptyBox","linkText","link","ComponentComposition","compositionsIframe","viewport","forceHeight","fullContentHeight","pubsub"],"sources":["compositions.tsx"],"sourcesContent":["import React, { useContext, useEffect, useState, useMemo, useRef, ReactNode } from 'react';\nimport { useParams } from 'react-router-dom';\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, useNavigate, useLocation } 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';\nimport { ComponentCompositionProps } from './ui/composition-preview';\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 [searchParams, setSearchParams] = useSearchParams();\n const params = useParams();\n const navigate = useNavigate();\n const location = useLocation();\n const currentCompositionName = params['*'];\n // console.log(routes);\n const currentComposition =\n component.compositions.find((composition) => composition.identifier.toLowerCase() === currentCompositionName) ||\n head(component.compositions);\n // const [selected, selectComposition] = useState(head(component.compositions));\n const selectedRef = useRef(currentComposition);\n selectedRef.current = currentComposition;\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 // navigate(next.displayName.toLowerCase().replaceAll(' ', '-'));\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 includesEnvTemplates = component?.preview?.includesEnvTemplate;\n const compositionIdentifierParam =\n isScaling && includesEnvTemplates === false\n ? `name=${currentComposition?.identifier}`\n : currentComposition?.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 className={styles.compositionPanel}\n emptyState={emptyState}\n component={component}\n selected={currentComposition}\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 includesEnvTemplate={component.preview?.includesEnvTemplate}\n onSelectComposition={(composition) => {\n if (!currentComposition || !location) return;\n if (location.pathname.includes(currentComposition.identifier.toLowerCase())) {\n navigate(composition.identifier.toLowerCase());\n return;\n }\n\n const path = location.pathname.replace(\n currentComposition.identifier.toLowerCase(),\n composition.identifier.toLowerCase()\n );\n\n if (!path) return;\n if (!path.includes(composition.identifier.toLowerCase())) {\n const nextPath = location.pathname.concat(`/${composition.identifier.toLowerCase()}`);\n navigate(nextPath);\n return;\n }\n navigate(path);\n }}\n url={compositionUrl}\n compositions={component.compositions}\n active={currentComposition}\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} & ComponentCompositionProps;\n\nexport function CompositionContent({\n component,\n selected,\n queryParams,\n emptyState,\n ...componentCompositionProps\n}: 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/reference/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 {...componentCompositionProps}\n />\n );\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,gBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,eAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAH,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAK,sBAAA,CAAAH,OAAA;EAAAI,YAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,iBAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,gBAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,yBAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,wBAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,0BAAA;EAAA,MAAAT,IAAA,GAAAE,OAAA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QAAA;IACnB8E,SAAS,EAAEC,6BAAM,CAACuE;IAClB;IAAA;IACAC,QAAQ,EAAE,IAAK;IACf/H,SAAS,EAAEA,SAAU;IACrBgI,WAAW,EAAC,MAAM;IAClBnH,WAAW,EAAEuD,QAAS;IACtB6D,iBAAiB;IACjBC,MAAM,EAAE,IAAK;IACbvF,WAAW,EAAEA;EAAY,GACrB6D,yBAAyB,CAC9B,CAAC;AAEN"}
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_reactRouterDom","_lodash","_interopRequireDefault","_queryString","_documenterTheme","_baseUiSurfacesSplitPane","_baseUiSurfacesSplitPane2","_component","_documenterUi","_panels","_docsUiQueries","_uiFoundationUiButtons","_designUi","_previewUi","_uiFoundationUiHooks","_compositionsUi","_compositionsUiHooks","_mdxUi","_designUi2","_documenterUi2","_designUi3","_baseReactNavigation","_designUiInput","_designUiSurfaces","_compositionsModule","_ui","_compositionsPanel","_excluded","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","Compositions","menuBarWidgets","emptyState","component","useContext","ComponentContext","params","useParams","navigate","useNavigate","location","useLocation","currentCompositionName","currentComposition","compositions","find","composition","identifier","toLowerCase","head","selectedRef","useRef","current","properties","useDocs","id","isMobile","useIsMobile","showSidebar","isSidebarOpen","setSidebarOpenness","useState","sidebarOpenness","Layout","row","left","compositionUrl","toPreviewUrl","isScaling","preview","includesEnvTemplates","includesEnvTemplate","compositionIdentifierParam","currentCompositionFullUrl","compositionParams","setCompositionParams","queryParams","useMemo","queryString","stringify","useEffect","createElement","CompositionContextProvider","setQueryParams","SplitPane","layout","size","className","styles","compositionsPage","Pane","CompositionsMenuBar","menuBar","Link","external","href","openInNewTab","OptionButton","icon","CompositionContent","compositionPanel","selected","HoverSplitter","splitter","Collapser","placement","isOpen","onMouseDown","stopPropagation","onClick","x","tooltipContent","collapser","right","ThemeContext","TabContainer","tabsContainer","TabList","tabs","Tab","TabPanel","tabContent","CompositionsPanel","onSelectComposition","pathname","includes","path","replace","nextPath","concat","url","active","PropTable","rows","showListView","_ref","componentCompositionProps","env","environment","EmptyStateTemplate","host","noCompositionsPage","H1","title","Separator","isPresentational","separator","AlertCard","level","MDXLayout","buildStatus","StatusMessageCard","buildStatusMessage","status","EmptyBox","linkText","link","ComponentComposition","compositionsIframe","viewport","forceHeight","fullContentHeight","pubsub"],"sources":["compositions.tsx"],"sourcesContent":["import React, { useContext, useEffect, useState, useMemo, useRef, ReactNode } from 'react';\nimport { useParams } from 'react-router-dom';\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, useNavigate, useLocation } 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';\nimport { ComponentCompositionProps } from './ui/composition-preview';\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 [searchParams, setSearchParams] = useSearchParams();\n const params = useParams();\n const navigate = useNavigate();\n const location = useLocation();\n const currentCompositionName = params['*'];\n // console.log(routes);\n const currentComposition =\n component.compositions.find((composition) => composition.identifier.toLowerCase() === currentCompositionName) ||\n head(component.compositions);\n // const [selected, selectComposition] = useState(head(component.compositions));\n const selectedRef = useRef(currentComposition);\n selectedRef.current = currentComposition;\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 // navigate(next.displayName.toLowerCase().replaceAll(' ', '-'));\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 includesEnvTemplates = component?.preview?.includesEnvTemplate;\n const compositionIdentifierParam =\n isScaling && includesEnvTemplates === false\n ? `name=${currentComposition?.identifier}`\n : currentComposition?.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 className={styles.compositionPanel}\n emptyState={emptyState}\n component={component}\n selected={currentComposition}\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 includesEnvTemplate={component.preview?.includesEnvTemplate}\n onSelectComposition={(composition) => {\n if (!currentComposition || !location) return;\n if (location.pathname.includes(currentComposition.identifier.toLowerCase())) {\n navigate(composition.identifier.toLowerCase());\n return;\n }\n\n const path = location.pathname.replace(\n currentComposition.identifier.toLowerCase(),\n composition.identifier.toLowerCase()\n );\n\n if (!path) return;\n if (!path.includes(composition.identifier.toLowerCase())) {\n const nextPath = location.pathname.concat(`/${composition.identifier.toLowerCase()}`);\n navigate(nextPath);\n return;\n }\n navigate(path);\n }}\n url={compositionUrl}\n compositions={component.compositions}\n active={currentComposition}\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} & ComponentCompositionProps;\n\nexport function CompositionContent({\n component,\n selected,\n queryParams,\n emptyState,\n ...componentCompositionProps\n}: 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/reference/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 {...componentCompositionProps}\n />\n );\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,gBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,eAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAH,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAK,sBAAA,CAAAH,OAAA;EAAAI,YAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,iBAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,gBAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,yBAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,wBAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,0BAAA;EAAA,MAAAT,IAAA,GAAAE,OAAA;EAAAO,yBAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAU,WAAA;EAAA,MAAAV,IAAA,GAAAE,OAAA;EAAAQ,UAAA,YAAAA,CAAA;IAAA,OAAAV,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAW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,CAAChG,iBAAA,GAAAsK,iBAAiB;IAChBhE,SAAS,EAAEC,6BAAM,CAACgE,kBAAmB;IACrCC,MAAM,EAAC,SAAS;IAChBV,KAAK,EAAC;EAAkC,CACtB,CAAC;;EAGzB;EACA,IAAI9G,SAAS,CAACW,YAAY,CAAC3B,MAAM,KAAK,CAAC,EAAE;IACvC,oBACE3D,MAAA,GAAAkC,OAAA,CAAAyF,aAAA,CAAC3G,SAAA,GAAAoL,QAAQ;MACPX,KAAK,EAAC,+CAA+C;MACrDY,QAAQ,EAAC,kCAAkC;MAC3CC,IAAI,EAAG;IAAoF,CAC5F,CAAC;EAEN;EAEA,oBACEtM,MAAA,GAAAkC,OAAA,CAAAyF,aAAA,CAAC9F,GAAA,GAAA0K,oBAAoB,EAAAjJ,QAAA;IACnB2E,SAAS,EAAEC,6BAAM,CAACsE;IAClB;IAAA;IACAC,QAAQ,EAAE,IAAK;IACf9H,SAAS,EAAEA,SAAU;IACrB+H,WAAW,EAAC,MAAM;IAClBlH,WAAW,EAAEuD,QAAS;IACtB4D,iBAAiB;IACjBC,MAAM,EAAE,IAAK;IACbtF,WAAW,EAAEA;EAAY,GACrB4D,yBAAyB,CAC9B,CAAC;AAEN"}
|
|
@@ -9,7 +9,7 @@ import { PreviewMain } from '@teambit/preview';
|
|
|
9
9
|
import { SchemaMain } from '@teambit/schema';
|
|
10
10
|
import { Workspace } from '@teambit/workspace';
|
|
11
11
|
import { Composition } from './composition';
|
|
12
|
-
export
|
|
12
|
+
export type CompositionsConfig = {
|
|
13
13
|
/**
|
|
14
14
|
* glob pattern to detect composition files. This includes all related files, like styles and jsons.
|
|
15
15
|
* @example ['/*.composition?(s).*']
|
|
@@ -89,10 +89,7 @@ export declare class CompositionsMain {
|
|
|
89
89
|
name: string;
|
|
90
90
|
pattern: string[];
|
|
91
91
|
};
|
|
92
|
-
getDevPatternToRegister():
|
|
93
|
-
name: string;
|
|
94
|
-
pattern: string[];
|
|
95
|
-
};
|
|
92
|
+
getDevPatternToRegister(): any;
|
|
96
93
|
onComponentLoad(component: Component, loadOpts?: ComponentLoadOptions): Promise<AspectData | undefined>;
|
|
97
94
|
private computeCompositions;
|
|
98
95
|
static defaultConfig: CompositionsConfig;
|
|
@@ -197,9 +197,8 @@ class CompositionsMain {
|
|
|
197
197
|
return this.compositionFilePattern;
|
|
198
198
|
}
|
|
199
199
|
getComponentDevPatterns(component) {
|
|
200
|
-
var _this$workspace;
|
|
201
200
|
const env = this.envs.calculateEnv(component, {
|
|
202
|
-
skipWarnings: !!
|
|
201
|
+
skipWarnings: !!this.workspace?.inInstallContext
|
|
203
202
|
}).env;
|
|
204
203
|
const componentEnvCompositionsDevPatterns = env.getCompositionsDevPatterns ? env.getCompositionsDevPatterns(component) : [];
|
|
205
204
|
const componentPatterns = componentEnvCompositionsDevPatterns.concat(this.getCompositionFilePattern());
|
|
@@ -212,7 +211,7 @@ class CompositionsMain {
|
|
|
212
211
|
return this.getComponentDevPatterns.bind(this);
|
|
213
212
|
}
|
|
214
213
|
async onComponentLoad(component, loadOpts) {
|
|
215
|
-
if (
|
|
214
|
+
if (loadOpts?.loadCompositions === false) return undefined;
|
|
216
215
|
const compositions = this.readCompositions(component);
|
|
217
216
|
return {
|
|
218
217
|
compositions: compositions.map(composition => composition.toObject())
|
|
@@ -225,8 +224,7 @@ class CompositionsMain {
|
|
|
225
224
|
const modulePath = this.workspace ? (0, _path().join)(this.workspace.componentDir(component.id), file.relative) : file.relative;
|
|
226
225
|
const exports = this.schema.parseModule(modulePath, file.contents.toString());
|
|
227
226
|
return exports.map(exportModel => {
|
|
228
|
-
|
|
229
|
-
const displayName = (_exportModel$staticPr = exportModel.staticProperties) === null || _exportModel$staticPr === void 0 ? void 0 : _exportModel$staticPr.get('compositionName');
|
|
227
|
+
const displayName = exportModel.staticProperties?.get('compositionName');
|
|
230
228
|
return new (_composition().Composition)(exportModel.identifier, file.relative, typeof displayName === 'string' ? displayName : undefined);
|
|
231
229
|
});
|
|
232
230
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_cli","data","require","_component","_scope","_interopRequireDefault","_devFiles","_envs","_graphql","_preview","_schema","_toolboxPath","_workspace","_path","_composition","_compositions","_compositions2","_compositions3","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","CompositionsMain","constructor","compositionFilePattern","previewFilePattern","preview","workspace","schema","devFiles","envs","getPreviewFiles","components","ComponentMap","as","component","compositionFiles","state","filesystem","byGlob","previewFiles","Set","map","file","relative","files","filter","has","isCompositionFile","filePath","includePatterns","excludePatterns","splitPatterns","matchPatterns","getCompositions","entry","get","CompositionsAspect","id","compositions","Composition","fromArray","readCompositions","maybeFiles","byComponent","computeCompositions","flat","getCompositionFilePattern","getComponentDevPatterns","_this$workspace","env","calculateEnv","skipWarnings","inInstallContext","componentEnvCompositionsDevPatterns","getCompositionsDevPatterns","componentPatterns","concat","name","pattern","getDevPatternToRegister","bind","onComponentLoad","loadOpts","loadCompositions","undefined","composition","toObject","pathArray","path","split","length","modulePath","join","componentDir","exports","parseModule","contents","toString","exportModel","_exportModel$staticPr","displayName","staticProperties","identifier","provider","graphql","scope","config","compositionPreviewFilePattern","registerDevPattern","register","compositionsSchema","registerDefinition","CompositionPreviewDefinition","registerOnComponentLoad","registerOnCompAspectReCalc","MainRuntime","PreviewAspect","GraphqlAspect","WorkspaceAspect","SchemaAspect","DevFilesAspect","EnvsAspect","ScopeAspect","addRuntime"],"sources":["compositions.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { AspectData, Component, ComponentMap, IComponent } from '@teambit/component';\nimport ScopeAspect, { ScopeMain } from '@teambit/scope';\nimport { DevFilesAspect, DevFilesMain } from '@teambit/dev-files';\nimport EnvsAspect, { EnvsMain } from '@teambit/envs';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { PreviewAspect, PreviewMain } from '@teambit/preview';\nimport { SchemaAspect, SchemaMain } from '@teambit/schema';\nimport { matchPatterns, splitPatterns } from '@teambit/toolbox.path.match-patterns';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { join } from 'path';\nimport { Composition } from './composition';\nimport { CompositionsAspect } from './compositions.aspect';\nimport { compositionsSchema } from './compositions.graphql';\nimport { CompositionPreviewDefinition } from './compositions.preview-definition';\n\nexport type CompositionsConfig = {\n /**\n * glob pattern to detect composition files. This includes all related files, like styles and jsons.\n * @example ['/*.composition?(s).*']\n */\n compositionFilePattern: string[];\n /**\n * glob pattern to select Preview files. this will only include files matched by compositionFilePattern.\n * @example ['*.{t,j}s', '*.{t,j}sx']\n */\n compositionPreviewFilePattern: string[];\n};\n\n/**\n * the component documentation extension.\n */\nexport class CompositionsMain {\n constructor(\n /**\n * Glob pattern to select all composition files\n */\n private compositionFilePattern: string[],\n\n /**\n * Glob pattern to select composition preview files\n */\n private previewFilePattern: string[],\n\n /**\n * envs extension.\n */\n private preview: PreviewMain,\n\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * schema extension.\n */\n private schema: SchemaMain,\n\n private devFiles: DevFilesMain,\n\n private envs: EnvsMain\n ) {}\n\n /**\n * returns an array of doc file paths for a set of components.\n */\n getPreviewFiles(components: Component[]): ComponentMap<AbstractVinyl[]> {\n return ComponentMap.as<AbstractVinyl[]>(components, (component) => {\n // this includes non executables, like `button.compositions.module.scss` or `presets.compositions.json`\n const compositionFiles = component.state.filesystem.byGlob(this.compositionFilePattern);\n\n // select only relevant preview files (.tsx, etc)\n const previewFiles = new Set(\n component.state.filesystem.byGlob(this.previewFilePattern).map((file) => file.relative)\n );\n const files = compositionFiles.filter((file) => previewFiles.has(file.relative));\n\n return files;\n });\n }\n\n /**\n * checks if a file matches the composition file pattern.\n */\n isCompositionFile(filePath: string): boolean {\n const { includePatterns, excludePatterns } = splitPatterns(this.compositionFilePattern);\n return matchPatterns(filePath, includePatterns, excludePatterns);\n }\n\n /**\n * get component compositions.\n */\n getCompositions(component: IComponent): Composition[] {\n const entry = component.get(CompositionsAspect.id);\n if (!entry) return [];\n const compositions = entry.data.compositions;\n if (!compositions) return [];\n\n return Composition.fromArray(compositions);\n }\n\n /**\n * read composition from the component source code.\n */\n readCompositions(component: Component): Composition[] {\n const maybeFiles = this.getPreviewFiles([component]).byComponent(component);\n\n if (!maybeFiles) return [];\n const [, files] = maybeFiles;\n return files.map((file) => this.computeCompositions(component, file)).flat();\n }\n\n getCompositionFilePattern() {\n return this.compositionFilePattern;\n }\n\n getComponentDevPatterns(component: Component) {\n const env = this.envs.calculateEnv(component, { skipWarnings: !!this.workspace?.inInstallContext }).env;\n const componentEnvCompositionsDevPatterns: string[] = env.getCompositionsDevPatterns\n ? env.getCompositionsDevPatterns(component)\n : [];\n const componentPatterns = componentEnvCompositionsDevPatterns.concat(this.getCompositionFilePattern());\n return { name: 'compositions', pattern: componentPatterns };\n }\n\n getDevPatternToRegister() {\n return this.getComponentDevPatterns.bind(this);\n }\n\n async onComponentLoad(component: Component, loadOpts?: ComponentLoadOptions): Promise<AspectData | undefined> {\n if (loadOpts?.loadCompositions === false) return undefined;\n const compositions = this.readCompositions(component);\n return {\n compositions: compositions.map((composition) => composition.toObject()),\n };\n }\n\n private computeCompositions(component: Component, file: AbstractVinyl): Composition[] {\n // :TODO hacked for a specific file extension now until david will take care in the compiler.\n const pathArray = file.path.split('.');\n pathArray[pathArray.length - 1] = 'js';\n\n const modulePath = this.workspace ? join(this.workspace.componentDir(component.id), file.relative) : file.relative;\n const exports = this.schema.parseModule(modulePath, file.contents.toString());\n return exports.map((exportModel) => {\n const displayName = exportModel.staticProperties?.get('compositionName');\n\n return new Composition(\n exportModel.identifier,\n file.relative,\n typeof displayName === 'string' ? displayName : undefined\n );\n });\n }\n\n static defaultConfig: CompositionsConfig = {\n compositionFilePattern: ['**/*.composition?(s).*'],\n compositionPreviewFilePattern: ['**/*.{t,j}s?(x)'],\n };\n\n static runtime = MainRuntime;\n static dependencies = [\n PreviewAspect,\n GraphqlAspect,\n WorkspaceAspect,\n SchemaAspect,\n DevFilesAspect,\n EnvsAspect,\n ScopeAspect,\n ];\n\n static async provider(\n [preview, graphql, workspace, schema, devFiles, envs, scope]: [\n PreviewMain,\n GraphqlMain,\n Workspace,\n SchemaMain,\n DevFilesMain,\n EnvsMain,\n ScopeMain\n ],\n config: CompositionsConfig\n ) {\n const compositions = new CompositionsMain(\n config.compositionFilePattern,\n config.compositionPreviewFilePattern,\n preview,\n workspace,\n schema,\n devFiles,\n envs\n );\n\n // TODO: use the docs implementation to allow component specific pattern\n devFiles.registerDevPattern(compositions.getDevPatternToRegister());\n\n graphql.register(compositionsSchema(compositions));\n preview.registerDefinition(new CompositionPreviewDefinition(compositions));\n\n if (workspace) {\n workspace.registerOnComponentLoad(compositions.onComponentLoad.bind(compositions));\n }\n if (scope) {\n scope.registerOnCompAspectReCalc(compositions.onComponentLoad.bind(compositions));\n }\n\n return compositions;\n }\n}\n\nCompositionsAspect.addRuntime(CompositionsMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,SAAA,YAAAA,CAAA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AC;AAAA1G,eAAA,CA/HUoB,gBAAgB,aAiIV8F,kBAAW;AAAAlH,eAAA,CAjIjBoB,gBAAgB,kBAkIL,CACpB+F,wBAAa,EACbC,wBAAa,EACbC,4BAAe,EACfC,sBAAY,EACZC,0BAAc,EACdC,eAAU,EACVC,gBAAW,CACZ;AAyCHlE,kCAAkB,CAACmE,UAAU,CAACtG,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"names":["_cli","data","require","_component","_scope","_interopRequireDefault","_devFiles","_envs","_graphql","_preview","_schema","_toolboxPath","_workspace","_path","_composition","_compositions","_compositions2","_compositions3","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","CompositionsMain","constructor","compositionFilePattern","previewFilePattern","preview","workspace","schema","devFiles","envs","getPreviewFiles","components","ComponentMap","as","component","compositionFiles","state","filesystem","byGlob","previewFiles","Set","map","file","relative","files","filter","has","isCompositionFile","filePath","includePatterns","excludePatterns","splitPatterns","matchPatterns","getCompositions","entry","get","CompositionsAspect","id","compositions","Composition","fromArray","readCompositions","maybeFiles","byComponent","computeCompositions","flat","getCompositionFilePattern","getComponentDevPatterns","env","calculateEnv","skipWarnings","inInstallContext","componentEnvCompositionsDevPatterns","getCompositionsDevPatterns","componentPatterns","concat","name","pattern","getDevPatternToRegister","bind","onComponentLoad","loadOpts","loadCompositions","undefined","composition","toObject","pathArray","path","split","length","modulePath","join","componentDir","exports","parseModule","contents","toString","exportModel","displayName","staticProperties","identifier","provider","graphql","scope","config","compositionPreviewFilePattern","registerDevPattern","register","compositionsSchema","registerDefinition","CompositionPreviewDefinition","registerOnComponentLoad","registerOnCompAspectReCalc","MainRuntime","PreviewAspect","GraphqlAspect","WorkspaceAspect","SchemaAspect","DevFilesAspect","EnvsAspect","ScopeAspect","addRuntime"],"sources":["compositions.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { AspectData, Component, ComponentMap, IComponent } from '@teambit/component';\nimport ScopeAspect, { ScopeMain } from '@teambit/scope';\nimport { DevFilesAspect, DevFilesMain } from '@teambit/dev-files';\nimport EnvsAspect, { EnvsMain } from '@teambit/envs';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { PreviewAspect, PreviewMain } from '@teambit/preview';\nimport { SchemaAspect, SchemaMain } from '@teambit/schema';\nimport { matchPatterns, splitPatterns } from '@teambit/toolbox.path.match-patterns';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { join } from 'path';\nimport { Composition } from './composition';\nimport { CompositionsAspect } from './compositions.aspect';\nimport { compositionsSchema } from './compositions.graphql';\nimport { CompositionPreviewDefinition } from './compositions.preview-definition';\n\nexport type CompositionsConfig = {\n /**\n * glob pattern to detect composition files. This includes all related files, like styles and jsons.\n * @example ['/*.composition?(s).*']\n */\n compositionFilePattern: string[];\n /**\n * glob pattern to select Preview files. this will only include files matched by compositionFilePattern.\n * @example ['*.{t,j}s', '*.{t,j}sx']\n */\n compositionPreviewFilePattern: string[];\n};\n\n/**\n * the component documentation extension.\n */\nexport class CompositionsMain {\n constructor(\n /**\n * Glob pattern to select all composition files\n */\n private compositionFilePattern: string[],\n\n /**\n * Glob pattern to select composition preview files\n */\n private previewFilePattern: string[],\n\n /**\n * envs extension.\n */\n private preview: PreviewMain,\n\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * schema extension.\n */\n private schema: SchemaMain,\n\n private devFiles: DevFilesMain,\n\n private envs: EnvsMain\n ) {}\n\n /**\n * returns an array of doc file paths for a set of components.\n */\n getPreviewFiles(components: Component[]): ComponentMap<AbstractVinyl[]> {\n return ComponentMap.as<AbstractVinyl[]>(components, (component) => {\n // this includes non executables, like `button.compositions.module.scss` or `presets.compositions.json`\n const compositionFiles = component.state.filesystem.byGlob(this.compositionFilePattern);\n\n // select only relevant preview files (.tsx, etc)\n const previewFiles = new Set(\n component.state.filesystem.byGlob(this.previewFilePattern).map((file) => file.relative)\n );\n const files = compositionFiles.filter((file) => previewFiles.has(file.relative));\n\n return files;\n });\n }\n\n /**\n * checks if a file matches the composition file pattern.\n */\n isCompositionFile(filePath: string): boolean {\n const { includePatterns, excludePatterns } = splitPatterns(this.compositionFilePattern);\n return matchPatterns(filePath, includePatterns, excludePatterns);\n }\n\n /**\n * get component compositions.\n */\n getCompositions(component: IComponent): Composition[] {\n const entry = component.get(CompositionsAspect.id);\n if (!entry) return [];\n const compositions = entry.data.compositions;\n if (!compositions) return [];\n\n return Composition.fromArray(compositions);\n }\n\n /**\n * read composition from the component source code.\n */\n readCompositions(component: Component): Composition[] {\n const maybeFiles = this.getPreviewFiles([component]).byComponent(component);\n\n if (!maybeFiles) return [];\n const [, files] = maybeFiles;\n return files.map((file) => this.computeCompositions(component, file)).flat();\n }\n\n getCompositionFilePattern() {\n return this.compositionFilePattern;\n }\n\n getComponentDevPatterns(component: Component) {\n const env = this.envs.calculateEnv(component, { skipWarnings: !!this.workspace?.inInstallContext }).env;\n const componentEnvCompositionsDevPatterns: string[] = env.getCompositionsDevPatterns\n ? env.getCompositionsDevPatterns(component)\n : [];\n const componentPatterns = componentEnvCompositionsDevPatterns.concat(this.getCompositionFilePattern());\n return { name: 'compositions', pattern: componentPatterns };\n }\n\n getDevPatternToRegister() {\n return this.getComponentDevPatterns.bind(this);\n }\n\n async onComponentLoad(component: Component, loadOpts?: ComponentLoadOptions): Promise<AspectData | undefined> {\n if (loadOpts?.loadCompositions === false) return undefined;\n const compositions = this.readCompositions(component);\n return {\n compositions: compositions.map((composition) => composition.toObject()),\n };\n }\n\n private computeCompositions(component: Component, file: AbstractVinyl): Composition[] {\n // :TODO hacked for a specific file extension now until david will take care in the compiler.\n const pathArray = file.path.split('.');\n pathArray[pathArray.length - 1] = 'js';\n\n const modulePath = this.workspace ? join(this.workspace.componentDir(component.id), file.relative) : file.relative;\n const exports = this.schema.parseModule(modulePath, file.contents.toString());\n return exports.map((exportModel) => {\n const displayName = exportModel.staticProperties?.get('compositionName');\n\n return new Composition(\n exportModel.identifier,\n file.relative,\n typeof displayName === 'string' ? displayName : undefined\n );\n });\n }\n\n static defaultConfig: CompositionsConfig = {\n compositionFilePattern: ['**/*.composition?(s).*'],\n compositionPreviewFilePattern: ['**/*.{t,j}s?(x)'],\n };\n\n static runtime = MainRuntime;\n static dependencies = [\n PreviewAspect,\n GraphqlAspect,\n WorkspaceAspect,\n SchemaAspect,\n DevFilesAspect,\n EnvsAspect,\n ScopeAspect,\n ];\n\n static async provider(\n [preview, graphql, workspace, schema, devFiles, envs, scope]: [\n PreviewMain,\n GraphqlMain,\n Workspace,\n SchemaMain,\n DevFilesMain,\n EnvsMain,\n ScopeMain\n ],\n config: CompositionsConfig\n ) {\n const compositions = new CompositionsMain(\n config.compositionFilePattern,\n config.compositionPreviewFilePattern,\n preview,\n workspace,\n schema,\n devFiles,\n envs\n );\n\n // TODO: use the docs implementation to allow component specific pattern\n devFiles.registerDevPattern(compositions.getDevPatternToRegister());\n\n graphql.register(compositionsSchema(compositions));\n preview.registerDefinition(new CompositionPreviewDefinition(compositions));\n\n if (workspace) {\n workspace.registerOnComponentLoad(compositions.onComponentLoad.bind(compositions));\n }\n if (scope) {\n scope.registerOnCompAspectReCalc(compositions.onComponentLoad.bind(compositions));\n }\n\n return compositions;\n }\n}\n\nCompositionsAspect.addRuntime(CompositionsMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,S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DkF,6BAA6B,EAAE,CAAC,iBAAiB;AACnD,CAAC;AAAAxG,eAAA,CA/HUoB,gBAAgB,aAiIV4F,kBAAW;AAAAhH,eAAA,CAjIjBoB,gBAAgB,kBAkIL,CACpB6F,wBAAa,EACbC,wBAAa,EACbC,4BAAe,EACfC,sBAAY,EACZC,0BAAc,EACdC,eAAU,EACVC,gBAAW,CACZ;AAyCHhE,kCAAkB,CAACiE,UAAU,CAACpG,gBAAgB,CAAC"}
|
|
@@ -56,7 +56,7 @@ class CompositionsPreview {
|
|
|
56
56
|
return combined;
|
|
57
57
|
}
|
|
58
58
|
getMetadata(componentFullName, previewModule) {
|
|
59
|
-
const metadata = previewModule
|
|
59
|
+
const metadata = previewModule?.componentMapMetadata ? previewModule.componentMapMetadata[componentFullName] : undefined;
|
|
60
60
|
if (metadata) {
|
|
61
61
|
return metadata;
|
|
62
62
|
}
|
|
@@ -71,7 +71,7 @@ class CompositionsPreview {
|
|
|
71
71
|
}
|
|
72
72
|
if (metadata && metadata.compositions) {
|
|
73
73
|
const first = (0, _lodash().default)(metadata.compositions);
|
|
74
|
-
const firstId = first
|
|
74
|
+
const firstId = first?.identifier;
|
|
75
75
|
if (firstId && module[firstId]) {
|
|
76
76
|
return module[firstId];
|
|
77
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_preview","data","require","_lodash","_interopRequireDefault","_compositions","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","CompositionsPreview","constructor","preview","render","componentId","envId","modules","otherPreviewDefs","context","componentMap","fullName","compositions","selectPreviewModel","metadata","getMetadata","active","getActiveComposition","mainModule","modulesMap","defaultExports","componentFullName","previewModule","files","combined","assign","componentMapMetadata","undefined","module","firstQueryParam","window","location","hash","split","query","getQuery","compositionId","getParam","first","head","firstId","identifier","values","provider","compPreview","registerPreview","name","bind","exports","PreviewRuntime","PreviewAspect","CompositionsAspect","addRuntime"],"sources":["compositions.preview.runtime.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport {\n PreviewAspect,\n PreviewPreview,\n RenderingContext,\n PreviewRuntime,\n PreviewModule,\n ModuleFile,\n} from '@teambit/preview';\nimport head from 'lodash.head';\nimport { CompositionBrowserMetadataObject } from './composition';\n\nimport { CompositionsAspect } from './compositions.aspect';\n\nexport class CompositionsPreview {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewPreview\n ) {}\n\n render(componentId: ComponentID, envId: string, modules: PreviewModule, otherPreviewDefs, context: RenderingContext) {\n if (!modules.componentMap[componentId.fullName]) return;\n\n const compositions = this.selectPreviewModel(componentId.fullName, modules);\n const metadata = this.getMetadata(componentId.fullName, modules);\n const active = this.getActiveComposition(compositions, metadata);\n\n const mainModule = modules.modulesMap[envId] || modules.modulesMap.default;\n const defaultExports = mainModule.default;\n\n defaultExports(active, context);\n }\n\n /** gets relevant information for this preview to render */\n selectPreviewModel(componentFullName: string, previewModule: PreviewModule) {\n const files = previewModule.componentMap[componentFullName] || [];\n\n // allow compositions to come from many files. It is assumed they will have unique named\n const combined = Object.assign({}, ...files);\n return combined;\n }\n\n getMetadata(componentFullName: string, previewModule: PreviewModule): CompositionBrowserMetadataObject | undefined {\n const metadata = previewModule?.componentMapMetadata\n ? previewModule.componentMapMetadata[componentFullName]\n : undefined;\n if (metadata) {\n return metadata as CompositionBrowserMetadataObject;\n }\n return undefined;\n }\n\n private getActiveComposition(module: ModuleFile, metadata?: CompositionBrowserMetadataObject) {\n const firstQueryParam = window.location.hash.split('&')[1];\n const query = this.preview.getQuery();\n const compositionId = this.preview.getParam(query, 'name') || firstQueryParam;\n\n if (compositionId && module[compositionId]) {\n return module[compositionId];\n }\n\n if (metadata && metadata.compositions) {\n const first = head(metadata.compositions);\n const firstId = first?.identifier;\n if (firstId && module[firstId]) {\n return module[firstId];\n }\n }\n\n const first = head(Object.values(module));\n return first;\n }\n\n static runtime = PreviewRuntime;\n\n static dependencies = [PreviewAspect];\n\n static async provider([preview]: [PreviewPreview]) {\n const compPreview = new CompositionsPreview(preview);\n preview.registerPreview({\n name: 'compositions',\n render: compPreview.render.bind(compPreview),\n selectPreviewModel: compPreview.selectPreviewModel.bind(compPreview),\n default: true,\n });\n\n return compPreview;\n }\n}\n\nCompositionsAspect.addRuntime(CompositionsPreview);\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2D,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,C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E,GAAGF,KAAK,CAAC;IAC5C,OAAOC,QAAQ;EACjB;EAEAT,WAAWA,CAACM,iBAAyB,EAAEC,aAA4B,EAAgD;IACjH,MAAMR,QAAQ,GAAGQ,aAAa,
|
|
1
|
+
{"version":3,"names":["_preview","data","require","_lodash","_interopRequireDefault","_compositions","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","CompositionsPreview","constructor","preview","render","componentId","envId","modules","otherPreviewDefs","context","componentMap","fullName","compositions","selectPreviewModel","metadata","getMetadata","active","getActiveComposition","mainModule","modulesMap","defaultExports","componentFullName","previewModule","files","combined","assign","componentMapMetadata","undefined","module","firstQueryParam","window","location","hash","split","query","getQuery","compositionId","getParam","first","head","firstId","identifier","values","provider","compPreview","registerPreview","name","bind","exports","PreviewRuntime","PreviewAspect","CompositionsAspect","addRuntime"],"sources":["compositions.preview.runtime.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport {\n PreviewAspect,\n PreviewPreview,\n RenderingContext,\n PreviewRuntime,\n PreviewModule,\n ModuleFile,\n} from '@teambit/preview';\nimport head from 'lodash.head';\nimport { CompositionBrowserMetadataObject } from './composition';\n\nimport { CompositionsAspect } from './compositions.aspect';\n\nexport class CompositionsPreview {\n constructor(\n /**\n * preview extension.\n */\n private preview: PreviewPreview\n ) {}\n\n render(componentId: ComponentID, envId: string, modules: PreviewModule, otherPreviewDefs, context: RenderingContext) {\n if (!modules.componentMap[componentId.fullName]) return;\n\n const compositions = this.selectPreviewModel(componentId.fullName, modules);\n const metadata = this.getMetadata(componentId.fullName, modules);\n const active = this.getActiveComposition(compositions, metadata);\n\n const mainModule = modules.modulesMap[envId] || modules.modulesMap.default;\n const defaultExports = mainModule.default;\n\n defaultExports(active, context);\n }\n\n /** gets relevant information for this preview to render */\n selectPreviewModel(componentFullName: string, previewModule: PreviewModule) {\n const files = previewModule.componentMap[componentFullName] || [];\n\n // allow compositions to come from many files. It is assumed they will have unique named\n const combined = Object.assign({}, ...files);\n return combined;\n }\n\n getMetadata(componentFullName: string, previewModule: PreviewModule): CompositionBrowserMetadataObject | undefined {\n const metadata = previewModule?.componentMapMetadata\n ? previewModule.componentMapMetadata[componentFullName]\n : undefined;\n if (metadata) {\n return metadata as CompositionBrowserMetadataObject;\n }\n return undefined;\n }\n\n private getActiveComposition(module: ModuleFile, metadata?: CompositionBrowserMetadataObject) {\n const firstQueryParam = window.location.hash.split('&')[1];\n const query = this.preview.getQuery();\n const compositionId = this.preview.getParam(query, 'name') || firstQueryParam;\n\n if (compositionId && module[compositionId]) {\n return module[compositionId];\n }\n\n if (metadata && metadata.compositions) {\n const first = head(metadata.compositions);\n const firstId = first?.identifier;\n if (firstId && module[firstId]) {\n return module[firstId];\n }\n }\n\n const first = head(Object.values(module));\n return first;\n }\n\n static runtime = PreviewRuntime;\n\n static dependencies = [PreviewAspect];\n\n static async provider([preview]: [PreviewPreview]) {\n const compPreview = new CompositionsPreview(preview);\n preview.registerPreview({\n name: 'compositions',\n render: compPreview.render.bind(compPreview),\n selectPreviewModel: compPreview.selectPreviewModel.bind(compPreview),\n default: true,\n });\n\n return compPreview;\n }\n}\n\nCompositionsAspect.addRuntime(CompositionsPreview);\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2D,SAAAG,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C,EAAE;MAC1C,OAAOR,MAAM,CAACQ,aAAa,CAAC;IAC9B;IAEA,IAAItB,QAAQ,IAAIA,QAAQ,CAACF,YAAY,EAAE;MACrC,MAAM0B,KAAK,GAAG,IAAAC,iBAAI,EAACzB,QAAQ,CAACF,YAAY,CAAC;MACzC,MAAM4B,OAAO,GAAGF,KAAK,EAAEG,UAAU;MACjC,IAAID,OAAO,IAAIZ,MAAM,CAACY,OAAO,CAAC,EAAE;QAC9B,OAAOZ,MAAM,CAACY,OAAO,CAAC;MACxB;IACF;IAEA,MAAMF,KAAK,GAAG,IAAAC,iBAAI,EAACtD,MAAM,CAACyD,MAAM,CAACd,MAAM,CAAC,CAAC;IACzC,OAAOU,KAAK;EACd;EAMA,aAAaK,QAAQA,CAAC,CAACxC,OAAO,CAAmB,EAAE;IACjD,MAAMyC,WAAW,GAAG,IAAI3C,mBAAmB,CAACE,OAAO,CAAC;IACpDA,OAAO,CAAC0C,eAAe,CAAC;MACtBC,IAAI,EAAE,cAAc;MACpB1C,MAAM,EAAEwC,WAAW,CAACxC,MAAM,CAAC2C,IAAI,CAACH,WAAW,CAAC;MAC5C/B,kBAAkB,EAAE+B,WAAW,CAAC/B,kBAAkB,CAACkC,IAAI,CAACH,WAAW,CAAC;MACpEhE,OAAO,EAAE;IACX,CAAC,CAAC;IAEF,OAAOgE,WAAW;EACpB;AACF;AAACI,OAAA,CAAA/C,mBAAA,GAAAA,mBAAA;AAAApB,eAAA,CA5EYoB,mBAAmB,aA6DbgD,yBAAc;AAAApE,eAAA,CA7DpBoB,mBAAmB,kBA+DR,CAACiD,wBAAa,CAAC;AAevCC,kCAAkB,CAACC,UAAU,CAACnD,mBAAmB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
3
|
import { SlotRegistry } from '@teambit/harmony';
|
|
4
4
|
import { ComponentUI } from '@teambit/component';
|
|
5
5
|
import { ComponentCompareUI } from '@teambit/component-compare';
|
|
6
6
|
import { MenuBarWidget } from './compositions';
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type CompositionsMenuSlot = SlotRegistry<MenuBarWidget[]>;
|
|
8
|
+
export type EmptyStateSlot = SlotRegistry<ComponentType>;
|
|
9
9
|
export declare class CompositionsUI {
|
|
10
10
|
private menuBarWidgetSlot;
|
|
11
11
|
private emptyStateSlot;
|
|
@@ -15,7 +15,7 @@ export declare class CompositionsUI {
|
|
|
15
15
|
*/
|
|
16
16
|
registerEmptyState(emptyStateComponent: ComponentType): this;
|
|
17
17
|
registerMenuWidget(...widget: MenuBarWidget[]): void;
|
|
18
|
-
getCompositionsCompare: () =>
|
|
18
|
+
getCompositionsCompare: () => JSX.Element;
|
|
19
19
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
20
20
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
21
21
|
static slots: ((registerFn: () => string) => SlotRegistry<ReactNode>)[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compositions_compositions@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compositions_compositions@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compositions_compositions@1.0.109/dist/compositions.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compositions_compositions@1.0.109/dist/compositions.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ComponentPreviewProps } from '@teambit/preview.ui.component-preview';
|
|
3
3
|
import { Composition } from '../composition';
|
|
4
|
-
export
|
|
4
|
+
export type ComponentCompositionProps = {
|
|
5
5
|
/**
|
|
6
6
|
* composition to use for component rendering.
|
|
7
7
|
*/
|
|
8
8
|
composition?: Composition;
|
|
9
9
|
} & ComponentPreviewProps;
|
|
10
|
-
export declare function ComponentComposition({ composition, component, queryParams, ...rest }: ComponentCompositionProps):
|
|
10
|
+
export declare function ComponentComposition({ composition, component, queryParams, ...rest }: ComponentCompositionProps): JSX.Element;
|
|
@@ -25,17 +25,16 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
25
25
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
26
26
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
27
27
|
function ComponentComposition(_ref) {
|
|
28
|
-
var _component$preview, _component$preview2;
|
|
29
28
|
let {
|
|
30
29
|
composition,
|
|
31
30
|
component,
|
|
32
31
|
queryParams = []
|
|
33
32
|
} = _ref,
|
|
34
33
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
35
|
-
const includesEnvTemplate =
|
|
36
|
-
const isScaling =
|
|
34
|
+
const includesEnvTemplate = component.preview?.includesEnvTemplate;
|
|
35
|
+
const isScaling = component.preview?.isScaling;
|
|
37
36
|
const shouldAddNameParam = isScaling && includesEnvTemplate === false;
|
|
38
|
-
const compositionParams = (0, _react().useMemo)(() => (composition ? [shouldAddNameParam ? `name=${composition.identifier}` : composition.identifier] : []).concat(queryParams), [composition
|
|
37
|
+
const compositionParams = (0, _react().useMemo)(() => (composition ? [shouldAddNameParam ? `name=${composition.identifier}` : composition.identifier] : []).concat(queryParams), [composition?.identifier, queryParams]);
|
|
39
38
|
return /*#__PURE__*/_react().default.createElement(_previewUi().ComponentPreview, _extends({}, rest, {
|
|
40
39
|
component: component,
|
|
41
40
|
style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_previewUi","_excluded","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","ComponentComposition","_ref","
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_previewUi","_excluded","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","ComponentComposition","_ref","composition","component","queryParams","rest","includesEnvTemplate","preview","isScaling","shouldAddNameParam","compositionParams","useMemo","identifier","concat","createElement","ComponentPreview","style","width","height","previewName"],"sources":["composition-preview.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { ComponentPreview, ComponentPreviewProps } from '@teambit/preview.ui.component-preview';\n\nimport { Composition } from '../composition';\n\nexport type ComponentCompositionProps = {\n /**\n * composition to use for component rendering.\n */\n composition?: Composition;\n} & ComponentPreviewProps;\n\nexport function ComponentComposition({ composition, component, queryParams = [], ...rest }: ComponentCompositionProps) {\n const includesEnvTemplate = component.preview?.includesEnvTemplate;\n const isScaling = component.preview?.isScaling;\n const shouldAddNameParam = isScaling && includesEnvTemplate === false;\n\n const compositionParams = useMemo(\n () =>\n (composition ? [shouldAddNameParam ? `name=${composition.identifier}` : composition.identifier] : []).concat(\n queryParams\n ),\n [composition?.identifier, queryParams]\n );\n\n return (\n <ComponentPreview\n {...rest}\n component={component}\n style={{ width: '100%', height: '100%' }}\n previewName=\"compositions\"\n queryParams={compositionParams}\n />\n );\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgG,MAAAI,SAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAA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,WACF,CAAC,EACH,CAACF,WAAW,EAAEU,UAAU,EAAER,WAAW,CACvC,CAAC;EAED,oBACEjD,MAAA,GAAAY,OAAA,CAAA+C,aAAA,CAACvD,UAAA,GAAAwD,gBAAgB,EAAAjC,QAAA,KACXuB,IAAI;IACRF,SAAS,EAAEA,SAAU;IACrBa,KAAK,EAAE;MAAEC,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE;IAAO,CAAE;IACzCC,WAAW,EAAC,cAAc;IAC1Bf,WAAW,EAAEM;EAAkB,EAChC,CAAC;AAEN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Composition } from '../../composition';
|
|
3
|
-
export
|
|
3
|
+
export type CompositionsPanelProps = {
|
|
4
4
|
/**
|
|
5
5
|
* list of compositions
|
|
6
6
|
*/
|
|
@@ -23,4 +23,4 @@ export declare type CompositionsPanelProps = {
|
|
|
23
23
|
isScaling?: boolean;
|
|
24
24
|
includesEnvTemplate?: boolean;
|
|
25
25
|
} & React.HTMLAttributes<HTMLUListElement>;
|
|
26
|
-
export declare function CompositionsPanel({ url, compositions, isScaling, onSelectComposition: onSelect, active, includesEnvTemplate, className, ...rest }: CompositionsPanelProps):
|
|
26
|
+
export declare function CompositionsPanel({ url, compositions, isScaling, onSelectComposition: onSelect, active, includesEnvTemplate, className, ...rest }: CompositionsPanelProps): JSX.Element;
|
|
@@ -72,9 +72,9 @@ function CompositionsPanel(_ref) {
|
|
|
72
72
|
const navigate = (0, _baseReactNavigation().useNavigate)();
|
|
73
73
|
const onCompositionCodeClicked = (0, _react().useCallback)(composition => e => {
|
|
74
74
|
e.preventDefault();
|
|
75
|
-
const basePath = location
|
|
75
|
+
const basePath = location?.pathname.split('/~compositions')[0];
|
|
76
76
|
navigate(`${basePath}/~code/${composition.filepath}#search=${composition.identifier}`);
|
|
77
|
-
}, [location
|
|
77
|
+
}, [location?.pathname]);
|
|
78
78
|
return /*#__PURE__*/_react().default.createElement("ul", _extends({}, rest, {
|
|
79
79
|
className: (0, _classnames().default)(className)
|
|
80
80
|
}), compositions.map(composition => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_evangelistElements","data","require","_classnames","_interopRequireDefault","_react","_interopRequireWildcard","_uiFoundationUi","_baseReactNavigation","_compositionsPanelModule","_excluded","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","CompositionsPanel","_ref","url","compositions","isScaling","onSelectComposition","onSelect","active","includesEnvTemplate","className","rest","shouldAddNameParam","handleSelect","useCallback","selected","location","useLocation","navigate","useNavigate","onCompositionCodeClicked","composition","preventDefault","basePath","pathname","split","filepath","identifier","createElement","classNames","map","href","styles","linkWrapper","panelLink","onClick","box","name","displayName","right","MenuWidgetIcon","codeLink","icon","tooltipContent","rel","Icon","of"],"sources":["compositions-panel.tsx"],"sourcesContent":["import { Icon } from '@teambit/evangelist.elements.icon';\nimport classNames from 'classnames';\nimport React, { useCallback } from 'react';\nimport { MenuWidgetIcon } from '@teambit/ui-foundation.ui.menu-widget-icon';\nimport { useNavigate, useLocation } from '@teambit/base-react.navigation.link';\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\n includesEnvTemplate?: boolean;\n} & React.HTMLAttributes<HTMLUListElement>;\n\nexport function CompositionsPanel({\n url,\n compositions,\n isScaling,\n onSelectComposition: onSelect,\n active,\n includesEnvTemplate,\n className,\n ...rest\n}: CompositionsPanelProps) {\n const shouldAddNameParam = isScaling && includesEnvTemplate === false;\n\n const handleSelect = useCallback(\n (selected: Composition) => {\n onSelect && onSelect(selected);\n },\n [onSelect]\n );\n\n const location = useLocation();\n const navigate = useNavigate();\n\n const onCompositionCodeClicked = useCallback(\n (composition: Composition) => (e: React.MouseEvent<HTMLDivElement>) => {\n e.preventDefault();\n const basePath = location?.pathname.split('/~compositions')[0];\n navigate(`${basePath}/~code/${composition.filepath}#search=${composition.identifier}`);\n },\n [location?.pathname]\n );\n\n return (\n <ul {...rest} className={classNames(className)}>\n {compositions.map((composition) => {\n const href = shouldAddNameParam ? `${url}&name=${composition.identifier}` : `${url}&${composition.identifier}`;\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 <MenuWidgetIcon\n className={styles.codeLink}\n icon=\"Code\"\n tooltipContent=\"Code\"\n onClick={onCompositionCodeClicked(composition)}\n />\n <a className={styles.panelLink} target=\"_blank\" rel=\"noopener noreferrer\" href={href}>\n <Icon className={styles.icon} of=\"open-tab\" />\n </a>\n </div>\n </li>\n );\n })}\n </ul>\n );\n}\n"],"mappings":";;;;;;AAAA,SAAAA,oBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,mBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAK,uBAAA,CAAAJ,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K;IACrEA,CAAC,CAAC4D,cAAc,CAAC,CAAC;IAClB,MAAMC,QAAQ,GAAGP,QAAQ,
|
|
1
|
+
{"version":3,"names":["_evangelistElements","data","require","_classnames","_interopRequireDefault","_react","_interopRequireWildcard","_uiFoundationUi","_baseReactNavigation","_compositionsPanelModule","_excluded","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","CompositionsPanel","_ref","url","compositions","isScaling","onSelectComposition","onSelect","active","includesEnvTemplate","className","rest","shouldAddNameParam","handleSelect","useCallback","selected","location","useLocation","navigate","useNavigate","onCompositionCodeClicked","composition","preventDefault","basePath","pathname","split","filepath","identifier","createElement","classNames","map","href","styles","linkWrapper","panelLink","onClick","box","name","displayName","right","MenuWidgetIcon","codeLink","icon","tooltipContent","rel","Icon","of"],"sources":["compositions-panel.tsx"],"sourcesContent":["import { Icon } from '@teambit/evangelist.elements.icon';\nimport classNames from 'classnames';\nimport React, { useCallback } from 'react';\nimport { MenuWidgetIcon } from '@teambit/ui-foundation.ui.menu-widget-icon';\nimport { useNavigate, useLocation } from '@teambit/base-react.navigation.link';\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\n includesEnvTemplate?: boolean;\n} & React.HTMLAttributes<HTMLUListElement>;\n\nexport function CompositionsPanel({\n url,\n compositions,\n isScaling,\n onSelectComposition: onSelect,\n active,\n includesEnvTemplate,\n className,\n ...rest\n}: CompositionsPanelProps) {\n const shouldAddNameParam = isScaling && includesEnvTemplate === false;\n\n const handleSelect = useCallback(\n (selected: Composition) => {\n onSelect && onSelect(selected);\n },\n [onSelect]\n );\n\n const location = useLocation();\n const navigate = useNavigate();\n\n const onCompositionCodeClicked = useCallback(\n (composition: Composition) => (e: React.MouseEvent<HTMLDivElement>) => {\n e.preventDefault();\n const basePath = location?.pathname.split('/~compositions')[0];\n navigate(`${basePath}/~code/${composition.filepath}#search=${composition.identifier}`);\n },\n [location?.pathname]\n );\n\n return (\n <ul {...rest} className={classNames(className)}>\n {compositions.map((composition) => {\n const href = shouldAddNameParam ? `${url}&name=${composition.identifier}` : `${url}&${composition.identifier}`;\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 <MenuWidgetIcon\n className={styles.codeLink}\n icon=\"Code\"\n tooltipContent=\"Code\"\n onClick={onCompositionCodeClicked(composition)}\n />\n <a className={styles.panelLink} target=\"_blank\" rel=\"noopener noreferrer\" href={href}>\n <Icon className={styles.icon} of=\"open-tab\" />\n </a>\n </div>\n </li>\n );\n })}\n </ul>\n );\n}\n"],"mappings":";;;;;;AAAA,SAAAA,oBAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,mBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAK,uBAAA,CAAAJ,OAAA;EAAAG,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S,EAAEsB,kCAAM,CAACO;IAAM,gBAC3BpF,MAAA,GAAAY,OAAA,CAAA6D,aAAA,CAACvE,eAAA,GAAAmF,cAAc;MACb9B,SAAS,EAAEsB,kCAAM,CAACS,QAAS;MAC3BC,IAAI,EAAC,MAAM;MACXC,cAAc,EAAC,MAAM;MACrBR,OAAO,EAAEf,wBAAwB,CAACC,WAAW;IAAE,CAChD,CAAC,eACFlE,MAAA,GAAAY,OAAA,CAAA6D,aAAA;MAAGlB,SAAS,EAAEsB,kCAAM,CAACE,SAAU;MAAChD,MAAM,EAAC,QAAQ;MAAC0D,GAAG,EAAC,qBAAqB;MAACb,IAAI,EAAEA;IAAK,gBACnF5E,MAAA,GAAAY,OAAA,CAAA6D,aAAA,CAAC9E,mBAAA,GAAA+F,IAAI;MAACnC,SAAS,EAAEsB,kCAAM,CAACU,IAAK;MAACI,EAAE,EAAC;IAAU,CAAE,CAC5C,CACA,CACH,CAAC;EAET,CAAC,CACC,CAAC;AAET"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type CompositionsPanelNodeProps = {
|
|
3
3
|
name: string;
|
|
4
4
|
onClick: (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
5
5
|
isActive: boolean;
|
|
6
6
|
} & React.HTMLAttributes<HTMLLIElement>;
|
|
7
|
-
export declare function CompositionsPanelNode({ name, onClick, isActive, ...rest }: CompositionsPanelNodeProps):
|
|
7
|
+
export declare function CompositionsPanelNode({ name, onClick, isActive, ...rest }: CompositionsPanelNodeProps): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/compositions",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.109",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/compositions/compositions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.compositions",
|
|
8
8
|
"name": "compositions",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.109"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"graphql-tag": "2.12.1",
|
|
@@ -14,11 +14,8 @@
|
|
|
14
14
|
"lodash.head": "4.0.1",
|
|
15
15
|
"query-string": "7.0.0",
|
|
16
16
|
"classnames": "2.2.6",
|
|
17
|
-
"core-js": "^3.0.0",
|
|
18
|
-
"@babel/runtime": "7.20.0",
|
|
19
17
|
"@teambit/harmony": "0.4.6",
|
|
20
18
|
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.504",
|
|
21
|
-
"@teambit/component-id": "1.2.0",
|
|
22
19
|
"@teambit/base-react.navigation.link": "2.0.27",
|
|
23
20
|
"@teambit/base-ui.surfaces.split-pane.hover-splitter": "1.0.0",
|
|
24
21
|
"@teambit/base-ui.surfaces.split-pane.split-pane": "1.0.0",
|
|
@@ -39,40 +36,39 @@
|
|
|
39
36
|
"@teambit/compositions.ui.composition-compare": "0.0.255",
|
|
40
37
|
"@teambit/evangelist.elements.icon": "1.0.2",
|
|
41
38
|
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.502",
|
|
42
|
-
"@teambit/component": "1.0.
|
|
39
|
+
"@teambit/component": "1.0.109",
|
|
43
40
|
"@teambit/compositions.model.composition-id": "0.0.500",
|
|
44
|
-
"@teambit/graphql": "1.0.
|
|
45
|
-
"@teambit/cli": "0.0.
|
|
46
|
-
"@teambit/dev-files": "1.0.
|
|
47
|
-
"@teambit/envs": "1.0.
|
|
48
|
-
"@teambit/preview": "1.0.
|
|
49
|
-
"@teambit/schema": "1.0.
|
|
50
|
-
"@teambit/scope": "1.0.
|
|
41
|
+
"@teambit/graphql": "1.0.109",
|
|
42
|
+
"@teambit/cli": "0.0.841",
|
|
43
|
+
"@teambit/dev-files": "1.0.109",
|
|
44
|
+
"@teambit/envs": "1.0.109",
|
|
45
|
+
"@teambit/preview": "1.0.109",
|
|
46
|
+
"@teambit/schema": "1.0.109",
|
|
47
|
+
"@teambit/scope": "1.0.109",
|
|
51
48
|
"@teambit/toolbox.path.match-patterns": "0.0.13",
|
|
52
|
-
"@teambit/workspace": "1.0.
|
|
49
|
+
"@teambit/workspace": "1.0.109",
|
|
53
50
|
"@teambit/docs.ui.queries.get-docs": "0.0.506",
|
|
54
|
-
"@teambit/panels": "0.0.
|
|
51
|
+
"@teambit/panels": "0.0.842",
|
|
55
52
|
"@teambit/preview.ui.component-preview": "1.0.3",
|
|
56
|
-
"@teambit/component-compare": "1.0.
|
|
57
|
-
"@teambit/ui": "1.0.
|
|
53
|
+
"@teambit/component-compare": "1.0.109",
|
|
54
|
+
"@teambit/ui": "1.0.109"
|
|
58
55
|
},
|
|
59
56
|
"devDependencies": {
|
|
60
|
-
"@types/react": "^17.0.8",
|
|
61
57
|
"@types/lodash": "4.14.165",
|
|
62
58
|
"@types/lodash.head": "4.0.6",
|
|
63
59
|
"@types/classnames": "2.2.11",
|
|
64
60
|
"@types/mocha": "9.1.0",
|
|
65
|
-
"@types/
|
|
66
|
-
"@types/
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
61
|
+
"@types/jest": "^29.2.2",
|
|
62
|
+
"@types/testing-library__jest-dom": "^5.9.5",
|
|
63
|
+
"@teambit/component-id": "1.2.0",
|
|
64
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.14",
|
|
69
65
|
"@teambit/compositions.aspect-docs.compositions": "0.0.165"
|
|
70
66
|
},
|
|
71
67
|
"peerDependencies": {
|
|
72
|
-
"react
|
|
73
|
-
"
|
|
74
|
-
"react": "^
|
|
75
|
-
"
|
|
68
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
69
|
+
"react-router-dom": "^6.8.1",
|
|
70
|
+
"@types/react": "^18.2.12",
|
|
71
|
+
"@teambit/legacy": "1.0.624"
|
|
76
72
|
},
|
|
77
73
|
"license": "Apache-2.0",
|
|
78
74
|
"optionalDependencies": {},
|
|
@@ -86,7 +82,7 @@
|
|
|
86
82
|
},
|
|
87
83
|
"private": false,
|
|
88
84
|
"engines": {
|
|
89
|
-
"node": ">=
|
|
85
|
+
"node": ">=16.0.0"
|
|
90
86
|
},
|
|
91
87
|
"repository": {
|
|
92
88
|
"type": "git",
|
|
@@ -95,12 +91,9 @@
|
|
|
95
91
|
"keywords": [
|
|
96
92
|
"bit",
|
|
97
93
|
"bit-aspect",
|
|
94
|
+
"bit-core-aspect",
|
|
98
95
|
"components",
|
|
99
96
|
"collaboration",
|
|
100
|
-
"web"
|
|
101
|
-
"react",
|
|
102
|
-
"react-components",
|
|
103
|
-
"angular",
|
|
104
|
-
"angular-components"
|
|
97
|
+
"web"
|
|
105
98
|
]
|
|
106
99
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,38 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"lib": [
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"DOM.Iterable",
|
|
8
|
-
"ScriptHost"
|
|
4
|
+
"esnext",
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.Iterable"
|
|
9
7
|
],
|
|
10
|
-
"target": "
|
|
11
|
-
"module": "
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"allowJs": true,
|
|
14
|
-
"composite": true,
|
|
8
|
+
"target": "es2020",
|
|
9
|
+
"module": "es2020",
|
|
10
|
+
"jsx": "react-jsx",
|
|
15
11
|
"declaration": true,
|
|
16
12
|
"sourceMap": true,
|
|
17
|
-
"skipLibCheck": true,
|
|
18
13
|
"experimentalDecorators": true,
|
|
19
|
-
"
|
|
14
|
+
"skipLibCheck": true,
|
|
20
15
|
"moduleResolution": "node",
|
|
21
16
|
"esModuleInterop": true,
|
|
22
|
-
"rootDir": ".",
|
|
23
17
|
"resolveJsonModule": true,
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"strictPropertyInitialization": false,
|
|
28
|
-
"strict": true,
|
|
29
|
-
"noImplicitAny": false,
|
|
30
|
-
"preserveConstEnums": true
|
|
18
|
+
"allowJs": true,
|
|
19
|
+
"outDir": "dist",
|
|
20
|
+
"emitDeclarationOnly": true
|
|
31
21
|
},
|
|
32
22
|
"exclude": [
|
|
23
|
+
"artifacts",
|
|
24
|
+
"public",
|
|
33
25
|
"dist",
|
|
26
|
+
"node_modules",
|
|
27
|
+
"package.json",
|
|
34
28
|
"esm.mjs",
|
|
35
|
-
"
|
|
29
|
+
"**/*.cjs",
|
|
30
|
+
"./dist"
|
|
36
31
|
],
|
|
37
32
|
"include": [
|
|
38
33
|
"**/*",
|
package/types/asset.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ declare module '*.png' {
|
|
|
5
5
|
declare module '*.svg' {
|
|
6
6
|
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
7
|
|
|
8
|
-
export const ReactComponent: FunctionComponent<
|
|
8
|
+
export const ReactComponent: FunctionComponent<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
9
11
|
const src: string;
|
|
10
12
|
export default src;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
14
|
declare module '*.jpg' {
|
|
15
15
|
const value: any;
|
|
16
16
|
export = value;
|
|
@@ -27,3 +27,15 @@ declare module '*.bmp' {
|
|
|
27
27
|
const value: any;
|
|
28
28
|
export = value;
|
|
29
29
|
}
|
|
30
|
+
declare module '*.otf' {
|
|
31
|
+
const value: any;
|
|
32
|
+
export = value;
|
|
33
|
+
}
|
|
34
|
+
declare module '*.woff' {
|
|
35
|
+
const value: any;
|
|
36
|
+
export = value;
|
|
37
|
+
}
|
|
38
|
+
declare module '*.woff2' {
|
|
39
|
+
const value: any;
|
|
40
|
+
export = value;
|
|
41
|
+
}
|