@teambit/component 0.0.743 → 0.0.744
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.744.tgz +0 -0
- package/package.json +24 -27
- package/{preview-1653708349111.js → preview-1653827208409.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.743.tgz +0 -0
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { extendPath } from '@teambit/ui-foundation.ui.react-router.extend-path';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
import { Link, LinkProps } from '@teambit/base-react.navigation.link';
|
|
6
5
|
|
|
7
6
|
import styles from './top-bar-nav.module.scss';
|
|
8
7
|
|
|
9
|
-
export type TopBarNavProps = {} &
|
|
8
|
+
export type TopBarNavProps = {} & LinkProps;
|
|
10
9
|
|
|
11
10
|
export function TopBarNav({ href, className, activeClassName, children, ...rest }: TopBarNavProps) {
|
|
12
|
-
const { url } = useRouteMatch();
|
|
13
11
|
const { search } = useLocation(); // sticky query params
|
|
14
12
|
|
|
15
|
-
const target = `${
|
|
13
|
+
const target = `${href}${search}`;
|
|
16
14
|
|
|
17
15
|
return (
|
|
18
|
-
<
|
|
16
|
+
<Link
|
|
19
17
|
{...rest}
|
|
20
18
|
className={classnames(className, styles.topBarLink)}
|
|
21
19
|
activeClassName={classnames(activeClassName, styles.active)}
|
|
22
20
|
href={target}
|
|
23
21
|
>
|
|
24
22
|
<div>{children}</div>
|
|
25
|
-
</
|
|
23
|
+
</Link>
|
|
26
24
|
);
|
|
27
25
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useParams } from 'react-router-dom';
|
|
2
|
+
|
|
3
|
+
/** component url is comprised of letters, numbers, "_", "-", "/" but should not include trailing "/", and should not include "~" */
|
|
4
|
+
const componentRegex = /^[\w/-]*[\w-]/;
|
|
5
|
+
export function useIdFromLocation() {
|
|
6
|
+
const params = useParams();
|
|
7
|
+
const splat = params['*'];
|
|
8
|
+
if (!splat) return undefined;
|
|
9
|
+
|
|
10
|
+
const match = componentRegex.exec(splat);
|
|
11
|
+
return match?.[0];
|
|
12
|
+
}
|
package/ui/use-component.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useRouteMatch } from 'react-router-dom';
|
|
2
1
|
import { ComponentID } from '@teambit/component-id';
|
|
3
2
|
import { useQuery } from '@teambit/ui-foundation.ui.react-router.use-query';
|
|
4
3
|
import { ComponentDescriptor } from '@teambit/component-descriptor';
|
|
@@ -13,18 +12,13 @@ export type Component = {
|
|
|
13
12
|
componentDescriptor?: ComponentDescriptor;
|
|
14
13
|
};
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
componentId?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function useComponent(host: string, id?: ComponentID): Component {
|
|
21
|
-
const {
|
|
22
|
-
params: { componentId },
|
|
23
|
-
} = useRouteMatch<ComponentRoute>();
|
|
15
|
+
export function useComponent(host: string, id?: string | ComponentID): Component {
|
|
24
16
|
const query = useQuery();
|
|
25
17
|
const version = query.get('version') || undefined;
|
|
26
18
|
const lanesContext = useLanesContext();
|
|
27
|
-
|
|
19
|
+
|
|
20
|
+
const targetId =
|
|
21
|
+
(typeof id === 'string' && id) || (typeof id !== 'undefined' && id.toString({ ignoreVersion: true }));
|
|
28
22
|
if (!targetId) throw new TypeError('useComponent received no component id');
|
|
29
23
|
const currentLane = lanesContext?.viewedLane;
|
|
30
24
|
// when on a lane, always fetch all the logs starting from the 'head' version
|
|
Binary file
|