@teambit/component 0.0.639 → 0.0.643
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/{__preview-1643772133658.js → __preview-1644248123158.js} +1 -1
- package/dist/ui/menu/menu.js +26 -5
- package/dist/ui/menu/menu.js.map +1 -1
- package/dist/ui/use-component-query.js +2 -0
- package/dist/ui/use-component-query.js.map +1 -1
- package/package-tar/teambit-component-0.0.643.tgz +0 -0
- package/package.json +18 -17
- package/ui/menu/menu.tsx +23 -13
- package/ui/use-component-query.ts +2 -0
- package/package-tar/teambit-component-0.0.639.tgz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.
|
|
1
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.643/dist/component.docs.mdx')]
|
package/dist/ui/menu/menu.js
CHANGED
|
@@ -4,6 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
|
|
5
5
|
require("core-js/modules/es.array.iterator.js");
|
|
6
6
|
|
|
7
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
8
|
+
|
|
7
9
|
Object.defineProperty(exports, "__esModule", {
|
|
8
10
|
value: true
|
|
9
11
|
});
|
|
@@ -39,6 +41,16 @@ function _fullLoader() {
|
|
|
39
41
|
return data;
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
function _baseUiRouting() {
|
|
45
|
+
const data = require("@teambit/base-ui.routing.routing-provider");
|
|
46
|
+
|
|
47
|
+
_baseUiRouting = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
function _lodash() {
|
|
43
55
|
const data = require("lodash");
|
|
44
56
|
|
|
@@ -153,7 +165,8 @@ function Menu({
|
|
|
153
165
|
navigationSlot: widgetSlot
|
|
154
166
|
})), /*#__PURE__*/_react().default.createElement(VersionRelatedDropdowns, {
|
|
155
167
|
component: component,
|
|
156
|
-
consumeMethods: consumeMethodSlot
|
|
168
|
+
consumeMethods: consumeMethodSlot,
|
|
169
|
+
host: host
|
|
157
170
|
}), /*#__PURE__*/_react().default.createElement(_uiFoundationUi().MainDropdown, {
|
|
158
171
|
menuItems: mainMenuItems
|
|
159
172
|
})));
|
|
@@ -161,17 +174,24 @@ function Menu({
|
|
|
161
174
|
|
|
162
175
|
function VersionRelatedDropdowns({
|
|
163
176
|
component,
|
|
164
|
-
consumeMethods
|
|
177
|
+
consumeMethods,
|
|
178
|
+
host
|
|
165
179
|
}) {
|
|
180
|
+
const location = (0, _baseUiRouting().useLocation)();
|
|
181
|
+
const isNew = component.tags.isEmpty();
|
|
182
|
+
const isWorkspace = host === 'teambit.workspace/workspace';
|
|
166
183
|
const versionList = (0, _react().useMemo)(() => {
|
|
167
184
|
var _component$tags;
|
|
168
185
|
|
|
169
|
-
|
|
186
|
+
const tagsArray = (_component$tags = component.tags) === null || _component$tags === void 0 ? void 0 : _component$tags.toArray().map(tag => {
|
|
170
187
|
var _tag$version;
|
|
171
188
|
|
|
172
189
|
return tag === null || tag === void 0 ? void 0 : (_tag$version = tag.version) === null || _tag$version === void 0 ? void 0 : _tag$version.version;
|
|
173
190
|
}).filter(x => x !== undefined).reverse();
|
|
174
|
-
|
|
191
|
+
const wsLink = [isWorkspace && !isNew ? 'workspace' : undefined];
|
|
192
|
+
return (0, _lodash().compact)([...wsLink, ...tagsArray]);
|
|
193
|
+
}, [component.tags, isWorkspace, isNew]);
|
|
194
|
+
const currentVersion = isWorkspace && !isNew && !location.search.includes('version') ? 'workspace' : component.version;
|
|
175
195
|
const methods = useConsumeMethods(consumeMethods, component);
|
|
176
196
|
return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, versionList.length > 0 && /*#__PURE__*/_react().default.createElement(_uiFoundationUiUseBox().UseBoxDropdown, {
|
|
177
197
|
position: "bottom-end",
|
|
@@ -182,7 +202,8 @@ function VersionRelatedDropdowns({
|
|
|
182
202
|
})
|
|
183
203
|
}), /*#__PURE__*/_react().default.createElement(_componentUi().VersionDropdown, {
|
|
184
204
|
versions: versionList,
|
|
185
|
-
currentVersion:
|
|
205
|
+
currentVersion: currentVersion,
|
|
206
|
+
latestVersion: component.latest
|
|
186
207
|
}));
|
|
187
208
|
}
|
|
188
209
|
|
package/dist/ui/menu/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["menu.tsx"],"names":["Menu","navigationSlot","widgetSlot","className","host","menuItemSlot","consumeMethodSlot","component","mainMenuItems","values","styles","topBar","leftSide","rightSide","widgets","VersionRelatedDropdowns","consumeMethods","
|
|
1
|
+
{"version":3,"sources":["menu.tsx"],"names":["Menu","navigationSlot","widgetSlot","className","host","menuItemSlot","consumeMethodSlot","component","mainMenuItems","values","styles","topBar","leftSide","rightSide","widgets","VersionRelatedDropdowns","consumeMethods","location","isNew","tags","isEmpty","isWorkspace","versionList","tagsArray","toArray","map","tag","version","filter","x","undefined","reverse","wsLink","currentVersion","search","includes","methods","useConsumeMethods","length","useBox","id","name","latest","componentModel","method","Component","Title"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;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AV,CAAaC;AAAlE;AAHR,IAFJ,eAQE,+BAAC,8BAAD;AAAiB,IAAA,QAAQ,EAAEnB,WAA3B;AAAwC,IAAA,cAAc,EAAEW,cAAxD;AAAwE,IAAA,aAAa,EAAE1B,SAAS,CAACmC;AAAjG,IARF,CADF;AAYD;;AAED,SAASL,iBAAT,CAA2BrB,cAA3B,EAA8D2B,cAA9D,EAA+G;AAC7G,SAAO,sBACL,MACE,uBAAQ3B,cAAc,CAACP,MAAf,EAAR,EACGgB,GADH,CACQmB,MAAD,IAAY;AACf,WAAOA,MAAP,aAAOA,MAAP,uBAAOA,MAAM,CAAGD,cAAH,CAAb;AACD,GAHH,EAIGf,MAJH,CAIWC,CAAD,IAAO,CAAC,CAACA,CAAF,IAAOA,CAAC,CAACgB,SAAT,IAAsBhB,CAAC,CAACiB,KAJzC,CAFG,EAOL,CAAC9B,cAAD,EAAiB2B,cAAjB,CAPK,CAAP;AASD","sourcesContent":["import { MainDropdown, MenuItemSlot } from '@teambit/ui-foundation.ui.main-dropdown';\nimport { VersionDropdown } from '@teambit/component.ui.version-dropdown';\nimport { FullLoader } from '@teambit/legacy/dist/to-eject/full-loader';\nimport type { ConsumeMethod } from '@teambit/ui-foundation.ui.use-box.menu';\nimport { useLocation } from '@teambit/base-ui.routing.routing-provider';\nimport { compact, flatten, groupBy } from 'lodash';\nimport classnames from 'classnames';\nimport React, { useMemo } from 'react';\nimport { UseBoxDropdown } from '@teambit/ui-foundation.ui.use-box.dropdown';\nimport { Menu as ConsumeMethodsMenu } from '@teambit/ui-foundation.ui.use-box.menu';\nimport type { ComponentModel } from '../component-model';\nimport { useComponent } from '../use-component';\nimport { MenuNav } from './menu-nav';\nimport styles from './menu.module.scss';\nimport { OrderedNavigationSlot, ConsumeMethodSlot } from './nav-plugin';\n\nexport type MenuProps = {\n className?: string;\n /**\n * slot for top bar menu nav items\n */\n navigationSlot: OrderedNavigationSlot;\n /**\n * right side menu item slot\n */\n widgetSlot: OrderedNavigationSlot;\n host: string;\n /**\n * main dropdown item slot\n */\n menuItemSlot: MenuItemSlot;\n\n consumeMethodSlot: ConsumeMethodSlot;\n};\n\n/**\n * top bar menu.\n */\nexport function Menu({ navigationSlot, widgetSlot, className, host, menuItemSlot, consumeMethodSlot }: MenuProps) {\n const { component } = useComponent(host);\n const mainMenuItems = useMemo(() => groupBy(flatten(menuItemSlot.values()), 'category'), [menuItemSlot]);\n if (!component) return <FullLoader />;\n return (\n <div className={classnames(styles.topBar, className)}>\n <div className={styles.leftSide}>\n <MenuNav navigationSlot={navigationSlot} />\n </div>\n <div className={styles.rightSide}>\n <div className={styles.widgets}>\n <MenuNav navigationSlot={widgetSlot} />\n </div>\n <VersionRelatedDropdowns component={component} consumeMethods={consumeMethodSlot} host={host} />\n <MainDropdown menuItems={mainMenuItems} />\n </div>\n </div>\n );\n}\n\nfunction VersionRelatedDropdowns({\n component,\n consumeMethods,\n host,\n}: {\n component: ComponentModel;\n consumeMethods: ConsumeMethodSlot;\n host: string;\n}) {\n const location = useLocation();\n const isNew = component.tags.isEmpty();\n\n const isWorkspace = host === 'teambit.workspace/workspace';\n const versionList = useMemo(() => {\n const tagsArray = component.tags\n ?.toArray()\n .map((tag) => tag?.version?.version)\n .filter((x) => x !== undefined)\n .reverse();\n const wsLink = [isWorkspace && !isNew ? 'workspace' : undefined];\n\n return compact([...wsLink, ...tagsArray]);\n }, [component.tags, isWorkspace, isNew]);\n\n const currentVersion =\n isWorkspace && !isNew && !location.search.includes('version') ? 'workspace' : component.version;\n\n const methods = useConsumeMethods(consumeMethods, component);\n return (\n <>\n {versionList.length > 0 && (\n <UseBoxDropdown\n position=\"bottom-end\"\n className={styles.useBox}\n Menu={<ConsumeMethodsMenu methods={methods} componentName={component.id.name} />}\n />\n )}\n <VersionDropdown versions={versionList} currentVersion={currentVersion} latestVersion={component.latest} />\n </>\n );\n}\n\nfunction useConsumeMethods(consumeMethods: ConsumeMethodSlot, componentModel: ComponentModel): ConsumeMethod[] {\n return useMemo(\n () =>\n flatten(consumeMethods.values())\n .map((method) => {\n return method?.(componentModel);\n })\n .filter((x) => !!x && x.Component && x.Title) as ConsumeMethod[],\n [consumeMethods, componentModel]\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["use-component-query.ts"],"names":["componentIdFields","componentFields","GET_COMPONENT","SUB_SUBSCRIPTION_ADDED","SUB_COMPONENT_CHANGED","SUB_COMPONENT_REMOVED","useComponentQuery","componentId","host","idRef","current","data","error","loading","subscribeToMore","variables","id","extensionId","unsubAddition","document","updateQuery","prev","subscriptionData","prevComponent","getHost","get","addedComponent","componentAdded","component","name","unsubChanges","updatedComponent","componentChanged","isUpdated","ComponentID","isEqualObj","unsubRemoval","removedIds","componentRemoved","componentIds","length","isRemoved","some","removedId","rawComponent","ComponentModel","from","undefined","ComponentError","message"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEA,MAAMA,iBAAiB,GAAG,kBAAI;AAC9B;AACA;AACA;AACA;AACA;AACA,CANA;AAQA,MAAMC,eAAe,GAAG,kBAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,iBAAkB;AACtB,
|
|
1
|
+
{"version":3,"sources":["use-component-query.ts"],"names":["componentIdFields","componentFields","GET_COMPONENT","SUB_SUBSCRIPTION_ADDED","SUB_COMPONENT_CHANGED","SUB_COMPONENT_REMOVED","useComponentQuery","componentId","host","idRef","current","data","error","loading","subscribeToMore","variables","id","extensionId","unsubAddition","document","updateQuery","prev","subscriptionData","prevComponent","getHost","get","addedComponent","componentAdded","component","name","unsubChanges","updatedComponent","componentChanged","isUpdated","ComponentID","isEqualObj","unsubRemoval","removedIds","componentRemoved","componentIds","length","isRemoved","some","removedId","rawComponent","ComponentModel","from","undefined","ComponentError","message"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEA,MAAMA,iBAAiB,GAAG,kBAAI;AAC9B;AACA;AACA;AACA;AACA;AACA,CANA;AAQA,MAAMC,eAAe,GAAG,kBAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,iBAAkB;AACtB,CAhCA;AAkCA,MAAME,aAAa,GAAG,kBAAI;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAID,eAAgB;AACpB,CAVA;AAYA,MAAME,sBAAsB,GAAG,kBAAI;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIF,eAAgB;AACpB,CATA;AAWA,MAAMG,qBAAqB,GAAG,kBAAI;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIH,eAAgB;AACpB,CATA;AAWA,MAAMI,qBAAqB,GAAG,kBAAI;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIL,iBAAkB;AACtB,CATA;AAWA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,YAAI,CAAChB,aAAD,IAAkB,EAACc,UAAD,aAACA,UAAD,eAACA,UAAU,CAAEG,MAAb,CAAtB,EAA2C,OAAOnB,IAAP;AAE3C,cAAMoB,SAAS,GAAGJ,UAAU,CAACK,IAAX,CAAiBC,SAAD,IAAeT,2BAAYC,UAAZ,CAAuBQ,SAAvB,EAAkCpB,aAAa,CAACP,EAAhD,CAA/B,CAAlB;;AAEA,YAAIyB,SAAJ,EAAe;AACb,iDACKpB,IADL;AAEEG,YAAAA,OAAO,kCACFH,IAAI,CAACG,OADH;AAELC,cAAAA,GAAG,EAAE;AAFA;AAFT;AAOD;;AAED,eAAOJ,IAAP;AACD;AAtBkC,KAAD,CAApC;AAyBA,WAAO,MAAM;AACXS,MAAAA,YAAY;AACZZ,MAAAA,aAAa;AACbkB,MAAAA,YAAY;AACb,KAJD;AAKD,GAlFD,EAkFG,EAlFH;AAoFA,QAAMQ,YAAY,GAAGjC,IAAH,aAAGA,IAAH,wCAAGA,IAAI,CAAEa,OAAT,kDAAG,cAAeC,GAApC;AAEA,SAAO,sBAAQ,MAAM;AACnB,WAAO;AACLG,MAAAA,SAAS,EAAEgB,YAAY,GAAGC,iCAAeC,IAAf,iCAAyBF,YAAzB;AAAuCpC,QAAAA;AAAvC,SAAH,GAAoDuC,SADtE;AAEL;AACAnC,MAAAA,KAAK,EAAEA,KAAK,GACR,KAAIoC,gCAAJ,EAAmB,GAAnB,EAAwBpC,KAAK,CAACqC,OAA9B,CADQ,GAER,CAACL,YAAD,IAAiB,CAAC/B,OAAlB,GACA,KAAImC,gCAAJ,EAAmB,GAAnB,CADA,GAEAD;AAPC,KAAP;AASD,GAVM,EAUJ,CAACH,YAAD,EAAepC,IAAf,EAAqBI,KAArB,CAVI,CAAP;AAWD","sourcesContent":["import { useMemo, useEffect, useRef } from 'react';\nimport { gql } from '@apollo/client';\nimport { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query';\nimport { ComponentID, ComponentIdObj } from '@teambit/component-id';\n\nimport { ComponentModel } from './component-model';\nimport { ComponentError } from './component-error';\n\nconst componentIdFields = gql`\n fragment componentIdFields on ComponentID {\n name\n version\n scope\n }\n`;\n\nconst componentFields = gql`\n fragment componentFields on Component {\n id {\n ...componentIdFields\n }\n packageName\n elementsUrl\n description\n labels\n displayName\n latest\n server {\n env\n url\n }\n buildStatus\n compositions {\n identifier\n displayName\n }\n tags {\n version\n }\n env {\n id\n icon\n }\n preview {\n includesEnvTemplate\n }\n }\n ${componentIdFields}\n`;\n\nconst GET_COMPONENT = gql`\n query Component($id: String!, $extensionId: String!) {\n getHost(id: $extensionId) {\n id # used for GQL caching\n get(id: $id) {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nconst SUB_SUBSCRIPTION_ADDED = gql`\n subscription OnComponentAdded {\n componentAdded {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nconst SUB_COMPONENT_CHANGED = gql`\n subscription OnComponentChanged {\n componentChanged {\n component {\n ...componentFields\n }\n }\n }\n ${componentFields}\n`;\n\nconst SUB_COMPONENT_REMOVED = gql`\n subscription OnComponentRemoved {\n componentRemoved {\n componentIds {\n ...componentIdFields\n }\n }\n }\n ${componentIdFields}\n`;\n\n/** provides data to component ui page, making sure both variables and return value are safely typed and memoized */\nexport function useComponentQuery(componentId: string, host: string) {\n const idRef = useRef(componentId);\n idRef.current = componentId;\n const { data, error, loading, subscribeToMore } = useDataQuery(GET_COMPONENT, {\n variables: { id: componentId, extensionId: host },\n });\n\n useEffect(() => {\n // @TODO @Kutner fix subscription for scope\n if (host !== 'teambit.workspace/workspace') {\n return () => {};\n }\n\n const unsubAddition = subscribeToMore({\n document: SUB_SUBSCRIPTION_ADDED,\n updateQuery: (prev, { subscriptionData }) => {\n const prevComponent = prev?.getHost?.get;\n const addedComponent = subscriptionData?.data?.componentAdded?.component;\n\n if (!addedComponent || prevComponent) return prev;\n\n if (idRef.current === addedComponent.id.name) {\n return {\n ...prev,\n getHost: {\n ...prev.getHost,\n get: addedComponent,\n },\n };\n }\n\n return prev;\n },\n });\n\n const unsubChanges = subscribeToMore({\n document: SUB_COMPONENT_CHANGED,\n updateQuery: (prev, { subscriptionData }) => {\n if (!subscriptionData.data) return prev;\n\n const prevComponent = prev?.getHost?.get;\n const updatedComponent = subscriptionData?.data?.componentChanged?.component;\n\n const isUpdated = updatedComponent && ComponentID.isEqualObj(prevComponent?.id, updatedComponent?.id);\n\n if (isUpdated) {\n return {\n ...prev,\n getHost: {\n ...prev.getHost,\n get: updatedComponent,\n },\n };\n }\n\n return prev;\n },\n });\n\n const unsubRemoval = subscribeToMore({\n document: SUB_COMPONENT_REMOVED,\n updateQuery: (prev, { subscriptionData }) => {\n if (!subscriptionData.data) return prev;\n\n const prevComponent = prev?.getHost?.get;\n const removedIds: ComponentIdObj[] | undefined = subscriptionData?.data?.componentRemoved?.componentIds;\n if (!prevComponent || !removedIds?.length) return prev;\n\n const isRemoved = removedIds.some((removedId) => ComponentID.isEqualObj(removedId, prevComponent.id));\n\n if (isRemoved) {\n return {\n ...prev,\n getHost: {\n ...prev.getHost,\n get: null,\n },\n };\n }\n\n return prev;\n },\n });\n\n return () => {\n unsubChanges();\n unsubAddition();\n unsubRemoval();\n };\n }, []);\n\n const rawComponent = data?.getHost?.get;\n\n return useMemo(() => {\n return {\n component: rawComponent ? ComponentModel.from({ ...rawComponent, host }) : undefined,\n // eslint-disable-next-line\n error: error\n ? new ComponentError(500, error.message)\n : !rawComponent && !loading\n ? new ComponentError(404)\n : undefined,\n };\n }, [rawComponent, host, error]);\n}\n"]}
|
|
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.643",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/component/component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "component",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.643"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -26,24 +26,25 @@
|
|
|
26
26
|
"@teambit/base-ui.routing.nav-link": "1.0.0",
|
|
27
27
|
"@teambit/documenter.ui.heading": "4.1.1",
|
|
28
28
|
"@teambit/documenter.ui.separator": "4.1.1",
|
|
29
|
+
"@teambit/base-ui.routing.routing-provider": "1.0.0",
|
|
29
30
|
"@teambit/component-id": "0.0.400",
|
|
30
31
|
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.487",
|
|
31
|
-
"@teambit/aspect-loader": "0.0.
|
|
32
|
+
"@teambit/aspect-loader": "0.0.643",
|
|
32
33
|
"@teambit/legacy-bit-id": "0.0.397",
|
|
33
34
|
"@teambit/toolbox.string.capitalize": "0.0.482",
|
|
34
|
-
"@teambit/cli": "0.0.
|
|
35
|
-
"@teambit/config": "0.0.
|
|
36
|
-
"@teambit/express": "0.0.
|
|
37
|
-
"@teambit/graphql": "0.0.
|
|
35
|
+
"@teambit/cli": "0.0.438",
|
|
36
|
+
"@teambit/config": "0.0.451",
|
|
37
|
+
"@teambit/express": "0.0.532",
|
|
38
|
+
"@teambit/graphql": "0.0.643",
|
|
38
39
|
"@teambit/bit-error": "0.0.394",
|
|
39
|
-
"@teambit/command-bar": "0.0.
|
|
40
|
-
"@teambit/preview": "0.0.
|
|
41
|
-
"@teambit/pubsub": "0.0.
|
|
40
|
+
"@teambit/command-bar": "0.0.643",
|
|
41
|
+
"@teambit/preview": "0.0.643",
|
|
42
|
+
"@teambit/pubsub": "0.0.643",
|
|
42
43
|
"@teambit/ui-foundation.ui.is-browser": "0.0.485",
|
|
43
44
|
"@teambit/ui-foundation.ui.main-dropdown": "0.0.485",
|
|
44
45
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.487",
|
|
45
46
|
"@teambit/ui-foundation.ui.use-box.menu": "0.0.108",
|
|
46
|
-
"@teambit/ui": "0.0.
|
|
47
|
+
"@teambit/ui": "0.0.643",
|
|
47
48
|
"@teambit/component-issues": "0.0.45",
|
|
48
49
|
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.486",
|
|
49
50
|
"@teambit/cli-table": "0.0.33",
|
|
@@ -52,10 +53,10 @@
|
|
|
52
53
|
"@teambit/harmony.ui.aspect-box": "0.0.485",
|
|
53
54
|
"@teambit/design.ui.pages.not-found": "0.0.353",
|
|
54
55
|
"@teambit/design.ui.pages.server-error": "0.0.353",
|
|
55
|
-
"@teambit/compositions": "0.0.
|
|
56
|
-
"@teambit/deprecation": "0.0.
|
|
57
|
-
"@teambit/envs": "0.0.
|
|
58
|
-
"@teambit/component.ui.version-dropdown": "0.0.
|
|
56
|
+
"@teambit/compositions": "0.0.643",
|
|
57
|
+
"@teambit/deprecation": "0.0.643",
|
|
58
|
+
"@teambit/envs": "0.0.643",
|
|
59
|
+
"@teambit/component.ui.version-dropdown": "0.0.491",
|
|
59
60
|
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.108",
|
|
60
61
|
"@teambit/ui-foundation.ui.react-router.extend-path": "0.0.485"
|
|
61
62
|
},
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
},
|
|
77
78
|
"peerDependencies": {
|
|
78
79
|
"@apollo/client": "^3.0.0",
|
|
79
|
-
"@teambit/legacy": "1.0.
|
|
80
|
+
"@teambit/legacy": "1.0.216",
|
|
80
81
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
81
82
|
"react": "^16.8.0 || ^17.0.0"
|
|
82
83
|
},
|
|
@@ -104,7 +105,7 @@
|
|
|
104
105
|
"react": "-"
|
|
105
106
|
},
|
|
106
107
|
"peerDependencies": {
|
|
107
|
-
"@teambit/legacy": "1.0.
|
|
108
|
+
"@teambit/legacy": "1.0.216",
|
|
108
109
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
109
110
|
"react": "^16.8.0 || ^17.0.0"
|
|
110
111
|
}
|
package/ui/menu/menu.tsx
CHANGED
|
@@ -2,7 +2,8 @@ import { MainDropdown, MenuItemSlot } from '@teambit/ui-foundation.ui.main-dropd
|
|
|
2
2
|
import { VersionDropdown } from '@teambit/component.ui.version-dropdown';
|
|
3
3
|
import { FullLoader } from '@teambit/legacy/dist/to-eject/full-loader';
|
|
4
4
|
import type { ConsumeMethod } from '@teambit/ui-foundation.ui.use-box.menu';
|
|
5
|
-
import {
|
|
5
|
+
import { useLocation } from '@teambit/base-ui.routing.routing-provider';
|
|
6
|
+
import { compact, flatten, groupBy } from 'lodash';
|
|
6
7
|
import classnames from 'classnames';
|
|
7
8
|
import React, { useMemo } from 'react';
|
|
8
9
|
import { UseBoxDropdown } from '@teambit/ui-foundation.ui.use-box.dropdown';
|
|
@@ -48,7 +49,7 @@ export function Menu({ navigationSlot, widgetSlot, className, host, menuItemSlot
|
|
|
48
49
|
<div className={styles.widgets}>
|
|
49
50
|
<MenuNav navigationSlot={widgetSlot} />
|
|
50
51
|
</div>
|
|
51
|
-
<VersionRelatedDropdowns component={component} consumeMethods={consumeMethodSlot} />
|
|
52
|
+
<VersionRelatedDropdowns component={component} consumeMethods={consumeMethodSlot} host={host} />
|
|
52
53
|
<MainDropdown menuItems={mainMenuItems} />
|
|
53
54
|
</div>
|
|
54
55
|
</div>
|
|
@@ -58,20 +59,29 @@ export function Menu({ navigationSlot, widgetSlot, className, host, menuItemSlot
|
|
|
58
59
|
function VersionRelatedDropdowns({
|
|
59
60
|
component,
|
|
60
61
|
consumeMethods,
|
|
62
|
+
host,
|
|
61
63
|
}: {
|
|
62
64
|
component: ComponentModel;
|
|
63
65
|
consumeMethods: ConsumeMethodSlot;
|
|
66
|
+
host: string;
|
|
64
67
|
}) {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
const location = useLocation();
|
|
69
|
+
const isNew = component.tags.isEmpty();
|
|
70
|
+
|
|
71
|
+
const isWorkspace = host === 'teambit.workspace/workspace';
|
|
72
|
+
const versionList = useMemo(() => {
|
|
73
|
+
const tagsArray = component.tags
|
|
74
|
+
?.toArray()
|
|
75
|
+
.map((tag) => tag?.version?.version)
|
|
76
|
+
.filter((x) => x !== undefined)
|
|
77
|
+
.reverse();
|
|
78
|
+
const wsLink = [isWorkspace && !isNew ? 'workspace' : undefined];
|
|
79
|
+
|
|
80
|
+
return compact([...wsLink, ...tagsArray]);
|
|
81
|
+
}, [component.tags, isWorkspace, isNew]);
|
|
82
|
+
|
|
83
|
+
const currentVersion =
|
|
84
|
+
isWorkspace && !isNew && !location.search.includes('version') ? 'workspace' : component.version;
|
|
75
85
|
|
|
76
86
|
const methods = useConsumeMethods(consumeMethods, component);
|
|
77
87
|
return (
|
|
@@ -83,7 +93,7 @@ function VersionRelatedDropdowns({
|
|
|
83
93
|
Menu={<ConsumeMethodsMenu methods={methods} componentName={component.id.name} />}
|
|
84
94
|
/>
|
|
85
95
|
)}
|
|
86
|
-
<VersionDropdown versions={versionList} currentVersion={component.
|
|
96
|
+
<VersionDropdown versions={versionList} currentVersion={currentVersion} latestVersion={component.latest} />
|
|
87
97
|
</>
|
|
88
98
|
);
|
|
89
99
|
}
|
|
Binary file
|