@quansitech/antd-admin 1.1.26 → 1.1.28

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.
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import './New.scss';
2
3
  export default function ({ children, pageTitle, siteTitle, setDarkMode }: {
3
4
  children: React.ReactNode;
4
5
  pageTitle: string;
@@ -24,6 +24,7 @@ import http from "../../lib/http";
24
24
 
25
25
  import { MoonOutlined, SunOutlined } from "@ant-design/icons";
26
26
  import { usePage } from "@inertiajs/react";
27
+ import "./New.scss";
27
28
  export default function (_ref) {
28
29
  var _layoutContext$props$;
29
30
  var children = _ref.children,
@@ -0,0 +1,3 @@
1
+ .ant-pro-global-header .ant-menu {
2
+ background: none;
3
+ }
@@ -19,11 +19,12 @@ import React, { useContext, useEffect, useState } from "react";
19
19
  import { TableContext } from "../../TableContext";
20
20
  import http from "../../../lib/http";
21
21
  import { modalShow, routerNavigateTo } from "../../../lib/helpers";
22
+ import { cloneDeep } from "es-toolkit";
22
23
  export default function (props) {
23
24
  var tableContext = useContext(TableContext);
24
25
  var onClick = /*#__PURE__*/function () {
25
26
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
26
- var rowKey, data, _props$selectedRows, _loop, _ret, key, _tableContext$getActi;
27
+ var rowKey, data, selectedRows, _loop, _ret, key, _tableContext$getActi;
27
28
  return _regeneratorRuntime().wrap(function _callee$(_context2) {
28
29
  while (1) switch (_context2.prev = _context2.next) {
29
30
  case 0:
@@ -36,20 +37,20 @@ export default function (props) {
36
37
  return _context2.abrupt("return");
37
38
  case 4:
38
39
  if (!props.request) {
39
- _context2.next = 29;
40
+ _context2.next = 30;
40
41
  break;
41
42
  }
42
43
  setLoading(true);
43
- data = props.request.data || {};
44
+ data = cloneDeep(props.request.data) || {};
44
45
  if (!props.relateSelection) {
45
- _context2.next = 19;
46
+ _context2.next = 20;
46
47
  break;
47
48
  }
48
- data.selection = (_props$selectedRows = props.selectedRows) === null || _props$selectedRows === void 0 ? void 0 : _props$selectedRows.map(function (item) {
49
+ selectedRows = tableContext.getSelectedRows();
50
+ data.selection = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (item) {
49
51
  return item[rowKey];
50
52
  });
51
53
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
52
- var _props$selectedRows2;
53
54
  var matches;
54
55
  return _regeneratorRuntime().wrap(function _loop$(_context) {
55
56
  while (1) switch (_context.prev = _context.next) {
@@ -67,7 +68,7 @@ export default function (props) {
67
68
  }
68
69
  return _context.abrupt("return", 0);
69
70
  case 5:
70
- data[key] = (_props$selectedRows2 = props.selectedRows) === null || _props$selectedRows2 === void 0 ? void 0 : _props$selectedRows2.map(function (item) {
71
+ data[key] = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (item) {
71
72
  return item[matches[1]];
72
73
  });
73
74
  case 6:
@@ -77,65 +78,65 @@ export default function (props) {
77
78
  }, _loop);
78
79
  });
79
80
  _context2.t0 = _regeneratorRuntime().keys(data);
80
- case 11:
81
+ case 12:
81
82
  if ((_context2.t1 = _context2.t0()).done) {
82
- _context2.next = 19;
83
+ _context2.next = 20;
83
84
  break;
84
85
  }
85
86
  key = _context2.t1.value;
86
- return _context2.delegateYield(_loop(), "t2", 14);
87
- case 14:
87
+ return _context2.delegateYield(_loop(), "t2", 15);
88
+ case 15:
88
89
  _ret = _context2.t2;
89
90
  if (!(_ret === 0)) {
90
- _context2.next = 17;
91
+ _context2.next = 18;
91
92
  break;
92
93
  }
93
- return _context2.abrupt("continue", 11);
94
- case 17:
95
- _context2.next = 11;
94
+ return _context2.abrupt("continue", 12);
95
+ case 18:
96
+ _context2.next = 12;
96
97
  break;
97
- case 19:
98
- _context2.prev = 19;
99
- _context2.next = 22;
98
+ case 20:
99
+ _context2.prev = 20;
100
+ _context2.next = 23;
100
101
  return http({
101
102
  url: props.request.url,
102
103
  method: props.request.method,
103
104
  headers: props.request.headers || {},
104
105
  data: data
105
106
  });
106
- case 22:
107
- _context2.next = 24;
107
+ case 23:
108
+ _context2.next = 25;
108
109
  return (_tableContext$getActi = tableContext.getActionRef()) === null || _tableContext$getActi === void 0 ? void 0 : _tableContext$getActi.reload();
109
- case 24:
110
+ case 25:
110
111
  if (props.relateSelection) {
111
112
  tableContext.getActionRef().clearSelected();
112
113
  }
113
- case 25:
114
- _context2.prev = 25;
114
+ case 26:
115
+ _context2.prev = 26;
115
116
  setLoading(false);
116
- return _context2.finish(25);
117
- case 28:
118
- return _context2.abrupt("return");
117
+ return _context2.finish(26);
119
118
  case 29:
119
+ return _context2.abrupt("return");
120
+ case 30:
120
121
  if (!props.modal) {
121
- _context2.next = 35;
122
+ _context2.next = 36;
122
123
  break;
123
124
  }
124
125
  setLoading(true);
125
- _context2.next = 33;
126
+ _context2.next = 34;
126
127
  return modalShow(_objectSpread(_objectSpread({}, props.modal), {}, {
127
128
  contexts: {
128
129
  tableContext: tableContext
129
130
  }
130
131
  }));
131
- case 33:
132
+ case 34:
132
133
  setLoading(false);
133
134
  return _context2.abrupt("return");
134
- case 35:
135
+ case 36:
135
136
  case "end":
136
137
  return _context2.stop();
137
138
  }
138
- }, _callee, null, [[19,, 25, 28]]);
139
+ }, _callee, null, [[20,, 26, 29]]);
139
140
  }));
140
141
  return function onClick() {
141
142
  return _ref.apply(this, arguments);
@@ -150,12 +151,12 @@ export default function (props) {
150
151
  disabled = _useState4[0],
151
152
  setDisabled = _useState4[1];
152
153
  useEffect(function () {
153
- var _props$selectedRows3;
154
+ var _tableContext$getSele;
154
155
  if (!props.relateSelection) {
155
156
  return;
156
157
  }
157
- setDisabled(((_props$selectedRows3 = props.selectedRows) === null || _props$selectedRows3 === void 0 ? void 0 : _props$selectedRows3.length) === 0);
158
- }, [props.selectedRows]);
158
+ setDisabled(((_tableContext$getSele = tableContext.getSelectedRows()) === null || _tableContext$getSele === void 0 ? void 0 : _tableContext$getSele.length) === 0);
159
+ }, [tableContext.getSelectedRows()]);
159
160
  var ButtonComponent = function ButtonComponent() {
160
161
  var _props$request;
161
162
  if ((_props$request = props.request) !== null && _props$request !== void 0 && _props$request.confirm) {
@@ -3,6 +3,5 @@ export type TableActionProps = {
3
3
  title: string,
4
4
  props?: Record<string, any>,
5
5
  relateSelection?: boolean,
6
- selectedRows?: any[],
7
6
  badge?: string | number,
8
7
  }
@@ -1,5 +1,4 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- 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); }
3
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -38,12 +37,8 @@ export default function (_ref) {
38
37
  }, c.props.badge ? /*#__PURE__*/React.createElement(Badge, {
39
38
  count: c.props.badge,
40
39
  style: {
41
- zIndex: 100
40
+ zIndex: 2
42
41
  }
43
- }, /*#__PURE__*/React.createElement(c.Component, _extends({}, c.props, {
44
- selectedRows: selectedRows
45
- }))) : /*#__PURE__*/React.createElement(c.Component, _extends({}, c.props, {
46
- selectedRows: selectedRows
47
- })));
42
+ }, /*#__PURE__*/React.createElement(c.Component, c.props)) : /*#__PURE__*/React.createElement(c.Component, c.props));
48
43
  })));
49
44
  }
@@ -27,8 +27,7 @@ import http from "../lib/http";
27
27
  import "./Table.scss";
28
28
  import { ModalContext } from "./ModalContext";
29
29
  import { commonHandler } from "../lib/schemaHandler";
30
- import { diffTree, getValueByPath } from "../lib/helpers";
31
- import { router } from "@inertiajs/react";
30
+ import { diffTree, getValueByPath, routerNavigateTo } from "../lib/helpers";
32
31
  import qs from 'qs';
33
32
  import { TabsContext } from "./TabsContext";
34
33
  export default function (props) {
@@ -58,7 +57,9 @@ export default function (props) {
58
57
  if (tabsContext.inTabs) {
59
58
  only.push('tabs');
60
59
  }
61
- router.get(searchUrl, data, {
60
+ routerNavigateTo(searchUrl, {
61
+ method: 'get',
62
+ data: data,
62
63
  preserveScroll: true,
63
64
  preserveState: true,
64
65
  only: only,
@@ -233,7 +234,10 @@ export default function (props) {
233
234
  return formRef.current;
234
235
  },
235
236
  extraRenderValues: extraRenderValues,
236
- dataSource: dataSource
237
+ dataSource: dataSource,
238
+ getSelectedRows: function getSelectedRows() {
239
+ return selectedRows;
240
+ }
237
241
  }
238
242
  }, /*#__PURE__*/React.createElement(ProTable, {
239
243
  rowKey: props.rowKey,
@@ -308,8 +312,7 @@ export default function (props) {
308
312
  toolBarRender: function toolBarRender(action) {
309
313
  return [/*#__PURE__*/React.createElement(ToolbarActions, {
310
314
  key: 'actions',
311
- actions: props.actions,
312
- selectedRows: selectedRows
315
+ actions: props.actions
313
316
  })];
314
317
  },
315
318
  editable: {
@@ -13,5 +13,6 @@ export type TableContextValue = {
13
13
  getFormRef: () => FormInstance;
14
14
  extraRenderValues?: Record<string, any>[];
15
15
  dataSource: any[];
16
+ getSelectedRows: () => any[];
16
17
  };
17
18
  export declare const TableContext: React.Context<TableContextValue>;
@@ -43,6 +43,10 @@ export function replaceParams(params, data) {
43
43
  return res;
44
44
  }
45
45
  export function routerNavigateTo(url, config) {
46
+ if (url.indexOf('javascript:') !== -1) {
47
+ window.location.href = url;
48
+ return;
49
+ }
46
50
  return router.visit(url, _objectSpread({}, config));
47
51
  }
48
52
  export function createScript(url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quansitech/antd-admin",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@ant-design/pro-components": "^2.7.15",
15
- "@inertiajs/react": "^1.2.0",
15
+ "@inertiajs/react": "^1.2.0 || ^2.0.0",
16
16
  "antd": "^5.20.5",
17
17
  "antd-img-crop": "^4.23.0",
18
18
  "axios": "^1.7.7",