@quansitech/antd-admin 1.1.10 → 1.1.11

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.
@@ -27,7 +27,7 @@ export default function (props) {
27
27
  var tableContext = useContext(TableContext);
28
28
  var onClick = /*#__PURE__*/function () {
29
29
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
30
- var _tableContext$actionR, url, m;
30
+ var _tableContext$getActi, url, m;
31
31
  return _regeneratorRuntime().wrap(function _callee$(_context) {
32
32
  while (1) switch (_context.prev = _context.next) {
33
33
  case 0:
@@ -53,7 +53,7 @@ export default function (props) {
53
53
  });
54
54
  case 8:
55
55
  _context.next = 10;
56
- return (_tableContext$actionR = tableContext.actionRef) === null || _tableContext$actionR === void 0 ? void 0 : _tableContext$actionR.reload();
56
+ return (_tableContext$getActi = tableContext.getActionRef()) === null || _tableContext$getActi === void 0 ? void 0 : _tableContext$getActi.reload();
57
57
  case 10:
58
58
  if (!props.modal) {
59
59
  _context.next = 14;
@@ -32,7 +32,7 @@ export default function (props) {
32
32
  var modalContext = useContext(ModalContext);
33
33
  var onClick = /*#__PURE__*/function () {
34
34
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
35
- var handleAfterAction, _formContext$formRef, _formContext$formRef2, _formContext$formRef3, _formContext$formRef4, _formContext$formRef5;
35
+ var handleAfterAction, _formContext$getFormR, _formContext$getFormR2, _formContext$getFormR3, _formContext$getFormR4, _formContext$getFormR5;
36
36
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
37
37
  while (1) switch (_context2.prev = _context2.next) {
38
38
  case 0:
@@ -51,15 +51,15 @@ export default function (props) {
51
51
  if (modalContext.contexts) {
52
52
  modalContext.setAfterClose(function () {
53
53
  var _modalContext$context;
54
- (_modalContext$context = modalContext.contexts) === null || _modalContext$context === void 0 || (_modalContext$context = _modalContext$context.tableContext) === null || _modalContext$context === void 0 || _modalContext$context.actionRef.reload();
54
+ (_modalContext$context = modalContext.contexts) === null || _modalContext$context === void 0 || (_modalContext$context = _modalContext$context.tableContext) === null || _modalContext$context === void 0 || _modalContext$context.getActionRef().reload();
55
55
  });
56
56
  }
57
- if (!tableContext.actionRef) {
57
+ if (!tableContext.getActionRef()) {
58
58
  _context.next = 5;
59
59
  break;
60
60
  }
61
61
  _context.next = 5;
62
- return tableContext.actionRef.reload();
62
+ return tableContext.getActionRef().reload();
63
63
  case 5:
64
64
  if (req !== null && req !== void 0 && (_req$afterAction2 = req.afterAction) !== null && _req$afterAction2 !== void 0 && _req$afterAction2.includes('closeModal') && modalContext.inModal) {
65
65
  modalContext.closeModal();
@@ -78,7 +78,7 @@ export default function (props) {
78
78
  _context2.next = 6;
79
79
  break;
80
80
  }
81
- (_formContext$formRef = formContext.formRef) === null || _formContext$formRef === void 0 || (_formContext$formRef = _formContext$formRef.current) === null || _formContext$formRef === void 0 || _formContext$formRef.submit();
81
+ (_formContext$getFormR = formContext.getFormRef()) === null || _formContext$getFormR === void 0 || _formContext$getFormR.submit();
82
82
  return _context2.abrupt("return");
83
83
  case 6:
84
84
  if (!props.request) {
@@ -94,7 +94,7 @@ export default function (props) {
94
94
  _context2.t6 = _objectSpread;
95
95
  _context2.t7 = {};
96
96
  _context2.next = 17;
97
- return (_formContext$formRef2 = formContext.formRef) === null || _formContext$formRef2 === void 0 || (_formContext$formRef2 = _formContext$formRef2.current) === null || _formContext$formRef2 === void 0 ? void 0 : _formContext$formRef2.getFieldsValue();
97
+ return (_formContext$getFormR2 = formContext.getFormRef()) === null || _formContext$getFormR2 === void 0 ? void 0 : _formContext$getFormR2.getFieldsValue();
98
98
  case 17:
99
99
  _context2.t8 = _context2.sent;
100
100
  _context2.t9 = (0, _context2.t6)(_context2.t7, _context2.t8);
@@ -120,7 +120,7 @@ export default function (props) {
120
120
  _context2.next = 29;
121
121
  return modalShow(_objectSpread(_objectSpread({}, props.modal), {}, {
122
122
  content: _objectSpread(_objectSpread({}, props.modal.content), {}, {
123
- url: replaceUrl(props.modal.content.url, (_formContext$formRef3 = formContext.formRef) === null || _formContext$formRef3 === void 0 || (_formContext$formRef3 = _formContext$formRef3.current) === null || _formContext$formRef3 === void 0 ? void 0 : _formContext$formRef3.getFieldsValue())
123
+ url: replaceUrl(props.modal.content.url, (_formContext$getFormR3 = formContext.getFormRef()) === null || _formContext$getFormR3 === void 0 ? void 0 : _formContext$getFormR3.getFieldsValue())
124
124
  })
125
125
  }));
126
126
  case 29:
@@ -134,7 +134,7 @@ export default function (props) {
134
134
  _context2.t13 = replaceUrl;
135
135
  _context2.t14 = props.link.url;
136
136
  _context2.next = 36;
137
- return (_formContext$formRef4 = formContext.formRef) === null || _formContext$formRef4 === void 0 || (_formContext$formRef4 = _formContext$formRef4.current) === null || _formContext$formRef4 === void 0 ? void 0 : _formContext$formRef4.getFieldsValue();
137
+ return (_formContext$getFormR4 = formContext.getFormRef()) === null || _formContext$getFormR4 === void 0 ? void 0 : _formContext$getFormR4.getFieldsValue();
138
138
  case 36:
139
139
  _context2.t15 = _context2.sent;
140
140
  _context2.t16 = (0, _context2.t13)(_context2.t14, _context2.t15);
@@ -145,7 +145,7 @@ export default function (props) {
145
145
  _context2.next = 43;
146
146
  break;
147
147
  }
148
- (_formContext$formRef5 = formContext.formRef) === null || _formContext$formRef5 === void 0 || (_formContext$formRef5 = _formContext$formRef5.current) === null || _formContext$formRef5 === void 0 || _formContext$formRef5.resetFields();
148
+ (_formContext$getFormR5 = formContext.getFormRef()) === null || _formContext$getFormR5 === void 0 || _formContext$getFormR5.resetFields();
149
149
  return _context2.abrupt("return");
150
150
  case 43:
151
151
  if (!props.back) {
@@ -77,15 +77,15 @@ export default function (props) {
77
77
  if (modalContext.contexts) {
78
78
  modalContext.setAfterClose(function () {
79
79
  var _modalContext$context;
80
- (_modalContext$context = modalContext.contexts) === null || _modalContext$context === void 0 || (_modalContext$context = _modalContext$context.tableContext) === null || _modalContext$context === void 0 || _modalContext$context.actionRef.reload();
80
+ (_modalContext$context = modalContext.contexts) === null || _modalContext$context === void 0 || (_modalContext$context = _modalContext$context.tableContext) === null || _modalContext$context === void 0 || _modalContext$context.getActionRef().reload();
81
81
  });
82
82
  }
83
- if (!tableContext.actionRef) {
83
+ if (!tableContext.getActionRef()) {
84
84
  _context.next = 5;
85
85
  break;
86
86
  }
87
87
  _context.next = 5;
88
- return tableContext.actionRef.reload();
88
+ return tableContext.getActionRef().reload();
89
89
  case 5:
90
90
  if (req !== null && req !== void 0 && (_req$afterAction2 = req.afterAction) !== null && _req$afterAction2 !== void 0 && _req$afterAction2.includes('closeModal') && modalContext.inModal) {
91
91
  modalContext.closeModal();
@@ -142,7 +142,9 @@ export default function (props) {
142
142
  lg: 20
143
143
  }, /*#__PURE__*/React.createElement(FormContext.Provider, {
144
144
  value: {
145
- formRef: formRef,
145
+ getFormRef: function getFormRef() {
146
+ return formRef.current;
147
+ },
146
148
  extraRenderValues: props.extraRenderValues
147
149
  }
148
150
  }, /*#__PURE__*/React.createElement(BetaSchemaForm, {
@@ -153,6 +155,10 @@ export default function (props) {
153
155
  loading: loading,
154
156
  formRef: formRef,
155
157
  initialValues: props.initialValues,
158
+ scrollToFirstError: {
159
+ block: 'center',
160
+ behavior: 'smooth'
161
+ },
156
162
  onFinish: onFinish,
157
163
  submitter: {
158
164
  render: function render() {
@@ -1,7 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { ProFormInstance } from "@ant-design/pro-components";
2
- import { MutableRefObject } from "react";
3
3
  export type FormContextProps = {
4
- formRef?: MutableRefObject<ProFormInstance | undefined>;
4
+ getFormRef: () => ProFormInstance;
5
5
  extraRenderValues?: Record<string, any>;
6
6
  };
7
7
  export declare const FormContext: import("react").Context<FormContextProps>;
@@ -70,6 +70,11 @@ export default function (props) {
70
70
  title: layoutProps === null || layoutProps === void 0 ? void 0 : layoutProps.title
71
71
  });
72
72
  }
73
+ if (layoutProps !== null && layoutProps !== void 0 && layoutProps.menuActiveKey) {
74
+ assignProps({
75
+ menuActiveKey: layoutProps === null || layoutProps === void 0 ? void 0 : layoutProps.menuActiveKey
76
+ });
77
+ }
73
78
  };
74
79
  document.addEventListener('inertia:navigate', listener);
75
80
  return function () {
@@ -23,7 +23,7 @@ export default function (props) {
23
23
  var tableContext = useContext(TableContext);
24
24
  var onClick = /*#__PURE__*/function () {
25
25
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
26
- var rowKey, data, _props$selectedRows, _loop, _ret, key, _tableContext$actionR;
26
+ var rowKey, data, _props$selectedRows, _loop, _ret, key, _tableContext$getActi;
27
27
  return _regeneratorRuntime().wrap(function _callee$(_context2) {
28
28
  while (1) switch (_context2.prev = _context2.next) {
29
29
  case 0:
@@ -105,7 +105,7 @@ export default function (props) {
105
105
  });
106
106
  case 22:
107
107
  _context2.next = 24;
108
- return (_tableContext$actionR = tableContext.actionRef) === null || _tableContext$actionR === void 0 ? void 0 : _tableContext$actionR.reload();
108
+ return (_tableContext$getActi = tableContext.getActionRef()) === null || _tableContext$getActi === void 0 ? void 0 : _tableContext$getActi.reload();
109
109
  case 24:
110
110
  _context2.prev = 24;
111
111
  setLoading(false);
@@ -28,15 +28,15 @@ export default function (props) {
28
28
  var onStartClick = function onStartClick() {
29
29
  var rowKey = tableContext.getTableProps().rowKey;
30
30
  allChildren(tableContext.dataSource, function (item) {
31
- var _tableContext$actionR;
32
- (_tableContext$actionR = tableContext.actionRef) === null || _tableContext$actionR === void 0 || _tableContext$actionR.startEditable(item[rowKey], item);
31
+ var _tableContext$getActi;
32
+ (_tableContext$getActi = tableContext.getActionRef()) === null || _tableContext$getActi === void 0 || _tableContext$getActi.startEditable(item[rowKey], item);
33
33
  });
34
34
  };
35
35
  var onCancelClick = function onCancelClick() {
36
36
  var rowKey = tableContext.getTableProps().rowKey;
37
37
  allChildren(tableContext.dataSource, function (item) {
38
- var _tableContext$actionR2;
39
- (_tableContext$actionR2 = tableContext.actionRef) === null || _tableContext$actionR2 === void 0 || _tableContext$actionR2.cancelEditable(item[rowKey]);
38
+ var _tableContext$getActi2;
39
+ (_tableContext$getActi2 = tableContext.getActionRef()) === null || _tableContext$getActi2 === void 0 || _tableContext$getActi2.cancelEditable(item[rowKey]);
40
40
  });
41
41
  };
42
42
  var _useState = useState(false),
@@ -45,7 +45,7 @@ export default function (props) {
45
45
  setLoading = _useState2[1];
46
46
  var onSaveClick = /*#__PURE__*/function () {
47
47
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
48
- var data, _loop, dataKey, _tableContext$actionR3;
48
+ var data, _loop, dataKey, _tableContext$getActi3;
49
49
  return _regeneratorRuntime().wrap(function _callee$(_context2) {
50
50
  while (1) switch (_context2.prev = _context2.next) {
51
51
  case 0:
@@ -105,7 +105,7 @@ export default function (props) {
105
105
  });
106
106
  case 16:
107
107
  _context2.next = 18;
108
- return (_tableContext$actionR3 = tableContext.actionRef) === null || _tableContext$actionR3 === void 0 ? void 0 : _tableContext$actionR3.reload();
108
+ return (_tableContext$getActi3 = tableContext.getActionRef()) === null || _tableContext$getActi3 === void 0 ? void 0 : _tableContext$getActi3.reload();
109
109
  case 18:
110
110
  _context2.prev = 18;
111
111
  setLoading(false);
@@ -177,8 +177,12 @@ export default function (props) {
177
177
  return editableValues;
178
178
  },
179
179
  editableKeys: editableKeys,
180
- actionRef: actionRef.current,
181
- formRef: formRef.current,
180
+ getActionRef: function getActionRef() {
181
+ return actionRef.current;
182
+ },
183
+ getFormRef: function getFormRef() {
184
+ return formRef.current;
185
+ },
182
186
  extraRenderValues: extraRenderValues,
183
187
  dataSource: dataSource
184
188
  }
@@ -6,11 +6,11 @@ export type TableContextValue = {
6
6
  getTableProps: () => TableProps;
7
7
  getEditedValues: () => Record<string, any>[];
8
8
  editableKeys: React.Key[];
9
- actionRef?: ActionType & {
9
+ getActionRef: () => ActionType & {
10
10
  startEditable: (key: React.Key, row?: any) => boolean;
11
11
  cancelEditable: (key: React.Key) => void;
12
12
  };
13
- formRef?: FormInstance;
13
+ getFormRef: () => FormInstance;
14
14
  extraRenderValues?: Record<string, any>[];
15
15
  dataSource: any[];
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quansitech/antd-admin",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"