@nokecy/qc-ui 1.0.60 → 1.0.62
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.
- package/dist/cjs/generatedListPage/OptionsColumn.js +4 -4
- package/dist/cjs/generatedListPage/PerformanceMonitor.d.ts +1 -1
- package/dist/cjs/generatedListPage/PerformanceMonitor.js +12 -10
- package/dist/cjs/generatedListPage/usePermissionCheck.d.ts +2 -2
- package/dist/cjs/generatedListPage/usePermissionCheck.js +7 -7
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/standardFormDialog/types.d.ts +2 -0
- package/dist/cjs/standardFormDialog/withStandardForm.js +27 -3
- package/dist/esm/generatedListPage/OptionsColumn.js +4 -4
- package/dist/esm/generatedListPage/PerformanceMonitor.d.ts +1 -1
- package/dist/esm/generatedListPage/PerformanceMonitor.js +1 -1
- package/dist/esm/generatedListPage/usePermissionCheck.d.ts +2 -2
- package/dist/esm/generatedListPage/usePermissionCheck.js +7 -7
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/standardFormDialog/types.d.ts +2 -0
- package/dist/esm/standardFormDialog/withStandardForm.js +25 -3
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -77,11 +77,11 @@ var OptionsColumn = function OptionsColumn(props) {
|
|
|
77
77
|
|
|
78
78
|
// 显示条件判断 - 优化后的权限检查
|
|
79
79
|
var showEditButton = (0, _react.useMemo)(function () {
|
|
80
|
-
return (formDialog === null || formDialog === void 0 ? void 0 : formDialog.component) && permissions.update && canUpdate;
|
|
81
|
-
}, [formDialog === null || formDialog === void 0 ? void 0 : formDialog.component, permissions.update, canUpdate]);
|
|
80
|
+
return (formDialog === null || formDialog === void 0 ? void 0 : formDialog.component) && (permissions === null || permissions === void 0 ? void 0 : permissions.update) && canUpdate;
|
|
81
|
+
}, [formDialog === null || formDialog === void 0 ? void 0 : formDialog.component, permissions === null || permissions === void 0 ? void 0 : permissions.update, canUpdate]);
|
|
82
82
|
var showDeleteButton = (0, _react.useMemo)(function () {
|
|
83
|
-
return deleteApi && permissions.delete && canDelete;
|
|
84
|
-
}, [deleteApi, permissions.delete, canDelete]);
|
|
83
|
+
return deleteApi && (permissions === null || permissions === void 0 ? void 0 : permissions.delete) && canDelete;
|
|
84
|
+
}, [deleteApi, permissions === null || permissions === void 0 ? void 0 : permissions.delete, canDelete]);
|
|
85
85
|
|
|
86
86
|
// 如果没有任何可操作的按钮,不渲染
|
|
87
87
|
if (!showEditButton && !showDeleteButton) {
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.usePerformanceMonitor = exports.PerformanceDevTools = void 0;
|
|
8
|
-
var _react = require("react");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
11
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
13
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -216,7 +218,7 @@ var PerformanceDevTools = exports.PerformanceDevTools = function PerformanceDevT
|
|
|
216
218
|
if (value <= thresholds[1]) return '#faad14';
|
|
217
219
|
return '#f5222d';
|
|
218
220
|
};
|
|
219
|
-
return /*#__PURE__*/
|
|
221
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
220
222
|
style: {
|
|
221
223
|
position: 'fixed',
|
|
222
224
|
bottom: 20,
|
|
@@ -233,33 +235,33 @@ var PerformanceDevTools = exports.PerformanceDevTools = function PerformanceDevT
|
|
|
233
235
|
},
|
|
234
236
|
onClick: handleShowReport,
|
|
235
237
|
title: "\u70B9\u51FB\u67E5\u770B\u8BE6\u7EC6\u6027\u80FD\u62A5\u544A"
|
|
236
|
-
}, /*#__PURE__*/
|
|
238
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
237
239
|
style: {
|
|
238
240
|
marginBottom: 4,
|
|
239
241
|
fontWeight: 'bold'
|
|
240
242
|
}
|
|
241
|
-
}, "\uD83D\uDCCA ", componentName), /*#__PURE__*/
|
|
243
|
+
}, "\uD83D\uDCCA ", componentName), /*#__PURE__*/_react.default.createElement("div", {
|
|
242
244
|
style: {
|
|
243
245
|
display: 'flex',
|
|
244
246
|
gap: 8
|
|
245
247
|
}
|
|
246
|
-
}, /*#__PURE__*/
|
|
248
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
247
249
|
style: {
|
|
248
250
|
color: getPerformanceColor(metrics.renderTime, [16, 50])
|
|
249
251
|
}
|
|
250
|
-
}, "R: ", metrics.renderTime, "ms"), /*#__PURE__*/
|
|
252
|
+
}, "R: ", metrics.renderTime, "ms"), /*#__PURE__*/_react.default.createElement("span", {
|
|
251
253
|
style: {
|
|
252
254
|
color: getPerformanceColor(metrics.mountTime, [100, 300])
|
|
253
255
|
}
|
|
254
|
-
}, "M: ", metrics.mountTime, "ms"), metrics.apiResponseTime && /*#__PURE__*/
|
|
256
|
+
}, "M: ", metrics.mountTime, "ms"), metrics.apiResponseTime && /*#__PURE__*/_react.default.createElement("span", {
|
|
255
257
|
style: {
|
|
256
258
|
color: getPerformanceColor(metrics.apiResponseTime, [300, 1000])
|
|
257
259
|
}
|
|
258
|
-
}, "API: ", metrics.apiResponseTime, "ms"), /*#__PURE__*/
|
|
260
|
+
}, "API: ", metrics.apiResponseTime, "ms"), /*#__PURE__*/_react.default.createElement("span", {
|
|
259
261
|
style: {
|
|
260
262
|
color: metrics.errorCount === 0 ? '#52c41a' : '#f5222d'
|
|
261
263
|
}
|
|
262
|
-
}, "E: ", metrics.errorCount)), showDetails && /*#__PURE__*/
|
|
264
|
+
}, "E: ", metrics.errorCount)), showDetails && /*#__PURE__*/_react.default.createElement("div", {
|
|
263
265
|
style: {
|
|
264
266
|
marginTop: 8,
|
|
265
267
|
padding: 8,
|
|
@@ -267,7 +269,7 @@ var PerformanceDevTools = exports.PerformanceDevTools = function PerformanceDevT
|
|
|
267
269
|
borderRadius: 4,
|
|
268
270
|
fontSize: 11
|
|
269
271
|
}
|
|
270
|
-
}, /*#__PURE__*/
|
|
272
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, "\u66F4\u65B0\u6B21\u6570: ", metrics.updateCount), metrics.memoryUsage && /*#__PURE__*/_react.default.createElement("div", null, "\u5185\u5B58: ", metrics.memoryUsage.toFixed(1), "MB"), /*#__PURE__*/_react.default.createElement("div", {
|
|
271
273
|
style: {
|
|
272
274
|
fontSize: 10,
|
|
273
275
|
opacity: 0.7,
|
|
@@ -27,11 +27,11 @@ interface PermissionCheckResult {
|
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* 权限检查 Hook
|
|
30
|
-
* @param permissions
|
|
30
|
+
* @param permissions 权限配置对象(可选)
|
|
31
31
|
* @param access 可选的 access 对象(如果不传入,默认全部允许)
|
|
32
32
|
* @returns 权限检查结果
|
|
33
33
|
*/
|
|
34
|
-
export declare function usePermissionCheck(permissions
|
|
34
|
+
export declare function usePermissionCheck(permissions?: PermissionConfig, access?: Record<string, boolean>): PermissionCheckResult;
|
|
35
35
|
/**
|
|
36
36
|
* 权限检查工具类
|
|
37
37
|
* 用于非 Hook 场景下的权限检查
|
|
@@ -20,7 +20,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
20
20
|
*/
|
|
21
21
|
/**
|
|
22
22
|
* 权限检查 Hook
|
|
23
|
-
* @param permissions
|
|
23
|
+
* @param permissions 权限配置对象(可选)
|
|
24
24
|
* @param access 可选的 access 对象(如果不传入,默认全部允许)
|
|
25
25
|
* @returns 权限检查结果
|
|
26
26
|
*/
|
|
@@ -62,12 +62,12 @@ function usePermissionCheck(permissions, access) {
|
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
64
|
return {
|
|
65
|
-
canView: hasPermission(permissions.view),
|
|
66
|
-
canCreate: hasPermission(permissions.create),
|
|
67
|
-
canUpdate: hasPermission(permissions.update),
|
|
68
|
-
canDelete: hasPermission(permissions.delete),
|
|
69
|
-
canImport: hasPermission(permissions.import),
|
|
70
|
-
canExport: hasPermission(permissions.export),
|
|
65
|
+
canView: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.view),
|
|
66
|
+
canCreate: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.create),
|
|
67
|
+
canUpdate: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.update),
|
|
68
|
+
canDelete: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.delete),
|
|
69
|
+
canImport: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.import),
|
|
70
|
+
canExport: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.export),
|
|
71
71
|
hasPermission: hasPermission,
|
|
72
72
|
hasAllPermissions: hasAllPermissions,
|
|
73
73
|
hasAnyPermission: hasAnyPermission
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -16,9 +16,9 @@ import ImportModal from "./importModal";
|
|
|
16
16
|
import FullScreenAlert from "./fullScreenAlert";
|
|
17
17
|
import ConfirmPro from "./ConfirmPro";
|
|
18
18
|
import { GeneratedListPage } from "./generatedListPage";
|
|
19
|
-
import { StandardFormDialog } from "./standardFormDialog";
|
|
19
|
+
import { StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField } from "./standardFormDialog";
|
|
20
20
|
import DeleteConfirm from "./deleteConfirm";
|
|
21
|
-
export { AgGridColumn, AgGridPlus, ArrayTable, ArrayTableIndex, Card, Dashboard, DialogSelect, DraggableModal, Editable, ExtensibleGrid, flattenTreeDeep, FormDesigner, FormProContext, FormProLayout, GridPlusContext, ImportModal, QueryBuilder, ToolBar, FullScreenAlert, ConfirmPro, GeneratedListPage, StandardFormDialog, DeleteConfirm };
|
|
21
|
+
export { AgGridColumn, AgGridPlus, ArrayTable, ArrayTableIndex, Card, Dashboard, DialogSelect, DraggableModal, Editable, ExtensibleGrid, flattenTreeDeep, FormDesigner, FormProContext, FormProLayout, GridPlusContext, ImportModal, QueryBuilder, ToolBar, FullScreenAlert, ConfirmPro, GeneratedListPage, StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField, DeleteConfirm };
|
|
22
22
|
export type * from "./generatedListPage";
|
|
23
23
|
export type * from "./standardFormDialog";
|
|
24
24
|
export type * from "./deleteConfirm";
|
package/dist/cjs/index.js
CHANGED
|
@@ -75,6 +75,12 @@ Object.defineProperty(exports, "ExtensibleGrid", {
|
|
|
75
75
|
return _extensibleGrid.default;
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
+
Object.defineProperty(exports, "FieldCreators", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _standardFormDialog.FieldCreators;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
78
84
|
Object.defineProperty(exports, "FormDesigner", {
|
|
79
85
|
enumerable: true,
|
|
80
86
|
get: function get() {
|
|
@@ -135,12 +141,30 @@ Object.defineProperty(exports, "ToolBar", {
|
|
|
135
141
|
return _toolBar.default;
|
|
136
142
|
}
|
|
137
143
|
});
|
|
144
|
+
Object.defineProperty(exports, "createCascaderField", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function get() {
|
|
147
|
+
return _standardFormDialog.createCascaderField;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "createSelectField", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function get() {
|
|
153
|
+
return _standardFormDialog.createSelectField;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
138
156
|
Object.defineProperty(exports, "flattenTreeDeep", {
|
|
139
157
|
enumerable: true,
|
|
140
158
|
get: function get() {
|
|
141
159
|
return _agGridPlus.flattenTreeDeep;
|
|
142
160
|
}
|
|
143
161
|
});
|
|
162
|
+
Object.defineProperty(exports, "withStandardForm", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function get() {
|
|
165
|
+
return _standardFormDialog.withStandardForm;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
144
168
|
var _agGridPlus = require("./ag-grid-plus");
|
|
145
169
|
var _arrayTable = _interopRequireDefault(require("./array-table"));
|
|
146
170
|
var _arrayTableIndex = _interopRequireDefault(require("./array-table-index"));
|
|
@@ -91,6 +91,8 @@ export interface WithStandardFormConfig {
|
|
|
91
91
|
initializer?: (form: any, entityId?: string | number) => Promise<void>;
|
|
92
92
|
submitHandler?: (values: any, isEdit: boolean) => Promise<void>;
|
|
93
93
|
};
|
|
94
|
+
/** 自定义组件映射 */
|
|
95
|
+
customComponents?: Record<string, React.ComponentType<any>>;
|
|
94
96
|
}
|
|
95
97
|
/**
|
|
96
98
|
* StandardFormDialog组件属性接口
|
|
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withStandardForm = exports.default = exports.createSelectField = exports.createCascaderField = exports.FieldCreators = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _react2 = require("@formily/react");
|
|
9
|
+
var _antdV = require("@formily/antd-v5");
|
|
8
10
|
var _StandardFormDialog = _interopRequireDefault(require("./StandardFormDialog"));
|
|
9
11
|
var _excluded = ["entityId", "title", "width", "onAfterSubmit", "children", "buttonProps"];
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
15
|
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); }
|
|
12
16
|
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); }
|
|
13
17
|
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; }
|
|
@@ -66,7 +70,9 @@ var withStandardForm = exports.withStandardForm = function withStandardForm(conf
|
|
|
66
70
|
_config$defaultDialog = config.defaultDialogConfig,
|
|
67
71
|
defaultDialogConfig = _config$defaultDialog === void 0 ? {} : _config$defaultDialog,
|
|
68
72
|
_config$customHandler = config.customHandlers,
|
|
69
|
-
customHandlers = _config$customHandler === void 0 ? {} : _config$customHandler
|
|
73
|
+
customHandlers = _config$customHandler === void 0 ? {} : _config$customHandler,
|
|
74
|
+
_config$customCompone = config.customComponents,
|
|
75
|
+
customComponents = _config$customCompone === void 0 ? {} : _config$customCompone;
|
|
70
76
|
|
|
71
77
|
// 验证配置
|
|
72
78
|
if (!externalSchema && !businessFields) {
|
|
@@ -135,6 +141,23 @@ var withStandardForm = exports.withStandardForm = function withStandardForm(conf
|
|
|
135
141
|
console.log("\u2705 withStandardForm: ".concat(formId, " \u4F7F\u7528\u5185\u90E8\u6784\u5EFASchema"));
|
|
136
142
|
}
|
|
137
143
|
|
|
144
|
+
// 创建自定义的 useSchemaField hook
|
|
145
|
+
var useCustomSchemaField = function useCustomSchemaField() {
|
|
146
|
+
return (0, _react.useMemo)(function () {
|
|
147
|
+
// 合并默认组件和自定义组件
|
|
148
|
+
var components = _objectSpread({
|
|
149
|
+
Input: _antdV.Input,
|
|
150
|
+
Select: _antdV.Select,
|
|
151
|
+
DatePicker: _antdV.DatePicker,
|
|
152
|
+
NumberPicker: _antdV.NumberPicker,
|
|
153
|
+
Switch: _antdV.Switch
|
|
154
|
+
}, customComponents);
|
|
155
|
+
return (0, _react2.createSchemaField)({
|
|
156
|
+
components: components
|
|
157
|
+
});
|
|
158
|
+
}, []);
|
|
159
|
+
};
|
|
160
|
+
|
|
138
161
|
// 创建标准表单组件
|
|
139
162
|
var StandardFormComponent = function StandardFormComponent(props) {
|
|
140
163
|
var entityId = props.entityId,
|
|
@@ -159,7 +182,8 @@ var withStandardForm = exports.withStandardForm = function withStandardForm(conf
|
|
|
159
182
|
onAfterSubmit: onAfterSubmit,
|
|
160
183
|
buttonProps: buttonProps,
|
|
161
184
|
customInitializer: customHandlers.initializer,
|
|
162
|
-
customSubmitHandler: customHandlers.submitHandler
|
|
185
|
+
customSubmitHandler: customHandlers.submitHandler,
|
|
186
|
+
useSchemaField: useCustomSchemaField
|
|
163
187
|
}, restProps), children);
|
|
164
188
|
};
|
|
165
189
|
|
|
@@ -69,11 +69,11 @@ var OptionsColumn = function OptionsColumn(props) {
|
|
|
69
69
|
|
|
70
70
|
// 显示条件判断 - 优化后的权限检查
|
|
71
71
|
var showEditButton = useMemo(function () {
|
|
72
|
-
return (formDialog === null || formDialog === void 0 ? void 0 : formDialog.component) && permissions.update && canUpdate;
|
|
73
|
-
}, [formDialog === null || formDialog === void 0 ? void 0 : formDialog.component, permissions.update, canUpdate]);
|
|
72
|
+
return (formDialog === null || formDialog === void 0 ? void 0 : formDialog.component) && (permissions === null || permissions === void 0 ? void 0 : permissions.update) && canUpdate;
|
|
73
|
+
}, [formDialog === null || formDialog === void 0 ? void 0 : formDialog.component, permissions === null || permissions === void 0 ? void 0 : permissions.update, canUpdate]);
|
|
74
74
|
var showDeleteButton = useMemo(function () {
|
|
75
|
-
return deleteApi && permissions.delete && canDelete;
|
|
76
|
-
}, [deleteApi, permissions.delete, canDelete]);
|
|
75
|
+
return deleteApi && (permissions === null || permissions === void 0 ? void 0 : permissions.delete) && canDelete;
|
|
76
|
+
}, [deleteApi, permissions === null || permissions === void 0 ? void 0 : permissions.delete, canDelete]);
|
|
77
77
|
|
|
78
78
|
// 如果没有任何可操作的按钮,不渲染
|
|
79
79
|
if (!showEditButton && !showDeleteButton) {
|
|
@@ -13,7 +13,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
13
13
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
14
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
import { useEffect, useRef, useState } from 'react';
|
|
16
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 性能指标接口
|
|
@@ -27,11 +27,11 @@ interface PermissionCheckResult {
|
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* 权限检查 Hook
|
|
30
|
-
* @param permissions
|
|
30
|
+
* @param permissions 权限配置对象(可选)
|
|
31
31
|
* @param access 可选的 access 对象(如果不传入,默认全部允许)
|
|
32
32
|
* @returns 权限检查结果
|
|
33
33
|
*/
|
|
34
|
-
export declare function usePermissionCheck(permissions
|
|
34
|
+
export declare function usePermissionCheck(permissions?: PermissionConfig, access?: Record<string, boolean>): PermissionCheckResult;
|
|
35
35
|
/**
|
|
36
36
|
* 权限检查工具类
|
|
37
37
|
* 用于非 Hook 场景下的权限检查
|
|
@@ -15,7 +15,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
15
15
|
import { useMemo } from 'react';
|
|
16
16
|
/**
|
|
17
17
|
* 权限检查 Hook
|
|
18
|
-
* @param permissions
|
|
18
|
+
* @param permissions 权限配置对象(可选)
|
|
19
19
|
* @param access 可选的 access 对象(如果不传入,默认全部允许)
|
|
20
20
|
* @returns 权限检查结果
|
|
21
21
|
*/
|
|
@@ -57,12 +57,12 @@ export function usePermissionCheck(permissions, access) {
|
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
return {
|
|
60
|
-
canView: hasPermission(permissions.view),
|
|
61
|
-
canCreate: hasPermission(permissions.create),
|
|
62
|
-
canUpdate: hasPermission(permissions.update),
|
|
63
|
-
canDelete: hasPermission(permissions.delete),
|
|
64
|
-
canImport: hasPermission(permissions.import),
|
|
65
|
-
canExport: hasPermission(permissions.export),
|
|
60
|
+
canView: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.view),
|
|
61
|
+
canCreate: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.create),
|
|
62
|
+
canUpdate: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.update),
|
|
63
|
+
canDelete: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.delete),
|
|
64
|
+
canImport: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.import),
|
|
65
|
+
canExport: hasPermission(permissions === null || permissions === void 0 ? void 0 : permissions.export),
|
|
66
66
|
hasPermission: hasPermission,
|
|
67
67
|
hasAllPermissions: hasAllPermissions,
|
|
68
68
|
hasAnyPermission: hasAnyPermission
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -16,9 +16,9 @@ import ImportModal from "./importModal";
|
|
|
16
16
|
import FullScreenAlert from "./fullScreenAlert";
|
|
17
17
|
import ConfirmPro from "./ConfirmPro";
|
|
18
18
|
import { GeneratedListPage } from "./generatedListPage";
|
|
19
|
-
import { StandardFormDialog } from "./standardFormDialog";
|
|
19
|
+
import { StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField } from "./standardFormDialog";
|
|
20
20
|
import DeleteConfirm from "./deleteConfirm";
|
|
21
|
-
export { AgGridColumn, AgGridPlus, ArrayTable, ArrayTableIndex, Card, Dashboard, DialogSelect, DraggableModal, Editable, ExtensibleGrid, flattenTreeDeep, FormDesigner, FormProContext, FormProLayout, GridPlusContext, ImportModal, QueryBuilder, ToolBar, FullScreenAlert, ConfirmPro, GeneratedListPage, StandardFormDialog, DeleteConfirm };
|
|
21
|
+
export { AgGridColumn, AgGridPlus, ArrayTable, ArrayTableIndex, Card, Dashboard, DialogSelect, DraggableModal, Editable, ExtensibleGrid, flattenTreeDeep, FormDesigner, FormProContext, FormProLayout, GridPlusContext, ImportModal, QueryBuilder, ToolBar, FullScreenAlert, ConfirmPro, GeneratedListPage, StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField, DeleteConfirm };
|
|
22
22
|
export type * from "./generatedListPage";
|
|
23
23
|
export type * from "./standardFormDialog";
|
|
24
24
|
export type * from "./deleteConfirm";
|
package/dist/esm/index.js
CHANGED
|
@@ -16,8 +16,8 @@ import ImportModal from "./importModal";
|
|
|
16
16
|
import FullScreenAlert from "./fullScreenAlert";
|
|
17
17
|
import ConfirmPro from "./ConfirmPro";
|
|
18
18
|
import { GeneratedListPage } from "./generatedListPage";
|
|
19
|
-
import { StandardFormDialog } from "./standardFormDialog";
|
|
19
|
+
import { StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField } from "./standardFormDialog";
|
|
20
20
|
import DeleteConfirm from "./deleteConfirm";
|
|
21
|
-
export { AgGridColumn, AgGridPlus, ArrayTable, ArrayTableIndex, Card, Dashboard, DialogSelect, DraggableModal, Editable, ExtensibleGrid, flattenTreeDeep, FormDesigner, FormProContext, FormProLayout, GridPlusContext, ImportModal, QueryBuilder, ToolBar, FullScreenAlert, ConfirmPro, GeneratedListPage, StandardFormDialog, DeleteConfirm };
|
|
21
|
+
export { AgGridColumn, AgGridPlus, ArrayTable, ArrayTableIndex, Card, Dashboard, DialogSelect, DraggableModal, Editable, ExtensibleGrid, flattenTreeDeep, FormDesigner, FormProContext, FormProLayout, GridPlusContext, ImportModal, QueryBuilder, ToolBar, FullScreenAlert, ConfirmPro, GeneratedListPage, StandardFormDialog, withStandardForm, FieldCreators, createSelectField, createCascaderField, DeleteConfirm };
|
|
22
22
|
|
|
23
23
|
// 导出类型定义
|
|
@@ -91,6 +91,8 @@ export interface WithStandardFormConfig {
|
|
|
91
91
|
initializer?: (form: any, entityId?: string | number) => Promise<void>;
|
|
92
92
|
submitHandler?: (values: any, isEdit: boolean) => Promise<void>;
|
|
93
93
|
};
|
|
94
|
+
/** 自定义组件映射 */
|
|
95
|
+
customComponents?: Record<string, React.ComponentType<any>>;
|
|
94
96
|
}
|
|
95
97
|
/**
|
|
96
98
|
* StandardFormDialog组件属性接口
|
|
@@ -8,7 +8,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
8
8
|
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; }
|
|
9
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
-
import React from 'react';
|
|
11
|
+
import React, { useMemo } from 'react';
|
|
12
|
+
import { createSchemaField } from '@formily/react';
|
|
13
|
+
import { Input, Select, DatePicker, NumberPicker, Switch } from '@formily/antd-v5';
|
|
12
14
|
import StandardFormDialog from "./StandardFormDialog";
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -60,7 +62,9 @@ export var withStandardForm = function withStandardForm(config) {
|
|
|
60
62
|
_config$defaultDialog = config.defaultDialogConfig,
|
|
61
63
|
defaultDialogConfig = _config$defaultDialog === void 0 ? {} : _config$defaultDialog,
|
|
62
64
|
_config$customHandler = config.customHandlers,
|
|
63
|
-
customHandlers = _config$customHandler === void 0 ? {} : _config$customHandler
|
|
65
|
+
customHandlers = _config$customHandler === void 0 ? {} : _config$customHandler,
|
|
66
|
+
_config$customCompone = config.customComponents,
|
|
67
|
+
customComponents = _config$customCompone === void 0 ? {} : _config$customCompone;
|
|
64
68
|
|
|
65
69
|
// 验证配置
|
|
66
70
|
if (!externalSchema && !businessFields) {
|
|
@@ -129,6 +133,23 @@ export var withStandardForm = function withStandardForm(config) {
|
|
|
129
133
|
console.log("\u2705 withStandardForm: ".concat(formId, " \u4F7F\u7528\u5185\u90E8\u6784\u5EFASchema"));
|
|
130
134
|
}
|
|
131
135
|
|
|
136
|
+
// 创建自定义的 useSchemaField hook
|
|
137
|
+
var useCustomSchemaField = function useCustomSchemaField() {
|
|
138
|
+
return useMemo(function () {
|
|
139
|
+
// 合并默认组件和自定义组件
|
|
140
|
+
var components = _objectSpread({
|
|
141
|
+
Input: Input,
|
|
142
|
+
Select: Select,
|
|
143
|
+
DatePicker: DatePicker,
|
|
144
|
+
NumberPicker: NumberPicker,
|
|
145
|
+
Switch: Switch
|
|
146
|
+
}, customComponents);
|
|
147
|
+
return createSchemaField({
|
|
148
|
+
components: components
|
|
149
|
+
});
|
|
150
|
+
}, []);
|
|
151
|
+
};
|
|
152
|
+
|
|
132
153
|
// 创建标准表单组件
|
|
133
154
|
var StandardFormComponent = function StandardFormComponent(props) {
|
|
134
155
|
var entityId = props.entityId,
|
|
@@ -153,7 +174,8 @@ export var withStandardForm = function withStandardForm(config) {
|
|
|
153
174
|
onAfterSubmit: onAfterSubmit,
|
|
154
175
|
buttonProps: buttonProps,
|
|
155
176
|
customInitializer: customHandlers.initializer,
|
|
156
|
-
customSubmitHandler: customHandlers.submitHandler
|
|
177
|
+
customSubmitHandler: customHandlers.submitHandler,
|
|
178
|
+
useSchemaField: useCustomSchemaField
|
|
157
179
|
}, restProps), children);
|
|
158
180
|
};
|
|
159
181
|
|