@nokecy/qc-ui 0.2.9 → 0.3.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.
@@ -273,6 +273,13 @@ function AgGridPlus(props) {
273
273
  };
274
274
  }, [queryFilter, JSON.stringify(gridParams), JSON.stringify(sortColumn)]);
275
275
  var colDefs = (0, _react.useMemo)(function () {
276
+ return _react.default.Children.map(children, function (child, index) {
277
+ return child.props;
278
+ }).filter(function (x) {
279
+ return !x.hideInTable;
280
+ });
281
+ }, []);
282
+ var allColDefs = (0, _react.useMemo)(function () {
276
283
  return _react.default.Children.map(children, function (child, index) {
277
284
  return child.props;
278
285
  });
@@ -292,6 +299,7 @@ function AgGridPlus(props) {
292
299
  height: "100%"
293
300
  }
294
301
  }, search == false ? null : /*#__PURE__*/_react.default.createElement(_queryForm.default, {
302
+ colDefs: allColDefs,
295
303
  columnStates: columnState || [],
296
304
  gridApi: apiRef.current,
297
305
  onQuery: function onQuery(formValues) {
@@ -346,6 +354,18 @@ function AgGridPlus(props) {
346
354
  },
347
355
  onSelectionChanged: onRowChanged,
348
356
  onRowSelected: onRowSelected,
357
+ onDragStopped: function onDragStopped(e) {
358
+ if (columnsRef.current) {
359
+ var _columnsRef$current2;
360
+
361
+ setColumnState((_columnsRef$current2 = columnsRef.current) === null || _columnsRef$current2 === void 0 ? void 0 : _columnsRef$current2.getColumnState());
362
+ }
363
+ } // onColumnMoved={() => {
364
+ // if (columnsRef.current) {
365
+ // setColumnState(columnsRef.current?.getColumnState());
366
+ // }
367
+ // }}
368
+ ,
349
369
  columnTypes: columnTypes,
350
370
  animateRows: true //停用默认分页组件
351
371
  ,
@@ -30,7 +30,7 @@ interface AgGridColumnPropsClone extends ColDef {
30
30
  hideInTable?: boolean;
31
31
  hideInSearch?: boolean;
32
32
  queryField?: string;
33
- searchComponent?: ReactNode | JSX.Element;
33
+ searchComponent?: ReactNode | JSX.Element | ((props: any) => JSX.Element);
34
34
  searchComponentProps?: any;
35
35
  searchSort?: number;
36
36
  }
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ColumnState, GridApi } from 'ag-grid-community';
2
+ import { ColDef, ColumnState, GridApi } from 'ag-grid-community';
3
3
  import './index.less';
4
4
  declare const FormRender: (props: {
5
5
  className?: any;
6
6
  gridApi?: GridApi<any> | undefined;
7
+ colDefs: ColDef[];
7
8
  columnStates: ColumnState[];
8
9
  onQuery: (formValue: any) => void;
9
10
  }) => JSX.Element;
@@ -58,6 +58,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
58
58
  var FormRender = function FormRender(props) {
59
59
  var className = props.className,
60
60
  gridApi = props.gridApi,
61
+ colDefs = props.colDefs,
61
62
  columnStates = props.columnStates,
62
63
  onQuery = props.onQuery;
63
64
 
@@ -166,13 +167,15 @@ var FormRender = function FormRender(props) {
166
167
  },
167
168
  properties: {}
168
169
  };
169
- var columns = columnStates.filter(function (x) {
170
- return !x.hide;
171
- }).map(function (columnState) {
172
- return gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
170
+ var columns = colDefs.map(function (colDef) {
171
+ var state = columnStates.find(function (x) {
172
+ return x.colId == colDef.field;
173
+ });
174
+ console.log("state", state);
175
+ return _objectSpread(_objectSpread({}, colDef), state);
173
176
  });
174
177
  columns = columns.filter(function (i) {
175
- return (i === null || i === void 0 ? void 0 : i.visible) != false && !i.hideInSearch || i.hideInTable;
178
+ return (i === null || i === void 0 ? void 0 : i.visible) != false && !(i !== null && i !== void 0 && i.hide) && !(i !== null && i !== void 0 && i.hideInSearch) || (i === null || i === void 0 ? void 0 : i.hideInTable);
176
179
  });
177
180
  columns.map(function (col) {
178
181
  var _colDef$queryField;
@@ -246,6 +246,13 @@ function AgGridPlus(props) {
246
246
  };
247
247
  }, [queryFilter, JSON.stringify(gridParams), JSON.stringify(sortColumn)]);
248
248
  var colDefs = useMemo(function () {
249
+ return React.Children.map(children, function (child, index) {
250
+ return child.props;
251
+ }).filter(function (x) {
252
+ return !x.hideInTable;
253
+ });
254
+ }, []);
255
+ var allColDefs = useMemo(function () {
249
256
  return React.Children.map(children, function (child, index) {
250
257
  return child.props;
251
258
  });
@@ -265,6 +272,7 @@ function AgGridPlus(props) {
265
272
  height: "100%"
266
273
  }
267
274
  }, search == false ? null : /*#__PURE__*/React.createElement(FormRender, {
275
+ colDefs: allColDefs,
268
276
  columnStates: columnState || [],
269
277
  gridApi: apiRef.current,
270
278
  onQuery: function onQuery(formValues) {
@@ -319,6 +327,18 @@ function AgGridPlus(props) {
319
327
  },
320
328
  onSelectionChanged: onRowChanged,
321
329
  onRowSelected: onRowSelected,
330
+ onDragStopped: function onDragStopped(e) {
331
+ if (columnsRef.current) {
332
+ var _columnsRef$current2;
333
+
334
+ setColumnState((_columnsRef$current2 = columnsRef.current) === null || _columnsRef$current2 === void 0 ? void 0 : _columnsRef$current2.getColumnState());
335
+ }
336
+ } // onColumnMoved={() => {
337
+ // if (columnsRef.current) {
338
+ // setColumnState(columnsRef.current?.getColumnState());
339
+ // }
340
+ // }}
341
+ ,
322
342
  columnTypes: columnTypes,
323
343
  animateRows: true //停用默认分页组件
324
344
  ,
@@ -30,7 +30,7 @@ interface AgGridColumnPropsClone extends ColDef {
30
30
  hideInTable?: boolean;
31
31
  hideInSearch?: boolean;
32
32
  queryField?: string;
33
- searchComponent?: ReactNode | JSX.Element;
33
+ searchComponent?: ReactNode | JSX.Element | ((props: any) => JSX.Element);
34
34
  searchComponentProps?: any;
35
35
  searchSort?: number;
36
36
  }
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ColumnState, GridApi } from 'ag-grid-community';
2
+ import { ColDef, ColumnState, GridApi } from 'ag-grid-community';
3
3
  import './index.less';
4
4
  declare const FormRender: (props: {
5
5
  className?: any;
6
6
  gridApi?: GridApi<any> | undefined;
7
+ colDefs: ColDef[];
7
8
  columnStates: ColumnState[];
8
9
  onQuery: (formValue: any) => void;
9
10
  }) => JSX.Element;
@@ -37,6 +37,7 @@ import "./index.less";
37
37
  var FormRender = function FormRender(props) {
38
38
  var className = props.className,
39
39
  gridApi = props.gridApi,
40
+ colDefs = props.colDefs,
40
41
  columnStates = props.columnStates,
41
42
  onQuery = props.onQuery;
42
43
 
@@ -145,13 +146,15 @@ var FormRender = function FormRender(props) {
145
146
  },
146
147
  properties: {}
147
148
  };
148
- var columns = columnStates.filter(function (x) {
149
- return !x.hide;
150
- }).map(function (columnState) {
151
- return gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
149
+ var columns = colDefs.map(function (colDef) {
150
+ var state = columnStates.find(function (x) {
151
+ return x.colId == colDef.field;
152
+ });
153
+ console.log("state", state);
154
+ return _objectSpread(_objectSpread({}, colDef), state);
152
155
  });
153
156
  columns = columns.filter(function (i) {
154
- return (i === null || i === void 0 ? void 0 : i.visible) != false && !i.hideInSearch || i.hideInTable;
157
+ return (i === null || i === void 0 ? void 0 : i.visible) != false && !(i !== null && i !== void 0 && i.hide) && !(i !== null && i !== void 0 && i.hideInSearch) || (i === null || i === void 0 ? void 0 : i.hideInTable);
155
158
  });
156
159
  columns.map(function (col) {
157
160
  var _colDef$queryField;