@teambit/component 1.0.106 → 1.0.108
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-entry.ts +73 -0
- package/aspect-list.ts +132 -0
- package/component-factory.ts +190 -0
- package/component-fs.ts +66 -0
- package/component-interface.ts +26 -0
- package/component-meta.ts +29 -0
- package/component.aspect.ts +9 -0
- package/component.graphql.ts +256 -0
- package/component.main.runtime.ts +170 -0
- package/component.route.ts +38 -0
- package/component.ts +319 -0
- package/config.ts +24 -0
- package/dist/aspect-entry.d.ts +4 -4
- package/dist/aspect-entry.js +1 -2
- package/dist/aspect-entry.js.map +1 -1
- package/dist/aspect-list.js +2 -2
- package/dist/aspect-list.js.map +1 -1
- package/dist/aspect.section.d.ts +3 -3
- package/dist/component-factory.d.ts +3 -3
- package/dist/component-interface.d.ts +1 -1
- package/dist/component-map/component-map.d.ts +2 -2
- package/dist/component.composition.d.ts +2 -2
- package/dist/component.d.ts +3 -3
- package/dist/component.graphql.d.ts +13 -13
- package/dist/component.graphql.js +3 -6
- package/dist/component.graphql.js.map +1 -1
- package/dist/component.js +5 -9
- package/dist/component.js.map +1 -1
- package/dist/component.main.runtime.d.ts +2 -2
- package/dist/component.route.d.ts +2 -2
- package/dist/component.ui.runtime.d.ts +7 -7
- package/dist/component.ui.runtime.js +12 -27
- package/dist/component.ui.runtime.js.map +1 -1
- package/dist/get-component-opts.d.ts +1 -1
- package/dist/hash.d.ts +1 -1
- package/dist/{preview-1703505948637.js → preview-1703647408454.js} +2 -2
- package/dist/snap/author.d.ts +1 -1
- package/dist/snap/snap.d.ts +1 -1
- package/dist/tag/tag.d.ts +1 -1
- package/dist/tag-map.d.ts +1 -1
- package/dist/ui/aspect-page/aspect-page.d.ts +2 -2
- package/dist/ui/aspect-page/aspect-page.js +1 -2
- package/dist/ui/aspect-page/aspect-page.js.map +1 -1
- package/dist/ui/component-error/component-error.d.ts +4 -4
- package/dist/ui/component-model/component-model.d.ts +21 -21
- package/dist/ui/component-model/component-model.js +1 -1
- package/dist/ui/component-model/component-model.js.map +1 -1
- package/dist/ui/component-searcher/component-result.d.ts +4 -4
- package/dist/ui/component-searcher/component-result.js +2 -2
- package/dist/ui/component-searcher/component-result.js.map +1 -1
- package/dist/ui/component-searcher/component-searcher.d.ts +2 -2
- package/dist/ui/component.d.ts +5 -5
- package/dist/ui/component.js +6 -6
- package/dist/ui/component.js.map +1 -1
- package/dist/ui/context/component-context.d.ts +1 -1
- package/dist/ui/context/component-provider.d.ts +5 -5
- package/dist/ui/menu/menu-nav.d.ts +2 -2
- package/dist/ui/menu/menu-nav.js +5 -5
- package/dist/ui/menu/menu-nav.js.map +1 -1
- package/dist/ui/menu/menu.d.ts +9 -9
- package/dist/ui/menu/menu.js +28 -31
- package/dist/ui/menu/menu.js.map +1 -1
- package/dist/ui/menu/nav-plugin.d.ts +7 -7
- package/dist/ui/top-bar-nav/top-bar-nav.d.ts +2 -2
- package/dist/ui/use-component-from-location.js +1 -1
- package/dist/ui/use-component-from-location.js.map +1 -1
- package/dist/ui/use-component-logs.d.ts +7 -7
- package/dist/ui/use-component-logs.js +5 -6
- package/dist/ui/use-component-logs.js.map +1 -1
- package/dist/ui/use-component-query.js +13 -17
- package/dist/ui/use-component-query.js.map +1 -1
- package/dist/ui/use-component.model.d.ts +7 -7
- package/get-component-opts.ts +14 -0
- package/hash.ts +4 -0
- package/head.ts +0 -0
- package/history-graph.ts +1 -0
- package/index.ts +50 -0
- package/on-load.ts +0 -0
- package/package.json +34 -41
- package/state.ts +88 -0
- package/store.ts +3 -0
- package/tag-map.ts +87 -0
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_harmonyUi","data","require","_component","_react","_interopRequireWildcard","_uiFoundationUiHooks","_client","_designUi","_documenterUi","_documenterUi2","_aspectPageModule","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","GET_COMPONENT","gql","AspectPage","
|
|
1
|
+
{"version":3,"names":["_harmonyUi","data","require","_component","_react","_interopRequireWildcard","_uiFoundationUiHooks","_client","_designUi","_documenterUi","_documenterUi2","_aspectPageModule","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","GET_COMPONENT","gql","AspectPage","component","useContext","ComponentContext","useDataQuery","variables","id","toString","aspectList","getHost","aspects","length","createElement","EmptyBox","title","linkText","link","className","styles","aspectPage","H1","Separator","separator","map","aspect","AspectBox","key","aspectBox","name","icon","config"],"sources":["aspect-page.tsx"],"sourcesContent":["import { AspectBox } from '@teambit/harmony.ui.aspect-box';\nimport { ComponentContext } from '@teambit/component';\nimport React, { useContext } from 'react';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { gql } from '@apollo/client';\nimport { EmptyBox } from '@teambit/design.ui.empty-box';\nimport { H1 } from '@teambit/documenter.ui.heading';\nimport { Separator } from '@teambit/documenter.ui.separator';\nimport styles from './aspect-page.module.scss';\n\nconst GET_COMPONENT = gql`\n query ($id: String!) {\n getHost {\n get(id: $id) {\n aspects {\n id\n config\n data\n icon\n }\n }\n }\n }\n`;\n\n// TODO: get the docs domain from the community aspect and pass it here as a prop\nexport function AspectPage() {\n const component = useContext(ComponentContext);\n const { data } = useDataQuery(GET_COMPONENT, {\n variables: { id: component.id.toString() },\n });\n const aspectList = data?.getHost?.get?.aspects;\n\n if (aspectList && aspectList.length === 0) {\n return (\n <EmptyBox\n title=\"This component is new and doesn’t have any aspects.\"\n linkText=\"Learn more about component aspects\"\n link={`https://bit.dev/docs/extending-bit/aspect-overview`}\n />\n );\n }\n\n return (\n <div className={styles.aspectPage}>\n <div>\n <H1 className={styles.title}>Configuration</H1>\n <Separator className={styles.separator} />\n {aspectList &&\n aspectList.map((aspect) => {\n return (\n <AspectBox\n key={aspect.id}\n className={styles.aspectBox}\n name={aspect.id}\n icon={aspect.icon}\n config={aspect.config}\n data={aspect.data}\n />\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAH,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,qBAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,oBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,UAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,SAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,cAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,aAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,eAAA;EAAA,MAAAT,IAAA,GAAAC,OAAA;EAAAQ,cAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAU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e,GAAG,CAAEC,MAAM,IAAK;IACzB,oBACEzD,MAAA,GAAAW,OAAA,CAAAkC,aAAA,CAACjD,UAAA,GAAA8D,SAAS;MACRC,GAAG,EAAEF,MAAM,CAAClB,EAAG;MACfW,SAAS,EAAEC,2BAAM,CAACS,SAAU;MAC5BC,IAAI,EAAEJ,MAAM,CAAClB,EAAG;MAChBuB,IAAI,EAAEL,MAAM,CAACK,IAAK;MAClBC,MAAM,EAAEN,MAAM,CAACM,MAAO;MACtBlE,IAAI,EAAE4D,MAAM,CAAC5D;IAAK,CACnB,CAAC;EAEN,CAAC,CACA,CACF,CAAC;AAEV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export declare class ComponentError {
|
|
3
3
|
/**
|
|
4
4
|
* http status code of error
|
|
@@ -7,7 +7,7 @@ export declare class ComponentError {
|
|
|
7
7
|
/**
|
|
8
8
|
* error message of the error
|
|
9
9
|
*/
|
|
10
|
-
readonly message?: string
|
|
10
|
+
readonly message?: string;
|
|
11
11
|
constructor(
|
|
12
12
|
/**
|
|
13
13
|
* http status code of error
|
|
@@ -16,6 +16,6 @@ export declare class ComponentError {
|
|
|
16
16
|
/**
|
|
17
17
|
* error message of the error
|
|
18
18
|
*/
|
|
19
|
-
message?: string
|
|
20
|
-
renderError():
|
|
19
|
+
message?: string);
|
|
20
|
+
renderError(): JSX.Element;
|
|
21
21
|
}
|
|
@@ -6,7 +6,7 @@ import { LegacyComponentLog } from '@teambit/legacy-component-log';
|
|
|
6
6
|
import { ComponentPreviewSize } from '@teambit/preview';
|
|
7
7
|
import { TagMap } from '../../tag-map';
|
|
8
8
|
import { TagProps } from '../../tag/tag';
|
|
9
|
-
export
|
|
9
|
+
export type ComponentModelProps = {
|
|
10
10
|
id: ComponentIdObj;
|
|
11
11
|
description: string;
|
|
12
12
|
buildStatus?: string;
|
|
@@ -27,13 +27,13 @@ export declare type ComponentModelProps = {
|
|
|
27
27
|
logs?: LegacyComponentLog[];
|
|
28
28
|
size?: ComponentPreviewSize;
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type ComponentPreview = {
|
|
31
31
|
includesEnvTemplate?: boolean;
|
|
32
32
|
isScaling?: boolean;
|
|
33
33
|
skipIncludes?: boolean;
|
|
34
34
|
legacyHeader?: boolean;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
36
|
+
export type ComponentServer = {
|
|
37
37
|
env: string;
|
|
38
38
|
/**
|
|
39
39
|
* Full dev server url.
|
|
@@ -76,15 +76,15 @@ export declare class ComponentModel {
|
|
|
76
76
|
/**
|
|
77
77
|
* component build status
|
|
78
78
|
*/
|
|
79
|
-
readonly buildStatus?: string
|
|
79
|
+
readonly buildStatus?: string;
|
|
80
80
|
/**
|
|
81
81
|
* issues of component.
|
|
82
82
|
*/
|
|
83
|
-
readonly issuesCount?: number
|
|
83
|
+
readonly issuesCount?: number;
|
|
84
84
|
/**
|
|
85
85
|
* elements url
|
|
86
86
|
*/
|
|
87
|
-
readonly elementsUrl?: string
|
|
87
|
+
readonly elementsUrl?: string;
|
|
88
88
|
/**
|
|
89
89
|
* status of component.
|
|
90
90
|
*/
|
|
@@ -92,11 +92,11 @@ export declare class ComponentModel {
|
|
|
92
92
|
/**
|
|
93
93
|
* deprecation info of the component.
|
|
94
94
|
*/
|
|
95
|
-
readonly deprecation?: DeprecationInfo
|
|
95
|
+
readonly deprecation?: DeprecationInfo;
|
|
96
96
|
/**
|
|
97
97
|
* env descriptor.
|
|
98
98
|
*/
|
|
99
|
-
readonly environment?: Descriptor
|
|
99
|
+
readonly environment?: Descriptor;
|
|
100
100
|
/**
|
|
101
101
|
* description of the component.
|
|
102
102
|
*/
|
|
@@ -105,18 +105,18 @@ export declare class ComponentModel {
|
|
|
105
105
|
/**
|
|
106
106
|
* host of the component
|
|
107
107
|
*/
|
|
108
|
-
readonly host?: string
|
|
108
|
+
readonly host?: string;
|
|
109
109
|
/**
|
|
110
110
|
*
|
|
111
111
|
* size preview
|
|
112
112
|
*/
|
|
113
|
-
readonly size?: ComponentPreviewSize
|
|
113
|
+
readonly size?: ComponentPreviewSize;
|
|
114
114
|
/**
|
|
115
115
|
* latest version of component
|
|
116
116
|
*/
|
|
117
|
-
readonly latest?: string
|
|
118
|
-
readonly preview?: ComponentPreview
|
|
119
|
-
readonly logs?: LegacyComponentLog[]
|
|
117
|
+
readonly latest?: string;
|
|
118
|
+
readonly preview?: ComponentPreview;
|
|
119
|
+
readonly logs?: LegacyComponentLog[];
|
|
120
120
|
constructor(
|
|
121
121
|
/**
|
|
122
122
|
* id of the component
|
|
@@ -145,15 +145,15 @@ export declare class ComponentModel {
|
|
|
145
145
|
/**
|
|
146
146
|
* component build status
|
|
147
147
|
*/
|
|
148
|
-
buildStatus?: string
|
|
148
|
+
buildStatus?: string,
|
|
149
149
|
/**
|
|
150
150
|
* issues of component.
|
|
151
151
|
*/
|
|
152
|
-
issuesCount?: number
|
|
152
|
+
issuesCount?: number,
|
|
153
153
|
/**
|
|
154
154
|
* elements url
|
|
155
155
|
*/
|
|
156
|
-
elementsUrl?: string
|
|
156
|
+
elementsUrl?: string,
|
|
157
157
|
/**
|
|
158
158
|
* status of component.
|
|
159
159
|
*/
|
|
@@ -161,11 +161,11 @@ export declare class ComponentModel {
|
|
|
161
161
|
/**
|
|
162
162
|
* deprecation info of the component.
|
|
163
163
|
*/
|
|
164
|
-
deprecation?: DeprecationInfo
|
|
164
|
+
deprecation?: DeprecationInfo,
|
|
165
165
|
/**
|
|
166
166
|
* env descriptor.
|
|
167
167
|
*/
|
|
168
|
-
environment?: Descriptor
|
|
168
|
+
environment?: Descriptor,
|
|
169
169
|
/**
|
|
170
170
|
* description of the component.
|
|
171
171
|
*/
|
|
@@ -173,16 +173,16 @@ export declare class ComponentModel {
|
|
|
173
173
|
/**
|
|
174
174
|
* host of the component
|
|
175
175
|
*/
|
|
176
|
-
host?: string
|
|
176
|
+
host?: string,
|
|
177
177
|
/**
|
|
178
178
|
*
|
|
179
179
|
* size preview
|
|
180
180
|
*/
|
|
181
|
-
size?: ComponentPreviewSize
|
|
181
|
+
size?: ComponentPreviewSize,
|
|
182
182
|
/**
|
|
183
183
|
* latest version of component
|
|
184
184
|
*/
|
|
185
|
-
latest?: string
|
|
185
|
+
latest?: string, preview?: ComponentPreview, logs?: LegacyComponentLog[]);
|
|
186
186
|
get version(): string;
|
|
187
187
|
/**
|
|
188
188
|
* create an instance of a component from a plain object.
|
|
@@ -155,7 +155,7 @@ class ComponentModel {
|
|
|
155
155
|
size,
|
|
156
156
|
logs
|
|
157
157
|
}) {
|
|
158
|
-
return new ComponentModel(_componentId().ComponentID.fromObject(id), displayName, packageName, server, _compositions().Composition.fromArray(compositions), _tagMap().TagMap.fromArray(tags.map(tag => _tag().Tag.fromObject(tag))), buildStatus, issuesCount, elementsUrl, status, deprecation, env, description, labels, host, size, latest, preview, logs
|
|
158
|
+
return new ComponentModel(_componentId().ComponentID.fromObject(id), displayName, packageName, server, _compositions().Composition.fromArray(compositions), _tagMap().TagMap.fromArray(tags.map(tag => _tag().Tag.fromObject(tag))), buildStatus, issuesCount, elementsUrl, status, deprecation, env, description, labels, host, size, latest, preview, logs?.map(log => log ?? {
|
|
159
159
|
hash: '[error]',
|
|
160
160
|
tag: '[error]',
|
|
161
161
|
message: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compositions","data","require","_componentId","_tag","_tagMap","ComponentModel","constructor","id","displayName","packageName","server","compositions","tags","buildStatus","issuesCount","elementsUrl","status","deprecation","environment","description","labels","host","size","latest","preview","logs","version","from","env","ComponentID","fromObject","Composition","fromArray","TagMap","map","tag","Tag","log","hash","message","parents","componentsProps","rawComponent","empty","name","scope","url","exports"],"sources":["component-model.ts"],"sourcesContent":["import { Composition, CompositionProps } from '@teambit/compositions';\nimport { DeprecationInfo } from '@teambit/deprecation';\nimport { Descriptor } from '@teambit/envs';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\nimport { LegacyComponentLog } from '@teambit/legacy-component-log';\nimport { ComponentPreviewSize } from '@teambit/preview';\nimport { Tag } from '../../tag';\nimport { TagMap } from '../../tag-map';\nimport { TagProps } from '../../tag/tag';\n// import { Snap } from '../../snap';\n\n// ADDING MORE PROPERTIES HERE IS NOT ALLOWED!!! IF YOU NEED DATA PLEASE ADD A NEW\n// HOOK FROM YOUR ASPECT!!!\n// TODO: remove all properties from here to their rightful place in their aspects.\nexport type ComponentModelProps = {\n id: ComponentIdObj;\n description: string;\n buildStatus?: string;\n server?: ComponentServer;\n displayName: string;\n packageName: string; // pkg aspect\n elementsUrl?: string; // pkg aspect\n compositions?: CompositionProps[];\n tags?: TagProps[];\n issuesCount?: number; // component/issues aspect\n status?: any; // workspace aspect.\n deprecation?: DeprecationInfo; // deprecation aspect\n env?: Descriptor; // env aspect.\n labels?: string[];\n host?: string;\n latest?: string;\n preview?: ComponentPreview;\n logs?: LegacyComponentLog[];\n size?: ComponentPreviewSize;\n};\n\nexport type ComponentPreview = {\n includesEnvTemplate?: boolean;\n isScaling?: boolean;\n skipIncludes?: boolean;\n legacyHeader?: boolean;\n};\n\nexport type ComponentServer = {\n env: string;\n /**\n * Full dev server url.\n */\n url?: string;\n\n /**\n * host of the component server (used mostly by cloud providers for remote scopes)\n */\n host?: string;\n\n /**\n * This is used mostly by cloud to proxy requests to the correct scope.\n */\n basePath?: string;\n};\n\nexport class ComponentModel {\n constructor(\n /**\n * id of the component\n */\n readonly id: ComponentID,\n\n /**\n * display name of the component.\n */\n readonly displayName: string,\n\n /**\n * package name of the component.\n */\n readonly packageName: string,\n\n /**\n * the component server.\n */\n readonly server: ComponentServer | undefined,\n\n /**\n * array of compositions\n */\n readonly compositions: Composition[],\n\n /**\n * tags of the component.\n */\n readonly tags: TagMap,\n\n /**\n * component build status\n */\n readonly buildStatus?: string,\n\n /**\n * issues of component.\n */\n readonly issuesCount?: number,\n /**\n * elements url\n */\n readonly elementsUrl?: string,\n /**\n * status of component.\n */\n readonly status?: any,\n\n /**\n * deprecation info of the component.\n */\n readonly deprecation?: DeprecationInfo,\n\n /**\n * env descriptor.\n */\n readonly environment?: Descriptor,\n\n /**\n * description of the component.\n */\n\n readonly description = '',\n\n readonly labels: string[] = [],\n\n /**\n * host of the component\n */\n readonly host?: string,\n\n /**\n *\n * size preview\n */\n readonly size?: ComponentPreviewSize,\n\n /**\n * latest version of component\n */\n readonly latest?: string,\n\n readonly preview?: ComponentPreview,\n\n readonly logs?: LegacyComponentLog[]\n ) {}\n\n get version() {\n if (!this.id.version) return 'new';\n return this.id.version;\n }\n\n /**\n * create an instance of a component from a plain object.\n */\n static from({\n id,\n server,\n displayName,\n compositions = [],\n packageName,\n elementsUrl,\n tags = [],\n deprecation,\n buildStatus,\n env,\n status,\n issuesCount,\n description,\n labels,\n host,\n latest,\n preview,\n size,\n logs,\n }: ComponentModelProps) {\n return new ComponentModel(\n ComponentID.fromObject(id),\n displayName,\n packageName,\n server,\n Composition.fromArray(compositions),\n TagMap.fromArray(tags.map((tag) => Tag.fromObject(tag))),\n buildStatus,\n issuesCount,\n elementsUrl,\n status,\n deprecation,\n env,\n description,\n labels,\n host,\n size,\n latest,\n preview,\n logs?.map((log) => log ?? { hash: '[error]', tag: '[error]', message: '', parents: [] })\n );\n }\n\n static fromArray(componentsProps: ComponentModelProps[]) {\n return componentsProps.map((rawComponent) => ComponentModel.from(rawComponent));\n }\n\n static empty() {\n return new ComponentModel(\n ComponentID.fromObject({ name: 'root', scope: 'temp' }),\n '',\n '',\n { env: '', url: '' },\n [],\n TagMap.empty()\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,cAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,aAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA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MAAM,EACNC,OAAO,EACPC,IAAI,
|
|
1
|
+
{"version":3,"names":["_compositions","data","require","_componentId","_tag","_tagMap","ComponentModel","constructor","id","displayName","packageName","server","compositions","tags","buildStatus","issuesCount","elementsUrl","status","deprecation","environment","description","labels","host","size","latest","preview","logs","version","from","env","ComponentID","fromObject","Composition","fromArray","TagMap","map","tag","Tag","log","hash","message","parents","componentsProps","rawComponent","empty","name","scope","url","exports"],"sources":["component-model.ts"],"sourcesContent":["import { Composition, CompositionProps } from '@teambit/compositions';\nimport { DeprecationInfo } from '@teambit/deprecation';\nimport { Descriptor } from '@teambit/envs';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\nimport { LegacyComponentLog } from '@teambit/legacy-component-log';\nimport { ComponentPreviewSize } from '@teambit/preview';\nimport { Tag } from '../../tag';\nimport { TagMap } from '../../tag-map';\nimport { TagProps } from '../../tag/tag';\n// import { Snap } from '../../snap';\n\n// ADDING MORE PROPERTIES HERE IS NOT ALLOWED!!! IF YOU NEED DATA PLEASE ADD A NEW\n// HOOK FROM YOUR ASPECT!!!\n// TODO: remove all properties from here to their rightful place in their aspects.\nexport type ComponentModelProps = {\n id: ComponentIdObj;\n description: string;\n buildStatus?: string;\n server?: ComponentServer;\n displayName: string;\n packageName: string; // pkg aspect\n elementsUrl?: string; // pkg aspect\n compositions?: CompositionProps[];\n tags?: TagProps[];\n issuesCount?: number; // component/issues aspect\n status?: any; // workspace aspect.\n deprecation?: DeprecationInfo; // deprecation aspect\n env?: Descriptor; // env aspect.\n labels?: string[];\n host?: string;\n latest?: string;\n preview?: ComponentPreview;\n logs?: LegacyComponentLog[];\n size?: ComponentPreviewSize;\n};\n\nexport type ComponentPreview = {\n includesEnvTemplate?: boolean;\n isScaling?: boolean;\n skipIncludes?: boolean;\n legacyHeader?: boolean;\n};\n\nexport type ComponentServer = {\n env: string;\n /**\n * Full dev server url.\n */\n url?: string;\n\n /**\n * host of the component server (used mostly by cloud providers for remote scopes)\n */\n host?: string;\n\n /**\n * This is used mostly by cloud to proxy requests to the correct scope.\n */\n basePath?: string;\n};\n\nexport class ComponentModel {\n constructor(\n /**\n * id of the component\n */\n readonly id: ComponentID,\n\n /**\n * display name of the component.\n */\n readonly displayName: string,\n\n /**\n * package name of the component.\n */\n readonly packageName: string,\n\n /**\n * the component server.\n */\n readonly server: ComponentServer | undefined,\n\n /**\n * array of compositions\n */\n readonly compositions: Composition[],\n\n /**\n * tags of the component.\n */\n readonly tags: TagMap,\n\n /**\n * component build status\n */\n readonly buildStatus?: string,\n\n /**\n * issues of component.\n */\n readonly issuesCount?: number,\n /**\n * elements url\n */\n readonly elementsUrl?: string,\n /**\n * status of component.\n */\n readonly status?: any,\n\n /**\n * deprecation info of the component.\n */\n readonly deprecation?: DeprecationInfo,\n\n /**\n * env descriptor.\n */\n readonly environment?: Descriptor,\n\n /**\n * description of the component.\n */\n\n readonly description = '',\n\n readonly labels: string[] = [],\n\n /**\n * host of the component\n */\n readonly host?: string,\n\n /**\n *\n * size preview\n */\n readonly size?: ComponentPreviewSize,\n\n /**\n * latest version of component\n */\n readonly latest?: string,\n\n readonly preview?: ComponentPreview,\n\n readonly logs?: LegacyComponentLog[]\n ) {}\n\n get version() {\n if (!this.id.version) return 'new';\n return this.id.version;\n }\n\n /**\n * create an instance of a component from a plain object.\n */\n static from({\n id,\n server,\n displayName,\n compositions = [],\n packageName,\n elementsUrl,\n tags = [],\n deprecation,\n buildStatus,\n env,\n status,\n issuesCount,\n description,\n labels,\n host,\n latest,\n preview,\n size,\n logs,\n }: ComponentModelProps) {\n return new ComponentModel(\n ComponentID.fromObject(id),\n displayName,\n packageName,\n server,\n Composition.fromArray(compositions),\n TagMap.fromArray(tags.map((tag) => Tag.fromObject(tag))),\n buildStatus,\n issuesCount,\n elementsUrl,\n status,\n deprecation,\n env,\n description,\n labels,\n host,\n size,\n latest,\n preview,\n logs?.map((log) => log ?? { hash: '[error]', tag: '[error]', message: '', parents: [] })\n );\n }\n\n static fromArray(componentsProps: ComponentModelProps[]) {\n return componentsProps.map((rawComponent) => ComponentModel.from(rawComponent));\n }\n\n static empty() {\n return new ComponentModel(\n ComponentID.fromObject({ name: 'root', scope: 'temp' }),\n '',\n '',\n { env: '', url: '' },\n [],\n TagMap.empty()\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,cAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,aAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA;;AAEA;AACA;AACA;;AAgDO,MAAMK,cAAc,CAAC;EAC1BC,WAAWA;EACT;AACJ;AACA;EACaC,EAAe;EAExB;AACJ;AACA;EACaC,WAAmB;EAE5B;AACJ;AACA;EACaC,WAAmB;EAE5B;AACJ;AACA;EACaC,MAAmC;EAE5C;AACJ;AACA;EACaC,YAA2B;EAEpC;AACJ;AACA;EACaC,IAAY;EAErB;AACJ;AACA;EACaC,WAAoB;EAE7B;AACJ;AACA;EACaC,WAAoB;EAC7B;AACJ;AACA;EACaC,WAAoB;EAC7B;AACJ;AACA;EACaC,MAAY;EAErB;AACJ;AACA;EACaC,WAA6B;EAEtC;AACJ;AACA;EACaC,WAAwB;EAEjC;AACJ;AACA;;EAEaC,WAAW,GAAG,EAAE,EAEhBC,MAAgB,GAAG,EAAE;EAE9B;AACJ;AACA;EACaC,IAA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;EACmB,CAAC,EAAE;IACtB,OAAO,IAAIpB,cAAc,CACvBwB,0BAAW,CAACC,UAAU,CAACvB,EAAE,CAAC,EAC1BC,WAAW,EACXC,WAAW,EACXC,MAAM,EACNqB,2BAAW,CAACC,SAAS,CAACrB,YAAY,CAAC,EACnCsB,gBAAM,CAACD,SAAS,CAACpB,IAAI,CAACsB,GAAG,CAAEC,GAAG,IAAKC,UAAG,CAACN,UAAU,CAACK,GAAG,CAAC,CAAC,CAAC,EACxDtB,WAAW,EACXC,WAAW,EACXC,WAAW,EACXC,MAAM,EACNC,WAAW,EACXW,GAAG,EACHT,WAAW,EACXC,MAAM,EACNC,IAAI,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,IAAI,EAAES,GAAG,CAAEG,GAAG,IAAKA,GAAG,IAAI;MAAEC,IAAI,EAAE,SAAS;MAAEH,GAAG,EAAE,SAAS;MAAEI,OAAO,EAAE,EAAE;MAAEC,OAAO,EAAE;IAAG,CAAC,CACzF,CAAC;EACH;EAEA,OAAOR,SAASA,CAACS,eAAsC,EAAE;IACvD,OAAOA,eAAe,CAACP,GAAG,CAAEQ,YAAY,IAAKrC,cAAc,CAACsB,IAAI,CAACe,YAAY,CAAC,CAAC;EACjF;EAEA,OAAOC,KAAKA,CAAA,EAAG;IACb,OAAO,IAAItC,cAAc,CACvBwB,0BAAW,CAACC,UAAU,CAAC;MAAEc,IAAI,EAAE,MAAM;MAAEC,KAAK,EAAE;IAAO,CAAC,CAAC,EACvD,EAAE,EACF,EAAE,EACF;MAAEjB,GAAG,EAAE,EAAE;MAAEkB,GAAG,EAAE;IAAG,CAAC,EACpB,EAAE,EACFb,gBAAM,CAACU,KAAK,CAAC,CACf,CAAC;EACH;AACF;AAACI,OAAA,CAAA1C,cAAA,GAAAA,cAAA"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React, { ComponentType } from 'react';
|
|
2
2
|
import { ComponentModel } from '@teambit/component';
|
|
3
|
-
export
|
|
3
|
+
export type ComponentPluginProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
4
4
|
component: ComponentModel;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type ComponentResultPlugin = {
|
|
7
7
|
key: string;
|
|
8
8
|
start?: ComponentType<ComponentPluginProps>;
|
|
9
9
|
end?: ComponentType<ComponentPluginProps>;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type ComponentResultProps = {
|
|
12
12
|
component: ComponentModel;
|
|
13
13
|
plugins?: ComponentResultPlugin[];
|
|
14
14
|
};
|
|
15
|
-
export declare function ComponentResult({ component, plugins }: ComponentResultProps):
|
|
15
|
+
export declare function ComponentResult({ component, plugins }: ComponentResultProps): JSX.Element;
|
|
16
16
|
export {};
|
|
@@ -52,11 +52,11 @@ function ComponentResult({
|
|
|
52
52
|
plugins
|
|
53
53
|
}) {
|
|
54
54
|
const name = component.id.fullName;
|
|
55
|
-
const startPlugins = (0, _lodash().default)(plugins
|
|
55
|
+
const startPlugins = (0, _lodash().default)(plugins?.map(plugin => plugin.start && /*#__PURE__*/_react().default.createElement(plugin.start, {
|
|
56
56
|
key: plugin.key,
|
|
57
57
|
component: component
|
|
58
58
|
})));
|
|
59
|
-
const endPlugins = (0, _lodash().default)(plugins
|
|
59
|
+
const endPlugins = (0, _lodash().default)(plugins?.map(plugin => plugin.end && /*#__PURE__*/_react().default.createElement(plugin.end, {
|
|
60
60
|
key: plugin.key,
|
|
61
61
|
component: component
|
|
62
62
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","_lodash","_designUiStyles","_envsUi","_classnames","_componentResultModule","obj","__esModule","default","ComponentResult","component","plugins","name","id","fullName","startPlugins","compact","map","plugin","start","createElement","key","endPlugins","end","Fragment","EnvIcon","className","styles","icon","classnames","ellipsis"],"sources":["component-result.tsx"],"sourcesContent":["import React, { ComponentType } from 'react';\nimport compact from 'lodash.compact';\nimport { ComponentModel } from '@teambit/component';\nimport { ellipsis } from '@teambit/design.ui.styles.ellipsis';\nimport { EnvIcon } from '@teambit/envs.ui.env-icon';\nimport classnames from 'classnames';\n\nimport styles from './component-result.module.scss';\n\nexport type ComponentPluginProps = React.HTMLAttributes<HTMLDivElement> & { component: ComponentModel };\n\nexport type ComponentResultPlugin = {\n key: string;\n start?: ComponentType<ComponentPluginProps>;\n end?: ComponentType<ComponentPluginProps>;\n};\ntype ComponentResultProps = {\n component: ComponentModel;\n plugins?: ComponentResultPlugin[];\n};\n\nexport function ComponentResult({ component, plugins }: ComponentResultProps) {\n const name = component.id.fullName;\n\n const startPlugins = compact(\n plugins?.map((plugin) => plugin.start && <plugin.start key={plugin.key} component={component} />)\n );\n const endPlugins = compact(\n plugins?.map((plugin) => plugin.end && <plugin.end key={plugin.key} component={component} />)\n );\n\n return (\n <>\n {startPlugins}\n <EnvIcon component={component} className={styles.icon} />\n <div className={classnames(styles.name, ellipsis)}>{name}</div>\n {endPlugins}\n </>\n );\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,YAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,uBAAA;EAAA,MAAAP,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAK,sBAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoD,SAAAC,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAc7C,SAASG,eAAeA,CAAC;EAAEC,SAAS;EAAEC;AAA8B,CAAC,EAAE;EAC5E,MAAMC,IAAI,GAAGF,SAAS,CAACG,EAAE,CAACC,QAAQ;EAElC,MAAMC,YAAY,GAAG,IAAAC,iBAAO,EAC1BL,OAAO,
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","_lodash","_designUiStyles","_envsUi","_classnames","_componentResultModule","obj","__esModule","default","ComponentResult","component","plugins","name","id","fullName","startPlugins","compact","map","plugin","start","createElement","key","endPlugins","end","Fragment","EnvIcon","className","styles","icon","classnames","ellipsis"],"sources":["component-result.tsx"],"sourcesContent":["import React, { ComponentType } from 'react';\nimport compact from 'lodash.compact';\nimport { ComponentModel } from '@teambit/component';\nimport { ellipsis } from '@teambit/design.ui.styles.ellipsis';\nimport { EnvIcon } from '@teambit/envs.ui.env-icon';\nimport classnames from 'classnames';\n\nimport styles from './component-result.module.scss';\n\nexport type ComponentPluginProps = React.HTMLAttributes<HTMLDivElement> & { component: ComponentModel };\n\nexport type ComponentResultPlugin = {\n key: string;\n start?: ComponentType<ComponentPluginProps>;\n end?: ComponentType<ComponentPluginProps>;\n};\ntype ComponentResultProps = {\n component: ComponentModel;\n plugins?: ComponentResultPlugin[];\n};\n\nexport function ComponentResult({ component, plugins }: ComponentResultProps) {\n const name = component.id.fullName;\n\n const startPlugins = compact(\n plugins?.map((plugin) => plugin.start && <plugin.start key={plugin.key} component={component} />)\n );\n const endPlugins = compact(\n plugins?.map((plugin) => plugin.end && <plugin.end key={plugin.key} component={component} />)\n );\n\n return (\n <>\n {startPlugins}\n <EnvIcon component={component} className={styles.icon} />\n <div className={classnames(styles.name, ellipsis)}>{name}</div>\n {endPlugins}\n </>\n );\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,gBAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,eAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,YAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,uBAAA;EAAA,MAAAP,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAK,sBAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoD,SAAAC,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAc7C,SAASG,eAAeA,CAAC;EAAEC,SAAS;EAAEC;AAA8B,CAAC,EAAE;EAC5E,MAAMC,IAAI,GAAGF,SAAS,CAACG,EAAE,CAACC,QAAQ;EAElC,MAAMC,YAAY,GAAG,IAAAC,iBAAO,EAC1BL,OAAO,EAAEM,GAAG,CAAEC,MAAM,IAAKA,MAAM,CAACC,KAAK,iBAAItB,MAAA,GAAAW,OAAA,CAAAY,aAAA,CAACF,MAAM,CAACC,KAAK;IAACE,GAAG,EAAEH,MAAM,CAACG,GAAI;IAACX,SAAS,EAAEA;EAAU,CAAE,CAAC,CAClG,CAAC;EACD,MAAMY,UAAU,GAAG,IAAAN,iBAAO,EACxBL,OAAO,EAAEM,GAAG,CAAEC,MAAM,IAAKA,MAAM,CAACK,GAAG,iBAAI1B,MAAA,GAAAW,OAAA,CAAAY,aAAA,CAACF,MAAM,CAACK,GAAG;IAACF,GAAG,EAAEH,MAAM,CAACG,GAAI;IAACX,SAAS,EAAEA;EAAU,CAAE,CAAC,CAC9F,CAAC;EAED,oBACEb,MAAA,GAAAW,OAAA,CAAAY,aAAA,CAAAvB,MAAA,GAAAW,OAAA,CAAAgB,QAAA,QACGT,YAAY,eACblB,MAAA,GAAAW,OAAA,CAAAY,aAAA,CAACjB,OAAA,GAAAsB,OAAO;IAACf,SAAS,EAAEA,SAAU;IAACgB,SAAS,EAAEC,gCAAM,CAACC;EAAK,CAAE,CAAC,eACzD/B,MAAA,GAAAW,OAAA,CAAAY,aAAA;IAAKM,SAAS,EAAE,IAAAG,qBAAU,EAACF,gCAAM,CAACf,IAAI,EAAEkB,0BAAQ;EAAE,GAAElB,IAAU,CAAC,EAC9DU,UACD,CAAC;AAEP"}
|
|
@@ -3,12 +3,12 @@ import { SearchResult, FuzzySearchItem, FuzzySearcher } from '@teambit/explorer.
|
|
|
3
3
|
import type { SearchProvider } from '@teambit/command-bar';
|
|
4
4
|
import { ComponentResultPlugin } from './component-result';
|
|
5
5
|
export type { ComponentResultPlugin };
|
|
6
|
-
|
|
6
|
+
type ComponentSearchIdx = {
|
|
7
7
|
name: string;
|
|
8
8
|
displayName: string;
|
|
9
9
|
component: ComponentModel;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type ComponentSearcherOptions = {
|
|
12
12
|
navigate: (path: string) => void;
|
|
13
13
|
resultPlugins?: ComponentResultPlugin[];
|
|
14
14
|
};
|
package/dist/ui/component.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { RouteProps } from 'react-router-dom';
|
|
3
3
|
import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
4
4
|
import { SlotRegistry } from '@teambit/harmony';
|
|
5
5
|
import { UseComponentType, Filters } from './use-component';
|
|
6
6
|
import { ComponentModel } from './component-model';
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type ComponentPageSlot = SlotRegistry<ComponentPageElement[]>;
|
|
8
|
+
export type ComponentPageElement = {
|
|
9
9
|
type: 'before' | 'after';
|
|
10
10
|
content: ReactNode;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type ComponentProps = {
|
|
13
13
|
containerSlot?: ComponentPageSlot;
|
|
14
14
|
routeSlot: RouteSlot;
|
|
15
15
|
overriddenRoutes?: RouteProps[];
|
|
@@ -23,4 +23,4 @@ export declare type ComponentProps = {
|
|
|
23
23
|
/**
|
|
24
24
|
* main UI component of the Component extension.
|
|
25
25
|
*/
|
|
26
|
-
export declare function Component({ routeSlot, overriddenRoutes, containerSlot, host, onComponentChange, componentIdStr, useComponent, path, useComponentFilters, }: ComponentProps):
|
|
26
|
+
export declare function Component({ routeSlot, overriddenRoutes, containerSlot, host, onComponentChange, componentIdStr, useComponent, path, useComponentFilters, }: ComponentProps): JSX.Element;
|
package/dist/ui/component.js
CHANGED
|
@@ -98,7 +98,7 @@ function Component({
|
|
|
98
98
|
const _componentIdStr = getComponentIdStr(componentIdStr);
|
|
99
99
|
const componentId = _componentIdStr ? _().ComponentID.fromString(_componentIdStr) : undefined;
|
|
100
100
|
const resolvedComponentIdStr = path || idFromLocation;
|
|
101
|
-
const componentFiltersFromProps =
|
|
101
|
+
const componentFiltersFromProps = useComponentFilters?.() || {};
|
|
102
102
|
const useComponentOptions = {
|
|
103
103
|
logFilters: _objectSpread(_objectSpread({}, componentFiltersFromProps), componentFiltersFromProps.loading ? {} : {
|
|
104
104
|
log: _objectSpread({}, componentFiltersFromProps.log)
|
|
@@ -109,16 +109,16 @@ function Component({
|
|
|
109
109
|
component,
|
|
110
110
|
componentDescriptor,
|
|
111
111
|
error
|
|
112
|
-
} = (0, _useComponent().useComponent)(host,
|
|
112
|
+
} = (0, _useComponent().useComponent)(host, componentId?.toString() || idFromLocation, useComponentOptions);
|
|
113
113
|
|
|
114
114
|
// trigger onComponentChange when component changes
|
|
115
|
-
(0, _react().useEffect)(() => onComponentChange
|
|
115
|
+
(0, _react().useEffect)(() => onComponentChange?.(component), [component]);
|
|
116
116
|
// cleanup when unmounting component
|
|
117
|
-
(0, _react().useEffect)(() => () => onComponentChange
|
|
118
|
-
const pageItems = (0, _react().useMemo)(() => (0, _lodash().default)(containerSlot
|
|
117
|
+
(0, _react().useEffect)(() => () => onComponentChange?.(undefined), []);
|
|
118
|
+
const pageItems = (0, _react().useMemo)(() => (0, _lodash().default)(containerSlot?.values()), [containerSlot]);
|
|
119
119
|
const before = (0, _react().useMemo)(() => pageItems.filter(x => x.type === 'before').map(x => x.content), [pageItems]);
|
|
120
120
|
const after = (0, _react().useMemo)(() => pageItems.filter(x => x.type === 'after').map(x => x.content), [pageItems]);
|
|
121
|
-
if (error) return error
|
|
121
|
+
if (error) return error?.renderError();
|
|
122
122
|
if (!component) return /*#__PURE__*/_react().default.createElement("div", null);
|
|
123
123
|
return /*#__PURE__*/_react().default.createElement(_context().ComponentDescriptorProvider, {
|
|
124
124
|
componentDescriptor: componentDescriptor
|
package/dist/ui/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_lodash","_interopRequireDefault","_uiFoundationUiReactRouter","_lodash2","_context","_useComponent","_useComponentFromLocation","_","_componentModule","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","key","value","_toPropertyKey","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","getComponentIdStr","componentIdStr","isFunction","Component","routeSlot","overriddenRoutes","containerSlot","host","onComponentChange","useComponent","path","useComponentFilters","idFromLocation","useIdFromLocation","_componentIdStr","componentId","ComponentID","fromString","undefined","resolvedComponentIdStr","componentFiltersFromProps","useComponentOptions","logFilters","loading","log","customUseComponent","component","componentDescriptor","error","useComponentQuery","toString","useEffect","pageItems","useMemo","flatten","values","before","x","type","map","content","after","renderError","createElement","ComponentDescriptorProvider","ComponentProvider","className","styles","container","SlotRouter","parentPath","slot","routes"],"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 { ComponentProvider, ComponentDescriptorProvider } from './context';\nimport { useComponent as useComponentQuery, UseComponentType, Filters } from './use-component';\nimport { ComponentModel } from './component-model';\nimport { useIdFromLocation } from './use-component-from-location';\nimport { ComponentID } from '..';\n\nimport styles from './component.module.scss';\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 componentFiltersFromProps = useComponentFilters?.() || {};\n\n const useComponentOptions = {\n logFilters: {\n ...componentFiltersFromProps,\n ...(componentFiltersFromProps.loading\n ? {}\n : {\n log: {\n // @todo - enable this when we have lazy loading of logs\n // limit: 3,\n ...componentFiltersFromProps.log,\n },\n }),\n },\n customUseComponent: useComponent,\n };\n\n const { component, componentDescriptor, error } = useComponentQuery(\n host,\n componentId?.toString() || idFromLocation,\n useComponentOptions\n );\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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AO,CAAC,EAAE,CAACR,SAAS,CAAC,CAAC;EAE3G,IAAIJ,KAAK,EAAE,OAAOA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEc,WAAW,CAAC,CAAC;EACtC,IAAI,CAAChB,SAAS,EAAE,oBAAOvF,MAAA,GAAAe,OAAA,CAAAyF,aAAA,YAAU,CAAC;EAElC,oBACExG,MAAA,GAAAe,OAAA,CAAAyF,aAAA,CAAChG,QAAA,GAAAiG,2BAA2B;IAACjB,mBAAmB,EAAEA;EAAoB,gBACpExF,MAAA,GAAAe,OAAA,CAAAyF,aAAA,CAAChG,QAAA,GAAAkG,iBAAiB;IAACnB,SAAS,EAAEA;EAAU,GACrCU,MAAM,eACPjG,MAAA,GAAAe,OAAA,CAAAyF,aAAA;IAAKG,SAAS,EAAEC,0BAAM,CAACC;EAAU,GAC9B5C,SAAS,iBACRjE,MAAA,GAAAe,OAAA,CAAAyF,aAAA,CAAClG,0BAAA,GAAAwG,UAAU;IAACC,UAAU,EAAG,GAAE/B,sBAAuB,IAAI;IAACgC,IAAI,EAAE/C,SAAU;IAACgD,MAAM,EAAE/C;EAAiB,CAAE,CAElG,CAAC,EACLoC,KACgB,CACQ,CAAC;AAElC"}
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_lodash","_interopRequireDefault","_uiFoundationUiReactRouter","_lodash2","_context","_useComponent","_useComponentFromLocation","_","_componentModule","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","key","value","_toPropertyKey","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","getComponentIdStr","componentIdStr","isFunction","Component","routeSlot","overriddenRoutes","containerSlot","host","onComponentChange","useComponent","path","useComponentFilters","idFromLocation","useIdFromLocation","_componentIdStr","componentId","ComponentID","fromString","undefined","resolvedComponentIdStr","componentFiltersFromProps","useComponentOptions","logFilters","loading","log","customUseComponent","component","componentDescriptor","error","useComponentQuery","toString","useEffect","pageItems","useMemo","flatten","values","before","x","type","map","content","after","renderError","createElement","ComponentDescriptorProvider","ComponentProvider","className","styles","container","SlotRouter","parentPath","slot","routes"],"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 { ComponentProvider, ComponentDescriptorProvider } from './context';\nimport { useComponent as useComponentQuery, UseComponentType, Filters } from './use-component';\nimport { ComponentModel } from './component-model';\nimport { useIdFromLocation } from './use-component-from-location';\nimport { ComponentID } from '..';\n\nimport styles from './component.module.scss';\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 componentFiltersFromProps = useComponentFilters?.() || {};\n\n const useComponentOptions = {\n logFilters: {\n ...componentFiltersFromProps,\n ...(componentFiltersFromProps.loading\n ? {}\n : {\n log: {\n // @todo - enable this when we have lazy loading of logs\n // limit: 3,\n ...componentFiltersFromProps.log,\n },\n }),\n },\n customUseComponent: useComponent,\n };\n\n const { component, componentDescriptor, error } = useComponentQuery(\n host,\n componentId?.toString() || idFromLocation,\n useComponentOptions\n );\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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAF,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,2BAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,0BAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;E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ACC,UAAU,EAAG,GAAE/B,sBAAuB,IAAI;IAACgC,IAAI,EAAE/C,SAAU;IAACgD,MAAM,EAAE/C;EAAiB,CAAE,CAElG,CAAC,EACLoC,KACgB,CACQ,CAAC;AAElC"}
|
|
@@ -3,4 +3,4 @@ import type { ComponentDescriptor } from '@teambit/component-descriptor';
|
|
|
3
3
|
import { ComponentModel } from '../component-model';
|
|
4
4
|
export declare const ComponentContext: React.Context<ComponentModel>;
|
|
5
5
|
export declare const ComponentDescriptorContext: React.Context<ComponentDescriptor | undefined>;
|
|
6
|
-
export declare const useComponentDescriptor: () => ComponentDescriptor
|
|
6
|
+
export declare const useComponentDescriptor: () => ComponentDescriptor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import type { ComponentDescriptor } from '@teambit/component-descriptor';
|
|
3
3
|
import { ComponentModel } from '../component-model';
|
|
4
|
-
export
|
|
4
|
+
export type ComponentProviderProps = {
|
|
5
5
|
/**
|
|
6
6
|
* component model.
|
|
7
7
|
*/
|
|
@@ -11,8 +11,8 @@ export declare type ComponentProviderProps = {
|
|
|
11
11
|
*/
|
|
12
12
|
children: ReactNode;
|
|
13
13
|
};
|
|
14
|
-
export declare function ComponentProvider({ component, children }: ComponentProviderProps):
|
|
15
|
-
export
|
|
14
|
+
export declare function ComponentProvider({ component, children }: ComponentProviderProps): JSX.Element;
|
|
15
|
+
export type ComponentDescriptorProviderProps = {
|
|
16
16
|
/**
|
|
17
17
|
* component model.
|
|
18
18
|
*/
|
|
@@ -22,4 +22,4 @@ export declare type ComponentDescriptorProviderProps = {
|
|
|
22
22
|
*/
|
|
23
23
|
children: ReactNode;
|
|
24
24
|
};
|
|
25
|
-
export declare function ComponentDescriptorProvider({ componentDescriptor, children }: ComponentDescriptorProviderProps):
|
|
25
|
+
export declare function ComponentDescriptorProvider({ componentDescriptor, children }: ComponentDescriptorProviderProps): JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NavPlugin, OrderedNavigationSlot } from './nav-plugin';
|
|
3
|
-
export
|
|
3
|
+
export type MenuNavProps = {
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated
|
|
6
6
|
* use @property navPlugins
|
|
@@ -20,4 +20,4 @@ export declare type MenuNavProps = {
|
|
|
20
20
|
activeTabIndex?: number;
|
|
21
21
|
alwaysShowActiveTab?: boolean;
|
|
22
22
|
} & React.HTMLAttributes<HTMLElement>;
|
|
23
|
-
export declare function CollapsibleMenuNav({ navigationSlot, widgetSlot, navPlugins, widgetPlugins, className, secondaryNavClassName, activeTabIndex, alwaysShowActiveTab, children, }: MenuNavProps):
|
|
23
|
+
export declare function CollapsibleMenuNav({ navigationSlot, widgetSlot, navPlugins, widgetPlugins, className, secondaryNavClassName, activeTabIndex, alwaysShowActiveTab, children, }: MenuNavProps): JSX.Element;
|
package/dist/ui/menu/menu-nav.js
CHANGED
|
@@ -56,10 +56,10 @@ function TopBarNavComponent({
|
|
|
56
56
|
* to accommodate for the top level nav which should display the children
|
|
57
57
|
* in the dropdown secondary menu if there is a displayName set
|
|
58
58
|
*/
|
|
59
|
-
const widgetDisplayText = menuItemProps
|
|
59
|
+
const widgetDisplayText = menuItemProps?.displayName && isInMenu ? menuItemProps?.displayName : undefined;
|
|
60
60
|
return /*#__PURE__*/_react().default.createElement(_topBarNav().TopBarNav, _extends({}, menuItemProps, {
|
|
61
|
-
className: (0, _classnames().default)(menuItemProps
|
|
62
|
-
}), widgetDisplayText ||
|
|
61
|
+
className: (0, _classnames().default)(menuItemProps?.className, _menuModule().default.topBarNav, isInMenu && _menuModule().default.noBorder)
|
|
62
|
+
}), widgetDisplayText || menuItemProps?.children);
|
|
63
63
|
}
|
|
64
64
|
function CollapsibleMenuNav({
|
|
65
65
|
navigationSlot,
|
|
@@ -73,11 +73,11 @@ function CollapsibleMenuNav({
|
|
|
73
73
|
children
|
|
74
74
|
}) {
|
|
75
75
|
const plugins = (0, _react().useMemo)(() => {
|
|
76
|
-
const _navPlugins = navPlugins.length > 0 ? navPlugins : navigationSlot
|
|
76
|
+
const _navPlugins = navPlugins.length > 0 ? navPlugins : navigationSlot?.toArray();
|
|
77
77
|
return (_navPlugins || []).sort(sortFn);
|
|
78
78
|
}, [navigationSlot, navPlugins]);
|
|
79
79
|
const widgets = (0, _react().useMemo)(() => {
|
|
80
|
-
const _widgetPlugins = widgetPlugins.length > 0 ? widgetPlugins : widgetSlot
|
|
80
|
+
const _widgetPlugins = widgetPlugins.length > 0 ? widgetPlugins : widgetSlot?.toArray();
|
|
81
81
|
return (_widgetPlugins || []).sort(sortFn);
|
|
82
82
|
}, [widgetSlot, widgetPlugins]);
|
|
83
83
|
const links = [...plugins, ...widgets].map(([, menuItem], index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_classnames","_interopRequireDefault","_designNavigation","_topBarNav","_menuModule","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","key","value","_toPropertyKey","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","_extends","assign","bind","target","source","TopBarNavComponent","isInMenu","menuItemProps","widgetDisplayText","displayName","undefined","createElement","TopBarNav","className","classnames","styles","topBarNav","noBorder","children","CollapsibleMenuNav","navigationSlot","widgetSlot","navPlugins","widgetPlugins","secondaryNavClassName","activeTabIndex","alwaysShowActiveTab","plugins","useMemo","_navPlugins","toArray","sort","sortFn","widgets","_widgetPlugins","links","map","menuItem","index","lastPluginStyle","marginRight","firstWidgetStyle","marginLeft","component","tabProps","props","style","ResponsiveNavbar","navClassName","tab","width","height","priority","tabs","defaultActiveIndex","order","first","second"],"sources":["menu-nav.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport classnames from 'classnames';\nimport { ResponsiveNavbar } from '@teambit/design.navigation.responsive-navbar';\nimport type { TabProps } from '@teambit/design.navigation.responsive-navbar';\nimport { TopBarNav } from '../top-bar-nav';\nimport styles from './menu.module.scss';\nimport { NavPlugin, OrderedNavigationSlot } from './nav-plugin';\n\nexport type MenuNavProps = {\n /**\n * @deprecated\n * use @property navPlugins\n */\n navigationSlot?: OrderedNavigationSlot;\n /**\n * @deprecated\n * use @property widgetPlugins\n */\n widgetSlot?: OrderedNavigationSlot;\n navPlugins?: [string, NavPlugin][];\n widgetPlugins?: [string, NavPlugin][];\n /**\n * A className to pass to the secondary nav, i.e dropdown\n */\n secondaryNavClassName?: string;\n activeTabIndex?: number;\n alwaysShowActiveTab?: boolean;\n} & React.HTMLAttributes<HTMLElement>;\n\nfunction TopBarNavComponent({ isInMenu, menuItemProps }: TabProps) {\n /**\n * to accommodate for the top level nav which should display the children\n * in the dropdown secondary menu if there is a displayName set\n */\n const widgetDisplayText = menuItemProps?.displayName && isInMenu ? menuItemProps?.displayName : undefined;\n return (\n <TopBarNav\n {...menuItemProps}\n className={classnames(menuItemProps?.className, styles.topBarNav, isInMenu && styles.noBorder)}\n >\n {widgetDisplayText || menuItemProps?.children}\n </TopBarNav>\n );\n}\n\nexport function CollapsibleMenuNav({\n navigationSlot,\n widgetSlot,\n navPlugins = [],\n widgetPlugins = [],\n className,\n secondaryNavClassName,\n activeTabIndex,\n alwaysShowActiveTab,\n children,\n}: MenuNavProps) {\n const plugins = useMemo(() => {\n const _navPlugins = navPlugins.length > 0 ? navPlugins : navigationSlot?.toArray();\n return (_navPlugins || []).sort(sortFn);\n }, [navigationSlot, navPlugins]);\n const widgets = useMemo(() => {\n const _widgetPlugins = widgetPlugins.length > 0 ? widgetPlugins : widgetSlot?.toArray();\n return (_widgetPlugins || []).sort(sortFn);\n }, [widgetSlot, widgetPlugins]);\n\n const links = [...plugins, ...widgets].map(([, menuItem], index) => {\n // these styles keep plugins to the left and widgets to the right.\n const lastPluginStyle = plugins.length - 1 === index ? { marginRight: 'auto' } : {};\n\n const firstWidgetStyle = plugins.length === index ? { marginLeft: 'auto' } : {};\n\n return {\n component: TopBarNavComponent,\n tabProps: {\n menuItemProps: menuItem.props,\n },\n style: { ...firstWidgetStyle, ...lastPluginStyle },\n className: menuItem.props.className,\n };\n });\n\n return (\n <ResponsiveNavbar\n navClassName={classnames(styles.tab, className)}\n secondaryNavClassName={secondaryNavClassName}\n style={{ width: '100%', height: '100%' }}\n priority=\"none\"\n tabs={links}\n defaultActiveIndex={activeTabIndex}\n alwaysShowActiveTab={alwaysShowActiveTab}\n >\n {children}\n </ResponsiveNavbar>\n );\n}\n\nfunction sortFn([, { order: first }]: [string, NavPlugin], [, { order: second }]: [string, NavPlugin]) {\n // 0 - equal\n // <0 - first < second\n // >0 - first > second\n\n return (first ?? 0) - (second ?? 0);\n}\n\n// // this is the aspect-oriented and serialize-able way to sort plugins.\n// const pluginOrder = ['teambit.docs/docs', 'teambit.compositions/compositions', 'teambit.docs/docs'];\n// export function toSortedArray<T>(slot: SlotRegistry<T>, order: string[]) {\n// // sort items according to the order\n// const sorted = order.map((x) => [x, slot.get(x)]).filter(([, val]) => !!val) as [string, T][];\n//\n// // add all other items\n// const unsorted = slot.toArray().filter(([id]) => order.indexOf(id) < 0);\n//\n// return sorted.concat(unsorted);\n// }\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,kBAAA;EAAA,MAAAL,IAAA,GAAAE,OAA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,EAAElB,KAAM;IACZmB,kBAAkB,EAAE7B,cAAe;IACnCC,mBAAmB,EAAEA;EAAoB,GAExCR,QACe,CAAC;AAEvB;AAEA,SAASc,MAAMA,CAAC,GAAG;EAAEuB,KAAK,EAAEC;AAAM,CAAC,CAAsB,EAAE,GAAG;EAAED,KAAK,EAAEE;AAAO,CAAC,CAAsB,EAAE;EACrG;EACA;EACA;;EAEA,OAAO,CAACD,KAAK,IAAI,CAAC,KAAKC,MAAM,IAAI,CAAC,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireWildcard","require","_classnames","_interopRequireDefault","_designNavigation","_topBarNav","_menuModule","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","key","value","_toPropertyKey","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","_extends","assign","bind","target","source","TopBarNavComponent","isInMenu","menuItemProps","widgetDisplayText","displayName","undefined","createElement","TopBarNav","className","classnames","styles","topBarNav","noBorder","children","CollapsibleMenuNav","navigationSlot","widgetSlot","navPlugins","widgetPlugins","secondaryNavClassName","activeTabIndex","alwaysShowActiveTab","plugins","useMemo","_navPlugins","toArray","sort","sortFn","widgets","_widgetPlugins","links","map","menuItem","index","lastPluginStyle","marginRight","firstWidgetStyle","marginLeft","component","tabProps","props","style","ResponsiveNavbar","navClassName","tab","width","height","priority","tabs","defaultActiveIndex","order","first","second"],"sources":["menu-nav.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport classnames from 'classnames';\nimport { ResponsiveNavbar } from '@teambit/design.navigation.responsive-navbar';\nimport type { TabProps } from '@teambit/design.navigation.responsive-navbar';\nimport { TopBarNav } from '../top-bar-nav';\nimport styles from './menu.module.scss';\nimport { NavPlugin, OrderedNavigationSlot } from './nav-plugin';\n\nexport type MenuNavProps = {\n /**\n * @deprecated\n * use @property navPlugins\n */\n navigationSlot?: OrderedNavigationSlot;\n /**\n * @deprecated\n * use @property widgetPlugins\n */\n widgetSlot?: OrderedNavigationSlot;\n navPlugins?: [string, NavPlugin][];\n widgetPlugins?: [string, NavPlugin][];\n /**\n * A className to pass to the secondary nav, i.e dropdown\n */\n secondaryNavClassName?: string;\n activeTabIndex?: number;\n alwaysShowActiveTab?: boolean;\n} & React.HTMLAttributes<HTMLElement>;\n\nfunction TopBarNavComponent({ isInMenu, menuItemProps }: TabProps) {\n /**\n * to accommodate for the top level nav which should display the children\n * in the dropdown secondary menu if there is a displayName set\n */\n const widgetDisplayText = menuItemProps?.displayName && isInMenu ? menuItemProps?.displayName : undefined;\n return (\n <TopBarNav\n {...menuItemProps}\n className={classnames(menuItemProps?.className, styles.topBarNav, isInMenu && styles.noBorder)}\n >\n {widgetDisplayText || menuItemProps?.children}\n </TopBarNav>\n );\n}\n\nexport function CollapsibleMenuNav({\n navigationSlot,\n widgetSlot,\n navPlugins = [],\n widgetPlugins = [],\n className,\n secondaryNavClassName,\n activeTabIndex,\n alwaysShowActiveTab,\n children,\n}: MenuNavProps) {\n const plugins = useMemo(() => {\n const _navPlugins = navPlugins.length > 0 ? navPlugins : navigationSlot?.toArray();\n return (_navPlugins || []).sort(sortFn);\n }, [navigationSlot, navPlugins]);\n const widgets = useMemo(() => {\n const _widgetPlugins = widgetPlugins.length > 0 ? widgetPlugins : widgetSlot?.toArray();\n return (_widgetPlugins || []).sort(sortFn);\n }, [widgetSlot, widgetPlugins]);\n\n const links = [...plugins, ...widgets].map(([, menuItem], index) => {\n // these styles keep plugins to the left and widgets to the right.\n const lastPluginStyle = plugins.length - 1 === index ? { marginRight: 'auto' } : {};\n\n const firstWidgetStyle = plugins.length === index ? { marginLeft: 'auto' } : {};\n\n return {\n component: TopBarNavComponent,\n tabProps: {\n menuItemProps: menuItem.props,\n },\n style: { ...firstWidgetStyle, ...lastPluginStyle },\n className: menuItem.props.className,\n };\n });\n\n return (\n <ResponsiveNavbar\n navClassName={classnames(styles.tab, className)}\n secondaryNavClassName={secondaryNavClassName}\n style={{ width: '100%', height: '100%' }}\n priority=\"none\"\n tabs={links}\n defaultActiveIndex={activeTabIndex}\n alwaysShowActiveTab={alwaysShowActiveTab}\n >\n {children}\n </ResponsiveNavbar>\n );\n}\n\nfunction sortFn([, { order: first }]: [string, NavPlugin], [, { order: second }]: [string, NavPlugin]) {\n // 0 - equal\n // <0 - first < second\n // >0 - first > second\n\n return (first ?? 0) - (second ?? 0);\n}\n\n// // this is the aspect-oriented and serialize-able way to sort plugins.\n// const pluginOrder = ['teambit.docs/docs', 'teambit.compositions/compositions', 'teambit.docs/docs'];\n// export function toSortedArray<T>(slot: SlotRegistry<T>, order: string[]) {\n// // sort items according to the order\n// const sorted = order.map((x) => [x, slot.get(x)]).filter(([, val]) => !!val) as [string, T][];\n//\n// // add all other items\n// const unsorted = slot.toArray().filter(([id]) => order.indexOf(id) < 0);\n//\n// return sorted.concat(unsorted);\n// }\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,kBAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,iBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,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