@aloudata/aloudata-design 2.12.6 → 2.13.0

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.
Files changed (41) hide show
  1. package/dist/ColorPicker/index.js +2 -2
  2. package/dist/Icon/components/SignLightLine.d.ts +11 -0
  3. package/dist/Icon/components/SignLightLine.js +35 -0
  4. package/dist/Icon/index.d.ts +1 -0
  5. package/dist/Icon/index.js +1 -0
  6. package/dist/Icon/svg/Sign-light-line.svg +3 -0
  7. package/dist/List/index.js +1 -4
  8. package/dist/LogicTree/DisplayLogicTree.d.ts +9 -0
  9. package/dist/LogicTree/DisplayLogicTree.js +14 -0
  10. package/dist/LogicTree/components/DisplayLogicItem/index.d.ts +10 -0
  11. package/dist/LogicTree/components/DisplayLogicItem/index.js +87 -0
  12. package/dist/LogicTree/components/LogicItem/index.d.ts +14 -0
  13. package/dist/LogicTree/components/LogicItem/index.js +144 -0
  14. package/dist/LogicTree/helper.d.ts +8 -0
  15. package/dist/LogicTree/helper.js +183 -0
  16. package/dist/LogicTree/index.d.ts +17 -0
  17. package/dist/LogicTree/index.js +78 -0
  18. package/dist/LogicTree/style/DisplayLogicItem.less +54 -0
  19. package/dist/LogicTree/style/LoginItem.less +79 -0
  20. package/dist/LogicTree/style/index.d.ts +2 -0
  21. package/dist/LogicTree/style/index.js +2 -0
  22. package/dist/LogicTree/style/index.less +12 -0
  23. package/dist/LogicTree/type.d.ts +22 -0
  24. package/dist/LogicTree/type.js +10 -0
  25. package/dist/MemberPicker/components/PanelWrapper.js +0 -1
  26. package/dist/MemberPicker/index.js +24 -21
  27. package/dist/MemberPicker/tests/mockPort.d.ts +6 -0
  28. package/dist/MemberPicker/tests/mockPort.js +147 -0
  29. package/dist/Steps/style/index.less +1 -7
  30. package/dist/_utils/getUniqId.d.ts +5 -0
  31. package/dist/_utils/getUniqId.js +12 -0
  32. package/dist/ald.min.css +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +1 -0
  35. package/dist/index.less +1 -0
  36. package/dist/locale/default.d.ts +10 -0
  37. package/dist/locale/en_US.d.ts +10 -0
  38. package/dist/locale/en_US.js +10 -0
  39. package/dist/locale/zh_CN.d.ts +10 -0
  40. package/dist/locale/zh_CN.js +10 -0
  41. package/package.json +1 -1
@@ -155,10 +155,10 @@ export default function ColorPicker(_ref) {
155
155
  }),
156
156
  ref: wrapRef
157
157
  }, /*#__PURE__*/React.createElement(Dropdown, {
158
- trigger: ['click'],
158
+ trigger: 'click',
159
159
  open: open,
160
160
  disabled: disabled,
161
- placement: 'bottomLeft',
161
+ placement: 'bottom-start',
162
162
  dropdownRender: function dropdownRender() {
163
163
  return overlay;
164
164
  }
@@ -0,0 +1,11 @@
1
+ import type { SVGProps } from 'react';
2
+ import * as React from 'react';
3
+ interface SVGRProps {
4
+ size?: number | string;
5
+ title?: string;
6
+ titleId?: string;
7
+ desc?: string;
8
+ descId?: string;
9
+ }
10
+ declare const Memo: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<SVGProps<SVGSVGElement> & SVGRProps, "ref"> & React.RefAttributes<SVGSVGElement>>>;
11
+ export default Memo;
@@ -0,0 +1,35 @@
1
+ var _excluded = ["title", "titleId", "desc", "descId"];
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
+ import * as React from 'react';
6
+ import { forwardRef, memo } from 'react';
7
+ var SignLightLine = function SignLightLine(_ref, ref) {
8
+ var title = _ref.title,
9
+ titleId = _ref.titleId,
10
+ desc = _ref.desc,
11
+ descId = _ref.descId,
12
+ props = _objectWithoutProperties(_ref, _excluded);
13
+ return /*#__PURE__*/React.createElement("svg", _extends({
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ width: props.width || props.size || 16,
16
+ height: props.height || props.size || 16,
17
+ fill: "none",
18
+ viewBox: "0 0 24 24",
19
+ ref: ref,
20
+ "aria-labelledby": titleId,
21
+ "aria-describedby": descId
22
+ }, props), desc ? /*#__PURE__*/React.createElement("desc", {
23
+ id: descId
24
+ }, desc) : null, title ? /*#__PURE__*/React.createElement("title", {
25
+ id: titleId
26
+ }, title) : null, /*#__PURE__*/React.createElement("path", {
27
+ fill: props.color || 'currentColor',
28
+ fillRule: "evenodd",
29
+ d: "M12 5.25a.75.75 0 0 1 .75.75v5.25H18a.75.75 0 0 1 0 1.5h-5.25V18a.75.75 0 0 1-1.5 0v-5.25H6a.75.75 0 0 1 0-1.5h5.25V6a.75.75 0 0 1 .75-.75Z",
30
+ clipRule: "evenodd"
31
+ }));
32
+ };
33
+ var ForwardRef = /*#__PURE__*/forwardRef(SignLightLine);
34
+ var Memo = /*#__PURE__*/memo(ForwardRef);
35
+ export default Memo;
@@ -38,6 +38,7 @@ export { default as LoadingDuotone } from './components/LoadingDuotone';
38
38
  export { default as LoadingLine } from './components/LoadingLine';
39
39
  export { default as MoreVerticalLine } from './components/MoreVerticalLine';
40
40
  export { default as SearchLine } from './components/SearchLine';
41
+ export { default as SignLightLine } from './components/SignLightLine';
41
42
  export { default as SortAscendingOrderColor } from './components/SortAscendingOrderColor';
42
43
  export { default as SortColor } from './components/SortColor';
43
44
  export { default as SortDescendingOrderColor } from './components/SortDescendingOrderColor';
@@ -38,6 +38,7 @@ export { default as LoadingDuotone } from "./components/LoadingDuotone";
38
38
  export { default as LoadingLine } from "./components/LoadingLine";
39
39
  export { default as MoreVerticalLine } from "./components/MoreVerticalLine";
40
40
  export { default as SearchLine } from "./components/SearchLine";
41
+ export { default as SignLightLine } from "./components/SignLightLine";
41
42
  export { default as SortAscendingOrderColor } from "./components/SortAscendingOrderColor";
42
43
  export { default as SortColor } from "./components/SortColor";
43
44
  export { default as SortDescendingOrderColor } from "./components/SortDescendingOrderColor";
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12 5.25C12.4142 5.25 12.75 5.58579 12.75 6V11.25H18C18.4142 11.25 18.75 11.5858 18.75 12C18.75 12.4142 18.4142 12.75 18 12.75H12.75V18C12.75 18.4142 12.4142 18.75 12 18.75C11.5858 18.75 11.25 18.4142 11.25 18V12.75H6C5.58579 12.75 5.25 12.4142 5.25 12C5.25 11.5858 5.58579 11.25 6 11.25H11.25V6C11.25 5.58579 11.5858 5.25 12 5.25Z" fill="black"/>
3
+ </svg>
@@ -12,7 +12,6 @@ function List(props) {
12
12
  var _props$dataSource = props.dataSource,
13
13
  dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
14
14
  renderItem = props.renderItem,
15
- bordered = props.bordered,
16
15
  customizeSize = props.size,
17
16
  rowKey = props.rowKey,
18
17
  children = props.children,
@@ -60,9 +59,7 @@ function List(props) {
60
59
  return key;
61
60
  }
62
61
  var size = customizeSize || 'default';
63
- var customizeClassNames = classNames('ald-list', _defineProperty({
64
- 'ald-list-bordered': bordered
65
- }, "ald-list-".concat(size), size), className);
62
+ var customizeClassNames = classNames('ald-list', _defineProperty({}, "ald-list-".concat(size), size), className);
66
63
  if (virtual) {
67
64
  var renderInnerItem = function renderInnerItem(index) {
68
65
  if (!renderItem) return null;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { TNode } from './type';
3
+ interface IProps<T> {
4
+ value?: TNode<T>;
5
+ renderCondition: (data: T) => React.ReactNode;
6
+ backgroundColor?: string;
7
+ }
8
+ export default function DisplayLogicTree<T>({ value, renderCondition, backgroundColor, }: IProps<T>): React.JSX.Element | null;
9
+ export {};
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { DisplayLogicItem } from "./components/DisplayLogicItem";
3
+ export default function DisplayLogicTree(_ref) {
4
+ var value = _ref.value,
5
+ renderCondition = _ref.renderCondition,
6
+ backgroundColor = _ref.backgroundColor;
7
+ if (!value) return null;
8
+ return /*#__PURE__*/React.createElement(DisplayLogicItem, {
9
+ key: value.id,
10
+ value: value,
11
+ renderCondition: renderCondition,
12
+ backgroundColor: backgroundColor
13
+ });
14
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { TNode } from '../../type';
3
+ interface IProps<T> {
4
+ value: TNode<T>;
5
+ renderCondition: (value: T) => React.ReactNode;
6
+ backgroundColor?: string;
7
+ key: string;
8
+ }
9
+ export declare function DisplayLogicItem<T>({ value, renderCondition, backgroundColor, key, }: IProps<T>): React.JSX.Element | null;
10
+ export {};
@@ -0,0 +1,87 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ 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."); }
7
+ 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); }
8
+ 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; }
9
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import _ from 'lodash';
12
+ import React, { useContext, useState } from 'react';
13
+ import { LocaleContext, getTranslator } from "../../../locale/default";
14
+ import { ELogicType, ENodeType } from "../../type";
15
+ var TWO = 2;
16
+ export function DisplayLogicItem(_ref) {
17
+ var _logicTypeTextMap;
18
+ var value = _ref.value,
19
+ renderCondition = _ref.renderCondition,
20
+ backgroundColor = _ref.backgroundColor,
21
+ key = _ref.key;
22
+ var _useState = useState(0),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ firstNodeHight = _useState2[0],
25
+ setFirstNodeHight = _useState2[1];
26
+ var _useState3 = useState(0),
27
+ _useState4 = _slicedToArray(_useState3, 2),
28
+ lastNodeHight = _useState4[0],
29
+ setLastNodeHight = _useState4[1];
30
+ var _useContext = useContext(LocaleContext),
31
+ locale = _useContext.locale;
32
+ var t = getTranslator(locale);
33
+ var logicTypeTextMap = (_logicTypeTextMap = {}, _defineProperty(_logicTypeTextMap, ELogicType.AND, t.LogicTree.select.and), _defineProperty(_logicTypeTextMap, ELogicType.OR, t.LogicTree.select.or), _logicTypeTextMap);
34
+ var type = value.type;
35
+ var firstRefCallback = function firstRefCallback(e) {
36
+ if (e) {
37
+ setFirstNodeHight(e.clientHeight);
38
+ }
39
+ };
40
+ var lastRefCallback = function lastRefCallback(e) {
41
+ if (e) {
42
+ setLastNodeHight(e.clientHeight);
43
+ }
44
+ };
45
+ if (type === ENodeType.LOGIC) {
46
+ var nodes = value.nodes;
47
+ if (!_.size(nodes)) return null;
48
+ return /*#__PURE__*/React.createElement("div", {
49
+ className: "ald-logic-tree-display-logic-node"
50
+ }, _.map(nodes, function (node, index) {
51
+ var ref = null;
52
+ if (index === 0) {
53
+ ref = firstRefCallback;
54
+ } else if (index === nodes.length - 1) {
55
+ ref = lastRefCallback;
56
+ }
57
+ return /*#__PURE__*/React.createElement("div", {
58
+ className: "ald-logic-tree-node-wrap",
59
+ ref: ref,
60
+ key: key
61
+ }, /*#__PURE__*/React.createElement("div", {
62
+ className: "ald-logic-tree-horizontal-line"
63
+ }), /*#__PURE__*/React.createElement(DisplayLogicItem, {
64
+ key: node.id,
65
+ value: node,
66
+ renderCondition: renderCondition,
67
+ backgroundColor: backgroundColor
68
+ }));
69
+ }), /*#__PURE__*/React.createElement("div", {
70
+ className: "ald-logic-tree-logic-type",
71
+ style: {
72
+ backgroundColor: backgroundColor
73
+ }
74
+ }, logicTypeTextMap[value.logicType]), nodes.length > 1 && /*#__PURE__*/React.createElement("div", {
75
+ className: "ald-logic-tree-logic-vertical-line",
76
+ style: {
77
+ height: "calc(100% - ".concat(firstNodeHight / TWO, "px - ").concat(lastNodeHight / TWO, "px"),
78
+ top: "".concat(firstNodeHight / TWO, "px")
79
+ }
80
+ }));
81
+ }
82
+ return /*#__PURE__*/React.createElement("div", {
83
+ className: "ald-logic-tree-display-record-node"
84
+ }, /*#__PURE__*/React.createElement("div", {
85
+ className: "ald-logic-tree-render-condition-wrap"
86
+ }, renderCondition(value.data)));
87
+ }
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { TRenderCondition } from '../..';
3
+ import { ELogicType, TNode } from '../../type';
4
+ interface IProps<T> {
5
+ value: TNode<T>;
6
+ addCondition: (id: string) => void;
7
+ addRelation: (id: string) => void;
8
+ remove: (id: string) => void;
9
+ changeRecordData: (id: string, data: T) => void;
10
+ changeRelation: (id: string, logicType: ELogicType) => void;
11
+ renderCondition: TRenderCondition<T>;
12
+ }
13
+ export default function LogicItem<T>({ value, addCondition, addRelation, changeRecordData, remove, changeRelation, renderCondition, }: IProps<T>): React.JSX.Element;
14
+ export {};
@@ -0,0 +1,144 @@
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import _ from 'lodash';
8
+ import React, { useContext, useState } from 'react';
9
+ import PlusIcon from "../../../Icon/components/SignLightLine";
10
+ import CloseIcon from "../../../Icon/components/TimesLightLine";
11
+ import IconButton from "../../../IconButton";
12
+ import Select from "../../../Select";
13
+ import TextLink from "../../../TextLink";
14
+ import { LocaleContext, getTranslator } from "../../../locale/default";
15
+ import { ELogicType, ENodeType } from "../../type";
16
+ var TWO = 2;
17
+ export default function LogicItem(_ref) {
18
+ var value = _ref.value,
19
+ addCondition = _ref.addCondition,
20
+ addRelation = _ref.addRelation,
21
+ changeRecordData = _ref.changeRecordData,
22
+ remove = _ref.remove,
23
+ changeRelation = _ref.changeRelation,
24
+ renderCondition = _ref.renderCondition;
25
+ var _useState = useState(0),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ firstNodeHight = _useState2[0],
28
+ setFirstNodeHight = _useState2[1];
29
+ var _useState3 = useState(0),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ lastNodeHight = _useState4[0],
32
+ setLastNodeHight = _useState4[1];
33
+ var _useContext = useContext(LocaleContext),
34
+ locale = _useContext.locale;
35
+ var t = getTranslator(locale);
36
+ var logicOptions = [{
37
+ value: ELogicType.AND,
38
+ label: t.LogicTree.select.and
39
+ }, {
40
+ value: ELogicType.OR,
41
+ label: t.LogicTree.select.or
42
+ }];
43
+ var type = value.type;
44
+ var firstRefCallback = function firstRefCallback(e) {
45
+ if (e) {
46
+ setFirstNodeHight(e.clientHeight);
47
+ }
48
+ };
49
+ var lastRefCallback = function lastRefCallback(e) {
50
+ if (e) {
51
+ setLastNodeHight(e.clientHeight);
52
+ }
53
+ };
54
+ var onAddCondition = function onAddCondition() {
55
+ var id = value.id;
56
+ addCondition(id);
57
+ };
58
+ var onAddRelation = function onAddRelation() {
59
+ var id = value.id;
60
+ addRelation(id);
61
+ };
62
+ var onRemove = function onRemove() {
63
+ var id = value.id;
64
+ remove(id);
65
+ };
66
+ var onChangeRelation = function onChangeRelation(logicType) {
67
+ var id = value.id;
68
+ changeRelation(id, logicType);
69
+ };
70
+ var onChangeRecordData = function onChangeRecordData(data) {
71
+ var id = value.id;
72
+ changeRecordData(id, data);
73
+ };
74
+ if (type === ENodeType.LOGIC) {
75
+ var nodes = value.nodes,
76
+ _logicType = value.logicType;
77
+ var verticalLineHeight = nodes.length > 1 ? "calc(100% - ".concat(firstNodeHight / TWO, "px - ").concat(lastNodeHight / TWO, "px - 40px)") : "30px";
78
+ return /*#__PURE__*/React.createElement("div", {
79
+ className: "ald-logic-tree-logic-node"
80
+ }, _.map(nodes, function (node, index) {
81
+ var ref = null;
82
+ if (index === 0) {
83
+ ref = firstRefCallback;
84
+ } else if (index === nodes.length - 1) {
85
+ ref = lastRefCallback;
86
+ }
87
+ return /*#__PURE__*/React.createElement("div", {
88
+ className: "ald-logic-tree-node-wrap",
89
+ ref: ref,
90
+ key: node.id
91
+ }, /*#__PURE__*/React.createElement("div", {
92
+ className: "ald-logic-tree-horizontal-line"
93
+ }), /*#__PURE__*/React.createElement(LogicItem, {
94
+ key: node.id,
95
+ value: node,
96
+ addCondition: addCondition,
97
+ addRelation: addRelation,
98
+ remove: remove,
99
+ changeRelation: changeRelation,
100
+ renderCondition: renderCondition,
101
+ changeRecordData: changeRecordData
102
+ }));
103
+ }), /*#__PURE__*/React.createElement("div", {
104
+ className: "ald-logic-tree-operation"
105
+ }, /*#__PURE__*/React.createElement("div", {
106
+ className: "ald-logic-tree-left-bottom-dash-line"
107
+ }), /*#__PURE__*/React.createElement(TextLink, {
108
+ icon: /*#__PURE__*/React.createElement(PlusIcon, {
109
+ size: 24
110
+ }),
111
+ onClick: onAddCondition
112
+ }, t.LogicTree.btn.addCondition), /*#__PURE__*/React.createElement(TextLink, {
113
+ icon: /*#__PURE__*/React.createElement(PlusIcon, {
114
+ size: 24
115
+ }),
116
+ onClick: onAddRelation
117
+ }, t.LogicTree.btn.addRelation)), !!_.size(nodes) && /*#__PURE__*/React.createElement("div", {
118
+ className: "ald-logic-tree-logic-vertical-line",
119
+ style: {
120
+ height: verticalLineHeight,
121
+ top: "".concat(firstNodeHight / TWO, "px")
122
+ }
123
+ }), /*#__PURE__*/React.createElement(Select, {
124
+ options: logicOptions,
125
+ className: "ald-logic-tree-select-relation",
126
+ size: "small",
127
+ value: _logicType,
128
+ onChange: onChangeRelation,
129
+ disabled: nodes.length <= 1
130
+ }));
131
+ }
132
+ return /*#__PURE__*/React.createElement("div", {
133
+ className: "ald-logic-tree-record-node"
134
+ }, /*#__PURE__*/React.createElement("div", {
135
+ className: "ald-logic-tree-render-condition-wrap"
136
+ }, renderCondition(value.data, {
137
+ changeData: onChangeRecordData
138
+ })), /*#__PURE__*/React.createElement(IconButton, {
139
+ icon: /*#__PURE__*/React.createElement(CloseIcon, {
140
+ size: 24
141
+ }),
142
+ onClick: onRemove
143
+ }));
144
+ }
@@ -0,0 +1,8 @@
1
+ import { ELogicType, TNode } from './type';
2
+ export declare function addLogicNode<T>(nodeId: string, rootNode: TNode<T>, newInitializationData: T): TNode<T>;
3
+ export declare function addRecordNode<T>(nodeId: string, rootNode: TNode<T>, newInitializationData: T): TNode<T>;
4
+ export declare function removeNode<T>(nodeId: string, rootNode: TNode<T>, initialNode: TNode<T>, rootNodeAllowedEmpty?: boolean): TNode<T>;
5
+ export declare function changeRelation<T>(id: string, logicType: ELogicType, rootNode: TNode<T>): TNode<T>;
6
+ export declare function changeRecordData<T>(id: string, newData: T, rootNode: TNode<T>): TNode<T>;
7
+ export declare function getInitialLogicNode<T>(initialData: T[]): TNode<T>;
8
+ export declare function logicTreeIterator<T, U>(rootNode: TNode<T>, callback: (node: TNode<T>, acc: U[]) => U): U;
@@ -0,0 +1,183 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ 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); }
3
+ 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; }
4
+ import _ from 'lodash';
5
+ import { getUniqId } from "../_utils/getUniqId";
6
+ import { ELogicType, ENodeType } from "./type";
7
+
8
+ // 递归查找节点
9
+ function findNodeById(nodeId, currentNodes) {
10
+ if (nodeId === currentNodes.id) {
11
+ return currentNodes;
12
+ }
13
+ if (currentNodes.type === ENodeType.LOGIC) {
14
+ var childrenNodes = currentNodes.nodes;
15
+ var _iterator = _createForOfIteratorHelper(childrenNodes),
16
+ _step;
17
+ try {
18
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
19
+ var _node = _step.value;
20
+ var foundNode = findNodeById(nodeId, _node);
21
+ if (foundNode) {
22
+ return foundNode;
23
+ }
24
+ }
25
+ } catch (err) {
26
+ _iterator.e(err);
27
+ } finally {
28
+ _iterator.f();
29
+ }
30
+ }
31
+ return undefined;
32
+ }
33
+
34
+ // 递归查找父节点
35
+ function findParentNodeById(nodeId, currentNodes) {
36
+ if (currentNodes.type === ENodeType.LOGIC) {
37
+ var childrenNodes = currentNodes.nodes;
38
+ var _iterator2 = _createForOfIteratorHelper(childrenNodes),
39
+ _step2;
40
+ try {
41
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
42
+ var _node2 = _step2.value;
43
+ if (_node2.id === nodeId) {
44
+ return currentNodes;
45
+ }
46
+ var foundNode = findParentNodeById(nodeId, _node2);
47
+ if (foundNode) {
48
+ return foundNode;
49
+ }
50
+ }
51
+ } catch (err) {
52
+ _iterator2.e(err);
53
+ } finally {
54
+ _iterator2.f();
55
+ }
56
+ }
57
+ return undefined;
58
+ }
59
+
60
+ // 添加logic节点
61
+ export function addLogicNode(nodeId, rootNode, newInitializationData) {
62
+ var newRootNode = _.cloneDeep(rootNode);
63
+ var newNode = {
64
+ id: getUniqId(),
65
+ type: ENodeType.LOGIC,
66
+ logicType: ELogicType.AND,
67
+ nodes: [{
68
+ id: getUniqId(),
69
+ // 生成唯一 id
70
+ type: ENodeType.RECORD,
71
+ data: newInitializationData
72
+ }]
73
+ };
74
+ var parent = findNodeById(nodeId, newRootNode);
75
+ if (parent && parent.type === ENodeType.LOGIC) {
76
+ parent.nodes.push(newNode);
77
+ return newRootNode;
78
+ }
79
+ return rootNode;
80
+ }
81
+
82
+ // 添加record节点
83
+ export function addRecordNode(nodeId, rootNode, newInitializationData) {
84
+ var newRootNode = _.cloneDeep(rootNode);
85
+ var newNode = {
86
+ id: getUniqId(),
87
+ // 生成唯一 id
88
+ type: ENodeType.RECORD,
89
+ data: newInitializationData
90
+ };
91
+ var parent = findNodeById(nodeId, newRootNode);
92
+ if (parent && parent.type === ENodeType.LOGIC) {
93
+ parent.nodes.push(newNode);
94
+ return newRootNode;
95
+ }
96
+ return rootNode;
97
+ }
98
+
99
+ // 移除节点
100
+ export function removeNode(nodeId, rootNode, initialNode, rootNodeAllowedEmpty) {
101
+ var newRootNode = _.cloneDeep(rootNode);
102
+ var parent = findParentNodeById(nodeId, newRootNode);
103
+ if (parent) {
104
+ if (parent.nodes.length === 1) {
105
+ if (rootNodeAllowedEmpty && parent.id === rootNode.id) {
106
+ parent.nodes = [];
107
+ return newRootNode;
108
+ } else {
109
+ if (parent.id === rootNode.id) {
110
+ return initialNode;
111
+ }
112
+ }
113
+ var removeNodeId = nodeId;
114
+ do {
115
+ removeNodeId = parent.id;
116
+ parent = findParentNodeById(parent.id, newRootNode);
117
+ } while (parent && parent.id !== rootNode.id && parent.nodes.length === 1);
118
+ if (parent) {
119
+ parent.nodes.splice(parent.nodes.findIndex(function (node) {
120
+ return node.id === removeNodeId;
121
+ }), 1);
122
+ }
123
+ return newRootNode;
124
+ } else {
125
+ parent.nodes.splice(parent.nodes.findIndex(function (node) {
126
+ return node.id === nodeId;
127
+ }), 1);
128
+ return newRootNode;
129
+ }
130
+ }
131
+ return rootNode;
132
+ }
133
+
134
+ // 修改logic节点关系
135
+ export function changeRelation(id, logicType, rootNode) {
136
+ var newRootNode = _.cloneDeep(rootNode);
137
+ var node = findNodeById(id, newRootNode);
138
+ if (node && node.type === ENodeType.LOGIC) {
139
+ node.logicType = logicType;
140
+ return newRootNode;
141
+ }
142
+ return rootNode;
143
+ }
144
+
145
+ // 修改record节点数据
146
+ export function changeRecordData(id, newData, rootNode) {
147
+ var newRootNode = _.cloneDeep(rootNode);
148
+ var node = findNodeById(id, newRootNode);
149
+ if (node && node.type === ENodeType.RECORD) {
150
+ node.data = newData;
151
+ return newRootNode;
152
+ }
153
+ return rootNode;
154
+ }
155
+ export function getInitialLogicNode(initialData) {
156
+ return {
157
+ id: getUniqId(),
158
+ type: ENodeType.LOGIC,
159
+ logicType: ELogicType.AND,
160
+ nodes: initialData.map(function (item) {
161
+ return {
162
+ id: getUniqId(),
163
+ type: ENodeType.RECORD,
164
+ data: item
165
+ };
166
+ })
167
+ };
168
+ }
169
+
170
+ // 深度优先遍历
171
+ export function logicTreeIterator(rootNode, callback) {
172
+ if (rootNode.type === ENodeType.LOGIC) {
173
+ var nodes = rootNode.nodes;
174
+ var result = nodes.map(function (childNode) {
175
+ return logicTreeIterator(childNode, callback);
176
+ });
177
+ return callback(rootNode, result);
178
+ }
179
+ if (rootNode.type === ENodeType.RECORD) {
180
+ return callback(rootNode, []);
181
+ }
182
+ return callback(rootNode, []);
183
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import DisplayLogicTree from './DisplayLogicTree';
3
+ import { ELogicType, ENodeType, TNode } from './type';
4
+ export type { TNode };
5
+ export { DisplayLogicTree, ELogicType, ENodeType };
6
+ export type TRenderCondition<T> = (data: T, { changeData }: {
7
+ changeData: (data: T) => void;
8
+ }) => React.ReactNode;
9
+ interface IProps<T> {
10
+ newInitializationData: T;
11
+ onChange: (value: TNode<T>) => void;
12
+ value?: TNode<T>;
13
+ renderCondition: TRenderCondition<T>;
14
+ rootNodeAllowedEmpty?: boolean;
15
+ className?: string;
16
+ }
17
+ export default function LogicTree<T>(props: IProps<T>): React.JSX.Element | null;