@nokecy/qc-ui 0.1.49 → 0.1.51

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.
@@ -26,11 +26,10 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
26
26
 
27
27
  import { AgGridReact } from 'ag-grid-react';
28
28
  import { Spin, Pagination, Card, Tag } from 'antd';
29
- import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
29
+ import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
30
30
  import "ag-grid-enterprise";
31
31
  import "./global.scss";
32
32
  import "./index.less";
33
- import { AgGridColumn } from "./interface";
34
33
  import FormRender from "./queryForm";
35
34
  import ToolBar from "./toolBar";
36
35
  import SettingItem from "./settingItem";
@@ -205,6 +204,11 @@ function AgGridPlus(props) {
205
204
  onRefresh: onRefresh
206
205
  };
207
206
  }, [queryFilter, JSON.stringify(gridParams), JSON.stringify(sortColumn)]);
207
+ var colDefs = useMemo(function () {
208
+ return React.Children.map(children, function (child, index) {
209
+ return child.props;
210
+ });
211
+ }, [children]);
208
212
  return /*#__PURE__*/React.createElement(Spin, {
209
213
  spinning: loading,
210
214
  wrapperClassName: "grid-spin"
@@ -328,18 +332,8 @@ function AgGridPlus(props) {
328
332
  } // animateRows={true}
329
333
  //停用默认分页组件
330
334
  ,
331
- suppressPaginationPanel: true
332
- }), props.rowSelection ? /*#__PURE__*/React.createElement(AgGridColumn, {
333
- field: "",
334
- width: 30,
335
- flex: 0,
336
- headerCheckboxSelection: true,
337
- checkboxSelection: true,
338
- showDisabledCheckboxes: true,
339
- filter: false,
340
- pinned: "left"
341
- }) : null, React.Children.map(children, function (child, index) {
342
- return child;
335
+ suppressPaginationPanel: true,
336
+ columnDefs: colDefs || props.columnDefs
343
337
  }))), /*#__PURE__*/React.createElement("div", {
344
338
  style: {
345
339
  marginTop: 12,
@@ -4,18 +4,24 @@
4
4
  // alpine-active-color: red,
5
5
  odd-row-background-color:#fafafa,
6
6
  secondary-border-color:#f0f0f0,
7
- border-color:#f0f0f5,
7
+ border-color:#f0f0f0,
8
8
  foreground-color: rgba(0, 0, 0, 0.88),
9
9
 
10
10
  --ag-font-size: 11px,
11
11
  --ag-font-family: ('microsoft yahei', 'Helvetica', 'Arial'),
12
12
 
13
13
  --ag-borders: solid 0px,
14
- --ag-borders-row: solid 1px,
15
- --ag-row-border-color:#f0f0f5,
14
+ --ag-row-border-color:#f0f0f0,
16
15
  --ag-grid-size: 4px,
17
16
 
18
- --ag-header-background-color: #fafafa,
17
+ --ag-header-background-color: #f0f0f0,
18
+
19
+ --ag-cell-horizontal-border: solid #f0f0f0,
20
+
21
+ --ag-header-column-separator-display: block,
22
+ --ag-header-column-separator-height: 100%,
23
+ --ag-header-column-separator-width: 2px,
24
+ --ag-header-column-separator-color: #cecece,
19
25
  ));
20
26
 
21
27
  .ag-theme-alpine .ag-header-group-cell {
@@ -1,5 +1,5 @@
1
- import { GridApi } from 'ag-grid-community';
2
- import { AgGridReactProps, AgGridColumnProps, AgGridColumnGroupProps } from 'ag-grid-react';
1
+ import { GridApi, ColDef, ColGroupDef } from 'ag-grid-community';
2
+ import { AgGridReactProps } from 'ag-grid-react';
3
3
  import React, { CSSProperties, ReactNode } from 'react';
4
4
  interface GridRef {
5
5
  onRefresh: () => void;
@@ -26,7 +26,7 @@ interface GridProps extends AgGridReactProps {
26
26
  gridColumnState?: any[];
27
27
  gridRef?: React.Ref<GridRef | undefined>;
28
28
  }
29
- interface AgGridColumnPropsClone extends AgGridColumnProps {
29
+ interface AgGridColumnPropsClone extends ColDef {
30
30
  hideInTable?: boolean;
31
31
  hideInSearch?: boolean;
32
32
  queryField?: string;
@@ -34,5 +34,5 @@ interface AgGridColumnPropsClone extends AgGridColumnProps {
34
34
  searchComponentProps?: any;
35
35
  searchSort?: number;
36
36
  }
37
- declare function AgGridColumn(props: AgGridColumnPropsClone | AgGridColumnGroupProps): JSX.Element;
37
+ declare function AgGridColumn(props: AgGridColumnPropsClone | ColGroupDef): JSX.Element;
38
38
  export { GridProps, AgGridColumn, GridRef };
@@ -1,4 +1,3 @@
1
- import { AgGridColumn as AgGridColumnClone } from 'ag-grid-react';
2
1
  import React from 'react';
3
2
 
4
3
  function AgGridColumn(props) {
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { ButtonProps } from 'antd/lib/button';
3
+ import { ArrayField } from '@formily/core';
4
+ import { Schema, JSXComponent } from '@formily/react';
5
+ export interface IArrayBaseAdditionProps extends ButtonProps {
6
+ title?: string;
7
+ method?: 'push' | 'unshift';
8
+ defaultValue?: any;
9
+ }
10
+ export interface IArrayBaseOperationProps extends ButtonProps {
11
+ title?: string;
12
+ index?: number;
13
+ ref?: React.Ref<HTMLElement>;
14
+ }
15
+ export interface IArrayBaseContext {
16
+ props: IArrayBaseProps;
17
+ field: ArrayField;
18
+ schema: Schema;
19
+ }
20
+ export interface IArrayBaseItemProps {
21
+ index: number;
22
+ record: ((index: number) => Record<string, any>) | Record<string, any>;
23
+ props: IArrayBaseProps;
24
+ field: ArrayField;
25
+ schema: Schema;
26
+ }
27
+ export declare type ArrayBaseMixins = {
28
+ Addition?: React.FC<React.PropsWithChildren<IArrayBaseAdditionProps>>;
29
+ Copy?: React.FC<React.PropsWithChildren<IArrayBaseOperationProps & {
30
+ index?: number;
31
+ }>>;
32
+ Remove?: React.FC<React.PropsWithChildren<IArrayBaseOperationProps & {
33
+ index?: number;
34
+ }>>;
35
+ MoveUp?: React.FC<React.PropsWithChildren<IArrayBaseOperationProps & {
36
+ index?: number;
37
+ }>>;
38
+ MoveDown?: React.FC<React.PropsWithChildren<IArrayBaseOperationProps & {
39
+ index?: number;
40
+ }>>;
41
+ SortHandle?: React.FC<React.PropsWithChildren<IArrayBaseOperationProps & {
42
+ index?: number;
43
+ }>>;
44
+ Index?: React.FC;
45
+ useArray?: () => IArrayBaseContext;
46
+ useIndex?: (index?: number) => number;
47
+ useRecord?: (record?: number) => any;
48
+ };
49
+ export interface IArrayBaseProps {
50
+ disabled?: boolean;
51
+ onAdd?: (index: number) => void;
52
+ onCopy?: (index: number) => void;
53
+ onRemove?: (index: number) => void;
54
+ onMoveDown?: (index: number) => void;
55
+ onMoveUp?: (index: number) => void;
56
+ }
57
+ declare type ComposedArrayBase = React.FC<React.PropsWithChildren<IArrayBaseProps>> & ArrayBaseMixins & {
58
+ Item?: React.FC<React.PropsWithChildren<IArrayBaseItemProps>>;
59
+ mixin?: <T extends JSXComponent>(target: T) => T & ArrayBaseMixins;
60
+ };
61
+ export declare const ArrayBase: ComposedArrayBase;
62
+ export default ArrayBase;
@@ -0,0 +1,261 @@
1
+ var _excluded = ["children"];
2
+
3
+ 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); }
4
+
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; }
6
+
7
+ 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; }
8
+
9
+ import React, { createContext, useContext } from 'react';
10
+ import { Button } from 'antd';
11
+ import { DeleteOutlined, DownOutlined, UpOutlined, PlusOutlined, CopyOutlined } from '@ant-design/icons';
12
+ import { useField } from '@formily/react';
13
+ import { isValid, clone, isUndef } from '@formily/shared';
14
+ import { usePrefixCls } from '@formily/antd-v5/lib/__builtins__';
15
+ import cls from 'classnames';
16
+ var ItemContext = /*#__PURE__*/createContext(null);
17
+
18
+ var takeRecord = function takeRecord(val, index) {
19
+ return typeof val === 'function' ? val(index) : val;
20
+ };
21
+
22
+ var useArray = function useArray() {
23
+ return useContext(ItemContext);
24
+ };
25
+
26
+ var useIndex = function useIndex(index) {
27
+ var ctx = useContext(ItemContext);
28
+ return ctx ? ctx.index : index || 0;
29
+ };
30
+
31
+ var useRecord = function useRecord(record) {
32
+ var ctx = useContext(ItemContext);
33
+ return takeRecord(ctx ? ctx.record : record, ctx === null || ctx === void 0 ? void 0 : ctx.index);
34
+ };
35
+
36
+ var getSchemaDefaultValue = function getSchemaDefaultValue(schema) {
37
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array') return [];
38
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object') return {};
39
+
40
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'void') {
41
+ for (var key in schema.properties) {
42
+ var value = getSchemaDefaultValue(schema.properties[key]);
43
+ if (isValid(value)) return value;
44
+ }
45
+ }
46
+ };
47
+
48
+ var getDefaultValue = function getDefaultValue(defaultValue, schema) {
49
+ if (isValid(defaultValue)) return clone(defaultValue);
50
+ if (Array.isArray(schema === null || schema === void 0 ? void 0 : schema.items)) return getSchemaDefaultValue(schema === null || schema === void 0 ? void 0 : schema.items[0]);
51
+ return getSchemaDefaultValue(schema === null || schema === void 0 ? void 0 : schema.items);
52
+ };
53
+
54
+ export var ArrayBase = function ArrayBase(props) {
55
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
56
+ };
57
+
58
+ ArrayBase.Item = function (_ref) {
59
+ var children = _ref.children,
60
+ props = _objectWithoutProperties(_ref, _excluded);
61
+
62
+ return /*#__PURE__*/React.createElement(ItemContext.Provider, {
63
+ value: props
64
+ }, children);
65
+ };
66
+
67
+ ArrayBase.Index = function (props) {
68
+ var index = useIndex();
69
+ var prefixCls = usePrefixCls('formily-array-base');
70
+ return /*#__PURE__*/React.createElement("span", _extends({}, props, {
71
+ className: "".concat(prefixCls, "-index")
72
+ }), "#", (index ? index : 0) + 1, ".");
73
+ };
74
+
75
+ ArrayBase.Addition = function (props) {
76
+ var _array$field, _array$field2;
77
+
78
+ var self = useField();
79
+ var array = useArray();
80
+ var prefixCls = usePrefixCls('formily-array-base');
81
+ if (!array) return null;
82
+ if (((_array$field = array.field) === null || _array$field === void 0 ? void 0 : _array$field.pattern) !== 'editable' && ((_array$field2 = array.field) === null || _array$field2 === void 0 ? void 0 : _array$field2.pattern) !== 'disabled') return null;
83
+ return /*#__PURE__*/React.createElement(Button, _extends({
84
+ type: "dashed",
85
+ block: true
86
+ }, props, {
87
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
88
+ className: cls("".concat(prefixCls, "-addition"), props.className),
89
+ onClick: function onClick(e) {
90
+ var _array$props;
91
+
92
+ if ((_array$props = array.props) !== null && _array$props !== void 0 && _array$props.disabled) return;
93
+ var defaultValue = getDefaultValue(props.defaultValue, array.schema);
94
+
95
+ if (props.method === 'unshift') {
96
+ var _array$field3, _array$field3$unshift, _array$props2, _array$props2$onAdd;
97
+
98
+ (_array$field3 = array.field) === null || _array$field3 === void 0 ? void 0 : (_array$field3$unshift = _array$field3.unshift) === null || _array$field3$unshift === void 0 ? void 0 : _array$field3$unshift.call(_array$field3, defaultValue);
99
+ (_array$props2 = array.props) === null || _array$props2 === void 0 ? void 0 : (_array$props2$onAdd = _array$props2.onAdd) === null || _array$props2$onAdd === void 0 ? void 0 : _array$props2$onAdd.call(_array$props2, 0);
100
+ } else {
101
+ var _array$field4, _array$field4$push, _array$props3, _array$props3$onAdd, _array$field5, _array$field5$value;
102
+
103
+ (_array$field4 = array.field) === null || _array$field4 === void 0 ? void 0 : (_array$field4$push = _array$field4.push) === null || _array$field4$push === void 0 ? void 0 : _array$field4$push.call(_array$field4, defaultValue);
104
+ (_array$props3 = array.props) === null || _array$props3 === void 0 ? void 0 : (_array$props3$onAdd = _array$props3.onAdd) === null || _array$props3$onAdd === void 0 ? void 0 : _array$props3$onAdd.call(_array$props3, (array === null || array === void 0 ? void 0 : (_array$field5 = array.field) === null || _array$field5 === void 0 ? void 0 : (_array$field5$value = _array$field5.value) === null || _array$field5$value === void 0 ? void 0 : _array$field5$value.length) - 1);
105
+ }
106
+
107
+ if (props.onClick) {
108
+ //@ts-ignore
109
+ props.onClick(e);
110
+ }
111
+ },
112
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(PlusOutlined, null) : props.icon
113
+ }), props.title || self.title);
114
+ };
115
+
116
+ ArrayBase.Copy = /*#__PURE__*/React.forwardRef(function (props, ref) {
117
+ var _array$field6;
118
+
119
+ var self = useField();
120
+ var array = useArray();
121
+ var index = useIndex(props.index);
122
+ var prefixCls = usePrefixCls('formily-array-base');
123
+ if (!array) return null;
124
+ if (((_array$field6 = array.field) === null || _array$field6 === void 0 ? void 0 : _array$field6.pattern) !== 'editable') return null;
125
+ return /*#__PURE__*/React.createElement(Button, _extends({
126
+ type: "text"
127
+ }, props, {
128
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
129
+ className: cls("".concat(prefixCls, "-copy"), self !== null && self !== void 0 && self.disabled ? "".concat(prefixCls, "-copy-disabled") : '', props.className),
130
+ ref: ref,
131
+ onClick: function onClick(e) {
132
+ var _array$props4, _array$field7, _array$field8, _array$field8$insert, _array$props5, _array$props5$onCopy;
133
+
134
+ if (self !== null && self !== void 0 && self.disabled) return;
135
+ e.stopPropagation();
136
+ if ((_array$props4 = array.props) !== null && _array$props4 !== void 0 && _array$props4.disabled) return;
137
+ var value = clone(array === null || array === void 0 ? void 0 : (_array$field7 = array.field) === null || _array$field7 === void 0 ? void 0 : _array$field7.value[index]);
138
+ var distIndex = index + 1;
139
+ (_array$field8 = array.field) === null || _array$field8 === void 0 ? void 0 : (_array$field8$insert = _array$field8.insert) === null || _array$field8$insert === void 0 ? void 0 : _array$field8$insert.call(_array$field8, distIndex, value);
140
+ (_array$props5 = array.props) === null || _array$props5 === void 0 ? void 0 : (_array$props5$onCopy = _array$props5.onCopy) === null || _array$props5$onCopy === void 0 ? void 0 : _array$props5$onCopy.call(_array$props5, distIndex);
141
+
142
+ if (props.onClick) {
143
+ //@ts-ignore
144
+ props.onClick(e);
145
+ }
146
+ },
147
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(CopyOutlined, null) : props.icon
148
+ }), props.title || self.title);
149
+ });
150
+ ArrayBase.Remove = /*#__PURE__*/React.forwardRef(function (props, ref) {
151
+ var _array$field9;
152
+
153
+ var index = useIndex(props.index);
154
+ var self = useField();
155
+ var array = useArray();
156
+ var prefixCls = usePrefixCls('formily-array-base');
157
+ if (!array) return null;
158
+ if (((_array$field9 = array.field) === null || _array$field9 === void 0 ? void 0 : _array$field9.pattern) !== 'editable') return null;
159
+ return /*#__PURE__*/React.createElement(Button, _extends({
160
+ type: "text"
161
+ }, props, {
162
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
163
+ className: cls("".concat(prefixCls, "-remove"), self !== null && self !== void 0 && self.disabled ? "".concat(prefixCls, "-remove-disabled") : '', props.className),
164
+ ref: ref,
165
+ onClick: function onClick(e) {
166
+ var _array$field10, _array$field10$remove, _array$props6, _array$props6$onRemov;
167
+
168
+ if (self !== null && self !== void 0 && self.disabled) return;
169
+ e.stopPropagation();
170
+ (_array$field10 = array.field) === null || _array$field10 === void 0 ? void 0 : (_array$field10$remove = _array$field10.remove) === null || _array$field10$remove === void 0 ? void 0 : _array$field10$remove.call(_array$field10, index);
171
+ (_array$props6 = array.props) === null || _array$props6 === void 0 ? void 0 : (_array$props6$onRemov = _array$props6.onRemove) === null || _array$props6$onRemov === void 0 ? void 0 : _array$props6$onRemov.call(_array$props6, index);
172
+
173
+ if (props.onClick) {
174
+ //@ts-ignore
175
+ props.onClick(e);
176
+ }
177
+ },
178
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(DeleteOutlined, null) : props.icon
179
+ }), props.title || self.title);
180
+ });
181
+ ArrayBase.MoveDown = /*#__PURE__*/React.forwardRef(function (props, ref) {
182
+ var _array$field11;
183
+
184
+ var index = useIndex(props.index);
185
+ var self = useField();
186
+ var array = useArray();
187
+ var prefixCls = usePrefixCls('formily-array-base');
188
+ if (!array) return null;
189
+ if (((_array$field11 = array.field) === null || _array$field11 === void 0 ? void 0 : _array$field11.pattern) !== 'editable') return null;
190
+ return /*#__PURE__*/React.createElement(Button, _extends({
191
+ type: "text"
192
+ }, props, {
193
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
194
+ className: cls("".concat(prefixCls, "-move-down"), self !== null && self !== void 0 && self.disabled ? "".concat(prefixCls, "-move-down-disabled") : '', props.className),
195
+ ref: ref,
196
+ onClick: function onClick(e) {
197
+ var _array$field12, _array$field12$moveDo, _array$props7, _array$props7$onMoveD;
198
+
199
+ if (self !== null && self !== void 0 && self.disabled) return;
200
+ e.stopPropagation();
201
+ (_array$field12 = array.field) === null || _array$field12 === void 0 ? void 0 : (_array$field12$moveDo = _array$field12.moveDown) === null || _array$field12$moveDo === void 0 ? void 0 : _array$field12$moveDo.call(_array$field12, index);
202
+ (_array$props7 = array.props) === null || _array$props7 === void 0 ? void 0 : (_array$props7$onMoveD = _array$props7.onMoveDown) === null || _array$props7$onMoveD === void 0 ? void 0 : _array$props7$onMoveD.call(_array$props7, index);
203
+
204
+ if (props.onClick) {
205
+ //@ts-ignore
206
+ props.onClick(e);
207
+ }
208
+ },
209
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(DownOutlined, null) : props.icon
210
+ }), props.title || self.title);
211
+ });
212
+ ArrayBase.MoveUp = /*#__PURE__*/React.forwardRef(function (props, ref) {
213
+ var _array$field13;
214
+
215
+ var index = useIndex(props.index);
216
+ var self = useField();
217
+ var array = useArray();
218
+ var prefixCls = usePrefixCls('formily-array-base');
219
+ if (!array) return null;
220
+ if (((_array$field13 = array.field) === null || _array$field13 === void 0 ? void 0 : _array$field13.pattern) !== 'editable') return null;
221
+ return /*#__PURE__*/React.createElement(Button, _extends({
222
+ type: "text"
223
+ }, props, {
224
+ disabled: self === null || self === void 0 ? void 0 : self.disabled,
225
+ className: cls("".concat(prefixCls, "-move-up"), self !== null && self !== void 0 && self.disabled ? "".concat(prefixCls, "-move-up-disabled") : '', props.className),
226
+ ref: ref,
227
+ onClick: function onClick(e) {
228
+ var _array$field14, _array$props8, _array$props8$onMoveU;
229
+
230
+ if (self !== null && self !== void 0 && self.disabled) return;
231
+ e.stopPropagation();
232
+ array === null || array === void 0 ? void 0 : (_array$field14 = array.field) === null || _array$field14 === void 0 ? void 0 : _array$field14.moveUp(index);
233
+ array === null || array === void 0 ? void 0 : (_array$props8 = array.props) === null || _array$props8 === void 0 ? void 0 : (_array$props8$onMoveU = _array$props8.onMoveUp) === null || _array$props8$onMoveU === void 0 ? void 0 : _array$props8$onMoveU.call(_array$props8, index);
234
+
235
+ if (props.onClick) {
236
+ //@ts-ignore
237
+ props.onClick(e);
238
+ }
239
+ },
240
+ icon: isUndef(props.icon) ? /*#__PURE__*/React.createElement(UpOutlined, null) : props.icon
241
+ }), props.title || self.title);
242
+ });
243
+ ArrayBase.useArray = useArray;
244
+ ArrayBase.useIndex = useIndex;
245
+ ArrayBase.useRecord = useRecord;
246
+
247
+ ArrayBase.mixin = function (target) {
248
+ target.Index = ArrayBase.Index;
249
+ target.SortHandle = ArrayBase.SortHandle;
250
+ target.Addition = ArrayBase.Addition;
251
+ target.Copy = ArrayBase.Copy;
252
+ target.Remove = ArrayBase.Remove;
253
+ target.MoveDown = ArrayBase.MoveDown;
254
+ target.MoveUp = ArrayBase.MoveUp;
255
+ target.useArray = ArrayBase.useArray;
256
+ target.useIndex = ArrayBase.useIndex;
257
+ target.useRecord = ArrayBase.useRecord;
258
+ return target;
259
+ };
260
+
261
+ export default ArrayBase;
@@ -21,11 +21,11 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
21
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
22
 
23
23
  import React, { Fragment, useRef, useState } from "react";
24
- import { AgGridPlus } from "../ag-grid-plus";
24
+ import { AgGridReact } from "ag-grid-react";
25
25
  import { useField, observer, RecursionField } from "@formily/react";
26
- import { ArrayBase } from "@formily/antd-v5";
27
26
  import uniqueId from "lodash/uniqueId";
28
- import { useAddition, useArrayTableColumns, useArrayTableSources, isColumnComponent } from "./utils"; //@ts-ignore
27
+ import { useAddition, useArrayTableColumns, useArrayTableSources, isColumnComponent } from "./utils";
28
+ import ArrayBase from "./arrayBase"; //@ts-ignore
29
29
 
30
30
  export var ArrayTable = observer(function (props) {
31
31
  var height = props.height;
@@ -47,11 +47,7 @@ export var ArrayTable = observer(function (props) {
47
47
  style: {
48
48
  height: height ? height : 400
49
49
  }
50
- }, /*#__PURE__*/React.createElement(ArrayBase, {
51
- onAdd: function onAdd() {
52
- setIsAdd(true);
53
- }
54
- }, /*#__PURE__*/React.createElement(AgGridPlus, {
50
+ }, /*#__PURE__*/React.createElement(ArrayBase, null, /*#__PURE__*/React.createElement(AgGridReact, {
55
51
  onGridReady: function onGridReady(params) {
56
52
  apiRef.current = params.api;
57
53
  },
@@ -64,14 +60,10 @@ export var ArrayTable = observer(function (props) {
64
60
  }
65
61
  },
66
62
  className: "ag-theme-alpine",
67
- search: false,
68
63
  getRowId: function getRowId(_ref) {
69
64
  var data = _ref.data;
70
65
  return data._id || data.id;
71
66
  },
72
- toolBarRender: function toolBarRender() {
73
- return [addition];
74
- },
75
67
  rowDragEntireRow: true,
76
68
  onRowDragEnd: function onRowDragEnd(event) {
77
69
  var overIndex = event.overIndex,
@@ -114,8 +106,6 @@ ArrayTable.Column = function () {
114
106
  ArrayBase.mixin(ArrayTable);
115
107
 
116
108
  var Addition = function Addition(props) {
117
- var self = useField();
118
- var array = ArrayBase.useArray();
119
109
  return /*#__PURE__*/React.createElement(ArrayBase.Addition, _extends({
120
110
  type: "primary",
121
111
  children: "新增行"
@@ -4,10 +4,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
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
6
 
7
- import React from 'react';
7
+ import React, { forwardRef } from 'react';
8
8
  import { useField, useFieldSchema, RecursionField } from '@formily/react';
9
9
  import { isArr } from '@formily/shared';
10
- import { ArrayBase } from '@formily/antd-v5';
10
+ import ArrayBase from "./arrayBase";
11
11
 
12
12
  var isColumnComponent = function isColumnComponent(schema) {
13
13
  var _schema$xComponent;
@@ -75,37 +75,48 @@ var useArrayTableSources = function useArrayTableSources() {
75
75
  return parseArrayItems(schema.items);
76
76
  };
77
77
 
78
+ var AgField = /*#__PURE__*/forwardRef(function (_ref, ref) {
79
+ var value = _ref.value,
80
+ record = _ref.data,
81
+ dataSource = _ref.dataSource,
82
+ schema = _ref.schema,
83
+ field = _ref.field;
84
+ var index = dataSource === null || dataSource === void 0 ? void 0 : dataSource.indexOf(record);
85
+ var children = /*#__PURE__*/React.createElement(ArrayBase.Item, {
86
+ index: index,
87
+ record: function record() {
88
+ var _field$value;
89
+
90
+ return (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value[index];
91
+ },
92
+ schema: schema,
93
+ field: field
94
+ }, /*#__PURE__*/React.createElement(RecursionField, {
95
+ schema: schema,
96
+ name: index,
97
+ onlyRenderProperties: true
98
+ }));
99
+ return children;
100
+ });
101
+
78
102
  var useArrayTableColumns = function useArrayTableColumns(dataSource, field, sources) {
79
- return sources.reduce(function (buf, _ref, key) {
80
- var name = _ref.name,
81
- columnProps = _ref.columnProps,
82
- schema = _ref.schema,
83
- display = _ref.display;
103
+ return sources.reduce(function (buf, _ref2, key) {
104
+ var name = _ref2.name,
105
+ columnProps = _ref2.columnProps,
106
+ schema = _ref2.schema,
107
+ display = _ref2.display;
84
108
  if (display !== 'visible') return buf;
85
109
  if (!isColumnComponent(schema)) return buf;
86
110
  return buf.concat(_objectSpread(_objectSpread({}, columnProps), {}, {
87
111
  //@ts-ignore
88
112
  headerName: columnProps.headerName || columnProps.title,
89
113
  field: name,
90
- cellRenderer: function cellRenderer(_ref2) {
91
- var rowIndex = _ref2.rowIndex,
92
- value = _ref2.value,
93
- record = _ref2.data;
94
- var index = dataSource === null || dataSource === void 0 ? void 0 : dataSource.indexOf(record);
95
- var children = /*#__PURE__*/React.createElement(ArrayBase.Item, {
96
- index: index,
97
- record: function record() {
98
- var _field$value;
99
-
100
- return field === null || field === void 0 ? void 0 : (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value[index];
101
- }
102
- }, /*#__PURE__*/React.createElement(RecursionField, {
103
- schema: schema,
104
- name: index,
105
- onlyRenderProperties: true
106
- }));
107
- return children;
108
- }
114
+ cellRendererParams: {
115
+ dataSource: dataSource,
116
+ schema: schema,
117
+ field: field
118
+ },
119
+ cellRenderer: AgField
109
120
  }));
110
121
  }, []);
111
122
  };