@nokecy/qc-ui 1.1.39 → 1.1.41
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/adapters/abpPagedApiAdapter.d.ts +8 -0
- package/dist/cjs/adapters/abpPagedApiAdapter.js +35 -0
- package/dist/cjs/adapters/index.d.ts +6 -0
- package/dist/cjs/adapters/index.js +12 -0
- package/dist/cjs/adapters/pagedApiAdapter.d.ts +25 -0
- package/dist/cjs/adapters/pagedApiAdapter.js +5 -0
- package/dist/cjs/ag-grid-plus/ag-gridPlus.js +51 -205
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/context/queryFormContext.d.ts +20 -0
- package/dist/cjs/ag-grid-plus/context/queryFormContext.js +25 -0
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/hooks/index.d.ts +1 -3
- package/dist/cjs/ag-grid-plus/hooks/index.js +7 -39
- package/dist/cjs/ag-grid-plus/hooks/useRowId.d.ts +13 -0
- package/dist/cjs/ag-grid-plus/hooks/useRowId.js +57 -0
- package/dist/cjs/ag-grid-plus/interface.d.ts +9 -0
- package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +6 -6
- package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.js +2 -3
- package/dist/cjs/ag-grid-plus/types.d.ts +9 -0
- package/dist/cjs/ag-grid-plus/utils/aggregation.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/utils/aggregation.js +101 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +2 -2
- package/dist/cjs/ag-grid-plus/utils/entityExtensionColumns.d.ts +12 -3
- package/dist/cjs/ag-grid-plus/utils/entityExtensionColumns.js +20 -5
- package/dist/cjs/ag-grid-plus/utils/queryFormDerivation.d.ts +19 -0
- package/dist/cjs/ag-grid-plus/utils/queryFormDerivation.js +49 -0
- package/dist/cjs/ag-grid-plus/utils/requestParams.d.ts +15 -0
- package/dist/cjs/ag-grid-plus/utils/requestParams.js +31 -0
- package/dist/cjs/ag-grid-plus/utils/rowSelection.d.ts +9 -0
- package/dist/cjs/ag-grid-plus/utils/rowSelection.js +24 -0
- package/dist/cjs/ag-grid-plus/utils.js +2 -2
- package/dist/cjs/array-table/arrayBase.js +2 -0
- package/dist/cjs/array-table/utils.d.ts +15 -1
- package/dist/cjs/array-table/utils.js +48 -20
- package/dist/cjs/components/RegexEditor/hooks/useRegexValidation.js +2 -3
- package/dist/cjs/components/RegexEditor/hooks/useTemplateManager.js +1 -0
- package/dist/cjs/components/RegexEditor/validation/types.d.ts +1 -3
- package/dist/cjs/components/RegexEditor/visualizer/astToRailroad.d.ts +0 -2
- package/dist/cjs/dashboard/dashboard/index.js +8 -11
- package/dist/cjs/dashboard/dashboard/utils.js +3 -6
- package/dist/cjs/dashboard/widget/index.js +3 -3
- package/dist/cjs/dashboard/widget/selector/index.js +5 -7
- package/dist/cjs/dashboard/widget/utils.js +3 -4
- package/dist/cjs/dialogSelect/index.d.ts +3 -0
- package/dist/cjs/dialogSelect/index.js +16 -13
- package/dist/cjs/generatedListPage/GeneratedListPage.js +20 -19
- package/dist/cjs/generatedListPage/_utils/toAbpPagedRequest.d.ts +15 -0
- package/dist/cjs/generatedListPage/_utils/toAbpPagedRequest.js +26 -0
- package/dist/cjs/generatedListPage/types.d.ts +3 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +57 -0
- package/dist/cjs/standardFormDialog/types.d.ts +7 -0
- package/dist/cjs/standardFormDialog/useStandardFormSchema.d.ts +1 -1
- package/dist/cjs/standardFormDialog/withStandardForm.js +5 -4
- package/dist/esm/adapters/abpPagedApiAdapter.d.ts +8 -0
- package/dist/esm/adapters/abpPagedApiAdapter.js +29 -0
- package/dist/esm/adapters/index.d.ts +6 -0
- package/dist/esm/adapters/index.js +6 -0
- package/dist/esm/adapters/pagedApiAdapter.d.ts +25 -0
- package/dist/esm/adapters/pagedApiAdapter.js +1 -0
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +49 -203
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +3 -0
- package/dist/esm/ag-grid-plus/context/queryFormContext.d.ts +20 -0
- package/dist/esm/ag-grid-plus/context/queryFormContext.js +19 -0
- package/dist/esm/ag-grid-plus/hooks/index.d.ts +1 -3
- package/dist/esm/ag-grid-plus/hooks/index.js +2 -6
- package/dist/esm/ag-grid-plus/hooks/useRowId.d.ts +13 -0
- package/dist/esm/ag-grid-plus/hooks/useRowId.js +52 -0
- package/dist/esm/ag-grid-plus/interface.d.ts +9 -0
- package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +6 -6
- package/dist/esm/ag-grid-plus/setting/columnGroupUtils.js +7 -6
- package/dist/esm/ag-grid-plus/types.d.ts +9 -0
- package/dist/esm/ag-grid-plus/utils/aggregation.d.ts +17 -0
- package/dist/esm/ag-grid-plus/utils/aggregation.js +93 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +2 -2
- package/dist/esm/ag-grid-plus/utils/entityExtensionColumns.d.ts +12 -3
- package/dist/esm/ag-grid-plus/utils/entityExtensionColumns.js +20 -5
- package/dist/esm/ag-grid-plus/utils/queryFormDerivation.d.ts +19 -0
- package/dist/esm/ag-grid-plus/utils/queryFormDerivation.js +42 -0
- package/dist/esm/ag-grid-plus/utils/requestParams.d.ts +15 -0
- package/dist/esm/ag-grid-plus/utils/requestParams.js +24 -0
- package/dist/esm/ag-grid-plus/utils/rowSelection.d.ts +9 -0
- package/dist/esm/ag-grid-plus/utils/rowSelection.js +18 -0
- package/dist/esm/ag-grid-plus/utils.js +2 -2
- package/dist/esm/array-table/arrayBase.js +2 -0
- package/dist/esm/array-table/utils.d.ts +15 -1
- package/dist/esm/array-table/utils.js +48 -20
- package/dist/esm/components/RegexEditor/hooks/useRegexValidation.js +2 -2
- package/dist/esm/components/RegexEditor/hooks/useTemplateManager.js +1 -0
- package/dist/esm/components/RegexEditor/validation/types.d.ts +0 -1
- package/dist/esm/components/RegexEditor/visualizer/astToRailroad.d.ts +0 -1
- package/dist/esm/dashboard/dashboard/index.js +8 -11
- package/dist/esm/dashboard/dashboard/utils.js +3 -2
- package/dist/esm/dashboard/widget/index.js +3 -3
- package/dist/esm/dashboard/widget/selector/index.js +5 -7
- package/dist/esm/dashboard/widget/utils.js +3 -3
- package/dist/esm/dialogSelect/index.d.ts +3 -0
- package/dist/esm/dialogSelect/index.js +16 -13
- package/dist/esm/generatedListPage/GeneratedListPage.js +20 -19
- package/dist/esm/generatedListPage/_utils/toAbpPagedRequest.d.ts +15 -0
- package/dist/esm/generatedListPage/_utils/toAbpPagedRequest.js +20 -0
- package/dist/esm/generatedListPage/types.d.ts +3 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/standardFormDialog/types.d.ts +7 -0
- package/dist/esm/standardFormDialog/withStandardForm.js +5 -4
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +52 -13
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.d.ts +0 -88
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.js +0 -224
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.d.ts +0 -91
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.js +0 -230
- package/dist/cjs/ag-grid-plus/hooks/useGridState.d.ts +0 -153
- package/dist/cjs/ag-grid-plus/hooks/useGridState.js +0 -258
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.d.ts +0 -88
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.js +0 -217
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.d.ts +0 -91
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.js +0 -225
- package/dist/esm/ag-grid-plus/hooks/useGridState.d.ts +0 -153
- package/dist/esm/ag-grid-plus/hooks/useGridState.js +0 -258
|
@@ -8,7 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
8
8
|
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; }
|
|
9
9
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
10
|
import React from 'react';
|
|
11
|
-
import { useField, useFieldSchema, RecursionField } from '@formily/react';
|
|
11
|
+
import { useField, useFieldSchema, RecursionField, Observer } from '@formily/react';
|
|
12
12
|
import { isArr } from '@formily/shared';
|
|
13
13
|
import ArrayBase from "./arrayBase";
|
|
14
14
|
import { getReadOnlyFormatter } from "./readOnlyFormatters";
|
|
@@ -148,7 +148,7 @@ var AgField = function AgField(_ref) {
|
|
|
148
148
|
* 校验安全:未碰过的存量格本就是 readPretty、本就不参与校验,不挂树校验语义零变化。@author nokecy
|
|
149
149
|
*/
|
|
150
150
|
var LazyAgField = function LazyAgField(params) {
|
|
151
|
-
var _context$activeCells, _context$activeCells
|
|
151
|
+
var _context$activeCells, _context$activeCells$, _fieldSchema$name;
|
|
152
152
|
var value = params.value,
|
|
153
153
|
record = params.data,
|
|
154
154
|
dataSource = params.dataSource,
|
|
@@ -172,19 +172,29 @@ var LazyAgField = function LazyAgField(params) {
|
|
|
172
172
|
node: node
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
|
|
176
|
+
// Observer 包裹纯文本:让未激活的廉价文本格反应式跟随内层 Formily 字段值。
|
|
177
|
+
// record 即 field.value[index] 的可观察对象;在 Observer 里按内层字段名直接读 record[dataKey]
|
|
178
|
+
// (而非 AG-Grid 渲染时快照的 params.value)建立依赖后,onFieldValueChange/setValuesIn 程序化原地
|
|
179
|
+
// 改值(行引用不变 → AG-Grid 不刷新该格、外层 observer 也不重渲)时,本格能自行重渲刷新——
|
|
180
|
+
// 免去调用方加 forceAgField 逃生阀。字段名缺失才回退 params.value。@author nokecy
|
|
181
|
+
var dataKey = (_fieldSchema$name = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name !== void 0 ? _fieldSchema$name : colDef === null || colDef === void 0 ? void 0 : colDef.field;
|
|
182
|
+
return /*#__PURE__*/React.createElement(Observer, null, function () {
|
|
183
|
+
var liveValue = dataKey != null && record ? record[dataKey] : value;
|
|
184
|
+
var text = formatter ? formatter(liveValue, {
|
|
185
|
+
columnProps: columnProps,
|
|
186
|
+
fieldSchema: fieldSchema
|
|
187
|
+
}) : liveValue == null ? '' : String(liveValue);
|
|
188
|
+
// 纯文本占满单元格,点击交给 AG-Grid onCellClicked 激活;样式尽量贴近 Editable 只读态避免点开跳动
|
|
189
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
190
|
+
className: "ag-array-table-lazy-text",
|
|
191
|
+
style: {
|
|
192
|
+
display: 'inline-block',
|
|
193
|
+
width: '100%',
|
|
194
|
+
cursor: 'text'
|
|
195
|
+
}
|
|
196
|
+
}, text);
|
|
197
|
+
});
|
|
188
198
|
};
|
|
189
199
|
|
|
190
200
|
// 在 Column 的子 schema 里递归找到内层数据字段(可读 x-component / x-pattern / x-reactions / enum) @author nokecy
|
|
@@ -272,10 +282,26 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
|
|
|
272
282
|
var readOnly = isColumnReadOnlyEligible(arrayPattern, dataField, columnProps);
|
|
273
283
|
var hasReactions = !!(dataField && dataField['x-reactions']);
|
|
274
284
|
var forceEager = (columnProps === null || columnProps === void 0 ? void 0 : columnProps.forceAgField) === true;
|
|
285
|
+
// Switch/Checkbox 是「单击直控」组件:可编辑态本就该常驻渲染真控件(优化前即如此)。
|
|
286
|
+
// 懒挂载会把它降成「是/否」纯文本(点击才挂出开关),用户会以为开关消失。故可编辑态强制 eager。
|
|
287
|
+
// 只读态(下方 ① 路径)仍走「是/否」文本快路径不受影响。@author nokecy
|
|
288
|
+
var isInlineToggle = component === 'Switch' || component === 'Checkbox';
|
|
289
|
+
|
|
290
|
+
// formatter 路径(只读快路径/懒挂载)经 AG-Grid params.value 取值,而 params.value 由 colDef.field(=name)驱动。
|
|
291
|
+
// 但设计器生成的 schema 里 Column key 多为随机 designable-id 且无 dataIndex,真实数据键在内层字段 name 上,
|
|
292
|
+
// 两者不一致时 record[name] 恒为 undefined → 单元格空白(点击挂 AgField 才按内层字段名显真值)。
|
|
293
|
+
// 故按内层字段名补 valueGetter(仅在与 name 不一致时,保持 name===字段名 的现状)。@author nokecy
|
|
294
|
+
var dataFieldName = dataField === null || dataField === void 0 ? void 0 : dataField.name;
|
|
295
|
+
var valueGetter = dataFieldName && dataFieldName !== name ? function (params) {
|
|
296
|
+
var _params$data;
|
|
297
|
+
return params === null || params === void 0 || (_params$data = params.data) === null || _params$data === void 0 ? void 0 : _params$data[dataFieldName];
|
|
298
|
+
} : undefined;
|
|
275
299
|
|
|
276
300
|
// ① 只读纯文本
|
|
277
301
|
if (readOnly && formatter) {
|
|
278
|
-
return buf.concat(_objectSpread(_objectSpread({}, base),
|
|
302
|
+
return buf.concat(_objectSpread(_objectSpread(_objectSpread({}, base), valueGetter ? {
|
|
303
|
+
valueGetter: valueGetter
|
|
304
|
+
} : {}), {}, {
|
|
279
305
|
// 显式清掉可能从 safeColumnProps 漏带的 cellRenderer(AG-Grid 中 renderer 优先级高于 formatter)
|
|
280
306
|
cellRenderer: undefined,
|
|
281
307
|
valueFormatter: function valueFormatter(params) {
|
|
@@ -287,9 +313,11 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
|
|
|
287
313
|
}));
|
|
288
314
|
}
|
|
289
315
|
|
|
290
|
-
// ② 可编辑懒挂载
|
|
291
|
-
if (!readOnly && formatter && !hasReactions && !forceEager) {
|
|
292
|
-
return buf.concat(_objectSpread(_objectSpread({}, base),
|
|
316
|
+
// ② 可编辑懒挂载(排除单击直控的 Switch/Checkbox:须 eager 出真控件)
|
|
317
|
+
if (!readOnly && formatter && !hasReactions && !forceEager && !isInlineToggle) {
|
|
318
|
+
return buf.concat(_objectSpread(_objectSpread(_objectSpread({}, base), valueGetter ? {
|
|
319
|
+
valueGetter: valueGetter
|
|
320
|
+
} : {}), {}, {
|
|
293
321
|
cellRenderer: LazyAgField,
|
|
294
322
|
cellRendererParams: {
|
|
295
323
|
dataSource: dataSource,
|
|
@@ -326,4 +354,4 @@ var useAddition = function useAddition() {
|
|
|
326
354
|
return addition;
|
|
327
355
|
}, null);
|
|
328
356
|
};
|
|
329
|
-
export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition };
|
|
357
|
+
export { isColumnComponent, useArrayTableSources, useArrayTableActions, buildArrayTableColumns, useAddition, LazyAgField };
|
|
@@ -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
|
-
import _debounce from "lodash-es/debounce";
|
|
3
2
|
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; }
|
|
4
3
|
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); } }
|
|
5
4
|
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); }); }; }
|
|
@@ -33,6 +32,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
33
32
|
*/
|
|
34
33
|
|
|
35
34
|
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
35
|
+
import { debounce } from 'lodash-es';
|
|
36
36
|
import { parseRegex } from "../validation/parser";
|
|
37
37
|
import { validateRegex } from "../validation/validator";
|
|
38
38
|
import { analyzeComplexity } from "../validation/complexity";
|
|
@@ -187,7 +187,7 @@ export var useRegexValidation = function useRegexValidation(pattern) {
|
|
|
187
187
|
|
|
188
188
|
// 防抖验证函数
|
|
189
189
|
// 使用 useRef 保存防抖函数,避免在每次渲染时重新创建
|
|
190
|
-
var debouncedValidateRef = useRef(
|
|
190
|
+
var debouncedValidateRef = useRef(debounce(function (value) {
|
|
191
191
|
validate(value);
|
|
192
192
|
}, debounceMs));
|
|
193
193
|
|
|
@@ -140,6 +140,7 @@ export var useTemplateManager = function useTemplateManager() {
|
|
|
140
140
|
|
|
141
141
|
// 使用模板
|
|
142
142
|
var useTemplateCallback = useCallback(function (id) {
|
|
143
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- useTemplate 是纯函数(读/更新存储),非 React hook,误名 use* 前缀
|
|
143
144
|
var template = useTemplateUtil(id);
|
|
144
145
|
if (template) {
|
|
145
146
|
// 刷新模板列表以更新使用统计
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* @module RegexEditor/visualizer/astToRailroad
|
|
5
5
|
* @description 将 regexp-tree 的 AST 转换为 railroad-diagrams 格式
|
|
6
6
|
*/
|
|
7
|
-
/// <reference types="dist/esm/types/railroad-diagrams" />
|
|
8
7
|
/// <reference types="src/types/railroad-diagrams" />
|
|
9
8
|
import { Diagram, type DiagramNode } from 'railroad-diagrams';
|
|
10
9
|
import type { ASTNode } from '../validation/types';
|
|
@@ -1,8 +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
|
-
import _debounce from "lodash/debounce";
|
|
3
|
-
import _isArray from "lodash/isArray";
|
|
4
|
-
import _isEmpty from "lodash/isEmpty";
|
|
5
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
6
2
|
var _excluded = ["storageKey", "editMode", "widgets", "defaultLayout", "widgetWrapClassName", "widgetWrapStyle", "layout", "minHeight", "maxWidgetLength", "toolbar", "onLayoutChange", "onReset", "onReload", "onRemoveWidget", "onAddWidget", "onCancelEdit", "onEdit", "onRevert", "onSave"];
|
|
7
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); }
|
|
8
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
@@ -23,6 +19,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
23
19
|
import { CheckOutlined, CloseOutlined, DashboardOutlined, DeleteOutlined, PlusOutlined, ReloadOutlined, RetweetOutlined } from '@ant-design/icons';
|
|
24
20
|
import { Button, Empty, message, Spin, Tooltip } from 'antd';
|
|
25
21
|
import classnames from 'classnames';
|
|
22
|
+
import { cloneDeep, isEmpty, isArray, debounce } from 'lodash';
|
|
26
23
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState } from 'react';
|
|
27
24
|
import { Responsive, WidthProvider } from 'react-grid-layout';
|
|
28
25
|
import KeyEvent from 'react-keyevent';
|
|
@@ -85,7 +82,7 @@ var Dashboard = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
85
82
|
var dom = useRef(null);
|
|
86
83
|
|
|
87
84
|
//获取操作
|
|
88
|
-
var fetch = useCallback(
|
|
85
|
+
var fetch = useCallback(debounce( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
89
86
|
var response, _layout, resArr, data;
|
|
90
87
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
91
88
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -97,10 +94,10 @@ var Dashboard = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
97
94
|
});
|
|
98
95
|
case 3:
|
|
99
96
|
response = _context.sent;
|
|
100
|
-
_layout =
|
|
97
|
+
_layout = isArray(defaultLayout) ? defaultLayout : [];
|
|
101
98
|
if (response) {
|
|
102
99
|
resArr = JSON.parse(response).currentLayout;
|
|
103
|
-
if (!
|
|
100
|
+
if (!isEmpty(resArr)) {
|
|
104
101
|
_layout = resArr;
|
|
105
102
|
}
|
|
106
103
|
}
|
|
@@ -194,7 +191,7 @@ var Dashboard = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
194
191
|
}(), [storageKey, widgets]);
|
|
195
192
|
|
|
196
193
|
//改变布局触发
|
|
197
|
-
var onLayoutChange = useCallback(
|
|
194
|
+
var onLayoutChange = useCallback(debounce(function (layout, layouts, callback) {
|
|
198
195
|
window.dispatchEvent(new Event('resize'));
|
|
199
196
|
if (!stateEditMode) {
|
|
200
197
|
return;
|
|
@@ -234,7 +231,7 @@ var Dashboard = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
234
231
|
//删除小程序
|
|
235
232
|
var removeWidget = useCallback(function (widgetKey) {
|
|
236
233
|
var removedWidget;
|
|
237
|
-
var newLayout =
|
|
234
|
+
var newLayout = cloneDeep(dirtyCurrentLayout);
|
|
238
235
|
newLayout.map(function (item, index) {
|
|
239
236
|
if (item['i'] === widgetKey) {
|
|
240
237
|
removedWidget = item;
|
|
@@ -352,7 +349,7 @@ var Dashboard = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
352
349
|
|
|
353
350
|
//响应外部数据
|
|
354
351
|
useEffect(function () {
|
|
355
|
-
if (!
|
|
352
|
+
if (!isArray(customLayout)) {
|
|
356
353
|
return;
|
|
357
354
|
}
|
|
358
355
|
var data = calcMinAndMax(customLayout, widgets);
|
|
@@ -504,7 +501,7 @@ var Dashboard = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
504
501
|
size: "small",
|
|
505
502
|
onClick: revert,
|
|
506
503
|
icon: /*#__PURE__*/React.createElement(RetweetOutlined, null)
|
|
507
|
-
}, '恢复'), !
|
|
504
|
+
}, '恢复'), !isEmpty(finLayout) && /*#__PURE__*/React.createElement(Button, {
|
|
508
505
|
size: "small",
|
|
509
506
|
danger: true,
|
|
510
507
|
onClick: reset,
|
|
@@ -1,8 +1,9 @@
|
|
|
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
|
-
import _cloneDeep from "lodash/cloneDeep"; // import { updateApi as modifySmartChartConfig } from '@/pages/common/widgets/smartchart/service'
|
|
3
2
|
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; }
|
|
4
3
|
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); } }
|
|
5
4
|
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); }); }; }
|
|
5
|
+
// import { updateApi as modifySmartChartConfig } from '@/pages/common/widgets/smartchart/service'
|
|
6
|
+
import { cloneDeep } from 'lodash';
|
|
6
7
|
export var request = /*#__PURE__*/function () {
|
|
7
8
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, options) {
|
|
8
9
|
var method, _options$data, dataId, dataType, bigData, res;
|
|
@@ -52,7 +53,7 @@ export var copy = function copy(str) {
|
|
|
52
53
|
}, 1000);
|
|
53
54
|
};
|
|
54
55
|
export var formatLayout = function formatLayout(layout) {
|
|
55
|
-
var data =
|
|
56
|
+
var data = cloneDeep(layout);
|
|
56
57
|
data.forEach(function (item) {
|
|
57
58
|
delete item.minW;
|
|
58
59
|
delete item.maxW;
|
|
@@ -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
|
-
import _get from "lodash/get";
|
|
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; }
|
|
@@ -12,6 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
12
11
|
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; } }
|
|
13
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
13
|
import classnames from 'classnames';
|
|
14
|
+
import { get } from 'lodash';
|
|
15
15
|
import React, { useState } from 'react';
|
|
16
16
|
import "./index.less";
|
|
17
17
|
import { ConfigBar } from "./utils";
|
|
@@ -28,8 +28,8 @@ var Widget = function Widget(props) {
|
|
|
28
28
|
_useState2 = _slicedToArray(_useState, 2),
|
|
29
29
|
configShow = _useState2[0],
|
|
30
30
|
setConfigShow = _useState2[1];
|
|
31
|
-
var component =
|
|
32
|
-
var configComponent =
|
|
31
|
+
var component = get(widgets, widgetType + '.component');
|
|
32
|
+
var configComponent = get(widgets, widgetType + '.configComponent');
|
|
33
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
34
|
className: classnames(widgetWrapClassName, 'react-dashboard-widget'),
|
|
35
35
|
style: widgetWrapStyle
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _get from "lodash/get";
|
|
2
|
-
import _isEmpty from "lodash/isEmpty";
|
|
3
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
4
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -14,6 +11,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
14
11
|
import { AppstoreAddOutlined, PlusOutlined, SearchOutlined } from '@ant-design/icons';
|
|
15
12
|
import { Button, Drawer, Empty, Input } from 'antd';
|
|
16
13
|
import classnames from 'classnames';
|
|
14
|
+
import { cloneDeep, isEmpty, get } from 'lodash';
|
|
17
15
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
18
16
|
import "./index.less";
|
|
19
17
|
var Search = Input.Search;
|
|
@@ -89,7 +87,7 @@ var WidgetSelector = function WidgetSelector(props) {
|
|
|
89
87
|
handleCalcMenuData();
|
|
90
88
|
}, []);
|
|
91
89
|
var finWidgets = useMemo(function () {
|
|
92
|
-
var finData =
|
|
90
|
+
var finData = cloneDeep(widgets);
|
|
93
91
|
Object.keys(finData).map(function (key) {
|
|
94
92
|
//初始化数据
|
|
95
93
|
finData[key].length = 0;
|
|
@@ -174,7 +172,7 @@ var WidgetSelector = function WidgetSelector(props) {
|
|
|
174
172
|
height: '100%',
|
|
175
173
|
overflowY: 'auto'
|
|
176
174
|
}
|
|
177
|
-
}, !
|
|
175
|
+
}, !isEmpty(finWidgets) ? /*#__PURE__*/React.createElement("div", {
|
|
178
176
|
className: "react-dashboard-widget-waterfall",
|
|
179
177
|
style: {
|
|
180
178
|
columnCount: Math.ceil((width - 200) / 200)
|
|
@@ -195,8 +193,8 @@ var WidgetSelector = function WidgetSelector(props) {
|
|
|
195
193
|
}, /*#__PURE__*/React.createElement("div", {
|
|
196
194
|
className: 'react-dashboard-widget-iconWrap',
|
|
197
195
|
style: {
|
|
198
|
-
backgroundColor:
|
|
199
|
-
backgroundImage:
|
|
196
|
+
backgroundColor: get(widgets, key + '.iconBackground'),
|
|
197
|
+
backgroundImage: get(widgets, key + '.iconBackground')
|
|
200
198
|
}
|
|
201
199
|
}, item.icon), /*#__PURE__*/React.createElement("div", {
|
|
202
200
|
className: 'react-dashboard-widget-name'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _get from "lodash/get";
|
|
2
1
|
import { Drawer } from 'antd';
|
|
2
|
+
import { get } from 'lodash';
|
|
3
3
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
4
4
|
import { DeleteOutlined, SettingOutlined } from '@ant-design/icons';
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ export var ConfigBar = function ConfigBar(props) {
|
|
|
27
27
|
var widgetType = getWidgetType(widgetKey, widgets);
|
|
28
28
|
return /*#__PURE__*/React.createElement(React.Fragment, null, editMode && /*#__PURE__*/React.createElement("div", {
|
|
29
29
|
className: 'react-dashboard-mask'
|
|
30
|
-
}), editMode &&
|
|
30
|
+
}), editMode && get('widgets', widgetType + '.configComponent') && /*#__PURE__*/React.createElement("div", {
|
|
31
31
|
className: 'react-dashboard-configicon',
|
|
32
32
|
onClick: function onClick() {
|
|
33
33
|
return setConfigShow(true);
|
|
@@ -65,7 +65,7 @@ export var ConfigWrap = function ConfigWrap(props, widgets) {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
var widgetType = getWidgetType(widgetKey, widgets);
|
|
68
|
-
return
|
|
68
|
+
return get(widgets, widgetType + '.name') + '设置';
|
|
69
69
|
}, [widgetKey, widgets, getWidgetType]);
|
|
70
70
|
useEffect(function () {
|
|
71
71
|
afterVisibleChange(visible);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SelectProps } from 'antd/lib/select';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ColDef, ColGroupDef } from 'ag-grid-community';
|
|
4
|
+
import type { PagedApiAdapter } from '../adapters';
|
|
4
5
|
interface IDialogSelectProps extends SelectProps<any> {
|
|
5
6
|
hideBtn?: boolean;
|
|
6
7
|
request?: any;
|
|
@@ -10,6 +11,8 @@ interface IDialogSelectProps extends SelectProps<any> {
|
|
|
10
11
|
queryFun?: (item: any) => void;
|
|
11
12
|
onChangeItem?: (item: any) => void;
|
|
12
13
|
useAutoComplete?: boolean;
|
|
14
|
+
/** 分页 API 适配器(默认 ABP)。@author nokecy */
|
|
15
|
+
pagedApiAdapter?: PagedApiAdapter;
|
|
13
16
|
}
|
|
14
17
|
declare const DialogSelect: (props: IDialogSelectProps) => React.JSX.Element;
|
|
15
18
|
export { IDialogSelectProps };
|
|
@@ -24,6 +24,7 @@ import React, { useState } from 'react';
|
|
|
24
24
|
import { AgGridPlus } from "../ag-grid-plus";
|
|
25
25
|
import { useBoolean, useControllableValue } from 'ahooks';
|
|
26
26
|
import DraggableModal from "../draggableModal";
|
|
27
|
+
import { abpPagedApiAdapter } from "../adapters";
|
|
27
28
|
var DialogSelect = function DialogSelect(props) {
|
|
28
29
|
var request = props.request,
|
|
29
30
|
columnDefs = props.columnDefs,
|
|
@@ -148,27 +149,29 @@ var DialogSelect = function DialogSelect(props) {
|
|
|
148
149
|
},
|
|
149
150
|
request: ( /*#__PURE__*/function () {
|
|
150
151
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params, _, record) {
|
|
151
|
-
var
|
|
152
|
+
var _props$pagedApiAdapte;
|
|
153
|
+
var adapter, data, requestData;
|
|
152
154
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
153
155
|
while (1) switch (_context.prev = _context.next) {
|
|
154
156
|
case 0:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
adapter = (_props$pagedApiAdapte = props.pagedApiAdapter) !== null && _props$pagedApiAdapte !== void 0 ? _props$pagedApiAdapte : abpPagedApiAdapter;
|
|
158
|
+
_context.next = 3;
|
|
159
|
+
return request(adapter.toRequest({
|
|
160
|
+
filter: props !== null && props !== void 0 && props.queryFun ? props === null || props === void 0 ? void 0 : props.queryFun(params === null || params === void 0 ? void 0 : params.filter) : params === null || params === void 0 ? void 0 : params.filter,
|
|
161
|
+
sorter: params === null || params === void 0 ? void 0 : params.sorter,
|
|
162
|
+
skipCount: params === null || params === void 0 ? void 0 : params.skipCount,
|
|
163
|
+
maxResultCount: params === null || params === void 0 ? void 0 : params.maxResultCount
|
|
164
|
+
}), record);
|
|
165
|
+
case 3:
|
|
163
166
|
data = _context.sent;
|
|
164
167
|
requestData = {
|
|
165
168
|
success: true,
|
|
166
|
-
data: data
|
|
167
|
-
total: data
|
|
169
|
+
data: adapter.getItems(data),
|
|
170
|
+
total: adapter.getTotal(data)
|
|
168
171
|
};
|
|
169
|
-
setItems(data
|
|
172
|
+
setItems(adapter.getItems(data));
|
|
170
173
|
return _context.abrupt("return", requestData);
|
|
171
|
-
case
|
|
174
|
+
case 7:
|
|
172
175
|
case "end":
|
|
173
176
|
return _context.stop();
|
|
174
177
|
}
|
|
@@ -41,6 +41,8 @@ var ConfigurableToolbar = /*#__PURE__*/lazy(function () {
|
|
|
41
41
|
});
|
|
42
42
|
// 直接导入操作列组件,避免懒加载导致的渲染问题
|
|
43
43
|
import OptionsColumn from "./OptionsColumn";
|
|
44
|
+
import { toAbpPagedRequest } from "./_utils/toAbpPagedRequest";
|
|
45
|
+
import { abpPagedApiAdapter } from "../adapters";
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* 通用列表页面生成器组件
|
|
@@ -79,7 +81,8 @@ var GeneratedListPage = function GeneratedListPage(config) {
|
|
|
79
81
|
defaultPageSize: 20
|
|
80
82
|
} : _config$paginationCon,
|
|
81
83
|
externalGridRef = config.gridRef,
|
|
82
|
-
externalOnRefresh = config.onRefresh
|
|
84
|
+
externalOnRefresh = config.onRefresh,
|
|
85
|
+
pagedApiAdapter = config.pagedApiAdapter;
|
|
83
86
|
|
|
84
87
|
// 内部Grid引用
|
|
85
88
|
var internalGridRef = useRef();
|
|
@@ -253,7 +256,7 @@ var GeneratedListPage = function GeneratedListPage(config) {
|
|
|
253
256
|
_context2.next = 5;
|
|
254
257
|
return managedRequest(params, /*#__PURE__*/function () {
|
|
255
258
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestParams, signal) {
|
|
256
|
-
var treeData, flatData, filteredData, filterText, apiParams, data, items, _treeData, _flatData, _filteredData, _filterText;
|
|
259
|
+
var treeData, flatData, filteredData, filterText, pagedAdapter, apiParams, data, items, _treeData, _flatData, _filteredData, _filterText;
|
|
257
260
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
258
261
|
while (1) switch (_context.prev = _context.next) {
|
|
259
262
|
case 0:
|
|
@@ -282,25 +285,23 @@ var GeneratedListPage = function GeneratedListPage(config) {
|
|
|
282
285
|
});
|
|
283
286
|
case 8:
|
|
284
287
|
// 普通列表数据处理
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
};
|
|
295
|
-
_context.next = 11;
|
|
288
|
+
// 注入了适配器时走适配器的 toRequest;否则保持原有 toAbpPagedRequest(向后兼容)
|
|
289
|
+
pagedAdapter = pagedApiAdapter !== null && pagedApiAdapter !== void 0 ? pagedApiAdapter : abpPagedApiAdapter;
|
|
290
|
+
apiParams = pagedApiAdapter ? pagedAdapter.toRequest({
|
|
291
|
+
skipCount: requestParams === null || requestParams === void 0 ? void 0 : requestParams.skipCount,
|
|
292
|
+
maxResultCount: requestParams === null || requestParams === void 0 ? void 0 : requestParams.maxResultCount,
|
|
293
|
+
filter: requestParams === null || requestParams === void 0 ? void 0 : requestParams.filter,
|
|
294
|
+
sorter: requestParams === null || requestParams === void 0 ? void 0 : requestParams.sorter
|
|
295
|
+
}) : toAbpPagedRequest(requestParams, paginationConfig);
|
|
296
|
+
_context.next = 12;
|
|
296
297
|
return measureApiCall(function () {
|
|
297
298
|
return apiConfig.list(apiParams);
|
|
298
299
|
});
|
|
299
|
-
case
|
|
300
|
+
case 12:
|
|
300
301
|
data = _context.sent;
|
|
301
|
-
items = data
|
|
302
|
+
items = pagedAdapter.getItems(data); // 自动树形模式 - 从扁平数据构建树形结构
|
|
302
303
|
if (!(treeConfig !== null && treeConfig !== void 0 && treeConfig.enabled && treeConfig.autoMode)) {
|
|
303
|
-
_context.next =
|
|
304
|
+
_context.next = 20;
|
|
304
305
|
break;
|
|
305
306
|
}
|
|
306
307
|
_treeData = buildTreeFromFlat(items);
|
|
@@ -319,13 +320,13 @@ var GeneratedListPage = function GeneratedListPage(config) {
|
|
|
319
320
|
data: _filteredData,
|
|
320
321
|
total: _filteredData.length
|
|
321
322
|
});
|
|
322
|
-
case
|
|
323
|
+
case 20:
|
|
323
324
|
return _context.abrupt("return", {
|
|
324
325
|
success: true,
|
|
325
326
|
data: items,
|
|
326
|
-
total: data
|
|
327
|
+
total: pagedAdapter.getTotal(data)
|
|
327
328
|
});
|
|
328
|
-
case
|
|
329
|
+
case 21:
|
|
329
330
|
case "end":
|
|
330
331
|
return _context.stop();
|
|
331
332
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 列表请求参数 → ABP 分页契约映射(从 GeneratedListPage 内联逻辑抽出)。
|
|
3
|
+
* @author nokecy
|
|
4
|
+
*/
|
|
5
|
+
export interface ListRequestParams {
|
|
6
|
+
maxResultCount?: number;
|
|
7
|
+
skipCount?: number;
|
|
8
|
+
filter?: string;
|
|
9
|
+
sorter?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PaginationConfig {
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
defaultPageSize?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function toAbpPagedRequest(requestParams: ListRequestParams | undefined, paginationConfig: PaginationConfig): Record<string, unknown>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 列表请求参数 → ABP 分页契约映射(从 GeneratedListPage 内联逻辑抽出)。
|
|
3
|
+
* @author nokecy
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export function toAbpPagedRequest(requestParams, paginationConfig) {
|
|
7
|
+
if (paginationConfig.enabled) {
|
|
8
|
+
return {
|
|
9
|
+
PageSize: (requestParams === null || requestParams === void 0 ? void 0 : requestParams.maxResultCount) || paginationConfig.defaultPageSize,
|
|
10
|
+
Filter: requestParams === null || requestParams === void 0 ? void 0 : requestParams.filter,
|
|
11
|
+
MaxResultCount: (requestParams === null || requestParams === void 0 ? void 0 : requestParams.maxResultCount) || paginationConfig.defaultPageSize,
|
|
12
|
+
SkipCount: (requestParams === null || requestParams === void 0 ? void 0 : requestParams.skipCount) || 0,
|
|
13
|
+
Sorting: requestParams === null || requestParams === void 0 ? void 0 : requestParams.sorter
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
Filter: requestParams === null || requestParams === void 0 ? void 0 : requestParams.filter,
|
|
18
|
+
Sorting: requestParams === null || requestParams === void 0 ? void 0 : requestParams.sorter
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { GridRef } from "../ag-grid-plus/interface";
|
|
3
3
|
import { ColDef } from "ag-grid-community";
|
|
4
4
|
import { ButtonProps } from "antd";
|
|
5
|
+
import { PagedApiAdapter } from '../adapters';
|
|
5
6
|
/**
|
|
6
7
|
* 权限配置接口
|
|
7
8
|
*/
|
|
@@ -200,6 +201,8 @@ export interface GeneratedListPageConfig<T = any> {
|
|
|
200
201
|
gridRef?: React.RefObject<GridRef>;
|
|
201
202
|
/** 刷新回调 */
|
|
202
203
|
onRefresh?: () => void;
|
|
204
|
+
/** 分页 API 适配器(默认 ABP);非 ABP 后端可注入。@author nokecy */
|
|
205
|
+
pagedApiAdapter?: PagedApiAdapter;
|
|
203
206
|
}
|
|
204
207
|
/**
|
|
205
208
|
* 操作列组件属性接口
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -30,4 +30,5 @@ export type * from "./fullScreenAlert";
|
|
|
30
30
|
export type * from "./RuleBuilder";
|
|
31
31
|
export type { ColumnConfig } from "./array-table/columnHelper";
|
|
32
32
|
export type { CentralizedColumnScheme, QueryScheme, SchemeStorageAdapter, SchemeSyncDataDto, CurrentSchemeDto, SchemeStorageConfig, LocalStorageAdapterConfig, BackendApiAdapterConfig, UseSchemeManagerConfig, GridPlusContextValue, GlobalConfigPermissions, } from "./ag-grid-plus";
|
|
33
|
+
export * from './adapters';
|
|
33
34
|
export type { ParseResult as RegexParseResult, ValidationResult as RegexValidationResult, RegexError, ComplexityMetrics, ASTNode, AstRegExp, RegexTemplate, TestResult as RegexTestResult, CodeMirrorWrapperProps, RegexEditorProps, RegexFlags, MatchResult, RegexTesterProps, FlagsSelectorProps, MatchItemProps, RegexRailroadDiagramProps, } from "./components/RegexEditor";
|
package/dist/esm/index.js
CHANGED