Commit 3bc50ca7ad3a95a8dfb418f5183eefbcba70f512

Authored by 邢晴晴
1 parent ccb0a6b1

feat:XQ230328006 批量操作也需要

Too many changes to show.

To preserve performance only 26 of 102 files are displayed.

... ... @@ -2,54 +2,37 @@ import _PlusCircleFilled from "@ant-design/icons/es/icons/PlusCircleFilled";
2 2 import _DownOutlined from "@ant-design/icons/es/icons/DownOutlined";
3 3 import _UpOutlined from "@ant-design/icons/es/icons/UpOutlined";
4 4 import _DeleteOutlined from "@ant-design/icons/es/icons/DeleteOutlined";
5   -
6 5 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7   -
8 6 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."); }
9   -
10 7 function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11   -
12 8 function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13   -
14 9 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15   -
16 10 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."); }
17   -
18 11 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); }
19   -
20   -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; }
21   -
22   -function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
23   -
  12 +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; }
  13 +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; } }
24 14 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25   -
26 15 /* eslint-disable jsx-a11y/anchor-is-valid */
27 16 import React, { useEffect, useMemo, useState } from 'react';
28   -import Core from '../../index'; // import { Button, Space, Popconfirm } from 'antd';
  17 +import Core from '../../index';
  18 +// import { Button, Space, Popconfirm } from 'antd';
29 19 // import ArrowDown from '../../../components/ArrowDown';
30   -
31 20 import { Collapse } from 'antd-mobile';
32   -
33 21 // 数字转汉字
34 22 function convertToChinaNum(num) {
35 23 var arr1 = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
36 24 var arr2 = ['', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿']; //可继续追加更高位转换值
37   -
38 25 if (!num || isNaN(num)) {
39 26 return "零";
40 27 }
41   -
42 28 var english = num.toString().split("");
43 29 var result = "";
44   -
45 30 for (var i = 0; i < english.length; i++) {
46 31 var des_i = english.length - 1 - i; //倒序排列设值
47   -
48 32 result = arr2[i] + result;
49 33 var arr1_index = english[des_i];
50 34 result = arr1[arr1_index] + result;
51 35 }
52   -
53 36 result = result.replace(/零(千|百|十)/g, '零').replace(/十零/g, '十');
54 37 result = result.replace(/零+/g, '零');
55 38 result = result.replace(/零亿/g, '亿').replace(/零万/g, '万');
... ... @@ -58,36 +41,36 @@ function convertToChinaNum(num) {
58 41 result = result.replace(/^一十/g, '十');
59 42 return result;
60 43 }
61   -
62 44 var ListForMobile = function ListForMobile(_ref) {
63 45 var _ref$displayList = _ref.displayList,
64   - displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
65   - listData = _ref.listData,
66   - changeList = _ref.changeList,
67   - schema = _ref.schema,
68   - deleteItem = _ref.deleteItem,
69   - copyItem = _ref.copyItem,
70   - addItem = _ref.addItem,
71   - moveItemUp = _ref.moveItemUp,
72   - moveItemDown = _ref.moveItemDown,
73   - displayType = _ref.displayType,
74   - getFieldsProps = _ref.getFieldsProps;
  46 + displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
  47 + listData = _ref.listData,
  48 + changeList = _ref.changeList,
  49 + schema = _ref.schema,
  50 + deleteItem = _ref.deleteItem,
  51 + copyItem = _ref.copyItem,
  52 + addItem = _ref.addItem,
  53 + moveItemUp = _ref.moveItemUp,
  54 + moveItemDown = _ref.moveItemDown,
  55 + displayType = _ref.displayType,
  56 + getFieldsProps = _ref.getFieldsProps;
75 57 var _schema$props = schema.props,
76   - props = _schema$props === void 0 ? {} : _schema$props,
77   - itemProps = schema.itemProps;
78   -
  58 + props = _schema$props === void 0 ? {} : _schema$props,
  59 + itemProps = schema.itemProps;
79 60 var _useState = useState([]),
80   - _useState2 = _slicedToArray(_useState, 2),
81   - allKeys = _useState2[0],
82   - setKeys = _useState2[1]; // let addBtnProps = {
  61 + _useState2 = _slicedToArray(_useState, 2),
  62 + allKeys = _useState2[0],
  63 + setKeys = _useState2[1];
  64 +
  65 + // let addBtnProps = {
83 66 // type: 'dashed',
84 67 // children: '新增一条list',
85 68 // };
  69 +
86 70 // if (props.addBtnProps && typeof props.addBtnProps === 'object') {
87 71 // addBtnProps = { ...addBtnProps, ...props.addBtnProps };
88 72 // }
89 73
90   -
91 74 useEffect(function () {
92 75 var _allKeys = [];
93 76 displayList.forEach(function (item, idx) {
... ... @@ -97,7 +80,6 @@ var ListForMobile = function ListForMobile(_ref) {
97 80 });
98 81 setKeys(_allKeys);
99 82 }, [displayList]);
100   -
101 83 var getTitle = function getTitle(id) {
102 84 return /*#__PURE__*/React.createElement("div", {
103 85 style: {
... ... @@ -122,7 +104,6 @@ var ListForMobile = function ListForMobile(_ref) {
122 104 }
123 105 })));
124 106 };
125   -
126 107 var handleArrow = function handleArrow(active) {
127 108 if (active) {
128 109 return /*#__PURE__*/React.createElement(_UpOutlined, {
... ... @@ -132,7 +113,6 @@ var ListForMobile = function ListForMobile(_ref) {
132 113 return /*#__PURE__*/React.createElement(_DownOutlined, null);
133 114 }
134 115 };
135   -
136 116 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
137 117 className: "fr-card-list qx-card-mobile"
138 118 }, /*#__PURE__*/React.createElement(Collapse, {
... ... @@ -146,7 +126,6 @@ var ListForMobile = function ListForMobile(_ref) {
146 126 arrow: handleArrow,
147 127 onClick: function onClick() {
148 128 var _active = item._active || false;
149   -
150 129 displayList[idx]._active = !_active;
151 130 changeList(_toConsumableArray(displayList));
152 131 }
... ... @@ -167,5 +146,4 @@ var ListForMobile = function ListForMobile(_ref) {
167 146 }
168 147 }), "\u70B9\u51FB\u65B0\u589E\u6570\u636E"));
169 148 };
170   -
171 149 export default ListForMobile;
\ No newline at end of file
... ...
1 1 import { createFromIconfontCN } from '@ant-design/icons/lib';
  2 +
2 3 /**
3 4 * 使用:
4 5 * import QxIcon from '@/packages/qx-icon';
... ... @@ -10,7 +11,6 @@ import { createFromIconfontCN } from '@ant-design/icons/lib';
10 11 *
11 12 * @type {React.FC<IconFontProps<string>>}
12 13 */
13   -
14 14 var QxIcon = createFromIconfontCN({
15 15 scriptUrl: 'https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_13749_95.b05de9dc2fbe8efffb150f83b64da806.es5.js'
16 16 });
... ...
1 1 /* eslint-disable react-hooks/exhaustive-deps */
2 2 import { useEffect } from 'react';
3 3 import { getValueByPath } from './utils';
4   -
5 4 var Watcher = function Watcher(_ref) {
6 5 var watchKey = _ref.watchKey,
7   - watch = _ref.watch,
8   - formData = _ref.formData,
9   - firstMount = _ref.firstMount;
  6 + watch = _ref.watch,
  7 + formData = _ref.formData,
  8 + firstMount = _ref.firstMount;
10 9 var value = getValueByPath(formData, watchKey);
11 10 var watchObj = watch[watchKey];
12 11 useEffect(function () {
... ... @@ -25,10 +24,8 @@ var Watcher = function Watcher(_ref) {
25 24 }
26 25 }
27 26 };
28   -
29 27 if (firstMount) {
30 28 var immediate = watchObj && watchObj.immediate;
31   -
32 29 if (immediate) {
33 30 runWatcher();
34 31 }
... ... @@ -38,5 +35,4 @@ var Watcher = function Watcher(_ref) {
38 35 }, [JSON.stringify(value), firstMount]);
39 36 return null;
40 37 };
41   -
42 38 export default Watcher;
\ No newline at end of file
... ...
1   -function _extends() { _extends = Object.assign || 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   -
  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); }
3 2 import React, { forwardRef } from 'react';
4 3 import useForm from './useForm';
5   -
6 4 var connectForm = function connectForm(Component) {
7 5 return /*#__PURE__*/forwardRef(function (props, ref) {
8 6 var form = useForm();
... ... @@ -13,5 +11,4 @@ var connectForm = function connectForm(Component) {
13 11 }));
14 12 });
15 13 };
16   -
17 14 export default connectForm;
\ No newline at end of file
... ...
... ... @@ -6,45 +6,38 @@ import _CloseOutlined from "@ant-design/icons/es/icons/CloseOutlined";
6 6 import _CopyOutlined from "@ant-design/icons/es/icons/CopyOutlined";
7 7 import _ArrowDownOutlined from "@ant-design/icons/es/icons/ArrowDownOutlined";
8 8 import _ArrowUpOutlined from "@ant-design/icons/es/icons/ArrowUpOutlined";
9   -
10   -function _extends() { _extends = Object.assign || 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); }
11   -
12   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
13   -
14   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15   -
16   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17   -
18   -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19   -
  9 +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); }
  10 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  11 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  12 +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; }
  13 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  14 +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); }
  15 +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); }
20 16 import React from 'react';
21 17 import { useTools } from '../../../hooks';
22 18 import Core from '../../index';
23   -
24 19 var CardList = function CardList(_ref) {
25 20 var _ref$displayList = _ref.displayList,
26   - displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
27   - listData = _ref.listData,
28   - changeList = _ref.changeList,
29   - schema = _ref.schema,
30   - deleteItem = _ref.deleteItem,
31   - copyItem = _ref.copyItem,
32   - addItem = _ref.addItem,
33   - moveItemUp = _ref.moveItemUp,
34   - moveItemDown = _ref.moveItemDown,
35   - displayType = _ref.displayType,
36   - getFieldsProps = _ref.getFieldsProps;
  21 + displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
  22 + listData = _ref.listData,
  23 + changeList = _ref.changeList,
  24 + schema = _ref.schema,
  25 + deleteItem = _ref.deleteItem,
  26 + copyItem = _ref.copyItem,
  27 + addItem = _ref.addItem,
  28 + moveItemUp = _ref.moveItemUp,
  29 + moveItemDown = _ref.moveItemDown,
  30 + displayType = _ref.displayType,
  31 + getFieldsProps = _ref.getFieldsProps;
37 32 var _schema$props = schema.props,
38   - props = _schema$props === void 0 ? {} : _schema$props,
39   - itemProps = schema.itemProps,
40   - _schema$min = schema.min,
41   - min = _schema$min === void 0 ? 0 : _schema$min,
42   - _schema$max = schema.max,
43   - max = _schema$max === void 0 ? 9999 : _schema$max;
44   -
  33 + props = _schema$props === void 0 ? {} : _schema$props,
  34 + itemProps = schema.itemProps,
  35 + _schema$min = schema.min,
  36 + min = _schema$min === void 0 ? 0 : _schema$min,
  37 + _schema$max = schema.max,
  38 + max = _schema$max === void 0 ? 9999 : _schema$max;
45 39 var _useTools = useTools(),
46   - methods = _useTools.methods;
47   -
  40 + methods = _useTools.methods;
48 41 var addBtnProps = {
49 42 type: 'dashed',
50 43 children: '新增一条'
... ... @@ -54,15 +47,12 @@ var CardList = function CardList(_ref) {
54 47 okText: '确定',
55 48 cancelText: '取消'
56 49 };
57   -
58 50 if (props.addBtnProps && _typeof(props.addBtnProps) === 'object') {
59 51 addBtnProps = _objectSpread(_objectSpread({}, addBtnProps), props.addBtnProps);
60 52 }
61   -
62 53 if (props.delConfirmProps && _typeof(props.delConfirmProps) === 'object') {
63 54 delConfirmProps = _objectSpread(_objectSpread({}, delConfirmProps), props.delConfirmProps);
64 55 }
65   -
66 56 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
67 57 className: "fr-card-list"
68 58 }, displayList.map(function (item, idx) {
... ... @@ -104,16 +94,13 @@ var CardList = function CardList(_ref) {
104 94 onConfirm: function onConfirm() {
105 95 if (props.onConfirm && typeof props.onConfirm === 'string') {
106 96 var cb = methods[props.onConfirm];
107   -
108 97 if (typeof cb === 'function') {
109 98 var result = cb(item, idx);
110   -
111 99 if (!result) {
112 100 return;
113 101 }
114 102 }
115 103 }
116   -
117 104 deleteItem(idx);
118 105 }
119 106 }, delConfirmProps), /*#__PURE__*/React.createElement(_CloseOutlined, {
... ... @@ -130,9 +117,8 @@ var CardList = function CardList(_ref) {
130 117 onClick: addItem
131 118 }, addBtnProps)), Array.isArray(props.buttons) ? props.buttons.map(function (item, idx) {
132 119 var callback = item.callback,
133   - text = item.text,
134   - html = item.html;
135   -
  120 + text = item.text,
  121 + html = item.html;
136 122 var onClick = function onClick() {
137 123 console.log({
138 124 value: listData,
... ... @@ -140,7 +126,6 @@ var CardList = function CardList(_ref) {
140 126 schema: schema
141 127 });
142 128 };
143   -
144 129 if (typeof window[callback] === 'function') {
145 130 onClick = function onClick() {
146 131 window[callback]({
... ... @@ -150,7 +135,6 @@ var CardList = function CardList(_ref) {
150 135 });
151 136 };
152 137 }
153   -
154 138 return /*#__PURE__*/React.createElement(_Button, {
155 139 key: idx.toString(),
156 140 style: {
... ... @@ -165,5 +149,4 @@ var CardList = function CardList(_ref) {
165 149 }));
166 150 }) : null));
167 151 };
168   -
169 152 export default CardList;
\ No newline at end of file
... ...
... ... @@ -9,74 +9,55 @@ import _ArrowUpOutlined from "@ant-design/icons/es/icons/ArrowUpOutlined";
9 9 import "antd/es/popconfirm/style";
10 10 import _Popconfirm from "antd/es/popconfirm";
11 11 var _excluded = ["buttons"],
12   - _excluded2 = ["pagination"];
13   -
14   -function _extends() { _extends = Object.assign || 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); }
15   -
  12 + _excluded2 = ["pagination"];
  13 +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); }
16 14 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17   -
18 15 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."); }
19   -
20 16 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); }
21   -
22   -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; }
23   -
24   -function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
25   -
  17 +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; }
  18 +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; } }
26 19 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27   -
28   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
29   -
30   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
31   -
32   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33   -
34   -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
35   -
  20 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  21 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  22 +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; }
  23 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  24 +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); }
  25 +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); }
36 26 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; }
37   -
38 27 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; }
39   -
40 28 import React, { useRef } from 'react';
41 29 import { useSet, useTools } from '../../../hooks';
42 30 import { getDataPath, getDisplayValue, getKeyFromPath } from '../../../utils';
43 31 import Core from '../../index';
44 32 import ErrorMessage from '../../RenderField/ErrorMessage';
45 33 var FIELD_LENGTH = 170;
46   -
47 34 var DrawerList = function DrawerList(_ref) {
48 35 var _extends2;
49   -
50 36 var _ref$displayList = _ref.displayList,
51   - displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
52   - dataPath = _ref.dataPath,
53   - children = _ref.children,
54   - deleteItem = _ref.deleteItem,
55   - addItem = _ref.addItem,
56   - moveItemDown = _ref.moveItemDown,
57   - moveItemUp = _ref.moveItemUp,
58   - flatten = _ref.flatten,
59   - errorFields = _ref.errorFields,
60   - getFieldsProps = _ref.getFieldsProps,
61   - schema = _ref.schema,
62   - changeList = _ref.changeList,
63   - listData = _ref.listData;
64   -
  37 + displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
  38 + dataPath = _ref.dataPath,
  39 + children = _ref.children,
  40 + deleteItem = _ref.deleteItem,
  41 + addItem = _ref.addItem,
  42 + moveItemDown = _ref.moveItemDown,
  43 + moveItemUp = _ref.moveItemUp,
  44 + flatten = _ref.flatten,
  45 + errorFields = _ref.errorFields,
  46 + getFieldsProps = _ref.getFieldsProps,
  47 + schema = _ref.schema,
  48 + changeList = _ref.changeList,
  49 + listData = _ref.listData;
65 50 var _useTools = useTools(),
66   - widgets = _useTools.widgets;
67   -
  51 + widgets = _useTools.widgets;
68 52 var _schema$props = schema.props,
69   - props = _schema$props === void 0 ? {} : _schema$props,
70   - _schema$itemProps = schema.itemProps,
71   - itemProps = _schema$itemProps === void 0 ? {} : _schema$itemProps;
72   -
  53 + props = _schema$props === void 0 ? {} : _schema$props,
  54 + _schema$itemProps = schema.itemProps,
  55 + itemProps = _schema$itemProps === void 0 ? {} : _schema$itemProps;
73 56 var buttons = itemProps.buttons,
74   - columnProps = _objectWithoutProperties(itemProps, _excluded);
75   -
  57 + columnProps = _objectWithoutProperties(itemProps, _excluded);
76 58 var _props$pagination = props.pagination,
77   - pagination = _props$pagination === void 0 ? {} : _props$pagination,
78   - rest = _objectWithoutProperties(props, _excluded2);
79   -
  59 + pagination = _props$pagination === void 0 ? {} : _props$pagination,
  60 + rest = _objectWithoutProperties(props, _excluded2);
80 61 var actionColumnProps = {
81 62 colHeaderText: '操作',
82 63 editText: '编辑',
... ... @@ -92,33 +73,26 @@ var DrawerList = function DrawerList(_ref) {
92 73 children: '新增一条',
93 74 size: 'small'
94 75 };
95   -
96 76 if (props.actionColumnProps && _typeof(props.actionColumnProps) === 'object') {
97 77 actionColumnProps = _objectSpread(_objectSpread({}, actionColumnProps), props.actionColumnProps);
98 78 }
99   -
100 79 if (props.delConfirmProps && _typeof(props.delConfirmProps) === 'object') {
101 80 delConfirmProps = _objectSpread(_objectSpread({}, delConfirmProps), props.delConfirmProps);
102 81 }
103   -
104 82 if (props.addBtnProps && _typeof(props.addBtnProps) === 'object') {
105 83 addBtnProps = _objectSpread(_objectSpread({}, addBtnProps), props.addBtnProps);
106 84 }
107   -
108 85 var paginationConfig = pagination && _objectSpread({
109 86 size: 'small',
110 87 hideOnSinglePage: true
111 88 }, pagination);
112   -
113 89 var currentIndex = useRef(-1);
114   -
115 90 var _useSet = useSet({
116   - showDrawer: false
117   - }),
118   - _useSet2 = _slicedToArray(_useSet, 2),
119   - state = _useSet2[0],
120   - setState = _useSet2[1];
121   -
  91 + showDrawer: false
  92 + }),
  93 + _useSet2 = _slicedToArray(_useSet, 2),
  94 + state = _useSet2[0],
  95 + setState = _useSet2[1];
122 96 var showDrawer = state.showDrawer;
123 97 var dataSource = displayList.map(function (item, index) {
124 98 return _objectSpread(_objectSpread({}, item), {}, {
... ... @@ -128,9 +102,7 @@ var DrawerList = function DrawerList(_ref) {
128 102 var columns = children.map(function (child) {
129 103 var item = flatten[child];
130 104 var schema = item && item.schema || {};
131   -
132 105 var _dataIndex = getKeyFromPath(child);
133   -
134 106 return _objectSpread({
135 107 dataIndex: _dataIndex,
136 108 title: schema.required ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
... ... @@ -141,8 +113,8 @@ var DrawerList = function DrawerList(_ref) {
141 113 var childPath = getDataPath(child, [record.$idx]);
142 114 var errorObj = errorFields.find(function (item) {
143 115 return item.name == childPath;
144   - }) || {}; //TODO: 万一error在更深的层,这个办法是find不到的,会展示那一行没有提示。可以整一行加一个红线的方式处理
145   -
  116 + }) || {};
  117 + //TODO: 万一error在更深的层,这个办法是find不到的,会展示那一行没有提示。可以整一行加一个红线的方式处理
146 118 var Widget = widgets[schema.readOnlyWidget];
147 119 return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, Widget ? /*#__PURE__*/React.createElement(Widget, {
148 120 value: value,
... ... @@ -195,35 +167,30 @@ var DrawerList = function DrawerList(_ref) {
195 167 }
196 168 });
197 169 var fieldsProps = getFieldsProps(currentIndex.current);
198   -
199 170 var openDrawer = function openDrawer(index) {
200 171 currentIndex.current = index;
201 172 setState({
202 173 showDrawer: true
203 174 });
204 175 };
205   -
206 176 var closeDrawer = function closeDrawer() {
207 177 currentIndex.current = -1;
208 178 setState({
209 179 showDrawer: false
210 180 });
211 181 };
212   -
213 182 var handleAdd = function handleAdd() {
214 183 var newIndex = addItem();
215 184 openDrawer(newIndex);
216 185 };
217   -
218 186 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
219 187 className: "w-100 mb2 tr"
220 188 }, !props.hideAdd && /*#__PURE__*/React.createElement(_Button, _extends({}, addBtnProps, {
221 189 onClick: handleAdd
222 190 })), Array.isArray(props.buttons) ? props.buttons.map(function (item, idx) {
223 191 var callback = item.callback,
224   - text = item.text,
225   - html = item.html;
226   -
  192 + text = item.text,
  193 + html = item.html;
227 194 var onClick = function onClick() {
228 195 console.log({
229 196 value: listData,
... ... @@ -231,7 +198,6 @@ var DrawerList = function DrawerList(_ref) {
231 198 schema: schema
232 199 });
233 200 };
234   -
235 201 if (typeof window[callback] === 'function') {
236 202 onClick = function onClick() {
237 203 window[callback]({
... ... @@ -241,7 +207,6 @@ var DrawerList = function DrawerList(_ref) {
241 207 });
242 208 };
243 209 }
244   -
245 210 return /*#__PURE__*/React.createElement(_Button, {
246 211 key: idx.toString(),
247 212 style: {
... ... @@ -261,7 +226,6 @@ var DrawerList = function DrawerList(_ref) {
261 226 onClose: closeDrawer,
262 227 visible: showDrawer,
263 228 destroyOnClose: true // 必须要加,currentIndex不是一个state,Core不会重新渲染就跪了
264   -
265 229 }, /*#__PURE__*/React.createElement("div", {
266 230 className: "fr-container"
267 231 }, /*#__PURE__*/React.createElement(Core, fieldsProps))), /*#__PURE__*/React.createElement(_Table, _extends((_extends2 = {
... ... @@ -281,5 +245,4 @@ var DrawerList = function DrawerList(_ref) {
281 245 rowKey: "$idx"
282 246 }, _defineProperty(_extends2, "size", "small"), _defineProperty(_extends2, "pagination", paginationConfig), _extends2), rest)));
283 247 };
284   -
285 248 export default DrawerList;
\ No newline at end of file
... ...
... ... @@ -2,30 +2,20 @@ import _PlusCircleFilled from "@ant-design/icons/es/icons/PlusCircleFilled";
2 2 import _DownOutlined from "@ant-design/icons/es/icons/DownOutlined";
3 3 import _UpOutlined from "@ant-design/icons/es/icons/UpOutlined";
4 4 import _DeleteOutlined from "@ant-design/icons/es/icons/DeleteOutlined";
5   -
6 5 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7   -
8 6 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."); }
9   -
10 7 function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11   -
12 8 function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13   -
14 9 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15   -
16 10 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."); }
17   -
18 11 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); }
19   -
20   -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; }
21   -
22   -function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
23   -
  12 +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; }
  13 +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; } }
24 14 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25   -
26 15 /* eslint-disable jsx-a11y/anchor-is-valid */
27 16 import React, { useEffect, useMemo, useState } from 'react';
28   -import Core from '../../index'; // import { Button, Space, Popconfirm } from 'antd';
  17 +import Core from '../../index';
  18 +// import { Button, Space, Popconfirm } from 'antd';
29 19 // import ArrowDown from '../../../components/ArrowDown';
30 20 // import { Collapse } from 'antd-mobile'
31 21
... ... @@ -33,22 +23,17 @@ import Core from '../../index'; // import { Button, Space, Popconfirm } from 'an
33 23 function convertToChinaNum(num) {
34 24 var arr1 = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
35 25 var arr2 = ['', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿']; //可继续追加更高位转换值
36   -
37 26 if (!num || isNaN(num)) {
38 27 return "零";
39 28 }
40   -
41 29 var english = num.toString().split("");
42 30 var result = "";
43   -
44 31 for (var i = 0; i < english.length; i++) {
45 32 var des_i = english.length - 1 - i; //倒序排列设值
46   -
47 33 result = arr2[i] + result;
48 34 var arr1_index = english[des_i];
49 35 result = arr1[arr1_index] + result;
50 36 }
51   -
52 37 result = result.replace(/零(千|百|十)/g, '零').replace(/十零/g, '十');
53 38 result = result.replace(/零+/g, '零');
54 39 result = result.replace(/零亿/g, '亿').replace(/零万/g, '万');
... ... @@ -57,36 +42,36 @@ function convertToChinaNum(num) {
57 42 result = result.replace(/^一十/g, '十');
58 43 return result;
59 44 }
60   -
61 45 var ListForMobile = function ListForMobile(_ref) {
62 46 var _ref$displayList = _ref.displayList,
63   - displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
64   - listData = _ref.listData,
65   - changeList = _ref.changeList,
66   - schema = _ref.schema,
67   - deleteItem = _ref.deleteItem,
68   - copyItem = _ref.copyItem,
69   - addItem = _ref.addItem,
70   - moveItemUp = _ref.moveItemUp,
71   - moveItemDown = _ref.moveItemDown,
72   - displayType = _ref.displayType,
73   - getFieldsProps = _ref.getFieldsProps;
  47 + displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
  48 + listData = _ref.listData,
  49 + changeList = _ref.changeList,
  50 + schema = _ref.schema,
  51 + deleteItem = _ref.deleteItem,
  52 + copyItem = _ref.copyItem,
  53 + addItem = _ref.addItem,
  54 + moveItemUp = _ref.moveItemUp,
  55 + moveItemDown = _ref.moveItemDown,
  56 + displayType = _ref.displayType,
  57 + getFieldsProps = _ref.getFieldsProps;
74 58 var _schema$props = schema.props,
75   - props = _schema$props === void 0 ? {} : _schema$props,
76   - itemProps = schema.itemProps;
77   -
  59 + props = _schema$props === void 0 ? {} : _schema$props,
  60 + itemProps = schema.itemProps;
78 61 var _useState = useState([]),
79   - _useState2 = _slicedToArray(_useState, 2),
80   - allKeys = _useState2[0],
81   - setKeys = _useState2[1]; // let addBtnProps = {
  62 + _useState2 = _slicedToArray(_useState, 2),
  63 + allKeys = _useState2[0],
  64 + setKeys = _useState2[1];
  65 +
  66 + // let addBtnProps = {
82 67 // type: 'dashed',
83 68 // children: '新增一条list',
84 69 // };
  70 +
85 71 // if (props.addBtnProps && typeof props.addBtnProps === 'object') {
86 72 // addBtnProps = { ...addBtnProps, ...props.addBtnProps };
87 73 // }
88 74
89   -
90 75 useEffect(function () {
91 76 var _allKeys = [];
92 77 displayList.forEach(function (item, idx) {
... ... @@ -96,7 +81,6 @@ var ListForMobile = function ListForMobile(_ref) {
96 81 });
97 82 setKeys(_allKeys);
98 83 }, [displayList]);
99   -
100 84 var getTitle = function getTitle(id) {
101 85 return /*#__PURE__*/React.createElement("div", {
102 86 style: {
... ... @@ -121,7 +105,6 @@ var ListForMobile = function ListForMobile(_ref) {
121 105 }
122 106 })));
123 107 };
124   -
125 108 var handleArrow = function handleArrow(active) {
126 109 if (active) {
127 110 return /*#__PURE__*/React.createElement(_UpOutlined, {
... ... @@ -131,7 +114,6 @@ var ListForMobile = function ListForMobile(_ref) {
131 114 return /*#__PURE__*/React.createElement(_DownOutlined, null);
132 115 }
133 116 };
134   -
135 117 return null;
136 118 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
137 119 className: "fr-card-list qx-card-mobile"
... ... @@ -146,7 +128,6 @@ var ListForMobile = function ListForMobile(_ref) {
146 128 arrow: handleArrow,
147 129 onClick: function onClick() {
148 130 var _active = item._active || false;
149   -
150 131 displayList[idx]._active = !_active;
151 132 changeList(_toConsumableArray(displayList));
152 133 }
... ... @@ -167,5 +148,4 @@ var ListForMobile = function ListForMobile(_ref) {
167 148 }
168 149 }), "\u70B9\u51FB\u65B0\u589E\u6570\u636E"));
169 150 };
170   -
171 151 export default ListForMobile;
\ No newline at end of file
... ...
... ... @@ -6,39 +6,34 @@ import _CopyOutlined from "@ant-design/icons/es/icons/CopyOutlined";
6 6 import "antd/es/popconfirm/style";
7 7 import _Popconfirm from "antd/es/popconfirm";
8 8 import _DeleteOutlined from "@ant-design/icons/es/icons/DeleteOutlined";
9   -
10   -function _extends() { _extends = Object.assign || 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); }
11   -
12   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
13   -
14   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15   -
16   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17   -
18   -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19   -
  9 +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); }
  10 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  11 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  12 +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; }
  13 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  14 +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); }
  15 +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); }
20 16 import React from 'react';
21 17 import Core from '../../index';
22   -
23 18 var SimpleList = function SimpleList(_ref) {
24 19 var schema = _ref.schema,
25   - _ref$displayList = _ref.displayList,
26   - displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
27   - listData = _ref.listData,
28   - changeList = _ref.changeList,
29   - deleteItem = _ref.deleteItem,
30   - addItem = _ref.addItem,
31   - copyItem = _ref.copyItem,
32   - moveItemUp = _ref.moveItemUp,
33   - moveItemDown = _ref.moveItemDown,
34   - getFieldsProps = _ref.getFieldsProps;
  20 + _ref$displayList = _ref.displayList,
  21 + displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
  22 + listData = _ref.listData,
  23 + changeList = _ref.changeList,
  24 + deleteItem = _ref.deleteItem,
  25 + addItem = _ref.addItem,
  26 + copyItem = _ref.copyItem,
  27 + moveItemUp = _ref.moveItemUp,
  28 + moveItemDown = _ref.moveItemDown,
  29 + getFieldsProps = _ref.getFieldsProps;
35 30 var _schema$props = schema.props,
36   - props = _schema$props === void 0 ? {} : _schema$props,
37   - itemProps = schema.itemProps,
38   - _schema$min = schema.min,
39   - min = _schema$min === void 0 ? 0 : _schema$min,
40   - _schema$max = schema.max,
41   - max = _schema$max === void 0 ? 99999 : _schema$max;
  31 + props = _schema$props === void 0 ? {} : _schema$props,
  32 + itemProps = schema.itemProps,
  33 + _schema$min = schema.min,
  34 + min = _schema$min === void 0 ? 0 : _schema$min,
  35 + _schema$max = schema.max,
  36 + max = _schema$max === void 0 ? 99999 : _schema$max;
42 37 var addBtnProps = {
43 38 type: 'dashed',
44 39 children: '新增一条'
... ... @@ -48,25 +43,20 @@ var SimpleList = function SimpleList(_ref) {
48 43 okText: '确定',
49 44 cancelText: '取消'
50 45 };
51   -
52 46 if (props.addBtnProps && _typeof(props.addBtnProps) === 'object') {
53 47 addBtnProps = _objectSpread(_objectSpread({}, addBtnProps), props.addBtnProps);
54 48 }
55   -
56 49 if (props.delConfirmProps && _typeof(props.delConfirmProps) === 'object') {
57 50 delConfirmProps = _objectSpread(_objectSpread({}, delConfirmProps), props.delConfirmProps);
58 51 }
59   -
60 52 return /*#__PURE__*/React.createElement("div", {
61 53 className: "fr-list-1"
62 54 }, displayList.map(function (item, idx) {
63 55 var fieldsProps = getFieldsProps(idx);
64 56 fieldsProps.displayType = 'inline';
65   -
66 57 if (props.hideTitle) {
67 58 fieldsProps.hideTitle = true;
68 59 }
69   -
70 60 return /*#__PURE__*/React.createElement("div", {
71 61 key: idx,
72 62 style: {
... ... @@ -118,9 +108,8 @@ var SimpleList = function SimpleList(_ref) {
118 108 onClick: addItem
119 109 }, addBtnProps)), Array.isArray(props.buttons) ? props.buttons.map(function (item, idx) {
120 110 var callback = item.callback,
121   - text = item.text,
122   - html = item.html;
123   -
  111 + text = item.text,
  112 + html = item.html;
124 113 var onClick = function onClick() {
125 114 console.log({
126 115 value: listData,
... ... @@ -128,7 +117,6 @@ var SimpleList = function SimpleList(_ref) {
128 117 schema: schema
129 118 });
130 119 };
131   -
132 120 if (typeof window[callback] === 'function') {
133 121 onClick = function onClick() {
134 122 window[callback]({
... ... @@ -138,7 +126,6 @@ var SimpleList = function SimpleList(_ref) {
138 126 });
139 127 };
140 128 }
141   -
142 129 return /*#__PURE__*/React.createElement(_Button, {
143 130 key: idx.toString(),
144 131 style: {
... ... @@ -153,5 +140,4 @@ var SimpleList = function SimpleList(_ref) {
153 140 }));
154 141 }) : null));
155 142 };
156   -
157 143 export default SimpleList;
\ No newline at end of file
... ...
1 1 import "antd/es/tabs/style";
2 2 import _Tabs from "antd/es/tabs";
3 3 var _excluded = ["tabName", "type", "draggable"];
4   -
5   -function _extends() { _extends = Object.assign || 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); }
6   -
  4 +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); }
7 5 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; }
8   -
9 6 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; }
10   -
11 7 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12   -
13 8 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."); }
14   -
15 9 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); }
16   -
17   -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; }
18   -
19   -function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
20   -
  10 +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; }
  11 +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; } }
21 12 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22   -
23 13 /* eslint-disable jsx-a11y/anchor-is-valid */
24 14 import React, { useState, useRef } from 'react';
25 15 import Core from '../../index';
26 16 var TabPane = _Tabs.TabPane;
27 17 var dragType = 'DraggableTabNode';
28   -
29 18 var DraggableTabNode = function DraggableTabNode(_ref) {
30 19 var index = _ref.index,
31   - children = _ref.children,
32   - moveNode = _ref.moveNode;
  20 + children = _ref.children,
  21 + moveNode = _ref.moveNode;
33 22 var ref = useRef(null);
34   -
35 23 var _useDrop = useDrop({
36   - accept: dragType,
37   - collect: function collect(monitor) {
38   - var _ref2 = monitor.getItem() || {},
  24 + accept: dragType,
  25 + collect: function collect(monitor) {
  26 + var _ref2 = monitor.getItem() || {},
39 27 dragIndex = _ref2.index;
40   -
41   - if (dragIndex === index) {
42   - return {};
  28 + if (dragIndex === index) {
  29 + return {};
  30 + }
  31 + return {
  32 + isOver: monitor.isOver(),
  33 + dropClassName: 'dropping'
  34 + };
  35 + },
  36 + drop: function drop(item) {
  37 + moveNode(item.index, index);
43 38 }
44   -
45   - return {
46   - isOver: monitor.isOver(),
47   - dropClassName: 'dropping'
48   - };
49   - },
50   - drop: function drop(item) {
51   - moveNode(item.index, index);
52   - }
53   - }),
54   - _useDrop2 = _slicedToArray(_useDrop, 2),
55   - _useDrop2$ = _useDrop2[0],
56   - isOver = _useDrop2$.isOver,
57   - dropClassName = _useDrop2$.dropClassName,
58   - drop = _useDrop2[1];
59   -
  39 + }),
  40 + _useDrop2 = _slicedToArray(_useDrop, 2),
  41 + _useDrop2$ = _useDrop2[0],
  42 + isOver = _useDrop2$.isOver,
  43 + dropClassName = _useDrop2$.dropClassName,
  44 + drop = _useDrop2[1];
60 45 var _useDrag = useDrag({
61   - type: dragType,
62   - item: {
63   - index: index
64   - },
65   - collect: function collect(monitor) {
66   - return {
67   - isDragging: monitor.isDragging()
68   - };
69   - }
70   - }),
71   - _useDrag2 = _slicedToArray(_useDrag, 2),
72   - drag = _useDrag2[1];
73   -
  46 + type: dragType,
  47 + item: {
  48 + index: index
  49 + },
  50 + collect: function collect(monitor) {
  51 + return {
  52 + isDragging: monitor.isDragging()
  53 + };
  54 + }
  55 + }),
  56 + _useDrag2 = _slicedToArray(_useDrag, 2),
  57 + drag = _useDrag2[1];
74 58 drop(drag(ref));
75 59 return /*#__PURE__*/React.createElement("div", {
76 60 ref: ref,
... ... @@ -80,36 +64,31 @@ var DraggableTabNode = function DraggableTabNode(_ref) {
80 64 className: isOver ? dropClassName : ''
81 65 }, children);
82 66 };
83   -
84 67 var TabList = function TabList(_ref3) {
85 68 var _ref3$displayList = _ref3.displayList,
86   - displayList = _ref3$displayList === void 0 ? [] : _ref3$displayList,
87   - listData = _ref3.listData,
88   - changeList = _ref3.changeList,
89   - schema = _ref3.schema,
90   - deleteItem = _ref3.deleteItem,
91   - copyItem = _ref3.copyItem,
92   - addItem = _ref3.addItem,
93   - moveItemUp = _ref3.moveItemUp,
94   - moveItemDown = _ref3.moveItemDown,
95   - displayType = _ref3.displayType,
96   - getFieldsProps = _ref3.getFieldsProps;
97   -
  69 + displayList = _ref3$displayList === void 0 ? [] : _ref3$displayList,
  70 + listData = _ref3.listData,
  71 + changeList = _ref3.changeList,
  72 + schema = _ref3.schema,
  73 + deleteItem = _ref3.deleteItem,
  74 + copyItem = _ref3.copyItem,
  75 + addItem = _ref3.addItem,
  76 + moveItemUp = _ref3.moveItemUp,
  77 + moveItemDown = _ref3.moveItemDown,
  78 + displayType = _ref3.displayType,
  79 + getFieldsProps = _ref3.getFieldsProps;
98 80 var _useState = useState('0'),
99   - _useState2 = _slicedToArray(_useState, 2),
100   - activeKey = _useState2[0],
101   - setActiveKey = _useState2[1];
102   -
  81 + _useState2 = _slicedToArray(_useState, 2),
  82 + activeKey = _useState2[0],
  83 + setActiveKey = _useState2[1];
103 84 var _schema$props = schema.props,
104   - props = _schema$props === void 0 ? {} : _schema$props,
105   - itemProps = schema.itemProps;
106   -
  85 + props = _schema$props === void 0 ? {} : _schema$props,
  86 + itemProps = schema.itemProps;
107 87 var tabName = props.tabName,
108   - type = props.type,
109   - _props$draggable = props.draggable,
110   - draggable = _props$draggable === void 0 ? false : _props$draggable,
111   - restProps = _objectWithoutProperties(props, _excluded);
112   -
  88 + type = props.type,
  89 + _props$draggable = props.draggable,
  90 + draggable = _props$draggable === void 0 ? false : _props$draggable,
  91 + restProps = _objectWithoutProperties(props, _excluded);
113 92 var onEdit = function onEdit(targetKey, action) {
114 93 if (action === 'add') {
115 94 var currentKey = addItem();
... ... @@ -120,13 +99,12 @@ var TabList = function TabList(_ref3) {
120 99 } else {
121 100 return null;
122 101 }
123   - }; // 如果tabName传数组是可以「自定义」tab页的名字的。表单联动可以使用formrender的watch 配合 setSchemaByPath
124   -
  102 + };
125 103
  104 + // 如果tabName传数组是可以「自定义」tab页的名字的。表单联动可以使用formrender的watch 配合 setSchemaByPath
126 105 var getCurrentTabPaneName = function getCurrentTabPaneName(idx) {
127 106 return tabName instanceof Array ? tabName[idx] || idx + 1 : "".concat(tabName || '项目', " ").concat(idx + 1);
128 107 };
129   -
130 108 return /*#__PURE__*/React.createElement(_Tabs, _extends({
131 109 type: type || 'line',
132 110 onChange: setActiveKey,
... ... @@ -141,5 +119,4 @@ var TabList = function TabList(_ref3) {
141 119 }, /*#__PURE__*/React.createElement(Core, fieldsProps));
142 120 }));
143 121 };
144   -
145 122 export default TabList;
\ No newline at end of file
... ...
... ... @@ -7,64 +7,48 @@ import _ArrowUpOutlined from "@ant-design/icons/es/icons/ArrowUpOutlined";
7 7 import "antd/es/popconfirm/style";
8 8 import _Popconfirm from "antd/es/popconfirm";
9 9 var _excluded = ["buttons"],
10   - _excluded2 = ["pagination"];
11   -
12   -function _extends() { _extends = Object.assign || 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); }
13   -
  10 + _excluded2 = ["pagination"];
  11 +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); }
14 12 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
15   -
16 13 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."); }
17   -
18 14 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); }
19   -
20 15 function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
21   -
22 16 function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
23   -
24   -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; }
25   -
26   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
27   -
28   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29   -
30   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31   -
32   -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
33   -
  17 +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; }
  18 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  19 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  20 +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; }
  21 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  22 +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); }
  23 +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); }
34 24 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; }
35   -
36 25 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; }
37   -
38 26 import React from 'react';
39 27 import Core from '../../index';
40 28 var FIELD_LENGTH = 170;
41   -
42 29 var TableList = function TableList(_ref) {
43 30 var _ref$displayList = _ref.displayList,
44   - displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
45   - dataIndex = _ref.dataIndex,
46   - children = _ref.children,
47   - deleteItem = _ref.deleteItem,
48   - copyItem = _ref.copyItem,
49   - addItem = _ref.addItem,
50   - moveItemUp = _ref.moveItemUp,
51   - moveItemDown = _ref.moveItemDown,
52   - flatten = _ref.flatten,
53   - schema = _ref.schema,
54   - listData = _ref.listData,
55   - changeList = _ref.changeList;
  31 + displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
  32 + dataIndex = _ref.dataIndex,
  33 + children = _ref.children,
  34 + deleteItem = _ref.deleteItem,
  35 + copyItem = _ref.copyItem,
  36 + addItem = _ref.addItem,
  37 + moveItemUp = _ref.moveItemUp,
  38 + moveItemDown = _ref.moveItemDown,
  39 + flatten = _ref.flatten,
  40 + schema = _ref.schema,
  41 + listData = _ref.listData,
  42 + changeList = _ref.changeList;
56 43 var _schema$props = schema.props,
57   - props = _schema$props === void 0 ? {} : _schema$props,
58   - _schema$itemProps = schema.itemProps,
59   - itemProps = _schema$itemProps === void 0 ? {} : _schema$itemProps;
60   -
  44 + props = _schema$props === void 0 ? {} : _schema$props,
  45 + _schema$itemProps = schema.itemProps,
  46 + itemProps = _schema$itemProps === void 0 ? {} : _schema$itemProps;
61 47 var buttons = itemProps.buttons,
62   - columnProps = _objectWithoutProperties(itemProps, _excluded);
63   -
  48 + columnProps = _objectWithoutProperties(itemProps, _excluded);
64 49 var _props$pagination = props.pagination,
65   - pagination = _props$pagination === void 0 ? {} : _props$pagination,
66   - rest = _objectWithoutProperties(props, _excluded2);
67   -
  50 + pagination = _props$pagination === void 0 ? {} : _props$pagination,
  51 + rest = _objectWithoutProperties(props, _excluded2);
68 52 var actionColumnProps = {
69 53 colHeaderText: '操作',
70 54 copyText: '复制',
... ... @@ -80,24 +64,19 @@ var TableList = function TableList(_ref) {
80 64 children: '新增一条',
81 65 size: 'small'
82 66 };
83   -
84 67 if (props.actionColumnProps && _typeof(props.actionColumnProps) === 'object') {
85 68 actionColumnProps = _objectSpread(_objectSpread({}, actionColumnProps), props.actionColumnProps);
86 69 }
87   -
88 70 if (props.delConfirmProps && _typeof(props.delConfirmProps) === 'object') {
89 71 delConfirmProps = _objectSpread(_objectSpread({}, delConfirmProps), props.delConfirmProps);
90 72 }
91   -
92 73 if (props.addBtnProps && _typeof(props.addBtnProps) === 'object') {
93 74 addBtnProps = _objectSpread(_objectSpread({}, addBtnProps), props.addBtnProps);
94 75 }
95   -
96 76 var paginationConfig = pagination && _objectSpread({
97 77 size: 'small',
98 78 hideOnSinglePage: true
99 79 }, pagination);
100   -
101 80 var dataSource = displayList.map(function (item, idx) {
102 81 return {
103 82 index: idx
... ... @@ -125,7 +104,6 @@ var TableList = function TableList(_ref) {
125 104 }
126 105 }, columnProps);
127 106 });
128   -
129 107 if (!props.hideDelete || !props.hideAdd || !props.hideCopy || !props.hideMove) {
130 108 columns.push({
131 109 title: actionColumnProps.colHeaderText,
... ... @@ -168,16 +146,14 @@ var TableList = function TableList(_ref) {
168 146 }
169 147 });
170 148 }
171   -
172 149 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
173 150 className: "w-100 mb2 tr"
174 151 }, !props.hideAdd && /*#__PURE__*/React.createElement(_Button, _extends({}, addBtnProps, {
175 152 onClick: addItem
176 153 })), Array.isArray(props.buttons) ? props.buttons.map(function (item, idx) {
177 154 var callback = item.callback,
178   - text = item.text,
179   - html = item.html;
180   -
  155 + text = item.text,
  156 + html = item.html;
181 157 var onClick = function onClick() {
182 158 console.log({
183 159 value: listData,
... ... @@ -185,7 +161,6 @@ var TableList = function TableList(_ref) {
185 161 schema: schema
186 162 });
187 163 };
188   -
189 164 if (typeof window[callback] === 'function') {
190 165 onClick = function onClick() {
191 166 window[callback]({
... ... @@ -195,7 +170,6 @@ var TableList = function TableList(_ref) {
195 170 });
196 171 };
197 172 }
198   -
199 173 return /*#__PURE__*/React.createElement(_Button, {
200 174 key: idx.toString(),
201 175 style: {
... ... @@ -219,5 +193,4 @@ var TableList = function TableList(_ref) {
219 193 pagination: paginationConfig
220 194 }, rest)));
221 195 };
222   -
223 196 export default TableList;
\ No newline at end of file
... ...
... ... @@ -45,52 +45,36 @@ import _PlusOutlined from "@ant-design/icons/es/icons/PlusOutlined";
45 45 import "antd/es/modal/style";
46 46 import _Modal from "antd/es/modal";
47 47 var _excluded = ["scrollY", "summary", "batchKey", "type", "bar", "line", "searchKey", "rowSelection", "size", "originWidget"];
48   -
  48 +function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
49 49 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
50   -
51 50 function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
52   -
53   -function _extends() { _extends = Object.assign || 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); }
54   -
55   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
56   -
57   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
58   -
59   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
60   -
  51 +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); }
  52 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  53 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  54 +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; }
  55 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  56 +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); }
61 57 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
62   -
63 58 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."); }
64   -
65 59 function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
66   -
67 60 function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
68   -
69   -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
70   -
  61 +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); }
71 62 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
72   -
73 63 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."); }
74   -
75 64 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); }
76   -
77   -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; }
78   -
79   -function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
80   -
  65 +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; }
  66 +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; } }
81 67 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
82   -
83 68 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; }
84   -
85 69 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; }
86   -
87 70 /* eslint-disable jsx-a11y/anchor-is-valid */
88 71 import React, { useEffect, useMemo, useRef, useState } from 'react';
89 72 import Core from '../../index';
90   -var confirm = _Modal.confirm; // import { isDesignPage } from './utils'
91   -
  73 +var confirm = _Modal.confirm;
  74 +// import { isDesignPage } from './utils'
92 75 import * as dd from 'dingtalk-jsapi';
93   -import moment from 'moment'; // import {useVT} from 'virtualizedtableforantd4';
  76 +import moment from 'moment';
  77 +// import {useVT} from 'virtualizedtableforantd4';
94 78
95 79 import QxIcon from './icon';
96 80 var BUTTON_ICONS_MAP = {
... ... @@ -126,99 +110,86 @@ var EXPORT_STATUS = {
126 110 // 失败
127 111 FAIL: 'error'
128 112 };
129   -
130 113 var VirtualList = function VirtualList(_ref) {
131 114 var _dd$env;
132   -
133 115 var _ref$displayList = _ref.displayList,
134   - displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
135   - dataIndex = _ref.dataIndex,
136   - children = _ref.children,
137   - deleteItem = _ref.deleteItem,
138   - batchDelete = _ref.batchDelete,
139   - addItem = _ref.addItem,
140   - moveItemUp = _ref.moveItemUp,
141   - moveItemDown = _ref.moveItemDown,
142   - flatten = _ref.flatten,
143   - schema = _ref.schema,
144   - listData = _ref.listData,
145   - changeList = _ref.changeList,
146   - copyItem = _ref.copyItem,
147   - dataPath = _ref.dataPath;
  116 + displayList = _ref$displayList === void 0 ? [] : _ref$displayList,
  117 + dataIndex = _ref.dataIndex,
  118 + children = _ref.children,
  119 + deleteItem = _ref.deleteItem,
  120 + batchDelete = _ref.batchDelete,
  121 + addItem = _ref.addItem,
  122 + moveItemUp = _ref.moveItemUp,
  123 + moveItemDown = _ref.moveItemDown,
  124 + flatten = _ref.flatten,
  125 + schema = _ref.schema,
  126 + listData = _ref.listData,
  127 + changeList = _ref.changeList,
  128 + copyItem = _ref.copyItem,
  129 + dataPath = _ref.dataPath;
148 130 var _schema$props = schema.props,
149   - props = _schema$props === void 0 ? {} : _schema$props,
150   - _schema$itemProps = schema.itemProps,
151   - itemProps = _schema$itemProps === void 0 ? {} : _schema$itemProps,
152   - fieldName = schema.fieldName,
153   - _schema$qxProps = schema.qxProps,
154   - qxProps = _schema$qxProps === void 0 ? {} : _schema$qxProps,
155   - subformMode = schema.subformMode,
156   - isReadOnly = schema.isReadOnly,
157   - subReadOnly = schema.subReadOnly,
158   - isLoading = schema.isLoading,
159   - isFullScreen = schema.isFullScreen;
160   -
  131 + props = _schema$props === void 0 ? {} : _schema$props,
  132 + _schema$itemProps = schema.itemProps,
  133 + itemProps = _schema$itemProps === void 0 ? {} : _schema$itemProps,
  134 + fieldName = schema.fieldName,
  135 + _schema$qxProps = schema.qxProps,
  136 + qxProps = _schema$qxProps === void 0 ? {} : _schema$qxProps,
  137 + subformMode = schema.subformMode,
  138 + isReadOnly = schema.isReadOnly,
  139 + subReadOnly = schema.subReadOnly,
  140 + isLoading = schema.isLoading,
  141 + isFullScreen = schema.isFullScreen;
161 142 var _props$scrollY = props.scrollY,
162   - scrollY = _props$scrollY === void 0 ? 300 : _props$scrollY,
163   - _summary = props.summary,
164   - batchKey = props.batchKey,
165   - type = props.type,
166   - _props$bar = props.bar,
167   - bar = _props$bar === void 0 ? {} : _props$bar,
168   - _props$line = props.line,
169   - line = _props$line === void 0 ? {} : _props$line,
170   - searchKey = props.searchKey,
171   - rowSelection = props.rowSelection,
172   - size = props.size,
173   - originWidget = props.originWidget,
174   - rest = _objectWithoutProperties(props, _excluded); // const [vt, set_components] = useVT(() => ({scroll: {y: scrollY}}), []);
175   -
176   -
  143 + scrollY = _props$scrollY === void 0 ? 300 : _props$scrollY,
  144 + _summary = props.summary,
  145 + batchKey = props.batchKey,
  146 + type = props.type,
  147 + _props$bar = props.bar,
  148 + bar = _props$bar === void 0 ? {} : _props$bar,
  149 + _props$line = props.line,
  150 + line = _props$line === void 0 ? {} : _props$line,
  151 + searchKey = props.searchKey,
  152 + rowSelection = props.rowSelection,
  153 + size = props.size,
  154 + originWidget = props.originWidget,
  155 + rest = _objectWithoutProperties(props, _excluded);
  156 + // const [vt, set_components] = useVT(() => ({scroll: {y: scrollY}}), []);
177 157 var _useState = useState(''),
178   - _useState2 = _slicedToArray(_useState, 2),
179   - keyWord = _useState2[0],
180   - setKeyWord = _useState2[1];
181   -
  158 + _useState2 = _slicedToArray(_useState, 2),
  159 + keyWord = _useState2[0],
  160 + setKeyWord = _useState2[1];
182 161 var _useState3 = useState([]),
183   - _useState4 = _slicedToArray(_useState3, 2),
184   - selectedRowKeys = _useState4[0],
185   - setSelectedRowKeys = _useState4[1];
186   -
  162 + _useState4 = _slicedToArray(_useState3, 2),
  163 + selectedRowKeys = _useState4[0],
  164 + setSelectedRowKeys = _useState4[1];
187 165 var _useState5 = useState(),
188   - _useState6 = _slicedToArray(_useState5, 2),
189   - exportProgressData = _useState6[0],
190   - setProgressData = _useState6[1];
191   -
  166 + _useState6 = _slicedToArray(_useState5, 2),
  167 + exportProgressData = _useState6[0],
  168 + setProgressData = _useState6[1];
192 169 var _useState7 = useState(),
193   - _useState8 = _slicedToArray(_useState7, 2),
194   - intervalName = _useState8[0],
195   - setIntervalName = _useState8[1];
196   -
  170 + _useState8 = _slicedToArray(_useState7, 2),
  171 + intervalName = _useState8[0],
  172 + setIntervalName = _useState8[1];
197 173 var exportTaskId = useRef('');
198   -
199 174 var _useState9 = useState(false),
200   - _useState10 = _slicedToArray(_useState9, 2),
201   - isSubCanEdit = _useState10[0],
202   - setSubEdit = _useState10[1];
203   -
  175 + _useState10 = _slicedToArray(_useState9, 2),
  176 + isSubCanEdit = _useState10[0],
  177 + setSubEdit = _useState10[1];
204 178 var _useState11 = useState(''),
205   - _useState12 = _slicedToArray(_useState11, 2),
206   - searchName = _useState12[0],
207   - setSearchName = _useState12[1]; // const [dataSource, setDataSource] = useState([]);
  179 + _useState12 = _slicedToArray(_useState11, 2),
  180 + searchName = _useState12[0],
  181 + setSearchName = _useState12[1];
  182 + // const [dataSource, setDataSource] = useState([]);
208 183 // const [refresh, setRefresh] = useState('1');
209 184 // const [authDisplayList, setAuthDisplayList] = useState([]) // 有权限展示的数据
210   -
211   -
212 185 var _useState13 = useState(false),
213   - _useState14 = _slicedToArray(_useState13, 2),
214   - loading = _useState14[0],
215   - setLoading = _useState14[1];
216   -
  186 + _useState14 = _slicedToArray(_useState13, 2),
  187 + loading = _useState14[0],
  188 + setLoading = _useState14[1];
217 189 var mergeFieldsMap = useRef({});
218   - var isMergeFieldExist = useRef(false); // const [cloneList, setCloneList] = useState([]);
219   -
  190 + var isMergeFieldExist = useRef(false);
  191 + // const [cloneList, setCloneList] = useState([]);
220 192 var isInDing = dd && (dd === null || dd === void 0 ? void 0 : (_dd$env = dd.env) === null || _dd$env === void 0 ? void 0 : _dd$env.platform) !== 'notInDingTalk';
221   -
222 193 if (subReadOnly) {
223 194 Object.keys(flatten).forEach(function (key) {
224 195 if (key.indexOf(schema.$id) === 0 && key.split('.').length > 1) {
... ... @@ -226,7 +197,6 @@ var VirtualList = function VirtualList(_ref) {
226 197 }
227 198 });
228 199 }
229   -
230 200 useEffect(function () {
231 201 setLoading(!!isLoading);
232 202 }, [isLoading]);
... ... @@ -235,29 +205,25 @@ var VirtualList = function VirtualList(_ref) {
235 205 }, [size]);
236 206 var newRowSelection = useMemo(function () {
237 207 var _bar$buttons;
238   -
239 208 // if (schema.isReadOnly) return null
240   - var _rowSelection = _.cloneDeep(rowSelection); // 根据是否含有批量操作按钮,渲染表格是否可选择
241   -
242   -
  209 + var _rowSelection = _.cloneDeep(rowSelection);
  210 + // 根据是否含有批量操作按钮,渲染表格是否可选择
243 211 var selectable = false;
244   -
245 212 if (((_bar$buttons = bar.buttons) === null || _bar$buttons === void 0 ? void 0 : _bar$buttons.findIndex(function (item) {
246 213 return item.code === 'DELETE';
247 214 })) > -1) {
248 215 selectable = true;
249 216 }
250   -
251 217 if (_rowSelection && selectable) {
252 218 _rowSelection.onChange = function (_selectedRowKeys) {
253 219 setSelectedRowKeys(_selectedRowKeys);
254 220 };
255   -
256 221 _rowSelection.selectedRowKeys = selectedRowKeys;
257 222 }
258   -
259 223 return _rowSelection;
260   - }, [JSON.stringify(bar.buttons), JSON.stringify(rowSelection), JSON.stringify(selectedRowKeys)]); // useEffect(() => {
  224 + }, [JSON.stringify(bar.buttons), JSON.stringify(rowSelection), JSON.stringify(selectedRowKeys)]);
  225 +
  226 + // useEffect(() => {
261 227 // const _cloneList = _.cloneDeep(displayList);
262 228 // _cloneList.forEach((item, index) => {
263 229 // if (typeof item === 'object') {
... ... @@ -279,43 +245,38 @@ var VirtualList = function VirtualList(_ref) {
279 245 // } else {
280 246 // _displayList = [...cloneList]
281 247 // }
282   -
283 248 var cloneList = useMemo(function () {
284 249 //console.log('useMemo cloneList', displayList)
285   - var _cloneList = _.cloneDeep(displayList);
286 250
  251 + var _cloneList = _.cloneDeep(displayList);
287 252 _cloneList.forEach(function (item, index) {
288 253 if (_typeof(item) === 'object') {
289 254 item.orginIdx = index;
290 255 }
291 256 });
292   -
293 257 return _cloneList;
294   - }, [displayList]); // 数据变化时,子表汇总值重新计算,并加到主表的formData中
  258 + }, [displayList]);
295 259
  260 + // 数据变化时,子表汇总值重新计算,并加到主表的formData中
296 261 useEffect(function () {
297 262 var _schema$qxProps2;
298   -
299 263 console.log('计算汇总');
300 264 if (schema.originWidget !== 'subform') return;
301 265 var subKey = schema.fieldName || schema.propertyKey;
302 266 if (!schema._setValueByPath) return;
303 267 (((_schema$qxProps2 = schema.qxProps) === null || _schema$qxProps2 === void 0 ? void 0 : _schema$qxProps2.summary) || []).forEach(function (item) {
304 268 var fx = item.fx,
305   - relField = item.relField,
306   - code = item.code;
307   - var key = "".concat(subKey, ":").concat(code, ":").concat(fx); // subKey + '.' + code +;
308   -
  269 + relField = item.relField,
  270 + code = item.code;
  271 + var key = "".concat(subKey, ":").concat(code, ":").concat(fx);
  272 + // subKey + '.' + code +;
309 273 var values = (displayList || []).map(function (it) {
310 274 return it[relField];
311 275 });
312   -
313 276 if (!values.length) {
314 277 schema._setValueByPath(key, 'EMPTY');
315   -
316 278 return;
317 279 }
318   -
319 280 if (['COUNTUNIQUE', 'COUNTA'].includes(fx)) {
320 281 values.forEach(function (_item, index) {
321 282 if (Array.isArray(_item)) {
... ... @@ -323,51 +284,41 @@ var VirtualList = function VirtualList(_ref) {
323 284 }
324 285 });
325 286 }
326   -
327 287 values = values.filter(function (item) {
328 288 return item !== undefined;
329 289 });
330   -
331 290 if (fx === 'MAX' || fx === 'MIN') {
332 291 var widget = '';
333 292 var keys = Object.keys(flatten || {});
334   -
335 293 for (var i = 0; i < keys.length; i++) {
336 294 if (keys[i].indexOf(relField) > -1) {
337 295 var _flatten$keys$i, _flatten$keys$i$schem;
338   -
339 296 var _widget = (_flatten$keys$i = flatten[keys[i]]) === null || _flatten$keys$i === void 0 ? void 0 : (_flatten$keys$i$schem = _flatten$keys$i.schema) === null || _flatten$keys$i$schem === void 0 ? void 0 : _flatten$keys$i$schem.widget;
340   -
341 297 if (_widget !== 'qxSummary') {
342 298 widget = _widget;
343 299 break;
344 300 }
345 301 }
346 302 }
347   -
348 303 if (['qxDatetime', 'createdAt', 'updatedAt'].includes(widget)) {
349 304 var _moment$fx$toLowerCas;
350   -
351 305 values = values.filter(function (it) {
352 306 return it;
353 307 }); // 计算日期的最大最小时,过滤掉空值
354   -
355 308 values.forEach(function (it, index) {
356 309 values[index] = moment(it);
357   - }); // schema.parentFormData[key] = moment[fx.toLowerCase()](values)?._i || 'EMPTY';
358   -
  310 + });
  311 + // schema.parentFormData[key] = moment[fx.toLowerCase()](values)?._i || 'EMPTY';
359 312 schema._setValueByPath(key, ((_moment$fx$toLowerCas = moment[fx.toLowerCase()](values)) === null || _moment$fx$toLowerCas === void 0 ? void 0 : _moment$fx$toLowerCas._i) || 'EMPTY');
360 313 } else if (widget === 'qxTime') {
361 314 var _moment$fx$toLowerCas2, _moment$fx$toLowerCas3;
362   -
363 315 values = values.filter(function (it) {
364 316 return it;
365 317 }); // 计算时间的最大最小时,过滤掉空值
366   -
367 318 values.forEach(function (it, index) {
368 319 values[index] = moment('0001-01-01 ' + it); // 随意拼个年月日返回,计算时替换
369   - }); // schema.parentFormData[key] = (moment[fx.toLowerCase()](values)?._i)?.slice(11) || 'EMPTY';
370   -
  320 + });
  321 + // schema.parentFormData[key] = (moment[fx.toLowerCase()](values)?._i)?.slice(11) || 'EMPTY';
371 322 schema._setValueByPath(key, ((_moment$fx$toLowerCas2 = moment[fx.toLowerCase()](values)) === null || _moment$fx$toLowerCas2 === void 0 ? void 0 : (_moment$fx$toLowerCas3 = _moment$fx$toLowerCas2._i) === null || _moment$fx$toLowerCas3 === void 0 ? void 0 : _moment$fx$toLowerCas3.slice(11)) || 'EMPTY');
372 323 } else {
373 324 // schema.parentFormData[key] = window[fx](values);
... ... @@ -376,20 +327,19 @@ var VirtualList = function VirtualList(_ref) {
376 327 } else {
377 328 // schema.parentFormData['__SUMMARY_' + subKey][key] = window[fx](values);
378 329 var res = window[fx](values);
379   -
380 330 if (String(res).startsWith('Error')) {
381 331 res = null;
382 332 }
383   -
384 333 schema._setValueByPath(key, res);
385 334 }
386 335 });
387 336 }, [JSON.stringify(displayList)]);
388   -
389 337 var _displayList = useMemo(function () {
390 338 //console.log('useMemo _displayList', cloneList)
391   - var _displayList1 = []; // 筛选展示的数据
392 339
  340 + var _displayList1 = [];
  341 +
  342 + // 筛选展示的数据
393 343 if (props.originWidget === 'relSelector') {
394 344 cloneList.forEach(function (item) {
395 345 if (!item.hasOwnProperty('$auth') || item.$auth) {
... ... @@ -399,9 +349,9 @@ var VirtualList = function VirtualList(_ref) {
399 349 } else {
400 350 _displayList1 = _toConsumableArray(cloneList);
401 351 }
402   -
403 352 return _displayList1;
404   - }, [cloneList]); // useEffect(() => {
  353 + }, [cloneList]);
  354 + // useEffect(() => {
405 355 // 筛选展示的数据
406 356 // if (props.originWidget === 'relSelector') {
407 357 // displayList.forEach((item, index) => {
... ... @@ -422,6 +372,7 @@ var VirtualList = function VirtualList(_ref) {
422 372 // }
423 373 // setAuthDisplayList(_displayList)
424 374 // }, [displayList, props.originWidget])
  375 +
425 376 // const _displayList = useMemo(() => {
426 377 // let arr = []
427 378 // const cloneList = _.cloneDeep(displayList)
... ... @@ -440,7 +391,6 @@ var VirtualList = function VirtualList(_ref) {
440 391 // return arr
441 392 // }, [displayList])
442 393
443   -
444 394 var selectedIds = useMemo(function () {
445 395 var _selectedIds = [];
446 396 cloneList.forEach(function (item) {
... ... @@ -449,13 +399,13 @@ var VirtualList = function VirtualList(_ref) {
449 399 }
450 400 });
451 401 return _selectedIds;
452   - }, [selectedRowKeys, cloneList]); // useEffect(() => {
  402 + }, [selectedRowKeys, cloneList]);
453 403
  404 + // useEffect(() => {
454 405 var dataSource = useMemo(function () {
455 406 //console.log('useMemo dataSource',dataSource);
456 407 return (keyWord.length ? _displayList.filter(function (item) {
457 408 var _String;
458   -
459 409 return ((_String = String(item[searchKey])) === null || _String === void 0 ? void 0 : _String.indexOf(keyWord)) > -1;
460 410 }) : _displayList).map(function (item, idx) {
461 411 return _objectSpread(_objectSpread({}, item), {}, {
... ... @@ -463,9 +413,12 @@ var VirtualList = function VirtualList(_ref) {
463 413 orginIdx: item.hasOwnProperty('orginIdx') ? item.orginIdx : null
464 414 });
465 415 });
466   - }, [_displayList, keyWord, searchKey]); // useEffect(() => {
  416 + }, [_displayList, keyWord, searchKey]);
  417 +
  418 + // useEffect(() => {
467 419 // setRefresh(refresh + '1')
468 420 // }, [JSON.stringify(dataSource)])
  421 +
469 422 // setDataSource(_dataSource)
470 423 // }, [keyWord, JSON.stringify(_displayList)])
471 424 // useEffect(() => {
... ... @@ -479,7 +432,6 @@ var VirtualList = function VirtualList(_ref) {
479 432 if (!total) {
480 433 total = 0;
481 434 }
482   -
483 435 if (props.originWidget === 'subform' || total === displayList.length) {
484 436 return "\u5171".concat(total, "\u6761\u8BB0\u5F55");
485 437 } else {
... ... @@ -491,7 +443,6 @@ var VirtualList = function VirtualList(_ref) {
491 443 }, "(", displayList.length - total, "\u6761\u4E0D\u53EF\u89C1)"));
492 444 }
493 445 };
494   -
495 446 var pagination = useMemo(function () {
496 447 // console.log('useMemo pagination', dataSource?.length, props.limit)
497 448 return {
... ... @@ -502,14 +453,13 @@ var VirtualList = function VirtualList(_ref) {
502 453 return handleTotal(total);
503 454 },
504 455 defaultCurrent: 1,
505   - size: size || 'small' // hideOnSinglePage: true
506   -
  456 + size: size || 'small'
  457 + // hideOnSinglePage: true
507 458 };
508 459 }, [dataSource === null || dataSource === void 0 ? void 0 : dataSource.length, props.limit]);
509 460 var barButtons = useMemo(function () {
510 461 // console.log('useMemo barButtons', schema.isReadOnly, bar.buttons, originWidget, type, subReadOnly)
511 462 var _barButtons = _.cloneDeep(bar.buttons || []);
512   -
513 463 if (schema.isReadOnly) {
514 464 // 关联表只读
515 465 // return _barButtons.filter(item => item.code === 'EXPORT')
... ... @@ -518,32 +468,27 @@ var VirtualList = function VirtualList(_ref) {
518 468 return _barButtons.filter(function (item) {
519 469 return item.code === 'EXPORT';
520 470 });
521   - } // 关联表的导入,先隐藏 TODO
522   -
523   -
  471 + }
  472 + // 关联表的导入,先隐藏 TODO
524 473 if (props.originWidget === 'relSelector') {
525 474 ['IMPORT'].forEach(function (code) {
526 475 var _index = _barButtons.findIndex(function (item) {
527 476 return item.code === code;
528 477 });
529   -
530 478 if (_index > -1) {
531 479 _barButtons.splice(_index, 1);
532 480 }
533 481 });
534   - } // 子表默认可以新增,删掉ADD按钮
535   -
536   -
  482 + }
  483 + // 子表默认可以新增,删掉ADD按钮
537 484 if (props.originWidget === 'subform') {
538 485 var _index = _barButtons.findIndex(function (item) {
539 486 return item.code === 'ADD';
540 487 });
541   -
542 488 if (_index > -1) {
543 489 _barButtons.splice(_index, 1);
544 490 }
545 491 }
546   -
547 492 if (batchKey && type !== 'view') {
548 493 _barButtons.push({
549 494 code: 'BATCH_ADD',
... ... @@ -552,7 +497,6 @@ var VirtualList = function VirtualList(_ref) {
552 497 name: '批量新增'
553 498 });
554 499 }
555   -
556 500 if (props.originWidget === 'relSelector' && subformMode && type === 'edit') {
557 501 _barButtons.unshift({
558 502 code: 'subformEdit',
... ... @@ -561,51 +505,43 @@ var VirtualList = function VirtualList(_ref) {
561 505 action: 'SYS',
562 506 name: '表格编辑'
563 507 });
564   - } // 选择位置提前
565   -
566   -
  508 + }
  509 + // 选择位置提前
567 510 ['SELECT'].forEach(function (code) {
568 511 var _index = _barButtons.findIndex(function (item) {
569 512 return item.code === code;
570 513 });
571   -
572 514 if (_index > -1) {
573 515 var btn = _barButtons.splice(_index, 1);
574   -
575 516 _barButtons.unshift.apply(_barButtons, _toConsumableArray(btn));
576 517 }
577 518 });
578   -
579 519 if (type === 'add') {
580 520 var addBtns = ['SELECT', 'IMPORT', 'ADD', 'BATCH_ADD'];
581   -
582 521 if (props.originWidget === 'subform') {
583 522 addBtns.push('DELETE');
  523 + return _barButtons.filter(function (item) {
  524 + return addBtns.includes(item.code);
  525 + });
584 526 }
585   -
586   - return _barButtons.filter(function (item) {
587   - return addBtns.includes(item.code);
588   - });
589 527 } else if (type === 'view') {
590 528 return _barButtons.filter(function (item) {
591 529 return item.code === 'EXPORT';
592 530 });
593 531 }
594   -
595 532 return _barButtons;
596 533 }, [schema.isReadOnly, bar.buttons, originWidget, type, subReadOnly]);
597 534 var moreButtons = useMemo(function () {
598 535 var _barButtons = _.cloneDeep(barButtons);
599   -
600 536 return /*#__PURE__*/React.createElement(_Menu, null, _barButtons.slice(3).filter(function (item) {
601 537 return isInDing ? !['EXPORT', 'IMPORT'].includes(item.code) : true;
602 538 }).map(function (item) {
603 539 var name = item.name,
604   - code = item.code,
605   - needConfirm = item.needConfirm,
606   - confirmContent = item.confirmContent,
607   - icon = item.icon,
608   - action = item.action;
  540 + code = item.code,
  541 + needConfirm = item.needConfirm,
  542 + confirmContent = item.confirmContent,
  543 + icon = item.icon,
  544 + action = item.action;
609 545 return /*#__PURE__*/React.createElement(_Menu.Item, null, /*#__PURE__*/React.createElement(_Button, _extends({
610 546 key: code,
611 547 style: {
... ... @@ -632,10 +568,8 @@ var VirtualList = function VirtualList(_ref) {
632 568 }), name));
633 569 }));
634 570 }, [barButtons, barBtnClick]);
635   -
636 571 var handleColumn = function handleColumn(schema, child, index) {
637 572 var _schema$props2;
638   -
639 573 if (props.editable && props.originWidget === 'subform') {
640 574 if (isSubCanEdit && !['relField', 'qxFormula'].includes(schema.widget)) {
641 575 schema.readOnly = false;
... ... @@ -643,22 +577,17 @@ var VirtualList = function VirtualList(_ref) {
643 577 schema.readOnly = true;
644 578 }
645 579 }
646   -
647 580 if (schema.fieldName === searchKey) {
648 581 setSearchName(schema.title);
649 582 }
650   -
651 583 var tip = schema.description ? /*#__PURE__*/React.createElement("span", {
652 584 className: 'qx-column_desc'
653 585 }, /*#__PURE__*/React.createElement(_Tooltip, {
654 586 title: schema.description
655 587 }, /*#__PURE__*/React.createElement(_InfoCircleOutlined, null))) : null;
656 588 var column = ((_schema$props2 = schema.props) === null || _schema$props2 === void 0 ? void 0 : _schema$props2.column) || {};
657   -
658 589 var _dataIndex = child.indexOf(dataPath) === -1 ? dataPath + '[].' + child : child;
659   -
660 590 var _width = parseInt(column.width);
661   -
662 591 return {
663 592 dataIndex: _dataIndex,
664 593 width: (column.width && _width ? _width : FIELD_LENGTH) + padding,
... ... @@ -686,8 +615,8 @@ var VirtualList = function VirtualList(_ref) {
686 615 key: index.toString(),
687 616 id: _dataIndex,
688 617 dataIndex: childIndex,
689   - _item: flatten[_dataIndex] ? null : getItemSchema(_dataIndex) // subReadOnly={subReadOnly}
690   -
  618 + _item: flatten[_dataIndex] ? null : getItemSchema(_dataIndex)
  619 + // subReadOnly={subReadOnly}
691 620 });
692 621 }
693 622 };
... ... @@ -695,7 +624,6 @@ var VirtualList = function VirtualList(_ref) {
695 624
696 625 var getItemSchema = function getItemSchema(id) {
697 626 var _item;
698   -
699 627 Object.keys(mergeFieldsMap.current || {}).forEach(function (key) {
700 628 if (id.indexOf(key) > -1) {
701 629 _item = mergeFieldsMap.current[key];
... ... @@ -703,7 +631,6 @@ var VirtualList = function VirtualList(_ref) {
703 631 });
704 632 return _item;
705 633 };
706   -
707 634 var handleMergeField = function handleMergeField(schema) {
708 635 // const column = schema.props?.column || {};
709 636 var _props = schema.props;
... ... @@ -713,15 +640,12 @@ var VirtualList = function VirtualList(_ref) {
713 640 dataIndex: _props.dataIndex,
714 641 children: Object.keys(schema.children).map(function (key) {
715 642 var _schema$children$key, _schema$children$key2;
716   -
717 643 if (key.indexOf('_merge_field') > -1 && Object.keys((_schema$children$key = schema.children[key]) === null || _schema$children$key === void 0 ? void 0 : _schema$children$key.children).length === 1 && ((_schema$children$key2 = schema.children[key]) === null || _schema$children$key2 === void 0 ? void 0 : _schema$children$key2.children.hidden)) {
718 644 return {
719 645 show: false
720 646 };
721 647 }
722   -
723 648 var isMergeField = key.indexOf('_merge_field') > -1 && Object.keys(schema.children[key].children || {}).length;
724   -
725 649 if (isMergeField) {
726 650 return handleMergeField(schema.children[key]);
727 651 } else {
... ... @@ -730,22 +654,16 @@ var VirtualList = function VirtualList(_ref) {
730 654 })
731 655 };
732 656 };
733   -
734 657 var getMergeMap = function getMergeMap() {
735 658 var _map = {};
736 659 Object.keys(flatten).forEach(function (key) {
737 660 var _schema$schema;
738   -
739 661 var _schema = flatten[key];
740   -
741 662 var _children = (_schema === null || _schema === void 0 ? void 0 : (_schema$schema = _schema.schema) === null || _schema$schema === void 0 ? void 0 : _schema$schema.children) || {};
742   -
743 663 if (key.indexOf('_merge_field') > -1 && Object.keys(_children).length) {
744 664 Object.keys(_children).forEach(function (item) {
745 665 var _schema1 = _children[item];
746   -
747 666 var _children1 = _schema1.children || {};
748   -
749 667 if (item.indexOf('_merge_field') > -1 && Object.keys(_children1).length) {
750 668 Object.keys(_children1).forEach(function (it) {
751 669 _map[it] = {
... ... @@ -762,30 +680,23 @@ var VirtualList = function VirtualList(_ref) {
762 680 });
763 681 return _map;
764 682 };
765   -
766 683 var columns = useMemo(function () {
767 684 var _line_buttons2;
768   -
769 685 //console.log('useMemo columns', isSubCanEdit, subReadOnly, JSON.stringify(line.buttons))
  686 +
770 687 mergeFieldsMap.current = getMergeMap();
771 688 isMergeFieldExist.current = false;
772   -
773 689 var _line_buttons = _.cloneDeep(line.buttons);
774   -
775 690 var _columns = (children || []).map(function (child, index) {
776 691 var _schema$children;
777   -
778 692 var item = flatten[child];
779 693 var schema = item && item.schema || {};
780   -
781 694 if (child.indexOf('_merge_field') > -1 && (((_schema$children = schema.children) === null || _schema$children === void 0 ? void 0 : _schema$children.hidden) || !Object.keys(schema.children || {}).length)) {
782 695 return {
783 696 show: false
784 697 };
785 698 }
786   -
787 699 var isMergeField = child.indexOf('_merge_field') > -1 && Object.keys(schema.children || {}).length;
788   -
789 700 if (isMergeField) {
790 701 isMergeFieldExist.current = true;
791 702 return handleMergeField(schema, index);
... ... @@ -793,25 +704,21 @@ var VirtualList = function VirtualList(_ref) {
793 704 return handleColumn(schema, child, index);
794 705 }
795 706 });
796   -
797 707 _columns = _columns.filter(function (item) {
798 708 return Object.keys(item).length !== 1 && (!item.hidden || item.show);
799 709 });
800   -
801 710 if (((_line_buttons2 = _line_buttons) === null || _line_buttons2 === void 0 ? void 0 : _line_buttons2.length) || Array.isArray(itemProps.buttons)) {
802 711 var top = line.top,
803   - _line$style = line.style,
804   - style = _line$style === void 0 ? 'ICON' : _line$style,
805   - fixed = line.fixed;
806   -
  712 + _line$style = line.style,
  713 + style = _line$style === void 0 ? 'ICON' : _line$style,
  714 + fixed = line.fixed;
807 715 if (type === 'add') {
808 716 if (props.originWidget === 'subform') {
809 717 _line_buttons = _line_buttons.filter(function (item) {
810 718 return item.code === 'DELETE';
811 719 });
812 720 }
813   -
814   - console.log('关联记录放开所有行按钮关联XQ230328006'); // 关联记录放开所有行按钮关联XQ230328006
  721 + // 关联记录放开所有行按钮关联XQ230328006
815 722 // else if (props.originWidget === 'relSelector') {
816 723 // // jbl ERP需求,新增时放开编辑按钮
817 724 // _line_buttons = _line_buttons.filter(item => ['REMOVE', 'EDIT'].includes(item.code))
... ... @@ -821,7 +728,6 @@ var VirtualList = function VirtualList(_ref) {
821 728 return item.code === 'VIEW';
822 729 });
823 730 }
824   -
825 731 var len = (_line_buttons || []).length;
826 732 var action = subReadOnly || isReadOnly && originWidget === 'subform' ? {} : {
827 733 title: '操作',
... ... @@ -832,11 +738,9 @@ var VirtualList = function VirtualList(_ref) {
832 738 render: function render(value, record, idx) {
833 739 return /*#__PURE__*/React.createElement(React.Fragment, null, Array.isArray(itemProps.buttons) ? itemProps.buttons.map(function (item, idx) {
834 740 var callback = item.callback,
835   - text = item.text,
836   - html = item.html;
837   -
  741 + text = item.text,
  742 + html = item.html;
838 743 var onClick = function onClick() {};
839   -
840 744 if (typeof window[callback] === 'function') {
841 745 onClick = function onClick() {
842 746 window[callback]({
... ... @@ -846,7 +750,6 @@ var VirtualList = function VirtualList(_ref) {
846 750 });
847 751 };
848 752 }
849   -
850 753 return /*#__PURE__*/React.createElement("a", {
851 754 key: idx.toString(),
852 755 style: {
... ... @@ -860,14 +763,14 @@ var VirtualList = function VirtualList(_ref) {
860 763 }));
861 764 }) : null, Array.isArray(_line_buttons) ? _line_buttons.map(function (item) {
862 765 var name = item.name,
863   - code = item.code,
864   - needConfirm = item.needConfirm,
865   - confirmContent = item.confirmContent,
866   - icon = item.icon;
867   - var display = handleState(record, code, props.originWidget); // if (display === '') {
  766 + code = item.code,
  767 + needConfirm = item.needConfirm,
  768 + confirmContent = item.confirmContent,
  769 + icon = item.icon;
  770 + var display = handleState(record, code, props.originWidget);
  771 + // if (display === '') {
868 772 // btnMap[code] = ''
869 773 // }
870   -
871 774 return /*#__PURE__*/React.createElement(_Tooltip, {
872 775 title: name
873 776 }, /*#__PURE__*/React.createElement(_Button, _extends({
... ... @@ -891,7 +794,8 @@ var VirtualList = function VirtualList(_ref) {
891 794 type: String(icon)
892 795 }) : BUTTON_ICONS_MAP[icon + ''] : null,
893 796 type: 'link',
894   - size: 'small' // disabled={props.originWidget === 'subform' ? false : handleAuth(record, code)}
  797 + size: 'small'
  798 + // disabled={props.originWidget === 'subform' ? false : handleAuth(record, code)}
895 799 ,
896 800 onClick: function onClick() {
897 801 // 已有数据进行操作时才二次提示
... ... @@ -933,12 +837,12 @@ var VirtualList = function VirtualList(_ref) {
933 837 }
934 838 }
935 839 }
936   - }), style !== 'ICON' || !icon ? name : null)); // }
  840 + }), style !== 'ICON' || !icon ? name : null));
  841 + // }
937 842 }) : null);
938 843 }
939 844 };
940 845 var actionLength = 0;
941   -
942 846 _line_buttons.forEach(function (item) {
943 847 if (props.originWidget === 'subform' || style === 'ICON' && item.icon) {
944 848 actionLength += 32;
... ... @@ -953,9 +857,7 @@ var VirtualList = function VirtualList(_ref) {
953 857 div.remove();
954 858 }
955 859 });
956   -
957 860 action.width = actionLength + padding * 2 - 8;
958   -
959 861 if ((_columns || []).findIndex(function (item) {
960 862 return item.key === '$action';
961 863 }) === -1 && len > 0 && action.title) {
... ... @@ -966,91 +868,73 @@ var VirtualList = function VirtualList(_ref) {
966 868 }
967 869 }
968 870 }
969   -
970 871 return _columns;
971 872 }, [isSubCanEdit, subReadOnly, JSON.stringify(line.buttons), deleteItem]);
972   -
973 873 var handleAuth = function handleAuth(record, code) {
974 874 switch (code) {
975 875 case 'VIEW':
976 876 return !record.VIEW_flag_;
977   -
978 877 case 'DELETE':
979 878 return !record.DELETE_flag_;
980   -
981 879 case 'EDIT':
982 880 return !record.EDIT_flag_;
983 881 }
984 882 };
985   -
986 883 var handleState = function handleState(record, code, originWidget) {
987 884 if (originWidget === 'subform') {
988 885 if (code === 'COPY' && !record.id) {
989 886 return 'none';
990 887 }
991   -
992 888 return '';
993 889 } else {
994 890 switch (code) {
995 891 case 'VIEW':
996 892 return record.VIEW_flag_ === true ? '' : 'none';
997   -
998 893 case 'DELETE':
999 894 return record.DELETE_flag_ === true ? '' : 'none';
1000   -
1001 895 case 'EDIT':
1002 896 return record.EDIT_flag_ === true ? '' : 'none';
1003   -
1004 897 case 'REMOVE':
1005 898 return '';
1006   -
1007 899 default:
1008 900 return record[code + '_flag_'] ? '' : 'none';
1009 901 }
1010 902 }
1011 903 };
1012   -
1013 904 var handleExport = /*#__PURE__*/function () {
1014   - var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
  905 + var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1015 906 var queryParams, currentAppCode, currentFunCode, appCode, funCode, fieldName, result;
1016   - return regeneratorRuntime.wrap(function _callee$(_context) {
1017   - while (1) {
1018   - switch (_context.prev = _context.next) {
1019   - case 0:
1020   - setProgressData({
1021   - "percent": 0,
1022   - "status": "PROCESSING"
1023   - });
1024   - queryParams = _defineProperty({
1025   - dataId: props.dataId
1026   - }, searchKey, keyWord);
1027   - currentAppCode = qxProps.currentAppCode, currentFunCode = qxProps.currentFunCode, appCode = qxProps.appCode, funCode = qxProps.funCode, fieldName = qxProps.fieldName;
1028   - _context.next = 5;
1029   - return props.exportChild(props.originWidget === 'subform' ? appCode : currentAppCode, props.originWidget === 'subform' ? funCode : currentFunCode, fieldName, queryParams);
1030   -
1031   - case 5:
1032   - result = _context.sent;
1033   - exportTaskId.current = result.taskId || '';
1034   -
1035   - if (result.downloadUrl) {
1036   - setTimeout(function () {
1037   - exportData(result.taskId);
1038   - }, 5000);
1039   - }
1040   -
1041   - case 8:
1042   - case "end":
1043   - return _context.stop();
1044   - }
  907 + return _regeneratorRuntime().wrap(function _callee$(_context) {
  908 + while (1) switch (_context.prev = _context.next) {
  909 + case 0:
  910 + setProgressData({
  911 + "percent": 0,
  912 + "status": "PROCESSING"
  913 + });
  914 + queryParams = _defineProperty({
  915 + dataId: props.dataId
  916 + }, searchKey, keyWord);
  917 + currentAppCode = qxProps.currentAppCode, currentFunCode = qxProps.currentFunCode, appCode = qxProps.appCode, funCode = qxProps.funCode, fieldName = qxProps.fieldName;
  918 + _context.next = 5;
  919 + return props.exportChild(props.originWidget === 'subform' ? appCode : currentAppCode, props.originWidget === 'subform' ? funCode : currentFunCode, fieldName, queryParams);
  920 + case 5:
  921 + result = _context.sent;
  922 + exportTaskId.current = result.taskId || '';
  923 + if (result.downloadUrl) {
  924 + setTimeout(function () {
  925 + exportData(result.taskId);
  926 + }, 5000);
  927 + }
  928 + case 8:
  929 + case "end":
  930 + return _context.stop();
1045 931 }
1046 932 }, _callee);
1047 933 }));
1048   -
1049 934 return function handleExport() {
1050 935 return _ref2.apply(this, arguments);
1051 936 };
1052 937 }();
1053   -
1054 938 var exportData = function exportData(taskId) {
1055 939 // const {appCode, funCode, viewCode} = qxProps
1056 940 // taskType: UPLOAD || EXPORT
... ... @@ -1059,7 +943,6 @@ var VirtualList = function VirtualList(_ref) {
1059 943 setProgressData(res || null);
1060 944 });
1061 945 };
1062   -
1063 946 useEffect(function () {
1064 947 if (exportProgressData) {
1065 948 if (exportProgressData.status === 'PROCESSING' && !intervalName) {
... ... @@ -1068,13 +951,11 @@ var VirtualList = function VirtualList(_ref) {
1068 951 }, 1000 * 10));
1069 952 return;
1070 953 }
1071   -
1072 954 if (exportProgressData.status !== 'PROCESSING' && intervalName) {
1073 955 clearInterval(intervalName);
1074 956 return;
1075 957 }
1076 958 }
1077   -
1078 959 return function () {
1079 960 if (intervalName) {
1080 961 setTimeout(function () {
... ... @@ -1083,22 +964,19 @@ var VirtualList = function VirtualList(_ref) {
1083 964 }
1084 965 };
1085 966 }, [exportProgressData]);
1086   -
1087 967 var handleCloseExport = function handleCloseExport(taskId) {
1088 968 var appCode = qxProps.appCode,
1089   - funCode = qxProps.funCode,
1090   - viewCode = qxProps.viewCode;
  969 + funCode = qxProps.funCode,
  970 + viewCode = qxProps.viewCode;
1091 971 props.closeExport(appCode, funCode, viewCode, {
1092 972 taskId: taskId
1093 973 }).then(function (res) {
1094 974 setProgressData(null);
1095   -
1096 975 if (intervalName) {
1097 976 clearInterval(intervalName);
1098 977 }
1099 978 });
1100 979 };
1101   -
1102 980 var getExportMessage = function getExportMessage() {
1103 981 if (exportProgressData.status === 'SUCCESS') {
1104 982 return /*#__PURE__*/React.createElement("div", null, "\u5BFC\u51FA\u6210\u529F\uFF0C\u70B9\u51FB", /*#__PURE__*/React.createElement(_Button, {
... ... @@ -1116,7 +994,6 @@ var VirtualList = function VirtualList(_ref) {
1116 994 type: 'link'
1117 995 }, "\u3010\u5173\u95ED\u63D0\u9192\u3011"));
1118 996 }
1119   -
1120 997 return /*#__PURE__*/React.createElement("div", null, "\u5BFC\u51FA\u8FDB\u884C\u4E2D\uFF0C\u8BF7\u7A0D\u540E......", /*#__PURE__*/React.createElement(_Button, {
1121 998 onClick: function onClick() {
1122 999 return exportData('');
... ... @@ -1132,23 +1009,18 @@ var VirtualList = function VirtualList(_ref) {
1132 1009 type: 'link'
1133 1010 }, "\u3010\u5173\u95ED\u63D0\u9192\u3011"));
1134 1011 };
1135   -
1136 1012 var cancelSubEdit = function cancelSubEdit() {
1137 1013 setSubEdit(false);
1138 1014 };
1139   -
1140 1015 var submitSubEdit = function submitSubEdit() {
1141 1016 setSubEdit(false);
1142 1017 };
1143   -
1144 1018 var barBtnClick = function barBtnClick(code, needConfirm, confirmContent, action, item) {
1145 1019 setSelectedRowKeys([]);
1146   -
1147 1020 if (needConfirm && confirmContent) {
1148 1021 if (!selectedRowKeys.length) {
1149 1022 return _message.warning('请选择数据');
1150 1023 }
1151   -
1152 1024 confirm({
1153 1025 title: confirmContent,
1154 1026 icon: /*#__PURE__*/React.createElement(_ExclamationCircleOutlined, null),
... ... @@ -1202,7 +1074,6 @@ var VirtualList = function VirtualList(_ref) {
1202 1074 }
1203 1075 }
1204 1076 };
1205   -
1206 1077 return /*#__PURE__*/React.createElement("div", null, props.editable ? isSubCanEdit ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Button, {
1207 1078 type: 'text',
1208 1079 size: "small",
... ... @@ -1245,18 +1116,17 @@ var VirtualList = function VirtualList(_ref) {
1245 1116 }),
1246 1117 onChange: function onChange(e) {
1247 1118 var _e$target;
1248   -
1249 1119 setKeyWord(((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value) || '');
1250 1120 }
1251 1121 }) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement("div", null, (barButtons.length > 4 ? barButtons.slice(0, 3) : barButtons.slice(0, 4)).filter(function (item) {
1252 1122 return isInDing ? !['EXPORT', 'IMPORT'].includes(item.code) : true;
1253 1123 }).map(function (item) {
1254 1124 var name = item.name,
1255   - code = item.code,
1256   - needConfirm = item.needConfirm,
1257   - confirmContent = item.confirmContent,
1258   - icon = item.icon,
1259   - action = item.action;
  1125 + code = item.code,
  1126 + needConfirm = item.needConfirm,
  1127 + confirmContent = item.confirmContent,
  1128 + icon = item.icon,
  1129 + action = item.action;
1260 1130 return /*#__PURE__*/React.createElement(_Button, _extends({
1261 1131 key: code,
1262 1132 style: {
... ... @@ -1279,7 +1149,8 @@ var VirtualList = function VirtualList(_ref) {
1279 1149 onClick: function onClick() {
1280 1150 barBtnClick(code, needConfirm, confirmContent, action, item);
1281 1151 }
1282   - }), name); // }
  1152 + }), name);
  1153 + // }
1283 1154 }), barButtons.slice(4).length ? /*#__PURE__*/React.createElement(_Dropdown, {
1284 1155 overlay: moreButtons
1285 1156 }, /*#__PURE__*/React.createElement(_Button, {
... ... @@ -1288,11 +1159,9 @@ var VirtualList = function VirtualList(_ref) {
1288 1159 }
1289 1160 }, /*#__PURE__*/React.createElement(_Space, null, "\u66F4\u591A\u64CD\u4F5C", /*#__PURE__*/React.createElement(_DownOutlined, null)))) : null), Array.isArray(props.buttons) ? props.buttons.map(function (item, idx) {
1290 1161 var callback = item.callback,
1291   - text = item.text,
1292   - html = item.html;
1293   -
  1162 + text = item.text,
  1163 + html = item.html;
1294 1164 var onClick = function onClick() {};
1295   -
1296 1165 if (typeof window[callback] === 'function') {
1297 1166 onClick = function onClick() {
1298 1167 window[callback]({
... ... @@ -1310,7 +1179,6 @@ var VirtualList = function VirtualList(_ref) {
1310 1179 });
1311 1180 }
1312 1181 }
1313   -
1314 1182 return /*#__PURE__*/React.createElement(_Button, {
1315 1183 key: idx.toString(),
1316 1184 style: {
... ... @@ -1342,7 +1210,8 @@ var VirtualList = function VirtualList(_ref) {
1342 1210 x: '100%'
1343 1211 }, !isFullScreen && {
1344 1212 y: scrollY
1345   - }) // components={vt}
  1213 + })
  1214 + // components={vt}
1346 1215 ,
1347 1216 size: size || 'small'
1348 1217 }, props.originWidget === 'relSelector' ? {
... ... @@ -1350,14 +1219,14 @@ var VirtualList = function VirtualList(_ref) {
1350 1219 } : {}, {
1351 1220 columns: columns,
1352 1221 dataSource: dataSource,
1353   - pagination: pagination // style={{marginBottom: 25}}
  1222 + pagination: pagination
  1223 + // style={{marginBottom: 25}}
1354 1224 ,
1355 1225 rowSelection: newRowSelection,
1356 1226 summary: function summary() {
1357 1227 if (!_summary || Array.isArray(_summary) && !_summary.length) {
1358 1228 return null;
1359 1229 }
1360   -
1361 1230 return _summary(listData);
1362 1231 }
1363 1232 }, rest)), !props.hideAdd && props.originWidget === 'subform' && !subReadOnly && /*#__PURE__*/React.createElement(_Button, {
... ... @@ -1368,6 +1237,7 @@ var VirtualList = function VirtualList(_ref) {
1368 1237 }
1369 1238 }, "\u65B0\u589E"));
1370 1239 };
  1240 +
1371 1241 /**
1372 1242 * 文件下载。依赖HTML页面
1373 1243 *
... ... @@ -1375,86 +1245,76 @@ var VirtualList = function VirtualList(_ref) {
1375 1245 * @param name 指定的文件名(包括扩展名)
1376 1246 * @param request
1377 1247 */
1378   -
1379   -
1380   -function handleDownload(_x, _x2, _x3) {
  1248 +function handleDownload(_x2, _x3, _x4) {
1381 1249 return _handleDownload.apply(this, arguments);
1382 1250 }
1383   -
1384 1251 function _handleDownload() {
1385   - _handleDownload = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(url, name, request) {
  1252 + _handleDownload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url, name, request) {
1386 1253 var isDownload,
1387   - link,
1388   - blob,
1389   - downloadUrl,
1390   - _args2 = arguments;
1391   - return regeneratorRuntime.wrap(function _callee2$(_context2) {
1392   - while (1) {
1393   - switch (_context2.prev = _context2.next) {
1394   - case 0:
1395   - // eslint-disable-next-line prefer-rest-params
1396   - isDownload = _args2[3];
1397   -
1398   - if (isDownload === null || Boolean(isDownload)) {
1399   - _message.warning('即将开始下载,请勿重复点击。');
1400   - } // console.log('url========', url);
1401   - // const isInDing = dd && dd?.env?.platform !== 'notInDingTalk';
1402   - // if (isInDing) {
1403   - // // 比如导出 导入
1404   - // const needToken = !(url.includes('http://') || url.includes('https://'));
1405   - // let dingUrl;
1406   - // if (needToken) {
1407   - // const apiUri = process.env.apiUrl || '';
1408   - // const needConcat = !(apiUri.includes('http://') || apiUri.includes('https://')); // 打包后
1409   - // const prev = `${needConcat ? location.origin : ''}${apiUri}${url}`;
1410   - // const append = `_token=${QIXIAO_TOKEN}${isDesignPage() ? '&_bizCode=design' : ''}`;
1411   - // dingUrl = `${prev}${prev.includes('?') ? '&' : '?'}${append}`; // 文件服务器 不能加参数
1412   - // } else {
1413   - // dingUrl = url;
1414   - // }
1415   - // console.log('dingUrl========', dingUrl);
1416   - // const fileName = name || '下载文件';
1417   - // dd.biz.util.downloadFile({
1418   - // url: dingUrl,
1419   - // name: fileName,
1420   - // onFail: function () {
1421   - // message.error(`${fileName} 文件下载失败`);
1422   - // },
1423   - // });
1424   - // return;
1425   - // }
1426   -
1427   -
1428   - link = document.createElement('a');
1429   - link.href = url;
1430   - link.download = name;
1431   - link.target = '_blank';
1432   - document.body.appendChild(link); //TODO 文件过大时,看不到下载进度
1433   -
1434   - _context2.next = 9;
1435   - return request.get(url, {
1436   - autoShowError: true
1437   - });
1438   -
1439   - case 9:
1440   - blob = _context2.sent;
1441   -
1442   - if (blob !== null) {
1443   - downloadUrl = URL.createObjectURL(blob);
1444   - link.href = downloadUrl;
1445   - link.click();
1446   - document.body.removeChild(link);
1447   - URL.revokeObjectURL(downloadUrl);
1448   - }
1449   -
1450   - case 11:
1451   - case "end":
1452   - return _context2.stop();
1453   - }
  1254 + link,
  1255 + blob,
  1256 + downloadUrl,
  1257 + _args2 = arguments;
  1258 + return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  1259 + while (1) switch (_context2.prev = _context2.next) {
  1260 + case 0:
  1261 + // eslint-disable-next-line prefer-rest-params
  1262 + isDownload = _args2[3];
  1263 + if (isDownload === null || Boolean(isDownload)) {
  1264 + _message.warning('即将开始下载,请勿重复点击。');
  1265 + }
  1266 + // console.log('url========', url);
  1267 + // const isInDing = dd && dd?.env?.platform !== 'notInDingTalk';
  1268 + // if (isInDing) {
  1269 + // // 比如导出 导入
  1270 + // const needToken = !(url.includes('http://') || url.includes('https://'));
  1271 + // let dingUrl;
  1272 + // if (needToken) {
  1273 + // const apiUri = process.env.apiUrl || '';
  1274 + // const needConcat = !(apiUri.includes('http://') || apiUri.includes('https://')); // 打包后
  1275 + // const prev = `${needConcat ? location.origin : ''}${apiUri}${url}`;
  1276 + // const append = `_token=${QIXIAO_TOKEN}${isDesignPage() ? '&_bizCode=design' : ''}`;
  1277 + // dingUrl = `${prev}${prev.includes('?') ? '&' : '?'}${append}`; // 文件服务器 不能加参数
  1278 + // } else {
  1279 + // dingUrl = url;
  1280 + // }
  1281 + // console.log('dingUrl========', dingUrl);
  1282 + // const fileName = name || '下载文件';
  1283 + // dd.biz.util.downloadFile({
  1284 + // url: dingUrl,
  1285 + // name: fileName,
  1286 + // onFail: function () {
  1287 + // message.error(`${fileName} 文件下载失败`);
  1288 + // },
  1289 + // });
  1290 + // return;
  1291 + // }
  1292 + link = document.createElement('a');
  1293 + link.href = url;
  1294 + link.download = name;
  1295 + link.target = '_blank';
  1296 + document.body.appendChild(link);
  1297 +
  1298 + //TODO 文件过大时,看不到下载进度
  1299 + _context2.next = 9;
  1300 + return request.get(url, {
  1301 + autoShowError: true
  1302 + });
  1303 + case 9:
  1304 + blob = _context2.sent;
  1305 + if (blob !== null) {
  1306 + downloadUrl = URL.createObjectURL(blob);
  1307 + link.href = downloadUrl;
  1308 + link.click();
  1309 + document.body.removeChild(link);
  1310 + URL.revokeObjectURL(downloadUrl);
  1311 + }
  1312 + case 11:
  1313 + case "end":
  1314 + return _context2.stop();
1454 1315 }
1455 1316 }, _callee2);
1456 1317 }));
1457 1318 return _handleDownload.apply(this, arguments);
1458 1319 }
1459   -
1460 1320 export default VirtualList;
\ No newline at end of file
... ...
1 1 import { createFromIconfontCN } from '@ant-design/icons/lib';
  2 +
2 3 /**
3 4 * 使用:
4 5 * import QxIcon from '@/packages/qx-icon';
... ... @@ -10,7 +11,6 @@ import { createFromIconfontCN } from '@ant-design/icons/lib';
10 11 *
11 12 * @type {React.FC<IconFontProps<string>>}
12 13 */
13   -
14 14 var QxIcon = createFromIconfontCN({
15 15 scriptUrl: 'https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_13749_95.b05de9dc2fbe8efffb150f83b64da806.es5.js'
16 16 });
... ...
  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); }
1 2 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2   -
3 3 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."); }
4   -
5 4 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); }
6   -
7 5 function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8   -
9 6 function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10   -
11   -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; }
12   -
13   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14   -
15   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16   -
17   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18   -
  7 +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; }
  8 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  9 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  10 +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; }
  11 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  12 +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); }
19 13 /* eslint-disable jsx-a11y/anchor-is-valid */
20 14 import React from 'react';
21 15 import { cloneDeep, get, isFunction } from 'lodash-es';
... ... @@ -29,58 +23,46 @@ import TableList from './TableList';
29 23 import TabList from './TabList';
30 24 import VirtualList from './VirtualList';
31 25 import ListForMobile from "./ListForMobile";
32   -
33 26 var RenderList = function RenderList(_ref) {
34 27 var parentId = _ref.parentId,
35   - _ref$schema = _ref.schema,
36   - schema = _ref$schema === void 0 ? {} : _ref$schema,
37   - _ref$dataIndex = _ref.dataIndex,
38   - dataIndex = _ref$dataIndex === void 0 ? [] : _ref$dataIndex,
39   - _ref$children = _ref.children,
40   - children = _ref$children === void 0 ? [] : _ref$children,
41   - errorFields = _ref.errorFields,
42   - displayType = _ref.displayType;
43   -
  28 + _ref$schema = _ref.schema,
  29 + schema = _ref$schema === void 0 ? {} : _ref$schema,
  30 + _ref$dataIndex = _ref.dataIndex,
  31 + dataIndex = _ref$dataIndex === void 0 ? [] : _ref$dataIndex,
  32 + _ref$children = _ref.children,
  33 + children = _ref$children === void 0 ? [] : _ref$children,
  34 + errorFields = _ref.errorFields,
  35 + displayType = _ref.displayType;
44 36 var _useStore = useStore(),
45   - formData = _useStore.formData,
46   - flatten = _useStore.flatten;
47   -
  37 + formData = _useStore.formData,
  38 + flatten = _useStore.flatten;
48 39 var _useTools = useTools(),
49   - onItemChange = _useTools.onItemChange,
50   - removeTouched = _useTools.removeTouched,
51   - methods = _useTools.methods,
52   - layoutWidgets = _useTools.layoutWidgets;
53   -
  40 + onItemChange = _useTools.onItemChange,
  41 + removeTouched = _useTools.removeTouched,
  42 + methods = _useTools.methods,
  43 + layoutWidgets = _useTools.layoutWidgets;
54 44 var _schema$props = schema.props,
55   - props = _schema$props === void 0 ? {} : _schema$props;
  45 + props = _schema$props === void 0 ? {} : _schema$props;
56 46 var renderWidget = 'list';
57   -
58 47 try {
59 48 renderWidget = schema.widget;
60   - } catch (error) {} // 计算 list对应的formData
61   -
  49 + } catch (error) {}
62 50
  51 + // 计算 list对应的formData
63 52 var dataPath = getDataPath(parentId, dataIndex);
64 53 var listData;
65   -
66 54 if (typeof dataPath === 'string') {
67 55 // TODO: listData会有不少“窟窿”,submit 的时候,listData 需要补齐 or filter
68 56 listData = get(formData, dataPath);
69 57 }
70   -
71 58 var displayList = Array.isArray(listData) && JSON.stringify(listData) !== '[{}]' ? listData : [];
72   -
73 59 var changeList = function changeList(newList) {
74 60 onItemChange(dataPath, newList);
75 61 };
76   -
77 62 var addItem = function addItem() {
78 63 var _item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
79   -
80 64 var _schema = getSchemaFromFlatten(flatten, parentId);
81   -
82 65 var newItem = _objectSpread(_objectSpread({}, generateDataSkeleton(_schema.items) || {}), _item);
83   -
84 66 var newList = [].concat(_toConsumableArray(displayList), [_objectSpread(_objectSpread({}, newItem), {}, {
85 67 _active: true
86 68 })]);
... ... @@ -88,14 +70,12 @@ var RenderList = function RenderList(_ref) {
88 70 onItemChange(dataPath, newList);
89 71 return newIndex;
90 72 };
91   -
92 73 var copyItem = function copyItem(idx) {
93 74 var newItem = cloneDeep(displayList[idx]);
94 75 delete newItem.id;
95 76 var newList = [].concat(_toConsumableArray(displayList.slice(0, idx + 1)), [newItem], _toConsumableArray(displayList.slice(idx + 1)));
96 77 onItemChange(dataPath, JSON.parse(JSON.stringify(newList)));
97 78 };
98   -
99 79 var deleteItem = function deleteItem(idx) {
100 80 // TODO: 删除元素的时候,也需要delete相对于的校验信息(errorFields)
101 81 // remark: 删除时,不存在的item需要补齐,用null
... ... @@ -108,18 +88,16 @@ var RenderList = function RenderList(_ref) {
108 88 onItemChange(dataPath, newList);
109 89 removeTouched("".concat(dataPath, "[").concat(idx, "]"));
110 90 };
111   -
112 91 var handleMoving = function handleMoving() {
113 92 if (props.onMove && typeof props.onMove === 'string') {
114 93 var cb = methods[props.onMove];
115   -
116 94 if (typeof cb === 'function') {
117 95 cb();
118 96 }
119 97 }
120   - }; // 批量删除的方法
121   -
  98 + };
122 99
  100 + // 批量删除的方法
123 101 var batchDelete = function batchDelete(ids) {
124 102 displayList.forEach(function (item) {
125 103 return delete item.orginIdx;
... ... @@ -131,9 +109,9 @@ var RenderList = function RenderList(_ref) {
131 109 (ids || []).forEach(function (id) {
132 110 removeTouched("".concat(dataPath, "[").concat(id, "]"));
133 111 });
134   - }; //TODO1: 上线翻页要正确!!现在是错的
135   -
  112 + };
136 113
  114 + //TODO1: 上线翻页要正确!!现在是错的
137 115 var moveItemUp = function moveItemUp(idx) {
138 116 handleMoving();
139 117 if (idx === 0) return;
... ... @@ -142,11 +120,10 @@ var RenderList = function RenderList(_ref) {
142 120 var newList = displayList;
143 121 newList[idx] = itemAbove;
144 122 newList[idx - 1] = currentItem;
145   - onItemChange(dataPath, newList); // TODO: 这块懒了,之后要处理一下
146   -
  123 + onItemChange(dataPath, newList);
  124 + // TODO: 这块懒了,之后要处理一下
147 125 removeTouched("".concat(dataPath, "[").concat(idx, "]"));
148 126 };
149   -
150 127 var moveItemDown = function moveItemDown(idx) {
151 128 handleMoving();
152 129 if (idx >= displayList.length - 1) return;
... ... @@ -155,11 +132,10 @@ var RenderList = function RenderList(_ref) {
155 132 var newList = displayList;
156 133 newList[idx] = itemBelow;
157 134 newList[idx + 1] = currentItem;
158   - onItemChange(dataPath, newList); // TODO: 这块懒了,之后要处理一下
159   -
  135 + onItemChange(dataPath, newList);
  136 + // TODO: 这块懒了,之后要处理一下
160 137 removeTouched("".concat(dataPath, "[").concat(idx, "]"));
161 138 };
162   -
163 139 var itemSchema = {
164 140 type: 'object',
165 141 properties: {},
... ... @@ -170,14 +146,12 @@ var RenderList = function RenderList(_ref) {
170 146 schema: itemSchema,
171 147 children: children
172 148 };
173   -
174 149 var getFieldsProps = function getFieldsProps(idx, extraProps) {
175 150 return _objectSpread({
176 151 _item: itemFlatten,
177 152 dataIndex: [].concat(_toConsumableArray(dataIndex), [idx])
178 153 }, extraProps);
179 154 };
180   -
181 155 var displayProps = {
182 156 displayList: displayList,
183 157 changeList: changeList,
... ... @@ -196,10 +170,9 @@ var RenderList = function RenderList(_ref) {
196 170 errorFields: errorFields,
197 171 displayType: displayType,
198 172 getFieldsProps: getFieldsProps
199   - }; // 外部定义:添加按钮事件
200   -
  173 + };
  174 + // 外部定义:添加按钮事件
201 175 var onAdd = methods[props.onAdd];
202   -
203 176 if (isFunction(onAdd)) {
204 177 displayProps.addItem = function () {
205 178 return onAdd(function (_item) {
... ... @@ -209,41 +182,32 @@ var RenderList = function RenderList(_ref) {
209 182 });
210 183 };
211 184 }
212   -
213 185 if (renderWidget === 'listForMobile') {
214 186 return /*#__PURE__*/React.createElement(ListForMobile, displayProps);
215 187 }
216   -
217 188 if (layoutWidgets && layoutWidgets[renderWidget]) {
218 189 var Component = layoutWidgets[renderWidget];
219 190 return /*#__PURE__*/React.createElement(Component, displayProps);
220 191 }
221   -
222 192 switch (renderWidget) {
223 193 case 'list1':
224 194 case 'simpleList':
225 195 return /*#__PURE__*/React.createElement(SimpleList, displayProps);
226   -
227 196 case 'list2':
228 197 case 'tableList':
229 198 return /*#__PURE__*/React.createElement(TableList, displayProps);
230   -
231 199 case 'list3':
232 200 case 'drawerList':
233 201 return /*#__PURE__*/React.createElement(DrawerList, displayProps);
234   -
235 202 case 'list4':
236 203 case 'virtualList':
237 204 return /*#__PURE__*/React.createElement(VirtualList, displayProps);
238   -
239 205 case 'tabList':
240 206 return /*#__PURE__*/React.createElement(TabList, displayProps);
241   -
242 207 case 'list0':
243 208 case 'cardList':
244 209 default:
245 210 return /*#__PURE__*/React.createElement(CardList, displayProps);
246 211 }
247 212 };
248   -
249 213 export default RenderList;
\ No newline at end of file
... ...
1 1 export function isDesignPage() {
2 2 var href = location.href;
3 3 var res = false;
4   -
5 4 if (href.indexOf('/app-view/') > -1) {
6 5 res = true;
7 6 } else if (href.indexOf('/apps/design') > -1) {
... ... @@ -33,6 +32,5 @@ export function isDesignPage() {
33 32 } else if (href.indexOf('/datacube/design') > -1) {
34 33 res = true;
35 34 }
36   -
37 35 return res;
38 36 }
\ No newline at end of file
... ...
1   -function _extends() { _extends = Object.assign || 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   -
  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); }
3 2 import React from 'react';
4 3 import Core from '../index';
5   -
6 4 var RenderObject = function RenderObject(_ref) {
7 5 var _ref$children = _ref.children,
8   - children = _ref$children === void 0 ? [] : _ref$children,
9   - _ref$dataIndex = _ref.dataIndex,
10   - dataIndex = _ref$dataIndex === void 0 ? [] : _ref$dataIndex,
11   - displayType = _ref.displayType,
12   - labelAlign = _ref.labelAlign,
13   - hideTitle = _ref.hideTitle;
  6 + children = _ref$children === void 0 ? [] : _ref$children,
  7 + _ref$dataIndex = _ref.dataIndex,
  8 + dataIndex = _ref$dataIndex === void 0 ? [] : _ref$dataIndex,
  9 + displayType = _ref.displayType,
  10 + labelAlign = _ref.labelAlign,
  11 + hideTitle = _ref.hideTitle;
14 12 return /*#__PURE__*/React.createElement(React.Fragment, null, children.map(function (child, i) {
15 13 var FRProps = {
16 14 displayType: displayType,
... ... @@ -24,5 +22,4 @@ var RenderObject = function RenderObject(_ref) {
24 22 }, FRProps));
25 23 }));
26 24 };
27   -
28 25 export default RenderObject;
\ No newline at end of file
... ...
1 1 import React from 'react';
2 2 import { translateMessage } from '../../utils';
3 3 import "./ErrorMessage.css";
4   -
5 4 var ErrorMessage = function ErrorMessage(_ref) {
6 5 var message = _ref.message,
7   - schema = _ref.schema,
8   - softHidden = _ref.softHidden,
9   - hardHidden = _ref.hardHidden;
  6 + schema = _ref.schema,
  7 + softHidden = _ref.softHidden,
  8 + hardHidden = _ref.hardHidden;
10 9 var msg = '';
11 10 if (typeof message === 'string') msg = message;
12   -
13 11 if (Array.isArray(message)) {
14 12 msg = message[0] || '';
15 13 }
  14 + msg = translateMessage(msg, schema);
16 15
17   - msg = translateMessage(msg, schema); // 无错误信息不渲染 msg 元素占位,表单之间的间隔通过 field-block 元素分隔
18   -
  16 + // 无错误信息不渲染 msg 元素占位,表单之间的间隔通过 field-block 元素分隔
19 17 if (!msg) return null;
20 18 if (hardHidden) return /*#__PURE__*/React.createElement("div", {
21 19 className: "error-message"
... ... @@ -24,5 +22,4 @@ var ErrorMessage = function ErrorMessage(_ref) {
24 22 className: "error-message"
25 23 }, msg);
26 24 };
27   -
28 25 export default ErrorMessage;
\ No newline at end of file
... ...
1   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2   -
3   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4   -
5   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6   -
  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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  3 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  6 +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); }
7 7 import React, { Suspense } from 'react';
8 8 import { transformProps } from '../../createWidget';
9 9 import { useStore, useTools } from '../../hooks';
10 10 import { extraSchemaList, getWidgetName } from '../../mapping';
11 11 import { isListType, isObject, isObjType } from '../../utils';
12   -
13 12 var ErrorSchema = function ErrorSchema(schema) {
14 13 return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
15 14 style: {
... ... @@ -17,81 +16,74 @@ var ErrorSchema = function ErrorSchema(schema) {
17 16 }
18 17 }, "schema\u672A\u5339\u914D\u5230\u5C55\u793A\u7EC4\u4EF6\uFF1A"), /*#__PURE__*/React.createElement("div", null, JSON.stringify(schema)));
19 18 };
20   -
21 19 var ExtendedWidget = function ExtendedWidget(_ref) {
22 20 var schema = _ref.schema,
23   - onChange = _ref.onChange,
24   - value = _ref.value,
25   - dependValues = _ref.dependValues,
26   - children = _ref.children,
27   - onItemChange = _ref.onItemChange,
28   - formData = _ref.formData,
29   - getValue = _ref.getValue,
30   - readOnly = _ref.readOnly,
31   - dataPath = _ref.dataPath,
32   - disabled = _ref.disabled,
33   - dataIndex = _ref.dataIndex,
34   - watch = _ref.watch,
35   - hasError = _ref.hasError;
36   -
  21 + onChange = _ref.onChange,
  22 + value = _ref.value,
  23 + dependValues = _ref.dependValues,
  24 + children = _ref.children,
  25 + onItemChange = _ref.onItemChange,
  26 + formData = _ref.formData,
  27 + getValue = _ref.getValue,
  28 + readOnly = _ref.readOnly,
  29 + dataPath = _ref.dataPath,
  30 + disabled = _ref.disabled,
  31 + dataIndex = _ref.dataIndex,
  32 + watch = _ref.watch,
  33 + hasError = _ref.hasError;
37 34 var _useTools = useTools(),
38   - widgets = _useTools.widgets,
39   - mapping = _useTools.mapping,
40   - setValueByPath = _useTools.setValueByPath,
41   - getSchemaByPath = _useTools.getSchemaByPath,
42   - setSchemaByPath = _useTools.setSchemaByPath,
43   - setSchema = _useTools.setSchema,
44   - setValues = _useTools.setValues,
45   - getValues = _useTools.getValues,
46   - resetFields = _useTools.resetFields,
47   - setErrorFields = _useTools.setErrorFields,
48   - removeErrorField = _useTools.removeErrorField,
49   - validateFields = _useTools.validateFields,
50   - isFieldTouched = _useTools.isFieldTouched,
51   - isFieldsTouched = _useTools.isFieldsTouched,
52   - isFieldValidating = _useTools.isFieldValidating,
53   - scrollToPath = _useTools.scrollToPath,
54   - getFieldError = _useTools.getFieldError,
55   - getFieldsError = _useTools.getFieldsError,
56   - setFields = _useTools.setFields;
57   -
  35 + widgets = _useTools.widgets,
  36 + mapping = _useTools.mapping,
  37 + setValueByPath = _useTools.setValueByPath,
  38 + getSchemaByPath = _useTools.getSchemaByPath,
  39 + setSchemaByPath = _useTools.setSchemaByPath,
  40 + setSchema = _useTools.setSchema,
  41 + setValues = _useTools.setValues,
  42 + getValues = _useTools.getValues,
  43 + resetFields = _useTools.resetFields,
  44 + setErrorFields = _useTools.setErrorFields,
  45 + removeErrorField = _useTools.removeErrorField,
  46 + validateFields = _useTools.validateFields,
  47 + isFieldTouched = _useTools.isFieldTouched,
  48 + isFieldsTouched = _useTools.isFieldsTouched,
  49 + isFieldValidating = _useTools.isFieldValidating,
  50 + scrollToPath = _useTools.scrollToPath,
  51 + getFieldError = _useTools.getFieldError,
  52 + getFieldsError = _useTools.getFieldsError,
  53 + setFields = _useTools.setFields;
58 54 var _useStore = useStore(),
59   - globalProps = _useStore.globalProps; // if (isObjType(schema)) {
  55 + globalProps = _useStore.globalProps;
  56 +
  57 + // if (isObjType(schema)) {
60 58 // return <Map value={value} onChange={onChange} children={children} />;
61 59 // }
62 60 // if (isListType(schema)) {
63 61 // return 'haha';
64 62 // }
65 63 // return <Input value={value} onChange={e => onChange(e.target.value)} />;
  64 +
66 65 // TODO: calc widget, better way?
67 66 // let widgetName = useMemo(() => getWidgetName(schema, mapping), [
68 67 // JSON.stringify(schema),
69 68 // ]);
70   -
71   -
72 69 var widgetName = getWidgetName(schema, mapping);
73 70 var customName = schema.widget || schema['ui:widget'];
74   -
75 71 if (customName && widgets[customName]) {
76 72 widgetName = customName;
77 73 }
78   -
79 74 var readOnlyName = schema.readOnlyWidget || 'html';
80   -
81 75 if (readOnly && !isObjType(schema) && !isListType(schema)) {
82 76 widgetName = readOnlyName;
83 77 }
84   -
85 78 if (!widgetName) {
86 79 widgetName = 'input';
87 80 return /*#__PURE__*/React.createElement(ErrorSchema, {
88 81 schema: schema
89 82 });
90 83 }
91   -
92 84 var Widget = widgets[widgetName] || widgets['html'];
93   - var extraSchema = extraSchemaList[widgetName]; // console.log(hasError, '----------');
94   -
  85 + var extraSchema = extraSchemaList[widgetName];
  86 + // console.log(hasError, '----------');
95 87 var widgetProps = _objectSpread(_objectSpread({
96 88 schema: _objectSpread(_objectSpread({}, schema), extraSchema),
97 89 onChange: onChange,
... ... @@ -103,40 +95,36 @@ var ExtendedWidget = function ExtendedWidget(_ref) {
103 95 // dataIndex,
104 96 className: hasError ? 'fr-item-status-error' : ''
105 97 }, schema.props), globalProps);
106   -
107 98 if (schema.type === 'string' && typeof schema.max === 'number') {
108 99 widgetProps.maxLength = schema.max;
109 100 }
110   -
111 101 ['title', 'placeholder', 'disabled', 'format'].forEach(function (key) {
112 102 if (schema[key]) {
113 103 widgetProps[key] = schema[key];
114 104 }
115 105 });
116   -
117 106 if (schema.props) {
118 107 widgetProps = _objectSpread(_objectSpread({}, widgetProps), schema.props);
119 108 }
120   -
121 109 Object.keys(schema).forEach(function (key) {
122 110 if (typeof key === 'string' && key.toLowerCase().indexOf('props') > -1 && key.length > 5) {
123 111 widgetProps[key] = schema[key];
124 112 }
125   - }); // 支持 addonAfter 为自定义组件的情况
  113 + });
126 114
  115 + // 支持 addonAfter 为自定义组件的情况
127 116 if (isObject(widgetProps.addonAfter) && widgetProps.addonAfter.widget) {
128 117 var AddonAfterWidget = widgets[widgetProps.addonAfter.widget];
129 118 widgetProps.addonAfter = /*#__PURE__*/React.createElement(AddonAfterWidget, schema);
130 119 }
131   -
132 120 var hideSelf = function hideSelf() {
133 121 var hidden = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
134 122 setSchemaByPath(schema.$id, {
135 123 hidden: hidden
136 124 });
137   - }; // 避免传组件不接受的props,按情况传多余的props
138   -
  125 + };
139 126
  127 + // 避免传组件不接受的props,按情况传多余的props
140 128 widgetProps.addons = {
141 129 dependValues: dependValues,
142 130 onItemChange: onItemChange,
... ... @@ -172,12 +160,10 @@ var ExtendedWidget = function ExtendedWidget(_ref) {
172 160 className: "fr-item-wrapper"
173 161 }, /*#__PURE__*/React.createElement(Widget, finalProps)));
174 162 };
175   -
176 163 function getValue(_data, key) {
177 164 if (!key) {
178 165 return null;
179 166 }
180   -
181 167 var keys = key.split('.');
182 168 return keys.reduce(function (prev, cur) {
183 169 if (cur === keys[keys.length - 1]) {
... ... @@ -187,48 +173,39 @@ function getValue(_data, key) {
187 173 }
188 174 }, _data);
189 175 }
190   -
191 176 var areEqual = function areEqual(prev, current) {
192 177 var _prev$schema, _prev$schema$props;
193   -
194 178 if (prev.schema && current.schema) {
195 179 if (prev.schema.$id === '#') {
196 180 return false;
197   - } // if (prev.schema.hidden && current.schema.hidden) {
  181 + }
  182 + // if (prev.schema.hidden && current.schema.hidden) {
198 183 // return true;
199 184 // }
200   -
201 185 }
202 186
203 187 if (prev.readOnly !== current.readOnly) {
204 188 return false;
205 189 }
206   -
207 190 if (prev.hasError !== current.hasError) {
208 191 return false;
209 192 }
210   -
211 193 if (prev.disabled !== current.disabled) {
212 194 return false;
213 195 }
214   -
215 196 if (JSON.stringify(prev.dependValues) !== JSON.stringify(current.dependValues)) {
216 197 return false;
217 198 }
218   -
219 199 if ((prev.schema.widget === 'virtualList' || prev.schema.widget === 'relSelector') && ((_prev$schema = prev.schema) === null || _prev$schema === void 0 ? void 0 : (_prev$schema$props = _prev$schema.props) === null || _prev$schema$props === void 0 ? void 0 : _prev$schema$props.mode) === 'TAG' && JSON.stringify(getValue(prev.formData, prev.schema.relformKey)) !== JSON.stringify(getValue(current.formData, current.schema.relformKey))) {
220 200 return false;
221 201 }
222   -
223 202 if (isObjType(prev.schema) && isObjType(current.schema)) {
224 203 return false;
225 204 }
226   -
227 205 if (JSON.stringify(prev.value) === JSON.stringify(current.value) && JSON.stringify(prev.schema) === JSON.stringify(current.schema)) {
228 206 return true;
229 207 }
230   -
231 208 return false;
232 209 };
233   -
234   -export default /*#__PURE__*/React.memo(ExtendedWidget, areEqual); // export default ExtendedWidget;
\ No newline at end of file
  210 +export default /*#__PURE__*/React.memo(ExtendedWidget, areEqual);
  211 +// export default ExtendedWidget;
\ No newline at end of file
... ...
1   -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2   -
  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); }
3 2 import React from 'react';
4 3 import { useTools } from '../../hooks';
5 4 import "./Extra.css";
6   -
7 5 var Extra = function Extra(_ref) {
8 6 var schema = _ref.schema;
9 7 var extra = schema.extra;
10   -
11 8 var _useTools = useTools(),
12   - widgets = _useTools.widgets;
13   -
14   - if (!extra) return null; // widget 这个api也可以不对外
  9 + widgets = _useTools.widgets;
  10 + if (!extra) return null;
15 11
  12 + // widget 这个api也可以不对外
16 13 var widgetName = extra.widget;
17 14 var Widget = widgets[widgetName];
18 15 if (Widget) return /*#__PURE__*/React.createElement(Widget, {
19 16 schema: schema
20 17 });
21 18 var __html = '';
22   -
23 19 if (typeof extra === 'string') {
24 20 __html = extra;
25   - } // 内部BU使用的口子,这个api不对外,也没有必要
26   -
27   -
  21 + }
  22 + // 内部BU使用的口子,这个api不对外,也没有必要
28 23 if (_typeof(extra) === 'object' && extra.text) {
29 24 __html = extra.text;
30 25 }
31   -
32 26 return __html && /*#__PURE__*/React.createElement("div", {
33 27 className: "fr-form-item-extra",
34 28 dangerouslySetInnerHTML: {
... ... @@ -36,5 +30,4 @@ var Extra = function Extra(_ref) {
36 30 }
37 31 });
38 32 };
39   -
40 33 export default Extra;
\ No newline at end of file
... ...
... ... @@ -3,56 +3,45 @@ import _Tooltip from "antd/es/tooltip";
3 3 import React from 'react';
4 4 import { useStore2, useTools } from '../../hooks';
5 5 import { isCheckBoxType } from '../../utils';
6   -
7 6 var Description = function Description(_ref) {
8 7 var displayType = _ref.displayType,
9   - schema = _ref.schema;
  8 + schema = _ref.schema;
10 9 var description = schema.description,
11   - descType = schema.descType,
12   - descWidget = schema.descWidget;
  10 + descType = schema.descType,
  11 + descWidget = schema.descWidget;
13 12 if (!description && !descWidget) return null;
14   -
15 13 var _useTools = useTools(),
16   - widgets = _useTools.widgets;
17   -
  14 + widgets = _useTools.widgets;
18 15 var _description = typeof description === 'string' && /(^<|\/>)/.test(description) ? /*#__PURE__*/React.createElement("div", {
19 16 dangerouslySetInnerHTML: {
20 17 __html: description
21 18 }
22 19 }) : description;
23   -
24 20 var RenderDesc = function RenderDesc() {
25 21 var Widget = widgets[schema.descWidget];
26   -
27 22 if (Widget) {
28 23 return /*#__PURE__*/React.createElement(Widget, {
29 24 schema: schema
30 25 });
31 26 }
32   -
33 27 return null;
34 28 };
35   -
36 29 switch (displayType) {
37 30 case 'row':
38 31 if (descType === 'widget') {
39 32 return /*#__PURE__*/React.createElement(RenderDesc, null);
40 33 }
41   -
42 34 return /*#__PURE__*/React.createElement(_Tooltip, {
43 35 title: _description
44 36 }, /*#__PURE__*/React.createElement("i", {
45 37 className: "fr-tooltip-icon"
46 38 }));
47   -
48 39 case 'inline':
49 40 return null;
50   -
51 41 default:
52 42 if (descType === 'widget') {
53 43 return /*#__PURE__*/React.createElement(RenderDesc, null);
54 44 }
55   -
56 45 if (descType === 'icon') {
57 46 return /*#__PURE__*/React.createElement(_Tooltip, {
58 47 title: _description
... ... @@ -60,35 +49,29 @@ var Description = function Description(_ref) {
60 49 className: "fr-tooltip-icon"
61 50 }));
62 51 }
63   -
64 52 return /*#__PURE__*/React.createElement("span", {
65 53 className: "fr-desc ml2",
66 54 title: description
67 55 }, "( ".concat(description, " )"));
68 56 }
69 57 };
70   -
71 58 var Title = function Title(_ref2) {
72 59 var labelClass = _ref2.labelClass,
73   - labelStyle = _ref2.labelStyle,
74   - schema = _ref2.schema,
75   - displayType = _ref2.displayType,
76   - renderTitle = _ref2.renderTitle,
77   - globalRequiredMark = _ref2.requiredMark;
78   -
  60 + labelStyle = _ref2.labelStyle,
  61 + schema = _ref2.schema,
  62 + displayType = _ref2.displayType,
  63 + renderTitle = _ref2.renderTitle,
  64 + globalRequiredMark = _ref2.requiredMark;
79 65 var _useStore = useStore2(),
80   - globalDisplayType = _useStore.displayType,
81   - readOnly = _useStore.readOnly,
82   - colon = _useStore.colon;
83   -
  66 + globalDisplayType = _useStore.displayType,
  67 + readOnly = _useStore.readOnly,
  68 + colon = _useStore.colon;
84 69 var title = schema.title,
85   - required = schema.required,
86   - type = schema.type,
87   - schemaRequiredMark = schema.requiredMark;
  70 + required = schema.required,
  71 + type = schema.type,
  72 + schemaRequiredMark = schema.requiredMark;
88 73 var isObjType = type === 'object';
89   -
90 74 var _displayType = schema.displayType || displayType || globalDisplayType || 'column';
91   -
92 75 if (renderTitle) {
93 76 return renderTitle({
94 77 labelClass: labelClass,
... ... @@ -99,13 +82,12 @@ var Title = function Title(_ref2) {
99 82 colon: colon
100 83 });
101 84 }
  85 + var requiredMark = typeof schemaRequiredMark === 'undefined' ? globalRequiredMark : schemaRequiredMark;
102 86
103   - var requiredMark = typeof schemaRequiredMark === 'undefined' ? globalRequiredMark : schemaRequiredMark; // 左侧的的 * 号提示
104   -
105   - var TitleRequiredMark = null; // 左侧的 option 提示
106   -
  87 + // 左侧的的 * 号提示
  88 + var TitleRequiredMark = null;
  89 + // 左侧的 option 提示
107 90 var TitleTextMark = null;
108   -
109 91 if (required) {
110 92 /**
111 93 * ant-design requiredMark 实现
... ... @@ -124,14 +106,13 @@ var Title = function Title(_ref2) {
124 106 className: "fr-label-required-text"
125 107 }, "\uFF08\u53EF\u9009\uFF09");
126 108 }
127   - } // requiredMark 为 false 不展示必填符号
128   -
  109 + }
129 110
  111 + // requiredMark 为 false 不展示必填符号
130 112 if (requiredMark === false) {
131 113 TitleRequiredMark = null;
132 114 TitleTextMark = null;
133 115 }
134   -
135 116 return /*#__PURE__*/React.createElement("div", {
136 117 className: labelClass,
137 118 style: labelStyle
... ... @@ -150,5 +131,4 @@ var Title = function Title(_ref2) {
150 131 displayType: _displayType
151 132 })) : null);
152 133 };
153   -
154 134 export default Title;
\ No newline at end of file
... ...
1   -function _extends() { _extends = Object.assign || 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   -
  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 _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 3 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4   -
5 4 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."); }
6   -
7 5 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   -
9 6 function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10   -
11 7 function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12   -
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   -
15   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16   -
  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 _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; }
  10 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  11 +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); }
17 12 import React, { useRef } from 'react';
18 13 import { useStore, useStore2, useTools } from '../../hooks';
19 14 import useDebouncedCallback from '../../useDebounce';
... ... @@ -22,80 +17,71 @@ import { validateField } from '../../validator';
22 17 import ErrorMessage from './ErrorMessage';
23 18 import ExtendedWidget from './ExtendedWidget';
24 19 import Extra from './Extra';
25   -import FieldTitle from './Title'; // TODO: 之后不要直接用get,收口到一个内部方法getValue,便于全局 ctrl + f 查找
  20 +import FieldTitle from './Title';
26 21
  22 +// TODO: 之后不要直接用get,收口到一个内部方法getValue,便于全局 ctrl + f 查找
27 23 var RenderField = function RenderField(props) {
28 24 var $id = props.$id,
29   - dataIndex = props.dataIndex,
30   - dataPath = props.dataPath,
31   - _value = props._value,
32   - dependValues = props.dependValues,
33   - _schema = props._schema,
34   - labelClass = props.labelClass,
35   - labelStyle = props.labelStyle,
36   - _contentClass = props.contentClass,
37   - children = props.children,
38   - _props$errorFields = props.errorFields,
39   - errorFields = _props$errorFields === void 0 ? [] : _props$errorFields,
40   - hideTitle = props.hideTitle,
41   - displayType = props.displayType;
42   -
  25 + dataIndex = props.dataIndex,
  26 + dataPath = props.dataPath,
  27 + _value = props._value,
  28 + dependValues = props.dependValues,
  29 + _schema = props._schema,
  30 + labelClass = props.labelClass,
  31 + labelStyle = props.labelStyle,
  32 + _contentClass = props.contentClass,
  33 + children = props.children,
  34 + _props$errorFields = props.errorFields,
  35 + errorFields = _props$errorFields === void 0 ? [] : _props$errorFields,
  36 + hideTitle = props.hideTitle,
  37 + displayType = props.displayType;
43 38 var _useStore = useStore(),
44   - formData = _useStore.formData,
45   - flatten = _useStore.flatten;
46   -
  39 + formData = _useStore.formData,
  40 + flatten = _useStore.flatten;
47 41 var _useStore2 = useStore2(),
48   - debounceInput = _useStore2.debounceInput,
49   - readOnly = _useStore2.readOnly,
50   - disabled = _useStore2.disabled,
51   - showValidate = _useStore2.showValidate,
52   - validateMessages = _useStore2.validateMessages,
53   - locale = _useStore2.locale,
54   - watch = _useStore2.watch;
55   -
  42 + debounceInput = _useStore2.debounceInput,
  43 + readOnly = _useStore2.readOnly,
  44 + disabled = _useStore2.disabled,
  45 + showValidate = _useStore2.showValidate,
  46 + validateMessages = _useStore2.validateMessages,
  47 + locale = _useStore2.locale,
  48 + watch = _useStore2.watch;
56 49 var _useTools = useTools(),
57   - onValuesChange = _useTools.onValuesChange,
58   - onItemChange = _useTools.onItemChange,
59   - setEditing = _useTools.setEditing,
60   - touchKey = _useTools.touchKey,
61   - _setErrors = _useTools._setErrors,
62   - renderTitle = _useTools.renderTitle,
63   - requiredMark = _useTools.requiredMark,
64   - setFieldValidating = _useTools.setFieldValidating,
65   - removeFieldValidating = _useTools.removeFieldValidating,
66   - setValueByPath = _useTools.setValueByPath;
67   -
  50 + onValuesChange = _useTools.onValuesChange,
  51 + onItemChange = _useTools.onItemChange,
  52 + setEditing = _useTools.setEditing,
  53 + touchKey = _useTools.touchKey,
  54 + _setErrors = _useTools._setErrors,
  55 + renderTitle = _useTools.renderTitle,
  56 + requiredMark = _useTools.requiredMark,
  57 + setFieldValidating = _useTools.setFieldValidating,
  58 + removeFieldValidating = _useTools.removeFieldValidating,
  59 + setValueByPath = _useTools.setValueByPath;
68 60 var formDataRef = useRef();
69   - formDataRef.current = formData; // console.log('<renderField>', $id);
  61 + formDataRef.current = formData;
  62 + // console.log('<renderField>', $id);
70 63
71 64 var errObj = errorFields.find(function (err) {
72 65 return err.name === dataPath;
73 66 });
74 67 var errorMessage = errObj && errObj.error; // 是一个list
75   -
76   - var hasError = Array.isArray(errorMessage) && errorMessage.length > 0; // 补上这个class,会自动让下面所有的展示ui变红!
77   -
  68 + var hasError = Array.isArray(errorMessage) && errorMessage.length > 0;
  69 + // 补上这个class,会自动让下面所有的展示ui变红!
78 70 var contentClass = hasError && showValidate ? _contentClass + ' ant-form-item-has-error' : _contentClass;
79 71 var contentStyle = {};
80 72 var debouncedSetEditing = useDebouncedCallback(setEditing, 350);
81   -
82 73 var _readOnly = readOnly !== undefined ? readOnly : _schema.readOnly;
83   -
84 74 var _disabled = disabled !== undefined ? disabled : _schema.disabled;
85   -
86 75 var removeDupErrors = function removeDupErrors(arr) {
87 76 if (!Array.isArray(arr)) {
88 77 console.log('in removeDups: param is not an array');
89 78 return;
90 79 }
91   -
92 80 var array = [];
93   -
94 81 for (var i = 0; i < arr.length; i++) {
95 82 var sameNameIndex = array.findIndex(function (item) {
96 83 return item.name === arr[i].name;
97 84 });
98   -
99 85 if (sameNameIndex > -1) {
100 86 var sameNameItem = array[sameNameIndex];
101 87 var error1 = sameNameItem.error;
... ... @@ -108,31 +94,27 @@ var RenderField = function RenderField(props) {
108 94 array.push(arr[i]);
109 95 }
110 96 }
111   -
112 97 return array.filter(function (item) {
113 98 return Array.isArray(item.error) && item.error.length > 0;
114 99 });
115   - }; // TODO: 优化一下,只有touch还是false的时候,setTouched
116   -
  100 + };
117 101
  102 + // TODO: 优化一下,只有touch还是false的时候,setTouched
118 103 var onChange = function onChange(value) {
119 104 // 动过的key,算被touch了, 这里之后要考虑动的来源
120   - touchKey(dataPath); // 开始编辑,节流
121   -
  105 + touchKey(dataPath);
  106 + // 开始编辑,节流
122 107 if (debounceInput) {
123 108 setEditing(true);
124 109 debouncedSetEditing(false);
125 110 }
126   -
127 111 if (typeof dataPath === 'string') {
128 112 onItemChange(dataPath, value);
129   - } // 先不暴露给外部,这个api
130   -
131   -
  113 + }
  114 + // 先不暴露给外部,这个api
132 115 if (typeof onValuesChange === 'function') {
133 116 onValuesChange(_defineProperty({}, dataPath, value), formDataRef.current);
134 117 }
135   -
136 118 validateField({
137 119 path: dataPath,
138 120 formData: formDataRef.current,
... ... @@ -151,7 +133,6 @@ var RenderField = function RenderField(props) {
151 133 });
152 134 });
153 135 };
154   -
155 136 var titleProps = {
156 137 labelClass: labelClass,
157 138 labelStyle: labelStyle,
... ... @@ -167,28 +148,23 @@ var RenderField = function RenderField(props) {
167 148 softHidden: displayType === 'inline',
168 149 // 这个是如果没有校验信息时,展示与否
169 150 hardHidden: showValidate === false || _readOnly === true // 这个是强制的展示与否
170   -
171 151 };
  152 +
172 153 var placeholderTitleProps = {
173 154 className: labelClass,
174 155 style: labelStyle
175 156 };
176   -
177   - var _showTitle = !hideTitle && typeof _schema.title === 'string'; // TODO: 这块最好能判断上一层是list1,
178   -
179   -
  157 + var _showTitle = !hideTitle && typeof _schema.title === 'string';
  158 + // TODO: 这块最好能判断上一层是list1,
180 159 if (hideTitle && _schema.title) {
181 160 _schema.placeholder = _schema.placeholder || _schema.title;
182 161 }
183   -
184 162 var _getValue = function _getValue(path) {
185 163 return getValueByPath(formData, path);
186 164 };
187   -
188 165 if (formDataRef.current && ['virtualList', 'listForMobile'].includes(_schema.widget)) {
189 166 _schema._setValueByPath = setValueByPath;
190 167 }
191   -
192 168 var widgetProps = {
193 169 $id: $id,
194 170 schema: _schema,
... ... @@ -206,19 +182,18 @@ var RenderField = function RenderField(props) {
206 182 watch: watch,
207 183 hasError: hasError
208 184 };
209   -
210 185 var displayBlock = function displayBlock() {
211 186 if (hasError && !_schema.extra) {
212 187 return false;
213 188 }
214   -
215 189 return true;
216   - }; // if (_schema && _schema.default !== undefined) {
  190 + };
  191 +
  192 + // if (_schema && _schema.default !== undefined) {
217 193 // widgetProps.value = _schema.default;
218 194 // }
219   - // checkbox必须单独处理,布局太不同了
220   -
221 195
  196 + // checkbox必须单独处理,布局太不同了
222 197 if (isCheckBoxType(_schema, _readOnly)) {
223 198 return /*#__PURE__*/React.createElement(React.Fragment, null, _showTitle && /*#__PURE__*/React.createElement("div", placeholderTitleProps), /*#__PURE__*/React.createElement("div", {
224 199 className: contentClass,
... ... @@ -228,9 +203,7 @@ var RenderField = function RenderField(props) {
228 203 className: "field-block"
229 204 })));
230 205 }
231   -
232 206 var titleElement = /*#__PURE__*/React.createElement(FieldTitle, titleProps);
233   -
234 207 if (isObjType(_schema)) {
235 208 titleElement = /*#__PURE__*/React.createElement("div", {
236 209 style: {
... ... @@ -252,7 +225,6 @@ var RenderField = function RenderField(props) {
252 225 datapath: dataPath
253 226 }, /*#__PURE__*/React.createElement(ExtendedWidget, widgetProps));
254 227 }
255   -
256 228 return /*#__PURE__*/React.createElement(React.Fragment, null, _showTitle && titleElement, /*#__PURE__*/React.createElement("div", {
257 229 className: "".concat(contentClass, " ").concat(hideTitle ? 'fr-content-no-title' : ''),
258 230 style: contentStyle,
... ... @@ -261,5 +233,4 @@ var RenderField = function RenderField(props) {
261 233 className: "field-block"
262 234 })));
263 235 };
264   -
265 236 export default RenderField;
\ No newline at end of file
... ...
  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); }
1 2 var _excluded = ["id", "_item", "dataIndex", "hideTitle", "hideValidation", "debugCss"],
2   - _excluded2 = ["id", "item", "dataIndex", "dataPath", "hideTitle", "hideValidation", "debugCss", "schema", "_value", "dependValues", "displayType", "labelAlign", "column", "labelWidth", "readOnly", "errorFields", "effectiveLabelWidth"];
3   -
4   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5   -
6   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7   -
8   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9   -
  3 + _excluded2 = ["id", "item", "dataIndex", "dataPath", "hideTitle", "hideValidation", "debugCss", "schema", "_value", "dependValues", "displayType", "labelAlign", "column", "labelWidth", "readOnly", "errorFields", "effectiveLabelWidth"];
  4 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  5 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  6 +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; }
  7 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  8 +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); }
10 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; }
11   -
12 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; }
13   -
14 11 import React, { useRef } from 'react';
15 12 import { useStore, useStore2 } from '../hooks';
16 13 import { clone, getDataPath, getParentPath, getParentProps, getValueByPath, isCheckBoxType, isCssLength, isListType, isLooselyNumber, isObjType, parseRootValueInSchema } from '../utils';
17 14 import RenderList from './RenderChildren/RenderList';
18 15 import RenderObject from './RenderChildren/RenderObject';
19 16 import RenderField from './RenderField';
20   -
21 17 var Core = function Core(_ref) {
22 18 var _ref$id = _ref.id,
23   - id = _ref$id === void 0 ? '#' : _ref$id,
24   - _item = _ref._item,
25   - _ref$dataIndex = _ref.dataIndex,
26   - dataIndex = _ref$dataIndex === void 0 ? [] : _ref$dataIndex,
27   - _ref$hideTitle = _ref.hideTitle,
28   - hideTitle = _ref$hideTitle === void 0 ? false : _ref$hideTitle,
29   - _ref$hideValidation = _ref.hideValidation,
30   - hideValidation = _ref$hideValidation === void 0 ? false : _ref$hideValidation,
31   - debugCss = _ref.debugCss,
32   - rest = _objectWithoutProperties(_ref, _excluded);
33   -
  19 + id = _ref$id === void 0 ? '#' : _ref$id,
  20 + _item = _ref._item,
  21 + _ref$dataIndex = _ref.dataIndex,
  22 + dataIndex = _ref$dataIndex === void 0 ? [] : _ref$dataIndex,
  23 + _ref$hideTitle = _ref.hideTitle,
  24 + hideTitle = _ref$hideTitle === void 0 ? false : _ref$hideTitle,
  25 + _ref$hideValidation = _ref.hideValidation,
  26 + hideValidation = _ref$hideValidation === void 0 ? false : _ref$hideValidation,
  27 + debugCss = _ref.debugCss,
  28 + rest = _objectWithoutProperties(_ref, _excluded);
34 29 var snapShot = useRef();
35   -
36 30 var _useStore = useStore(),
37   - flatten = _useStore.flatten,
38   - errorFields = _useStore.errorFields,
39   - isEditing = _useStore.isEditing,
40   - formData = _useStore.formData,
41   - allTouched = _useStore.allTouched;
42   -
  31 + flatten = _useStore.flatten,
  32 + errorFields = _useStore.errorFields,
  33 + isEditing = _useStore.isEditing,
  34 + formData = _useStore.formData,
  35 + allTouched = _useStore.allTouched;
43 36 var _useStore2 = useStore2(),
44   - displayType = _useStore2.displayType,
45   - column = _useStore2.column,
46   - labelWidth = _useStore2.labelWidth,
47   - readOnly = _useStore2.readOnly,
48   - labelAlign = _useStore2.labelAlign;
49   -
  37 + displayType = _useStore2.displayType,
  38 + column = _useStore2.column,
  39 + labelWidth = _useStore2.labelWidth,
  40 + readOnly = _useStore2.readOnly,
  41 + labelAlign = _useStore2.labelAlign;
50 42 var item = _item ? _item : flatten[id];
51 43 if (!item) return null;
52 44 var dataPath = getDataPath(id, dataIndex);
53 45 var parentPath = getParentPath(dataPath);
54   -
55 46 var _value = getValueByPath(formData, dataPath);
56   -
57   - var schema = clone(item.schema); // schema.disabled = !!subReadOnly;
58   -
  47 + var schema = clone(item.schema);
  48 + // schema.disabled = !!subReadOnly;
59 49 var dependencies = schema.dependencies;
60 50 var dependValues = [];
61 51 var rootValue;
62   -
63 52 try {
64 53 if (Array.isArray(dependencies)) {
65 54 dependencies.forEach(function (item) {
... ... @@ -71,29 +60,25 @@ var Core = function Core(_ref) {
71 60 } catch (error) {
72 61 console.error("dependencies \u8BA1\u7B97\u62A5\u9519\uFF0C".concat(dependencies));
73 62 }
74   -
75 63 try {
76 64 rootValue = getValueByPath(formData, parentPath);
77   -
78 65 if (dataIndex.length) {
79 66 rootValue.index = dataIndex[dataIndex.length - 1];
80 67 }
81   - } catch (error) {} // 节流部分逻辑,编辑时不执行
82   -
  68 + } catch (error) {}
83 69
  70 + // 节流部分逻辑,编辑时不执行
84 71 if (isEditing && snapShot.current) {
85 72 schema = snapShot.current;
86 73 } else {
87 74 if (JSON.stringify(schema).indexOf('rootValue') > -1) {
88 75 schema = parseRootValueInSchema(schema, rootValue);
89 76 }
90   -
91 77 snapShot.current = schema;
92   - } // 真正有效的label宽度需要从现在所在item开始一直往上回溯(设计成了继承关系),找到的第一个有值的 ui:labelWidth
93   -
  78 + }
94 79
  80 + // 真正有效的label宽度需要从现在所在item开始一直往上回溯(设计成了继承关系),找到的第一个有值的 ui:labelWidth
95 81 var effectiveLabelWidth = getParentProps('labelWidth', id, flatten) || labelWidth;
96   -
97 82 var dataProps = _objectSpread({
98 83 id: id,
99 84 item: item,
... ... @@ -116,39 +101,34 @@ var Core = function Core(_ref) {
116 101 allTouched: allTouched,
117 102 labelAlign: labelAlign
118 103 }, rest);
119   -
120 104 return /*#__PURE__*/React.createElement(CoreRender, dataProps);
121 105 };
122   -
123 106 var CoreRender = function CoreRender(_ref2) {
124 107 var id = _ref2.id,
125   - item = _ref2.item,
126   - dataIndex = _ref2.dataIndex,
127   - dataPath = _ref2.dataPath,
128   - hideTitle = _ref2.hideTitle,
129   - hideValidation = _ref2.hideValidation,
130   - debugCss = _ref2.debugCss,
131   - schema = _ref2.schema,
132   - _value = _ref2._value,
133   - dependValues = _ref2.dependValues,
134   - displayType = _ref2.displayType,
135   - labelAlign = _ref2.labelAlign,
136   - column = _ref2.column,
137   - labelWidth = _ref2.labelWidth,
138   - readOnly = _ref2.readOnly,
139   - errorFields = _ref2.errorFields,
140   - effectiveLabelWidth = _ref2.effectiveLabelWidth,
141   - rest = _objectWithoutProperties(_ref2, _excluded2);
142   -
  108 + item = _ref2.item,
  109 + dataIndex = _ref2.dataIndex,
  110 + dataPath = _ref2.dataPath,
  111 + hideTitle = _ref2.hideTitle,
  112 + hideValidation = _ref2.hideValidation,
  113 + debugCss = _ref2.debugCss,
  114 + schema = _ref2.schema,
  115 + _value = _ref2._value,
  116 + dependValues = _ref2.dependValues,
  117 + displayType = _ref2.displayType,
  118 + labelAlign = _ref2.labelAlign,
  119 + column = _ref2.column,
  120 + labelWidth = _ref2.labelWidth,
  121 + readOnly = _ref2.readOnly,
  122 + errorFields = _ref2.errorFields,
  123 + effectiveLabelWidth = _ref2.effectiveLabelWidth,
  124 + rest = _objectWithoutProperties(_ref2, _excluded2);
143 125 // if (schema.hidden) {
144 126 // return null;
145 127 // }
146 128 // 样式的逻辑全放在这层
147 129 // displayType 一层层网上找值
148 130 var _displayType = schema.displayType || rest.displayType || displayType || 'column';
149   -
150 131 var _labelAlign = schema.labelAlign || rest.labelAlign || labelAlign || 'right';
151   -
152 132 var isList = isListType(schema);
153 133 var isObj = isObjType(schema);
154 134 var isComplex = isObj || isList;
... ... @@ -157,68 +137,53 @@ var CoreRender = function CoreRender(_ref2) {
157 137 var containerClass = "fr-field ".concat(_displayType === 'inline' ? '' : 'w-100', " flex");
158 138 var labelClass = "fr-label";
159 139 var contentClass = "fr-content";
160   -
161 140 if (typeof schema.className === 'string') {
162 141 containerClass += ' ' + schema.className;
163   - } // common classNames dispite row or column
164   -
  142 + }
165 143
  144 + // common classNames dispite row or column
166 145 switch (schema.type) {
167 146 case 'object':
168 147 if (isObj) {
169 148 if (schema.title) {
170 149 labelClass += ' fr-label-object';
171 150 }
172   -
173 151 containerClass += ' fr-field-object';
174 152 }
175   -
176 153 break;
177   -
178 154 case 'array':
179 155 // list 有两种展示形式!
180 156 if (isList) {
181 157 if (schema.title) {
182 158 labelClass += ' fr-label-list';
183 159 }
184   -
185 160 containerClass += ' fr-field-column';
186 161 }
187   -
188 162 break;
189   -
190 163 case 'boolean':
191 164 if (isCheckBox) {
192 165 contentClass += ' fr-content-column'; // checkbox高度短,需要居中对齐
193   -
194 166 containerClass += " flex ".concat(_displayType === 'column' ? 'flex-column' : '');
195 167 }
196   -
197 168 break;
198   -
199 169 default:
200   - } // column specific className
201   -
202   -
  170 + }
  171 + // column specific className
203 172 if (!isComplex && !isCheckBox) {
204 173 if (_displayType === 'column') {
205 174 containerClass += ' flex-column';
206 175 labelClass += ' fr-label-column';
207 176 contentClass += ' fr-content-column';
208   -
209 177 switch (schema.type) {
210 178 case 'object':
211 179 break;
212   -
213 180 case 'array':
214   - if (schema.title && !schema.enum) {// labelClass += ' b mb2';
  181 + if (schema.title && !schema.enum) {
  182 + // labelClass += ' b mb2';
215 183 }
216   -
217 184 break;
218   -
219 185 case 'boolean':
220 186 break;
221   -
222 187 default:
223 188 }
224 189 } else if (_displayType === 'row') {
... ... @@ -226,29 +191,25 @@ var CoreRender = function CoreRender(_ref2) {
226 191 containerClass += '';
227 192 labelClass += " fr-label-row ".concat(_labelAlign === 'right' ? 'fr-label-align-right' : 'fr-label-align-left');
228 193 contentClass += ' fr-content-row';
229   -
230 194 if (!isObj && !isCheckBox) {
231 195 labelClass += ' flex-shrink-0 fr-label-row';
232 196 contentClass += ' flex-grow-1 relative';
233 197 }
234 198 }
235   - } // style part
236   -
  199 + }
237 200
  201 + // style part
238 202 var columnStyle = {};
239   -
240 203 if (schema.currentStep === false) {
241 204 columnStyle.display = 'none';
242 205 } else {
243 206 columnStyle = {};
244 207 }
245   -
246 208 if (schema.hidden) {
247 209 columnStyle.display = 'none';
248   - } // if (!isComplex) {
  210 + }
  211 + // if (!isComplex) {
249 212 // }
250   -
251   -
252 213 if (!isObj) {
253 214 if (width) {
254 215 columnStyle.width = width;
... ... @@ -258,20 +219,16 @@ var CoreRender = function CoreRender(_ref2) {
258 219 columnStyle.paddingRight = 8;
259 220 }
260 221 }
261   -
262 222 var _labelWidth = isLooselyNumber(effectiveLabelWidth) ? Number(effectiveLabelWidth) : isCssLength(effectiveLabelWidth) ? effectiveLabelWidth : 110; // 默认是 110px 的长度
263 223
264   -
265 224 var labelStyle = {
266 225 width: _labelWidth
267 226 };
268   -
269 227 if (isComplex || _displayType === 'column') {
270 228 labelStyle = {
271 229 flexGrow: 1
272 230 };
273 231 }
274   -
275 232 if (_displayType === 'inline') {
276 233 labelStyle = {
277 234 marginTop: 5,
... ... @@ -279,12 +236,10 @@ var CoreRender = function CoreRender(_ref2) {
279 236 };
280 237 labelClass = '';
281 238 contentClass += ' fr-content-inline';
282   -
283 239 if (containerClass.indexOf('fr-field-object') === -1) {
284 240 containerClass += ' fr-field-inline';
285 241 }
286 242 }
287   -
288 243 var hasChildren = item.children && item.children.length > 0;
289 244 var fieldProps = {
290 245 $id: id,
... ... @@ -318,10 +273,10 @@ var CoreRender = function CoreRender(_ref2) {
318 273 errorFields: errorFields,
319 274 displayType: _displayType,
320 275 hideTitle: hideTitle
321   - }, item.children); // 计算 children
  276 + }, item.children);
322 277
  278 + // 计算 children
323 279 var _children = null;
324   -
325 280 if (hasChildren) {
326 281 if (isObj) {
327 282 _children = objChildren;
... ... @@ -331,58 +286,46 @@ var CoreRender = function CoreRender(_ref2) {
331 286 } else if (isCheckBox) {
332 287 _children = schema.title;
333 288 }
334   -
335 289 return /*#__PURE__*/React.createElement("div", {
336 290 style: columnStyle,
337 291 className: "".concat(containerClass, " ").concat(debugCss ? 'debug' : '')
338 292 }, /*#__PURE__*/React.createElement(RenderField, fieldProps, _children));
339   -}; // haven't used
340   -
  293 +};
341 294
  295 +// haven't used
342 296 var areEqual = function areEqual(prev, current) {
343 297 if (prev.allTouched !== current.allTouched) {
344 298 return false;
345 299 }
346   -
347 300 if (prev.displayType !== current.displayType) {
348 301 return false;
349 302 }
350   -
351 303 if (prev.column !== current.column) {
352 304 return false;
353 305 }
354   -
355 306 if (prev.labelWidth !== current.labelWidth) {
356 307 return false;
357 308 }
358   -
359 309 if (prev.readOnly !== current.readOnly) {
360 310 return false;
361 311 }
362   -
363 312 if (prev.disabled !== current.disabled) {
364 313 return false;
365 314 }
366   -
367 315 if (prev.schema && current.schema) {
368 316 if (prev.schema.$id === '#') {
369 317 return false;
370 318 }
371 319 }
372   -
373 320 if (isObjType(prev.schema) && isObjType(current.schema)) {
374 321 return false;
375 322 }
376   -
377 323 if (JSON.stringify(prev.dependValues) !== JSON.stringify(current.dependValues)) {
378 324 return false;
379 325 }
380   -
381 326 if (JSON.stringify(prev._value) === JSON.stringify(current._value) && JSON.stringify(prev.schema) === JSON.stringify(current.schema) && JSON.stringify(prev.errorFields) === JSON.stringify(current.errorFields)) {
382 327 return true;
383 328 }
384   -
385 329 return false;
386 330 };
387   -
388 331 export default Core;
\ No newline at end of file
... ...
  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); }
1 2 var _excluded = ["schema"],
2   - _excluded2 = ["onChange", "value", "defaultValue", "schema", "readOnly"];
3   -
4   -function _extends() { _extends = Object.assign || 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); }
5   -
6   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
7   -
8   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
9   -
10   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11   -
  3 + _excluded2 = ["onChange", "value", "defaultValue", "schema", "readOnly"];
  4 +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); }
  5 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  6 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  7 +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; }
  8 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  9 +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); }
12 10 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; }
13   -
14 11 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; }
15   -
16 12 import React from "react";
17 13 import { defaultGetValueFromEvent } from './utils';
18 14 export var createWidget = function createWidget(mapProps, extraSchema) {
19 15 return function (Component) {
20 16 return function (props) {
21 17 var schema = props.schema,
22   - rest = _objectWithoutProperties(props, _excluded);
23   -
  18 + rest = _objectWithoutProperties(props, _excluded);
24 19 var _schema = _objectSpread(_objectSpread({}, schema), extraSchema);
25   -
26 20 var propsMap = typeof mapProps === 'function' ? mapProps(_objectSpread({
27 21 schema: _schema
28 22 }, rest)) : {};
29   -
30 23 var _props = _objectSpread(_objectSpread({
31 24 schema: _schema
32 25 }, rest), propsMap);
33   -
34 26 var finalProps = transformProps(_props);
35 27 return /*#__PURE__*/React.createElement(Component, _extends({}, finalProps, {
36 28 getPopupContainer: function getPopupContainer(triggerNode) {
... ... @@ -42,55 +34,44 @@ export var createWidget = function createWidget(mapProps, extraSchema) {
42 34 };
43 35 export var transformProps = function transformProps(props) {
44 36 var onChange = props.onChange,
45   - value = props.value,
46   - defaultValue = props.defaultValue,
47   - ownSchema = props.schema,
48   - readOnly = props.readOnly,
49   - rest = _objectWithoutProperties(props, _excluded2);
50   -
  37 + value = props.value,
  38 + defaultValue = props.defaultValue,
  39 + ownSchema = props.schema,
  40 + readOnly = props.readOnly,
  41 + rest = _objectWithoutProperties(props, _excluded2);
51 42 var schema = _objectSpread({}, ownSchema);
52   -
53 43 var _ref = schema || {},
54   - trigger = _ref.trigger,
55   - valuePropName = _ref.valuePropName;
56   -
  44 + trigger = _ref.trigger,
  45 + valuePropName = _ref.valuePropName;
57 46 var controlProps = {};
58 47 var _valuePropName = 'value';
59   -
60 48 var _value = value === undefined ? defaultValue : value;
61   -
62 49 if (valuePropName && typeof valuePropName === 'string') {
63 50 _valuePropName = valuePropName;
64 51 controlProps[valuePropName] = _value;
65 52 } else {
66 53 controlProps.value = _value;
67 54 }
68   -
69 55 var _onChange = function _onChange() {
70 56 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
71 57 args[_key] = arguments[_key];
72 58 }
73   -
74 59 var newValue = defaultGetValueFromEvent.apply(void 0, [_valuePropName].concat(args));
75 60 onChange(newValue);
76 61 };
77   -
78 62 if (trigger && typeof trigger === 'string') {
79 63 controlProps.onChange = _onChange;
80 64 controlProps[trigger] = _onChange;
81 65 } else {
82 66 controlProps.onChange = _onChange;
83 67 }
84   -
85 68 var usefulPropsFromSchema = {
86 69 disabled: schema.disabled || schema['ui:disabled'],
87 70 readOnly: schema.readOnly || schema['ui:readonly'] || readOnly,
88 71 hidden: schema.hidden || schema['ui:hidden']
89 72 };
90   -
91 73 var _props = _objectSpread(_objectSpread(_objectSpread({}, controlProps), {}, {
92 74 schema: schema
93 75 }, usefulPropsFromSchema), rest);
94   -
95 76 return _props;
96 77 };
\ No newline at end of file
... ...
1   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2   -
3   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4   -
5   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6   -
  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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  3 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  6 +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); }
7 7 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8   -
9 8 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."); }
10   -
11 9 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); }
12   -
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   -
15   -function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
16   -
  10 +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; }
  11 +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; } }
17 12 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18   -
19 13 import { createContext, useContext, useEffect, useReducer, useRef, useState } from 'react';
20 14 export var Ctx = /*#__PURE__*/createContext(function () {});
21 15 export var StoreCtx = /*#__PURE__*/createContext({});
... ... @@ -31,38 +25,27 @@ export var useStore2 = function useStore2() {
31 25 };
32 26 export var useSet = function useSet(initState) {
33 27 var _useReducer = useReducer(function (state, newState) {
34   - var action = newState;
35   -
36   - if (typeof newState === 'function') {
37   - action = action(state);
38   - }
39   -
40   - if (newState.action && newState.payload) {
41   - action = newState.payload;
42   -
43   - if (typeof action === 'function') {
  28 + var action = newState;
  29 + if (typeof newState === 'function') {
44 30 action = action(state);
45 31 }
46   - }
47   -
48   - var result = _objectSpread(_objectSpread({}, state), action); // console.group(newState.action || 'action'); // TODO: give it a name
49   - // console.log('%cState:', 'color: #9E9E9E; font-weight: 700;', state);
50   - // console.log('%cAction:', 'color: #00A7F7; font-weight: 700;', action);
51   - // console.log('%cNext:', 'color: #47B04B; font-weight: 700;', result);
52   - // console.groupEnd();
53   -
54   -
55   - // console.group(newState.action || 'action'); // TODO: give it a name
56   - // console.log('%cState:', 'color: #9E9E9E; font-weight: 700;', state);
57   - // console.log('%cAction:', 'color: #00A7F7; font-weight: 700;', action);
58   - // console.log('%cNext:', 'color: #47B04B; font-weight: 700;', result);
59   - // console.groupEnd();
60   - return result;
61   - }, initState),
62   - _useReducer2 = _slicedToArray(_useReducer, 2),
63   - state = _useReducer2[0],
64   - setState = _useReducer2[1];
65   -
  32 + if (newState.action && newState.payload) {
  33 + action = newState.payload;
  34 + if (typeof action === 'function') {
  35 + action = action(state);
  36 + }
  37 + }
  38 + var result = _objectSpread(_objectSpread({}, state), action);
  39 + // console.group(newState.action || 'action'); // TODO: give it a name
  40 + // console.log('%cState:', 'color: #9E9E9E; font-weight: 700;', state);
  41 + // console.log('%cAction:', 'color: #00A7F7; font-weight: 700;', action);
  42 + // console.log('%cNext:', 'color: #47B04B; font-weight: 700;', result);
  43 + // console.groupEnd();
  44 + return result;
  45 + }, initState),
  46 + _useReducer2 = _slicedToArray(_useReducer, 2),
  47 + state = _useReducer2[0],
  48 + setState = _useReducer2[1];
66 49 return [state, setState];
67 50 };
68 51 export function useInterval(callback, delay, start) {
... ... @@ -75,13 +58,10 @@ export function useInterval(callback, delay, start) {
75 58 if (!start) {
76 59 return;
77 60 }
78   -
79 61 function tick() {
80 62 savedCallback && savedCallback.current && savedCallback.current();
81 63 }
82   -
83 64 tick();
84   -
85 65 if (delay !== null) {
86 66 id.current = setInterval(tick, delay);
87 67 return function () {
... ... @@ -96,62 +76,54 @@ export function useInterval(callback, delay, start) {
96 76 export function usePrevious(value) {
97 77 // The ref object is a generic container whose current property is mutable ...
98 78 // ... and can hold any value, similar to an instance property on a class
99   - var ref = useRef(); // Store current value in ref
  79 + var ref = useRef();
100 80
  81 + // Store current value in ref
101 82 useEffect(function () {
102 83 ref.current = value;
103 84 }, [value]); // Only re-run if value changes
104   - // Return previous value (happens before update in useEffect above)
105 85
  86 + // Return previous value (happens before update in useEffect above)
106 87 return ref.current;
107 88 }
108 89 export var useShowOnce = function useShowOnce(localKey) {
109 90 // 从 localStorage 读取 key 值
110 91 var _useState = useState(false),
111   - _useState2 = _slicedToArray(_useState, 2),
112   - show = _useState2[0],
113   - setShow = _useState2[1];
114   -
  92 + _useState2 = _slicedToArray(_useState, 2),
  93 + show = _useState2[0],
  94 + setShow = _useState2[1];
115 95 var localStr;
116   -
117 96 try {
118 97 localStr = localStorage.getItem(localKey);
119 98 } catch (error) {}
120   -
121 99 if (!localStr) {
122 100 setShow(true);
123 101 localStorage.setItem(localKey, JSON.stringify(true));
124 102 }
125   -
126 103 return show;
127 104 };
128 105 export var useModal = function useModal() {
129 106 var _useState3 = useState(false),
130   - _useState4 = _slicedToArray(_useState3, 2),
131   - show = _useState4[0],
132   - setShow = _useState4[1];
133   -
  107 + _useState4 = _slicedToArray(_useState3, 2),
  108 + show = _useState4[0],
  109 + setShow = _useState4[1];
134 110 var toggle = function toggle() {
135 111 return setShow(!show);
136 112 };
137   -
138 113 return [show, toggle];
139 114 };
140 115 export var useWindowState = function useWindowState(initState) {
141 116 var _useState5 = useState(initState),
142   - _useState6 = _slicedToArray(_useState5, 2),
143   - state = _useState6[0],
144   - setState = _useState6[1];
145   -
  117 + _useState6 = _slicedToArray(_useState5, 2),
  118 + state = _useState6[0],
  119 + setState = _useState6[1];
146 120 return [state, setState];
147 121 };
148 122 export var useStorageState = function useStorageState() {
149 123 var initState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
150 124 var searchKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'SAVES';
151   -
152 125 var readSearchFromStorage = function readSearchFromStorage() {
153 126 var searchStr = localStorage.getItem(searchKey);
154   -
155 127 if (searchStr) {
156 128 try {
157 129 return JSON.parse(searchStr);
... ... @@ -159,19 +131,15 @@ export var useStorageState = function useStorageState() {
159 131 return initState;
160 132 }
161 133 }
162   -
163 134 return initState;
164 135 };
165   -
166 136 var _useState7 = useState(readSearchFromStorage()),
167   - _useState8 = _slicedToArray(_useState7, 2),
168   - data = _useState8[0],
169   - setData = _useState8[1];
170   -
  137 + _useState8 = _slicedToArray(_useState7, 2),
  138 + data = _useState8[0],
  139 + setData = _useState8[1];
171 140 var setSearchWithStorage = function setSearchWithStorage(search) {
172 141 setData(search);
173 142 localStorage.setItem(searchKey, JSON.stringify(search));
174 143 };
175   -
176 144 return [data, setSearchWithStorage];
177 145 };
\ No newline at end of file
... ...
1 1 var _excluded = ["id", "widgets", "layoutWidgets", "mapping", "form", "className", "style", "beforeFinish", "onFinish", "displayType", "labelAlign", "colon", "schema", "debug", "debugCss", "locale", "debounceInput", "size", "configProvider", "theme", "validateMessages", "watch", "config", "onMount", "labelWidth", "readOnly", "disabled", "allCollapsed", "onValuesChange", "column", "removeHiddenData", "globalProps", "methods", "renderTitle", "requiredMark"],
2   - _excluded2 = ["onItemChange", "setEditing", "touchKey", "setValueByPath", "getSchemaByPath", "setSchemaByPath", "setSchema", "setValues", "getValues", "resetFields", "submit", "endValidating", "endSubmitting", "setErrorFields", "removeErrorField", "removeTouched", "changeTouchedKeys", "syncStuff", "logOnMount", "logOnSubmit", "setFirstMount", "_setErrors"],
3   - _excluded3 = ["isOldVersion", "schema"];
4   -
5   -function _extends() { _extends = Object.assign || 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); }
6   -
7   -function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8   -
9   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
10   -
11   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
12   -
13   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14   -
  2 + _excluded2 = ["onItemChange", "setEditing", "touchKey", "setValueByPath", "getSchemaByPath", "setSchemaByPath", "setSchema", "setValues", "getValues", "resetFields", "submit", "endValidating", "endSubmitting", "setErrorFields", "removeErrorField", "removeTouched", "changeTouchedKeys", "syncStuff", "logOnMount", "logOnSubmit", "setFirstMount", "_setErrors"],
  3 + _excluded3 = ["isOldVersion", "schema"];
  4 +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); }
  5 +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); }
  6 +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  7 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  8 +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; }
  9 +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  10 +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); }
15 11 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; }
16   -
17 12 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; }
18   -
19 13 /* eslint-disable react-hooks/exhaustive-deps */
20 14 import React, { useEffect, useMemo, useRef } from 'react';
21 15 import "./atom.css";
... ... @@ -25,109 +19,102 @@ import "./index.css";
25 19 import { mapping as defaultMapping } from './mapping';
26 20 import { getParamByName, msToTime, updateSchemaToNewVersion, yymmdd } from './utils';
27 21 import Watcher from './Watcher';
28   -
29 22 var defaultFinish = function defaultFinish(data, errors) {
30 23 console.log('onFinish:', {
31 24 data: data,
32 25 errors: errors
33 26 });
34 27 };
35   -
36 28 export { default as connectForm } from './connectForm';
37 29 export { createWidget } from './createWidget';
38 30 export { default as useForm } from './useForm';
39 31 export { defaultMapping as mapping };
40   -
41 32 function App(_ref) {
42 33 var id = _ref.id,
43   - widgets = _ref.widgets,
44   - layoutWidgets = _ref.layoutWidgets,
45   - mapping = _ref.mapping,
46   - form = _ref.form,
47   - className = _ref.className,
48   - style = _ref.style,
49   - beforeFinish = _ref.beforeFinish,
50   - _ref$onFinish = _ref.onFinish,
51   - onFinish = _ref$onFinish === void 0 ? defaultFinish : _ref$onFinish,
52   - _ref$displayType = _ref.displayType,
53   - displayType = _ref$displayType === void 0 ? 'column' : _ref$displayType,
54   - _ref$labelAlign = _ref.labelAlign,
55   - labelAlign = _ref$labelAlign === void 0 ? 'right' : _ref$labelAlign,
56   - _ref$colon = _ref.colon,
57   - colon = _ref$colon === void 0 ? true : _ref$colon,
58   - schema = _ref.schema,
59   - debug = _ref.debug,
60   - debugCss = _ref.debugCss,
61   - _ref$locale = _ref.locale,
62   - locale = _ref$locale === void 0 ? 'cn' : _ref$locale,
63   - _ref$debounceInput = _ref.debounceInput,
64   - debounceInput = _ref$debounceInput === void 0 ? false : _ref$debounceInput,
65   - size = _ref.size,
66   - configProvider = _ref.configProvider,
67   - theme = _ref.theme,
68   - validateMessages = _ref.validateMessages,
69   - _ref$watch = _ref.watch,
70   - watch = _ref$watch === void 0 ? {} : _ref$watch,
71   - config = _ref.config,
72   - onMount = _ref.onMount,
73   - labelWidth = _ref.labelWidth,
74   - readOnly = _ref.readOnly,
75   - disabled = _ref.disabled,
76   - _ref$allCollapsed = _ref.allCollapsed,
77   - allCollapsed = _ref$allCollapsed === void 0 ? false : _ref$allCollapsed,
78   - onValuesChange = _ref.onValuesChange,
79   - column = _ref.column,
80   - _ref$removeHiddenData = _ref.removeHiddenData,
81   - removeHiddenData = _ref$removeHiddenData === void 0 ? false : _ref$removeHiddenData,
82   - _ref$globalProps = _ref.globalProps,
83   - globalProps = _ref$globalProps === void 0 ? {} : _ref$globalProps,
84   - _ref$methods = _ref.methods,
85   - methods = _ref$methods === void 0 ? {} : _ref$methods,
86   - renderTitle = _ref.renderTitle,
87   - requiredMark = _ref.requiredMark,
88   - rest = _objectWithoutProperties(_ref, _excluded);
89   -
  34 + widgets = _ref.widgets,
  35 + layoutWidgets = _ref.layoutWidgets,
  36 + mapping = _ref.mapping,
  37 + form = _ref.form,
  38 + className = _ref.className,
  39 + style = _ref.style,
  40 + beforeFinish = _ref.beforeFinish,
  41 + _ref$onFinish = _ref.onFinish,
  42 + onFinish = _ref$onFinish === void 0 ? defaultFinish : _ref$onFinish,
  43 + _ref$displayType = _ref.displayType,
  44 + displayType = _ref$displayType === void 0 ? 'column' : _ref$displayType,
  45 + _ref$labelAlign = _ref.labelAlign,
  46 + labelAlign = _ref$labelAlign === void 0 ? 'right' : _ref$labelAlign,
  47 + _ref$colon = _ref.colon,
  48 + colon = _ref$colon === void 0 ? true : _ref$colon,
  49 + schema = _ref.schema,
  50 + debug = _ref.debug,
  51 + debugCss = _ref.debugCss,
  52 + _ref$locale = _ref.locale,
  53 + locale = _ref$locale === void 0 ? 'cn' : _ref$locale,
  54 + _ref$debounceInput = _ref.debounceInput,
  55 + debounceInput = _ref$debounceInput === void 0 ? false : _ref$debounceInput,
  56 + size = _ref.size,
  57 + configProvider = _ref.configProvider,
  58 + theme = _ref.theme,
  59 + validateMessages = _ref.validateMessages,
  60 + _ref$watch = _ref.watch,
  61 + watch = _ref$watch === void 0 ? {} : _ref$watch,
  62 + config = _ref.config,
  63 + onMount = _ref.onMount,
  64 + labelWidth = _ref.labelWidth,
  65 + readOnly = _ref.readOnly,
  66 + disabled = _ref.disabled,
  67 + _ref$allCollapsed = _ref.allCollapsed,
  68 + allCollapsed = _ref$allCollapsed === void 0 ? false : _ref$allCollapsed,
  69 + onValuesChange = _ref.onValuesChange,
  70 + column = _ref.column,
  71 + _ref$removeHiddenData = _ref.removeHiddenData,
  72 + removeHiddenData = _ref$removeHiddenData === void 0 ? false : _ref$removeHiddenData,
  73 + _ref$globalProps = _ref.globalProps,
  74 + globalProps = _ref$globalProps === void 0 ? {} : _ref$globalProps,
  75 + _ref$methods = _ref.methods,
  76 + methods = _ref$methods === void 0 ? {} : _ref$methods,
  77 + renderTitle = _ref.renderTitle,
  78 + requiredMark = _ref.requiredMark,
  79 + rest = _objectWithoutProperties(_ref, _excluded);
90 80 try {
91 81 var _ = form.submit;
92 82 } catch (error) {
93 83 console.error('form 为必填 props,<FormRender /> 没有接收到 form 属性!');
94 84 }
95   -
96 85 var _column = schema && schema.column || column;
97   -
98 86 var onItemChange = form.onItemChange,
99   - setEditing = form.setEditing,
100   - touchKey = form.touchKey,
101   - setValueByPath = form.setValueByPath,
102   - getSchemaByPath = form.getSchemaByPath,
103   - setSchemaByPath = form.setSchemaByPath,
104   - setSchema = form.setSchema,
105   - setValues = form.setValues,
106   - getValues = form.getValues,
107   - resetFields = form.resetFields,
108   - submit = form.submit,
109   - endValidating = form.endValidating,
110   - endSubmitting = form.endSubmitting,
111   - setErrorFields = form.setErrorFields,
112   - removeErrorField = form.removeErrorField,
113   - removeTouched = form.removeTouched,
114   - changeTouchedKeys = form.changeTouchedKeys,
115   - syncStuff = form.syncStuff,
116   - logOnMount = form.logOnMount,
117   - logOnSubmit = form.logOnSubmit,
118   - setFirstMount = form.setFirstMount,
119   - _setErrors = form._setErrors,
120   - valuesThatWillChange = _objectWithoutProperties(form, _excluded2);
121   -
  87 + setEditing = form.setEditing,
  88 + touchKey = form.touchKey,
  89 + setValueByPath = form.setValueByPath,
  90 + getSchemaByPath = form.getSchemaByPath,
  91 + setSchemaByPath = form.setSchemaByPath,
  92 + setSchema = form.setSchema,
  93 + setValues = form.setValues,
  94 + getValues = form.getValues,
  95 + resetFields = form.resetFields,
  96 + submit = form.submit,
  97 + endValidating = form.endValidating,
  98 + endSubmitting = form.endSubmitting,
  99 + setErrorFields = form.setErrorFields,
  100 + removeErrorField = form.removeErrorField,
  101 + removeTouched = form.removeTouched,
  102 + changeTouchedKeys = form.changeTouchedKeys,
  103 + syncStuff = form.syncStuff,
  104 + logOnMount = form.logOnMount,
  105 + logOnSubmit = form.logOnSubmit,
  106 + setFirstMount = form.setFirstMount,
  107 + _setErrors = form._setErrors,
  108 + valuesThatWillChange = _objectWithoutProperties(form, _excluded2);
122 109 var submitData = valuesThatWillChange.submitData,
123   - errorFields = valuesThatWillChange.errorFields,
124   - isValidating = valuesThatWillChange.isValidating,
125   - outsideValidating = valuesThatWillChange.outsideValidating,
126   - isSubmitting = valuesThatWillChange.isSubmitting,
127   - formData = valuesThatWillChange.formData,
128   - flatten = valuesThatWillChange.flatten,
129   - showValidate = valuesThatWillChange.showValidate,
130   - firstMount = valuesThatWillChange.firstMount;
  110 + errorFields = valuesThatWillChange.errorFields,
  111 + isValidating = valuesThatWillChange.isValidating,
  112 + outsideValidating = valuesThatWillChange.outsideValidating,
  113 + isSubmitting = valuesThatWillChange.isSubmitting,
  114 + formData = valuesThatWillChange.formData,
  115 + flatten = valuesThatWillChange.flatten,
  116 + showValidate = valuesThatWillChange.showValidate,
  117 + firstMount = valuesThatWillChange.firstMount;
131 118 useEffect(function () {
132 119 // Schema最外层的type是object来判断,没有的话,认为schema没有传
133 120 if (schema && schema.type) {
... ... @@ -150,19 +137,15 @@ function App(_ref) {
150 137 onMount();
151 138 }, 0);
152 139 }
153   -
154 140 setTimeout(onMountLogger, 0);
155 141 }
156 142 }, [JSON.stringify(schema), firstMount]);
157   -
158 143 var onMountLogger = function onMountLogger() {
159 144 var start = new Date().getTime();
160   -
161 145 if (typeof logOnMount === 'function' || typeof logOnSubmit === 'function') {
162 146 sessionStorage.setItem('FORM_MOUNT_TIME', start);
163 147 sessionStorage.setItem('FORM_START', start);
164 148 }
165   -
166 149 if (typeof logOnMount === 'function') {
167 150 var logParams = {
168 151 schema: schema,
... ... @@ -170,22 +153,19 @@ function App(_ref) {
170 153 formData: JSON.stringify(form.getValues()),
171 154 formMount: yymmdd(start)
172 155 };
173   -
174 156 if (id) {
175 157 logParams.id = id;
176 158 }
177   -
178 159 logOnMount(logParams);
179   - } // 如果是要计算时间,在 onMount 时存一个时间戳
180   -
181   -
  160 + }
  161 + // 如果是要计算时间,在 onMount 时存一个时间戳
182 162 if (typeof logOnSubmit === 'function') {
183 163 sessionStorage.setItem('NUMBER_OF_SUBMITS', 0);
184 164 sessionStorage.setItem('FAILED_ATTEMPTS', 0);
185 165 }
186   - }; // 组件 destroy 的时候,destroy form,因为useForm可能在上层,所以不一定会跟着destroy
187   -
  166 + };
188 167
  168 + // 组件 destroy 的时候,destroy form,因为useForm可能在上层,所以不一定会跟着destroy
189 169 useEffect(function () {
190 170 return function () {
191 171 form.resetFields();
... ... @@ -195,8 +175,9 @@ function App(_ref) {
195 175 return _objectSpread(_objectSpread({}, valuesThatWillChange), {}, {
196 176 globalProps: globalProps
197 177 }, rest);
198   - }, [JSON.stringify(flatten), JSON.stringify(formData), JSON.stringify(errorFields), JSON.stringify(globalProps)]); // 不常用的context单独放一个地方
  178 + }, [JSON.stringify(flatten), JSON.stringify(formData), JSON.stringify(errorFields), JSON.stringify(globalProps)]);
199 179
  180 + // 不常用的context单独放一个地方
200 181 var store2 = useMemo(function () {
201 182 return {
202 183 displayType: displayType,
... ... @@ -238,28 +219,23 @@ function App(_ref) {
238 219 if (error) {
239 220 setErrorFields(error);
240 221 }
241   -
242 222 endValidating();
243 223 });
244 224 return;
245   - } // 如果validation结束,submitting开始
246   -
247   -
  225 + }
  226 + // 如果validation结束,submitting开始
248 227 if (isValidating === false && isSubmitting === true) {
249 228 endSubmitting();
250 229 onFinish(submitData, errorFields);
251   -
252 230 if (typeof logOnSubmit === 'function') {
253 231 var start = sessionStorage.getItem('FORM_START');
254 232 var mount = sessionStorage.getItem('FORM_MOUNT_TIME');
255 233 var numberOfSubmits = Number(sessionStorage.getItem('NUMBER_OF_SUBMITS')) + 1;
256 234 var end = new Date().getTime();
257 235 var failedAttempts = Number(sessionStorage.getItem('FAILED_ATTEMPTS'));
258   -
259 236 if (errorFields.length > 0) {
260 237 failedAttempts = failedAttempts + 1;
261 238 }
262   -
263 239 var logParams = {
264 240 formMount: yymmdd(mount),
265 241 ms: end - start,
... ... @@ -271,39 +247,33 @@ function App(_ref) {
271 247 errors: JSON.stringify(errorFields),
272 248 schema: JSON.stringify(schema)
273 249 };
274   -
275 250 if (id) {
276 251 logParams.id = id;
277 252 }
278   -
279 253 logOnSubmit(logParams);
280 254 sessionStorage.setItem('FORM_START', end);
281 255 sessionStorage.setItem('NUMBER_OF_SUBMITS', numberOfSubmits);
282 256 sessionStorage.setItem('FAILED_ATTEMPTS', failedAttempts);
283 257 }
284 258 }
285   - }, [isValidating, isSubmitting, outsideValidating]); // TODO: fk doesn't work
  259 + }, [isValidating, isSubmitting, outsideValidating]);
286 260
  261 + // TODO: fk doesn't work
287 262 var sizeCls = '';
288   -
289 263 if (size === 'small') {
290 264 sizeCls = 'fr-form-small';
291 265 } else if (size === 'large') {
292 266 sizeCls = 'fr-form-large';
293 267 }
294   -
295 268 var rootProps = {
296 269 className: "fr-container ".concat(sizeCls, " ").concat(className || '')
297 270 };
298   -
299 271 if (style && _typeof(style) === 'object') {
300 272 rootProps.style = style;
301 273 }
302   -
303 274 if (id && ['number', 'string'].indexOf(_typeof(id)) > -1) {
304 275 rootProps.id = id;
305 276 }
306   -
307 277 var debugForm = getParamByName('_debug_form');
308 278 var debugFormCss = getParamByName('_debug_form_css');
309 279 var isPre = location.href.indexOf('pre') > -1;
... ... @@ -339,23 +309,18 @@ function App(_ref) {
339 309 debugCss: isPre && debugFormCss || debugCss
340 310 })))));
341 311 }
342   -
343 312 var Wrapper = function Wrapper(props) {
344 313 var _ref2 = props || {},
345   - _ref2$isOldVersion = _ref2.isOldVersion,
346   - isOldVersion = _ref2$isOldVersion === void 0 ? true : _ref2$isOldVersion,
347   - schema = _ref2.schema,
348   - rest = _objectWithoutProperties(_ref2, _excluded3);
349   -
  314 + _ref2$isOldVersion = _ref2.isOldVersion,
  315 + isOldVersion = _ref2$isOldVersion === void 0 ? true : _ref2$isOldVersion,
  316 + schema = _ref2.schema,
  317 + rest = _objectWithoutProperties(_ref2, _excluded3);
350 318 var _schema = useRef(schema);
351   -
352 319 if (isOldVersion) {
353 320 _schema.current = updateSchemaToNewVersion(schema);
354 321 }
355   -
356 322 return /*#__PURE__*/React.createElement(App, _extends({
357 323 schema: _schema.current
358 324 }, rest));
359 325 };
360   -
361 326 export default Wrapper;
\ No newline at end of file
... ...
... ... @@ -31,47 +31,42 @@ export var mapping = {
31 31 'array?enum': 'checkboxes',
32 32 'array?enum_long': 'multiSelect',
33 33 '*?readOnly': 'html' // TODO: html widgets for list / object
34   -
35 34 };
  35 +
36 36 export function getWidgetName(schema) {
37 37 var _mapping = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : mapping;
38   -
39 38 var type = schema.type,
40   - format = schema.format,
41   - enums = schema.enum,
42   - readOnly = schema.readOnly,
43   - widget = schema.widget; // 如果已经注明了渲染widget,那最好
  39 + format = schema.format,
  40 + enums = schema.enum,
  41 + readOnly = schema.readOnly,
  42 + widget = schema.widget;
  43 +
  44 + // 如果已经注明了渲染widget,那最好
44 45 // if (schema['ui:widget']) {
45 46 // return schema['ui:widget'];
46 47 // }
47 48
48 49 var list = [];
49   -
50 50 if (readOnly) {
51 51 list.push("".concat(type, "?readOnly"));
52 52 list.push('*?readOnly');
53 53 }
54   -
55 54 if (enums) {
56 55 // 根据enum长度来智能选择控件
57 56 if (Array.isArray(enums) && (type === 'array' && enums.length > 6 || type !== 'array' && enums.length > 2)) {
58 57 list.push("".concat(type, "?enum_long"));
59 58 list.push('*?enum_long');
60 59 } else {
61   - list.push("".concat(type, "?enum")); // array 默认使用list,array?enum 默认使用checkboxes,*?enum 默认使用select
62   -
  60 + list.push("".concat(type, "?enum"));
  61 + // array 默认使用list,array?enum 默认使用checkboxes,*?enum 默认使用select
63 62 list.push('*?enum');
64 63 }
65 64 }
66   -
67 65 var _widget = widget || format;
68   -
69 66 if (_widget) {
70 67 list.push("".concat(type, ":").concat(_widget));
71 68 }
72   -
73 69 list.push(type); // 放在最后兜底,其他都不match时使用type默认的组件
74   -
75 70 var found = '';
76 71 list.some(function (item) {
77 72 found = _mapping[item];
... ...
1   -function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2   -
3   -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4   -
5   -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6   -
  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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  3 +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
  6 +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); }
7 7 import { get, set, unset } from 'lodash-es';
8   -import { cleanEmpty, clone, isObject, removeEmptyItemFromList, removeHiddenFromResult } from './utils'; // 提交前需要先处理formData的逻辑
9   -
  8 +import { cleanEmpty, clone, isObject, removeEmptyItemFromList, removeHiddenFromResult } from './utils';
  9 +// 提交前需要先处理formData的逻辑
10 10 export var processData = function processData(data, flatten, removeHiddenData) {
11   - var _data = clone(data); // 1. 去掉 hidden = true 的元素
12   -
13   -
  11 + var _data = clone(data);
  12 + // 1. 去掉 hidden = true 的元素
14 13 if (removeHiddenData) {
15 14 _data = removeHiddenFromResult(data, flatten);
16   - } // 2. bind 的处理
17   -
  15 + }
  16 + // 2. bind 的处理
  17 + _data = transformDataWithBind(_data, flatten);
18 18
19   - _data = transformDataWithBind(_data, flatten); // 3. 去掉list里面所有的空值
20   -
21   - _data = removeEmptyItemFromList(_data); // 4. 去掉所有的 undefined
  19 + // 3. 去掉list里面所有的空值
  20 + _data = removeEmptyItemFromList(_data);
22 21
  22 + // 4. 去掉所有的 undefined
23 23 _data = cleanEmpty(_data);
24 24 return _data;
25 25 };
... ... @@ -28,18 +28,14 @@ export var transformDataWithBind = function transformDataWithBind(data, flatten)
28 28 var unbindKeys = [];
29 29 var bindKeys = [];
30 30 var bindArrKeys = [];
31   -
32 31 var isMultiBind = function isMultiBind(bind) {
33 32 return Array.isArray(bind) && bind.every(function (item) {
34 33 return typeof item === 'string';
35 34 });
36 35 };
37   -
38 36 Object.keys(flatten).forEach(function (key) {
39 37 var bind = flatten[key] && flatten[key].schema && flatten[key].schema.bind;
40   -
41 38 var _key = key.replace('[]', '');
42   -
43 39 if (bind === false) {
44 40 unbindKeys.push(_key);
45 41 } else if (typeof bind === 'string') {
... ... @@ -54,30 +50,27 @@ export var transformDataWithBind = function transformDataWithBind(data, flatten)
54 50 });
55 51 }
56 52 });
57   -
58 53 var handleBindData = function handleBindData(formData) {
59 54 unbindKeys.forEach(function (key) {
60 55 unset(formData, key); // TODO: maybe removing upper structure
61 56 });
  57 +
62 58 bindKeys.forEach(function (item) {
63 59 var key = item.key,
64   - bind = item.bind;
  60 + bind = item.bind;
65 61 var temp = get(formData, key);
66 62 var oldVal = get(formData, bind);
67   -
68 63 if (isObject(oldVal)) {
69 64 temp = _objectSpread(_objectSpread({}, oldVal), temp);
70 65 }
71   -
72 66 set(formData, bind, temp);
73 67 unset(formData, key);
74 68 });
75 69 bindArrKeys.forEach(function (item) {
76 70 var key = item.key,
77   - bind = item.bind;
  71 + bind = item.bind;
78 72 var temp = get(formData, key);
79 73 unset(formData, key);
80   -
81 74 if (Array.isArray(temp)) {
82 75 temp.forEach(function (t, i) {
83 76 if (bind[i]) {
... ... @@ -87,27 +80,21 @@ export var transformDataWithBind = function transformDataWithBind(data, flatten)
87 80 }
88 81 });
89 82 };
90   -
91 83 handleBindData(_data);
92 84 return _data;
93 85 };
94 86 export var transformDataWithBind2 = function transformDataWithBind2(data, flatten) {
95 87 var _data = clone(data);
96   -
97 88 var bindKeys = [];
98 89 var bindArrKeys = [];
99   -
100 90 var isMultiBind = function isMultiBind(bind) {
101 91 return Array.isArray(bind) && bind.every(function (item) {
102 92 return typeof item === 'string';
103 93 });
104 94 };
105   -
106 95 Object.keys(flatten).forEach(function (key) {
107 96 var bind = flatten[key] && flatten[key].schema && flatten[key].schema.bind;
108   -
109 97 var _key = key.replace('[]', '');
110   -
111 98 if (typeof bind === 'string') {
112 99 bindKeys.push({
113 100 key: _key,
... ... @@ -120,42 +107,35 @@ export var transformDataWithBind2 = function transformDataWithBind2(data, flatte
120 107 });
121 108 }
122 109 });
123   -
124 110 var handleBindData2 = function handleBindData2(newData) {
125 111 bindKeys.forEach(function (item) {
126 112 var key = item.key,
127   - bind = item.bind;
128   - var temp = get(newData, bind); // 如果已经有值了,要和原来的值合并,而不是覆盖
129   -
  113 + bind = item.bind;
  114 + var temp = get(newData, bind);
  115 + // 如果已经有值了,要和原来的值合并,而不是覆盖
130 116 var oldVal = get(newData, key);
131   -
132 117 if (isObject(oldVal)) {
133 118 temp = _objectSpread(_objectSpread({}, oldVal), temp);
134 119 }
135   -
136 120 set(newData, key, temp);
137 121 unset(newData, bind);
138 122 });
139 123 bindArrKeys.forEach(function (item) {
140 124 var key = item.key,
141   - bind = item.bind;
  125 + bind = item.bind;
142 126 var temp = [];
143 127 bind.forEach(function (b) {
144 128 var bindValue = get(newData, b);
145   -
146 129 if (bindValue !== undefined) {
147 130 temp.push(bindValue);
148 131 }
149   -
150 132 unset(newData, b);
151 133 });
152   -
153 134 if (temp.length > 0) {
154 135 set(newData, key, temp);
155 136 }
156 137 });
157 138 };
158   -
159 139 handleBindData2(_data);
160 140 return _data;
161 141 };
\ No newline at end of file
... ...