@nokecy/qc-ui 0.1.33 → 0.1.35

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.
@@ -33,7 +33,7 @@ var _utils = require("./utils");
33
33
 
34
34
  var _setting = _interopRequireDefault(require("./setting"));
35
35
 
36
- var _excluded = ["style", "params", "request", "dataSource", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "gridColumnState", "children"];
36
+ var _excluded = ["style", "loading", "params", "request", "dataSource", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "gridColumnState", "children"];
37
37
 
38
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
39
 
@@ -71,6 +71,7 @@ var getSort = function getSort(columnState) {
71
71
 
72
72
  function AgGridPlus(props) {
73
73
  var style = props.style,
74
+ loadingProps = props.loading,
74
75
  gridParams = props.params,
75
76
  request = props.request,
76
77
  dataSource = props.dataSource,
@@ -96,7 +97,7 @@ function AgGridPlus(props) {
96
97
  ready = _useState2[0],
97
98
  setReady = _useState2[1];
98
99
 
99
- var _useState3 = (0, _react.useState)(false),
100
+ var _useState3 = (0, _react.useState)(loadingProps ? loadingProps : false),
100
101
  _useState4 = _slicedToArray(_useState3, 2),
101
102
  loading = _useState4[0],
102
103
  setLoading = _useState4[1];
@@ -167,7 +168,11 @@ function AgGridPlus(props) {
167
168
  }, [gridColumnState, columnsRef.current]);
168
169
  (0, _react.useEffect)(function () {
169
170
  setRowData(dataSource || propRowData || []);
170
- }, [dataSource, propRowData]);
171
+ }, [dataSource, propRowData]); //外部loading
172
+
173
+ (0, _react.useEffect)(function () {
174
+ loadingProps !== undefined && setLoading(loadingProps);
175
+ }, [loadingProps]);
171
176
  var onGridReady = (0, _react.useCallback)(function (params) {
172
177
  var _columnsRef$current;
173
178
 
@@ -9,6 +9,7 @@ interface GridProps extends AgGridReactProps {
9
9
  style?: CSSProperties;
10
10
  params?: any;
11
11
  initParams?: any;
12
+ loading?: boolean;
12
13
  request?: (params: any, sort: any, filter: any) => Promise<any>;
13
14
  dataSource?: any[];
14
15
  treeParentName?: string;
@@ -98,7 +98,8 @@ var Addition = function Addition(props) {
98
98
  }, props, {
99
99
  block: false,
100
100
  defaultValue: _objectSpread(_objectSpread({}, props.defaultValue), {}, {
101
- _id: (0, _uniqueId.default)()
101
+ _id: (0, _uniqueId.default)(),
102
+ _isNew: true
102
103
  })
103
104
  }));
104
105
  };
@@ -60,6 +60,9 @@ var useParentPattern = function useParentPattern() {
60
60
 
61
61
  var useEditable = function useEditable() {
62
62
  var pattern = useParentPattern();
63
+
64
+ var record = _antdV.ArrayBase.useRecord();
65
+
63
66
  var field = (0, _react.useField)(); // useLayoutEffect(() => {
64
67
  // if (pattern === 'editable') {
65
68
  // return field.setPattern('readPretty')
@@ -67,7 +70,7 @@ var useEditable = function useEditable() {
67
70
  // }, [pattern])
68
71
 
69
72
  (0, _react2.useLayoutEffect)(function () {
70
- if (field.initialValue && pattern === 'editable') {
73
+ if ((field.initialValue || !(record !== null && record !== void 0 && record._isNew)) && pattern === 'editable') {
71
74
  return field.setPattern('readPretty');
72
75
  }
73
76
  }, [field.initialValue]);
@@ -1,4 +1,4 @@
1
- var _excluded = ["style", "params", "request", "dataSource", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "gridColumnState", "children"];
1
+ var _excluded = ["style", "loading", "params", "request", "dataSource", "treeParentName", "rowData", "gridRef", "headerTitle", "toolBarRender", "search", "hideTool", "onGridReady", "gridKey", "gridColumnState", "children"];
2
2
 
3
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
4
 
@@ -44,6 +44,7 @@ var getSort = function getSort(columnState) {
44
44
 
45
45
  function AgGridPlus(props) {
46
46
  var style = props.style,
47
+ loadingProps = props.loading,
47
48
  gridParams = props.params,
48
49
  request = props.request,
49
50
  dataSource = props.dataSource,
@@ -69,7 +70,7 @@ function AgGridPlus(props) {
69
70
  ready = _useState2[0],
70
71
  setReady = _useState2[1];
71
72
 
72
- var _useState3 = useState(false),
73
+ var _useState3 = useState(loadingProps ? loadingProps : false),
73
74
  _useState4 = _slicedToArray(_useState3, 2),
74
75
  loading = _useState4[0],
75
76
  setLoading = _useState4[1];
@@ -140,7 +141,11 @@ function AgGridPlus(props) {
140
141
  }, [gridColumnState, columnsRef.current]);
141
142
  useEffect(function () {
142
143
  setRowData(dataSource || propRowData || []);
143
- }, [dataSource, propRowData]);
144
+ }, [dataSource, propRowData]); //外部loading
145
+
146
+ useEffect(function () {
147
+ loadingProps !== undefined && setLoading(loadingProps);
148
+ }, [loadingProps]);
144
149
  var onGridReady = useCallback(function (params) {
145
150
  var _columnsRef$current;
146
151
 
@@ -9,6 +9,7 @@ interface GridProps extends AgGridReactProps {
9
9
  style?: CSSProperties;
10
10
  params?: any;
11
11
  initParams?: any;
12
+ loading?: boolean;
12
13
  request?: (params: any, sort: any, filter: any) => Promise<any>;
13
14
  dataSource?: any[];
14
15
  treeParentName?: string;
@@ -74,7 +74,8 @@ var Addition = function Addition(props) {
74
74
  }, props, {
75
75
  block: false,
76
76
  defaultValue: _objectSpread(_objectSpread({}, props.defaultValue), {}, {
77
- _id: uniqueId()
77
+ _id: uniqueId(),
78
+ _isNew: true
78
79
  })
79
80
  }));
80
81
  };
@@ -25,7 +25,7 @@ import { isVoidField } from '@formily/core';
25
25
  import { observer, useField } from '@formily/react';
26
26
  import { Popover as AntdPopover } from 'antd';
27
27
  import cls from 'classnames';
28
- import { FormItem } from '@formily/antd-v5';
28
+ import { ArrayBase, FormItem } from '@formily/antd-v5';
29
29
  import React, { useLayoutEffect, useRef, useState } from 'react';
30
30
  import { useClickAway, usePrefixCls } from '@formily/antd-v5/lib/__builtins__';
31
31
  import useStyle from "./style";
@@ -39,6 +39,7 @@ var useParentPattern = function useParentPattern() {
39
39
 
40
40
  var useEditable = function useEditable() {
41
41
  var pattern = useParentPattern();
42
+ var record = ArrayBase.useRecord();
42
43
  var field = useField(); // useLayoutEffect(() => {
43
44
  // if (pattern === 'editable') {
44
45
  // return field.setPattern('readPretty')
@@ -46,7 +47,7 @@ var useEditable = function useEditable() {
46
47
  // }, [pattern])
47
48
 
48
49
  useLayoutEffect(function () {
49
- if (field.initialValue && pattern === 'editable') {
50
+ if ((field.initialValue || !(record !== null && record !== void 0 && record._isNew)) && pattern === 'editable') {
50
51
  return field.setPattern('readPretty');
51
52
  }
52
53
  }, [field.initialValue]);