@nokecy/qc-ui 1.1.67 → 1.1.69

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.
Files changed (32) hide show
  1. package/dist/cjs/ag-grid-plus/ag-gridPlus.js +1 -16
  2. package/dist/cjs/ag-grid-plus/setting/ColumnConfigForm.js +3 -1
  3. package/dist/cjs/ag-grid-plus/setting/ColumnConfigTable.js +7 -3
  4. package/dist/cjs/ag-grid-plus/setting/ColumnNameCellRenderer.js +9 -6
  5. package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +4 -2
  6. package/dist/cjs/ag-grid-plus/setting/MoveNodeModal.js +3 -1
  7. package/dist/cjs/ag-grid-plus/setting/NameColumnRenderer.js +6 -4
  8. package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +10 -8
  9. package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +6 -3
  10. package/dist/cjs/array-table/index.js +15 -1
  11. package/dist/cjs/array-table/indexColumn.d.ts +17 -0
  12. package/dist/cjs/array-table/indexColumn.js +58 -0
  13. package/dist/cjs/array-table/readOnlyFormatters.d.ts +8 -0
  14. package/dist/cjs/array-table/readOnlyFormatters.js +23 -1
  15. package/dist/cjs/array-table/utils.js +49 -12
  16. package/dist/esm/ag-grid-plus/ag-gridPlus.js +3 -18
  17. package/dist/esm/ag-grid-plus/setting/ColumnConfigForm.js +4 -2
  18. package/dist/esm/ag-grid-plus/setting/ColumnConfigTable.js +8 -4
  19. package/dist/esm/ag-grid-plus/setting/ColumnNameCellRenderer.js +10 -7
  20. package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +5 -3
  21. package/dist/esm/ag-grid-plus/setting/MoveNodeModal.js +4 -2
  22. package/dist/esm/ag-grid-plus/setting/NameColumnRenderer.js +7 -5
  23. package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +11 -9
  24. package/dist/esm/ag-grid-plus/utils/columnProcessors.js +6 -3
  25. package/dist/esm/array-table/index.js +15 -1
  26. package/dist/esm/array-table/indexColumn.d.ts +17 -0
  27. package/dist/esm/array-table/indexColumn.js +52 -0
  28. package/dist/esm/array-table/readOnlyFormatters.d.ts +8 -0
  29. package/dist/esm/array-table/readOnlyFormatters.js +22 -0
  30. package/dist/esm/array-table/utils.js +50 -13
  31. package/dist/umd/qc-ui.min.js +1 -1
  32. package/package.json +1 -1
@@ -9,20 +9,20 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
9
9
  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
10
  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
11
  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); }); }; }
12
+ 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
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
14
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
15
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
16
  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; }
16
17
  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; } }
17
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
- 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); }
19
19
  import React, { useReducer, useRef } from 'react';
20
20
  import { theme } from 'antd';
21
21
  import { useField, useFieldSchema, RecursionField, Observer, useExpressionScope } from '@formily/react';
22
22
  import { isArr, lazyMerge } from '@formily/shared';
23
23
  import { Schema } from '@formily/json-schema';
24
24
  import ArrayBase from "./arrayBase";
25
- import { getReadOnlyFormatter } from "./readOnlyFormatters";
25
+ import { fallbackFormatter, getReadOnlyFormatter } from "./readOnlyFormatters";
26
26
  import { markHeaderGroup } from "./columnGroup";
27
27
  import { CellFocusScope } from "./cellFocusScope";
28
28
  var isColumnComponent = function isColumnComponent(schema) {
@@ -159,6 +159,32 @@ var isSimpleFieldPath = function isSimpleFieldPath(name) {
159
159
  return !!name && /^[^.{}[\]*]+(\.[^.{}[\]*]+)*$/.test(name);
160
160
  };
161
161
 
162
+ /**
163
+ * 解析对象解构字段名 `{value:code,label:name}`(选择器 labelInValue 常用),返回 [对象键, 数据路径] 列表;
164
+ * 不是对象解构、或成员路径不是简单点号路径时返回 null(调用方回退 AgField 全树)。
165
+ * 成员可简写成 `{code}`,等同 `{code:code}`。@author nokecy
166
+ */
167
+ var parseObjectDestructure = function parseObjectDestructure(name) {
168
+ var matched = name && /^\{([^{}]+)\}$/.exec(name.trim());
169
+ if (!matched) return null;
170
+ var members = matched[1].split(',').map(function (part) {
171
+ return part.split(':').map(function (x) {
172
+ return x.trim();
173
+ });
174
+ });
175
+ if (members.some(function (m) {
176
+ return m.length > 2 || !m[0] || !isSimpleFieldPath(m[m.length - 1]);
177
+ })) return null;
178
+ return members.map(function (m) {
179
+ return [m[0], m[m.length - 1]];
180
+ });
181
+ };
182
+
183
+ /** 快路径(只读文本/懒挂载)能自己解析取值的字段名:简单点号路径或对象解构 @author nokecy */
184
+ var isFastPathFieldName = function isFastPathFieldName(name) {
185
+ return isSimpleFieldPath(name) || !!parseObjectDestructure(name);
186
+ };
187
+
162
188
  /**
163
189
  * 按 Formily 字段名从行数据取值。
164
190
  *
@@ -169,6 +195,14 @@ var isSimpleFieldPath = function isSimpleFieldPath(name) {
169
195
  */
170
196
  var readByFieldPath = function readByFieldPath(record, path) {
171
197
  if (record == null) return undefined;
198
+ // 对象解构:与 Formily 一致,按成员路径分别取值拼回 {value, label} 对象 @author nokecy
199
+ var destructure = path.startsWith('{') ? parseObjectDestructure(path) : null;
200
+ if (destructure) return Object.fromEntries(destructure.map(function (_ref3) {
201
+ var _ref4 = _slicedToArray(_ref3, 2),
202
+ key = _ref4[0],
203
+ memberPath = _ref4[1];
204
+ return [key, readByFieldPath(record, memberPath)];
205
+ }));
172
206
  if (path.indexOf('.') < 0) return record[path];
173
207
  return path.split('.').reduce(function (acc, key) {
174
208
  return acc == null ? undefined : acc[key];
@@ -328,7 +362,7 @@ var LazyAgField = function LazyAgField(params) {
328
362
 
329
363
  /** 焦点离开本格:校验通过才卸回懒挂载文本。isStale 为真说明校验期间焦点又回来了或格子已销毁 */
330
364
  var handleLeave = /*#__PURE__*/function () {
331
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(isStale) {
365
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(isStale) {
332
366
  var _field$value$indexOf3, _field$value3, _field$value3$indexOf, _field$form;
333
367
  var index, cellField;
334
368
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -372,7 +406,7 @@ var LazyAgField = function LazyAgField(params) {
372
406
  }, _callee, null, [[3, 8]]);
373
407
  }));
374
408
  return function handleLeave(_x) {
375
- return _ref3.apply(this, arguments);
409
+ return _ref5.apply(this, arguments);
376
410
  };
377
411
  }();
378
412
 
@@ -542,11 +576,12 @@ var applyNumberInputDefaults = function applyNumberInputDefaults(dataField) {
542
576
  // 重命名自 useArrayTableColumns:内部无任何 Hook 调用,use 前缀违反 Hook 命名约定且曾在 useMemo 内被调用 @author nokecy
543
577
  var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field, sources) {
544
578
  var arrayPattern = field === null || field === void 0 ? void 0 : field.pattern;
545
- return sources.reduce(function (buf, _ref4, key) {
546
- var name = _ref4.name,
547
- columnProps = _ref4.columnProps,
548
- schema = _ref4.schema,
549
- display = _ref4.display;
579
+ return sources.reduce(function (buf, _ref6, key) {
580
+ var _getReadOnlyFormatter;
581
+ var name = _ref6.name,
582
+ columnProps = _ref6.columnProps,
583
+ schema = _ref6.schema,
584
+ display = _ref6.display;
550
585
  if (display && display !== 'visible') return buf;
551
586
  if (!isColumnComponent(schema)) return buf;
552
587
 
@@ -585,8 +620,10 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
585
620
  // ③ 兜底全树:其余(无格式化器/带 reactions/forceAgField/复杂字段名/只读但无格式化器) -> AgField。
586
621
  var dataField = findDataFieldSchema(schema, name);
587
622
  var component = dataField === null || dataField === void 0 ? void 0 : dataField['x-component'];
588
- var formatter = getReadOnlyFormatter(component);
589
623
  var readOnly = isColumnReadOnlyEligible(arrayPattern, dataField, columnProps);
624
+ // 可编辑的数据字段(非 void 操作按钮)即使是业务自定义组件,也按兜底格式化器出懒挂载文本,默认阅读态;
625
+ // 只读列不兜底:自定义只读组件常显示别的字段(如 SiblingText),按自身值出文本会错。@author nokecy
626
+ var formatter = (_getReadOnlyFormatter = getReadOnlyFormatter(component)) !== null && _getReadOnlyFormatter !== void 0 ? _getReadOnlyFormatter : !readOnly && component && (dataField === null || dataField === void 0 ? void 0 : dataField.type) !== 'void' ? fallbackFormatter : null;
590
627
  var hasReactions = !!(dataField && dataField['x-reactions']);
591
628
  if (!readOnly) applyNumberInputDefaults(dataField);
592
629
  var forceEager = (columnProps === null || columnProps === void 0 ? void 0 : columnProps.forceAgField) === true;
@@ -603,9 +640,9 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
603
640
  var valueGetter = dataFieldName && dataFieldName !== name ? function (params) {
604
641
  return readByFieldPath(params === null || params === void 0 ? void 0 : params.data, dataFieldName);
605
642
  } : undefined;
606
- // 字段名是路径:`item.qty` 的值在 record.item.qty。快路径自己解析,只认点号分段;
607
- // 解构(`{value:a,label:b}`)/数组下标等复杂语法解析不了,回退全树交给 Formily。@author nokecy
608
- var canFastPath = !dataFieldName || isSimpleFieldPath(dataFieldName);
643
+ // 字段名是路径:`item.qty` 的值在 record.item.qty。快路径自己解析点号分段与对象解构(`{value:a,label:b}`);
644
+ // 数组解构/下标等其余语法解析不了,回退全树交给 Formily。@author nokecy
645
+ var canFastPath = !dataFieldName || isFastPathFieldName(dataFieldName);
609
646
 
610
647
  // ① 只读纯文本
611
648
  if (readOnly && formatter && canFastPath) {