@innoways/drip-form-theme-antd 5.0.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added tree table feature
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @innoways/hooks@6.1.0
13
+ - @innoways/utils@6.1.0
14
+
15
+ ## 6.0.0
16
+
17
+ ### Major Changes
18
+
19
+ - major datefix
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+ - @innoways/hooks@6.0.0
25
+ - @innoways/utils@6.0.0
26
+
3
27
  ## 5.0.1
4
28
 
5
29
  ### Patch Changes
package/dist/index.js CHANGED
@@ -23498,12 +23498,21 @@ var config$1 = {
23498
23498
  },
23499
23499
  propertyConfig: {
23500
23500
  styleSchema: [{
23501
+ fieldKey: 'searchVisible',
23502
+ type: 'boolean',
23503
+ title: 'Is search visible',
23504
+ "default": true,
23505
+ ui: {
23506
+ type: 'switch'
23507
+ }
23508
+ }, {
23501
23509
  fieldKey: 'advanceSearch',
23502
23510
  type: 'boolean',
23503
23511
  title: 'Advance Search',
23504
23512
  "default": false,
23505
23513
  ui: {
23506
- type: 'switch'
23514
+ type: 'switch',
23515
+ vcontrol: 'return props.formData.ui.searchVisible === true'
23507
23516
  }
23508
23517
  }, {
23509
23518
  type: 'string',
@@ -23670,6 +23679,44 @@ var config$1 = {
23670
23679
  vcontrol: 'return props.formData.ui.optionData === "dynamicData"'
23671
23680
  },
23672
23681
  fieldKey: 'primaryColumnId'
23682
+ }, {
23683
+ type: 'string',
23684
+ title: 'Table Mode',
23685
+ "default": 'normal',
23686
+ ui: {
23687
+ type: 'radio',
23688
+ vcontrol: 'return props.formData.ui.optionData === "dynamicData"',
23689
+ options: [{
23690
+ value: 'normal',
23691
+ label: 'Normal'
23692
+ }, {
23693
+ value: 'tree',
23694
+ label: 'Tree'
23695
+ }]
23696
+ },
23697
+ fieldKey: 'tableMode'
23698
+ }, {
23699
+ type: 'string',
23700
+ title: 'Child key name',
23701
+ "default": 'children',
23702
+ ui: {
23703
+ type: 'text',
23704
+ theme: 'antd',
23705
+ placeholder: 'child key name',
23706
+ vcontrol: 'return props.formData.ui.optionData === "dynamicData" && props.formData.ui.tableMode === "tree"'
23707
+ },
23708
+ fieldKey: 'childrenColumnName'
23709
+ }, {
23710
+ type: 'string',
23711
+ title: 'Child Primary Key',
23712
+ "default": '',
23713
+ ui: {
23714
+ type: 'text',
23715
+ theme: 'antd',
23716
+ placeholder: 'child primary key',
23717
+ vcontrol: 'return props.formData.ui.optionData === "dynamicData"'
23718
+ },
23719
+ fieldKey: 'childPrimaryKey'
23673
23720
  }, {
23674
23721
  type: 'array',
23675
23722
  title: 'Columns & Value Key',
@@ -23791,7 +23838,7 @@ var config$1 = {
23791
23838
  }
23792
23839
  };
23793
23840
 
23794
- var _excluded$2 = ["disabled", "onChange", "fieldData", "fieldKey", "dispatch", "style", "asyncValidate", "getKey", "columns", "columnsDataIndex", "values", "formMode", "optionData", "pagination", "amountOfDataPerPage", "url", "method", "jsonkey", "headers", "showAdd", "showEdit", "showDelete", "primaryColumnId"];
23841
+ var _excluded$2 = ["disabled", "onChange", "fieldData", "fieldKey", "dispatch", "style", "asyncValidate", "getKey", "columns", "columnsDataIndex", "values", "formMode", "optionData", "pagination", "amountOfDataPerPage", "url", "method", "jsonkey", "headers", "showAdd", "showEdit", "showDelete", "primaryColumnId", "childrenColumnName", "childPrimaryKey", "tableMode", "searchVisible"];
23795
23842
 
23796
23843
  function ownKeys$1(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; }
23797
23844
 
@@ -23833,7 +23880,15 @@ var TableField = function TableField(_ref) {
23833
23880
  _ref$showDelete = _ref.showDelete,
23834
23881
  showDelete = _ref$showDelete === void 0 ? true : _ref$showDelete,
23835
23882
  _ref$primaryColumnId = _ref.primaryColumnId,
23836
- primaryColumnId = _ref$primaryColumnId === void 0 ? '' : _ref$primaryColumnId,
23883
+ primaryColumnId = _ref$primaryColumnId === void 0 ? 'key' : _ref$primaryColumnId,
23884
+ _ref$childrenColumnNa = _ref.childrenColumnName,
23885
+ childrenColumnName = _ref$childrenColumnNa === void 0 ? 'children' : _ref$childrenColumnNa,
23886
+ _ref$childPrimaryKey = _ref.childPrimaryKey,
23887
+ childPrimaryKey = _ref$childPrimaryKey === void 0 ? '' : _ref$childPrimaryKey,
23888
+ _ref$tableMode = _ref.tableMode,
23889
+ tableMode = _ref$tableMode === void 0 ? 'normal' : _ref$tableMode,
23890
+ _ref$searchVisible = _ref.searchVisible,
23891
+ searchVisible = _ref$searchVisible === void 0 ? true : _ref$searchVisible,
23837
23892
  restProps = _objectWithoutProperties(_ref, _excluded$2);
23838
23893
 
23839
23894
  var _useState = useState([]),
@@ -23846,6 +23901,16 @@ var TableField = function TableField(_ref) {
23846
23901
  openModal = _useState4[0],
23847
23902
  setOpenModal = _useState4[1];
23848
23903
 
23904
+ var _React$useState = React.useState([]),
23905
+ _React$useState2 = _slicedToArray(_React$useState, 2),
23906
+ expandedRowKeys = _React$useState2[0],
23907
+ setExpandedRowKeys = _React$useState2[1];
23908
+
23909
+ var _React$useState3 = React.useState(false),
23910
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
23911
+ loading = _React$useState4[0],
23912
+ setLoading = _React$useState4[1];
23913
+
23849
23914
  useField({
23850
23915
  fieldKey: fieldKey,
23851
23916
  onChange: onChange,
@@ -23951,6 +24016,22 @@ var TableField = function TableField(_ref) {
23951
24016
  });
23952
24017
  };
23953
24018
 
24019
+ var setChildPrimaryKey = function setChildPrimaryKey(record, parentIndex) {
24020
+ var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
24021
+
24022
+ if (Array.isArray(record[childrenColumnName]) && record[childrenColumnName].length) {
24023
+ record[childrenColumnName] = record[childrenColumnName].map(function (item, index) {
24024
+ var _objectSpread2;
24025
+
24026
+ var childPrimaryvalue = setChildPrimaryKey(item, level + 1, index)[childPrimaryKey];
24027
+ return _objectSpread$1(_objectSpread$1({}, item), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, primaryColumnId, childPrimaryKey && childPrimaryvalue ? childPrimaryvalue : ''), _defineProperty(_objectSpread2, "".concat(primaryColumnId, "_unique"), "".concat(parentIndex).concat(level, ".").concat(index + 1)), _objectSpread2));
24028
+ });
24029
+ }
24030
+
24031
+ record["".concat(primaryColumnId, "_unique")] = "".concat(level, ".").concat(parentIndex + 1);
24032
+ return record;
24033
+ };
24034
+
23954
24035
  useEffect(function () {
23955
24036
  if (optionData === 'staticData' && formMode !== 'generator' && Array.isArray(values) && values.length && Array.isArray(columns) && columns.filter(function (item) {
23956
24037
  return !!item;
@@ -23982,14 +24063,32 @@ var TableField = function TableField(_ref) {
23982
24063
  headers: configHeaders,
23983
24064
  jsonkey: jsonkey
23984
24065
  };
24066
+ setLoading(true);
23985
24067
  fetchFnJsonKey({
23986
24068
  config: config,
23987
- dataSetter: setDynamicValues
24069
+ dataSetter: function dataSetter(data) {
24070
+ if (Array.isArray(data) && tableMode === 'tree') {
24071
+ var ids = data.filter(function (md) {
24072
+ return md[childrenColumnName];
24073
+ }).map(function (md) {
24074
+ return md[primaryColumnId];
24075
+ });
24076
+ setExpandedRowKeys(ids);
24077
+ setDynamicValues(data.map(function (item, index) {
24078
+ return setChildPrimaryKey(item, index);
24079
+ }));
24080
+ } else {
24081
+ setDynamicValues(data);
24082
+ }
24083
+ },
24084
+ doFinally: function doFinally() {
24085
+ setLoading(false);
24086
+ }
23988
24087
  });
23989
24088
  } else if (optionData === 'dynamicData') {
23990
24089
  setDynamicValues([]);
23991
24090
  }
23992
- }, [optionData, formMode, url, columns, values, method, jsonkey]);
24091
+ }, [optionData, formMode, url, columns, values, method, jsonkey, tableMode]);
23993
24092
 
23994
24093
  var handleAdd = function handleAdd() {
23995
24094
  if (restProps !== null && restProps !== void 0 && restProps.addApiUrl && isValidHttpUrl(restProps.addApiUrl)) {
@@ -24011,7 +24110,7 @@ var TableField = function TableField(_ref) {
24011
24110
  onClick: function onClick() {
24012
24111
  return handleAdd();
24013
24112
  }
24014
- }, "Add")), restProps !== null && restProps !== void 0 && restProps.advanceSearch ? /*#__PURE__*/React.createElement(_Button, {
24113
+ }, "Add")), searchVisible ? restProps !== null && restProps !== void 0 && restProps.advanceSearch ? /*#__PURE__*/React.createElement(_Button, {
24015
24114
  onClick: function onClick() {
24016
24115
  return setOpenModal(true);
24017
24116
  }
@@ -24020,7 +24119,32 @@ var TableField = function TableField(_ref) {
24020
24119
  style: {
24021
24120
  width: '200px'
24022
24121
  }
24023
- }));
24122
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null));
24123
+ };
24124
+
24125
+ function getDepth(arr, item) {
24126
+ var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
24127
+
24128
+ for (var i = 0; i < arr.length; i++) {
24129
+ if (arr[i][primaryColumnId] === item[primaryColumnId] && arr[i]["".concat(primaryColumnId, "_unique")] === item["".concat(primaryColumnId, "_unique")]) {
24130
+ return "".concat(depth).concat(i + 1, ". ");
24131
+ }
24132
+
24133
+ if (arr[i][childrenColumnName] && arr[i][childrenColumnName].length) {
24134
+ var childDepth = getDepth(arr[i][childrenColumnName], item, "".concat(depth).concat(i + 1, "."));
24135
+
24136
+ if (childDepth) {
24137
+ return "".concat(childDepth);
24138
+ }
24139
+ }
24140
+ }
24141
+
24142
+ return ''; // Item not found
24143
+ }
24144
+
24145
+ var renderPrefix = function renderPrefix(record) {
24146
+ var depth = getDepth(dynamicValues, record);
24147
+ return depth;
24024
24148
  };
24025
24149
 
24026
24150
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Modal, {
@@ -24037,8 +24161,22 @@ var TableField = function TableField(_ref) {
24037
24161
  pagination: pagination === 'yes' ? {
24038
24162
  pageSize: Number(amountOfDataPerPage) || 20
24039
24163
  } : false,
24164
+ rowKey: primaryColumnId,
24040
24165
  dataSource: dynamicValues,
24041
24166
  columns: columnSource()
24167
+ }, tableMode === 'tree' ? {
24168
+ expandable: {
24169
+ childrenColumnName: childrenColumnName,
24170
+ expandedRowKeys: expandedRowKeys,
24171
+ expandIcon: function expandIcon(_ref2) {
24172
+ _ref2.expanded;
24173
+ _ref2.onExpand;
24174
+ var record = _ref2.record;
24175
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderPrefix(record));
24176
+ }
24177
+ }
24178
+ } : {}, {
24179
+ loading: loading
24042
24180
  }, restProps)));
24043
24181
  };
24044
24182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innoways/drip-form-theme-antd",
3
- "version": "5.0.1",
3
+ "version": "6.1.0",
4
4
  "author": "JDFED",
5
5
  "description": "drip-form antd主题包",
6
6
  "main": "dist/index.js",
@@ -31,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "@ant-design/icons": "^4.7.0",
33
33
  "@babel/runtime": "^7.10.2",
34
- "@innoways/hooks": "^5.0.0",
35
- "@innoways/utils": "^5.0.0",
34
+ "@innoways/hooks": "^6.1.0",
35
+ "@innoways/utils": "^6.1.0",
36
36
  "moment": "^2.26.0",
37
37
  "react-color": "^2.18.1",
38
38
  "use-immer": "^0.6.0"