@nokecy/qc-ui 0.4.7 → 0.5.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 (92) hide show
  1. package/dist/esm/ag-grid-plus/_utils/boolSelect.js +49 -0
  2. package/dist/esm/ag-grid-plus/ag-grid-theme-builder.css +404 -0
  3. package/dist/esm/ag-grid-plus/ag-gridPlus.js +472 -0
  4. package/dist/esm/ag-grid-plus/context/gridContext.js +6 -0
  5. package/dist/esm/ag-grid-plus/gridManager/index.js +35 -0
  6. package/dist/esm/ag-grid-plus/index.js +10 -0
  7. package/dist/esm/ag-grid-plus/index.less +7 -0
  8. package/dist/esm/ag-grid-plus/interface.js +9 -0
  9. package/dist/esm/ag-grid-plus/queryForm/index.js +175 -0
  10. package/dist/esm/ag-grid-plus/queryForm/index.less +48 -0
  11. package/dist/esm/ag-grid-plus/queryForm/queryForm.js +84 -0
  12. package/dist/esm/ag-grid-plus/setting/index.js +198 -0
  13. package/dist/esm/ag-grid-plus/settingItem/index.js +15 -0
  14. package/dist/esm/ag-grid-plus/toolBar/index.js +171 -0
  15. package/dist/esm/ag-grid-plus/utils.js +137 -0
  16. package/dist/esm/array-table/arrayAddBtn.js +56 -0
  17. package/dist/esm/array-table/arrayBase.js +217 -0
  18. package/dist/esm/array-table/index.js +145 -0
  19. package/dist/esm/array-table/interface.js +1 -0
  20. package/dist/esm/array-table/preview.js +49 -0
  21. package/dist/esm/array-table/utils.js +124 -0
  22. package/dist/esm/array-table-index/index.js +10 -0
  23. package/dist/esm/dashboard/dashboard/components/index.js +2 -0
  24. package/dist/esm/dashboard/dashboard/components/modal/index.js +15 -0
  25. package/dist/esm/dashboard/dashboard/components/toolbar/index.js +22 -0
  26. package/dist/esm/dashboard/dashboard/components/toolbar/style/index.js +1 -0
  27. package/dist/esm/dashboard/dashboard/components/toolbar/style/index.less +49 -0
  28. package/dist/esm/dashboard/dashboard/index.js +525 -0
  29. package/dist/esm/dashboard/dashboard/index.less +173 -0
  30. package/dist/esm/dashboard/dashboard/service.js +86 -0
  31. package/dist/esm/dashboard/dashboard/utils.js +89 -0
  32. package/dist/esm/dashboard/index.js +3 -0
  33. package/dist/esm/dashboard/utils.js +125 -0
  34. package/dist/esm/dashboard/widget/index.js +47 -0
  35. package/dist/esm/dashboard/widget/index.less +7 -0
  36. package/dist/esm/dashboard/widget/selector/index.js +234 -0
  37. package/dist/esm/dashboard/widget/selector/index.less +172 -0
  38. package/dist/esm/dashboard/widget/utils.js +89 -0
  39. package/dist/esm/dialogSelect/index.js +70 -0
  40. package/dist/esm/dialogSelect/interface.js +0 -0
  41. package/dist/esm/dialogSelect/selectModal.js +138 -0
  42. package/dist/esm/editable/index.js +241 -0
  43. package/dist/esm/editable/style.js +46 -0
  44. package/dist/esm/extensible-grid/index.js +22 -0
  45. package/dist/esm/extensible-grid/interface.js +1 -0
  46. package/dist/esm/formDesigner/FormDesigner.js +222 -0
  47. package/dist/esm/formDesigner/ProCard/index.js +21 -0
  48. package/dist/esm/formDesigner/arrayTable/arrayTableSchema.js +106 -0
  49. package/dist/esm/formDesigner/arrayTable/index.js +1 -0
  50. package/dist/esm/formDesigner/arrayTable/preview.js +390 -0
  51. package/dist/esm/formDesigner/arrayTable/styles.less +3 -0
  52. package/dist/esm/formDesigner/index.js +2 -0
  53. package/dist/esm/formDesigner/index.less +3 -0
  54. package/dist/esm/formDesigner/preWidgets/arrayTableIndex/index.js +1 -0
  55. package/dist/esm/formDesigner/preWidgets/arrayTableIndex/preview.js +40 -0
  56. package/dist/esm/formDesigner/preWidgets/card/index.js +1 -0
  57. package/dist/esm/formDesigner/preWidgets/card/preview.js +38 -0
  58. package/dist/esm/formDesigner/preWidgets/index.js +12 -0
  59. package/dist/esm/formDesigner/preWidgets/preDefineProperty1/index.js +1 -0
  60. package/dist/esm/formDesigner/preWidgets/preDefineProperty1/preview.js +44 -0
  61. package/dist/esm/formDesigner/preWidgets/preDefineProperty10/index.js +1 -0
  62. package/dist/esm/formDesigner/preWidgets/preDefineProperty10/preview.js +43 -0
  63. package/dist/esm/formDesigner/preWidgets/preDefineProperty2/index.js +1 -0
  64. package/dist/esm/formDesigner/preWidgets/preDefineProperty2/preview.js +43 -0
  65. package/dist/esm/formDesigner/preWidgets/preDefineProperty3/index.js +1 -0
  66. package/dist/esm/formDesigner/preWidgets/preDefineProperty3/preview.js +43 -0
  67. package/dist/esm/formDesigner/preWidgets/preDefineProperty4/index.js +1 -0
  68. package/dist/esm/formDesigner/preWidgets/preDefineProperty4/preview.js +43 -0
  69. package/dist/esm/formDesigner/preWidgets/preDefineProperty5/index.js +1 -0
  70. package/dist/esm/formDesigner/preWidgets/preDefineProperty5/preview.js +43 -0
  71. package/dist/esm/formDesigner/preWidgets/preDefineProperty6/index.js +1 -0
  72. package/dist/esm/formDesigner/preWidgets/preDefineProperty6/preview.js +43 -0
  73. package/dist/esm/formDesigner/preWidgets/preDefineProperty7/index.js +1 -0
  74. package/dist/esm/formDesigner/preWidgets/preDefineProperty7/preview.js +43 -0
  75. package/dist/esm/formDesigner/preWidgets/preDefineProperty8/index.js +1 -0
  76. package/dist/esm/formDesigner/preWidgets/preDefineProperty8/preview.js +43 -0
  77. package/dist/esm/formDesigner/preWidgets/preDefineProperty9/index.js +1 -0
  78. package/dist/esm/formDesigner/preWidgets/preDefineProperty9/preview.js +43 -0
  79. package/dist/esm/formDesigner/preWidgets/utils.js +219 -0
  80. package/dist/esm/formDesigner/widgets/ActionsWidget.js +29 -0
  81. package/dist/esm/formDesigner/widgets/LogoWidget.js +24 -0
  82. package/dist/esm/formDesigner/widgets/PreviewWidget.js +33 -0
  83. package/dist/esm/formDesigner/widgets/SchemaEditorWidget.js +17 -0
  84. package/dist/esm/formDesigner/widgets/index.js +4 -0
  85. package/dist/esm/formPro/context/formProContext.js +5 -0
  86. package/dist/esm/formPro/formLayoutPro.js +41 -0
  87. package/dist/esm/formPro/index.js +2 -0
  88. package/dist/esm/index.js +12 -0
  89. package/dist/esm/type.d.ts +1 -0
  90. package/dist/umd/qc-ui.min.css +1 -0
  91. package/dist/umd/qc-ui.min.js +1 -0
  92. package/package.json +2 -2
@@ -0,0 +1,171 @@
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(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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(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); }
7
+ import { LabelIconTip } from '@ant-design/pro-utils';
8
+ import { ConfigProvider, Tooltip } from 'antd';
9
+ import classNames from 'classnames';
10
+ import React, { useContext, useMemo } from 'react';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ /**
14
+ * 获取配置区域 DOM Item
15
+ *
16
+ * @param setting 配置项
17
+ */
18
+ function getSettingItem(setting) {
19
+ if ( /*#__PURE__*/React.isValidElement(setting)) {
20
+ return setting;
21
+ }
22
+ if (setting) {
23
+ var settingConfig = setting;
24
+ var icon = settingConfig.icon,
25
+ tooltip = settingConfig.tooltip,
26
+ _onClick = settingConfig.onClick,
27
+ key = settingConfig.key;
28
+ if (icon && tooltip) {
29
+ return /*#__PURE__*/_jsx(Tooltip, {
30
+ title: tooltip,
31
+ children: /*#__PURE__*/_jsx("span", {
32
+ onClick: function onClick() {
33
+ if (_onClick) {
34
+ _onClick(key);
35
+ }
36
+ },
37
+ children: icon
38
+ }, key)
39
+ });
40
+ }
41
+ return icon;
42
+ }
43
+ return null;
44
+ }
45
+ var ListToolBar = function ListToolBar(_ref) {
46
+ var customizePrefixCls = _ref.prefixCls,
47
+ title = _ref.title,
48
+ subTitle = _ref.subTitle,
49
+ tooltip = _ref.tooltip,
50
+ className = _ref.className,
51
+ style = _ref.style,
52
+ _ref$actions = _ref.actions,
53
+ actions = _ref$actions === void 0 ? [] : _ref$actions,
54
+ _ref$settings = _ref.settings,
55
+ settings = _ref$settings === void 0 ? [] : _ref$settings;
56
+ var _useContext = useContext(ConfigProvider.ConfigContext),
57
+ getPrefixCls = _useContext.getPrefixCls;
58
+ var prefixCls = getPrefixCls('pro-table-list-toolbar', customizePrefixCls);
59
+ var hashId = "useStyle(prefixCls)";
60
+
61
+ /** 有没有 title,需要结合多个场景判断 */
62
+ var hasTitle = useMemo(function () {
63
+ return title || subTitle || tooltip;
64
+ }, [subTitle, title, tooltip]);
65
+
66
+ /** 没有 key 的时候帮忙加一下 key 不加的话很烦人 */
67
+ var actionDom = useMemo(function () {
68
+ if (!Array.isArray(actions)) {
69
+ return actions;
70
+ }
71
+ if (actions.length < 1) {
72
+ return null;
73
+ }
74
+ return /*#__PURE__*/_jsx("div", {
75
+ style: {
76
+ display: 'flex',
77
+ alignItems: 'center',
78
+ gap: 8
79
+ },
80
+ children: actions.map(function (action, index) {
81
+ if (! /*#__PURE__*/React.isValidElement(action)) {
82
+ // eslint-disable-next-line react/no-array-index-key
83
+ return /*#__PURE__*/_jsx(React.Fragment, {
84
+ children: action
85
+ }, index);
86
+ }
87
+ return /*#__PURE__*/React.cloneElement(action, _objectSpread({
88
+ // eslint-disable-next-line react/no-array-index-key
89
+ key: index
90
+ }, action === null || action === void 0 ? void 0 : action.props));
91
+ })
92
+ });
93
+ }, [actions]);
94
+ var hasRight = useMemo(function () {
95
+ return hasTitle || actionDom || (settings === null || settings === void 0 ? void 0 : settings.length);
96
+ }, [actionDom, hasTitle, settings === null || settings === void 0 ? void 0 : settings.length]);
97
+ var hasLeft = useMemo(function () {
98
+ return tooltip || title || subTitle;
99
+ }, [hasTitle, subTitle, title, tooltip]);
100
+ var leftTitleDom = useMemo(function () {
101
+ // 保留dom是为了占位,不然 right 就变到左边了
102
+ if (!hasLeft && hasRight) {
103
+ return /*#__PURE__*/_jsx("div", {
104
+ className: "".concat(prefixCls, "-left ").concat(hashId)
105
+ });
106
+ }
107
+
108
+ // 减少 space 的dom,渲染的时候能节省点性能
109
+ if (hasTitle) {
110
+ return /*#__PURE__*/_jsx("div", {
111
+ className: "".concat(prefixCls, "-left ").concat(hashId),
112
+ children: /*#__PURE__*/_jsx("div", {
113
+ className: "".concat(prefixCls, "-title ").concat(hashId),
114
+ children: /*#__PURE__*/_jsx(LabelIconTip, {
115
+ tooltip: tooltip,
116
+ label: title,
117
+ subTitle: subTitle
118
+ })
119
+ })
120
+ });
121
+ }
122
+ return /*#__PURE__*/_jsx("div", {
123
+ className: "".concat(prefixCls, "-left ").concat(hashId),
124
+ children: hasTitle && /*#__PURE__*/_jsx("div", {
125
+ className: "".concat(prefixCls, "-title ").concat(hashId),
126
+ children: /*#__PURE__*/_jsx(LabelIconTip, {
127
+ tooltip: tooltip,
128
+ label: title,
129
+ subTitle: subTitle
130
+ })
131
+ })
132
+ });
133
+ }, [hasLeft, hasRight, hasTitle, hashId, prefixCls, subTitle, title, tooltip]);
134
+ var rightTitleDom = useMemo(function () {
135
+ if (!hasRight) return null;
136
+ return /*#__PURE__*/_jsxs("div", {
137
+ className: "".concat(prefixCls, "-right ").concat(hashId),
138
+ style: {
139
+ alignItems: 'center'
140
+ },
141
+ children: [actionDom, settings !== null && settings !== void 0 && settings.length ? /*#__PURE__*/_jsx("div", {
142
+ className: "".concat(prefixCls, "-setting-items ").concat(hashId),
143
+ children: settings.map(function (setting, index) {
144
+ var settingItem = getSettingItem(setting);
145
+ return (
146
+ /*#__PURE__*/
147
+ // eslint-disable-next-line react/no-array-index-key
148
+ _jsx("div", {
149
+ className: "".concat(prefixCls, "-setting-item ").concat(hashId),
150
+ children: settingItem
151
+ }, index)
152
+ );
153
+ })
154
+ }) : null]
155
+ });
156
+ }, [hasRight, prefixCls, hashId, hasTitle, actionDom, settings]);
157
+ var titleNode = useMemo(function () {
158
+ if (!hasRight && !hasLeft) return null;
159
+ var containerClassName = classNames("".concat(prefixCls, "-container"), hashId, {});
160
+ return /*#__PURE__*/_jsxs("div", {
161
+ className: containerClassName,
162
+ children: [leftTitleDom, rightTitleDom]
163
+ });
164
+ }, [hasLeft, hasRight, hashId, leftTitleDom, prefixCls, rightTitleDom]);
165
+ return /*#__PURE__*/_jsx("div", {
166
+ style: style,
167
+ className: classNames(prefixCls, hashId, className),
168
+ children: titleNode
169
+ });
170
+ };
171
+ export default ListToolBar;
@@ -0,0 +1,137 @@
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
+ import _cloneDeep from "lodash/cloneDeep";
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ 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); }
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
+ 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; }
14
+ import dayjs from 'dayjs';
15
+ var esc = function esc(v) {
16
+ return v.replace(/([(),|,\\]|\/i)/g, '\\$1');
17
+ };
18
+ var getFilter = function getFilter(objectKey, value) {
19
+ if (typeof value === 'string') {
20
+ return value && value != "" ? "".concat(objectKey, " ^ ").concat(esc(value)) : "";
21
+ }
22
+ if (typeof value === 'number') {
23
+ return "".concat(objectKey, " = ").concat(value);
24
+ }
25
+ if (typeof value === 'boolean') {
26
+ return "".concat(objectKey, " = ").concat(value);
27
+ }
28
+ if (value instanceof Array) {
29
+ return "".concat(objectKey, " >= ").concat(dayjs(value[0]).format("YYYY-MM-DD"), " ,") + "".concat(objectKey, " <= ").concat(dayjs(value[1]).add(1, 'days').format("YYYY-MM-DD"));
30
+ }
31
+ var items = [];
32
+ getObjectFilter(value, objectKey, items);
33
+ return items.join(",");
34
+ };
35
+ var getObjectFilter = function getObjectFilter(obj, objKey, items) {
36
+ Object.keys(obj).map(function (key) {
37
+ var value = obj[key];
38
+ var objectKey = "".concat(objKey, ".").concat(key);
39
+ if (typeof value === 'number') {
40
+ items.push("".concat(objectKey, " = ").concat(value));
41
+ }
42
+ if (typeof value === 'string') {
43
+ value && value != "" && items.push("".concat(objectKey, " ^ ").concat(esc(value)));
44
+ }
45
+ if (typeof value === 'boolean') {
46
+ items.push("".concat(objectKey, " = ").concat(value));
47
+ }
48
+ if (value instanceof Array) {
49
+ items.push("".concat(objectKey, " >= ").concat(dayjs(value[0]).format("YYYY-MM-DD"), " ,") + "".concat(objectKey, " <= ").concat(dayjs(value[1]).add(1, 'days').format("YYYY-MM-DD")));
50
+ }
51
+ if (value instanceof Object) items.push(getObjectFilter(value, "".concat(objKey, ".").concat(key), items));
52
+ });
53
+ };
54
+ var convertFilterModel = function convertFilterModel(filterModel) {
55
+ var items = [];
56
+ Object.keys(filterModel).map(function (key) {
57
+ var value = filterModel[key];
58
+ if (value !== undefined && value !== null && value !== "") {
59
+ var filter = getFilter(key, value);
60
+ if (filter && filter != "") {
61
+ items.push(filter);
62
+ }
63
+ }
64
+ });
65
+ return items.join(",");
66
+ };
67
+ var convertSortModel = function convertSortModel(sortModel) {
68
+ var sorter = sortModel.map(function (sort) {
69
+ var key = sort.colId;
70
+ var value = sort.sort;
71
+ return "".concat(key.replace(',', '.'), " ").concat(value == 'desc' ? 'desc' : 'asc');
72
+ }).join(' , ');
73
+ return sorter;
74
+ };
75
+ var dateValueFormatter = function dateValueFormatter(params) {
76
+ return params.value ? dayjs(params.value).format("YYYY-MM-DD") : "";
77
+ };
78
+ var dateTimeValueFormatter = function dateTimeValueFormatter(params) {
79
+ return params.value ? dayjs(params.value).format("YYYY-MM-DD HH:mm:ss") : "";
80
+ };
81
+
82
+ //@ts-ignore
83
+ var flatten = function flatten(arr, keyName, parentref) {
84
+ var data = arr ? arr.reduce(function (result, item) {
85
+ return [].concat(_toConsumableArray(result), [_objectSpread(_objectSpread({}, item), {}, {
86
+ children: undefined,
87
+ hierarchy: parentref ? [].concat(_toConsumableArray(parentref), [item[keyName]]) : [item[keyName]]
88
+ })], _toConsumableArray(flatten(item.children, keyName, parentref ? [].concat(_toConsumableArray(parentref), [item[keyName]]) : [item[keyName]])));
89
+ }, []) : [];
90
+ return data;
91
+ };
92
+ var toTree = function toTree(data, keyName, parentKeyName) {
93
+ // 删除 所有 children,以防止多次调用
94
+ data.forEach(function (item) {
95
+ delete item.children;
96
+ });
97
+
98
+ // 将数据存储为 以 id 为 KEY 的 map 索引数据列
99
+ var map = {};
100
+ data.forEach(function (item) {
101
+ map[item[keyName]] = item;
102
+ });
103
+ var val = [];
104
+ data.forEach(function (item) {
105
+ // 以当前遍历项,的pid,去map对象中找到索引的id
106
+ var parent = map[item[parentKeyName]];
107
+ // 好绕啊,如果找到索引,那么说明此项不在顶级当中,那么需要把此项添加到,他对应的父级中
108
+ if (parent) {
109
+ (parent.children || (parent.children = [])).push(item);
110
+ } else {
111
+ //如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中,作为顶级
112
+ val.push(item);
113
+ }
114
+ });
115
+ return val;
116
+ };
117
+ var flattenTreeDeep = function flattenTreeDeep(treeData) {
118
+ var childrenName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'childrens';
119
+ var flattenData = function flattenData(treeData, res, parentId) {
120
+ var childrenName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'childrens';
121
+ treeData.forEach(function (item) {
122
+ res.push(_objectSpread(_objectSpread({}, item), {}, {
123
+ parentId: parentId
124
+ }));
125
+ if (item[childrenName] && item[childrenName].length !== 0) {
126
+ flattenData(item[childrenName], res, item.id, childrenName);
127
+ }
128
+ delete item[childrenName];
129
+ });
130
+ return res;
131
+ };
132
+ var data = _cloneDeep(treeData);
133
+ var res = [];
134
+ flattenData(data, res, null, childrenName);
135
+ return res;
136
+ };
137
+ export { dateValueFormatter, dateTimeValueFormatter, convertFilterModel, convertSortModel, flattenTreeDeep, toTree, flatten };
@@ -0,0 +1,56 @@
1
+ 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); }
2
+ import React from "react";
3
+ import { useField } from "@formily/react";
4
+ import { Button } from "antd";
5
+ import { usePrefixCls } from "@formily/antd-v5/lib/__builtins__";
6
+ import cls from 'classnames';
7
+ import { PlusOutlined } from "@ant-design/icons";
8
+ import { isValid, clone, isUndef } from '@formily/shared';
9
+ var getSchemaDefaultValue = function getSchemaDefaultValue(schema) {
10
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array') return [];
11
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object') return {};
12
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'void') {
13
+ for (var key in schema.properties) {
14
+ var value = getSchemaDefaultValue(schema.properties[key]);
15
+ if (isValid(value)) return value;
16
+ }
17
+ }
18
+ };
19
+ var getDefaultValue = function getDefaultValue(defaultValue, schema) {
20
+ if (isValid(defaultValue)) return clone(defaultValue);
21
+ if (Array.isArray(schema === null || schema === void 0 ? void 0 : schema.items)) return getSchemaDefaultValue(schema === null || schema === void 0 ? void 0 : schema.items[0]);
22
+ return getSchemaDefaultValue(schema === null || schema === void 0 ? void 0 : schema.items);
23
+ };
24
+ var ArrayAddBtn = function ArrayAddBtn(props) {
25
+ var self = useField();
26
+ var arrayField = props.arrayField,
27
+ schema = props.schema;
28
+ var prefixCls = usePrefixCls("formily-array-base");
29
+ if (!arrayField) return null;
30
+ if (arrayField.pattern !== "editable" && arrayField.pattern !== "disabled") return null;
31
+ return /*#__PURE__*/React.createElement(Button, _extends({
32
+ type: "primary"
33
+ }, props, {
34
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
35
+ className: cls("".concat(prefixCls, "-addition"), props.className),
36
+ onClick: function onClick(e) {
37
+ if (arrayField !== null && arrayField !== void 0 && arrayField.disabled) return;
38
+ var defaultValue = getDefaultValue(props.defaultValue, schema);
39
+ if (props.method === "unshift") {
40
+ var _arrayField$unshift, _props$onAdd;
41
+ (_arrayField$unshift = arrayField.unshift) === null || _arrayField$unshift === void 0 || _arrayField$unshift.call(arrayField, defaultValue);
42
+ props === null || props === void 0 || (_props$onAdd = props.onAdd) === null || _props$onAdd === void 0 || _props$onAdd.call(props, 0);
43
+ } else {
44
+ var _arrayField$push, _props$onAdd2, _arrayField$value;
45
+ (_arrayField$push = arrayField.push) === null || _arrayField$push === void 0 || _arrayField$push.call(arrayField, defaultValue);
46
+ props === null || props === void 0 || (_props$onAdd2 = props.onAdd) === null || _props$onAdd2 === void 0 || _props$onAdd2.call(props, (arrayField === null || arrayField === void 0 || (_arrayField$value = arrayField.value) === null || _arrayField$value === void 0 ? void 0 : _arrayField$value.length) - 1);
47
+ }
48
+ if (props.onClick) {
49
+ //@ts-ignore
50
+ props.onClick(e);
51
+ }
52
+ },
53
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(PlusOutlined, null) : props.icon
54
+ }), props.title || self.title);
55
+ };
56
+ export default ArrayAddBtn;
@@ -0,0 +1,217 @@
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
+ var _excluded = ["children"];
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ 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); }
9
+ 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; }
10
+ 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; }
11
+ import React, { createContext, useContext } from 'react';
12
+ import { Button } from 'antd';
13
+ import { DeleteOutlined, DownOutlined, UpOutlined, CopyOutlined } from '@ant-design/icons';
14
+ import { useField, useFieldSchema } from '@formily/react';
15
+ import { clone, isUndef } from '@formily/shared';
16
+ import { usePrefixCls } from '@formily/antd-v5/lib/__builtins__';
17
+ import cls from 'classnames';
18
+ import uniqueId from 'lodash/uniqueId';
19
+ var ArrayBaseContext = /*#__PURE__*/createContext(undefined);
20
+ var ItemContext = /*#__PURE__*/createContext(undefined);
21
+ var takeRecord = function takeRecord(val, index) {
22
+ return typeof val === 'function' ? val(index) : val;
23
+ };
24
+ var useArray = function useArray() {
25
+ return useContext(ArrayBaseContext);
26
+ };
27
+ var useIndex = function useIndex(index) {
28
+ var ctx = useContext(ItemContext);
29
+ return ctx ? ctx.index : index || 0;
30
+ };
31
+ var useRecord = function useRecord(record) {
32
+ var ctx = useContext(ItemContext);
33
+ return takeRecord(ctx ? ctx.record : record, ctx === null || ctx === void 0 ? void 0 : ctx.index);
34
+ };
35
+ export var ArrayBase = function ArrayBase(props) {
36
+ var field = useField();
37
+ var schema = useFieldSchema();
38
+ return /*#__PURE__*/React.createElement(ArrayBaseContext.Provider, {
39
+ value: {
40
+ field: field,
41
+ schema: schema,
42
+ props: props
43
+ }
44
+ }, props.children);
45
+ };
46
+ ArrayBase.Item = function (_ref) {
47
+ var children = _ref.children,
48
+ props = _objectWithoutProperties(_ref, _excluded);
49
+ return /*#__PURE__*/React.createElement(ItemContext.Provider, {
50
+ value: props
51
+ }, children);
52
+ };
53
+ ArrayBase.Index = function (props) {
54
+ var index = useIndex();
55
+ var prefixCls = usePrefixCls('formily-array-base');
56
+ return /*#__PURE__*/React.createElement("span", _extends({}, props, {
57
+ className: "".concat(prefixCls, "-index")
58
+ }), "#", (index ? index : 0) + 1, ".");
59
+ };
60
+
61
+ //@ts-ignore
62
+ ArrayBase.Copy = /*#__PURE__*/React.forwardRef(function (props, ref) {
63
+ var _array$field;
64
+ var self = useField();
65
+ var array = useArray();
66
+ var index = useIndex(props.index);
67
+ var prefixCls = usePrefixCls('formily-array-base');
68
+ if (!array) return null;
69
+ if (((_array$field = array.field) === null || _array$field === void 0 ? void 0 : _array$field.pattern) !== 'editable') return null;
70
+ return /*#__PURE__*/React.createElement(Button, _extends({
71
+ type: "text"
72
+ }, props, {
73
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
74
+ className: cls("".concat(prefixCls, "-copy"), self !== null && self !== void 0 && self.disabled ? "".concat(prefixCls, "-copy-disabled") : '', props.className)
75
+
76
+ //@ts-ignore
77
+ ,
78
+ ref: ref,
79
+ onClick: function onClick(e) {
80
+ var _array$props, _array$field2, _array$field3, _array$field3$insert, _array$props2, _array$props2$onCopy;
81
+ if (self !== null && self !== void 0 && self.disabled) return;
82
+ e.stopPropagation();
83
+ if ((_array$props = array.props) !== null && _array$props !== void 0 && _array$props.disabled) return;
84
+ var value = clone(array === null || array === void 0 || (_array$field2 = array.field) === null || _array$field2 === void 0 ? void 0 : _array$field2.value[index]);
85
+ var distIndex = index + 1;
86
+ (_array$field3 = array.field) === null || _array$field3 === void 0 || (_array$field3$insert = _array$field3.insert) === null || _array$field3$insert === void 0 || _array$field3$insert.call(_array$field3, distIndex, _objectSpread(_objectSpread({}, value), {}, {
87
+ id: undefined,
88
+ _id: uniqueId(),
89
+ _isNew: true
90
+ }));
91
+ (_array$props2 = array.props) === null || _array$props2 === void 0 || (_array$props2$onCopy = _array$props2.onCopy) === null || _array$props2$onCopy === void 0 || _array$props2$onCopy.call(_array$props2, distIndex);
92
+ if (props.onClick) {
93
+ //@ts-ignore
94
+ props.onClick(e);
95
+ }
96
+ },
97
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(CopyOutlined, null) : props.icon
98
+ }), props.title || self.title);
99
+ });
100
+
101
+ //@ts-ignore
102
+ ArrayBase.Remove = /*#__PURE__*/React.forwardRef(function (props, ref) {
103
+ var _array$field4;
104
+ var index = useIndex(props.index);
105
+ var self = useField();
106
+ var array = useArray();
107
+ var prefixCls = usePrefixCls('formily-array-base');
108
+ if (!array) return null;
109
+ if (((_array$field4 = array.field) === null || _array$field4 === void 0 ? void 0 : _array$field4.pattern) !== 'editable') return null;
110
+ return /*#__PURE__*/React.createElement(Button, _extends({
111
+ type: "text"
112
+ }, props, {
113
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
114
+ className: cls("".concat(prefixCls, "-remove"), self !== null && self !== void 0 && self.disabled ? "".concat(prefixCls, "-remove-disabled") : '', props.className)
115
+
116
+ //@ts-ignore
117
+ ,
118
+ ref: ref,
119
+ onClick: function onClick(e) {
120
+ var _array$field5, _array$field5$remove, _array$props3, _array$props3$onRemov;
121
+ if (self !== null && self !== void 0 && self.disabled) return;
122
+ e.stopPropagation();
123
+ (_array$field5 = array.field) === null || _array$field5 === void 0 || (_array$field5$remove = _array$field5.remove) === null || _array$field5$remove === void 0 || _array$field5$remove.call(_array$field5, index);
124
+ (_array$props3 = array.props) === null || _array$props3 === void 0 || (_array$props3$onRemov = _array$props3.onRemove) === null || _array$props3$onRemov === void 0 || _array$props3$onRemov.call(_array$props3, index);
125
+ if (props.onClick) {
126
+ //@ts-ignore
127
+ props.onClick(e);
128
+ }
129
+ },
130
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(DeleteOutlined, null) : props.icon
131
+ }), props.title || self.title);
132
+ });
133
+
134
+ //@ts-ignore
135
+ ArrayBase.MoveDown = /*#__PURE__*/React.forwardRef(function (props, ref) {
136
+ var _array$field6;
137
+ var index = useIndex(props.index);
138
+ var self = useField();
139
+ var array = useArray();
140
+ var prefixCls = usePrefixCls('formily-array-base');
141
+ if (!array) return null;
142
+ if (((_array$field6 = array.field) === null || _array$field6 === void 0 ? void 0 : _array$field6.pattern) !== 'editable') return null;
143
+ return /*#__PURE__*/React.createElement(Button, _extends({
144
+ type: "text"
145
+ }, props, {
146
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
147
+ className: cls("".concat(prefixCls, "-move-down"), self !== null && self !== void 0 && self.disabled ? "".concat(prefixCls, "-move-down-disabled") : '', props.className)
148
+
149
+ //@ts-ignore
150
+ ,
151
+ ref: ref,
152
+ onClick: function onClick(e) {
153
+ var _array$field7, _array$field7$moveDow, _array$props4, _array$props4$onMoveD;
154
+ if (self !== null && self !== void 0 && self.disabled) return;
155
+ e.stopPropagation();
156
+ (_array$field7 = array.field) === null || _array$field7 === void 0 || (_array$field7$moveDow = _array$field7.moveDown) === null || _array$field7$moveDow === void 0 || _array$field7$moveDow.call(_array$field7, index);
157
+ (_array$props4 = array.props) === null || _array$props4 === void 0 || (_array$props4$onMoveD = _array$props4.onMoveDown) === null || _array$props4$onMoveD === void 0 || _array$props4$onMoveD.call(_array$props4, index);
158
+ if (props.onClick) {
159
+ //@ts-ignore
160
+ props.onClick(e);
161
+ }
162
+ },
163
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(DownOutlined, null) : props.icon
164
+ }), props.title || self.title);
165
+ });
166
+
167
+ //@ts-ignore
168
+ ArrayBase.MoveUp = /*#__PURE__*/React.forwardRef(function (props, ref) {
169
+ var _array$field8;
170
+ var index = useIndex(props.index);
171
+ var self = useField();
172
+ var array = useArray();
173
+ var prefixCls = usePrefixCls('formily-array-base');
174
+ if (!array) return null;
175
+ if (((_array$field8 = array.field) === null || _array$field8 === void 0 ? void 0 : _array$field8.pattern) !== 'editable') return null;
176
+ return /*#__PURE__*/React.createElement(Button, _extends({
177
+ type: "text"
178
+ }, props, {
179
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
180
+ className: cls("".concat(prefixCls, "-move-up"), self !== null && self !== void 0 && self.disabled ? "".concat(prefixCls, "-move-up-disabled") : '', props.className)
181
+
182
+ //@ts-ignore
183
+ ,
184
+ ref: ref,
185
+ onClick: function onClick(e) {
186
+ var _array$field9, _array$props5, _array$props5$onMoveU;
187
+ if (self !== null && self !== void 0 && self.disabled) return;
188
+ e.stopPropagation();
189
+ array === null || array === void 0 || (_array$field9 = array.field) === null || _array$field9 === void 0 || _array$field9.moveUp(index);
190
+ array === null || array === void 0 || (_array$props5 = array.props) === null || _array$props5 === void 0 || (_array$props5$onMoveU = _array$props5.onMoveUp) === null || _array$props5$onMoveU === void 0 || _array$props5$onMoveU.call(_array$props5, index);
191
+ if (props.onClick) {
192
+ //@ts-ignore
193
+ props.onClick(e);
194
+ }
195
+ },
196
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(UpOutlined, null) : props.icon
197
+ }), props.title || self.title);
198
+ });
199
+
200
+ //@ts-ignore
201
+ ArrayBase.useArray = useArray;
202
+ ArrayBase.useIndex = useIndex;
203
+ ArrayBase.useRecord = useRecord;
204
+ ArrayBase.mixin = function (target) {
205
+ target.Index = ArrayBase.Index;
206
+ target.SortHandle = ArrayBase.SortHandle;
207
+ target.Addition = ArrayBase.Addition;
208
+ target.Copy = ArrayBase.Copy;
209
+ target.Remove = ArrayBase.Remove;
210
+ target.MoveDown = ArrayBase.MoveDown;
211
+ target.MoveUp = ArrayBase.MoveUp;
212
+ target.useArray = ArrayBase.useArray;
213
+ target.useIndex = ArrayBase.useIndex;
214
+ target.useRecord = ArrayBase.useRecord;
215
+ return target;
216
+ };
217
+ export default ArrayBase;