@teambit/ui-foundation.ui.react-router.slot-router 0.0.499 → 0.0.500

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.
@@ -5,8 +5,13 @@ import type { LinkProps } from '@teambit/base-react.navigation.link';
5
5
  export declare type RouteSlot = SlotRegistry<RouteProps | RouteProps[]>;
6
6
  export declare type NavigationSlot = SlotRegistry<LinkProps>;
7
7
  export declare type SlotRouterProps = PropsWithChildren<{
8
- slot: RouteSlot;
8
+ /**
9
+ * @deprecated
10
+ * use @property routes to pass list of routes instead
11
+ */
12
+ slot?: RouteSlot;
13
+ routes?: RouteProps[];
9
14
  rootRoutes?: RouteProps[];
10
15
  parentPath?: string;
11
16
  }>;
12
- export declare function SlotRouter({ slot, rootRoutes, children, parentPath }: SlotRouterProps): JSX.Element;
17
+ export declare function SlotRouter({ routes: routesFromProps, slot, rootRoutes, children, parentPath }: SlotRouterProps): JSX.Element;
@@ -7,8 +7,8 @@ exports.SlotRouter = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const react_router_dom_1 = require("react-router-dom");
9
9
  const lodash_1 = require("lodash");
10
- function SlotRouter({ slot, rootRoutes, children, parentPath }) {
11
- const routes = (0, lodash_1.flatten)(slot.values());
10
+ function SlotRouter({ routes: routesFromProps, slot, rootRoutes, children, parentPath }) {
11
+ const routes = routesFromProps || (slot && (0, lodash_1.flatten)(slot.values())) || [];
12
12
  const withRoot = routes.concat(rootRoutes || []);
13
13
  const jsxRoutes = withRoot.map((route) => react_1.default.createElement(react_router_dom_1.Route, Object.assign({ key: toKey(route) }, route)));
14
14
  if (parentPath) {
@@ -1 +1 @@
1
- {"version":3,"file":"slot-router.js","sourceRoot":"","sources":["../slot-router.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAiD;AAEjD,uDAA6D;AAC7D,mCAAiC;AAYjC,SAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,E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AAI,EAAE,CAAC,CAAC;IAEjD,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,8BAAC,wBAAK,kBAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,IAAM,KAAK,EAAI,CAAC,CAAC;IAEnF,IAAI,UAAU,EAAE;QACd,OAAO,CACL,8BAAC,yBAAM;YACL,8BAAC,wBAAK,IAAC,IAAI,EAAE,UAAU;gBACpB,SAAS;gBACT,QAAQ,CACH,CACD,CACV,CAAC;KACH;IAED,OAAO,CACL,8BAAC,yBAAM;QACL,8BAAC,wBAAK,IAAC,IAAI,EAAE,UAAU;YACpB,SAAS;YACT,QAAQ,CACH,CACD,CACV,CAAC;AACJ,CAAC;AAzBD,gCAyBC;AAED,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"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/ui-foundation.ui.react-router.slot-router",
3
- "version": "0.0.499",
3
+ "version": "0.0.500",
4
4
  "homepage": "https://bit.dev/teambit/ui-foundation/ui/react-router/slot-router",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.ui-foundation",
8
8
  "name": "ui/react-router/slot-router",
9
- "version": "0.0.499"
9
+ "version": "0.0.500"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
package/slot-router.tsx CHANGED
@@ -8,13 +8,18 @@ export type RouteSlot = SlotRegistry<RouteProps | RouteProps[]>;
8
8
  export type NavigationSlot = SlotRegistry<LinkProps>;
9
9
 
10
10
  export type SlotRouterProps = PropsWithChildren<{
11
- slot: RouteSlot;
11
+ /**
12
+ * @deprecated
13
+ * use @property routes to pass list of routes instead
14
+ */
15
+ slot?: RouteSlot;
16
+ routes?: RouteProps[];
12
17
  rootRoutes?: RouteProps[];
13
18
  parentPath?: string;
14
19
  }>;
15
20
 
16
- export function SlotRouter({ slot, rootRoutes, children, parentPath }: SlotRouterProps) {
17
- const routes = flatten(slot.values());
21
+ export function SlotRouter({ routes: routesFromProps, slot, rootRoutes, children, parentPath }: SlotRouterProps) {
22
+ const routes = routesFromProps || (slot && flatten(slot.values())) || [];
18
23
  const withRoot = routes.concat(rootRoutes || []);
19
24
 
20
25
  const jsxRoutes = withRoot.map((route) => <Route key={toKey(route)} {...route} />);