@lemon-fe/kits 1.3.0-alpha.1 → 1.3.1

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/es/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { default as BlankLayout } from './layouts/blank-layout';
9
9
  export { default as MicroLayout } from './layouts/micro-layout';
10
10
  export { default as SimpleLayout } from './layouts/simple-layout';
11
11
  export { default as Breadcrumb } from './layouts/breadcrumb';
12
+ export { default as RouteBreadcrumb } from './layouts/route-breadcrumb';
12
13
  export { default as useBatchOperator } from './hooks/use-batch-operator';
13
14
  export { default as useHistoryBlock } from './hooks/use-history-block';
14
15
  export { TabInstance } from './layouts/tab-instance';
package/es/index.js CHANGED
@@ -6,6 +6,7 @@ export { default as BlankLayout } from "./layouts/blank-layout";
6
6
  export { default as MicroLayout } from "./layouts/micro-layout";
7
7
  export { default as SimpleLayout } from "./layouts/simple-layout";
8
8
  export { default as Breadcrumb } from "./layouts/breadcrumb";
9
+ export { default as RouteBreadcrumb } from "./layouts/route-breadcrumb";
9
10
  export { default as useBatchOperator } from "./hooks/use-batch-operator";
10
11
  export { default as useHistoryBlock } from "./hooks/use-history-block";
11
12
  export { TabInstance } from "./layouts/tab-instance";
@@ -355,7 +355,8 @@ export default function Main(props) {
355
355
  match: tab.match,
356
356
  index: index,
357
357
  location: tab.location,
358
- pathAuthorities: pathAuthorities
358
+ pathAuthorities: pathAuthorities,
359
+ title: tab.title
359
360
  })
360
361
  }, key);
361
362
  })
@@ -13,12 +13,14 @@ interface Props {
13
13
  authorities?: Set<string | number> | null;
14
14
  pathAuthorities?: Map<string, string | number | (string | number)[]>;
15
15
  instance?: TabInstance;
16
+ title: string;
16
17
  }
17
18
  export declare const RouteTabContext: React.Context<{
18
19
  route: IRoute;
19
20
  match: match;
20
21
  routerBase?: string | undefined;
21
22
  instance?: TabInstance | undefined;
23
+ title: string;
22
24
  }>;
23
25
  declare const _default: React.NamedExoticComponent<Props>;
24
26
  export default _default;
@@ -13,13 +13,15 @@ export default /*#__PURE__*/memo(function RouteTab(props) {
13
13
  authorities = props.authorities,
14
14
  pathAuthorities = props.pathAuthorities,
15
15
  instance = props.instance,
16
- routerBase = props.routerBase;
16
+ routerBase = props.routerBase,
17
+ title = props.title;
17
18
  var ctx = useMemo(function () {
18
19
  return {
19
20
  match: match,
20
21
  route: route,
21
22
  instance: instance,
22
- routerBase: routerBase
23
+ routerBase: routerBase,
24
+ title: title
23
25
  };
24
26
  }, [route]);
25
27
  return /*#__PURE__*/_jsx(RouterContext.Provider, {
@@ -2,4 +2,5 @@ export { default as BasicLayout } from './basic-layout';
2
2
  export { default as BlankLayout } from './blank-layout';
3
3
  export { default as MicroLayout } from './micro-layout';
4
4
  export { default as Breadcrumb } from './breadcrumb';
5
+ export { default as RouteBreadcrumb } from './route-breadcrumb';
5
6
  export { default as SimpleLayout } from './simple-layout';
@@ -2,4 +2,5 @@ export { default as BasicLayout } from "./basic-layout";
2
2
  export { default as BlankLayout } from "./blank-layout";
3
3
  export { default as MicroLayout } from "./micro-layout";
4
4
  export { default as Breadcrumb } from "./breadcrumb";
5
+ export { default as RouteBreadcrumb } from "./route-breadcrumb";
5
6
  export { default as SimpleLayout } from "./simple-layout";
@@ -148,7 +148,8 @@ function MicroLayout(props) {
148
148
  route: route,
149
149
  location: tab.location,
150
150
  match: tab.match,
151
- instance: tab.instance
151
+ instance: tab.instance,
152
+ title: tab.title
152
153
  })
153
154
  })
154
155
  }, (_tab$key = tab.key) !== null && _tab$key !== void 0 ? _tab$key : tab.rootPath);
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare function RouteBreadcrumb(): JSX.Element;
3
+ export default RouteBreadcrumb;
@@ -0,0 +1,85 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useContext, useMemo } from 'react';
8
+ import { Link, matchPath, useRouteMatch } from 'react-router-dom';
9
+ import { RouteTabContext } from "./components/route-tab";
10
+ import { Icons, PREFIX_CLS, useLocaleReceiver, Breadcrumb } from '@lemon-fe/components';
11
+ import { uniqBy } from 'lodash';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ function RouteBreadcrumb() {
15
+ var _useRouteMatch = useRouteMatch(),
16
+ path = _useRouteMatch.path,
17
+ url = _useRouteMatch.url;
18
+ var _useContext = useContext(RouteTabContext),
19
+ route = _useContext.route,
20
+ title = _useContext.title;
21
+ var _useLocaleReceiver = useLocaleReceiver('Common'),
22
+ _useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
23
+ backText = _useLocaleReceiver2[0].backText;
24
+ var items = useMemo(function () {
25
+ var pathSet = new Set();
26
+ path.replace(/^\//, '').split(/\//).reduce(function (prev, item) {
27
+ var next = prev + '/' + item;
28
+ pathSet.add(next);
29
+ return next;
30
+ }, '');
31
+ var nodes = [];
32
+ var traverse = function traverse(routes) {
33
+ for (var i = 0; i < routes.length; i++) {
34
+ var curr = routes[i];
35
+ if (curr.title === undefined) {
36
+ continue;
37
+ }
38
+ var matched = matchPath(url, {
39
+ strict: curr.strict,
40
+ sensitive: curr.sensitive,
41
+ path: curr.path,
42
+ exact: curr.exact
43
+ });
44
+ if (matched !== null) {
45
+ if (pathSet.has(matched.path)) {
46
+ nodes.push({
47
+ title: curr.path === route.path ? title : curr.title,
48
+ url: matched.url
49
+ });
50
+ }
51
+ if (!matched.isExact) {
52
+ if (curr.routes !== undefined) {
53
+ traverse(curr.routes);
54
+ break;
55
+ }
56
+ } else {
57
+ break;
58
+ }
59
+ }
60
+ }
61
+ };
62
+ traverse([route]);
63
+ return uniqBy(nodes, 'title');
64
+ }, []);
65
+ return /*#__PURE__*/_jsxs(Breadcrumb, {
66
+ style: {
67
+ fontWeight: 'normal'
68
+ },
69
+ children: [items.length > 1 ? /*#__PURE__*/_jsxs(Breadcrumb.Item, {
70
+ className: "".concat(PREFIX_CLS, "-breadcrumb-back"),
71
+ children: [/*#__PURE__*/_jsx(Icons.Down, {}), /*#__PURE__*/_jsx(Link, {
72
+ to: items[items.length - 2].url,
73
+ children: backText
74
+ })]
75
+ }) : null, items.map(function (item, index) {
76
+ return /*#__PURE__*/_jsx(Breadcrumb.Item, {
77
+ children: item.url && index < items.length - 1 ? /*#__PURE__*/_jsx(Link, {
78
+ to: item.url,
79
+ children: item.title
80
+ }) : item.title
81
+ }, item.url);
82
+ })]
83
+ });
84
+ }
85
+ export default RouteBreadcrumb;
@@ -138,7 +138,8 @@ function SimpleLayout(props) {
138
138
  route: route,
139
139
  location: tab.location,
140
140
  match: tab.match,
141
- instance: tab.instance
141
+ instance: tab.instance,
142
+ title: tab.title
142
143
  })
143
144
  })
144
145
  }, (_tab$key = tab.key) !== null && _tab$key !== void 0 ? _tab$key : tab.rootPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.3.0-alpha.1",
3
+ "version": "1.3.1",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -24,9 +24,9 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@ant-design/icons": "^4.7.0",
27
- "@lemon-fe/components": "^1.3.0-alpha.1",
28
- "@lemon-fe/hooks": "^1.3.0-alpha.1",
29
- "@lemon-fe/utils": "^1.3.0-alpha.1",
27
+ "@lemon-fe/components": "^1.3.1",
28
+ "@lemon-fe/hooks": "^1.3.0",
29
+ "@lemon-fe/utils": "^1.3.0",
30
30
  "ag-grid-community": "29.2.0",
31
31
  "antd": "4.24.8",
32
32
  "classnames": "^2.2.6",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "registry": "https://registry.npmjs.org"
48
48
  },
49
- "gitHead": "52760c0efff162a4398a447c2f8c942618e100ed"
49
+ "gitHead": "dfdd62a5ff92ae105fadbd0edade32f77c04860d"
50
50
  }