@teambit/component 0.0.1037 → 0.0.1039
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/component.ui.runtime.tsx +7 -0
- package/dist/component-factory.d.ts +3 -0
- package/dist/component-factory.js.map +1 -1
- package/dist/component.ui.runtime.d.ts +1 -0
- package/dist/component.ui.runtime.js +5 -1
- package/dist/component.ui.runtime.js.map +1 -1
- package/dist/get-component-opts.d.ts +2 -0
- package/dist/get-component-opts.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{preview-1681875190881.js → preview-1682047751680.js} +2 -2
- package/dist/ui/component.d.ts +3 -1
- package/dist/ui/component.js +3 -1
- package/dist/ui/component.js.map +1 -1
- package/package-tar/teambit-component-0.0.1039.tgz +0 -0
- package/package.json +20 -20
- package/ui/component.tsx +6 -1
- package/package-tar/teambit-component-0.0.1037.tgz +0 -0
package/component.ui.runtime.tsx
CHANGED
|
@@ -74,6 +74,12 @@ export class ComponentUI {
|
|
|
74
74
|
if (isBrowser) this.registerPubSub();
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
get routes() {
|
|
78
|
+
return this.routeSlot
|
|
79
|
+
.toArray()
|
|
80
|
+
.map(([key, routes]) => [key, Array.isArray(routes) ? [...flatten(routes)] : [routes]] as [string, RouteProps[]]);
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
/**
|
|
78
84
|
* the current visible component
|
|
79
85
|
*/
|
|
@@ -187,6 +193,7 @@ export class ComponentUI {
|
|
|
187
193
|
useComponent={options.useComponent}
|
|
188
194
|
componentIdStr={options.componentId}
|
|
189
195
|
useComponentFilters={options.useComponentFilters}
|
|
196
|
+
overriddenRoutes={options.routes}
|
|
190
197
|
/>
|
|
191
198
|
);
|
|
192
199
|
}
|
|
@@ -14,6 +14,9 @@ export declare type ResolveAspectsOptions = FilterAspectsOptions & {
|
|
|
14
14
|
workspaceName?: string;
|
|
15
15
|
};
|
|
16
16
|
export declare type LoadAspectsOptions = {
|
|
17
|
+
throwOnError?: boolean;
|
|
18
|
+
hideMissingModuleError?: boolean;
|
|
19
|
+
ignoreErrors?: boolean;
|
|
17
20
|
[key: string]: any;
|
|
18
21
|
};
|
|
19
22
|
export declare type FilterAspectsOptions = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["component-factory.ts"],"sourcesContent":["import { Graph } from '@teambit/graph.cleargraph';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { CompIdGraph } from '@teambit/graph';\nimport type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';\nimport type { AspectDefinition } from '@teambit/aspect-loader';\nimport { ComponentID } from '@teambit/component-id';\nimport { Component, InvalidComponent } from './component';\nimport { State } from './state';\nimport { Snap } from './snap';\n\nexport type ResolveAspectsOptions = FilterAspectsOptions & {\n throwOnError?: boolean;\n useScopeAspectsCapsule?: boolean;\n workspaceName?: string;\n};\n\nexport type LoadAspectsOptions = {\n [key: string]: any;\n};\n\nexport type FilterAspectsOptions = {\n /**\n * Do not return results for the core aspects\n */\n excludeCore?: boolean;\n /**\n * Only return results for the provided list of ids\n */\n requestedOnly?: boolean;\n /**\n * Only return results for aspects that have a path to the specified runtime name\n */\n filterByRuntime?: boolean;\n};\n\nexport interface ComponentFactory {\n /**\n * name of the component host.\n */\n name: string;\n\n /**\n * path to the component host.\n */\n path: string;\n\n isLegacy: boolean;\n\n /**\n * resolve a `string` component ID to an instance of a ComponentID.\n */\n resolveComponentId(id: string | ComponentID | BitId): Promise<ComponentID>;\n\n /**\n * resolve multiple `string` component ID to an instance of a ComponentID.\n */\n resolveMultipleComponentIds(ids: (string | ComponentID | BitId)[]): Promise<ComponentID[]>;\n\n /**\n * returns a component by ID.\n */\n get(id: ComponentID): Promise<Component | undefined>;\n\n /**\n * returns many components by ids.\n */\n getMany(ids: ComponentID[]): Promise<Component[]>;\n\n /**\n * returns many components by their legacy representation.\n */\n getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;\n\n /**\n * get a component from a remote without importing it\n */\n getRemoteComponent?: (id: ComponentID) => Promise<Component>;\n\n /**\n * important - prefer using `getGraphIds()` if you don't need the component objects.\n * this method has a performance penalty. it must import all flattened-dependencies objects from the remotes.\n */\n getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>;\n\n /**\n * get graph of the given component-ids and all their dependencies (recursively/flattened).\n * the nodes are ComponentIds and is much faster than `this.getGraph()`.\n */\n getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>;\n\n getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>;\n\n /**\n * returns a specific state of a component by hash or semver.\n */\n getState(id: ComponentID, snapId: string): Promise<State>;\n\n /**\n * returns a specific snap of a component by hash.\n */\n getSnap(id: ComponentID, snapId: string): Promise<Snap>;\n\n /**\n * load aspects.\n * returns the loaded aspect ids including the loaded versions.\n */\n loadAspects: (ids: string[], throwOnError?: boolean, neededFor?: string, opts?: any) => Promise<string[]>;\n\n /**\n * Resolve dirs for aspects\n */\n resolveAspects: (\n runtimeName?: string,\n componentIds?: ComponentID[],\n opts?: ResolveAspectsOptions\n ) => Promise<AspectDefinition[]>;\n\n /**\n * list all components in the host.\n */\n list(filter?: { offset: number; limit: number }): Promise<Component[]>;\n\n /**\n * list invalid components, such as components with missing files on the fs.\n */\n listInvalid(): Promise<InvalidComponent[]>;\n\n listIds(): Promise<ComponentID[]>;\n\n /**\n * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.\n * it uses multimatch (https://www.npmjs.com/package/multimatch) package for the matching algorithm, which supports\n * (among others) negate character \"!\" to exclude ids. See the package page for more supported characters.\n */\n idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;\n\n hasId(componentId: ComponentID): Promise<boolean>;\n\n /**\n * Check if the host has the id, if no, search for the id in inner host (for example, workspace will search in the scope)\n * @param componentId\n */\n hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;\n\n /**\n * whether a component is not the same as its head.\n * for a new component, it'll return \"true\" as it has no head yet.\n * this is relevant for component from the workspace, where it can be locally changed. on the scope it's always false\n */\n isModified(component: Component): Promise<boolean>;\n\n /**\n * write the component to the filesystem when applicable (no-op for scope).\n * to change the component-path, specify the \"rootPath\", which should be a relative path inside the workspace.\n */\n write(component: Component, rootPath?: string): Promise<void>;\n\n /**\n * determine whether host should be the prior one in case multiple hosts persist.\n */\n priority?: boolean;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["component-factory.ts"],"sourcesContent":["import { Graph } from '@teambit/graph.cleargraph';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { CompIdGraph } from '@teambit/graph';\nimport type { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component';\nimport type { AspectDefinition } from '@teambit/aspect-loader';\nimport { ComponentID } from '@teambit/component-id';\nimport { Component, InvalidComponent } from './component';\nimport { State } from './state';\nimport { Snap } from './snap';\n\nexport type ResolveAspectsOptions = FilterAspectsOptions & {\n throwOnError?: boolean;\n useScopeAspectsCapsule?: boolean;\n workspaceName?: string;\n};\n\nexport type LoadAspectsOptions = {\n /* `throwOnError` is an optional parameter that can be passed to the loadAspects method in the `ComponentFactory` interface. If\n set to `true`, it will cause the method to throw an error if an error occurs during its execution. If set to `false`\n or not provided, the method will print a warning instead of throwing it. */\n throwOnError?: boolean;\n /* `hideMissingModuleError` is an optional parameter that can be passed to the `loadAspects` method in the\n `ComponentFactory` interface. If set to `true`, it will prevent the method from throwing/printing an error if a required module\n is missing during the loading of an aspect. Instead, it will continue loading the other\n aspects. If set to `false` or not provided, the method will print/throw an error if a required module is missing.\n (considering throwOnError as well) */\n hideMissingModuleError?: boolean;\n\n /* The `ignoreErrors` property is an optional boolean parameter that can be passed to the `LoadAspectsOptions` object in\n the `ComponentFactory` interface. If set to `true`, it will cause the `loadAspects` method to ignore any errors that\n occur during the loading of aspects and continue loading the other aspects. If set to `false` or not provided, the\n method will print/throw an error if a required module is missing or if any other error occurs during the loading of\n aspects. */\n ignoreErrors?: boolean;\n [key: string]: any;\n};\n\nexport type FilterAspectsOptions = {\n /**\n * Do not return results for the core aspects\n */\n excludeCore?: boolean;\n /**\n * Only return results for the provided list of ids\n */\n requestedOnly?: boolean;\n /**\n * Only return results for aspects that have a path to the specified runtime name\n */\n filterByRuntime?: boolean;\n};\n\nexport interface ComponentFactory {\n /**\n * name of the component host.\n */\n name: string;\n\n /**\n * path to the component host.\n */\n path: string;\n\n isLegacy: boolean;\n\n /**\n * resolve a `string` component ID to an instance of a ComponentID.\n */\n resolveComponentId(id: string | ComponentID | BitId): Promise<ComponentID>;\n\n /**\n * resolve multiple `string` component ID to an instance of a ComponentID.\n */\n resolveMultipleComponentIds(ids: (string | ComponentID | BitId)[]): Promise<ComponentID[]>;\n\n /**\n * returns a component by ID.\n */\n get(id: ComponentID): Promise<Component | undefined>;\n\n /**\n * returns many components by ids.\n */\n getMany(ids: ComponentID[]): Promise<Component[]>;\n\n /**\n * returns many components by their legacy representation.\n */\n getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;\n\n /**\n * get a component from a remote without importing it\n */\n getRemoteComponent?: (id: ComponentID) => Promise<Component>;\n\n /**\n * important - prefer using `getGraphIds()` if you don't need the component objects.\n * this method has a performance penalty. it must import all flattened-dependencies objects from the remotes.\n */\n getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>;\n\n /**\n * get graph of the given component-ids and all their dependencies (recursively/flattened).\n * the nodes are ComponentIds and is much faster than `this.getGraph()`.\n */\n getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>;\n\n getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>;\n\n /**\n * returns a specific state of a component by hash or semver.\n */\n getState(id: ComponentID, snapId: string): Promise<State>;\n\n /**\n * returns a specific snap of a component by hash.\n */\n getSnap(id: ComponentID, snapId: string): Promise<Snap>;\n\n /**\n * load aspects.\n * returns the loaded aspect ids including the loaded versions.\n */\n loadAspects: (ids: string[], throwOnError?: boolean, neededFor?: string, opts?: any) => Promise<string[]>;\n\n /**\n * Resolve dirs for aspects\n */\n resolveAspects: (\n runtimeName?: string,\n componentIds?: ComponentID[],\n opts?: ResolveAspectsOptions\n ) => Promise<AspectDefinition[]>;\n\n /**\n * list all components in the host.\n */\n list(filter?: { offset: number; limit: number }): Promise<Component[]>;\n\n /**\n * list invalid components, such as components with missing files on the fs.\n */\n listInvalid(): Promise<InvalidComponent[]>;\n\n listIds(): Promise<ComponentID[]>;\n\n /**\n * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.\n * it uses multimatch (https://www.npmjs.com/package/multimatch) package for the matching algorithm, which supports\n * (among others) negate character \"!\" to exclude ids. See the package page for more supported characters.\n */\n idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;\n\n hasId(componentId: ComponentID): Promise<boolean>;\n\n /**\n * Check if the host has the id, if no, search for the id in inner host (for example, workspace will search in the scope)\n * @param componentId\n */\n hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;\n\n /**\n * whether a component is not the same as its head.\n * for a new component, it'll return \"true\" as it has no head yet.\n * this is relevant for component from the workspace, where it can be locally changed. on the scope it's always false\n */\n isModified(component: Component): Promise<boolean>;\n\n /**\n * write the component to the filesystem when applicable (no-op for scope).\n * to change the component-path, specify the \"rootPath\", which should be a relative path inside the workspace.\n */\n write(component: Component, rootPath?: string): Promise<void>;\n\n /**\n * determine whether host should be the prior one in case multiple hosts persist.\n */\n priority?: boolean;\n}\n"],"mappings":""}
|
|
@@ -51,6 +51,7 @@ export declare class ComponentUI {
|
|
|
51
51
|
* slot for registering a new widget to the menu.
|
|
52
52
|
*/
|
|
53
53
|
widgetSlot: OrderedNavigationSlot, menuItemSlot: MenuItemSlot, pageItemSlot: ComponentPageSlot, componentSearchResultSlot: ComponentSearchResultSlot, commandBarUI: CommandBarUI, reactRouterUi: ReactRouterUI);
|
|
54
|
+
get routes(): [string, RouteProps[]][];
|
|
54
55
|
/**
|
|
55
56
|
* the current visible component
|
|
56
57
|
*/
|
|
@@ -273,6 +273,9 @@ class ComponentUI {
|
|
|
273
273
|
});
|
|
274
274
|
if (_uiFoundationUi().isBrowser) this.registerPubSub();
|
|
275
275
|
}
|
|
276
|
+
get routes() {
|
|
277
|
+
return this.routeSlot.toArray().map(([key, routes]) => [key, Array.isArray(routes) ? [...(0, _lodash().default)(routes)] : [routes]]);
|
|
278
|
+
}
|
|
276
279
|
|
|
277
280
|
/**
|
|
278
281
|
* the current visible component
|
|
@@ -303,7 +306,8 @@ class ComponentUI {
|
|
|
303
306
|
path: options.path,
|
|
304
307
|
useComponent: options.useComponent,
|
|
305
308
|
componentIdStr: options.componentId,
|
|
306
|
-
useComponentFilters: options.useComponentFilters
|
|
309
|
+
useComponentFilters: options.useComponentFilters,
|
|
310
|
+
overriddenRoutes: options.routes
|
|
307
311
|
});
|
|
308
312
|
}
|
|
309
313
|
getMenu(host, options = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ComponentUI","constructor","pubsub","routeSlot","navSlot","consumeMethodSlot","widgetSlot","menuItemSlot","pageItemSlot","componentSearchResultSlot","commandBarUI","reactRouterUi","packageName","activeComponent","version","id","versionString","formatToInstallableVersion","copy","action","toString","displayName","keybinding","copyNpmId","category","title","keyChar","handler","run","comp","options","latest","packageVersion","Title","width","Component","ignoreVersion","name","currentLane","order","menuItems","register","items","totalPlugins","flatten","values","componentSearcher","updatePlugins","components","update","ComponentSearcher","navigate","navigateTo","isBrowser","registerPubSub","snapToSemver","sub","PreviewAspect","be","type","ClickInsideAnIframeEvent","TYPE","event","MouseEvent","view","window","bubbles","cancelable","body","document","dispatchEvent","getComponentUI","host","handleComponentChange","path","useComponent","componentId","useComponentFilters","getMenu","className","skipRightSide","RightNode","listMenuItems","mainMenuItems","groupBy","registerRoute","routes","registerNavigation","nav","props","registerConsumeMethod","consumeMethods","registerWidget","widget","provider","reactRouterUI","config","pageSlot","componentUI","aspectSection","AspectSection","registerSearchResultWidget","key","end","DeprecationIcon","commandBar","addCommand","keyBindings","addSearcher","registerMenuItem","route","navigationLink","bitMethod","PubsubAspect","CommandBarAspect","ReactRouterAspect","UIRuntime","Slot","withType","ComponentAspect","addRuntime"],"sources":["component.ui.runtime.tsx"],"sourcesContent":["import React from 'react';\nimport flatten from 'lodash.flatten';\nimport copy from 'copy-to-clipboard';\nimport type { RouteProps } from 'react-router-dom';\nimport type { LinkProps } from '@teambit/base-react.navigation.link';\nimport CommandBarAspect, { CommandBarUI, CommandEntry } from '@teambit/command-bar';\nimport { DeprecationIcon } from '@teambit/component.ui.deprecation-icon';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport PreviewAspect, { ClickInsideAnIframeEvent } from '@teambit/preview';\nimport PubsubAspect, { BitBaseEvent, PubsubUI } from '@teambit/pubsub';\nimport ReactRouterAspect, { ReactRouterUI } from '@teambit/react-router';\nimport { UIRuntime } from '@teambit/ui';\nimport { groupBy } from 'lodash';\nimport { isBrowser } from '@teambit/ui-foundation.ui.is-browser';\nimport { MenuItem, MenuItemSlot } from '@teambit/ui-foundation.ui.main-dropdown';\nimport { NavigationSlot, RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';\nimport { Import } from '@teambit/ui-foundation.ui.use-box.menu';\nimport { snapToSemver } from '@teambit/component-package-version';\nimport { AspectSection } from './aspect.section';\nimport { ComponentAspect } from './component.aspect';\nimport { ComponentModel } from './ui';\nimport { Component, ComponentPageElement, ComponentPageSlot } from './ui/component';\nimport { ComponentResultPlugin, ComponentSearcher } from './ui/component-searcher';\nimport { ConsumeMethodSlot, ConsumePlugin, ComponentMenu, NavPlugin, OrderedNavigationSlot } from './ui/menu';\nimport { GetComponentsOptions } from './get-component-opts';\n\nexport type ComponentSearchResultSlot = SlotRegistry<ComponentResultPlugin[]>;\n\nexport type ComponentUIConfig = {\n commandBar: boolean;\n};\n\nexport type Server = {\n env: string;\n url: string;\n};\n\nexport type ComponentMeta = {\n id: string;\n};\n\nexport class ComponentUI {\n readonly routePath = `/*`;\n private componentSearcher: ComponentSearcher;\n\n constructor(\n /**\n * Pubsub aspects\n */\n private pubsub: PubsubUI,\n\n private routeSlot: RouteSlot,\n\n private navSlot: OrderedNavigationSlot,\n\n readonly consumeMethodSlot: ConsumeMethodSlot,\n\n /**\n * slot for registering a new widget to the menu.\n */\n private widgetSlot: OrderedNavigationSlot,\n\n private menuItemSlot: MenuItemSlot,\n\n private pageItemSlot: ComponentPageSlot,\n\n private componentSearchResultSlot: ComponentSearchResultSlot,\n\n private commandBarUI: CommandBarUI,\n\n reactRouterUi: ReactRouterUI\n ) {\n this.componentSearcher = new ComponentSearcher({ navigate: reactRouterUi.navigateTo });\n if (isBrowser) this.registerPubSub();\n }\n\n /**\n * the current visible component\n */\n private activeComponent?: ComponentModel;\n\n formatToInstallableVersion(version: string) {\n return snapToSemver(version);\n }\n\n private copyNpmId = () => {\n const packageName = this.activeComponent?.packageName;\n if (packageName) {\n const version = this.activeComponent?.id.version;\n const versionString = version ? `@${this.formatToInstallableVersion(version)}` : '';\n copy(`${packageName}${versionString}`);\n }\n };\n\n /**\n * key bindings used by component aspect\n */\n private keyBindings: CommandEntry[] = [\n {\n id: 'component.copyBitId', // TODO - extract to a component!\n action: () => {\n copy(this.activeComponent?.id.toString() || '');\n },\n displayName: 'Copy component ID',\n keybinding: '.',\n },\n {\n id: 'component.copyNpmId', // TODO - extract to a component!\n action: this.copyNpmId,\n displayName: 'Copy component package name',\n keybinding: ',',\n },\n ];\n\n private menuItems: MenuItem[] = [\n {\n category: 'general',\n title: 'Open command bar',\n keyChar: 'mod+k',\n handler: () => this.commandBarUI?.run('command-bar.open'),\n },\n {\n category: 'general',\n title: 'Toggle component list',\n keyChar: 'alt+s',\n handler: () => this.commandBarUI?.run('sidebar.toggle'),\n },\n {\n category: 'workflow',\n title: 'Copy component ID',\n keyChar: '.',\n handler: () => this.commandBarUI?.run('component.copyBitId'),\n },\n {\n category: 'workflow',\n title: 'Copy component package name',\n keyChar: ',',\n handler: () => this.commandBarUI?.run('component.copyNpmId'),\n },\n ];\n\n private bitMethod: ConsumePlugin = (comp, options) => {\n const version = comp.version === comp.latest ? '' : `@${comp.version}`;\n const packageVersion = comp.version === comp.latest ? '' : `@${this.formatToInstallableVersion(comp.version)}`;\n\n return {\n Title: <img style={{ width: '20px' }} src=\"https://static.bit.dev/brands/bit-logo-text.svg\" />,\n Component: (\n <Import\n componentId={`${comp.id.toString({ ignoreVersion: true })}${version}`}\n packageName={`${comp.packageName}${packageVersion}`}\n componentName={comp.id.name}\n showInstallMethod={!options?.currentLane}\n />\n ),\n order: 0,\n };\n };\n\n registerPubSub() {\n this.pubsub.sub(PreviewAspect.id, (be: BitBaseEvent<any>) => {\n if (be.type === ClickInsideAnIframeEvent.TYPE) {\n const event = new MouseEvent('mousedown', {\n view: window,\n bubbles: true,\n cancelable: true,\n });\n\n const body = document.body;\n body?.dispatchEvent(event);\n }\n });\n }\n\n handleComponentChange = (activeComponent?: ComponentModel) => {\n this.activeComponent = activeComponent;\n };\n\n getComponentUI(host: string, options: GetComponentsOptions = {}) {\n return (\n <Component\n routeSlot={this.routeSlot}\n containerSlot={this.pageItemSlot}\n onComponentChange={this.handleComponentChange}\n host={host}\n path={options.path}\n useComponent={options.useComponent}\n componentIdStr={options.componentId}\n useComponentFilters={options.useComponentFilters}\n />\n );\n }\n\n getMenu(host: string, options: GetComponentsOptions = {}) {\n return (\n <ComponentMenu\n className={options.className}\n skipRightSide={options.skipRightSide}\n navigationSlot={this.navSlot}\n consumeMethodSlot={this.consumeMethodSlot}\n widgetSlot={this.widgetSlot}\n host={host}\n menuItemSlot={this.menuItemSlot}\n useComponent={options.useComponent}\n path={options.path}\n componentIdStr={options.componentId}\n useComponentFilters={options.useComponentFilters}\n RightNode={options.RightNode}\n />\n );\n }\n\n listMenuItems() {\n const mainMenuItems = groupBy(flatten(this.menuItemSlot.values()), 'category');\n return mainMenuItems;\n }\n\n registerRoute(routes: RouteProps[] | RouteProps) {\n this.routeSlot.register(routes);\n return this;\n }\n\n registerNavigation(nav: LinkProps, order?: number) {\n this.navSlot.register({\n props: nav,\n order,\n });\n }\n\n registerConsumeMethod(...consumeMethods: ConsumePlugin[]) {\n this.consumeMethodSlot.register(consumeMethods);\n }\n\n registerWidget(widget: LinkProps, order?: number) {\n this.widgetSlot.register({ props: widget, order });\n }\n\n registerMenuItem = (menuItems: MenuItem[]) => {\n this.menuItemSlot.register(menuItems);\n };\n\n registerPageItem = (...items: ComponentPageElement[]) => {\n this.pageItemSlot.register(items);\n };\n\n /** register widgets to the components listed in the command bar */\n registerSearchResultWidget = (...items: ComponentResultPlugin[]) => {\n this.componentSearchResultSlot.register(items);\n const totalPlugins = flatten(this.componentSearchResultSlot.values());\n\n this.componentSearcher.updatePlugins(totalPlugins);\n };\n\n updateComponents = (components: ComponentModel[]) => {\n this.componentSearcher.update(components || []);\n };\n\n static dependencies = [PubsubAspect, CommandBarAspect, ReactRouterAspect];\n\n static runtime = UIRuntime;\n\n static slots = [\n Slot.withType<RouteProps>(),\n Slot.withType<NavPlugin>(),\n Slot.withType<NavigationSlot>(),\n Slot.withType<ConsumeMethodSlot>(),\n Slot.withType<MenuItemSlot>(),\n Slot.withType<ComponentPageSlot>(),\n Slot.withType<ComponentSearchResultSlot>(),\n ];\n static defaultConfig: ComponentUIConfig = {\n commandBar: true,\n };\n\n static async provider(\n [pubsub, commandBarUI, reactRouterUI]: [PubsubUI, CommandBarUI, ReactRouterUI],\n config: ComponentUIConfig,\n [routeSlot, navSlot, consumeMethodSlot, widgetSlot, menuItemSlot, pageSlot, componentSearchResultSlot]: [\n RouteSlot,\n OrderedNavigationSlot,\n ConsumeMethodSlot,\n OrderedNavigationSlot,\n MenuItemSlot,\n ComponentPageSlot,\n ComponentSearchResultSlot\n ]\n ) {\n // TODO: refactor ComponentHost to a separate extension (including sidebar, host, graphql, etc.)\n // TODO: add contextual hook for ComponentHost @uri/@oded\n const componentUI = new ComponentUI(\n pubsub,\n routeSlot,\n navSlot,\n consumeMethodSlot,\n widgetSlot,\n menuItemSlot,\n pageSlot,\n componentSearchResultSlot,\n commandBarUI,\n reactRouterUI\n );\n const aspectSection = new AspectSection();\n // @ts-ignore\n componentUI.registerSearchResultWidget({ key: 'deprecation', end: DeprecationIcon });\n\n if (componentUI.commandBarUI && config.commandBar) {\n componentUI.commandBarUI.addCommand(...componentUI.keyBindings);\n commandBarUI.addSearcher(componentUI.componentSearcher);\n }\n\n componentUI.registerMenuItem(componentUI.menuItems);\n componentUI.registerRoute(aspectSection.route);\n componentUI.registerWidget(aspectSection.navigationLink, aspectSection.order);\n componentUI.registerConsumeMethod(componentUI.bitMethod);\n return componentUI;\n }\n}\n\nexport default ComponentUI;\n\nComponentAspect.addRuntime(ComponentUI);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;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E2D,WAAW,CAACR,qBAAqB,CAACQ,WAAW,CAACc,SAAS,CAAC;IACxD,OAAOd,WAAW;EACpB;AACF;AAAC;AAAA,gCAnRYlG,WAAW,kBAwNA,CAACiH,iBAAY,EAAEC,qBAAgB,EAAEC,sBAAiB,CAAC;AAAA,gCAxN9DnH,WAAW,aA0NLoH,eAAS;AAAA,gCA1NfpH,WAAW,WA4NP,CACbqH,eAAI,CAACC,QAAQ,EAAc,EAC3BD,eAAI,CAACC,QAAQ,EAAa,EAC1BD,eAAI,CAACC,QAAQ,EAAkB,EAC/BD,eAAI,CAACC,QAAQ,EAAqB,EAClCD,eAAI,CAACC,QAAQ,EAAgB,EAC7BD,eAAI,CAACC,QAAQ,EAAqB,EAClCD,eAAI,CAACC,QAAQ,EAA6B,CAC3C;AAAA,gCApOUtH,WAAW,mBAqOoB;EACxCyG,UAAU,EAAE;AACd,CAAC;AAAA,eA8CYzG,WAAW;AAAA;AAE1BuH,4BAAe,CAACC,UAAU,CAACxH,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"names":["ComponentUI","constructor","pubsub","routeSlot","navSlot","consumeMethodSlot","widgetSlot","menuItemSlot","pageItemSlot","componentSearchResultSlot","commandBarUI","reactRouterUi","packageName","activeComponent","version","id","versionString","formatToInstallableVersion","copy","action","toString","displayName","keybinding","copyNpmId","category","title","keyChar","handler","run","comp","options","latest","packageVersion","Title","width","Component","ignoreVersion","name","currentLane","order","menuItems","register","items","totalPlugins","flatten","values","componentSearcher","updatePlugins","components","update","ComponentSearcher","navigate","navigateTo","isBrowser","registerPubSub","routes","toArray","map","key","Array","isArray","snapToSemver","sub","PreviewAspect","be","type","ClickInsideAnIframeEvent","TYPE","event","MouseEvent","view","window","bubbles","cancelable","body","document","dispatchEvent","getComponentUI","host","handleComponentChange","path","useComponent","componentId","useComponentFilters","getMenu","className","skipRightSide","RightNode","listMenuItems","mainMenuItems","groupBy","registerRoute","registerNavigation","nav","props","registerConsumeMethod","consumeMethods","registerWidget","widget","provider","reactRouterUI","config","pageSlot","componentUI","aspectSection","AspectSection","registerSearchResultWidget","end","DeprecationIcon","commandBar","addCommand","keyBindings","addSearcher","registerMenuItem","route","navigationLink","bitMethod","PubsubAspect","CommandBarAspect","ReactRouterAspect","UIRuntime","Slot","withType","ComponentAspect","addRuntime"],"sources":["component.ui.runtime.tsx"],"sourcesContent":["import React from 'react';\nimport flatten from 'lodash.flatten';\nimport copy from 'copy-to-clipboard';\nimport type { RouteProps } from 'react-router-dom';\nimport type { LinkProps } from '@teambit/base-react.navigation.link';\nimport CommandBarAspect, { CommandBarUI, CommandEntry } from '@teambit/command-bar';\nimport { DeprecationIcon } from '@teambit/component.ui.deprecation-icon';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport PreviewAspect, { ClickInsideAnIframeEvent } from '@teambit/preview';\nimport PubsubAspect, { BitBaseEvent, PubsubUI } from '@teambit/pubsub';\nimport ReactRouterAspect, { ReactRouterUI } from '@teambit/react-router';\nimport { UIRuntime } from '@teambit/ui';\nimport { groupBy } from 'lodash';\nimport { isBrowser } from '@teambit/ui-foundation.ui.is-browser';\nimport { MenuItem, MenuItemSlot } from '@teambit/ui-foundation.ui.main-dropdown';\nimport { NavigationSlot, RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';\nimport { Import } from '@teambit/ui-foundation.ui.use-box.menu';\nimport { snapToSemver } from '@teambit/component-package-version';\nimport { AspectSection } from './aspect.section';\nimport { ComponentAspect } from './component.aspect';\nimport { ComponentModel } from './ui';\nimport { Component, ComponentPageElement, ComponentPageSlot } from './ui/component';\nimport { ComponentResultPlugin, ComponentSearcher } from './ui/component-searcher';\nimport { ConsumeMethodSlot, ConsumePlugin, ComponentMenu, NavPlugin, OrderedNavigationSlot } from './ui/menu';\nimport { GetComponentsOptions } from './get-component-opts';\n\nexport type ComponentSearchResultSlot = SlotRegistry<ComponentResultPlugin[]>;\n\nexport type ComponentUIConfig = {\n commandBar: boolean;\n};\n\nexport type Server = {\n env: string;\n url: string;\n};\n\nexport type ComponentMeta = {\n id: string;\n};\n\nexport class ComponentUI {\n readonly routePath = `/*`;\n private componentSearcher: ComponentSearcher;\n\n constructor(\n /**\n * Pubsub aspects\n */\n private pubsub: PubsubUI,\n\n private routeSlot: RouteSlot,\n\n private navSlot: OrderedNavigationSlot,\n\n readonly consumeMethodSlot: ConsumeMethodSlot,\n\n /**\n * slot for registering a new widget to the menu.\n */\n private widgetSlot: OrderedNavigationSlot,\n\n private menuItemSlot: MenuItemSlot,\n\n private pageItemSlot: ComponentPageSlot,\n\n private componentSearchResultSlot: ComponentSearchResultSlot,\n\n private commandBarUI: CommandBarUI,\n\n reactRouterUi: ReactRouterUI\n ) {\n this.componentSearcher = new ComponentSearcher({ navigate: reactRouterUi.navigateTo });\n if (isBrowser) this.registerPubSub();\n }\n\n get routes() {\n return this.routeSlot\n .toArray()\n .map(([key, routes]) => [key, Array.isArray(routes) ? [...flatten(routes)] : [routes]] as [string, RouteProps[]]);\n }\n\n /**\n * the current visible component\n */\n private activeComponent?: ComponentModel;\n\n formatToInstallableVersion(version: string) {\n return snapToSemver(version);\n }\n\n private copyNpmId = () => {\n const packageName = this.activeComponent?.packageName;\n if (packageName) {\n const version = this.activeComponent?.id.version;\n const versionString = version ? `@${this.formatToInstallableVersion(version)}` : '';\n copy(`${packageName}${versionString}`);\n }\n };\n\n /**\n * key bindings used by component aspect\n */\n private keyBindings: CommandEntry[] = [\n {\n id: 'component.copyBitId', // TODO - extract to a component!\n action: () => {\n copy(this.activeComponent?.id.toString() || '');\n },\n displayName: 'Copy component ID',\n keybinding: '.',\n },\n {\n id: 'component.copyNpmId', // TODO - extract to a component!\n action: this.copyNpmId,\n displayName: 'Copy component package name',\n keybinding: ',',\n },\n ];\n\n private menuItems: MenuItem[] = [\n {\n category: 'general',\n title: 'Open command bar',\n keyChar: 'mod+k',\n handler: () => this.commandBarUI?.run('command-bar.open'),\n },\n {\n category: 'general',\n title: 'Toggle component list',\n keyChar: 'alt+s',\n handler: () => this.commandBarUI?.run('sidebar.toggle'),\n },\n {\n category: 'workflow',\n title: 'Copy component ID',\n keyChar: '.',\n handler: () => this.commandBarUI?.run('component.copyBitId'),\n },\n {\n category: 'workflow',\n title: 'Copy component package name',\n keyChar: ',',\n handler: () => this.commandBarUI?.run('component.copyNpmId'),\n },\n ];\n\n private bitMethod: ConsumePlugin = (comp, options) => {\n const version = comp.version === comp.latest ? '' : `@${comp.version}`;\n const packageVersion = comp.version === comp.latest ? '' : `@${this.formatToInstallableVersion(comp.version)}`;\n\n return {\n Title: <img style={{ width: '20px' }} src=\"https://static.bit.dev/brands/bit-logo-text.svg\" />,\n Component: (\n <Import\n componentId={`${comp.id.toString({ ignoreVersion: true })}${version}`}\n packageName={`${comp.packageName}${packageVersion}`}\n componentName={comp.id.name}\n showInstallMethod={!options?.currentLane}\n />\n ),\n order: 0,\n };\n };\n\n registerPubSub() {\n this.pubsub.sub(PreviewAspect.id, (be: BitBaseEvent<any>) => {\n if (be.type === ClickInsideAnIframeEvent.TYPE) {\n const event = new MouseEvent('mousedown', {\n view: window,\n bubbles: true,\n cancelable: true,\n });\n\n const body = document.body;\n body?.dispatchEvent(event);\n }\n });\n }\n\n handleComponentChange = (activeComponent?: ComponentModel) => {\n this.activeComponent = activeComponent;\n };\n\n getComponentUI(host: string, options: GetComponentsOptions = {}) {\n return (\n <Component\n routeSlot={this.routeSlot}\n containerSlot={this.pageItemSlot}\n onComponentChange={this.handleComponentChange}\n host={host}\n path={options.path}\n useComponent={options.useComponent}\n componentIdStr={options.componentId}\n useComponentFilters={options.useComponentFilters}\n overriddenRoutes={options.routes}\n />\n );\n }\n\n getMenu(host: string, options: GetComponentsOptions = {}) {\n return (\n <ComponentMenu\n className={options.className}\n skipRightSide={options.skipRightSide}\n navigationSlot={this.navSlot}\n consumeMethodSlot={this.consumeMethodSlot}\n widgetSlot={this.widgetSlot}\n host={host}\n menuItemSlot={this.menuItemSlot}\n useComponent={options.useComponent}\n path={options.path}\n componentIdStr={options.componentId}\n useComponentFilters={options.useComponentFilters}\n RightNode={options.RightNode}\n />\n );\n }\n\n listMenuItems() {\n const mainMenuItems = groupBy(flatten(this.menuItemSlot.values()), 'category');\n return mainMenuItems;\n }\n\n registerRoute(routes: RouteProps[] | RouteProps) {\n this.routeSlot.register(routes);\n return this;\n }\n\n registerNavigation(nav: LinkProps, order?: number) {\n this.navSlot.register({\n props: nav,\n order,\n });\n }\n\n registerConsumeMethod(...consumeMethods: ConsumePlugin[]) {\n this.consumeMethodSlot.register(consumeMethods);\n }\n\n registerWidget(widget: LinkProps, order?: number) {\n this.widgetSlot.register({ props: widget, order });\n }\n\n registerMenuItem = (menuItems: MenuItem[]) => {\n this.menuItemSlot.register(menuItems);\n };\n\n registerPageItem = (...items: ComponentPageElement[]) => {\n this.pageItemSlot.register(items);\n };\n\n /** register widgets to the components listed in the command bar */\n registerSearchResultWidget = (...items: ComponentResultPlugin[]) => {\n this.componentSearchResultSlot.register(items);\n const totalPlugins = flatten(this.componentSearchResultSlot.values());\n\n this.componentSearcher.updatePlugins(totalPlugins);\n };\n\n updateComponents = (components: ComponentModel[]) => {\n this.componentSearcher.update(components || []);\n };\n\n static dependencies = [PubsubAspect, CommandBarAspect, ReactRouterAspect];\n\n static runtime = UIRuntime;\n\n static slots = [\n Slot.withType<RouteProps>(),\n Slot.withType<NavPlugin>(),\n Slot.withType<NavigationSlot>(),\n Slot.withType<ConsumeMethodSlot>(),\n Slot.withType<MenuItemSlot>(),\n Slot.withType<ComponentPageSlot>(),\n Slot.withType<ComponentSearchResultSlot>(),\n ];\n static defaultConfig: ComponentUIConfig = {\n commandBar: true,\n };\n\n static async provider(\n [pubsub, commandBarUI, reactRouterUI]: [PubsubUI, CommandBarUI, ReactRouterUI],\n config: ComponentUIConfig,\n [routeSlot, navSlot, consumeMethodSlot, widgetSlot, menuItemSlot, pageSlot, componentSearchResultSlot]: [\n RouteSlot,\n OrderedNavigationSlot,\n ConsumeMethodSlot,\n OrderedNavigationSlot,\n MenuItemSlot,\n ComponentPageSlot,\n ComponentSearchResultSlot\n ]\n ) {\n // TODO: refactor ComponentHost to a separate extension (including sidebar, host, graphql, etc.)\n // TODO: add contextual hook for ComponentHost @uri/@oded\n const componentUI = new ComponentUI(\n pubsub,\n routeSlot,\n navSlot,\n consumeMethodSlot,\n widgetSlot,\n menuItemSlot,\n pageSlot,\n componentSearchResultSlot,\n commandBarUI,\n reactRouterUI\n );\n const aspectSection = new AspectSection();\n // @ts-ignore\n componentUI.registerSearchResultWidget({ key: 'deprecation', end: DeprecationIcon });\n\n if (componentUI.commandBarUI && config.commandBar) {\n componentUI.commandBarUI.addCommand(...componentUI.keyBindings);\n commandBarUI.addSearcher(componentUI.componentSearcher);\n }\n\n componentUI.registerMenuItem(componentUI.menuItems);\n componentUI.registerRoute(aspectSection.route);\n componentUI.registerWidget(aspectSection.navigationLink, aspectSection.order);\n componentUI.registerConsumeMethod(componentUI.bitMethod);\n return componentUI;\n }\n}\n\nexport default ComponentUI;\n\nComponentAspect.addRuntime(ComponentUI);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EA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GP,WAAW,CAACQ,WAAW,CAAC;MAC/DrG,YAAY,CAACsG,WAAW,CAACT,WAAW,CAACzD,iBAAiB,CAAC;IACzD;IAEAyD,WAAW,CAACU,gBAAgB,CAACV,WAAW,CAAC/D,SAAS,CAAC;IACnD+D,WAAW,CAACZ,aAAa,CAACa,aAAa,CAACU,KAAK,CAAC;IAC9CX,WAAW,CAACN,cAAc,CAACO,aAAa,CAACW,cAAc,EAAEX,aAAa,CAACjE,KAAK,CAAC;IAC7EgE,WAAW,CAACR,qBAAqB,CAACQ,WAAW,CAACa,SAAS,CAAC;IACxD,OAAOb,WAAW;EACpB;AACF;AAAC;AAAA,gCA1RYvG,WAAW,kBA+NA,CAACqH,iBAAY,EAAEC,qBAAgB,EAAEC,sBAAiB,CAAC;AAAA,gCA/N9DvH,WAAW,aAiOLwH,eAAS;AAAA,gCAjOfxH,WAAW,WAmOP,CACbyH,eAAI,CAACC,QAAQ,EAAc,EAC3BD,eAAI,CAACC,QAAQ,EAAa,EAC1BD,eAAI,CAACC,QAAQ,EAAkB,EAC/BD,eAAI,CAACC,QAAQ,EAAqB,EAClCD,eAAI,CAACC,QAAQ,EAAgB,EAC7BD,eAAI,CAACC,QAAQ,EAAqB,EAClCD,eAAI,CAACC,QAAQ,EAA6B,CAC3C;AAAA,gCA3OU1H,WAAW,mBA4OoB;EACxC6G,UAAU,EAAE;AACd,CAAC;AAAA,eA8CY7G,WAAW;AAAA;AAE1B2H,4BAAe,CAACC,UAAU,CAAC5H,WAAW,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { RouteProps } from 'react-router-dom';
|
|
2
3
|
import type { UseComponentType } from './ui/use-component';
|
|
3
4
|
import { Filters } from './ui/use-component-query';
|
|
4
5
|
export declare type GetComponentsOptions = {
|
|
@@ -9,4 +10,5 @@ export declare type GetComponentsOptions = {
|
|
|
9
10
|
skipRightSide?: boolean;
|
|
10
11
|
RightNode?: React.ReactNode;
|
|
11
12
|
className?: string;
|
|
13
|
+
routes?: RouteProps[];
|
|
12
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["get-component-opts.ts"],"sourcesContent":["import React from 'react';\nimport type { UseComponentType } from './ui/use-component';\nimport { Filters } from './ui/use-component-query';\n\nexport type GetComponentsOptions = {\n useComponent?: UseComponentType;\n componentId?: string | (() => string | undefined);\n useComponentFilters?: () => Filters;\n path?: string;\n skipRightSide?: boolean;\n RightNode?: React.ReactNode;\n className?: string;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["get-component-opts.ts"],"sourcesContent":["import React from 'react';\nimport { RouteProps } from 'react-router-dom';\nimport type { UseComponentType } from './ui/use-component';\nimport { Filters } from './ui/use-component-query';\n\nexport type GetComponentsOptions = {\n useComponent?: UseComponentType;\n componentId?: string | (() => string | undefined);\n useComponentFilters?: () => Filters;\n path?: string;\n skipRightSide?: boolean;\n RightNode?: React.ReactNode;\n className?: string;\n routes?: RouteProps[];\n};\n"],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { Component, InvalidComponent } from './component';
|
|
|
6
6
|
export { ComponentID } from '@teambit/component-id';
|
|
7
7
|
export { default as ComponentFS } from './component-fs';
|
|
8
8
|
export type { default as ComponentConfig } from './config';
|
|
9
|
-
export type { ComponentFactory, ResolveAspectsOptions, FilterAspectsOptions } from './component-factory';
|
|
9
|
+
export type { ComponentFactory, ResolveAspectsOptions, FilterAspectsOptions, LoadAspectsOptions, } from './component-factory';
|
|
10
10
|
export type { AspectList } from './aspect-list';
|
|
11
11
|
export { AspectEntry, AspectData, ResolveComponentIdFunc } from './aspect-entry';
|
|
12
12
|
export { Snap, SnapProps } from './snap/snap';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ComponentAspect"],"sources":["index.ts"],"sourcesContent":["import { ComponentAspect } from './component.aspect';\n\nexport type { GetComponentsOptions } from './get-component-opts';\nexport type { UseComponentType } from './ui/use-component';\nexport { useComponentHost } from './host';\nexport { Component, InvalidComponent } from './component';\nexport { ComponentID } from '@teambit/component-id';\nexport { default as ComponentFS } from './component-fs';\nexport type { default as ComponentConfig } from './config';\nexport type {
|
|
1
|
+
{"version":3,"names":["ComponentAspect"],"sources":["index.ts"],"sourcesContent":["import { ComponentAspect } from './component.aspect';\n\nexport type { GetComponentsOptions } from './get-component-opts';\nexport type { UseComponentType } from './ui/use-component';\nexport { useComponentHost } from './host';\nexport { Component, InvalidComponent } from './component';\nexport { ComponentID } from '@teambit/component-id';\nexport { default as ComponentFS } from './component-fs';\nexport type { default as ComponentConfig } from './config';\nexport type {\n ComponentFactory,\n ResolveAspectsOptions,\n FilterAspectsOptions,\n LoadAspectsOptions,\n} from './component-factory';\nexport type { AspectList } from './aspect-list';\nexport { AspectEntry, AspectData, ResolveComponentIdFunc } from './aspect-entry';\n// TODO: check why it's not working when using the index in snap dir like this:\n// export { Snap, Author } from './snap';\nexport { Snap, SnapProps } from './snap/snap';\nexport type { Author } from './snap/author';\n// TODO: check why it's not working when using the index in tag dir like this:\n// export { Tag } from './tag';\nexport { Tag, TagProps } from './tag/tag';\nexport type { IComponent } from './component-interface';\nexport { State } from './state';\nexport type { Hash } from './hash';\nexport { TagMap } from './tag-map';\nexport { ComponentMap } from './component-map';\nexport type { ComponentMain } from './component.main.runtime';\nexport type { ComponentUI } from './component.ui.runtime';\nexport { Section } from './section';\nexport { ComponentContext, ComponentDescriptorContext, useComponentDescriptor } from './ui/context/component-context';\nexport type { ComponentProviderProps, ComponentDescriptorProviderProps } from './ui/context';\nexport { ComponentProvider, ComponentDescriptorProvider } from './ui/context';\nexport { componentFields, componentIdFields, componentOverviewFields } from './ui';\nexport {\n NavPlugin,\n ConsumePlugin,\n CollapsibleMenuNav,\n MenuNavProps,\n ComponentMenu,\n VersionRelatedDropdowns,\n} from './ui/menu';\nexport { RegisteredComponentRoute, ComponentUrlParams } from './component.route';\nexport { ComponentModel, ComponentModelProps } from './ui/component-model';\nexport { TopBarNav } from './ui/top-bar-nav';\nexport type { ShowFragment, ShowRow, ShowJSONRow } from './show';\nexport { default as Config } from './config';\nexport { useComponent, useIdFromLocation } from './ui';\n\n// export { AspectList } from './aspect-list';\n// export { AspectEntry } from './aspect-entry';\nexport { ComponentAspect };\nexport default ComponentAspect;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AASA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AA/BA;AACA;AAGA;AACA;AA6BA;AACA;AAAA,eAEeA,4BAAe;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.1039/dist/component.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.1039/dist/component.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/dist/ui/component.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { RouteProps } from 'react-router-dom';
|
|
2
3
|
import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
3
4
|
import { SlotRegistry } from '@teambit/harmony';
|
|
4
5
|
import { UseComponentType } from './use-component';
|
|
@@ -12,6 +13,7 @@ export declare type ComponentPageElement = {
|
|
|
12
13
|
export declare type ComponentProps = {
|
|
13
14
|
containerSlot?: ComponentPageSlot;
|
|
14
15
|
routeSlot: RouteSlot;
|
|
16
|
+
overriddenRoutes?: RouteProps[];
|
|
15
17
|
host: string;
|
|
16
18
|
onComponentChange?: (activeComponent?: ComponentModel) => void;
|
|
17
19
|
useComponent?: UseComponentType;
|
|
@@ -22,4 +24,4 @@ export declare type ComponentProps = {
|
|
|
22
24
|
/**
|
|
23
25
|
* main UI component of the Component extension.
|
|
24
26
|
*/
|
|
25
|
-
export declare function Component({ routeSlot, containerSlot, host, onComponentChange, componentIdStr, useComponent, path, useComponentFilters, }: ComponentProps): JSX.Element;
|
|
27
|
+
export declare function Component({ routeSlot, overriddenRoutes, containerSlot, host, onComponentChange, componentIdStr, useComponent, path, useComponentFilters, }: ComponentProps): JSX.Element;
|
package/dist/ui/component.js
CHANGED
|
@@ -81,6 +81,7 @@ function getComponentIdStr(componentIdStr) {
|
|
|
81
81
|
*/
|
|
82
82
|
function Component({
|
|
83
83
|
routeSlot,
|
|
84
|
+
overriddenRoutes,
|
|
84
85
|
containerSlot,
|
|
85
86
|
host,
|
|
86
87
|
onComponentChange,
|
|
@@ -119,7 +120,8 @@ function Component({
|
|
|
119
120
|
className: _componentModule().default.container
|
|
120
121
|
}, routeSlot && /*#__PURE__*/_react().default.createElement(_uiFoundationUiReactRouter().SlotRouter, {
|
|
121
122
|
parentPath: `${resolvedComponentIdStr}/*`,
|
|
122
|
-
slot: routeSlot
|
|
123
|
+
slot: routeSlot,
|
|
124
|
+
routes: overriddenRoutes
|
|
123
125
|
})), after));
|
|
124
126
|
}
|
|
125
127
|
|
package/dist/ui/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getComponentIdStr","componentIdStr","isFunction","Component","routeSlot","containerSlot","host","onComponentChange","useComponent","path","useComponentFilters","idFromLocation","useIdFromLocation","_componentIdStr","componentId","ComponentID","fromString","undefined","resolvedComponentIdStr","useComponentOptions","logFilters","customUseComponent","component","componentDescriptor","error","useComponentQuery","toString","useEffect","pageItems","useMemo","flatten","values","before","filter","x","type","map","content","after","renderError","styles","container"],"sources":["component.tsx"],"sourcesContent":["import React, { useEffect, ReactNode, useMemo } from 'react';\nimport flatten from 'lodash.flatten';\nimport { RouteSlot, SlotRouter } from '@teambit/ui-foundation.ui.react-router.slot-router';\nimport { SlotRegistry } from '@teambit/harmony';\nimport { isFunction } from 'lodash';\nimport styles from './component.module.scss';\nimport { ComponentProvider, ComponentDescriptorProvider } from './context';\nimport { useComponent as useComponentQuery, UseComponentType } from './use-component';\nimport { ComponentModel } from './component-model';\nimport { useIdFromLocation } from './use-component-from-location';\nimport { ComponentID } from '..';\nimport { Filters } from './use-component-query';\n\nexport type ComponentPageSlot = SlotRegistry<ComponentPageElement[]>;\nexport type ComponentPageElement = {\n type: 'before' | 'after';\n content: ReactNode;\n};\n\nexport type ComponentProps = {\n containerSlot?: ComponentPageSlot;\n routeSlot: RouteSlot;\n host: string;\n onComponentChange?: (activeComponent?: ComponentModel) => void;\n useComponent?: UseComponentType;\n useComponentFilters?: () => Filters;\n path?: string;\n componentIdStr?: string | (() => string | undefined);\n};\n\nfunction getComponentIdStr(componentIdStr?: string | (() => string | undefined)): string | undefined {\n if (isFunction(componentIdStr)) return componentIdStr();\n return componentIdStr;\n}\n\n/**\n * main UI component of the Component extension.\n */\nexport function Component({\n routeSlot,\n containerSlot,\n host,\n onComponentChange,\n componentIdStr,\n useComponent,\n path,\n useComponentFilters,\n}: ComponentProps) {\n const idFromLocation = useIdFromLocation();\n const _componentIdStr = getComponentIdStr(componentIdStr);\n const componentId = _componentIdStr ? ComponentID.fromString(_componentIdStr) : undefined;\n const resolvedComponentIdStr = path || idFromLocation;\n const useComponentOptions = {\n logFilters: useComponentFilters?.(),\n customUseComponent: useComponent,\n };\n\n const { component, componentDescriptor, error } = useComponentQuery(\n host,\n componentId?.toString() || idFromLocation,\n useComponentOptions\n );\n // trigger onComponentChange when component changes\n useEffect(() => onComponentChange?.(component), [component]);\n // cleanup when unmounting component\n useEffect(() => () => onComponentChange?.(undefined), []);\n\n const pageItems = useMemo(() => flatten(containerSlot?.values()), [containerSlot]);\n const before = useMemo(() => pageItems.filter((x) => x.type === 'before').map((x) => x.content), [pageItems]);\n const after = useMemo(() => pageItems.filter((x) => x.type === 'after').map((x) => x.content), [pageItems]);\n\n if (error) return error.renderError();\n if (!component) return <div></div>;\n\n return (\n <ComponentDescriptorProvider componentDescriptor={componentDescriptor}>\n <ComponentProvider component={component}>\n {before}\n <div className={styles.container}>\n {routeSlot && <SlotRouter parentPath={`${resolvedComponentIdStr}/*`} slot={routeSlot}
|
|
1
|
+
{"version":3,"names":["getComponentIdStr","componentIdStr","isFunction","Component","routeSlot","overriddenRoutes","containerSlot","host","onComponentChange","useComponent","path","useComponentFilters","idFromLocation","useIdFromLocation","_componentIdStr","componentId","ComponentID","fromString","undefined","resolvedComponentIdStr","useComponentOptions","logFilters","customUseComponent","component","componentDescriptor","error","useComponentQuery","toString","useEffect","pageItems","useMemo","flatten","values","before","filter","x","type","map","content","after","renderError","styles","container"],"sources":["component.tsx"],"sourcesContent":["import React, { useEffect, ReactNode, useMemo } from 'react';\nimport { RouteProps } from 'react-router-dom';\nimport flatten from 'lodash.flatten';\nimport { RouteSlot, SlotRouter } from '@teambit/ui-foundation.ui.react-router.slot-router';\nimport { SlotRegistry } from '@teambit/harmony';\nimport { isFunction } from 'lodash';\nimport styles from './component.module.scss';\nimport { ComponentProvider, ComponentDescriptorProvider } from './context';\nimport { useComponent as useComponentQuery, UseComponentType } from './use-component';\nimport { ComponentModel } from './component-model';\nimport { useIdFromLocation } from './use-component-from-location';\nimport { ComponentID } from '..';\nimport { Filters } from './use-component-query';\n\nexport type ComponentPageSlot = SlotRegistry<ComponentPageElement[]>;\nexport type ComponentPageElement = {\n type: 'before' | 'after';\n content: ReactNode;\n};\n\nexport type ComponentProps = {\n containerSlot?: ComponentPageSlot;\n routeSlot: RouteSlot;\n overriddenRoutes?: RouteProps[];\n host: string;\n onComponentChange?: (activeComponent?: ComponentModel) => void;\n useComponent?: UseComponentType;\n useComponentFilters?: () => Filters;\n path?: string;\n componentIdStr?: string | (() => string | undefined);\n};\n\nfunction getComponentIdStr(componentIdStr?: string | (() => string | undefined)): string | undefined {\n if (isFunction(componentIdStr)) return componentIdStr();\n return componentIdStr;\n}\n\n/**\n * main UI component of the Component extension.\n */\nexport function Component({\n routeSlot,\n overriddenRoutes,\n containerSlot,\n host,\n onComponentChange,\n componentIdStr,\n useComponent,\n path,\n useComponentFilters,\n}: ComponentProps) {\n const idFromLocation = useIdFromLocation();\n const _componentIdStr = getComponentIdStr(componentIdStr);\n const componentId = _componentIdStr ? ComponentID.fromString(_componentIdStr) : undefined;\n const resolvedComponentIdStr = path || idFromLocation;\n const useComponentOptions = {\n logFilters: useComponentFilters?.(),\n customUseComponent: useComponent,\n };\n\n const { component, componentDescriptor, error } = useComponentQuery(\n host,\n componentId?.toString() || idFromLocation,\n useComponentOptions\n );\n // trigger onComponentChange when component changes\n useEffect(() => onComponentChange?.(component), [component]);\n // cleanup when unmounting component\n useEffect(() => () => onComponentChange?.(undefined), []);\n\n const pageItems = useMemo(() => flatten(containerSlot?.values()), [containerSlot]);\n const before = useMemo(() => pageItems.filter((x) => x.type === 'before').map((x) => x.content), [pageItems]);\n const after = useMemo(() => pageItems.filter((x) => x.type === 'after').map((x) => x.content), [pageItems]);\n\n if (error) return error.renderError();\n if (!component) return <div></div>;\n\n return (\n <ComponentDescriptorProvider componentDescriptor={componentDescriptor}>\n <ComponentProvider component={component}>\n {before}\n <div className={styles.container}>\n {routeSlot && (\n <SlotRouter parentPath={`${resolvedComponentIdStr}/*`} slot={routeSlot} routes={overriddenRoutes} />\n )}\n </div>\n {after}\n </ComponentProvider>\n </ComponentDescriptorProvider>\n );\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AA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;EAEzD,MAAMW,SAAS,GAAG,IAAAC,gBAAO,EAAC,MAAM,IAAAC,iBAAO,EAACzB,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAE0B,MAAM,EAAE,CAAC,EAAE,CAAC1B,aAAa,CAAC,CAAC;EAClF,MAAM2B,MAAM,GAAG,IAAAH,gBAAO,EAAC,MAAMD,SAAS,CAACK,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAK,QAAQ,CAAC,CAACC,GAAG,CAAEF,CAAC,IAAKA,CAAC,CAACG,OAAO,CAAC,EAAE,CAACT,SAAS,CAAC,CAAC;EAC7G,MAAMU,KAAK,GAAG,IAAAT,gBAAO,EAAC,MAAMD,SAAS,CAACK,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAK,OAAO,CAAC,CAACC,GAAG,CAAEF,CAAC,IAAKA,CAAC,CAACG,OAAO,CAAC,EAAE,CAACT,SAAS,CAAC,CAAC;EAE3G,IAAIJ,KAAK,EAAE,OAAOA,KAAK,CAACe,WAAW,EAAE;EACrC,IAAI,CAACjB,SAAS,EAAE,oBAAO,2CAAW;EAElC,oBACE,+BAAC,sCAA2B;IAAC,mBAAmB,EAAEC;EAAoB,gBACpE,+BAAC,4BAAiB;IAAC,SAAS,EAAED;EAAU,GACrCU,MAAM,eACP;IAAK,SAAS,EAAEQ,0BAAM,CAACC;EAAU,GAC9BtC,SAAS,iBACR,+BAAC,uCAAU;IAAC,UAAU,EAAG,GAAEe,sBAAuB,IAAI;IAAC,IAAI,EAAEf,SAAU;IAAC,MAAM,EAAEC;EAAiB,EAClG,CACG,EACLkC,KAAK,CACY,CACQ;AAElC"}
|
|
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.1039",
|
|
4
4
|
"homepage": "https://bit.cloud/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.1039"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/any-fs": "0.0.5",
|
|
@@ -36,39 +36,39 @@
|
|
|
36
36
|
"@teambit/design.navigation.responsive-navbar": "0.0.5",
|
|
37
37
|
"@teambit/base-ui.layout.breakpoints": "1.0.0",
|
|
38
38
|
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.497",
|
|
39
|
-
"@teambit/aspect-loader": "0.0.
|
|
40
|
-
"@teambit/graph": "0.0.
|
|
39
|
+
"@teambit/aspect-loader": "0.0.1039",
|
|
40
|
+
"@teambit/graph": "0.0.1039",
|
|
41
41
|
"@teambit/toolbox.path.match-patterns": "0.0.9",
|
|
42
42
|
"@teambit/toolbox.string.capitalize": "0.0.490",
|
|
43
|
-
"@teambit/cli": "0.0.
|
|
44
|
-
"@teambit/express": "0.0.
|
|
45
|
-
"@teambit/graphql": "0.0.
|
|
43
|
+
"@teambit/cli": "0.0.699",
|
|
44
|
+
"@teambit/express": "0.0.797",
|
|
45
|
+
"@teambit/graphql": "0.0.1039",
|
|
46
46
|
"@teambit/bit-error": "0.0.402",
|
|
47
|
-
"@teambit/command-bar": "0.0.
|
|
47
|
+
"@teambit/command-bar": "0.0.1039",
|
|
48
48
|
"@teambit/component-package-version": "0.0.422",
|
|
49
49
|
"@teambit/component.ui.deprecation-icon": "0.0.504",
|
|
50
|
-
"@teambit/preview": "0.0.
|
|
51
|
-
"@teambit/pubsub": "0.0.
|
|
52
|
-
"@teambit/react-router": "0.0.
|
|
50
|
+
"@teambit/preview": "0.0.1039",
|
|
51
|
+
"@teambit/pubsub": "0.0.1039",
|
|
52
|
+
"@teambit/react-router": "0.0.1039",
|
|
53
53
|
"@teambit/ui-foundation.ui.is-browser": "0.0.495",
|
|
54
54
|
"@teambit/ui-foundation.ui.main-dropdown": "0.0.497",
|
|
55
55
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.501",
|
|
56
56
|
"@teambit/ui-foundation.ui.use-box.menu": "0.0.133",
|
|
57
|
-
"@teambit/ui": "0.0.
|
|
57
|
+
"@teambit/ui": "0.0.1039",
|
|
58
58
|
"@teambit/component-issues": "0.0.89",
|
|
59
59
|
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.500",
|
|
60
60
|
"@teambit/cli-table": "0.0.41",
|
|
61
|
-
"@teambit/component-descriptor": "0.0.
|
|
61
|
+
"@teambit/component-descriptor": "0.0.268",
|
|
62
62
|
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.496",
|
|
63
63
|
"@teambit/harmony.ui.aspect-box": "0.0.497",
|
|
64
|
-
"@teambit/compositions": "0.0.
|
|
65
|
-
"@teambit/deprecation": "0.0.
|
|
66
|
-
"@teambit/envs": "0.0.
|
|
64
|
+
"@teambit/compositions": "0.0.1039",
|
|
65
|
+
"@teambit/deprecation": "0.0.1039",
|
|
66
|
+
"@teambit/envs": "0.0.1039",
|
|
67
67
|
"@teambit/legacy-component-log": "0.0.399",
|
|
68
68
|
"@teambit/envs.ui.env-icon": "0.0.495",
|
|
69
|
-
"@teambit/component.ui.version-dropdown": "0.0.
|
|
70
|
-
"@teambit/lanes.hooks.use-lanes": "0.0.
|
|
71
|
-
"@teambit/lanes.ui.models.lanes-model": "0.0.
|
|
69
|
+
"@teambit/component.ui.version-dropdown": "0.0.756",
|
|
70
|
+
"@teambit/lanes.hooks.use-lanes": "0.0.162",
|
|
71
|
+
"@teambit/lanes.ui.models.lanes-model": "0.0.115",
|
|
72
72
|
"@teambit/ui-foundation.ui.full-loader": "0.0.495",
|
|
73
73
|
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.132"
|
|
74
74
|
},
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"@apollo/client": "^3.6.0",
|
|
91
91
|
"react-router-dom": "^6.0.0",
|
|
92
|
-
"@teambit/legacy": "1.0.
|
|
92
|
+
"@teambit/legacy": "1.0.479",
|
|
93
93
|
"react": "^16.8.0 || ^17.0.0",
|
|
94
94
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
95
95
|
},
|
package/ui/component.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, ReactNode, useMemo } from 'react';
|
|
2
|
+
import { RouteProps } from 'react-router-dom';
|
|
2
3
|
import flatten from 'lodash.flatten';
|
|
3
4
|
import { RouteSlot, SlotRouter } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
4
5
|
import { SlotRegistry } from '@teambit/harmony';
|
|
@@ -20,6 +21,7 @@ export type ComponentPageElement = {
|
|
|
20
21
|
export type ComponentProps = {
|
|
21
22
|
containerSlot?: ComponentPageSlot;
|
|
22
23
|
routeSlot: RouteSlot;
|
|
24
|
+
overriddenRoutes?: RouteProps[];
|
|
23
25
|
host: string;
|
|
24
26
|
onComponentChange?: (activeComponent?: ComponentModel) => void;
|
|
25
27
|
useComponent?: UseComponentType;
|
|
@@ -38,6 +40,7 @@ function getComponentIdStr(componentIdStr?: string | (() => string | undefined))
|
|
|
38
40
|
*/
|
|
39
41
|
export function Component({
|
|
40
42
|
routeSlot,
|
|
43
|
+
overriddenRoutes,
|
|
41
44
|
containerSlot,
|
|
42
45
|
host,
|
|
43
46
|
onComponentChange,
|
|
@@ -77,7 +80,9 @@ export function Component({
|
|
|
77
80
|
<ComponentProvider component={component}>
|
|
78
81
|
{before}
|
|
79
82
|
<div className={styles.container}>
|
|
80
|
-
{routeSlot &&
|
|
83
|
+
{routeSlot && (
|
|
84
|
+
<SlotRouter parentPath={`${resolvedComponentIdStr}/*`} slot={routeSlot} routes={overriddenRoutes} />
|
|
85
|
+
)}
|
|
81
86
|
</div>
|
|
82
87
|
{after}
|
|
83
88
|
</ComponentProvider>
|
|
Binary file
|