@innoways/drip-form-theme-antd 6.0.0 → 6.1.1

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,26 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - modified tree table styles
8
+ - Updated dependencies
9
+ - @innoways/hooks@6.1.1
10
+ - @innoways/utils@6.1.1
11
+
12
+ ## 6.1.0
13
+
14
+ ### Minor Changes
15
+
16
+ - Added tree table feature
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+ - @innoways/hooks@6.1.0
22
+ - @innoways/utils@6.1.0
23
+
3
24
  ## 6.0.0
4
25
 
5
26
  ### Major Changes
package/dist/index.css CHANGED
@@ -16,6 +16,20 @@
16
16
  font-size: 12px;
17
17
  color: rgb(0 0, 0);
18
18
  }
19
+ .drip_table_field_tree .ant-table {
20
+ background: transparent;
21
+ }
22
+ .drip_table_field_tree .ant-table-cell {
23
+ border: none;
24
+ background: transparent;
25
+ }
26
+ .drip_table_field_tree .ant-table-thead > tr > th {
27
+ background: transparent;
28
+ }
29
+ .drip_table_field_tree .ant-table-row:hover > td,
30
+ .drip_table_field_tree .ant-table-cell-row-hover {
31
+ background: none !important;
32
+ }
19
33
 
20
34
  .drip-form--colorpicker {
21
35
  display: flex;
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,
@@ -23895,16 +23960,17 @@ var TableField = function TableField(_ref) {
23895
23960
  preparedColumns = columnsDataIndex.filter(function (item) {
23896
23961
  return !!(item !== null && item !== void 0 && item.column);
23897
23962
  }).map(function (column, i) {
23898
- return {
23963
+ return _objectSpread$1({
23899
23964
  title: (column === null || column === void 0 ? void 0 : column.column) || '',
23900
23965
  dataIndex: (column === null || column === void 0 ? void 0 : column.dataIndex) || i,
23901
- key: (column === null || column === void 0 ? void 0 : column.dataIndex) || i,
23966
+ key: (column === null || column === void 0 ? void 0 : column.dataIndex) || i
23967
+ }, tableMode !== 'tree' ? {
23902
23968
  sorter: function sorter(a, b) {
23903
23969
  var _a$column$dataIndex;
23904
23970
 
23905
23971
  return (_a$column$dataIndex = a[column === null || column === void 0 ? void 0 : column.dataIndex]) === null || _a$column$dataIndex === void 0 ? void 0 : _a$column$dataIndex.localeCompare(b[column === null || column === void 0 ? void 0 : column.dataIndex]);
23906
23972
  }
23907
- };
23973
+ } : {});
23908
23974
  });
23909
23975
 
23910
23976
  if (preparedColumns.length && (showEdit || showDelete)) {
@@ -23951,6 +24017,22 @@ var TableField = function TableField(_ref) {
23951
24017
  });
23952
24018
  };
23953
24019
 
24020
+ var setChildPrimaryKey = function setChildPrimaryKey(record, parentIndex) {
24021
+ var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
24022
+
24023
+ if (Array.isArray(record[childrenColumnName]) && record[childrenColumnName].length) {
24024
+ record[childrenColumnName] = record[childrenColumnName].map(function (item, index) {
24025
+ var _objectSpread2;
24026
+
24027
+ var childPrimaryvalue = setChildPrimaryKey(item, level + 1, index)[childPrimaryKey];
24028
+ 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));
24029
+ });
24030
+ }
24031
+
24032
+ record["".concat(primaryColumnId, "_unique")] = "".concat(level, ".").concat(parentIndex + 1);
24033
+ return record;
24034
+ };
24035
+
23954
24036
  useEffect(function () {
23955
24037
  if (optionData === 'staticData' && formMode !== 'generator' && Array.isArray(values) && values.length && Array.isArray(columns) && columns.filter(function (item) {
23956
24038
  return !!item;
@@ -23982,14 +24064,32 @@ var TableField = function TableField(_ref) {
23982
24064
  headers: configHeaders,
23983
24065
  jsonkey: jsonkey
23984
24066
  };
24067
+ setLoading(true);
23985
24068
  fetchFnJsonKey({
23986
24069
  config: config,
23987
- dataSetter: setDynamicValues
24070
+ dataSetter: function dataSetter(data) {
24071
+ if (Array.isArray(data) && tableMode === 'tree') {
24072
+ var ids = data.filter(function (md) {
24073
+ return md[childrenColumnName];
24074
+ }).map(function (md) {
24075
+ return md[primaryColumnId];
24076
+ });
24077
+ setExpandedRowKeys(ids);
24078
+ setDynamicValues(data.map(function (item, index) {
24079
+ return setChildPrimaryKey(item, index);
24080
+ }));
24081
+ } else {
24082
+ setDynamicValues(data);
24083
+ }
24084
+ },
24085
+ doFinally: function doFinally() {
24086
+ setLoading(false);
24087
+ }
23988
24088
  });
23989
24089
  } else if (optionData === 'dynamicData') {
23990
24090
  setDynamicValues([]);
23991
24091
  }
23992
- }, [optionData, formMode, url, columns, values, method, jsonkey]);
24092
+ }, [optionData, formMode, url, columns, values, method, jsonkey, tableMode]);
23993
24093
 
23994
24094
  var handleAdd = function handleAdd() {
23995
24095
  if (restProps !== null && restProps !== void 0 && restProps.addApiUrl && isValidHttpUrl(restProps.addApiUrl)) {
@@ -24011,7 +24111,7 @@ var TableField = function TableField(_ref) {
24011
24111
  onClick: function onClick() {
24012
24112
  return handleAdd();
24013
24113
  }
24014
- }, "Add")), restProps !== null && restProps !== void 0 && restProps.advanceSearch ? /*#__PURE__*/React.createElement(_Button, {
24114
+ }, "Add")), searchVisible ? restProps !== null && restProps !== void 0 && restProps.advanceSearch ? /*#__PURE__*/React.createElement(_Button, {
24015
24115
  onClick: function onClick() {
24016
24116
  return setOpenModal(true);
24017
24117
  }
@@ -24020,7 +24120,32 @@ var TableField = function TableField(_ref) {
24020
24120
  style: {
24021
24121
  width: '200px'
24022
24122
  }
24023
- }));
24123
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null));
24124
+ };
24125
+
24126
+ function getDepth(arr, item) {
24127
+ var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
24128
+
24129
+ for (var i = 0; i < arr.length; i++) {
24130
+ if (arr[i][primaryColumnId] === item[primaryColumnId] && arr[i]["".concat(primaryColumnId, "_unique")] === item["".concat(primaryColumnId, "_unique")]) {
24131
+ return "".concat(depth).concat(i + 1, ". ");
24132
+ }
24133
+
24134
+ if (arr[i][childrenColumnName] && arr[i][childrenColumnName].length) {
24135
+ var childDepth = getDepth(arr[i][childrenColumnName], item, "".concat(depth).concat(i + 1, "."));
24136
+
24137
+ if (childDepth) {
24138
+ return "".concat(childDepth);
24139
+ }
24140
+ }
24141
+ }
24142
+
24143
+ return ''; // Item not found
24144
+ }
24145
+
24146
+ var renderPrefix = function renderPrefix(record) {
24147
+ var depth = getDepth(dynamicValues, record);
24148
+ return depth;
24024
24149
  };
24025
24150
 
24026
24151
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Modal, {
@@ -24034,11 +24159,26 @@ var TableField = function TableField(_ref) {
24034
24159
  return setOpenModal(false);
24035
24160
  }
24036
24161
  }), renderActions(), /*#__PURE__*/React.createElement(_Table, _extends({
24162
+ className: tableMode === 'tree' ? 'drip_table_field_tree' : '',
24037
24163
  pagination: pagination === 'yes' ? {
24038
24164
  pageSize: Number(amountOfDataPerPage) || 20
24039
24165
  } : false,
24166
+ rowKey: primaryColumnId,
24040
24167
  dataSource: dynamicValues,
24041
24168
  columns: columnSource()
24169
+ }, tableMode === 'tree' ? {
24170
+ expandable: {
24171
+ childrenColumnName: childrenColumnName,
24172
+ expandedRowKeys: expandedRowKeys,
24173
+ expandIcon: function expandIcon(_ref2) {
24174
+ _ref2.expanded;
24175
+ _ref2.onExpand;
24176
+ var record = _ref2.record;
24177
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderPrefix(record));
24178
+ }
24179
+ }
24180
+ } : {}, {
24181
+ loading: loading
24042
24182
  }, restProps)));
24043
24183
  };
24044
24184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innoways/drip-form-theme-antd",
3
- "version": "6.0.0",
3
+ "version": "6.1.1",
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": "^6.0.0",
35
- "@innoways/utils": "^6.0.0",
34
+ "@innoways/hooks": "^6.1.1",
35
+ "@innoways/utils": "^6.1.1",
36
36
  "moment": "^2.26.0",
37
37
  "react-color": "^2.18.1",
38
38
  "use-immer": "^0.6.0"