@chaoswise/ui 3.1.5 → 3.1.6

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.
@@ -10,8 +10,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
10
10
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
11
11
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
12
12
  import React, { useMemo } from 'react';
13
- import { useHistory } from 'react-router-dom';
14
- import { Link } from 'react-router-dom';
13
+ import { useHistory, Link } from 'react-router-dom';
15
14
  function BreadcrumbShow(_ref) {
16
15
  var _ref$routes = _ref.routes,
17
16
  routes = _ref$routes === void 0 ? [] : _ref$routes,
@@ -55,15 +54,15 @@ function BreadcrumbShow(_ref) {
55
54
  }
56
55
  return data;
57
56
  }, [routes, pathname, formatData]);
57
+ var _breadcrumbData = breadData ? breadData : breadcrumbData;
58
58
  if (render) {
59
59
  return render({
60
60
  routes: routes,
61
- data: data,
61
+ data: _breadcrumbData,
62
62
  currentPath: currentPath,
63
63
  breadcrumbOptions: breadcrumbOptions
64
64
  });
65
65
  }
66
- var _breadcrumbData = breadData ? breadData : breadcrumbData;
67
66
  return /*#__PURE__*/React.createElement(_Breadcrumb, _extends({
68
67
  style: _objectSpread({}, style)
69
68
  }, resP), _breadcrumbData.map(function (bread, index) {
@@ -1,4 +1,5 @@
1
- var _excluded = ["children", "id"];
1
+ import _useConfigContext2 from "@chaoswise/ui/lib/useConfigContext";
2
+ var _excluded = ["children"];
2
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
4
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
4
5
  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."); }
@@ -9,16 +10,13 @@ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
9
10
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
10
11
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
11
12
  import React, { useLayoutEffect, useRef, useEffect } from "react";
12
- import useConfigContext from "../useConfigContext";
13
13
  import { eventManager } from "../utils";
14
14
  import classnames from "classnames";
15
15
  import useStyle from "./style/footer";
16
16
  function Footer(_ref) {
17
17
  var children = _ref.children,
18
- _ref$id = _ref.id,
19
- id = _ref$id === void 0 ? "" : _ref$id,
20
18
  res = _objectWithoutProperties(_ref, _excluded);
21
- var _useConfigContext = useConfigContext(),
19
+ var _useConfigContext = _useConfigContext2(),
22
20
  getPrefixCls = _useConfigContext.getPrefixCls;
23
21
  var prefixCls = getPrefixCls("basic-layout");
24
22
  var dom = useRef(null);
@@ -1,6 +1,7 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  import _Tooltip from "@chaoswise/ui/lib/Tooltip";
3
3
  import _SiderMenu from "@chaoswise/ui/lib/SiderMenu";
4
+ import _useConfigContext2 from "@chaoswise/ui/lib/useConfigContext";
4
5
  import _Layout from "@chaoswise/ui/lib/Layout";
5
6
  var _excluded = ["canDrag", "enable", "maxDragWidth", "resizeBarColor", "onResizeStart", "onResizeStop", "onResize", "siderDragWidth"],
6
7
  _excluded2 = ["menuData", "resizableProps"];
@@ -23,7 +24,6 @@ import { Resizable } from "re-resizable";
23
24
  import { MenuFoldOutlined, MenuUnfoldOutlined } from "@ant-design/icons";
24
25
  import { useTheme } from '../antd-style';
25
26
  import classnames from 'classnames';
26
- import useConfigContext from "../useConfigContext";
27
27
  import useStyle from "./style/sider";
28
28
  var AntSider = _Layout.Sider;
29
29
  function Sider(_ref) {
@@ -38,7 +38,7 @@ function Sider(_ref) {
38
38
  _setSiderDragWidth = _ref._setSiderDragWidth,
39
39
  menuOptions = _ref.menuOptions,
40
40
  onCollapse = _ref.onCollapse;
41
- var _useConfigContext = useConfigContext(),
41
+ var _useConfigContext = _useConfigContext2(),
42
42
  getPrefixCls = _useConfigContext.getPrefixCls;
43
43
  var prefixCls = getPrefixCls("basic-layout");
44
44
  var _useStyle = useStyle("".concat(prefixCls, "-cw-side")),
@@ -1,5 +1,6 @@
1
1
  import _ErrorBoundary from "@chaoswise/ui/lib/ErrorBoundary";
2
2
  import _Header from "@chaoswise/ui/lib/Header";
3
+ import _useConfigContext2 from "@chaoswise/ui/lib/useConfigContext";
3
4
  import _Layout from "@chaoswise/ui/lib/Layout";
4
5
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
5
6
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
@@ -21,7 +22,6 @@ import { eventManager } from '../utils';
21
22
  import { judgeIsIframe } from "./utils";
22
23
  import intl from "../locales";
23
24
  import useStyle from "./style/index";
24
- import useConfigContext from "../useConfigContext";
25
25
  var Content = _Layout.Content,
26
26
  AntHeader = _Layout.Header;
27
27
 
@@ -82,7 +82,7 @@ var BasicLayout = function BasicLayout(_ref) {
82
82
  _ref$style = _ref.style,
83
83
  style = _ref$style === void 0 ? {} : _ref$style;
84
84
  var isInIrame = judgeIsIframe();
85
- var _useConfigContext = useConfigContext(),
85
+ var _useConfigContext = _useConfigContext2(),
86
86
  getPrefixCls = _useConfigContext.getPrefixCls;
87
87
  var prefixCls = getPrefixCls("basic-layout");
88
88
  var _useStyle = useStyle("".concat(prefixCls, "-cw-layout-out")),
@@ -78,8 +78,7 @@ export var commonComponentToken = {
78
78
  opacityLoading: 0.35
79
79
  },
80
80
  Select: {
81
- optionPadding: "5px 10px",
82
- algorithm: true
81
+ optionPadding: "5px 10px"
83
82
  },
84
83
  CWSelect: {
85
84
  optionPadding: "5px 10px"
@@ -1,43 +1,79 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
7
  import React from "react";
2
8
  import PropTypes from "prop-types";
9
+
3
10
  /**
4
- *
5
11
  * 封装的树形结构懒加载组件
6
12
  */
7
13
  function fetchTreeNode(oldData, parentId, childNode) {
14
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
15
+ var _options$keyField = options.keyField,
16
+ keyField = _options$keyField === void 0 ? "value" : _options$keyField,
17
+ compareFn = options.compareFn;
8
18
  return oldData.map(function (item) {
9
- if (item.value === parentId) {
10
- item.children = childNode;
19
+ var isMatch = false;
20
+ if (compareFn) {
21
+ isMatch = compareFn(item, parentId);
22
+ } else {
23
+ var itemKey = item[keyField];
24
+ isMatch = itemKey === parentId;
25
+ }
26
+ if (isMatch) {
27
+ return _objectSpread(_objectSpread({}, item), {}, {
28
+ children: childNode
29
+ });
11
30
  } else if (item.children) {
12
- item.children = fetchTreeNode(item.children, parentId, childNode);
31
+ return _objectSpread(_objectSpread({}, item), {}, {
32
+ children: fetchTreeNode(item.children, parentId, childNode, options)
33
+ });
13
34
  }
14
35
  return item;
15
36
  });
16
37
  }
17
- function treeLoad(oldData, treeNodeKey, fetchData, getChildNode) {
38
+ // 1. 旧版API: treeLoad(oldData, treeNodeKey, fetchData, getChildNode)
39
+ // 2. 新版API: treeLoad(oldData, treeNodeKey, fetchData, options)
40
+ // 3. 混合API-1: treeLoad(oldData, treeNodeKey, fetchData, getChildNode, options) - 第四个参数是函数,第五个是对象
41
+ // 4. 混合API-2: treeLoad(oldData, treeNodeKey, fetchData, options, getChildNode) - 第四个参数是对象,第五个是函数
42
+
43
+ function treeLoad(oldData, treeNodeKey, fetchData, getChildNodeOrOptions, maybeOptions) {
44
+ // 兼容旧版API: 第四个参数可能是getChildNode回调函数或options对象
45
+ var getChildNode;
46
+ var options = {};
47
+ if (typeof getChildNodeOrOptions === "function") {
48
+ // 旧版API: 第四个参数是getChildNode回调函数
49
+ getChildNode = getChildNodeOrOptions;
50
+ // 如果第五个参数是对象,则作为options
51
+ if (maybeOptions && _typeof(maybeOptions) === "object") {
52
+ options = maybeOptions;
53
+ }
54
+ } else if (getChildNodeOrOptions && _typeof(getChildNodeOrOptions) === "object") {
55
+ // 新版API: 第四个参数是options对象
56
+ options = getChildNodeOrOptions;
57
+ // 如果提供了第五个参数且为函数,则视为getChildNode
58
+ if (typeof maybeOptions === "function") {
59
+ getChildNode = maybeOptions;
60
+ }
61
+ }
18
62
  fetchData(treeNodeKey, function (childNode) {
19
- var newData = fetchTreeNode(oldData, treeNodeKey, childNode);
63
+ var newData = fetchTreeNode(oldData, treeNodeKey, childNode, options);
20
64
  getChildNode && getChildNode();
21
65
  return newData;
22
66
  });
23
67
  }
24
68
  treeLoad.propTypes = {
25
- /**
26
- * 获取子节点的数据,并通过回调函数返回最终渲染的数据。
27
- * function(pageNum,callback(res):Data)
28
- */
29
69
  fetchData: PropTypes.func,
30
- /**
31
- * 加载前的树形结构数据,结构中把value作为唯一键值
32
- */
33
70
  oldData: PropTypes.array,
34
- /**
35
- * 要展开的树节点
36
- */
37
71
  treeNodeKey: PropTypes.string,
38
- /**
39
- * 获取子树数据时额外执行的回调函数。
40
- */
41
- getChildNode: PropTypes.func
72
+ getChildNode: PropTypes.func,
73
+ options: PropTypes.shape({
74
+ keyField: PropTypes.string,
75
+ // 指定用于匹配的字段名
76
+ compareFn: PropTypes.func // 自定义比较函数
77
+ })
42
78
  };
43
79
  export default treeLoad;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chaoswise/ui",
3
3
  "packageName": "chaoswiseUI",
4
- "version": "3.1.5",
4
+ "version": "3.1.6",
5
5
  "description": "公共UI库",
6
6
  "keywords": [
7
7
  "ui",
@@ -50,7 +50,7 @@
50
50
  "echarts-for-react": "^3.0.2",
51
51
  "highlight.js": "^9.18.5",
52
52
  "immutability-helper": "^3.1.1",
53
- "marked": "^15.0.7",
53
+ "marked": "^4.3.0",
54
54
  "moment-timezone": "^0.5.46",
55
55
  "omit.js": "^2.0.2",
56
56
  "qrcode.react": "^3.1.0",
@@ -1,4 +0,0 @@
1
- export default {
2
- back: 'Back',
3
- allProductsTitle: 'Products'
4
- };
@@ -1,11 +0,0 @@
1
- import zh_CN from './zh_CN.js';
2
- import en_US from './en_US.js';
3
- import zh_TW from './zh_TW.js';
4
- export default {
5
- zh_CN: zh_CN,
6
- en_US: en_US,
7
- zh_TW: zh_TW,
8
- // 兼容
9
- zh: zh_CN,
10
- en: en_US
11
- };
@@ -1,4 +0,0 @@
1
- export default {
2
- back: '返回',
3
- allProductsTitle: '所有产品'
4
- };
@@ -1,4 +0,0 @@
1
- export default {
2
- back: '返回',
3
- allProductsTitle: '所有產品'
4
- };