@teambit/component 0.0.568 → 0.0.569
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/aspect.section.tsx +16 -0
- package/component-map/component-map.ts +106 -0
- package/component-map/index.ts +1 -0
- package/component.ui.runtime.tsx +216 -0
- package/dependencies/dependencies.ts +74 -0
- package/dependencies/index.ts +1 -0
- package/exceptions/could-not-find-latest.ts +8 -0
- package/exceptions/host-not-found.ts +14 -0
- package/exceptions/index.ts +4 -0
- package/exceptions/nothing-to-snap.ts +1 -0
- package/host/component-host-model.ts +9 -0
- package/host/index.ts +2 -0
- package/host/use-component-host.ts +39 -0
- package/package-tar/teambit-component-0.0.569.tgz +0 -0
- package/package.json +34 -49
- package/section/index.ts +1 -0
- package/section/section.tsx +8 -0
- package/show/extensions.fragment.ts +23 -0
- package/show/files.fragment.ts +24 -0
- package/show/id.fragment.ts +20 -0
- package/show/index.ts +8 -0
- package/show/main-file.fragment.ts +13 -0
- package/show/name.fragment.ts +13 -0
- package/show/scope.fragment.ts +15 -0
- package/show/show-fragment.ts +44 -0
- package/show/show.cmd.ts +85 -0
- package/snap/author.ts +19 -0
- package/snap/index.ts +2 -0
- package/snap/snap.ts +63 -0
- package/tag/index.ts +1 -0
- package/tag/tag.ts +37 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
- package/ui/aspect-page/aspect-page.tsx +64 -0
- package/ui/aspect-page/index.ts +1 -0
- package/ui/component-error/component-error.tsx +22 -0
- package/ui/component-error/index.ts +1 -0
- package/ui/component-model/component-model.ts +169 -0
- package/ui/component-model/index.ts +1 -0
- package/ui/component.tsx +48 -0
- package/ui/context/component-context.ts +5 -0
- package/ui/context/component-provider.tsx +20 -0
- package/ui/context/index.ts +2 -0
- package/ui/index.ts +3 -0
- package/ui/menu/index.ts +2 -0
- package/ui/menu/menu-nav.tsx +37 -0
- package/ui/menu/menu.tsx +94 -0
- package/ui/menu/nav-plugin.tsx +9 -0
- package/ui/top-bar-nav/index.ts +1 -0
- package/ui/top-bar-nav/top-bar-nav.tsx +26 -0
- package/ui/use-component-query.ts +195 -0
- package/ui/use-component.tsx +34 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuWidgetIcon } from '@teambit/ui-foundation.ui.menu-widget-icon';
|
|
3
|
+
import { Section } from './section';
|
|
4
|
+
import { AspectPage } from './ui/aspect-page';
|
|
5
|
+
|
|
6
|
+
export class AspectSection implements Section {
|
|
7
|
+
route = {
|
|
8
|
+
path: '~aspect',
|
|
9
|
+
children: <AspectPage />,
|
|
10
|
+
};
|
|
11
|
+
navigationLink = {
|
|
12
|
+
href: '~aspect',
|
|
13
|
+
children: <MenuWidgetIcon icon="configuration" tooltipContent="Configuration" />,
|
|
14
|
+
};
|
|
15
|
+
order = 50;
|
|
16
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component-id';
|
|
2
|
+
import { Component } from '../component';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* allows to index components -> values.
|
|
6
|
+
*/
|
|
7
|
+
export class ComponentMap<T> {
|
|
8
|
+
constructor(readonly hashMap: Map<string, [Component, T]>) {}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated please use `get` instead
|
|
12
|
+
*/
|
|
13
|
+
byComponent(component: Component) {
|
|
14
|
+
return this.hashMap.get(component.id.toString());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get components() {
|
|
18
|
+
return this.toArray().map(([component]) => component);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* get a value for a component.
|
|
23
|
+
*/
|
|
24
|
+
get(component: Component) {
|
|
25
|
+
return this.hashMap.get(component.id.toString());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* get a value by the component-id
|
|
30
|
+
*/
|
|
31
|
+
getValueByComponentId(componentId: ComponentID): T | null {
|
|
32
|
+
const tuple = this.hashMap.get(componentId.toString());
|
|
33
|
+
if (!tuple) return null;
|
|
34
|
+
return tuple[1];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* returns an array.
|
|
39
|
+
*/
|
|
40
|
+
toArray() {
|
|
41
|
+
return Array.from(this.hashMap.values());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* map entries and return a new component map.
|
|
46
|
+
*/
|
|
47
|
+
map<NewType>(predicate: (value: T, component: Component) => NewType): ComponentMap<NewType> {
|
|
48
|
+
const tuples: [string, [Component, NewType]][] = this.toArray().map(([component, value]) => {
|
|
49
|
+
const newValue = predicate(value, component);
|
|
50
|
+
return [component.id.toString(), [component, newValue]];
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return new ComponentMap(new Map(tuples));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* flatten values of all components into a single array.
|
|
57
|
+
*/
|
|
58
|
+
flattenValue(): T[] {
|
|
59
|
+
return this.toArray().reduce((acc: T[], [, value]) => {
|
|
60
|
+
acc = acc.concat(value);
|
|
61
|
+
return acc;
|
|
62
|
+
}, []);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* filter all components with empty values and return a new map.
|
|
67
|
+
*/
|
|
68
|
+
filter(predicate: (value: T) => boolean): ComponentMap<T> {
|
|
69
|
+
const tuples = this.toArray().filter(([, value]) => {
|
|
70
|
+
return predicate(value);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const asMap: [string, [Component, T]][] = tuples.map(([component, value]) => {
|
|
74
|
+
return [component.id.toString(), [component, value]];
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return new ComponentMap(new Map(asMap));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* get all component ids.
|
|
82
|
+
*/
|
|
83
|
+
keys() {
|
|
84
|
+
return this.hashMap.keys();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static create<U>(rawMap: [Component, U][]) {
|
|
88
|
+
const newMap: [string, [Component, U]][] = rawMap.map(([component, data]) => {
|
|
89
|
+
return [component.id.toString(), [component, data]];
|
|
90
|
+
});
|
|
91
|
+
return new ComponentMap(new Map(newMap));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* create a component map from components and a value predicate.
|
|
96
|
+
* @param components components to zip into the map.
|
|
97
|
+
* @param predicate predicate for returning desired value.
|
|
98
|
+
*/
|
|
99
|
+
static as<U>(components: Component[], predicate: (component: Component) => U): ComponentMap<U> {
|
|
100
|
+
const tuples: [string, [Component, U]][] = components.map((component) => {
|
|
101
|
+
return [component.id.toString(), [component, predicate(component)]];
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return new ComponentMap(new Map(tuples));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ComponentMap } from './component-map';
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import PubsubAspect, { PubsubUI, BitBaseEvent } from '@teambit/pubsub';
|
|
2
|
+
import PreviewAspect, { ClickInsideAnIframeEvent } from '@teambit/preview';
|
|
3
|
+
import { MenuItemSlot, MenuItem } from '@teambit/ui-foundation.ui.main-dropdown';
|
|
4
|
+
import { Slot } from '@teambit/harmony';
|
|
5
|
+
import { NavigationSlot, RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
6
|
+
import { NavLinkProps } from '@teambit/base-ui.routing.nav-link';
|
|
7
|
+
import { UIRuntime } from '@teambit/ui';
|
|
8
|
+
import { isBrowser } from '@teambit/ui-foundation.ui.is-browser';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { RouteProps } from 'react-router-dom';
|
|
11
|
+
import CommandBarAspect, { CommandBarUI, CommandEntry } from '@teambit/command-bar';
|
|
12
|
+
import copy from 'copy-to-clipboard';
|
|
13
|
+
import { ComponentAspect } from './component.aspect';
|
|
14
|
+
import { Component, ComponentPageElement, ComponentPageSlot } from './ui/component';
|
|
15
|
+
import { Menu, NavPlugin, OrderedNavigationSlot } from './ui/menu';
|
|
16
|
+
import { AspectSection } from './aspect.section';
|
|
17
|
+
import { ComponentModel } from './ui';
|
|
18
|
+
|
|
19
|
+
export type Server = {
|
|
20
|
+
env: string;
|
|
21
|
+
url: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type ComponentMeta = {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const componentIdUrlRegex = '[\\w\\/-]*[\\w-]';
|
|
29
|
+
|
|
30
|
+
export class ComponentUI {
|
|
31
|
+
readonly routePath = `/:componentId(${componentIdUrlRegex})`;
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
/**
|
|
35
|
+
* Pubsub aspects
|
|
36
|
+
*/
|
|
37
|
+
private pubsub: PubsubUI,
|
|
38
|
+
|
|
39
|
+
private routeSlot: RouteSlot,
|
|
40
|
+
|
|
41
|
+
private navSlot: OrderedNavigationSlot,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* slot for registering a new widget to the menu.
|
|
45
|
+
*/
|
|
46
|
+
private widgetSlot: OrderedNavigationSlot,
|
|
47
|
+
|
|
48
|
+
private menuItemSlot: MenuItemSlot,
|
|
49
|
+
|
|
50
|
+
private pageItemSlot: ComponentPageSlot,
|
|
51
|
+
|
|
52
|
+
private commandBarUI: CommandBarUI
|
|
53
|
+
) {
|
|
54
|
+
if (isBrowser) this.registerPubSub();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* the current visible component
|
|
59
|
+
*/
|
|
60
|
+
private activeComponent?: ComponentModel;
|
|
61
|
+
|
|
62
|
+
private copyNpmId = () => {
|
|
63
|
+
const packageName = this.activeComponent?.packageName;
|
|
64
|
+
if (packageName) {
|
|
65
|
+
const version = this.activeComponent?.id.version;
|
|
66
|
+
const versionString = version ? `@${version}` : '';
|
|
67
|
+
copy(`${packageName}${versionString}`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* key bindings used by component aspect
|
|
73
|
+
*/
|
|
74
|
+
private keyBindings: CommandEntry[] = [
|
|
75
|
+
{
|
|
76
|
+
id: 'component.copyBitId', // TODO - extract to a component!
|
|
77
|
+
handler: () => {
|
|
78
|
+
copy(this.activeComponent?.id.toString() || '');
|
|
79
|
+
},
|
|
80
|
+
displayName: 'Copy component ID',
|
|
81
|
+
keybinding: '.',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'component.copyNpmId', // TODO - extract to a component!
|
|
85
|
+
handler: this.copyNpmId,
|
|
86
|
+
displayName: 'Copy component package name',
|
|
87
|
+
keybinding: ',',
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
private menuItems: MenuItem[] = [
|
|
92
|
+
{
|
|
93
|
+
category: 'general',
|
|
94
|
+
title: 'Open command bar',
|
|
95
|
+
keyChar: 'mod+k',
|
|
96
|
+
handler: () => this.commandBarUI?.run('command-bar.open'),
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
category: 'general',
|
|
100
|
+
title: 'Toggle component list',
|
|
101
|
+
keyChar: 'alt+s',
|
|
102
|
+
handler: () => this.commandBarUI?.run('sidebar.toggle'),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
category: 'workflow',
|
|
106
|
+
title: 'Copy component ID',
|
|
107
|
+
keyChar: '.',
|
|
108
|
+
handler: () => this.commandBarUI?.run('component.copyBitId'),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
category: 'workflow',
|
|
112
|
+
title: 'Copy component package name',
|
|
113
|
+
keyChar: ',',
|
|
114
|
+
handler: () => this.commandBarUI?.run('component.copyNpmId'),
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
registerPubSub() {
|
|
119
|
+
this.pubsub.sub(PreviewAspect.id, (be: BitBaseEvent<any>) => {
|
|
120
|
+
if (be.type === ClickInsideAnIframeEvent.TYPE) {
|
|
121
|
+
const event = new MouseEvent('mousedown', {
|
|
122
|
+
view: window,
|
|
123
|
+
bubbles: true,
|
|
124
|
+
cancelable: true,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const body = document.body;
|
|
128
|
+
body?.dispatchEvent(event);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
handleComponentChange = (activeComponent?: ComponentModel) => {
|
|
134
|
+
this.activeComponent = activeComponent;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
getComponentUI(host: string) {
|
|
138
|
+
return (
|
|
139
|
+
<Component
|
|
140
|
+
routeSlot={this.routeSlot}
|
|
141
|
+
containerSlot={this.pageItemSlot}
|
|
142
|
+
onComponentChange={this.handleComponentChange}
|
|
143
|
+
host={host}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getMenu(host: string) {
|
|
149
|
+
return (
|
|
150
|
+
<Menu navigationSlot={this.navSlot} widgetSlot={this.widgetSlot} host={host} menuItemSlot={this.menuItemSlot} />
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
registerRoute(route: RouteProps) {
|
|
155
|
+
this.routeSlot.register(route);
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
registerNavigation(nav: NavLinkProps, order?: number) {
|
|
160
|
+
this.navSlot.register({
|
|
161
|
+
props: nav,
|
|
162
|
+
order,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
registerWidget(widget: NavLinkProps, order?: number) {
|
|
167
|
+
this.widgetSlot.register({ props: widget, order });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
registerMenuItem = (menuItems: MenuItem[]) => {
|
|
171
|
+
this.menuItemSlot.register(menuItems);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
registerPageItem = (...items: ComponentPageElement[]) => {
|
|
175
|
+
this.pageItemSlot.register(items);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
static dependencies = [PubsubAspect, CommandBarAspect];
|
|
179
|
+
|
|
180
|
+
static runtime = UIRuntime;
|
|
181
|
+
|
|
182
|
+
static slots = [
|
|
183
|
+
Slot.withType<RouteProps>(),
|
|
184
|
+
Slot.withType<NavPlugin>(),
|
|
185
|
+
Slot.withType<NavigationSlot>(),
|
|
186
|
+
Slot.withType<MenuItemSlot>(),
|
|
187
|
+
Slot.withType<ComponentPageSlot>(),
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
static async provider(
|
|
191
|
+
[pubsub, commandBarUI]: [PubsubUI, CommandBarUI],
|
|
192
|
+
config,
|
|
193
|
+
[routeSlot, navSlot, widgetSlot, menuItemSlot, pageSlot]: [
|
|
194
|
+
RouteSlot,
|
|
195
|
+
OrderedNavigationSlot,
|
|
196
|
+
OrderedNavigationSlot,
|
|
197
|
+
MenuItemSlot,
|
|
198
|
+
ComponentPageSlot
|
|
199
|
+
]
|
|
200
|
+
) {
|
|
201
|
+
// TODO: refactor ComponentHost to a separate extension (including sidebar, host, graphql, etc.)
|
|
202
|
+
// TODO: add contextual hook for ComponentHost @uri/@oded
|
|
203
|
+
const componentUI = new ComponentUI(pubsub, routeSlot, navSlot, widgetSlot, menuItemSlot, pageSlot, commandBarUI);
|
|
204
|
+
const section = new AspectSection();
|
|
205
|
+
|
|
206
|
+
componentUI.commandBarUI.addCommand(...componentUI.keyBindings);
|
|
207
|
+
componentUI.registerMenuItem(componentUI.menuItems);
|
|
208
|
+
componentUI.registerRoute(section.route);
|
|
209
|
+
componentUI.registerWidget(section.navigationLink, section.order);
|
|
210
|
+
return componentUI;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export default ComponentUI;
|
|
215
|
+
|
|
216
|
+
ComponentAspect.addRuntime(ComponentUI);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { BitError } from '@teambit/bit-error';
|
|
3
|
+
import { BitId } from '@teambit/legacy-bit-id';
|
|
4
|
+
|
|
5
|
+
const DEV_ENV = 'development';
|
|
6
|
+
const RUNTIME_ENV = 'runtime';
|
|
7
|
+
|
|
8
|
+
// type Environment = DEV_ENV | RUNTIME_ENV;
|
|
9
|
+
type Environment = 'development' | 'runtime';
|
|
10
|
+
// type WrappingMethod = 'component' | 'package';
|
|
11
|
+
|
|
12
|
+
export class DependencyId extends BitId {}
|
|
13
|
+
|
|
14
|
+
export class Dependency {
|
|
15
|
+
constructor(public id: DependencyId) {}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class PackageDependency extends Dependency {}
|
|
19
|
+
|
|
20
|
+
export class ComponentDependency extends Dependency {}
|
|
21
|
+
|
|
22
|
+
export class DependencyList extends Array<Dependency> {
|
|
23
|
+
/**
|
|
24
|
+
* Get only package dependencies
|
|
25
|
+
*
|
|
26
|
+
* @readonly
|
|
27
|
+
* @memberof DependencyList
|
|
28
|
+
*/
|
|
29
|
+
get packages(): PackageDependency[] {
|
|
30
|
+
return this.filter((dep) => dep instanceof PackageDependency);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get components(): ComponentDependency[] {
|
|
34
|
+
return this.filter((dep) => dep instanceof ComponentDependency);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static fromArray(dependencies: Dependency[]): DependencyList {
|
|
38
|
+
return new DependencyList(...dependencies);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class Dependencies {
|
|
43
|
+
constructor(public runtime: DependencyList, public dev: DependencyList, public peer: DependencyList) {}
|
|
44
|
+
|
|
45
|
+
private getByEnvironment(env: Environment): DependencyList {
|
|
46
|
+
if (env === DEV_ENV) {
|
|
47
|
+
return DependencyList.fromArray(this.runtime.concat(this.dev).concat(this.peer));
|
|
48
|
+
}
|
|
49
|
+
if (env === RUNTIME_ENV) {
|
|
50
|
+
return DependencyList.fromArray(this.runtime.concat(this.peer));
|
|
51
|
+
}
|
|
52
|
+
throw new BitError(`env ${env} is not supported`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get dependencies needed for development environnement such as runtime, dev and peer
|
|
57
|
+
*
|
|
58
|
+
* @returns {DependencyList}
|
|
59
|
+
* @memberof Dependencies
|
|
60
|
+
*/
|
|
61
|
+
computeDev(): DependencyList {
|
|
62
|
+
return this.getByEnvironment(DEV_ENV);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get dependencies needed for runtime environnement such as runtime and peer
|
|
67
|
+
*
|
|
68
|
+
* @returns {DependencyList}
|
|
69
|
+
* @memberof Dependencies
|
|
70
|
+
*/
|
|
71
|
+
computeRuntime(): DependencyList {
|
|
72
|
+
return this.getByEnvironment(RUNTIME_ENV);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Dependencies } from './dependencies';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class NothingToSnap extends Error {}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentModel } from '../ui';
|
|
2
|
+
|
|
3
|
+
export class ComponentHostModel {
|
|
4
|
+
constructor(readonly name: string, readonly components: ComponentModel[]) {}
|
|
5
|
+
|
|
6
|
+
static from(data: any) {
|
|
7
|
+
return new ComponentHostModel(data.getHost.name, ComponentModel.fromArray(data.getHost.list));
|
|
8
|
+
}
|
|
9
|
+
}
|
package/host/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';
|
|
2
|
+
import { gql } from '@apollo/client';
|
|
3
|
+
|
|
4
|
+
import { ComponentHostModel } from './component-host-model';
|
|
5
|
+
|
|
6
|
+
const COMPONENT_HOST = gql`
|
|
7
|
+
{
|
|
8
|
+
getHost {
|
|
9
|
+
id # used for GQL caching
|
|
10
|
+
name
|
|
11
|
+
list {
|
|
12
|
+
id {
|
|
13
|
+
name
|
|
14
|
+
version
|
|
15
|
+
scope
|
|
16
|
+
}
|
|
17
|
+
deprecation {
|
|
18
|
+
isDeprecate
|
|
19
|
+
}
|
|
20
|
+
env {
|
|
21
|
+
id
|
|
22
|
+
icon
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export function useComponentHost() {
|
|
30
|
+
const { data, loading } = useDataQuery(COMPONENT_HOST);
|
|
31
|
+
|
|
32
|
+
if (!data || loading) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const host = ComponentHostModel.from(data);
|
|
37
|
+
|
|
38
|
+
return { host };
|
|
39
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/component",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.569",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/component/component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "component",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.569"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -26,38 +26,38 @@
|
|
|
26
26
|
"@teambit/base-ui.routing.nav-link": "1.0.0",
|
|
27
27
|
"@teambit/documenter.ui.heading": "4.1.1",
|
|
28
28
|
"@teambit/documenter.ui.separator": "4.1.1",
|
|
29
|
-
"@teambit/component-id": "0.0.
|
|
30
|
-
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.
|
|
31
|
-
"@teambit/aspect-loader": "0.0.
|
|
32
|
-
"@teambit/legacy-bit-id": "0.0.
|
|
33
|
-
"@teambit/toolbox.string.capitalize": "0.0.
|
|
34
|
-
"@teambit/cli": "0.0.
|
|
35
|
-
"@teambit/config": "0.0.
|
|
36
|
-
"@teambit/express": "0.0.
|
|
37
|
-
"@teambit/graphql": "0.0.
|
|
38
|
-
"@teambit/bit-error": "0.0.
|
|
39
|
-
"@teambit/command-bar": "0.0.
|
|
40
|
-
"@teambit/preview": "0.0.
|
|
41
|
-
"@teambit/pubsub": "0.0.
|
|
42
|
-
"@teambit/ui-foundation.ui.is-browser": "0.0.
|
|
43
|
-
"@teambit/ui-foundation.ui.main-dropdown": "0.0.
|
|
44
|
-
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.
|
|
45
|
-
"@teambit/ui": "0.0.
|
|
46
|
-
"@teambit/component-issues": "0.0.
|
|
47
|
-
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.
|
|
48
|
-
"@teambit/cli-table": "0.0.
|
|
49
|
-
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.
|
|
29
|
+
"@teambit/component-id": "0.0.385",
|
|
30
|
+
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.474",
|
|
31
|
+
"@teambit/aspect-loader": "0.0.569",
|
|
32
|
+
"@teambit/legacy-bit-id": "0.0.384",
|
|
33
|
+
"@teambit/toolbox.string.capitalize": "0.0.469",
|
|
34
|
+
"@teambit/cli": "0.0.395",
|
|
35
|
+
"@teambit/config": "0.0.407",
|
|
36
|
+
"@teambit/express": "0.0.485",
|
|
37
|
+
"@teambit/graphql": "0.0.569",
|
|
38
|
+
"@teambit/bit-error": "0.0.381",
|
|
39
|
+
"@teambit/command-bar": "0.0.569",
|
|
40
|
+
"@teambit/preview": "0.0.569",
|
|
41
|
+
"@teambit/pubsub": "0.0.569",
|
|
42
|
+
"@teambit/ui-foundation.ui.is-browser": "0.0.472",
|
|
43
|
+
"@teambit/ui-foundation.ui.main-dropdown": "0.0.472",
|
|
44
|
+
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.474",
|
|
45
|
+
"@teambit/ui": "0.0.569",
|
|
46
|
+
"@teambit/component-issues": "0.0.30",
|
|
47
|
+
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.473",
|
|
48
|
+
"@teambit/cli-table": "0.0.18",
|
|
49
|
+
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.472",
|
|
50
50
|
"@teambit/design.ui.empty-box": "0.0.352",
|
|
51
|
-
"@teambit/harmony.ui.aspect-box": "0.0.
|
|
51
|
+
"@teambit/harmony.ui.aspect-box": "0.0.472",
|
|
52
52
|
"@teambit/design.ui.pages.not-found": "0.0.352",
|
|
53
53
|
"@teambit/design.ui.pages.server-error": "0.0.352",
|
|
54
|
-
"@teambit/compositions": "0.0.
|
|
55
|
-
"@teambit/deprecation": "0.0.
|
|
56
|
-
"@teambit/envs": "0.0.
|
|
57
|
-
"@teambit/component.ui.version-dropdown": "0.0.
|
|
58
|
-
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.
|
|
59
|
-
"@teambit/ui-foundation.ui.use-box.menu": "0.0.
|
|
60
|
-
"@teambit/ui-foundation.ui.react-router.extend-path": "0.0.
|
|
54
|
+
"@teambit/compositions": "0.0.569",
|
|
55
|
+
"@teambit/deprecation": "0.0.569",
|
|
56
|
+
"@teambit/envs": "0.0.569",
|
|
57
|
+
"@teambit/component.ui.version-dropdown": "0.0.476",
|
|
58
|
+
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.93",
|
|
59
|
+
"@teambit/ui-foundation.ui.use-box.menu": "0.0.93",
|
|
60
|
+
"@teambit/ui-foundation.ui.react-router.extend-path": "0.0.472"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/lodash": "4.14.165",
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"@types/jest": "^26.0.0",
|
|
73
73
|
"@types/react-dom": "^17.0.5",
|
|
74
74
|
"@types/node": "12.20.4",
|
|
75
|
-
"@teambit/component.aspect-docs.component": "0.0.
|
|
75
|
+
"@teambit/component.aspect-docs.component": "0.0.115"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@apollo/client": "^3.0.0",
|
|
79
|
-
"@teambit/legacy": "1.0.
|
|
79
|
+
"@teambit/legacy": "1.0.181",
|
|
80
80
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
81
81
|
"react": "^16.8.0 || ^17.0.0"
|
|
82
82
|
},
|
|
@@ -104,27 +104,12 @@
|
|
|
104
104
|
"react": "-"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
|
-
"@teambit/legacy": "1.0.
|
|
107
|
+
"@teambit/legacy": "1.0.181",
|
|
108
108
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
109
109
|
"react": "^16.8.0 || ^17.0.0"
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
-
"files": [
|
|
114
|
-
"dist",
|
|
115
|
-
"!dist/tsconfig.tsbuildinfo",
|
|
116
|
-
"**/*.md",
|
|
117
|
-
"**/*.mdx",
|
|
118
|
-
"**/*.js",
|
|
119
|
-
"**/*.json",
|
|
120
|
-
"**/*.sass",
|
|
121
|
-
"**/*.scss",
|
|
122
|
-
"**/*.less",
|
|
123
|
-
"**/*.css",
|
|
124
|
-
"**/*.css",
|
|
125
|
-
"**/*.jpeg",
|
|
126
|
-
"**/*.gif"
|
|
127
|
-
],
|
|
128
113
|
"private": false,
|
|
129
114
|
"engines": {
|
|
130
115
|
"node": ">=12.22.0"
|
package/section/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Section } from './section';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ShowFragment } from './show-fragment';
|
|
2
|
+
import { Component } from '../component';
|
|
3
|
+
|
|
4
|
+
export class ExtensionsFragment implements ShowFragment {
|
|
5
|
+
private renderList(component: Component) {
|
|
6
|
+
const aspects = component.state.aspects.entries.map((entry) => entry.id.toString());
|
|
7
|
+
return aspects.join('\n');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async renderRow(component: Component) {
|
|
11
|
+
return {
|
|
12
|
+
title: 'extensions',
|
|
13
|
+
content: this.renderList(component),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async json(component: Component) {
|
|
18
|
+
return {
|
|
19
|
+
title: 'configuration',
|
|
20
|
+
json: component.state.aspects.serialize() as any,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|