@nokecy/qc-ui 1.0.87 → 1.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,11 @@
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
+ var _excluded = ["activate"];
2
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
4
  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."); }
4
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
8
+ 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; }
6
9
  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; }
7
10
  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; }
8
11
  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; }
@@ -331,7 +334,7 @@ export function useColumnSchemes(config) {
331
334
  */
332
335
  var createScheme = useCallback( /*#__PURE__*/function () {
333
336
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(name, columnConfig, options) {
334
- var nameValidation, uniqueName, newScheme, updatedSchemes;
337
+ var nameValidation, uniqueName, _ref6, activate, schemeOptions, newScheme, updatedSchemes;
335
338
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
336
339
  while (1) switch (_context5.prev = _context5.next) {
337
340
  case 0:
@@ -350,14 +353,15 @@ export function useColumnSchemes(config) {
350
353
  throw new Error("\u65B9\u6848\u6570\u91CF\u5DF2\u8FBE\u4E0A\u9650\uFF08".concat(MAX_SCHEMES_PER_GRID, "\u4E2A\uFF09\uFF0C\u8BF7\u5220\u9664\u4E00\u4E9B\u65B9\u6848\u540E\u518D\u8BD5"));
351
354
  case 5:
352
355
  // 处理重名情况
353
- uniqueName = checkDuplicateName(name, schemes) ? generateUniqueName(name, schemes) : name;
356
+ uniqueName = checkDuplicateName(name, schemes) ? generateUniqueName(name, schemes) : name; // 提取 activate 选项
357
+ _ref6 = options || {}, activate = _ref6.activate, schemeOptions = _objectWithoutProperties(_ref6, _excluded);
354
358
  newScheme = _objectSpread({
355
359
  id: uuidv4(),
356
360
  name: uniqueName,
357
361
  createdAt: Date.now(),
358
362
  updatedAt: Date.now(),
359
363
  columnConfig: columnConfig
360
- }, options); // 如果设置为默认方案,取消其他方案的默认标记
364
+ }, schemeOptions); // 如果设置为默认方案,取消其他方案的默认标记
361
365
  updatedSchemes = schemes;
362
366
  if (newScheme.isDefault) {
363
367
  updatedSchemes = schemes.map(function (s) {
@@ -367,27 +371,52 @@ export function useColumnSchemes(config) {
367
371
  });
368
372
  }
369
373
  updatedSchemes = [].concat(_toConsumableArray(updatedSchemes), [newScheme]);
370
- _context5.next = 12;
374
+ _context5.next = 13;
371
375
  return saveSchemesToStorage(updatedSchemes);
372
- case 12:
376
+ case 13:
377
+ if (!activate) {
378
+ _context5.next = 26;
379
+ break;
380
+ }
381
+ setCurrentScheme(newScheme);
382
+ setIsDirty(false);
383
+
384
+ // 保存当前方案ID
385
+ if (!storageAdapter.saveCurrentSchemeId) {
386
+ _context5.next = 25;
387
+ break;
388
+ }
389
+ _context5.prev = 17;
390
+ _context5.next = 20;
391
+ return storageAdapter.saveCurrentSchemeId(gridId, newScheme.id);
392
+ case 20:
393
+ _context5.next = 25;
394
+ break;
395
+ case 22:
396
+ _context5.prev = 22;
397
+ _context5.t0 = _context5["catch"](17);
398
+ console.error('[useColumnSchemes] 保存当前方案ID失败:', _context5.t0);
399
+ case 25:
400
+ onSchemeChange === null || onSchemeChange === void 0 || onSchemeChange(newScheme);
401
+ case 26:
373
402
  onSchemeSave === null || onSchemeSave === void 0 || onSchemeSave(newScheme);
374
403
  return _context5.abrupt("return", newScheme);
375
- case 14:
404
+ case 28:
376
405
  case "end":
377
406
  return _context5.stop();
378
407
  }
379
- }, _callee5);
408
+ }, _callee5, null, [[17, 22]]);
380
409
  }));
381
410
  return function (_x4, _x5, _x6) {
382
411
  return _ref5.apply(this, arguments);
383
412
  };
384
- }(), [schemes, saveSchemesToStorage, onSchemeSave]);
413
+ }(), [schemes, gridId, storageAdapter, saveSchemesToStorage, onSchemeChange, onSchemeSave]);
385
414
 
386
415
  /**
387
416
  * 更新方案信息(不影响 columnState)
388
417
  */
389
418
  var updateScheme = useCallback( /*#__PURE__*/function () {
390
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(schemeId, updates) {
419
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(schemeId, updates) {
391
420
  var scheme, nameValidation, updatedScheme, updatedSchemes;
392
421
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
393
422
  while (1) switch (_context6.prev = _context6.next) {
@@ -451,7 +480,7 @@ export function useColumnSchemes(config) {
451
480
  }, _callee6);
452
481
  }));
453
482
  return function (_x7, _x8) {
454
- return _ref6.apply(this, arguments);
483
+ return _ref7.apply(this, arguments);
455
484
  };
456
485
  }(), [schemes, currentScheme, saveSchemesToStorage]);
457
486
 
@@ -459,7 +488,7 @@ export function useColumnSchemes(config) {
459
488
  * 删除方案
460
489
  */
461
490
  var deleteScheme = useCallback( /*#__PURE__*/function () {
462
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(schemeId) {
491
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(schemeId) {
463
492
  var scheme, updatedSchemes;
464
493
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
465
494
  while (1) switch (_context7.prev = _context7.next) {
@@ -518,7 +547,7 @@ export function useColumnSchemes(config) {
518
547
  }, _callee7, null, [[12, 17]]);
519
548
  }));
520
549
  return function (_x9) {
521
- return _ref7.apply(this, arguments);
550
+ return _ref8.apply(this, arguments);
522
551
  };
523
552
  }(), [schemes, currentScheme, gridId, storageAdapter, saveSchemesToStorage, onSchemeChange, onSchemeDelete]);
524
553
 
@@ -537,7 +566,7 @@ export function useColumnSchemes(config) {
537
566
  * 设置默认方案
538
567
  */
539
568
  var setDefaultScheme = useCallback( /*#__PURE__*/function () {
540
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(schemeId) {
569
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(schemeId) {
541
570
  var updatedSchemes;
542
571
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
543
572
  while (1) switch (_context8.prev = _context8.next) {
@@ -556,7 +585,7 @@ export function useColumnSchemes(config) {
556
585
  }, _callee8);
557
586
  }));
558
587
  return function (_x10) {
559
- return _ref8.apply(this, arguments);
588
+ return _ref9.apply(this, arguments);
560
589
  };
561
590
  }(), [schemes, saveSchemesToStorage]);
562
591
 
@@ -109,7 +109,9 @@ export interface UseColumnSchemesReturn {
109
109
  /** 保存当前方案(更新现有方案) */
110
110
  saveScheme: (updates?: Partial<ColumnScheme>) => Promise<void>;
111
111
  /** 创建新方案 */
112
- createScheme: (name: string, columnConfig: FlatColumnItem[], options?: Partial<ColumnScheme>) => Promise<ColumnScheme>;
112
+ createScheme: (name: string, columnConfig: FlatColumnItem[], options?: Partial<ColumnScheme> & {
113
+ activate?: boolean;
114
+ }) => Promise<ColumnScheme>;
113
115
  /** 更新方案信息(不影响 columnConfig) */
114
116
  updateScheme: (schemeId: string, updates: Partial<Omit<ColumnScheme, 'id' | 'columnConfig'>>) => Promise<void>;
115
117
  /** 删除方案 */
@@ -245,7 +245,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
245
245
  while (1) switch (_context.prev = _context.next) {
246
246
  case 0:
247
247
  if (!(schemeManager && gridKey)) {
248
- _context.next = 29;
248
+ _context.next = 27;
249
249
  break;
250
250
  }
251
251
  _context.prev = 1;
@@ -278,7 +278,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
278
278
  filterModel: filterModel
279
279
  });
280
280
  case 8:
281
- _context.next = 24;
281
+ _context.next = 22;
282
282
  break;
283
283
  case 10:
284
284
  // 如果没有激活的方案,查找或创建"默认配置"方案
@@ -299,7 +299,7 @@ var ColumnSetting = function ColumnSetting(_ref) {
299
299
  filterModel: filterModel
300
300
  });
301
301
  case 16:
302
- _context.next = 24;
302
+ _context.next = 22;
303
303
  break;
304
304
  case 18:
305
305
  _context.next = 20;
@@ -308,33 +308,29 @@ var ColumnSetting = function ColumnSetting(_ref) {
308
308
  {
309
309
  isDefault: true,
310
310
  description: '自动保存的默认列配置',
311
- filterModel: filterModel
311
+ filterModel: filterModel,
312
+ activate: true // 立即激活该方案
312
313
  });
313
314
  case 20:
314
315
  newScheme = _context.sent;
315
- console.log('[ColumnSetting] 创建默认方案成功,准备应用:', {
316
+ console.log('[ColumnSetting] 创建默认方案成功并已激活:', {
316
317
  schemeId: newScheme.id,
317
318
  schemeName: newScheme.name,
318
319
  hasColumnConfig: !!newScheme.columnConfig,
319
320
  columnConfigLength: ((_newScheme$columnConf = newScheme.columnConfig) === null || _newScheme$columnConf === void 0 ? void 0 : _newScheme$columnConf.length) || 0
320
321
  });
321
-
322
- // 【修复】直接加载方案,确保立即应用
323
- // loadScheme 会设置 currentScheme 并触发 onSchemeChange
324
- _context.next = 24;
325
- return schemeManager.loadScheme(newScheme.id);
326
- case 24:
327
- _context.next = 29;
322
+ case 22:
323
+ _context.next = 27;
328
324
  break;
329
- case 26:
330
- _context.prev = 26;
325
+ case 24:
326
+ _context.prev = 24;
331
327
  _context.t0 = _context["catch"](1);
332
328
  console.error('[ColumnSetting] 保存列配置到方案失败:', _context.t0);
333
- case 29:
329
+ case 27:
334
330
  case "end":
335
331
  return _context.stop();
336
332
  }
337
- }, _callee, null, [[1, 26]]);
333
+ }, _callee, null, [[1, 24]]);
338
334
  })), 50);
339
335
 
340
336
  // 保存成功后清除备份
@@ -173,7 +173,7 @@ export declare const createSelectField: (title: string, options: {
173
173
  export declare const createCascaderField: (title: string, options: any[], config?: {
174
174
  required?: boolean | undefined;
175
175
  changeOnSelect?: boolean | undefined;
176
- expandTrigger?: "click" | "hover" | undefined;
176
+ expandTrigger?: "hover" | "click" | undefined;
177
177
  placeholder?: string | undefined;
178
178
  }) => {
179
179
  type: string;
@@ -187,7 +187,7 @@ export declare const createCascaderField: (title: string, options: any[], config
187
187
  };
188
188
  options: any[];
189
189
  changeOnSelect: boolean;
190
- expandTrigger: "click" | "hover";
190
+ expandTrigger: "hover" | "click";
191
191
  };
192
192
  };
193
193
  export default withStandardForm;