@teambit/compositions 0.0.551 → 0.0.556
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/dist/composition.d.ts +22 -1
- package/dist/composition.section.d.ts +8 -1
- package/dist/compositions.main.runtime.d.ts +56 -1
- package/dist/compositions.preview.runtime.d.ts +9 -1
- package/dist/compositions.ui.runtime.d.ts +3 -0
- package/dist/ui/composition-preview.d.ts +15 -0
- package/package.json +32 -26
- package/composition.section.tsx +0 -29
- package/composition.ts +0 -44
- package/compositions.aspect.ts +0 -9
- package/compositions.docs.mdx +0 -8
- package/compositions.graphql.ts +0 -32
- package/compositions.main.runtime.ts +0 -164
- package/compositions.module.scss +0 -100
- package/compositions.preview-definition.ts +0 -21
- package/compositions.preview.runtime.ts +0 -67
- package/compositions.tsx +0 -185
- package/compositions.ui.runtime.tsx +0 -53
- package/index.ts +0 -10
- package/package-tar/teambit-compositions-0.0.551.tgz +0 -0
- package/tsconfig.json +0 -35
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/ui/composition-preview.tsx +0 -60
- package/ui/compositions-overview/compositions-overview.module.scss +0 -16
- package/ui/compositions-overview/compositions-overview.tsx +0 -21
- package/ui/compositions-overview/index.ts +0 -1
- package/ui/compositions-panel/compositions-panel.module.scss +0 -119
- package/ui/compositions-panel/compositions-panel.tsx +0 -58
- package/ui/compositions-panel/index.ts +0 -0
- package/ui/compositions-panel-node/compositions-panel-node.module.scss +0 -15
- package/ui/compositions-panel-node/compositions-panel-node.tsx +0 -22
- package/ui/compositions-panel-node/index.ts +0 -1
- package/ui/index.ts +0 -1
- package/ui/use-compositions.tsx +0 -14
package/dist/composition.d.ts
CHANGED
|
@@ -4,10 +4,31 @@ export declare type CompositionProps = {
|
|
|
4
4
|
displayName?: string;
|
|
5
5
|
};
|
|
6
6
|
export declare class Composition {
|
|
7
|
+
/**
|
|
8
|
+
* identifier of the composition
|
|
9
|
+
*/
|
|
7
10
|
readonly identifier: string;
|
|
11
|
+
/**
|
|
12
|
+
* file path in which the composition is contained.
|
|
13
|
+
*/
|
|
8
14
|
readonly filepath?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* set explicit display name
|
|
17
|
+
*/
|
|
9
18
|
private _displayName?;
|
|
10
|
-
constructor(
|
|
19
|
+
constructor(
|
|
20
|
+
/**
|
|
21
|
+
* identifier of the composition
|
|
22
|
+
*/
|
|
23
|
+
identifier: string,
|
|
24
|
+
/**
|
|
25
|
+
* file path in which the composition is contained.
|
|
26
|
+
*/
|
|
27
|
+
filepath?: string | undefined,
|
|
28
|
+
/**
|
|
29
|
+
* set explicit display name
|
|
30
|
+
*/
|
|
31
|
+
_displayName?: string | undefined);
|
|
11
32
|
get displayName(): string;
|
|
12
33
|
toObject(): {
|
|
13
34
|
identifier: string;
|
|
@@ -4,10 +4,17 @@ declare type Options = {
|
|
|
4
4
|
menuBarWidgetSlot: CompositionsMenuSlot;
|
|
5
5
|
};
|
|
6
6
|
export declare class CompositionsSection implements Section {
|
|
7
|
+
/**
|
|
8
|
+
* simulations ui extension.
|
|
9
|
+
*/
|
|
7
10
|
private compositions;
|
|
8
11
|
private options;
|
|
9
12
|
private emptyStateSlot;
|
|
10
|
-
constructor(
|
|
13
|
+
constructor(
|
|
14
|
+
/**
|
|
15
|
+
* simulations ui extension.
|
|
16
|
+
*/
|
|
17
|
+
compositions: CompositionsUI, options: Options, emptyStateSlot: EmptyStateSlot);
|
|
11
18
|
navigationLink: {
|
|
12
19
|
href: string;
|
|
13
20
|
children: string;
|
|
@@ -7,19 +7,74 @@ import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
|
|
|
7
7
|
import { DevFilesMain } from '@teambit/dev-files';
|
|
8
8
|
import { Composition } from './composition';
|
|
9
9
|
export declare type CompositionsConfig = {
|
|
10
|
+
/**
|
|
11
|
+
* glob pattern to detect composition files. This includes all related files, like styles and jsons.
|
|
12
|
+
* @example ['/*.composition?(s).*']
|
|
13
|
+
*/
|
|
10
14
|
compositionFilePattern: string[];
|
|
15
|
+
/**
|
|
16
|
+
* glob pattern to select Preview files. this will only include files matched by compositionFilePattern.
|
|
17
|
+
* @example ['*.{t,j}s', '*.{t,j}sx']
|
|
18
|
+
*/
|
|
11
19
|
compositionPreviewFilePattern: string[];
|
|
12
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* the component documentation extension.
|
|
23
|
+
*/
|
|
13
24
|
export declare class CompositionsMain {
|
|
25
|
+
/**
|
|
26
|
+
* Glob pattern to select all composition files
|
|
27
|
+
*/
|
|
14
28
|
private compositionFilePattern;
|
|
29
|
+
/**
|
|
30
|
+
* Glob pattern to select composition preview files
|
|
31
|
+
*/
|
|
15
32
|
private previewFilePattern;
|
|
33
|
+
/**
|
|
34
|
+
* envs extension.
|
|
35
|
+
*/
|
|
16
36
|
private preview;
|
|
37
|
+
/**
|
|
38
|
+
* workspace extension.
|
|
39
|
+
*/
|
|
17
40
|
private workspace;
|
|
41
|
+
/**
|
|
42
|
+
* schema extension.
|
|
43
|
+
*/
|
|
18
44
|
private schema;
|
|
19
45
|
private devFiles;
|
|
20
|
-
constructor(
|
|
46
|
+
constructor(
|
|
47
|
+
/**
|
|
48
|
+
* Glob pattern to select all composition files
|
|
49
|
+
*/
|
|
50
|
+
compositionFilePattern: string[],
|
|
51
|
+
/**
|
|
52
|
+
* Glob pattern to select composition preview files
|
|
53
|
+
*/
|
|
54
|
+
previewFilePattern: string[],
|
|
55
|
+
/**
|
|
56
|
+
* envs extension.
|
|
57
|
+
*/
|
|
58
|
+
preview: PreviewMain,
|
|
59
|
+
/**
|
|
60
|
+
* workspace extension.
|
|
61
|
+
*/
|
|
62
|
+
workspace: Workspace,
|
|
63
|
+
/**
|
|
64
|
+
* schema extension.
|
|
65
|
+
*/
|
|
66
|
+
schema: SchemaMain, devFiles: DevFilesMain);
|
|
67
|
+
/**
|
|
68
|
+
* returns an array of doc file paths for a set of components.
|
|
69
|
+
*/
|
|
21
70
|
getPreviewFiles(components: Component[]): ComponentMap<AbstractVinyl[]>;
|
|
71
|
+
/**
|
|
72
|
+
* get component compositions.
|
|
73
|
+
*/
|
|
22
74
|
getCompositions(component: Component): Composition[];
|
|
75
|
+
/**
|
|
76
|
+
* read composition from the component source code.
|
|
77
|
+
*/
|
|
23
78
|
readCompositions(component: Component): Composition[];
|
|
24
79
|
onComponentLoad(component: Component): Promise<AspectData>;
|
|
25
80
|
private computeCompositions;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { PreviewPreview, RenderingContext, PreviewModule } from '@teambit/preview';
|
|
2
2
|
export declare class CompositionsPreview {
|
|
3
|
+
/**
|
|
4
|
+
* preview extension.
|
|
5
|
+
*/
|
|
3
6
|
private preview;
|
|
4
|
-
constructor(
|
|
7
|
+
constructor(
|
|
8
|
+
/**
|
|
9
|
+
* preview extension.
|
|
10
|
+
*/
|
|
11
|
+
preview: PreviewPreview);
|
|
5
12
|
render(componentId: string, modules: PreviewModule, otherPreviewDefs: any, context: RenderingContext): void;
|
|
13
|
+
/** gets relevant information for this preview to render */
|
|
6
14
|
selectPreviewModel(componentId: string, previewModule: PreviewModule): any;
|
|
7
15
|
private getActiveComposition;
|
|
8
16
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
@@ -9,6 +9,9 @@ export declare class CompositionsUI {
|
|
|
9
9
|
private menuBarWidgetSlot;
|
|
10
10
|
private emptyStateSlot;
|
|
11
11
|
constructor(menuBarWidgetSlot: CompositionsMenuSlot, emptyStateSlot: EmptyStateSlot);
|
|
12
|
+
/**
|
|
13
|
+
* register a new tester empty state. this allows to register a different empty state from each environment for example.
|
|
14
|
+
*/
|
|
12
15
|
registerEmptyState(emptyStateComponent: ComponentType): this;
|
|
13
16
|
registerMenuWidget(...widget: MenuBarWidget[]): void;
|
|
14
17
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { ComponentModel } from '@teambit/component';
|
|
2
2
|
import { Composition } from '../composition';
|
|
3
3
|
export declare type ComponentCompositionProps = {
|
|
4
|
+
/**
|
|
5
|
+
* HTML class
|
|
6
|
+
*/
|
|
4
7
|
className?: string;
|
|
8
|
+
/**
|
|
9
|
+
* component to render.
|
|
10
|
+
*/
|
|
5
11
|
component: ComponentModel;
|
|
12
|
+
/**
|
|
13
|
+
* composition to use for component rendering.
|
|
14
|
+
*/
|
|
6
15
|
composition?: Composition;
|
|
16
|
+
/**
|
|
17
|
+
* Additional query params to append at the end of the *hash*. Changing this property will not reload the composition.
|
|
18
|
+
*/
|
|
7
19
|
queryParams?: string | string[];
|
|
20
|
+
/**
|
|
21
|
+
* skip hot reload
|
|
22
|
+
*/
|
|
8
23
|
hotReload?: boolean;
|
|
9
24
|
};
|
|
10
25
|
export declare function ComponentComposition({ component, composition, hotReload, className, queryParams, }: ComponentCompositionProps): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/compositions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.556",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/compositions/compositions",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.compositions",
|
|
8
8
|
"name": "compositions",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.556"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/harmony": "0.2.11",
|
|
@@ -23,32 +23,32 @@
|
|
|
23
23
|
"@teambit/documenter.ui.heading": "4.1.1",
|
|
24
24
|
"@teambit/documenter.ui.property-table": "4.1.3",
|
|
25
25
|
"@teambit/evangelist.elements.icon": "1.0.2",
|
|
26
|
-
"@teambit/component": "0.0.
|
|
27
|
-
"@teambit/compositions.model.composition-id": "0.0.
|
|
28
|
-
"@teambit/graphql": "0.0.
|
|
29
|
-
"@teambit/cli": "0.0.
|
|
30
|
-
"@teambit/dev-files": "0.0.
|
|
31
|
-
"@teambit/preview": "0.0.
|
|
32
|
-
"@teambit/schema": "0.0.
|
|
33
|
-
"@teambit/workspace": "0.0.
|
|
34
|
-
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.
|
|
35
|
-
"@teambit/envs": "0.0.
|
|
36
|
-
"@teambit/compositions.ui.compositions-menu-bar": "0.0.
|
|
37
|
-
"@teambit/compositions.ui.hooks.use-composition": "0.0.
|
|
26
|
+
"@teambit/component": "0.0.556",
|
|
27
|
+
"@teambit/compositions.model.composition-id": "0.0.464",
|
|
28
|
+
"@teambit/graphql": "0.0.556",
|
|
29
|
+
"@teambit/cli": "0.0.387",
|
|
30
|
+
"@teambit/dev-files": "0.0.556",
|
|
31
|
+
"@teambit/preview": "0.0.556",
|
|
32
|
+
"@teambit/schema": "0.0.556",
|
|
33
|
+
"@teambit/workspace": "0.0.556",
|
|
34
|
+
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.464",
|
|
35
|
+
"@teambit/envs": "0.0.556",
|
|
36
|
+
"@teambit/compositions.ui.compositions-menu-bar": "0.0.141",
|
|
37
|
+
"@teambit/compositions.ui.hooks.use-composition": "0.0.141",
|
|
38
38
|
"@teambit/design.ui.alert-card": "0.0.13",
|
|
39
39
|
"@teambit/design.ui.empty-box": "0.0.352",
|
|
40
40
|
"@teambit/design.ui.input.option-button": "0.0.26",
|
|
41
41
|
"@teambit/design.ui.separator": "0.0.351",
|
|
42
42
|
"@teambit/design.ui.surfaces.status-message-card": "0.0.6",
|
|
43
|
-
"@teambit/docs.ui.queries.get-docs": "0.0.
|
|
44
|
-
"@teambit/mdx.ui.mdx-layout": "0.0.
|
|
45
|
-
"@teambit/panels": "0.0.
|
|
46
|
-
"@teambit/preview.ui.component-preview": "0.0.
|
|
47
|
-
"@teambit/ui-foundation.ui.buttons.collapser": "0.0.
|
|
48
|
-
"@teambit/ui-foundation.ui.hooks.use-is-mobile": "0.0.
|
|
49
|
-
"@teambit/ui": "0.0.
|
|
50
|
-
"@teambit/compositions.model.composition-type": "0.0.
|
|
51
|
-
"@teambit/compositions.ui.composition-card": "0.0.
|
|
43
|
+
"@teambit/docs.ui.queries.get-docs": "0.0.464",
|
|
44
|
+
"@teambit/mdx.ui.mdx-layout": "0.0.468",
|
|
45
|
+
"@teambit/panels": "0.0.387",
|
|
46
|
+
"@teambit/preview.ui.component-preview": "0.0.464",
|
|
47
|
+
"@teambit/ui-foundation.ui.buttons.collapser": "0.0.169",
|
|
48
|
+
"@teambit/ui-foundation.ui.hooks.use-is-mobile": "0.0.157",
|
|
49
|
+
"@teambit/ui": "0.0.556",
|
|
50
|
+
"@teambit/compositions.model.composition-type": "0.0.465",
|
|
51
|
+
"@teambit/compositions.ui.composition-card": "0.0.470"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^17.0.8",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"@types/jest": "^26.0.0",
|
|
60
60
|
"@types/react-dom": "^17.0.5",
|
|
61
61
|
"@types/node": "12.20.4",
|
|
62
|
-
"@teambit/compositions.aspect-docs.compositions": "0.0.
|
|
62
|
+
"@teambit/compositions.aspect-docs.compositions": "0.0.106"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@teambit/legacy": "1.0.
|
|
65
|
+
"@teambit/legacy": "1.0.173",
|
|
66
66
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
67
67
|
"react": "^16.8.0 || ^17.0.0"
|
|
68
68
|
},
|
|
@@ -90,12 +90,18 @@
|
|
|
90
90
|
"react": "-"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
-
"@teambit/legacy": "1.0.
|
|
93
|
+
"@teambit/legacy": "1.0.173",
|
|
94
94
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
95
95
|
"react": "^16.8.0 || ^17.0.0"
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
+
"files": [
|
|
100
|
+
"dist",
|
|
101
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
102
|
+
"README.md",
|
|
103
|
+
"README.mdx"
|
|
104
|
+
],
|
|
99
105
|
"private": false,
|
|
100
106
|
"engines": {
|
|
101
107
|
"node": ">=12.22.0"
|
package/composition.section.tsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Section } from '@teambit/component';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Compositions } from './compositions';
|
|
4
|
-
import type { CompositionsUI, CompositionsMenuSlot, EmptyStateSlot } from './compositions.ui.runtime';
|
|
5
|
-
|
|
6
|
-
type Options = { menuBarWidgetSlot: CompositionsMenuSlot };
|
|
7
|
-
|
|
8
|
-
export class CompositionsSection implements Section {
|
|
9
|
-
constructor(
|
|
10
|
-
/**
|
|
11
|
-
* simulations ui extension.
|
|
12
|
-
*/
|
|
13
|
-
private compositions: CompositionsUI,
|
|
14
|
-
private options: Options,
|
|
15
|
-
private emptyStateSlot: EmptyStateSlot
|
|
16
|
-
) {}
|
|
17
|
-
|
|
18
|
-
navigationLink = {
|
|
19
|
-
href: '~compositions',
|
|
20
|
-
children: 'Compositions',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
route = {
|
|
24
|
-
path: '~compositions',
|
|
25
|
-
children: <Compositions menuBarWidgets={this.options.menuBarWidgetSlot} emptyState={this.emptyStateSlot} />,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
order = 20;
|
|
29
|
-
}
|
package/composition.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { humanizeCompositionId } from '@teambit/compositions.model.composition-id';
|
|
2
|
-
|
|
3
|
-
export type CompositionProps = {
|
|
4
|
-
identifier: string;
|
|
5
|
-
filepath?: string;
|
|
6
|
-
displayName?: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export class Composition {
|
|
10
|
-
constructor(
|
|
11
|
-
/**
|
|
12
|
-
* identifier of the composition
|
|
13
|
-
*/
|
|
14
|
-
readonly identifier: string,
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* file path in which the composition is contained.
|
|
18
|
-
*/
|
|
19
|
-
readonly filepath?: string,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* set explicit display name
|
|
23
|
-
*/
|
|
24
|
-
private _displayName?: string
|
|
25
|
-
) {}
|
|
26
|
-
|
|
27
|
-
get displayName() {
|
|
28
|
-
return this._displayName || humanizeCompositionId(this.identifier);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
toObject() {
|
|
32
|
-
return {
|
|
33
|
-
identifier: this.identifier,
|
|
34
|
-
filepath: this.filepath,
|
|
35
|
-
displayName: this._displayName,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static fromArray(compositions: CompositionProps[]): Composition[] {
|
|
40
|
-
return compositions.map((composition) => {
|
|
41
|
-
return new Composition(composition.identifier, composition.filepath, composition.displayName);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
package/compositions.aspect.ts
DELETED
package/compositions.docs.mdx
DELETED
package/compositions.graphql.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Component } from '@teambit/component';
|
|
2
|
-
import { Schema } from '@teambit/graphql';
|
|
3
|
-
import gql from 'graphql-tag';
|
|
4
|
-
|
|
5
|
-
import { CompositionsMain } from './compositions.main.runtime';
|
|
6
|
-
|
|
7
|
-
export function compositionsSchema(compositions: CompositionsMain): Schema {
|
|
8
|
-
return {
|
|
9
|
-
typeDefs: gql`
|
|
10
|
-
extend type Component {
|
|
11
|
-
compositions: [Composition]
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type Subscription {
|
|
15
|
-
compositionAdded: Composition
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type Composition {
|
|
19
|
-
filepath: String
|
|
20
|
-
identifier: String
|
|
21
|
-
displayName: String
|
|
22
|
-
}
|
|
23
|
-
`,
|
|
24
|
-
resolvers: {
|
|
25
|
-
Component: {
|
|
26
|
-
compositions: (component: Component) => {
|
|
27
|
-
return compositions.getCompositions(component);
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { MainRuntime } from '@teambit/cli';
|
|
3
|
-
import { Component, ComponentAspect, ComponentMap, AspectData } from '@teambit/component';
|
|
4
|
-
import { GraphqlAspect, GraphqlMain } from '@teambit/graphql';
|
|
5
|
-
import { PreviewAspect, PreviewMain } from '@teambit/preview';
|
|
6
|
-
import { SchemaAspect, SchemaMain } from '@teambit/schema';
|
|
7
|
-
import { Workspace, WorkspaceAspect } from '@teambit/workspace';
|
|
8
|
-
import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
|
|
9
|
-
import { flatten } from '@teambit/legacy/dist/utils';
|
|
10
|
-
import { DevFilesAspect, DevFilesMain } from '@teambit/dev-files';
|
|
11
|
-
import { Composition } from './composition';
|
|
12
|
-
import { CompositionsAspect } from './compositions.aspect';
|
|
13
|
-
import { compositionsSchema } from './compositions.graphql';
|
|
14
|
-
import { CompositionPreviewDefinition } from './compositions.preview-definition';
|
|
15
|
-
|
|
16
|
-
export type CompositionsConfig = {
|
|
17
|
-
/**
|
|
18
|
-
* glob pattern to detect composition files. This includes all related files, like styles and jsons.
|
|
19
|
-
* @example ['/*.composition?(s).*']
|
|
20
|
-
*/
|
|
21
|
-
compositionFilePattern: string[];
|
|
22
|
-
/**
|
|
23
|
-
* glob pattern to select Preview files. this will only include files matched by compositionFilePattern.
|
|
24
|
-
* @example ['*.{t,j}s', '*.{t,j}sx']
|
|
25
|
-
*/
|
|
26
|
-
compositionPreviewFilePattern: string[];
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* the component documentation extension.
|
|
31
|
-
*/
|
|
32
|
-
export class CompositionsMain {
|
|
33
|
-
constructor(
|
|
34
|
-
/**
|
|
35
|
-
* Glob pattern to select all composition files
|
|
36
|
-
*/
|
|
37
|
-
private compositionFilePattern: string[],
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Glob pattern to select composition preview files
|
|
41
|
-
*/
|
|
42
|
-
private previewFilePattern: string[],
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* envs extension.
|
|
46
|
-
*/
|
|
47
|
-
private preview: PreviewMain,
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* workspace extension.
|
|
51
|
-
*/
|
|
52
|
-
private workspace: Workspace,
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* schema extension.
|
|
56
|
-
*/
|
|
57
|
-
private schema: SchemaMain,
|
|
58
|
-
|
|
59
|
-
private devFiles: DevFilesMain
|
|
60
|
-
) {}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* returns an array of doc file paths for a set of components.
|
|
64
|
-
*/
|
|
65
|
-
getPreviewFiles(components: Component[]): ComponentMap<AbstractVinyl[]> {
|
|
66
|
-
return ComponentMap.as<AbstractVinyl[]>(components, (component) => {
|
|
67
|
-
// this includes non executables, like `button.compositions.module.scss` or `presets.compositions.json`
|
|
68
|
-
const compositionFiles = component.state.filesystem.byGlob(this.compositionFilePattern);
|
|
69
|
-
|
|
70
|
-
// select only relevant preview files (.tsx, etc)
|
|
71
|
-
const previewFiles = new Set(
|
|
72
|
-
component.state.filesystem.byGlob(this.previewFilePattern).map((file) => file.relative)
|
|
73
|
-
);
|
|
74
|
-
const files = compositionFiles.filter((file) => previewFiles.has(file.relative));
|
|
75
|
-
|
|
76
|
-
return files;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* get component compositions.
|
|
82
|
-
*/
|
|
83
|
-
getCompositions(component: Component): Composition[] {
|
|
84
|
-
const entry = component.state.aspects.get(CompositionsAspect.id);
|
|
85
|
-
if (!entry) return [];
|
|
86
|
-
const compositions = entry.data.compositions;
|
|
87
|
-
if (!compositions) return [];
|
|
88
|
-
|
|
89
|
-
return Composition.fromArray(compositions);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* read composition from the component source code.
|
|
94
|
-
*/
|
|
95
|
-
readCompositions(component: Component): Composition[] {
|
|
96
|
-
const maybeFiles = this.getPreviewFiles([component]).byComponent(component);
|
|
97
|
-
|
|
98
|
-
if (!maybeFiles) return [];
|
|
99
|
-
const [, files] = maybeFiles;
|
|
100
|
-
return flatten(
|
|
101
|
-
files.map((file) => {
|
|
102
|
-
return this.computeCompositions(component, file);
|
|
103
|
-
})
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async onComponentLoad(component: Component): Promise<AspectData> {
|
|
108
|
-
const compositions = this.readCompositions(component);
|
|
109
|
-
return {
|
|
110
|
-
compositions: compositions.map((composition) => composition.toObject()),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private computeCompositions(component: Component, file: AbstractVinyl): Composition[] {
|
|
115
|
-
// :TODO hacked for a specific file extension now until david will take care in the compiler.
|
|
116
|
-
const pathArray = file.path.split('.');
|
|
117
|
-
pathArray[pathArray.length - 1] = 'js';
|
|
118
|
-
|
|
119
|
-
const module = this.schema.parseModule(join(this.workspace.componentDir(component.id), file.relative));
|
|
120
|
-
return module.exports.map((exportModel) => {
|
|
121
|
-
const displayName = exportModel.staticProperties?.get('compositionName');
|
|
122
|
-
|
|
123
|
-
return new Composition(
|
|
124
|
-
exportModel.identifier,
|
|
125
|
-
file.relative,
|
|
126
|
-
typeof displayName === 'string' ? displayName : undefined
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static defaultConfig: CompositionsConfig = {
|
|
132
|
-
compositionFilePattern: ['**/*.composition?(s).*'],
|
|
133
|
-
compositionPreviewFilePattern: ['**/*.{t,j}s?(x)'],
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
static runtime = MainRuntime;
|
|
137
|
-
static dependencies = [PreviewAspect, GraphqlAspect, WorkspaceAspect, SchemaAspect, DevFilesAspect, ComponentAspect];
|
|
138
|
-
|
|
139
|
-
static async provider(
|
|
140
|
-
[preview, graphql, workspace, schema, devFiles]: [PreviewMain, GraphqlMain, Workspace, SchemaMain, DevFilesMain],
|
|
141
|
-
config: CompositionsConfig
|
|
142
|
-
) {
|
|
143
|
-
const compositions = new CompositionsMain(
|
|
144
|
-
config.compositionFilePattern,
|
|
145
|
-
config.compositionPreviewFilePattern,
|
|
146
|
-
preview,
|
|
147
|
-
workspace,
|
|
148
|
-
schema,
|
|
149
|
-
devFiles
|
|
150
|
-
);
|
|
151
|
-
devFiles.registerDevPattern(config.compositionFilePattern);
|
|
152
|
-
|
|
153
|
-
graphql.register(compositionsSchema(compositions));
|
|
154
|
-
preview.registerDefinition(new CompositionPreviewDefinition(compositions));
|
|
155
|
-
|
|
156
|
-
if (workspace) {
|
|
157
|
-
workspace.onComponentLoad(compositions.onComponentLoad.bind(compositions));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return compositions;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
CompositionsAspect.addRuntime(CompositionsMain);
|
package/compositions.module.scss
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
@import '~@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
|
2
|
-
$panelBg: #fafafa;
|
|
3
|
-
|
|
4
|
-
.compositionsPage {
|
|
5
|
-
height: 100%;
|
|
6
|
-
width: 100%;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.compositionPreview {
|
|
10
|
-
padding-top: 20px;
|
|
11
|
-
width: 100%;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.left {
|
|
15
|
-
min-width: 200px;
|
|
16
|
-
|
|
17
|
-
//cannot assign max-width directly to right side
|
|
18
|
-
max-width: calc(100% - 200px);
|
|
19
|
-
|
|
20
|
-
display: flex;
|
|
21
|
-
overflow-y: auto;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.right {
|
|
26
|
-
background: $panelBg;
|
|
27
|
-
overflow-y: auto;
|
|
28
|
-
// this is to fix the right panel when it gets too big or too small
|
|
29
|
-
min-width: 200px;
|
|
30
|
-
max-width: calc(100% - 200px);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.menuBar {
|
|
34
|
-
border-bottom: 1px solid var(--bit-border-color-lightest, #ededed);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.splitter {
|
|
38
|
-
position: relative;
|
|
39
|
-
|
|
40
|
-
> :first-child {
|
|
41
|
-
z-index: $nav-z-index + 1;
|
|
42
|
-
position: absolute;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.collapser {
|
|
47
|
-
right: 0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.tabsContainer {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-direction: column;
|
|
53
|
-
height: 100%;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.tabs {
|
|
57
|
-
flex: none;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.tabContent {
|
|
61
|
-
flex: 1 1;
|
|
62
|
-
overflow: auto;
|
|
63
|
-
|
|
64
|
-
&:empty {
|
|
65
|
-
display: none;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.compositions {
|
|
70
|
-
padding: 16px 8px 0 8px;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.openInNewTab {
|
|
74
|
-
text-decoration: none;
|
|
75
|
-
color: inherit;
|
|
76
|
-
|
|
77
|
-
&:active {
|
|
78
|
-
color: inherit;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.noCompositionsPage {
|
|
83
|
-
padding: 50px 40px 100px 40px;
|
|
84
|
-
width: 100%;
|
|
85
|
-
box-sizing: border-box;
|
|
86
|
-
max-width: 1440px;
|
|
87
|
-
margin: 0 auto;
|
|
88
|
-
|
|
89
|
-
.title {
|
|
90
|
-
margin-bottom: 24px;
|
|
91
|
-
font-size: var(--bit-h-xs, 26px);
|
|
92
|
-
}
|
|
93
|
-
.separator {
|
|
94
|
-
margin-bottom: 41px;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.buildStatusMessage {
|
|
99
|
-
margin: auto;
|
|
100
|
-
}
|