@teambit/component 0.0.881 → 0.0.883
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/dist/aspect-entry.js +3 -16
- package/dist/aspect-entry.js.map +1 -1
- package/dist/aspect-list.js +6 -35
- package/dist/aspect-list.js.map +1 -1
- package/dist/aspect.section.js +0 -16
- package/dist/aspect.section.js.map +1 -1
- package/dist/component-fs.js +2 -25
- package/dist/component-fs.js.map +1 -1
- package/dist/component-map/component-map.js +10 -26
- package/dist/component-map/component-map.js.map +1 -1
- package/dist/component-map/index.js +0 -3
- package/dist/component-map/index.js.map +1 -1
- package/dist/component-meta.js +1 -14
- package/dist/component-meta.js.map +1 -1
- package/dist/component.aspect.js +0 -5
- package/dist/component.aspect.js.map +1 -1
- package/dist/component.composition.js +0 -6
- package/dist/component.composition.js.map +1 -1
- package/dist/component.graphql.js +2 -26
- package/dist/component.graphql.js.map +1 -1
- package/dist/component.js +19 -90
- package/dist/component.js.map +1 -1
- package/dist/component.main.runtime.js +6 -64
- package/dist/component.main.runtime.js.map +1 -1
- package/dist/component.route.js +2 -14
- package/dist/component.route.js.map +1 -1
- package/dist/component.ui.runtime.js +3 -83
- package/dist/component.ui.runtime.js.map +1 -1
- package/dist/config.js +0 -3
- package/dist/config.js.map +1 -1
- package/dist/dependencies/dependencies.js +7 -32
- package/dist/dependencies/dependencies.js.map +1 -1
- package/dist/dependencies/index.js +0 -3
- package/dist/dependencies/index.js.map +1 -1
- package/dist/exceptions/could-not-find-latest.js +0 -4
- package/dist/exceptions/could-not-find-latest.js.map +1 -1
- package/dist/exceptions/host-not-found.js +0 -4
- package/dist/exceptions/host-not-found.js.map +1 -1
- package/dist/exceptions/index.js +0 -13
- package/dist/exceptions/index.js.map +1 -1
- package/dist/exceptions/main-file-not-found.js +0 -4
- package/dist/exceptions/main-file-not-found.js.map +1 -1
- package/dist/exceptions/nothing-to-snap.js +0 -2
- package/dist/exceptions/nothing-to-snap.js.map +1 -1
- package/dist/history-graph.js +0 -2
- package/dist/history-graph.js.map +1 -1
- package/dist/host/component-host-model.js +0 -7
- package/dist/host/component-host-model.js.map +1 -1
- package/dist/host/index.js +0 -5
- package/dist/host/index.js.map +1 -1
- package/dist/host/use-component-host.js +0 -14
- package/dist/host/use-component-host.js.map +1 -1
- package/dist/index.js +0 -63
- package/dist/index.js.map +1 -1
- package/dist/section/index.js +0 -3
- package/dist/section/index.js.map +1 -1
- package/dist/show/extensions.fragment.js +0 -8
- package/dist/show/extensions.fragment.js.map +1 -1
- package/dist/show/files.fragment.js +0 -11
- package/dist/show/files.fragment.js.map +1 -1
- package/dist/show/id.fragment.js +0 -10
- package/dist/show/id.fragment.js.map +1 -1
- package/dist/show/index.js +0 -24
- package/dist/show/index.js.map +1 -1
- package/dist/show/main-file.fragment.js +0 -9
- package/dist/show/main-file.fragment.js.map +1 -1
- package/dist/show/name.fragment.js +0 -9
- package/dist/show/name.fragment.js.map +1 -1
- package/dist/show/scope.fragment.js +0 -10
- package/dist/show/scope.fragment.js.map +1 -1
- package/dist/show/show.cmd.js +1 -33
- package/dist/show/show.cmd.js.map +1 -1
- package/dist/snap/index.js +0 -6
- package/dist/snap/index.js.map +1 -1
- package/dist/snap/snap.js +0 -5
- package/dist/snap/snap.js.map +1 -1
- package/dist/state.js +6 -24
- package/dist/state.js.map +1 -1
- package/dist/store.js +0 -5
- package/dist/store.js.map +1 -1
- package/dist/tag/index.js +0 -3
- package/dist/tag/index.js.map +1 -1
- package/dist/tag/tag.js +1 -9
- package/dist/tag/tag.js.map +1 -1
- package/dist/tag-map.js +4 -28
- package/dist/tag-map.js.map +1 -1
- package/dist/ui/aspect-page/aspect-page.js +2 -35
- package/dist/ui/aspect-page/aspect-page.js.map +1 -1
- package/dist/ui/aspect-page/index.js +0 -3
- package/dist/ui/aspect-page/index.js.map +1 -1
- package/dist/ui/component-error/component-error.js +0 -14
- package/dist/ui/component-error/component-error.js.map +1 -1
- package/dist/ui/component-error/index.js +0 -3
- package/dist/ui/component-error/index.js.map +1 -1
- package/dist/ui/component-model/component-model.js +2 -21
- package/dist/ui/component-model/component-model.js.map +1 -1
- package/dist/ui/component-model/index.js +0 -3
- package/dist/ui/component-model/index.js.map +1 -1
- package/dist/ui/component-searcher/component-result.js +0 -20
- package/dist/ui/component-searcher/component-result.js.map +1 -1
- package/dist/ui/component-searcher/component-searcher.js +0 -22
- package/dist/ui/component-searcher/component-searcher.js.map +1 -1
- package/dist/ui/component-searcher/index.js +0 -3
- package/dist/ui/component-searcher/index.js.map +1 -1
- package/dist/ui/component.js +5 -40
- package/dist/ui/component.js.map +1 -1
- package/dist/ui/context/component-context.js +0 -9
- package/dist/ui/context/component-context.js.map +1 -1
- package/dist/ui/context/component-provider.js +0 -9
- package/dist/ui/context/component-provider.js.map +1 -1
- package/dist/ui/context/index.js +0 -6
- package/dist/ui/context/index.js.map +1 -1
- package/dist/ui/index.js +0 -21
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/menu/index.js +0 -3
- package/dist/ui/menu/index.js.map +1 -1
- package/dist/ui/menu/menu-nav.js +4 -23
- package/dist/ui/menu/menu-nav.js.map +1 -1
- package/dist/ui/menu/menu.js +0 -70
- package/dist/ui/menu/menu.js.map +1 -1
- package/dist/ui/menu/mobile-menu-nav.js +6 -49
- package/dist/ui/menu/mobile-menu-nav.js.map +1 -1
- package/dist/ui/top-bar-nav/index.js +0 -2
- package/dist/ui/top-bar-nav/index.js.map +1 -1
- package/dist/ui/top-bar-nav/top-bar-nav.js +8 -32
- package/dist/ui/top-bar-nav/top-bar-nav.js.map +1 -1
- package/dist/ui/use-component-from-location.js +0 -9
- package/dist/ui/use-component-from-location.js.map +1 -1
- package/dist/ui/use-component-query.js +12 -60
- package/dist/ui/use-component-query.js.map +1 -1
- package/dist/ui/use-component.js +0 -11
- package/dist/ui/use-component.js.map +1 -1
- package/package-tar/teambit-component-0.0.883.tgz +0 -0
- package/package.json +12 -12
- package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
- package/package-tar/teambit-component-0.0.881.tgz +0 -0
|
@@ -1,137 +1,99 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.array.sort.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.MobileMenuNav = MobileMenuNav;
|
|
13
|
-
|
|
14
10
|
function _objectWithoutProperties2() {
|
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
16
|
-
|
|
17
12
|
_objectWithoutProperties2 = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _extends2() {
|
|
25
18
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
26
|
-
|
|
27
19
|
_extends2 = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function _react() {
|
|
35
25
|
const data = _interopRequireWildcard(require("react"));
|
|
36
|
-
|
|
37
26
|
_react = function () {
|
|
38
27
|
return data;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
return data;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function _reactRouterDom() {
|
|
45
32
|
const data = require("react-router-dom");
|
|
46
|
-
|
|
47
33
|
_reactRouterDom = function () {
|
|
48
34
|
return data;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
return data;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
function _classnames() {
|
|
55
39
|
const data = _interopRequireDefault(require("classnames"));
|
|
56
|
-
|
|
57
40
|
_classnames = function () {
|
|
58
41
|
return data;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
return data;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
45
|
function _designElements() {
|
|
65
46
|
const data = require("@teambit/design.elements.icon");
|
|
66
|
-
|
|
67
47
|
_designElements = function () {
|
|
68
48
|
return data;
|
|
69
49
|
};
|
|
70
|
-
|
|
71
50
|
return data;
|
|
72
51
|
}
|
|
73
|
-
|
|
74
52
|
function _designInputs() {
|
|
75
53
|
const data = require("@teambit/design.inputs.dropdown");
|
|
76
|
-
|
|
77
54
|
_designInputs = function () {
|
|
78
55
|
return data;
|
|
79
56
|
};
|
|
80
|
-
|
|
81
57
|
return data;
|
|
82
58
|
}
|
|
83
|
-
|
|
84
59
|
function _baseReactNavigation() {
|
|
85
60
|
const data = require("@teambit/base-react.navigation.link");
|
|
86
|
-
|
|
87
61
|
_baseReactNavigation = function () {
|
|
88
62
|
return data;
|
|
89
63
|
};
|
|
90
|
-
|
|
91
64
|
return data;
|
|
92
65
|
}
|
|
93
|
-
|
|
94
66
|
function _topBarNav() {
|
|
95
67
|
const data = require("../top-bar-nav");
|
|
96
|
-
|
|
97
68
|
_topBarNav = function () {
|
|
98
69
|
return data;
|
|
99
70
|
};
|
|
100
|
-
|
|
101
71
|
return data;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
73
|
function _menuModule() {
|
|
105
74
|
const data = _interopRequireDefault(require("./menu.module.scss"));
|
|
106
|
-
|
|
107
75
|
_menuModule = function () {
|
|
108
76
|
return data;
|
|
109
77
|
};
|
|
110
|
-
|
|
111
78
|
return data;
|
|
112
79
|
}
|
|
113
|
-
|
|
114
80
|
function _mobileMenuNavModule() {
|
|
115
81
|
const data = _interopRequireDefault(require("./mobile-menu-nav.module.scss"));
|
|
116
|
-
|
|
117
82
|
_mobileMenuNavModule = function () {
|
|
118
83
|
return data;
|
|
119
84
|
};
|
|
120
|
-
|
|
121
85
|
return data;
|
|
122
86
|
}
|
|
123
|
-
|
|
124
87
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
125
|
-
|
|
126
88
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
127
|
-
|
|
128
89
|
function MobileMenuNav({
|
|
129
90
|
navigationSlot,
|
|
130
91
|
widgetSlot,
|
|
131
92
|
className
|
|
132
93
|
}) {
|
|
133
94
|
const totalSlots = (0, _react().useMemo)(() => [...navigationSlot.toArray().sort(sortFn), ...widgetSlot.toArray().sort(sortFn)], [navigationSlot, widgetSlot]);
|
|
134
|
-
return /*#__PURE__*/_react().default.createElement(_designInputs().Dropdown
|
|
95
|
+
return /*#__PURE__*/_react().default.createElement(_designInputs().Dropdown
|
|
96
|
+
// @ts-ignore - mismatch between @types/react
|
|
135
97
|
, {
|
|
136
98
|
placeholder: /*#__PURE__*/_react().default.createElement(Placeholder, {
|
|
137
99
|
slots: totalSlots
|
|
@@ -150,7 +112,6 @@ function MobileMenuNav({
|
|
|
150
112
|
}), typeof menuItem.props.children === 'string' ? menuItem.props.children : menuItem.props.displayName);
|
|
151
113
|
})));
|
|
152
114
|
}
|
|
153
|
-
|
|
154
115
|
function sortFn([, {
|
|
155
116
|
order: first
|
|
156
117
|
}], [, {
|
|
@@ -159,14 +120,14 @@ function sortFn([, {
|
|
|
159
120
|
// 0 - equal
|
|
160
121
|
// <0 - first < second
|
|
161
122
|
// >0 - first > second
|
|
123
|
+
|
|
162
124
|
return (first !== null && first !== void 0 ? first : 0) - (second !== null && second !== void 0 ? second : 0);
|
|
163
125
|
}
|
|
164
|
-
|
|
165
126
|
function Placeholder(_ref) {
|
|
166
127
|
let {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
128
|
+
slots
|
|
129
|
+
} = _ref,
|
|
130
|
+
rest = (0, _objectWithoutProperties2().default)(_ref, ["slots"]);
|
|
170
131
|
return /*#__PURE__*/_react().default.createElement("div", (0, _extends2().default)({}, rest, {
|
|
171
132
|
className: _mobileMenuNavModule().default.placeholder
|
|
172
133
|
}), slots.map(([id, menuItem]) => /*#__PURE__*/_react().default.createElement(ShowWhenMatch, {
|
|
@@ -177,7 +138,6 @@ function Placeholder(_ref) {
|
|
|
177
138
|
of: "fat-arrow-down"
|
|
178
139
|
}));
|
|
179
140
|
}
|
|
180
|
-
|
|
181
141
|
function ShowWhenMatch({
|
|
182
142
|
href,
|
|
183
143
|
children,
|
|
@@ -191,7 +151,6 @@ function ShowWhenMatch({
|
|
|
191
151
|
if (!isMatch) return null;
|
|
192
152
|
return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, children);
|
|
193
153
|
}
|
|
194
|
-
|
|
195
154
|
function useLinkMatch(href, {
|
|
196
155
|
caseSensitive,
|
|
197
156
|
exact
|
|
@@ -199,12 +158,10 @@ function useLinkMatch(href, {
|
|
|
199
158
|
const location = (0, _baseReactNavigation().useLocation)();
|
|
200
159
|
let pathname = (location === null || location === void 0 ? void 0 : location.pathname) || '/';
|
|
201
160
|
let destination = (0, _reactRouterDom().useResolvedPath)(href).pathname;
|
|
202
|
-
|
|
203
161
|
if (!caseSensitive) {
|
|
204
162
|
pathname = pathname.toLowerCase();
|
|
205
163
|
destination = destination.toLowerCase();
|
|
206
164
|
}
|
|
207
|
-
|
|
208
165
|
return destination === pathname || !exact && pathname.startsWith(destination) && pathname.charAt(destination.length) === '/';
|
|
209
166
|
}
|
|
210
167
|
|
|
@@ -1 +1 @@
|
|
|
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","exact","ShowWhenMatch","caseSensitive","end","isMatch","useLinkMatch","location","useLocation","pathname","destination","useResolvedPath","toLowerCase","startsWith","charAt","length"],"sources":["mobile-menu-nav.tsx"],"sourcesContent":["import React, { ReactNode, useMemo } from 'react';\nimport { useResolvedPath } from 'react-router-dom';\nimport classnames from 'classnames';\nimport { Icon } from '@teambit/design.elements.icon';\nimport { Dropdown } from '@teambit/design.inputs.dropdown';\nimport { useLocation } from '@teambit/base-react.navigation.link';\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 {slots.map(([id, menuItem]) => (\n <ShowWhenMatch key={id} href={menuItem.props.href || ''} end={menuItem.props.exact}>\n {typeof menuItem.props.children === 'string' ? menuItem.props.children : menuItem.props.displayName}\n </ShowWhenMatch>\n ))}\n <Icon of=\"fat-arrow-down\" />\n </div>\n );\n}\n\nfunction ShowWhenMatch({\n href,\n children,\n caseSensitive,\n end: exact,\n}: {\n href: string;\n children: ReactNode;\n caseSensitive?: boolean;\n end?: boolean;\n}) {\n const isMatch = useLinkMatch(href, { caseSensitive, exact });\n if (!isMatch) return null;\n return <>{children}</>;\n}\n\nfunction useLinkMatch(href: string, { caseSensitive, exact }: { caseSensitive?: boolean; exact?: boolean } = {}) {\n const location = useLocation();\n let pathname = location?.pathname || '/';\n let destination = useResolvedPath(href).pathname;\n\n if (!caseSensitive) {\n pathname = pathname.toLowerCase();\n destination = destination.toLowerCase();\n }\n\n return (\n destination === pathname ||\n (!exact && pathname.startsWith(destination) && pathname.charAt(destination.length) === '/')\n );\n}\n"],"mappings":"
|
|
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","exact","ShowWhenMatch","caseSensitive","end","isMatch","useLinkMatch","location","useLocation","pathname","destination","useResolvedPath","toLowerCase","startsWith","charAt","length"],"sources":["mobile-menu-nav.tsx"],"sourcesContent":["import React, { ReactNode, useMemo } from 'react';\nimport { useResolvedPath } from 'react-router-dom';\nimport classnames from 'classnames';\nimport { Icon } from '@teambit/design.elements.icon';\nimport { Dropdown } from '@teambit/design.inputs.dropdown';\nimport { useLocation } from '@teambit/base-react.navigation.link';\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 {slots.map(([id, menuItem]) => (\n <ShowWhenMatch key={id} href={menuItem.props.href || ''} end={menuItem.props.exact}>\n {typeof menuItem.props.children === 'string' ? menuItem.props.children : menuItem.props.displayName}\n </ShowWhenMatch>\n ))}\n <Icon of=\"fat-arrow-down\" />\n </div>\n );\n}\n\nfunction ShowWhenMatch({\n href,\n children,\n caseSensitive,\n end: exact,\n}: {\n href: string;\n children: ReactNode;\n caseSensitive?: boolean;\n end?: boolean;\n}) {\n const isMatch = useLinkMatch(href, { caseSensitive, exact });\n if (!isMatch) return null;\n return <>{children}</>;\n}\n\nfunction useLinkMatch(href: string, { caseSensitive, exact }: { caseSensitive?: boolean; exact?: boolean } = {}) {\n const location = useLocation();\n let pathname = location?.pathname || '/';\n let destination = useResolvedPath(href).pathname;\n\n if (!caseSensitive) {\n pathname = pathname.toLowerCase();\n destination = destination.toLowerCase();\n }\n\n return (\n destination === pathname ||\n (!exact && pathname.startsWith(destination) && pathname.charAt(destination.length) === '/')\n );\n}\n"],"mappings":"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"}
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _topBarNav = require("./top-bar-nav");
|
|
8
|
-
|
|
9
7
|
Object.keys(_topBarNav).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _topBarNav[key]) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './top-bar-nav';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './top-bar-nav';\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,101 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.TopBarNav = TopBarNav;
|
|
11
|
-
|
|
12
9
|
function _extends2() {
|
|
13
10
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
|
-
|
|
15
11
|
_extends2 = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function _objectWithoutProperties2() {
|
|
23
17
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
24
|
-
|
|
25
18
|
_objectWithoutProperties2 = function () {
|
|
26
19
|
return data;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
21
|
return data;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function _react() {
|
|
33
24
|
const data = _interopRequireDefault(require("react"));
|
|
34
|
-
|
|
35
25
|
_react = function () {
|
|
36
26
|
return data;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
return data;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function _classnames() {
|
|
43
31
|
const data = _interopRequireDefault(require("classnames"));
|
|
44
|
-
|
|
45
32
|
_classnames = function () {
|
|
46
33
|
return data;
|
|
47
34
|
};
|
|
48
|
-
|
|
49
35
|
return data;
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
function _reactRouterDom() {
|
|
53
38
|
const data = require("react-router-dom");
|
|
54
|
-
|
|
55
39
|
_reactRouterDom = function () {
|
|
56
40
|
return data;
|
|
57
41
|
};
|
|
58
|
-
|
|
59
42
|
return data;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
44
|
function _baseReactNavigation() {
|
|
63
45
|
const data = require("@teambit/base-react.navigation.link");
|
|
64
|
-
|
|
65
46
|
_baseReactNavigation = function () {
|
|
66
47
|
return data;
|
|
67
48
|
};
|
|
68
|
-
|
|
69
49
|
return data;
|
|
70
50
|
}
|
|
71
|
-
|
|
72
51
|
function _topBarNavModule() {
|
|
73
52
|
const data = _interopRequireDefault(require("./top-bar-nav.module.scss"));
|
|
74
|
-
|
|
75
53
|
_topBarNavModule = function () {
|
|
76
54
|
return data;
|
|
77
55
|
};
|
|
78
|
-
|
|
79
56
|
return data;
|
|
80
57
|
}
|
|
81
|
-
|
|
82
58
|
function TopBarNav(_ref) {
|
|
83
59
|
let {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
60
|
+
href,
|
|
61
|
+
className,
|
|
62
|
+
activeClassName,
|
|
63
|
+
children,
|
|
64
|
+
displayName
|
|
65
|
+
} = _ref,
|
|
66
|
+
rest = (0, _objectWithoutProperties2().default)(_ref, ["href", "className", "activeClassName", "children", "displayName"]);
|
|
91
67
|
const {
|
|
92
68
|
search
|
|
93
69
|
} = (0, _reactRouterDom().useLocation)(); // sticky query params
|
|
70
|
+
|
|
94
71
|
// @hack - this is so that the displayName will not pass to the link and cause a warning in the console.
|
|
95
72
|
// it is used for component page nav link widgets (code, aspects etc),
|
|
96
73
|
// but not for regular menu links (overview, compositions, etc).
|
|
97
74
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
98
|
-
|
|
99
75
|
const preventPassingDisplayNameToLink = displayName;
|
|
100
76
|
const target = `${href}${search}`;
|
|
101
77
|
return /*#__PURE__*/_react().default.createElement(_baseReactNavigation().Link, (0, _extends2().default)({}, rest, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TopBarNav","href","className","activeClassName","children","displayName","rest","search","useLocation","preventPassingDisplayNameToLink","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 } from '@teambit/base-react.navigation.link';\nimport { NavPluginProps } from '../menu/nav-plugin';\n\nimport styles from './top-bar-nav.module.scss';\n\nexport function TopBarNav({ href, className, activeClassName, children, displayName, ...rest }: NavPluginProps) {\n const { search } = useLocation(); // sticky query params\n\n // @hack - this is so that the displayName will not pass to the link and cause a warning in the console.\n // it is used for component page nav link widgets (code, aspects etc),\n // but not for regular menu links (overview, compositions, etc).\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const preventPassingDisplayNameToLink = displayName;\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":"
|
|
1
|
+
{"version":3,"names":["TopBarNav","href","className","activeClassName","children","displayName","rest","search","useLocation","preventPassingDisplayNameToLink","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 } from '@teambit/base-react.navigation.link';\nimport { NavPluginProps } from '../menu/nav-plugin';\n\nimport styles from './top-bar-nav.module.scss';\n\nexport function TopBarNav({ href, className, activeClassName, children, displayName, ...rest }: NavPluginProps) {\n const { search } = useLocation(); // sticky query params\n\n // @hack - this is so that the displayName will not pass to the link and cause a warning in the console.\n // it is used for component page nav link widgets (code, aspects etc),\n // but not for regular menu links (overview, compositions, etc).\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const preventPassingDisplayNameToLink = displayName;\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;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,SAASA,SAAS,OAAuF;EAAA,IAAtF;MAAEC,IAAI;MAAEC,SAAS;MAAEC,eAAe;MAAEC,QAAQ;MAAEC;IAAqC,CAAC;IAAtBC,IAAI;EAC1F,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,6BAAW,GAAE,CAAC,CAAC;;EAElC;EACA;EACA;EACA;EACA,MAAMC,+BAA+B,GAAGJ,WAAW;EAEnD,MAAMK,MAAM,GAAI,GAAET,IAAK,GAAEM,MAAO,EAAC;EAEjC,oBACE,+BAAC,2BAAI,+BACCD,IAAI;IACR,SAAS,EAAE,IAAAK,qBAAU,EAACT,SAAS,EAAEU,0BAAM,CAACC,UAAU,CAAE;IACpD,eAAe,EAAE,IAAAF,qBAAU,EAACR,eAAe,EAAES,0BAAM,CAACE,MAAM,CAAE;IAC5D,IAAI,EAAEJ;EAAO,iBAEb,4CAAMN,QAAQ,CAAO,CAChB;AAEX"}
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.array.iterator.js");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.useIdFromLocation = useIdFromLocation;
|
|
11
|
-
|
|
12
9
|
function _reactRouterDom() {
|
|
13
10
|
const data = require("react-router-dom");
|
|
14
|
-
|
|
15
11
|
_reactRouterDom = function () {
|
|
16
12
|
return data;
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
return data;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
/** component url is comprised of letters, numbers, "_", "-", "/" but should not include trailing "/", and should not include "~" */
|
|
23
17
|
const componentRegex = /^[\w/-]*[\w-]/;
|
|
24
|
-
|
|
25
18
|
function useIdFromLocation(url) {
|
|
26
19
|
const params = (0, _reactRouterDom().useParams)();
|
|
27
20
|
const splat = url || params['*'];
|
|
@@ -30,11 +23,9 @@ function useIdFromLocation(url) {
|
|
|
30
23
|
const hasScope = maybeOrgWithScope.split('.').length > 1;
|
|
31
24
|
const fullNameFromUrl = hasScope ? maybeFullName.join('/') : splat;
|
|
32
25
|
let scope;
|
|
33
|
-
|
|
34
26
|
if (hasScope) {
|
|
35
27
|
scope = maybeOrgWithScope;
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
const match = componentRegex.exec(fullNameFromUrl);
|
|
39
30
|
if (!(match !== null && match !== void 0 && match[0])) return undefined;
|
|
40
31
|
if (scope) return `${scope}/${match[0]}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["componentRegex","useIdFromLocation","url","params","useParams","splat","undefined","maybeOrgWithScope","maybeFullName","split","hasScope","length","fullNameFromUrl","join","scope","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-]/;\n\nexport function useIdFromLocation(url?: string): string | undefined {\n const params = useParams();\n const splat = url || params['*'];\n if (!splat) return undefined;\n\n const [maybeOrgWithScope, ...maybeFullName] = splat.split('/');\n const hasScope = maybeOrgWithScope.split('.').length > 1;\n const fullNameFromUrl = hasScope ? maybeFullName.join('/') : splat;\n let scope: string | undefined;\n if (hasScope) {\n scope = maybeOrgWithScope;\n }\n const match = componentRegex.exec(fullNameFromUrl);\n if (!match?.[0]) return undefined;\n if (scope) return `${scope}/${match[0]}`;\n return match[0];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["componentRegex","useIdFromLocation","url","params","useParams","splat","undefined","maybeOrgWithScope","maybeFullName","split","hasScope","length","fullNameFromUrl","join","scope","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-]/;\n\nexport function useIdFromLocation(url?: string): string | undefined {\n const params = useParams();\n const splat = url || params['*'];\n if (!splat) return undefined;\n\n const [maybeOrgWithScope, ...maybeFullName] = splat.split('/');\n const hasScope = maybeOrgWithScope.split('.').length > 1;\n const fullNameFromUrl = hasScope ? maybeFullName.join('/') : splat;\n let scope: string | undefined;\n if (hasScope) {\n scope = maybeOrgWithScope;\n }\n const match = componentRegex.exec(fullNameFromUrl);\n if (!match?.[0]) return undefined;\n if (scope) return `${scope}/${match[0]}`;\n return match[0];\n}\n"],"mappings":";;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;AACA,MAAMA,cAAc,GAAG,eAAe;AAE/B,SAASC,iBAAiB,CAACC,GAAY,EAAsB;EAClE,MAAMC,MAAM,GAAG,IAAAC,2BAAS,GAAE;EAC1B,MAAMC,KAAK,GAAGH,GAAG,IAAIC,MAAM,CAAC,GAAG,CAAC;EAChC,IAAI,CAACE,KAAK,EAAE,OAAOC,SAAS;EAE5B,MAAM,CAACC,iBAAiB,EAAE,GAAGC,aAAa,CAAC,GAAGH,KAAK,CAACI,KAAK,CAAC,GAAG,CAAC;EAC9D,MAAMC,QAAQ,GAAGH,iBAAiB,CAACE,KAAK,CAAC,GAAG,CAAC,CAACE,MAAM,GAAG,CAAC;EACxD,MAAMC,eAAe,GAAGF,QAAQ,GAAGF,aAAa,CAACK,IAAI,CAAC,GAAG,CAAC,GAAGR,KAAK;EAClE,IAAIS,KAAyB;EAC7B,IAAIJ,QAAQ,EAAE;IACZI,KAAK,GAAGP,iBAAiB;EAC3B;EACA,MAAMQ,KAAK,GAAGf,cAAc,CAACgB,IAAI,CAACJ,eAAe,CAAC;EAClD,IAAI,EAACG,KAAK,aAALA,KAAK,eAALA,KAAK,CAAG,CAAC,CAAC,GAAE,OAAOT,SAAS;EACjC,IAAIQ,KAAK,EAAE,OAAQ,GAAEA,KAAM,IAAGC,KAAK,CAAC,CAAC,CAAE,EAAC;EACxC,OAAOA,KAAK,CAAC,CAAC,CAAC;AACjB"}
|
|
@@ -1,107 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.componentOverviewFields = exports.componentIdFields = exports.componentFields = void 0;
|
|
9
8
|
exports.useComponentQuery = useComponentQuery;
|
|
10
|
-
|
|
11
9
|
function _defineProperty2() {
|
|
12
10
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
11
|
_defineProperty2 = function () {
|
|
15
12
|
return data;
|
|
16
13
|
};
|
|
17
|
-
|
|
18
14
|
return data;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
function _objectWithoutProperties2() {
|
|
22
17
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
23
|
-
|
|
24
18
|
_objectWithoutProperties2 = function () {
|
|
25
19
|
return data;
|
|
26
20
|
};
|
|
27
|
-
|
|
28
21
|
return data;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
function _react() {
|
|
32
24
|
const data = require("react");
|
|
33
|
-
|
|
34
25
|
_react = function () {
|
|
35
26
|
return data;
|
|
36
27
|
};
|
|
37
|
-
|
|
38
28
|
return data;
|
|
39
29
|
}
|
|
40
|
-
|
|
41
30
|
function _client() {
|
|
42
31
|
const data = require("@apollo/client");
|
|
43
|
-
|
|
44
32
|
_client = function () {
|
|
45
33
|
return data;
|
|
46
34
|
};
|
|
47
|
-
|
|
48
35
|
return data;
|
|
49
36
|
}
|
|
50
|
-
|
|
51
37
|
function _uiFoundationUiHooks() {
|
|
52
38
|
const data = require("@teambit/ui-foundation.ui.hooks.use-data-query");
|
|
53
|
-
|
|
54
39
|
_uiFoundationUiHooks = function () {
|
|
55
40
|
return data;
|
|
56
41
|
};
|
|
57
|
-
|
|
58
42
|
return data;
|
|
59
43
|
}
|
|
60
|
-
|
|
61
44
|
function _componentId() {
|
|
62
45
|
const data = require("@teambit/component-id");
|
|
63
|
-
|
|
64
46
|
_componentId = function () {
|
|
65
47
|
return data;
|
|
66
48
|
};
|
|
67
|
-
|
|
68
49
|
return data;
|
|
69
50
|
}
|
|
70
|
-
|
|
71
51
|
function _componentDescriptor() {
|
|
72
52
|
const data = require("@teambit/component-descriptor");
|
|
73
|
-
|
|
74
53
|
_componentDescriptor = function () {
|
|
75
54
|
return data;
|
|
76
55
|
};
|
|
77
|
-
|
|
78
56
|
return data;
|
|
79
57
|
}
|
|
80
|
-
|
|
81
58
|
function _componentModel() {
|
|
82
59
|
const data = require("./component-model");
|
|
83
|
-
|
|
84
60
|
_componentModel = function () {
|
|
85
61
|
return data;
|
|
86
62
|
};
|
|
87
|
-
|
|
88
63
|
return data;
|
|
89
64
|
}
|
|
90
|
-
|
|
91
65
|
function _componentError() {
|
|
92
66
|
const data = require("./component-error");
|
|
93
|
-
|
|
94
67
|
_componentError = function () {
|
|
95
68
|
return data;
|
|
96
69
|
};
|
|
97
|
-
|
|
98
70
|
return data;
|
|
99
71
|
}
|
|
100
|
-
|
|
101
72
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
102
|
-
|
|
103
73
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
104
|
-
|
|
105
74
|
const componentIdFields = (0, _client().gql)`
|
|
106
75
|
fragment componentIdFields on ComponentID {
|
|
107
76
|
name
|
|
@@ -239,45 +208,38 @@ const SUB_COMPONENT_REMOVED = (0, _client().gql)`
|
|
|
239
208
|
}
|
|
240
209
|
${componentIdFields}
|
|
241
210
|
`;
|
|
242
|
-
|
|
243
211
|
/** provides data to component ui page, making sure both variables and return value are safely typed and memoized */
|
|
244
212
|
function useComponentQuery(componentId, host, filters) {
|
|
245
213
|
var _data$getHost;
|
|
246
|
-
|
|
247
214
|
const idRef = (0, _react().useRef)(componentId);
|
|
248
215
|
idRef.current = componentId;
|
|
249
|
-
|
|
250
216
|
const _useDataQuery = (0, _uiFoundationUiHooks().useDataQuery)(GET_COMPONENT, {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
217
|
+
variables: _objectSpread({
|
|
218
|
+
id: componentId,
|
|
219
|
+
extensionId: host
|
|
220
|
+
}, (filters === null || filters === void 0 ? void 0 : filters.log) || {})
|
|
221
|
+
}),
|
|
222
|
+
{
|
|
223
|
+
data,
|
|
224
|
+
error,
|
|
225
|
+
loading,
|
|
226
|
+
subscribeToMore
|
|
227
|
+
} = _useDataQuery,
|
|
228
|
+
rest = (0, _objectWithoutProperties2().default)(_useDataQuery, ["data", "error", "loading", "subscribeToMore"]);
|
|
264
229
|
(0, _react().useEffect)(() => {
|
|
265
230
|
// @TODO @Kutner fix subscription for scope
|
|
266
231
|
if (host !== 'teambit.workspace/workspace') {
|
|
267
232
|
return () => {};
|
|
268
233
|
}
|
|
269
|
-
|
|
270
234
|
const unsubAddition = subscribeToMore({
|
|
271
235
|
document: SUB_SUBSCRIPTION_ADDED,
|
|
272
236
|
updateQuery: (prev, {
|
|
273
237
|
subscriptionData
|
|
274
238
|
}) => {
|
|
275
239
|
var _prev$getHost, _subscriptionData$dat, _subscriptionData$dat2;
|
|
276
|
-
|
|
277
240
|
const prevComponent = prev === null || prev === void 0 ? void 0 : (_prev$getHost = prev.getHost) === null || _prev$getHost === void 0 ? void 0 : _prev$getHost.get;
|
|
278
241
|
const addedComponent = subscriptionData === null || subscriptionData === void 0 ? void 0 : (_subscriptionData$dat = subscriptionData.data) === null || _subscriptionData$dat === void 0 ? void 0 : (_subscriptionData$dat2 = _subscriptionData$dat.componentAdded) === null || _subscriptionData$dat2 === void 0 ? void 0 : _subscriptionData$dat2.component;
|
|
279
242
|
if (!addedComponent || prevComponent) return prev;
|
|
280
|
-
|
|
281
243
|
if (idRef.current === addedComponent.id.name) {
|
|
282
244
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
283
245
|
getHost: _objectSpread(_objectSpread({}, prev.getHost), {}, {
|
|
@@ -285,7 +247,6 @@ function useComponentQuery(componentId, host, filters) {
|
|
|
285
247
|
})
|
|
286
248
|
});
|
|
287
249
|
}
|
|
288
|
-
|
|
289
250
|
return prev;
|
|
290
251
|
}
|
|
291
252
|
});
|
|
@@ -295,13 +256,10 @@ function useComponentQuery(componentId, host, filters) {
|
|
|
295
256
|
subscriptionData
|
|
296
257
|
}) => {
|
|
297
258
|
var _prev$getHost2, _subscriptionData$dat3, _subscriptionData$dat4;
|
|
298
|
-
|
|
299
259
|
if (!subscriptionData.data) return prev;
|
|
300
260
|
const prevComponent = prev === null || prev === void 0 ? void 0 : (_prev$getHost2 = prev.getHost) === null || _prev$getHost2 === void 0 ? void 0 : _prev$getHost2.get;
|
|
301
261
|
const updatedComponent = subscriptionData === null || subscriptionData === void 0 ? void 0 : (_subscriptionData$dat3 = subscriptionData.data) === null || _subscriptionData$dat3 === void 0 ? void 0 : (_subscriptionData$dat4 = _subscriptionData$dat3.componentChanged) === null || _subscriptionData$dat4 === void 0 ? void 0 : _subscriptionData$dat4.component;
|
|
302
|
-
|
|
303
262
|
const isUpdated = updatedComponent && _componentId().ComponentID.isEqualObj(prevComponent === null || prevComponent === void 0 ? void 0 : prevComponent.id, updatedComponent === null || updatedComponent === void 0 ? void 0 : updatedComponent.id);
|
|
304
|
-
|
|
305
263
|
if (isUpdated) {
|
|
306
264
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
307
265
|
getHost: _objectSpread(_objectSpread({}, prev.getHost), {}, {
|
|
@@ -309,7 +267,6 @@ function useComponentQuery(componentId, host, filters) {
|
|
|
309
267
|
})
|
|
310
268
|
});
|
|
311
269
|
}
|
|
312
|
-
|
|
313
270
|
return prev;
|
|
314
271
|
}
|
|
315
272
|
});
|
|
@@ -319,13 +276,11 @@ function useComponentQuery(componentId, host, filters) {
|
|
|
319
276
|
subscriptionData
|
|
320
277
|
}) => {
|
|
321
278
|
var _prev$getHost3, _subscriptionData$dat5, _subscriptionData$dat6;
|
|
322
|
-
|
|
323
279
|
if (!subscriptionData.data) return prev;
|
|
324
280
|
const prevComponent = prev === null || prev === void 0 ? void 0 : (_prev$getHost3 = prev.getHost) === null || _prev$getHost3 === void 0 ? void 0 : _prev$getHost3.get;
|
|
325
281
|
const removedIds = subscriptionData === null || subscriptionData === void 0 ? void 0 : (_subscriptionData$dat5 = subscriptionData.data) === null || _subscriptionData$dat5 === void 0 ? void 0 : (_subscriptionData$dat6 = _subscriptionData$dat5.componentRemoved) === null || _subscriptionData$dat6 === void 0 ? void 0 : _subscriptionData$dat6.componentIds;
|
|
326
282
|
if (!prevComponent || !(removedIds !== null && removedIds !== void 0 && removedIds.length)) return prev;
|
|
327
283
|
const isRemoved = removedIds.some(removedId => _componentId().ComponentID.isEqualObj(removedId, prevComponent.id));
|
|
328
|
-
|
|
329
284
|
if (isRemoved) {
|
|
330
285
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
331
286
|
getHost: _objectSpread(_objectSpread({}, prev.getHost), {}, {
|
|
@@ -333,7 +288,6 @@ function useComponentQuery(componentId, host, filters) {
|
|
|
333
288
|
})
|
|
334
289
|
});
|
|
335
290
|
}
|
|
336
|
-
|
|
337
291
|
return prev;
|
|
338
292
|
}
|
|
339
293
|
});
|
|
@@ -353,9 +307,7 @@ function useComponentQuery(componentId, host, filters) {
|
|
|
353
307
|
});
|
|
354
308
|
})
|
|
355
309
|
};
|
|
356
|
-
|
|
357
310
|
const id = rawComponent && _componentId().ComponentID.fromObject(rawComponent.id);
|
|
358
|
-
|
|
359
311
|
return _objectSpread({
|
|
360
312
|
componentDescriptor: id ? _componentDescriptor().ComponentDescriptor.fromObject({
|
|
361
313
|
id: id.toString(),
|