@teambit/ui-foundation.ui.react-router.slot-router 0.0.0-38ea42131da7ff9c461edaeb2e8cd531e9e54cbc

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.
@@ -0,0 +1,2 @@
1
+ export { SlotRouter } from './slot-router';
2
+ export type { SlotRouterProps, RouteSlot, NavigationSlot } from './slot-router';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { SlotRouter } from './slot-router';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ ;
2
+ ;
3
+
4
+ export const compositions = [];
5
+ export const overview = [];
6
+
7
+ export const compositions_metadata = {"compositions":[]};
@@ -0,0 +1,17 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { SlotRegistry } from '@teambit/harmony';
3
+ import { RouteProps } from 'react-router-dom';
4
+ import type { LinkProps } from '@teambit/base-react.navigation.link';
5
+ export type RouteSlot = SlotRegistry<RouteProps | RouteProps[]>;
6
+ export type NavigationSlot = SlotRegistry<LinkProps>;
7
+ export type SlotRouterProps = PropsWithChildren<{
8
+ /**
9
+ * @deprecated
10
+ * use @property routes to pass list of routes instead
11
+ */
12
+ slot?: RouteSlot;
13
+ routes?: RouteProps[];
14
+ rootRoutes?: RouteProps[];
15
+ parentPath?: string;
16
+ }>;
17
+ export declare function SlotRouter({ routes: routesFromProps, slot, rootRoutes, children, parentPath }: SlotRouterProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Routes, Route } from 'react-router-dom';
3
+ import { flatten } from 'lodash';
4
+ function toKey(route) {
5
+ if (route.path)
6
+ return route.path;
7
+ if (route.index)
8
+ return '/';
9
+ return '.';
10
+ }
11
+ export function SlotRouter({ routes: routesFromProps, slot, rootRoutes, children, parentPath }) {
12
+ const routes = routesFromProps || (slot && flatten(slot.values())) || [];
13
+ const withRoot = routes.concat(rootRoutes || []);
14
+ const jsxRoutes = withRoot.map((route) => _jsx(Route, { ...route }, toKey(route)));
15
+ if (parentPath) {
16
+ return (_jsx(Routes, { children: _jsxs(Route, { path: parentPath, children: [jsxRoutes, children] }) }));
17
+ }
18
+ return (_jsx(Routes, { children: _jsxs(Route, { path: parentPath, children: [jsxRoutes, children] }) }));
19
+ }
20
+ //# sourceMappingURL=slot-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slot-router.js","sourceRoot":"","sources":["../slot-router.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAc,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAiBjC,SAAS,KAAK,CAAC,KAAiB;IAC9B,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC;IAClC,IAAI,KAAK,CAAC,KAAK;QAAE,OAAO,GAAG,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAmB;IAC7G,MAAM,MAAM,GAAG,eAAe,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACzE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IAEjD,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,KAAK,OAAwB,KAAK,IAAvB,KAAK,CAAC,KAAK,CAAC,CAAe,CAAC,CAAC;IAEnF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CACL,KAAC,MAAM,cACL,MAAC,KAAK,IAAC,IAAI,EAAE,UAAU,aACpB,SAAS,EACT,QAAQ,IACH,GACD,CACV,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,MAAM,cACL,MAAC,KAAK,IAAC,IAAI,EAAE,UAAU,aACpB,SAAS,EACT,QAAQ,IACH,GACD,CACV,CAAC;AACJ,CAAC"}
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { SlotRouter } from './slot-router';
2
+ export type { SlotRouterProps, RouteSlot, NavigationSlot } from './slot-router';
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@teambit/ui-foundation.ui.react-router.slot-router",
3
+ "version": "0.0.0-38ea42131da7ff9c461edaeb2e8cd531e9e54cbc",
4
+ "homepage": "https://bit.cloud/teambit/ui-foundation/ui/react-router/slot-router",
5
+ "main": "dist/index.js",
6
+ "componentId": {
7
+ "scope": "teambit.ui-foundation",
8
+ "name": "ui/react-router/slot-router",
9
+ "version": "38ea42131da7ff9c461edaeb2e8cd531e9e54cbc"
10
+ },
11
+ "dependencies": {
12
+ "lodash": "4.17.21",
13
+ "@teambit/harmony": "0.4.7"
14
+ },
15
+ "devDependencies": {
16
+ "@types/lodash": "4.14.165",
17
+ "@types/mocha": "9.1.0",
18
+ "@teambit/react.v17.react-env": "1.1.94"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^16.8.0 || ^17.0.0",
22
+ "react-router-dom": "^6.16.0",
23
+ "@types/react": "^17.0.0",
24
+ "@teambit/base-react.navigation.link": "2.0.33"
25
+ },
26
+ "license": "Apache-2.0",
27
+ "optionalDependencies": {},
28
+ "peerDependenciesMeta": {},
29
+ "private": false,
30
+ "engines": {
31
+ "node": ">=12.22.0"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/teambit/bit"
36
+ },
37
+ "keywords": [
38
+ "bit",
39
+ "components",
40
+ "collaboration",
41
+ "web",
42
+ "react",
43
+ "react-components",
44
+ "angular",
45
+ "angular-components"
46
+ ]
47
+ }
@@ -0,0 +1,52 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { SlotRegistry } from '@teambit/harmony';
3
+ import { Routes, Route, RouteProps } from 'react-router-dom';
4
+ import { flatten } from 'lodash';
5
+ import type { LinkProps } from '@teambit/base-react.navigation.link';
6
+
7
+ export type RouteSlot = SlotRegistry<RouteProps | RouteProps[]>;
8
+ export type NavigationSlot = SlotRegistry<LinkProps>;
9
+
10
+ export type SlotRouterProps = PropsWithChildren<{
11
+ /**
12
+ * @deprecated
13
+ * use @property routes to pass list of routes instead
14
+ */
15
+ slot?: RouteSlot;
16
+ routes?: RouteProps[];
17
+ rootRoutes?: RouteProps[];
18
+ parentPath?: string;
19
+ }>;
20
+
21
+ function toKey(route: RouteProps) {
22
+ if (route.path) return route.path;
23
+ if (route.index) return '/';
24
+ return '.';
25
+ }
26
+
27
+ export function SlotRouter({ routes: routesFromProps, slot, rootRoutes, children, parentPath }: SlotRouterProps) {
28
+ const routes = routesFromProps || (slot && flatten(slot.values())) || [];
29
+ const withRoot = routes.concat(rootRoutes || []);
30
+
31
+ const jsxRoutes = withRoot.map((route) => <Route key={toKey(route)} {...route} />);
32
+
33
+ if (parentPath) {
34
+ return (
35
+ <Routes>
36
+ <Route path={parentPath}>
37
+ {jsxRoutes}
38
+ {children}
39
+ </Route>
40
+ </Routes>
41
+ );
42
+ }
43
+
44
+ return (
45
+ <Routes>
46
+ <Route path={parentPath}>
47
+ {jsxRoutes}
48
+ {children}
49
+ </Route>
50
+ </Routes>
51
+ );
52
+ }
@@ -0,0 +1,41 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
11
+ const src: string;
12
+ export default src;
13
+ }
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }