vxe-table 4.23.17 → 4.23.18

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.
@@ -264,14 +264,6 @@ var grid_default = (
264
264
  return funcs;
265
265
  };
266
266
  const gridExtendTableMethods = extendTableMethods(tableComponentMethodKeys);
267
- tableComponentMethodKeys.forEach((name) => {
268
- gridExtendTableMethods[name] = (...args) => {
269
- const $xeTable = refTable.value;
270
- if ($xeTable && $xeTable[name]) {
271
- return $xeTable && $xeTable[name](...args);
272
- }
273
- };
274
- });
275
267
  const computeProxyOpts = computed(() => {
276
268
  return XEUtils.merge({}, XEUtils.clone(getConfig().grid.proxyConfig, true), props.proxyConfig);
277
269
  });
@@ -404,76 +404,26 @@ hooks.add("tableEditModule", {
404
404
  const { editRender } = column;
405
405
  const { isFocus, isPos, isClear } = options;
406
406
  const cell = params.cell || $xeTable.getCellElement(row, column);
407
- const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
407
+ const beforeEditFn = editOpts.beforeEditMethod || editOpts.activeMethod;
408
+ const beforeEditAsyncFn = editOpts.beforeEditAsyncMethod;
408
409
  const editParams = { ...params, cell };
409
- if (cell && isEnableConf(editConfig) && isEnableConf(editRender)) {
410
- if (!$xeTable.isPendingByRow(row) && !$xeTable.isAggregateRecord(row)) {
411
- if (actived.row !== row || (mode === "cell" ? actived.column !== column : false)) {
412
- let type = "edit-disabled";
413
- if (!beforeEditMethod || beforeEditMethod({ ...editParams, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt })) {
414
- if (hasEnableConf(mouseConfig, mouseOpts)) {
415
- $xeTable.clearSelected();
416
- if ($xeTable.clearCellAreas) {
417
- $xeTable.clearCellAreas();
418
- $xeTable.clearCopyCellArea();
419
- }
420
- }
421
- $xeTable.closeTooltip();
422
- if (actived.column) {
423
- handleClearEdit(evnt);
424
- }
425
- type = "edit-activated";
426
- column.renderHeight = cell.offsetHeight;
427
- actived.args = editParams;
428
- actived.row = row;
429
- actived.column = column;
430
- $xeTable.handlePushStack();
431
- if (isClear) {
432
- setCellValue(row, column, null);
433
- }
434
- if (mode === "row") {
435
- tableColumn.forEach((column2) => getEditColumnModel(row, column2));
436
- } else {
437
- getEditColumnModel(row, column);
438
- }
439
- const afterEditMethod = editOpts.afterEditMethod;
440
- nextTick(() => {
441
- if (isFocus) {
442
- $xeTable.handleFocus(editParams, evnt);
443
- }
444
- if (afterEditMethod) {
445
- afterEditMethod({ ...editParams, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
446
- }
447
- });
448
- }
449
- $xeTable.dispatchEvent(
450
- type,
451
- {
452
- row,
453
- rowIndex: $xeTable.getRowIndex(row),
454
- $rowIndex: $xeTable.getVMRowIndex(row),
455
- column,
456
- columnIndex: $xeTable.getColumnIndex(column),
457
- $columnIndex: $xeTable.getVMColumnIndex(column)
458
- },
459
- evnt
460
- );
461
- if (type === "edit-activated") {
462
- $xeTable.dispatchEvent(
463
- "edit-actived",
464
- {
465
- row,
466
- rowIndex: $xeTable.getRowIndex(row),
467
- $rowIndex: $xeTable.getVMRowIndex(row),
468
- column,
469
- columnIndex: $xeTable.getColumnIndex(column),
470
- $columnIndex: $xeTable.getVMColumnIndex(column)
471
- },
472
- evnt
473
- );
474
- }
475
- } else {
476
- const { column: oldColumn } = actived;
410
+ if (!cell || !isEnableConf(editConfig) || !isEnableConf(editRender)) {
411
+ return nextTick();
412
+ }
413
+ if ($xeTable.isPendingByRow(row) || $xeTable.isAggregateRecord(row)) {
414
+ return nextTick();
415
+ }
416
+ if (actived.row !== row || (mode === "cell" ? actived.column !== column : false)) {
417
+ const evntParams = {
418
+ row,
419
+ rowIndex: $xeTable.getRowIndex(row),
420
+ $rowIndex: $xeTable.getVMRowIndex(row),
421
+ column,
422
+ columnIndex: $xeTable.getColumnIndex(column),
423
+ $columnIndex: $xeTable.getVMColumnIndex(column)
424
+ };
425
+ const handleCellEdit = (status) => {
426
+ if (status) {
477
427
  if (hasEnableConf(mouseConfig, mouseOpts)) {
478
428
  $xeTable.clearSelected();
479
429
  if ($xeTable.clearCellAreas) {
@@ -481,29 +431,81 @@ hooks.add("tableEditModule", {
481
431
  $xeTable.clearCopyCellArea();
482
432
  }
483
433
  }
484
- if (oldColumn && oldColumn !== column) {
485
- const { model: oldModel } = oldColumn;
486
- if (oldModel.update) {
487
- setCellValue(row, oldColumn, oldModel.value);
488
- }
489
- if ($xeTable.clearValidate) {
490
- $xeTable.clearValidate(row, column);
491
- }
434
+ $xeTable.closeTooltip();
435
+ if (actived.column) {
436
+ handleClearEdit(evnt);
492
437
  }
493
438
  column.renderHeight = cell.offsetHeight;
494
439
  actived.args = editParams;
440
+ actived.row = row;
495
441
  actived.column = column;
496
- if (isPos) {
497
- setTimeout(() => {
498
- $xeTable.handleFocus(editParams, evnt);
499
- });
442
+ $xeTable.handlePushStack();
443
+ if (isClear) {
444
+ setCellValue(row, column, null);
500
445
  }
446
+ if (mode === "row") {
447
+ tableColumn.forEach((column2) => getEditColumnModel(row, column2));
448
+ } else {
449
+ getEditColumnModel(row, column);
450
+ }
451
+ const afterEditMethod = editOpts.afterEditMethod;
452
+ nextTick(() => {
453
+ if (isFocus) {
454
+ $xeTable.handleFocus(editParams, evnt);
455
+ }
456
+ if (afterEditMethod) {
457
+ afterEditMethod({ ...editParams, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt });
458
+ }
459
+ });
460
+ $xeTable.dispatchEvent("edit-activated", evntParams, evnt);
461
+ $xeTable.dispatchEvent("edit-actived", evntParams, evnt);
462
+ } else {
463
+ $xeTable.dispatchEvent("edit-disabled", evntParams, evnt);
501
464
  }
502
465
  focused.column = null;
503
466
  focused.row = null;
504
467
  $xeTable.focus();
468
+ };
469
+ const eFnParams = { ...editParams, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt };
470
+ if (beforeEditFn) {
471
+ handleCellEdit(!!beforeEditFn(eFnParams));
472
+ } else if (beforeEditAsyncFn) {
473
+ return Promise.resolve().then(() => beforeEditAsyncFn(eFnParams)).catch(() => false).then((status) => {
474
+ handleCellEdit(!!status);
475
+ });
476
+ } else {
477
+ handleCellEdit(true);
505
478
  }
479
+ return nextTick();
506
480
  }
481
+ const { column: oldColumn } = actived;
482
+ if (hasEnableConf(mouseConfig, mouseOpts)) {
483
+ $xeTable.clearSelected();
484
+ if ($xeTable.clearCellAreas) {
485
+ $xeTable.clearCellAreas();
486
+ $xeTable.clearCopyCellArea();
487
+ }
488
+ }
489
+ if (oldColumn && oldColumn !== column) {
490
+ const { model: oldModel } = oldColumn;
491
+ if (oldModel.update) {
492
+ setCellValue(row, oldColumn, oldModel.value);
493
+ }
494
+ if ($xeTable.clearValidate) {
495
+ $xeTable.clearValidate(row, column);
496
+ }
497
+ }
498
+ column.renderHeight = cell.offsetHeight;
499
+ actived.args = editParams;
500
+ actived.column = column;
501
+ if (isPos) {
502
+ setTimeout(() => {
503
+ $xeTable.handleFocus(editParams, evnt);
504
+ });
505
+ }
506
+ focused.column = null;
507
+ focused.row = null;
508
+ $xeTable.focus();
507
509
  return nextTick();
508
510
  };
509
511
  const handleEditCell = (row, fieldOrColumn, options) => {
@@ -8249,7 +8249,8 @@ var table_default = (
8249
8249
  const operArrow = isLeftArrow || isUpArrow || isRightArrow || isDwArrow;
8250
8250
  const operCtxMenu = isContentMenu && ctxMenuStore.visible && (isEnter || isSpacebar || operArrow);
8251
8251
  const isEditStatus = isEnableConf(editConfig) && actived.column && actived.row;
8252
- const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod;
8252
+ const beforeEditFn = editOpts.beforeEditMethod || editOpts.activeMethod;
8253
+ const beforeEditAsyncFn = editOpts.beforeEditAsyncMethod;
8253
8254
  const selectRow = selected.row;
8254
8255
  const selectColumn = selected.column;
8255
8256
  if (operCtxMenu) {
@@ -8477,7 +8478,7 @@ var table_default = (
8477
8478
  $grid: $xeGrid,
8478
8479
  $gantt: $xeGantt
8479
8480
  };
8480
- if (!beforeEditMethod || beforeEditMethod(params)) {
8481
+ const handleEdit = () => {
8481
8482
  if (delMethod) {
8482
8483
  delMethod(params);
8483
8484
  } else {
@@ -8489,6 +8490,20 @@ var table_default = (
8489
8490
  }
8490
8491
  $xeTable.updateFooter();
8491
8492
  dispatchEvent("cell-delete-value", params, evnt);
8493
+ };
8494
+ if (beforeEditFn) {
8495
+ if (beforeEditFn(params)) {
8496
+ handleEdit();
8497
+ }
8498
+ } else if (beforeEditAsyncFn) {
8499
+ Promise.resolve(beforeEditAsyncFn(params)).then((status) => {
8500
+ if (status) {
8501
+ handleEdit();
8502
+ }
8503
+ }).catch(() => {
8504
+ });
8505
+ } else {
8506
+ handleEdit();
8492
8507
  }
8493
8508
  }
8494
8509
  } else if (hasBackspaceKey && hasEnableConf(keyboardConfig, keyboardOpts) && keyboardOpts.isBack && isEnableConf(editConfig) && (selectRow || selectColumn)) {
@@ -8508,7 +8523,7 @@ var table_default = (
8508
8523
  $grid: $xeGrid,
8509
8524
  $gantt: $xeGantt
8510
8525
  };
8511
- if (!beforeEditMethod || beforeEditMethod(params)) {
8526
+ const handleEdit = () => {
8512
8527
  if (backMethod) {
8513
8528
  backMethod(params);
8514
8529
  } else {
@@ -8517,6 +8532,20 @@ var table_default = (
8517
8532
  });
8518
8533
  }
8519
8534
  dispatchEvent("cell-backspace-value", params, evnt);
8535
+ };
8536
+ if (beforeEditFn) {
8537
+ if (beforeEditFn(params)) {
8538
+ handleEdit();
8539
+ }
8540
+ } else if (beforeEditAsyncFn) {
8541
+ Promise.resolve(beforeEditAsyncFn(params)).then((status) => {
8542
+ if (status) {
8543
+ handleEdit();
8544
+ }
8545
+ }).catch(() => {
8546
+ });
8547
+ } else {
8548
+ handleEdit();
8520
8549
  }
8521
8550
  }
8522
8551
  }
@@ -8547,7 +8576,6 @@ var table_default = (
8547
8576
  } else if (hasEnableConf(keyboardConfig, keyboardOpts) && isEnableConf(editConfig) && keyboardOpts.isEdit && !isControlKey && (isSpacebar || isProcess || evnt.key === "Process" || keyCode >= 48 && keyCode <= 57 || keyCode >= 65 && keyCode <= 90 || keyCode >= 96 && keyCode <= 111 || keyCode >= 186 && keyCode <= 192 || keyCode >= 219 && keyCode <= 222)) {
8548
8577
  const { editMode, editMethod } = keyboardOpts;
8549
8578
  if (selectColumn && selectRow && isEnableConf(selectColumn.editRender)) {
8550
- const beforeEditMethod2 = editOpts.beforeEditMethod || editOpts.activeMethod;
8551
8579
  const params = {
8552
8580
  row: selectRow,
8553
8581
  rowIndex: $xeTable.getRowIndex(selectRow),
@@ -8561,7 +8589,7 @@ var table_default = (
8561
8589
  $grid: $xeGrid,
8562
8590
  $gantt: $xeGantt
8563
8591
  };
8564
- if (!beforeEditMethod2 || beforeEditMethod2(params)) {
8592
+ const handleEdit = () => {
8565
8593
  if (editMethod) {
8566
8594
  editMethod(params);
8567
8595
  } else {
@@ -8573,6 +8601,20 @@ var table_default = (
8573
8601
  isClear: isClearValue
8574
8602
  });
8575
8603
  }
8604
+ };
8605
+ if (beforeEditFn) {
8606
+ if (beforeEditFn(params)) {
8607
+ handleEdit();
8608
+ }
8609
+ } else if (beforeEditAsyncFn) {
8610
+ Promise.resolve(beforeEditAsyncFn(params)).then((status) => {
8611
+ if (status) {
8612
+ handleEdit();
8613
+ }
8614
+ }).catch(() => {
8615
+ });
8616
+ } else {
8617
+ handleEdit();
8576
8618
  }
8577
8619
  }
8578
8620
  }
@@ -14338,6 +14380,7 @@ var table_default = (
14338
14380
  const mouseOpts = computeMouseOpts.value;
14339
14381
  const exportOpts = computeExportOpts.value;
14340
14382
  const importOpts = computeImportOpts.value;
14383
+ const keyboardOpts = computeKeyboardOpts.value;
14341
14384
  const rowDragOpts = computeRowDragOpts.value;
14342
14385
  const areaOpts = computeAreaOpts.value;
14343
14386
  const sortOpts = computeSortOpts.value;
@@ -14496,8 +14539,16 @@ var table_default = (
14496
14539
  if (mouseOpts.area && props.treeConfig && !treeOpts.transform) {
14497
14540
  errLog("vxe.error.notSupportProp", ["mouse-config.area", "tree-config.transform=false", "tree-config.transform=true"]);
14498
14541
  }
14499
- if (props.editConfig && editOpts.activeMethod) {
14500
- warnLog("vxe.error.delProp", ["edit-config.activeMethod", "edit-config.beforeEditMethod"]);
14542
+ if (props.editConfig) {
14543
+ if (editOpts.activeMethod) {
14544
+ warnLog("vxe.error.delProp", ["edit-config.activeMethod", "edit-config.beforeEditMethod"]);
14545
+ }
14546
+ if (editOpts.beforeEditMethod && editOpts.beforeEditAsyncMethod) {
14547
+ errLog("vxe.error.errConflicts", ["edit-config.beforeEditMethod", "edit-config.beforeEditAsyncMethod"]);
14548
+ }
14549
+ if (keyboardOpts.isEdit && editOpts.beforeEditAsyncMethod) {
14550
+ warnLog("vxe.error.errConflicts", ["keyboard-config.isEdit", "edit-config.beforeEditAsyncMethod"]);
14551
+ }
14501
14552
  }
14502
14553
  if (checkboxOpts.halfField) {
14503
14554
  warnLog("vxe.error.delProp", ["checkbox-config.halfField", "checkbox-config.indeterminateField"]);
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from "@vxe-ui/core";
2
2
  import { getFuncText } from "./src/utils";
3
- const version = "4.23.17";
3
+ const version = "4.23.18";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
package/es/ui/src/log.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from "@vxe-ui/core";
2
2
  const { log } = VxeUI;
3
- const tableVersion = `table v${"4.23.17"}`;
3
+ const tableVersion = `table v${"4.23.18"}`;
4
4
  function createComponentLog(name) {
5
5
  const uiVersion = VxeUI.uiVersion ? `ui v${VxeUI.uiVersion}` : "";
6
6
  const ganttVersion = VxeUI.ganttVersion ? `gantt v${VxeUI.ganttVersion}` : "";
@@ -297,14 +297,6 @@ var grid_default = (
297
297
  return funcs;
298
298
  };
299
299
  const gridExtendTableMethods = extendTableMethods(tableComponentMethodKeys);
300
- tableComponentMethodKeys.forEach((name) => {
301
- gridExtendTableMethods[name] = (...args) => {
302
- const $xeTable = refTable.value;
303
- if ($xeTable && $xeTable[name]) {
304
- return $xeTable && $xeTable[name](...args);
305
- }
306
- };
307
- });
308
300
  const computeProxyOpts = (0, import_vue.computed)(() => {
309
301
  return import_xe_utils.default.merge({}, import_xe_utils.default.clone(getConfig().grid.proxyConfig, true), props.proxyConfig);
310
302
  });