@nokecy/qc-ui 1.0.48 → 1.0.50

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.
@@ -48,6 +48,7 @@ var ArrayTable = (0, _react2.observer)(function (props) {
48
48
  var dataSource = Array.isArray(field.value) ? field.value.slice() : [];
49
49
  var dataSourceCopy = dataSource.slice();
50
50
  var sources = (0, _utils.useArrayTableSources)();
51
+ var actions = (0, _utils.useArrayTableActions)();
51
52
  var columns = (0, _utils.useArrayTableColumns)(dataSource, field, sources);
52
53
  var schema = (0, _react2.useFieldSchema)();
53
54
  //@ts-ignore
@@ -61,67 +62,6 @@ var ArrayTable = (0, _react2.observer)(function (props) {
61
62
  onSaveColumnState = _useGridPlusColumnSta.onSaveColumnState,
62
63
  gridPlusColumnState = _useGridPlusColumnSta.columnState,
63
64
  extensibleColumns = _useGridPlusColumnSta.extensibleColumns;
64
- // const teststyle = '[{\"id\":\"18\",\"field\":\"xdxcp47tycp\",\"headerName\":\"A1\",\"width\":800,\"hide\":false,\"colId\":\"a1\",\"pinned\":null,\"sort\":null,\"sortIndex\":null,\"aggFunc\":null,\"rowGroup\":false,\"rowGroupIndex\":null,\"pivot\":false,\"pivotIndex\":null,\"flex\":null},{\"id\":\"19\",\"field\":\"nvhezzkyak9\",\"headerName\":\"Operations\",\"width\":60,\"hide\":false,\"colId\":\"nvhezzkyak9\",\"pinned\":null,\"sort\":null,\"sortIndex\":null,\"aggFunc\":null,\"rowGroup\":false,\"rowGroupIndex\":null,\"pivot\":false,\"pivotIndex\":null,\"flex\":null}]'
65
- // const teststyle = [
66
- // {
67
- // "id": "5",
68
- // "field": "NO_NAME_FIELD_$1",
69
- // "headerName": "Index",
70
- // "width": 80,
71
- // "hide": false,
72
- // "cellClass": "custom-cell-left",
73
- // "suppressHeaderFilterButton": true,
74
- // "colId": "NO_NAME_FIELD_$1",
75
- // "pinned": null,
76
- // "sort": null,
77
- // "sortIndex": null,
78
- // "aggFunc": null,
79
- // "rowGroup": false,
80
- // "rowGroupIndex": null,
81
- // "pivot": false,
82
- // "pivotIndex": null,
83
- // "flex": null
84
- // },
85
- // {
86
- // "id": "6",
87
- // "field": "a1",
88
- // "headerName": "A1",
89
- // "width": 1200,
90
- // "hide": false,
91
- // "cellClass": "custom-cell-left",
92
- // "suppressHeaderFilterButton": true,
93
- // "colId": "a1",
94
- // "pinned": null,
95
- // "sort": null,
96
- // "sortIndex": null,
97
- // "aggFunc": null,
98
- // "rowGroup": false,
99
- // "rowGroupIndex": null,
100
- // "pivot": false,
101
- // "pivotIndex": null,
102
- // "flex": null
103
- // },
104
- // {
105
- // "id": "7",
106
- // "field": "operations",
107
- // "headerName": "Operations",
108
- // "width": 80,
109
- // "hide": false,
110
- // "cellClass": "custom-cell-left",
111
- // "suppressHeaderFilterButton": true,
112
- // "colId": "operations",
113
- // "pinned": "right",
114
- // "sort": null,
115
- // "sortIndex": null,
116
- // "aggFunc": null,
117
- // "rowGroup": false,
118
- // "rowGroupIndex": null,
119
- // "pivot": false,
120
- // "pivotIndex": null,
121
- // "flex": null
122
- // }
123
- // ]
124
-
125
65
  (0, _react.useEffect)(function () {
126
66
  if (props.gridKey && gridPlusColumnState && gridPlusColumnState[props.gridKey] && apiRef.current) {
127
67
  setTimeout(function () {
@@ -179,7 +119,13 @@ var ArrayTable = (0, _react2.observer)(function (props) {
179
119
  onAdd: function onAdd() {
180
120
  setIsAdd(true);
181
121
  }
182
- }, addition.props)) : null), /*#__PURE__*/_react.default.createElement("div", {
122
+ }, addition.props)) : null, actions.map(function (column, key) {
123
+ return /*#__PURE__*/_react.default.createElement(_react2.RecursionField, {
124
+ schema: column.schema,
125
+ name: key,
126
+ onlyRenderProperties: true
127
+ });
128
+ })), /*#__PURE__*/_react.default.createElement("div", {
183
129
  ref: ref,
184
130
  style: {
185
131
  height: height ? height : 400
@@ -5,6 +5,7 @@ import { Schema } from '@formily/json-schema';
5
5
  import { ObservableColumnSource } from './interface';
6
6
  declare const isColumnComponent: (schema: Schema) => boolean;
7
7
  declare const useArrayTableSources: () => ObservableColumnSource[];
8
+ declare const useArrayTableActions: () => ObservableColumnSource[];
8
9
  declare const useArrayTableColumns: (dataSource: any[], field: ArrayField, sources: ObservableColumnSource[]) => AgGridReactProps['columnDefs'];
9
10
  declare const useAddition: () => React.JSX.Element | null;
10
- export { isColumnComponent, useArrayTableSources, useArrayTableColumns, useAddition };
11
+ export { isColumnComponent, useArrayTableSources, useArrayTableActions, useArrayTableColumns, useAddition };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useArrayTableSources = exports.useArrayTableColumns = exports.useAddition = exports.isColumnComponent = void 0;
6
+ exports.useArrayTableSources = exports.useArrayTableColumns = exports.useArrayTableActions = exports.useAddition = exports.isColumnComponent = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _react2 = require("@formily/react");
9
9
  var _shared = require("@formily/shared");
@@ -27,6 +27,10 @@ var isAdditionComponent = function isAdditionComponent(schema) {
27
27
  var _schema$xComponent3;
28
28
  return ((_schema$xComponent3 = schema['x-component']) === null || _schema$xComponent3 === void 0 ? void 0 : _schema$xComponent3.indexOf('Addition')) > -1;
29
29
  };
30
+ var isActionComponent = function isActionComponent(schema) {
31
+ var _schema$xComponent4;
32
+ return schema && ((_schema$xComponent4 = schema['x-component']) === null || _schema$xComponent4 === void 0 ? void 0 : _schema$xComponent4.indexOf('Action')) > -1;
33
+ };
30
34
  var useArrayTableSources = exports.useArrayTableSources = function useArrayTableSources() {
31
35
  var arrayField = (0, _react2.useField)();
32
36
  var schema = (0, _react2.useFieldSchema)();
@@ -70,6 +74,37 @@ var useArrayTableSources = exports.useArrayTableSources = function useArrayTable
70
74
  if (!schema) throw new Error('can not found schema object');
71
75
  return parseArrayItems(schema.items);
72
76
  };
77
+ var useArrayTableActions = exports.useArrayTableActions = function useArrayTableActions() {
78
+ var arrayField = (0, _react2.useField)();
79
+ var schema = (0, _react2.useFieldSchema)();
80
+ var parseSources = function parseSources(schema) {
81
+ if (isActionComponent(schema)) {
82
+ var _schema$xComponentP3, _schema$xComponentP4, _field$component2;
83
+ if (!((_schema$xComponentP3 = schema['x-component-props']) !== null && _schema$xComponentP3 !== void 0 && _schema$xComponentP3['dataIndex']) && !schema['name']) return [];
84
+ var name = ((_schema$xComponentP4 = schema['x-component-props']) === null || _schema$xComponentP4 === void 0 ? void 0 : _schema$xComponentP4['dataIndex']) || schema['name'];
85
+ var field = arrayField.query(arrayField.address.concat(name)).take();
86
+ //@ts-ignore
87
+ var columnProps = (field === null || field === void 0 || (_field$component2 = field.component) === null || _field$component2 === void 0 ? void 0 : _field$component2[1]) || schema['x-component-props'] || {};
88
+ var display = (field === null || field === void 0 ? void 0 : field.display) || schema['x-display'];
89
+ return [{
90
+ name: name,
91
+ display: display,
92
+ //@ts-ignore
93
+ field: field,
94
+ schema: schema,
95
+ columnProps: columnProps
96
+ }];
97
+ } else if (schema.properties) {
98
+ return schema.reduceProperties(function (buf, schema) {
99
+ //@ts-ignore
100
+ return buf.concat(parseSources(schema));
101
+ }, []);
102
+ }
103
+ return [];
104
+ };
105
+ if (!schema) throw new Error('can not found schema object');
106
+ return schema.properties ? parseSources(schema.properties['actions'] || {}) : [];
107
+ };
73
108
  var AgField = function AgField(_ref) {
74
109
  var value = _ref.value,
75
110
  record = _ref.data,
@@ -17,7 +17,7 @@ import { useField, observer, RecursionField } from "@formily/react";
17
17
  import { useFieldSchema } from "@formily/react";
18
18
  import { connect, mapProps, mapReadPretty } from "@formily/react";
19
19
  import uniqueId from "lodash/uniqueId";
20
- import { useAddition, useArrayTableColumns, useArrayTableSources, isColumnComponent } from "./utils";
20
+ import { useAddition, useArrayTableColumns, useArrayTableSources, useArrayTableActions, isColumnComponent } from "./utils";
21
21
  import ArrayBase from "./arrayBase";
22
22
  import ArrayAddBtn from "./arrayAddBtn";
23
23
  import PreviewArrayTable from "./preview";
@@ -42,6 +42,7 @@ var ArrayTable = observer(function (props) {
42
42
  var dataSource = Array.isArray(field.value) ? field.value.slice() : [];
43
43
  var dataSourceCopy = dataSource.slice();
44
44
  var sources = useArrayTableSources();
45
+ var actions = useArrayTableActions();
45
46
  var columns = useArrayTableColumns(dataSource, field, sources);
46
47
  var schema = useFieldSchema();
47
48
  //@ts-ignore
@@ -55,67 +56,6 @@ var ArrayTable = observer(function (props) {
55
56
  onSaveColumnState = _useGridPlusColumnSta.onSaveColumnState,
56
57
  gridPlusColumnState = _useGridPlusColumnSta.columnState,
57
58
  extensibleColumns = _useGridPlusColumnSta.extensibleColumns;
58
- // const teststyle = '[{\"id\":\"18\",\"field\":\"xdxcp47tycp\",\"headerName\":\"A1\",\"width\":800,\"hide\":false,\"colId\":\"a1\",\"pinned\":null,\"sort\":null,\"sortIndex\":null,\"aggFunc\":null,\"rowGroup\":false,\"rowGroupIndex\":null,\"pivot\":false,\"pivotIndex\":null,\"flex\":null},{\"id\":\"19\",\"field\":\"nvhezzkyak9\",\"headerName\":\"Operations\",\"width\":60,\"hide\":false,\"colId\":\"nvhezzkyak9\",\"pinned\":null,\"sort\":null,\"sortIndex\":null,\"aggFunc\":null,\"rowGroup\":false,\"rowGroupIndex\":null,\"pivot\":false,\"pivotIndex\":null,\"flex\":null}]'
59
- // const teststyle = [
60
- // {
61
- // "id": "5",
62
- // "field": "NO_NAME_FIELD_$1",
63
- // "headerName": "Index",
64
- // "width": 80,
65
- // "hide": false,
66
- // "cellClass": "custom-cell-left",
67
- // "suppressHeaderFilterButton": true,
68
- // "colId": "NO_NAME_FIELD_$1",
69
- // "pinned": null,
70
- // "sort": null,
71
- // "sortIndex": null,
72
- // "aggFunc": null,
73
- // "rowGroup": false,
74
- // "rowGroupIndex": null,
75
- // "pivot": false,
76
- // "pivotIndex": null,
77
- // "flex": null
78
- // },
79
- // {
80
- // "id": "6",
81
- // "field": "a1",
82
- // "headerName": "A1",
83
- // "width": 1200,
84
- // "hide": false,
85
- // "cellClass": "custom-cell-left",
86
- // "suppressHeaderFilterButton": true,
87
- // "colId": "a1",
88
- // "pinned": null,
89
- // "sort": null,
90
- // "sortIndex": null,
91
- // "aggFunc": null,
92
- // "rowGroup": false,
93
- // "rowGroupIndex": null,
94
- // "pivot": false,
95
- // "pivotIndex": null,
96
- // "flex": null
97
- // },
98
- // {
99
- // "id": "7",
100
- // "field": "operations",
101
- // "headerName": "Operations",
102
- // "width": 80,
103
- // "hide": false,
104
- // "cellClass": "custom-cell-left",
105
- // "suppressHeaderFilterButton": true,
106
- // "colId": "operations",
107
- // "pinned": "right",
108
- // "sort": null,
109
- // "sortIndex": null,
110
- // "aggFunc": null,
111
- // "rowGroup": false,
112
- // "rowGroupIndex": null,
113
- // "pivot": false,
114
- // "pivotIndex": null,
115
- // "flex": null
116
- // }
117
- // ]
118
-
119
59
  useEffect(function () {
120
60
  if (props.gridKey && gridPlusColumnState && gridPlusColumnState[props.gridKey] && apiRef.current) {
121
61
  setTimeout(function () {
@@ -173,7 +113,13 @@ var ArrayTable = observer(function (props) {
173
113
  onAdd: function onAdd() {
174
114
  setIsAdd(true);
175
115
  }
176
- }, addition.props)) : null), /*#__PURE__*/React.createElement("div", {
116
+ }, addition.props)) : null, actions.map(function (column, key) {
117
+ return /*#__PURE__*/React.createElement(RecursionField, {
118
+ schema: column.schema,
119
+ name: key,
120
+ onlyRenderProperties: true
121
+ });
122
+ })), /*#__PURE__*/React.createElement("div", {
177
123
  ref: ref,
178
124
  style: {
179
125
  height: height ? height : 400
@@ -5,6 +5,7 @@ import { Schema } from '@formily/json-schema';
5
5
  import { ObservableColumnSource } from './interface';
6
6
  declare const isColumnComponent: (schema: Schema) => boolean;
7
7
  declare const useArrayTableSources: () => ObservableColumnSource[];
8
+ declare const useArrayTableActions: () => ObservableColumnSource[];
8
9
  declare const useArrayTableColumns: (dataSource: any[], field: ArrayField, sources: ObservableColumnSource[]) => AgGridReactProps['columnDefs'];
9
10
  declare const useAddition: () => React.JSX.Element | null;
10
- export { isColumnComponent, useArrayTableSources, useArrayTableColumns, useAddition };
11
+ export { isColumnComponent, useArrayTableSources, useArrayTableActions, useArrayTableColumns, useAddition };
@@ -20,6 +20,10 @@ var isAdditionComponent = function isAdditionComponent(schema) {
20
20
  var _schema$xComponent3;
21
21
  return ((_schema$xComponent3 = schema['x-component']) === null || _schema$xComponent3 === void 0 ? void 0 : _schema$xComponent3.indexOf('Addition')) > -1;
22
22
  };
23
+ var isActionComponent = function isActionComponent(schema) {
24
+ var _schema$xComponent4;
25
+ return schema && ((_schema$xComponent4 = schema['x-component']) === null || _schema$xComponent4 === void 0 ? void 0 : _schema$xComponent4.indexOf('Action')) > -1;
26
+ };
23
27
  var useArrayTableSources = function useArrayTableSources() {
24
28
  var arrayField = useField();
25
29
  var schema = useFieldSchema();
@@ -63,6 +67,37 @@ var useArrayTableSources = function useArrayTableSources() {
63
67
  if (!schema) throw new Error('can not found schema object');
64
68
  return parseArrayItems(schema.items);
65
69
  };
70
+ var useArrayTableActions = function useArrayTableActions() {
71
+ var arrayField = useField();
72
+ var schema = useFieldSchema();
73
+ var parseSources = function parseSources(schema) {
74
+ if (isActionComponent(schema)) {
75
+ var _schema$xComponentP3, _schema$xComponentP4, _field$component2;
76
+ if (!((_schema$xComponentP3 = schema['x-component-props']) !== null && _schema$xComponentP3 !== void 0 && _schema$xComponentP3['dataIndex']) && !schema['name']) return [];
77
+ var name = ((_schema$xComponentP4 = schema['x-component-props']) === null || _schema$xComponentP4 === void 0 ? void 0 : _schema$xComponentP4['dataIndex']) || schema['name'];
78
+ var field = arrayField.query(arrayField.address.concat(name)).take();
79
+ //@ts-ignore
80
+ var columnProps = (field === null || field === void 0 || (_field$component2 = field.component) === null || _field$component2 === void 0 ? void 0 : _field$component2[1]) || schema['x-component-props'] || {};
81
+ var display = (field === null || field === void 0 ? void 0 : field.display) || schema['x-display'];
82
+ return [{
83
+ name: name,
84
+ display: display,
85
+ //@ts-ignore
86
+ field: field,
87
+ schema: schema,
88
+ columnProps: columnProps
89
+ }];
90
+ } else if (schema.properties) {
91
+ return schema.reduceProperties(function (buf, schema) {
92
+ //@ts-ignore
93
+ return buf.concat(parseSources(schema));
94
+ }, []);
95
+ }
96
+ return [];
97
+ };
98
+ if (!schema) throw new Error('can not found schema object');
99
+ return schema.properties ? parseSources(schema.properties['actions'] || {}) : [];
100
+ };
66
101
  var AgField = function AgField(_ref) {
67
102
  var value = _ref.value,
68
103
  record = _ref.data,
@@ -121,4 +156,4 @@ var useAddition = function useAddition() {
121
156
  return addition;
122
157
  }, null);
123
158
  };
124
- export { isColumnComponent, useArrayTableSources, useArrayTableColumns, useAddition };
159
+ export { isColumnComponent, useArrayTableSources, useArrayTableActions, useArrayTableColumns, useAddition };