@teambit/component 0.0.742 → 0.0.745
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aspect.section.tsx +1 -1
- package/component.ui.runtime.tsx +10 -11
- package/dist/aspect.section.d.ts +1 -1
- package/dist/aspect.section.js +1 -1
- package/dist/aspect.section.js.map +1 -1
- package/dist/component.ui.runtime.d.ts +5 -8
- package/dist/component.ui.runtime.js +7 -9
- package/dist/component.ui.runtime.js.map +1 -1
- package/dist/section/section.d.ts +2 -2
- package/dist/section/section.js.map +1 -1
- package/dist/ui/component.js +14 -2
- package/dist/ui/component.js.map +1 -1
- package/dist/ui/menu/index.d.ts +1 -1
- package/dist/ui/menu/index.js +2 -2
- package/dist/ui/menu/index.js.map +1 -1
- package/dist/ui/menu/menu.d.ts +1 -1
- package/dist/ui/menu/menu.js +54 -30
- package/dist/ui/menu/menu.js.map +1 -1
- package/dist/ui/menu/mobile-menu-nav.js +7 -23
- package/dist/ui/menu/mobile-menu-nav.js.map +1 -1
- package/dist/ui/menu/nav-plugin.d.ts +2 -2
- package/dist/ui/menu/nav-plugin.js.map +1 -1
- package/dist/ui/top-bar-nav/top-bar-nav.d.ts +2 -2
- package/dist/ui/top-bar-nav/top-bar-nav.js +5 -18
- package/dist/ui/top-bar-nav/top-bar-nav.js.map +1 -1
- package/dist/ui/use-component-from-location.d.ts +1 -0
- package/dist/ui/use-component-from-location.js +31 -0
- package/dist/ui/use-component-from-location.js.map +1 -0
- package/dist/ui/use-component.d.ts +1 -1
- package/dist/ui/use-component.js +2 -17
- package/dist/ui/use-component.js.map +1 -1
- package/package-tar/teambit-component-0.0.745.tgz +0 -0
- package/package.json +29 -32
- package/{preview-1653535588073.js → preview-1653836960096.js} +2 -2
- package/section/section.tsx +2 -2
- package/ui/component.tsx +7 -3
- package/ui/menu/index.ts +1 -1
- package/ui/menu/menu.tsx +34 -17
- package/ui/menu/mobile-menu-nav.tsx +14 -15
- package/ui/menu/nav-plugin.tsx +2 -3
- package/ui/top-bar-nav/top-bar-nav.tsx +6 -8
- package/ui/use-component-from-location.tsx +12 -0
- package/ui/use-component.tsx +4 -10
- package/package-tar/teambit-component-0.0.742.tgz +0 -0
|
@@ -81,16 +81,6 @@ function _designInputs() {
|
|
|
81
81
|
return data;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function _uiFoundationUiReactRouter() {
|
|
85
|
-
const data = require("@teambit/ui-foundation.ui.react-router.extend-path");
|
|
86
|
-
|
|
87
|
-
_uiFoundationUiReactRouter = function () {
|
|
88
|
-
return data;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return data;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
84
|
function _topBarNav() {
|
|
95
85
|
const data = require("../top-bar-nav");
|
|
96
86
|
|
|
@@ -130,15 +120,11 @@ function MobileMenuNav({
|
|
|
130
120
|
widgetSlot,
|
|
131
121
|
className
|
|
132
122
|
}) {
|
|
133
|
-
const {
|
|
134
|
-
url
|
|
135
|
-
} = (0, _reactRouterDom().useRouteMatch)();
|
|
136
123
|
const totalSlots = (0, _react().useMemo)(() => [...navigationSlot.toArray().sort(sortFn), ...widgetSlot.toArray().sort(sortFn)], [navigationSlot, widgetSlot]);
|
|
137
124
|
return /*#__PURE__*/_react().default.createElement(_designInputs().Dropdown // @ts-ignore - mismatch between @types/react
|
|
138
125
|
, {
|
|
139
126
|
placeholder: /*#__PURE__*/_react().default.createElement(Placeholder, {
|
|
140
|
-
slots: totalSlots
|
|
141
|
-
baseUrl: url
|
|
127
|
+
slots: totalSlots
|
|
142
128
|
}),
|
|
143
129
|
className: (0, _classnames().default)(_menuModule().default.navigation, _menuModule().default.mobileNav, className),
|
|
144
130
|
dropClass: _mobileMenuNavModule().default.mobileMenu
|
|
@@ -168,21 +154,19 @@ function sortFn([, {
|
|
|
168
154
|
|
|
169
155
|
function Placeholder(_ref) {
|
|
170
156
|
let {
|
|
171
|
-
slots
|
|
172
|
-
baseUrl = ''
|
|
157
|
+
slots
|
|
173
158
|
} = _ref,
|
|
174
|
-
rest = (0, _objectWithoutProperties2().default)(_ref, ["slots"
|
|
159
|
+
rest = (0, _objectWithoutProperties2().default)(_ref, ["slots"]);
|
|
175
160
|
return /*#__PURE__*/_react().default.createElement("div", (0, _extends2().default)({}, rest, {
|
|
176
161
|
className: _mobileMenuNavModule().default.placeholder
|
|
177
|
-
}), /*#__PURE__*/_react().default.createElement(_reactRouterDom().
|
|
162
|
+
}), /*#__PURE__*/_react().default.createElement(_reactRouterDom().Routes, null, slots === null || slots === void 0 ? void 0 : slots.map(([id, menuItem]) => {
|
|
178
163
|
var _menuItem$props, _menuItem$props2, _menuItem$props3, _menuItem$props4;
|
|
179
164
|
|
|
180
|
-
const path = (0, _uiFoundationUiReactRouter().extendPath)(baseUrl, menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props = menuItem.props) === null || _menuItem$props === void 0 ? void 0 : _menuItem$props.href);
|
|
181
165
|
return /*#__PURE__*/_react().default.createElement(_reactRouterDom().Route, {
|
|
182
166
|
key: id,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
167
|
+
path: menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props = menuItem.props) === null || _menuItem$props === void 0 ? void 0 : _menuItem$props.href,
|
|
168
|
+
element: typeof (menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props2 = menuItem.props) === null || _menuItem$props2 === void 0 ? void 0 : _menuItem$props2.children) === 'string' ? menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props3 = menuItem.props) === null || _menuItem$props3 === void 0 ? void 0 : _menuItem$props3.children : menuItem === null || menuItem === void 0 ? void 0 : (_menuItem$props4 = menuItem.props) === null || _menuItem$props4 === void 0 ? void 0 : _menuItem$props4.displayName
|
|
169
|
+
});
|
|
186
170
|
})), /*#__PURE__*/_react().default.createElement(_designElements().Icon, {
|
|
187
171
|
of: "fat-arrow-down"
|
|
188
172
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MobileMenuNav","navigationSlot","widgetSlot","className","
|
|
1
|
+
{"version":3,"names":["MobileMenuNav","navigationSlot","widgetSlot","className","totalSlots","useMemo","toArray","sort","sortFn","classnames","styles","navigation","mobileNav","mobileStyles","mobileMenu","close","map","id","menuItem","props","mobileMenuLink","active","children","displayName","order","first","second","Placeholder","slots","rest","placeholder","href"],"sources":["mobile-menu-nav.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { Routes, Route } from 'react-router-dom';\nimport classnames from 'classnames';\nimport { Icon } from '@teambit/design.elements.icon';\nimport { Dropdown } from '@teambit/design.inputs.dropdown';\nimport { TopBarNav } from '../top-bar-nav';\nimport styles from './menu.module.scss';\nimport mobileStyles from './mobile-menu-nav.module.scss';\nimport { NavPlugin, OrderedNavigationSlot } from './nav-plugin';\n\nexport function MobileMenuNav({\n navigationSlot,\n widgetSlot,\n className,\n}: {\n navigationSlot: OrderedNavigationSlot;\n widgetSlot: OrderedNavigationSlot;\n className?: string;\n}) {\n const totalSlots = useMemo(\n () => [...navigationSlot.toArray().sort(sortFn), ...widgetSlot.toArray().sort(sortFn)],\n [navigationSlot, widgetSlot]\n );\n\n return (\n <Dropdown\n // @ts-ignore - mismatch between @types/react\n placeholder={<Placeholder slots={totalSlots} />}\n className={classnames(styles.navigation, styles.mobileNav, className)}\n dropClass={mobileStyles.mobileMenu}\n >\n <nav>\n <Icon of=\"x-thick\" className={mobileStyles.close} />\n {totalSlots.map(([id, menuItem]) => {\n return (\n <TopBarNav\n key={id}\n {...menuItem.props}\n className={mobileStyles.mobileMenuLink}\n activeClassName={mobileStyles.active}\n >\n {typeof menuItem.props.children === 'string' ? menuItem.props.children : menuItem.props.displayName}\n </TopBarNav>\n );\n })}\n </nav>\n </Dropdown>\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\ntype PlaceholderProps = {\n slots: [string, NavPlugin][];\n baseUrl?: string;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nfunction Placeholder({ slots, ...rest }: PlaceholderProps) {\n return (\n <div {...rest} className={mobileStyles.placeholder}>\n <Routes>\n {slots?.map(([id, menuItem]) => (\n <Route\n key={id}\n path={menuItem?.props?.href}\n element={\n typeof menuItem?.props?.children === 'string' ? menuItem?.props?.children : menuItem?.props?.displayName\n }\n />\n ))}\n </Routes>\n <Icon of=\"fat-arrow-down\" />\n </div>\n );\n}\n"],"mappings":"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"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SlotRegistry } from '@teambit/harmony';
|
|
2
|
-
import {
|
|
2
|
+
import type { LinkProps } from '@teambit/base-react.navigation.link';
|
|
3
3
|
import type { ConsumeMethod } from '@teambit/ui-foundation.ui.use-box.menu';
|
|
4
4
|
import { LaneModel } from '@teambit/lanes.ui.lanes';
|
|
5
5
|
import { ComponentModel } from '../../ui';
|
|
6
6
|
export declare type NavPluginProps = {
|
|
7
7
|
displayName?: string;
|
|
8
|
-
} &
|
|
8
|
+
} & LinkProps;
|
|
9
9
|
export declare type NavPlugin = {
|
|
10
10
|
props: NavPluginProps;
|
|
11
11
|
order?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["nav-plugin.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":[],"sources":["nav-plugin.tsx"],"sourcesContent":["import { SlotRegistry } from '@teambit/harmony';\nimport type { LinkProps } from '@teambit/base-react.navigation.link';\nimport type { ConsumeMethod } from '@teambit/ui-foundation.ui.use-box.menu';\nimport { LaneModel } from '@teambit/lanes.ui.lanes';\nimport { ComponentModel } from '../../ui';\n\nexport type NavPluginProps = {\n displayName?: string;\n} & LinkProps;\n\nexport type NavPlugin = {\n props: NavPluginProps;\n order?: number;\n};\n\nexport type OrderedNavigationSlot = SlotRegistry<NavPlugin>;\nexport type ConsumePluginOptions = {\n currentLane?: LaneModel;\n};\n\nexport type ConsumePlugin = (\n componentModel: ComponentModel,\n options?: ConsumePluginOptions\n) => ConsumeMethod | undefined;\n\nexport type ConsumeMethodSlot = SlotRegistry<ConsumePlugin[]>;\n"],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare type TopBarNavProps = {} &
|
|
2
|
+
import { LinkProps } from '@teambit/base-react.navigation.link';
|
|
3
|
+
export declare type TopBarNavProps = {} & LinkProps;
|
|
4
4
|
export declare function TopBarNav({ href, className, activeClassName, children, ...rest }: TopBarNavProps): JSX.Element;
|
|
@@ -59,20 +59,10 @@ function _reactRouterDom() {
|
|
|
59
59
|
return data;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function
|
|
63
|
-
const data = require("@teambit/base-
|
|
62
|
+
function _baseReactNavigation() {
|
|
63
|
+
const data = require("@teambit/base-react.navigation.link");
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
return data;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return data;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _uiFoundationUiReactRouter() {
|
|
73
|
-
const data = require("@teambit/ui-foundation.ui.react-router.extend-path");
|
|
74
|
-
|
|
75
|
-
_uiFoundationUiReactRouter = function () {
|
|
65
|
+
_baseReactNavigation = function () {
|
|
76
66
|
return data;
|
|
77
67
|
};
|
|
78
68
|
|
|
@@ -97,15 +87,12 @@ function TopBarNav(_ref) {
|
|
|
97
87
|
children
|
|
98
88
|
} = _ref,
|
|
99
89
|
rest = (0, _objectWithoutProperties2().default)(_ref, ["href", "className", "activeClassName", "children"]);
|
|
100
|
-
const {
|
|
101
|
-
url
|
|
102
|
-
} = (0, _reactRouterDom().useRouteMatch)();
|
|
103
90
|
const {
|
|
104
91
|
search
|
|
105
92
|
} = (0, _reactRouterDom().useLocation)(); // sticky query params
|
|
106
93
|
|
|
107
|
-
const target = `${
|
|
108
|
-
return /*#__PURE__*/_react().default.createElement(
|
|
94
|
+
const target = `${href}${search}`;
|
|
95
|
+
return /*#__PURE__*/_react().default.createElement(_baseReactNavigation().Link, (0, _extends2().default)({}, rest, {
|
|
109
96
|
className: (0, _classnames().default)(className, _topBarNavModule().default.topBarLink),
|
|
110
97
|
activeClassName: (0, _classnames().default)(activeClassName, _topBarNavModule().default.active),
|
|
111
98
|
href: target
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TopBarNav","href","className","activeClassName","children","rest","
|
|
1
|
+
{"version":3,"names":["TopBarNav","href","className","activeClassName","children","rest","search","useLocation","target","classnames","styles","topBarLink","active"],"sources":["top-bar-nav.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { useLocation } from 'react-router-dom';\nimport { Link, LinkProps } from '@teambit/base-react.navigation.link';\n\nimport styles from './top-bar-nav.module.scss';\n\nexport type TopBarNavProps = {} & LinkProps;\n\nexport function TopBarNav({ href, className, activeClassName, children, ...rest }: TopBarNavProps) {\n const { search } = useLocation(); // sticky query params\n\n const target = `${href}${search}`;\n\n return (\n <Link\n {...rest}\n className={classnames(className, styles.topBarLink)}\n activeClassName={classnames(activeClassName, styles.active)}\n href={target}\n >\n <div>{children}</div>\n </Link>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;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;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,SAASA,SAAT,OAA4F;EAAA,IAAzE;IAAEC,IAAF;IAAQC,SAAR;IAAmBC,eAAnB;IAAoCC;EAApC,CAAyE;EAAA,IAAxBC,IAAwB;EACjG,MAAM;IAAEC;EAAF,IAAa,IAAAC,6BAAA,GAAnB,CADiG,CAC/D;;EAElC,MAAMC,MAAM,GAAI,GAAEP,IAAK,GAAEK,MAAO,EAAhC;EAEA,oBACE,+BAAC,2BAAD,+BACMD,IADN;IAEE,SAAS,EAAE,IAAAI,qBAAA,EAAWP,SAAX,EAAsBQ,0BAAA,CAAOC,UAA7B,CAFb;IAGE,eAAe,EAAE,IAAAF,qBAAA,EAAWN,eAAX,EAA4BO,0BAAA,CAAOE,MAAnC,CAHnB;IAIE,IAAI,EAAEJ;EAJR,iBAME,4CAAMJ,QAAN,CANF,CADF;AAUD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIdFromLocation(): string | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useIdFromLocation = useIdFromLocation;
|
|
9
|
+
|
|
10
|
+
function _reactRouterDom() {
|
|
11
|
+
const data = require("react-router-dom");
|
|
12
|
+
|
|
13
|
+
_reactRouterDom = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** component url is comprised of letters, numbers, "_", "-", "/" but should not include trailing "/", and should not include "~" */
|
|
21
|
+
const componentRegex = /^[\w/-]*[\w-]/;
|
|
22
|
+
|
|
23
|
+
function useIdFromLocation() {
|
|
24
|
+
const params = (0, _reactRouterDom().useParams)();
|
|
25
|
+
const splat = params['*'];
|
|
26
|
+
if (!splat) return undefined;
|
|
27
|
+
const match = componentRegex.exec(splat);
|
|
28
|
+
return match === null || match === void 0 ? void 0 : match[0];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=use-component-from-location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["componentRegex","useIdFromLocation","params","useParams","splat","undefined","match","exec"],"sources":["use-component-from-location.tsx"],"sourcesContent":["import { useParams } from 'react-router-dom';\n\n/** component url is comprised of letters, numbers, \"_\", \"-\", \"/\" but should not include trailing \"/\", and should not include \"~\" */\nconst componentRegex = /^[\\w/-]*[\\w-]/;\nexport function useIdFromLocation() {\n const params = useParams();\n const splat = params['*'];\n if (!splat) return undefined;\n\n const match = componentRegex.exec(splat);\n return match?.[0];\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACA,MAAMA,cAAc,GAAG,eAAvB;;AACO,SAASC,iBAAT,GAA6B;EAClC,MAAMC,MAAM,GAAG,IAAAC,2BAAA,GAAf;EACA,MAAMC,KAAK,GAAGF,MAAM,CAAC,GAAD,CAApB;EACA,IAAI,CAACE,KAAL,EAAY,OAAOC,SAAP;EAEZ,MAAMC,KAAK,GAAGN,cAAc,CAACO,IAAf,CAAoBH,KAApB,CAAd;EACA,OAAOE,KAAP,aAAOA,KAAP,uBAAOA,KAAK,CAAG,CAAH,CAAZ;AACD"}
|
|
@@ -7,4 +7,4 @@ export declare type Component = {
|
|
|
7
7
|
error?: ComponentError;
|
|
8
8
|
componentDescriptor?: ComponentDescriptor;
|
|
9
9
|
};
|
|
10
|
-
export declare function useComponent(host: string, id?: ComponentID): Component;
|
|
10
|
+
export declare function useComponent(host: string, id?: string | ComponentID): Component;
|
package/dist/ui/use-component.js
CHANGED
|
@@ -5,16 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useComponent = useComponent;
|
|
7
7
|
|
|
8
|
-
function _reactRouterDom() {
|
|
9
|
-
const data = require("react-router-dom");
|
|
10
|
-
|
|
11
|
-
_reactRouterDom = function () {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
8
|
function _uiFoundationUiReactRouter() {
|
|
19
9
|
const data = require("@teambit/ui-foundation.ui.react-router.use-query");
|
|
20
10
|
|
|
@@ -48,17 +38,12 @@ function _useComponentQuery() {
|
|
|
48
38
|
function useComponent(host, id) {
|
|
49
39
|
var _lanesContext$viewedL, _lanesContext$viewedL2;
|
|
50
40
|
|
|
51
|
-
const {
|
|
52
|
-
params: {
|
|
53
|
-
componentId
|
|
54
|
-
}
|
|
55
|
-
} = (0, _reactRouterDom().useRouteMatch)();
|
|
56
41
|
const query = (0, _uiFoundationUiReactRouter().useQuery)();
|
|
57
42
|
const version = query.get('version') || undefined;
|
|
58
43
|
const lanesContext = (0, _lanesUi().useLanesContext)();
|
|
59
|
-
const targetId =
|
|
44
|
+
const targetId = typeof id === 'string' && id || typeof id !== 'undefined' && id.toString({
|
|
60
45
|
ignoreVersion: true
|
|
61
|
-
})
|
|
46
|
+
});
|
|
62
47
|
if (!targetId) throw new TypeError('useComponent received no component id');
|
|
63
48
|
const currentLane = lanesContext === null || lanesContext === void 0 ? void 0 : lanesContext.viewedLane; // when on a lane, always fetch all the logs starting from the 'head' version
|
|
64
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useComponent","host","id","
|
|
1
|
+
{"version":3,"names":["useComponent","host","id","query","useQuery","version","get","undefined","lanesContext","useLanesContext","targetId","toString","ignoreVersion","TypeError","currentLane","viewedLane","laneComponentId","components","find","component","fullName","componentIdStr","withVersion","logFilters","log","logHead","useComponentQuery","includes"],"sources":["use-component.tsx"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { useQuery } from '@teambit/ui-foundation.ui.react-router.use-query';\nimport { ComponentDescriptor } from '@teambit/component-descriptor';\nimport { useLanesContext } from '@teambit/lanes.ui.lanes';\nimport { ComponentModel } from './component-model';\nimport { ComponentError } from './component-error';\nimport { useComponentQuery } from './use-component-query';\n\nexport type Component = {\n component?: ComponentModel;\n error?: ComponentError;\n componentDescriptor?: ComponentDescriptor;\n};\n\nexport function useComponent(host: string, id?: string | ComponentID): Component {\n const query = useQuery();\n const version = query.get('version') || undefined;\n const lanesContext = useLanesContext();\n\n const targetId =\n (typeof id === 'string' && id) || (typeof id !== 'undefined' && id.toString({ ignoreVersion: true }));\n if (!targetId) throw new TypeError('useComponent received no component id');\n const currentLane = lanesContext?.viewedLane;\n // when on a lane, always fetch all the logs starting from the 'head' version\n const laneComponentId = lanesContext?.viewedLane?.components.find(\n (component) => component.id.fullName === targetId\n )?.id;\n\n const componentIdStr = laneComponentId ? laneComponentId?.toString() : withVersion(targetId, version);\n\n const logFilters = currentLane\n ? {\n log: {\n logHead: laneComponentId?.version,\n },\n }\n : undefined;\n\n return useComponentQuery(componentIdStr, host, logFilters);\n}\n\nfunction withVersion(id: string, version?: string) {\n if (!version) return id;\n if (id.includes('@')) return id;\n return `${id}@${version}`;\n}\n"],"mappings":";;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAQO,SAASA,YAAT,CAAsBC,IAAtB,EAAoCC,EAApC,EAA0E;EAAA;;EAC/E,MAAMC,KAAK,GAAG,IAAAC,qCAAA,GAAd;EACA,MAAMC,OAAO,GAAGF,KAAK,CAACG,GAAN,CAAU,SAAV,KAAwBC,SAAxC;EACA,MAAMC,YAAY,GAAG,IAAAC,0BAAA,GAArB;EAEA,MAAMC,QAAQ,GACX,OAAOR,EAAP,KAAc,QAAd,IAA0BA,EAA3B,IAAmC,OAAOA,EAAP,KAAc,WAAd,IAA6BA,EAAE,CAACS,QAAH,CAAY;IAAEC,aAAa,EAAE;EAAjB,CAAZ,CADlE;EAEA,IAAI,CAACF,QAAL,EAAe,MAAM,IAAIG,SAAJ,CAAc,uCAAd,CAAN;EACf,MAAMC,WAAW,GAAGN,YAAH,aAAGA,YAAH,uBAAGA,YAAY,CAAEO,UAAlC,CAR+E,CAS/E;;EACA,MAAMC,eAAe,GAAGR,YAAH,aAAGA,YAAH,gDAAGA,YAAY,CAAEO,UAAjB,oFAAG,sBAA0BE,UAA1B,CAAqCC,IAArC,CACrBC,SAAD,IAAeA,SAAS,CAACjB,EAAV,CAAakB,QAAb,KAA0BV,QADnB,CAAH,2DAAG,uBAErBR,EAFH;EAIA,MAAMmB,cAAc,GAAGL,eAAe,GAAGA,eAAH,aAAGA,eAAH,uBAAGA,eAAe,CAAEL,QAAjB,EAAH,GAAiCW,WAAW,CAACZ,QAAD,EAAWL,OAAX,CAAlF;EAEA,MAAMkB,UAAU,GAAGT,WAAW,GAC1B;IACEU,GAAG,EAAE;MACHC,OAAO,EAAET,eAAF,aAAEA,eAAF,uBAAEA,eAAe,CAAEX;IADvB;EADP,CAD0B,GAM1BE,SANJ;EAQA,OAAO,IAAAmB,sCAAA,EAAkBL,cAAlB,EAAkCpB,IAAlC,EAAwCsB,UAAxC,CAAP;AACD;;AAED,SAASD,WAAT,CAAqBpB,EAArB,EAAiCG,OAAjC,EAAmD;EACjD,IAAI,CAACA,OAAL,EAAc,OAAOH,EAAP;EACd,IAAIA,EAAE,CAACyB,QAAH,CAAY,GAAZ,CAAJ,EAAsB,OAAOzB,EAAP;EACtB,OAAQ,GAAEA,EAAG,IAAGG,OAAQ,EAAxB;AACD"}
|
|
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.745",
|
|
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.745"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/any-fs": "0.0.5",
|
|
@@ -17,69 +17,65 @@
|
|
|
17
17
|
"semver": "7.3.4",
|
|
18
18
|
"copy-to-clipboard": "3.3.1",
|
|
19
19
|
"lodash.flatten": "4.4.0",
|
|
20
|
-
"react-router-dom": "5.2.0",
|
|
21
20
|
"classnames": "2.2.6",
|
|
22
21
|
"lodash.compact": "3.0.1",
|
|
23
22
|
"@babel/runtime": "7.12.18",
|
|
24
23
|
"core-js": "^3.0.0",
|
|
25
24
|
"@teambit/harmony": "0.3.3",
|
|
26
|
-
"@teambit/base-
|
|
25
|
+
"@teambit/base-react.navigation.link": "2.0.27",
|
|
27
26
|
"@teambit/documenter.ui.heading": "4.1.1",
|
|
28
27
|
"@teambit/documenter.ui.separator": "4.1.1",
|
|
29
28
|
"@teambit/explorer.ui.command-bar": "1.0.2",
|
|
30
29
|
"@teambit/base-ui.layout.breakpoints": "1.0.0",
|
|
31
|
-
"@teambit/base-ui.routing.routing-provider": "1.0.0",
|
|
32
30
|
"@teambit/design.elements.icon": "1.0.5",
|
|
33
31
|
"@teambit/design.inputs.dropdown": "0.0.7",
|
|
34
32
|
"@teambit/component-id": "0.0.402",
|
|
35
33
|
"@teambit/ui-foundation.ui.menu-widget-icon": "0.0.488",
|
|
36
|
-
"@teambit/aspect-loader": "0.0.
|
|
34
|
+
"@teambit/aspect-loader": "0.0.745",
|
|
37
35
|
"@teambit/legacy-bit-id": "0.0.399",
|
|
38
36
|
"@teambit/toolbox.path.match-patterns": "0.0.1",
|
|
39
37
|
"@teambit/toolbox.string.capitalize": "0.0.483",
|
|
40
|
-
"@teambit/cli": "0.0.
|
|
41
|
-
"@teambit/config": "0.0.
|
|
42
|
-
"@teambit/express": "0.0.
|
|
43
|
-
"@teambit/graphql": "0.0.
|
|
38
|
+
"@teambit/cli": "0.0.493",
|
|
39
|
+
"@teambit/config": "0.0.506",
|
|
40
|
+
"@teambit/express": "0.0.591",
|
|
41
|
+
"@teambit/graphql": "0.0.745",
|
|
44
42
|
"@teambit/bit-error": "0.0.394",
|
|
45
|
-
"@teambit/command-bar": "0.0.
|
|
43
|
+
"@teambit/command-bar": "0.0.745",
|
|
46
44
|
"@teambit/component.ui.deprecation-icon": "0.0.493",
|
|
47
|
-
"@teambit/preview": "0.0.
|
|
48
|
-
"@teambit/pubsub": "0.0.
|
|
49
|
-
"@teambit/react-router": "0.0.
|
|
45
|
+
"@teambit/preview": "0.0.745",
|
|
46
|
+
"@teambit/pubsub": "0.0.745",
|
|
47
|
+
"@teambit/react-router": "0.0.745",
|
|
50
48
|
"@teambit/ui-foundation.ui.is-browser": "0.0.486",
|
|
51
49
|
"@teambit/ui-foundation.ui.main-dropdown": "0.0.487",
|
|
52
|
-
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.
|
|
53
|
-
"@teambit/ui-foundation.ui.use-box.menu": "0.0.
|
|
54
|
-
"@teambit/ui": "0.0.
|
|
50
|
+
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.490",
|
|
51
|
+
"@teambit/ui-foundation.ui.use-box.menu": "0.0.115",
|
|
52
|
+
"@teambit/ui": "0.0.745",
|
|
55
53
|
"@teambit/component-issues": "0.0.53",
|
|
56
54
|
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.487",
|
|
57
55
|
"@teambit/cli-table": "0.0.34",
|
|
58
|
-
"@teambit/component-descriptor": "0.0.
|
|
59
|
-
"@teambit/lanes.ui.lanes": "0.0.
|
|
60
|
-
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.
|
|
56
|
+
"@teambit/component-descriptor": "0.0.55",
|
|
57
|
+
"@teambit/lanes.ui.lanes": "0.0.60",
|
|
58
|
+
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.487",
|
|
61
59
|
"@teambit/design.ui.empty-box": "0.0.353",
|
|
62
60
|
"@teambit/harmony.ui.aspect-box": "0.0.486",
|
|
63
|
-
"@teambit/design.ui.pages.not-found": "0.0.
|
|
64
|
-
"@teambit/design.ui.pages.server-error": "0.0.
|
|
65
|
-
"@teambit/compositions": "0.0.
|
|
66
|
-
"@teambit/deprecation": "0.0.
|
|
67
|
-
"@teambit/envs": "0.0.
|
|
61
|
+
"@teambit/design.ui.pages.not-found": "0.0.355",
|
|
62
|
+
"@teambit/design.ui.pages.server-error": "0.0.355",
|
|
63
|
+
"@teambit/compositions": "0.0.745",
|
|
64
|
+
"@teambit/deprecation": "0.0.745",
|
|
65
|
+
"@teambit/envs": "0.0.745",
|
|
68
66
|
"@teambit/legacy-component-log": "0.0.392",
|
|
69
67
|
"@teambit/design.ui.styles.ellipsis": "0.0.347",
|
|
70
68
|
"@teambit/envs.ui.env-icon": "0.0.486",
|
|
71
|
-
"@teambit/component.ui.version-dropdown": "0.0.
|
|
69
|
+
"@teambit/component.ui.version-dropdown": "0.0.546",
|
|
72
70
|
"@teambit/ui-foundation.ui.full-loader": "0.0.486",
|
|
73
|
-
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.
|
|
74
|
-
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.487"
|
|
75
|
-
"@teambit/ui-foundation.ui.react-router.extend-path": "0.0.486"
|
|
71
|
+
"@teambit/ui-foundation.ui.use-box.dropdown": "0.0.115",
|
|
72
|
+
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.487"
|
|
76
73
|
},
|
|
77
74
|
"devDependencies": {
|
|
78
75
|
"@types/react": "^17.0.8",
|
|
79
76
|
"@types/lodash": "4.14.165",
|
|
80
77
|
"@types/semver": "7.3.4",
|
|
81
78
|
"@types/lodash.flatten": "4.4.6",
|
|
82
|
-
"@types/react-router-dom": "5.1.7",
|
|
83
79
|
"@types/classnames": "2.2.11",
|
|
84
80
|
"@types/lodash.compact": "3.0.6",
|
|
85
81
|
"@types/mocha": "9.1.0",
|
|
@@ -90,8 +86,9 @@
|
|
|
90
86
|
"@teambit/component.content.component-overview": "1.95.0"
|
|
91
87
|
},
|
|
92
88
|
"peerDependencies": {
|
|
89
|
+
"react-router-dom": "^6.0.0",
|
|
93
90
|
"@apollo/client": "^3.0.0",
|
|
94
|
-
"@teambit/legacy": "1.0.
|
|
91
|
+
"@teambit/legacy": "1.0.273",
|
|
95
92
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
96
93
|
"react": "^16.8.0 || ^17.0.0"
|
|
97
94
|
},
|
|
@@ -119,7 +116,7 @@
|
|
|
119
116
|
"react": "-"
|
|
120
117
|
},
|
|
121
118
|
"peerDependencies": {
|
|
122
|
-
"@teambit/legacy": "1.0.
|
|
119
|
+
"@teambit/legacy": "1.0.273",
|
|
123
120
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
124
121
|
"react": "^16.8.0 || ^17.0.0"
|
|
125
122
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.745/dist/component.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.component_component@0.0.745/dist/component.docs.mdx')]
|
package/section/section.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LinkProps } from '@teambit/base-react.navigation.link';
|
|
2
2
|
import { RouteProps } from 'react-router-dom';
|
|
3
3
|
|
|
4
4
|
export interface Section {
|
|
5
5
|
route: RouteProps;
|
|
6
|
-
navigationLink:
|
|
6
|
+
navigationLink: LinkProps;
|
|
7
7
|
/**
|
|
8
8
|
* text to be used in the mobile res dropdown
|
|
9
9
|
*/
|
package/ui/component.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { useEffect, ReactNode, useMemo } from 'react';
|
|
2
2
|
import flatten from 'lodash.flatten';
|
|
3
|
-
import { RouteSlot,
|
|
3
|
+
import { RouteSlot, SlotRouter } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
4
4
|
import { SlotRegistry } from '@teambit/harmony';
|
|
5
5
|
|
|
6
6
|
import styles from './component.module.scss';
|
|
7
7
|
import { ComponentProvider, ComponentDescriptorProvider } from './context';
|
|
8
8
|
import { useComponent } from './use-component';
|
|
9
9
|
import { ComponentModel } from './component-model';
|
|
10
|
+
import { useIdFromLocation } from './use-component-from-location';
|
|
10
11
|
|
|
11
12
|
export type ComponentPageSlot = SlotRegistry<ComponentPageElement[]>;
|
|
12
13
|
export type ComponentPageElement = {
|
|
@@ -25,7 +26,8 @@ export type ComponentProps = {
|
|
|
25
26
|
* main UI component of the Component extension.
|
|
26
27
|
*/
|
|
27
28
|
export function Component({ routeSlot, containerSlot, host, onComponentChange }: ComponentProps) {
|
|
28
|
-
const
|
|
29
|
+
const componentId = useIdFromLocation();
|
|
30
|
+
const { component, componentDescriptor, error } = useComponent(host, componentId);
|
|
29
31
|
// trigger onComponentChange when component changes
|
|
30
32
|
useEffect(() => onComponentChange?.(component), [component]);
|
|
31
33
|
// cleanup when unmounting component
|
|
@@ -42,7 +44,9 @@ export function Component({ routeSlot, containerSlot, host, onComponentChange }:
|
|
|
42
44
|
<ComponentDescriptorProvider componentDescriptor={componentDescriptor}>
|
|
43
45
|
<ComponentProvider component={component}>
|
|
44
46
|
{before}
|
|
45
|
-
<div className={styles.container}>
|
|
47
|
+
<div className={styles.container}>
|
|
48
|
+
{routeSlot && <SlotRouter parentPath={`${componentId}/*`} slot={routeSlot} />}
|
|
49
|
+
</div>
|
|
46
50
|
{after}
|
|
47
51
|
</ComponentProvider>
|
|
48
52
|
</ComponentDescriptorProvider>
|
package/ui/menu/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ComponentMenu } from './menu';
|
|
2
2
|
export type { NavPlugin, OrderedNavigationSlot, ConsumePlugin, ConsumeMethodSlot } from './nav-plugin';
|
package/ui/menu/menu.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Routes, Route } from 'react-router-dom';
|
|
1
2
|
import { MainDropdown, MenuItemSlot } from '@teambit/ui-foundation.ui.main-dropdown';
|
|
2
3
|
import { VersionDropdown } from '@teambit/component.ui.version-dropdown';
|
|
3
4
|
import { FullLoader } from '@teambit/ui-foundation.ui.full-loader';
|
|
4
5
|
import type { ConsumeMethod } from '@teambit/ui-foundation.ui.use-box.menu';
|
|
5
|
-
import { useLocation } from '@teambit/base-
|
|
6
|
+
import { useLocation } from '@teambit/base-react.navigation.link';
|
|
6
7
|
import { flatten, groupBy, compact } from 'lodash';
|
|
7
8
|
import classnames from 'classnames';
|
|
8
9
|
import React, { useMemo } from 'react';
|
|
@@ -16,6 +17,7 @@ import { MenuNav } from './menu-nav';
|
|
|
16
17
|
import { MobileMenuNav } from './mobile-menu-nav';
|
|
17
18
|
import styles from './menu.module.scss';
|
|
18
19
|
import { OrderedNavigationSlot, ConsumeMethodSlot } from './nav-plugin';
|
|
20
|
+
import { useIdFromLocation } from '../use-component-from-location';
|
|
19
21
|
|
|
20
22
|
export type MenuProps = {
|
|
21
23
|
className?: string;
|
|
@@ -39,24 +41,39 @@ export type MenuProps = {
|
|
|
39
41
|
/**
|
|
40
42
|
* top bar menu.
|
|
41
43
|
*/
|
|
42
|
-
export function
|
|
43
|
-
|
|
44
|
+
export function ComponentMenu({
|
|
45
|
+
navigationSlot,
|
|
46
|
+
widgetSlot,
|
|
47
|
+
className,
|
|
48
|
+
host,
|
|
49
|
+
menuItemSlot,
|
|
50
|
+
consumeMethodSlot,
|
|
51
|
+
}: MenuProps) {
|
|
52
|
+
const componentId = useIdFromLocation();
|
|
53
|
+
const { component } = useComponent(host, componentId);
|
|
44
54
|
const mainMenuItems = useMemo(() => groupBy(flatten(menuItemSlot.values()), 'category'), [menuItemSlot]);
|
|
45
55
|
if (!component) return <FullLoader />;
|
|
46
56
|
return (
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
<Routes>
|
|
58
|
+
<Route
|
|
59
|
+
path={`${componentId}/*`}
|
|
60
|
+
element={
|
|
61
|
+
<div className={classnames(styles.topBar, className)}>
|
|
62
|
+
<div className={styles.leftSide}>
|
|
63
|
+
<MenuNav navigationSlot={navigationSlot} />
|
|
64
|
+
<MobileMenuNav navigationSlot={navigationSlot} widgetSlot={widgetSlot} />
|
|
65
|
+
</div>
|
|
66
|
+
<div className={styles.rightSide}>
|
|
67
|
+
<div className={styles.widgets}>
|
|
68
|
+
<MenuNav navigationSlot={widgetSlot} />
|
|
69
|
+
</div>
|
|
70
|
+
<VersionRelatedDropdowns component={component} consumeMethods={consumeMethodSlot} host={host} />
|
|
71
|
+
<MainDropdown menuItems={mainMenuItems} />
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
}
|
|
75
|
+
/>
|
|
76
|
+
</Routes>
|
|
60
77
|
);
|
|
61
78
|
}
|
|
62
79
|
|
|
@@ -102,7 +119,7 @@ function VersionRelatedDropdowns({
|
|
|
102
119
|
const localVersion = isWorkspace && !isNew && !currentLane;
|
|
103
120
|
|
|
104
121
|
const currentVersion =
|
|
105
|
-
isWorkspace && !isNew && !location
|
|
122
|
+
isWorkspace && !isNew && !location?.search.includes('version') ? 'workspace' : component.version;
|
|
106
123
|
|
|
107
124
|
const methods = useConsumeMethods(consumeMethods, component, currentLane);
|
|
108
125
|
return (
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Routes, Route } from 'react-router-dom';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { Icon } from '@teambit/design.elements.icon';
|
|
5
5
|
import { Dropdown } from '@teambit/design.inputs.dropdown';
|
|
6
|
-
import { extendPath } from '@teambit/ui-foundation.ui.react-router.extend-path';
|
|
7
6
|
import { TopBarNav } from '../top-bar-nav';
|
|
8
7
|
import styles from './menu.module.scss';
|
|
9
8
|
import mobileStyles from './mobile-menu-nav.module.scss';
|
|
@@ -18,7 +17,6 @@ export function MobileMenuNav({
|
|
|
18
17
|
widgetSlot: OrderedNavigationSlot;
|
|
19
18
|
className?: string;
|
|
20
19
|
}) {
|
|
21
|
-
const { url } = useRouteMatch();
|
|
22
20
|
const totalSlots = useMemo(
|
|
23
21
|
() => [...navigationSlot.toArray().sort(sortFn), ...widgetSlot.toArray().sort(sortFn)],
|
|
24
22
|
[navigationSlot, widgetSlot]
|
|
@@ -27,7 +25,7 @@ export function MobileMenuNav({
|
|
|
27
25
|
return (
|
|
28
26
|
<Dropdown
|
|
29
27
|
// @ts-ignore - mismatch between @types/react
|
|
30
|
-
placeholder={<Placeholder slots={totalSlots}
|
|
28
|
+
placeholder={<Placeholder slots={totalSlots} />}
|
|
31
29
|
className={classnames(styles.navigation, styles.mobileNav, className)}
|
|
32
30
|
dropClass={mobileStyles.mobileMenu}
|
|
33
31
|
>
|
|
@@ -63,19 +61,20 @@ type PlaceholderProps = {
|
|
|
63
61
|
baseUrl?: string;
|
|
64
62
|
} & React.HTMLAttributes<HTMLDivElement>;
|
|
65
63
|
|
|
66
|
-
function Placeholder({ slots,
|
|
64
|
+
function Placeholder({ slots, ...rest }: PlaceholderProps) {
|
|
67
65
|
return (
|
|
68
66
|
<div {...rest} className={mobileStyles.placeholder}>
|
|
69
|
-
<
|
|
70
|
-
{slots?.map(([id, menuItem]) =>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
<Routes>
|
|
68
|
+
{slots?.map(([id, menuItem]) => (
|
|
69
|
+
<Route
|
|
70
|
+
key={id}
|
|
71
|
+
path={menuItem?.props?.href}
|
|
72
|
+
element={
|
|
73
|
+
typeof menuItem?.props?.children === 'string' ? menuItem?.props?.children : menuItem?.props?.displayName
|
|
74
|
+
}
|
|
75
|
+
/>
|
|
76
|
+
))}
|
|
77
|
+
</Routes>
|
|
79
78
|
<Icon of="fat-arrow-down" />
|
|
80
79
|
</div>
|
|
81
80
|
);
|