es-grid-template 1.9.49 → 1.9.51

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 (30) hide show
  1. package/es/ali-table/Grid.js +14 -8
  2. package/es/ali-table/InternalTable.js +29 -0
  3. package/es/ali-table/base-table/styles.d.ts +5 -1
  4. package/es/ali-table/base-table/styles.js +13 -4
  5. package/es/ali-table/base-table/table.js +1 -1
  6. package/es/ali-table/utils/selected.js +0 -1
  7. package/es/group-component/hook/utils.d.ts +3 -3
  8. package/es/table-component/TableContainerEdit.js +12 -5
  9. package/es/table-component/body/EditableCell.d.ts +3 -0
  10. package/es/table-component/body/EditableCell.js +122 -36
  11. package/es/table-component/body/TableBodyCellEdit.js +70 -9
  12. package/es/table-component/hook/useColumns.js +2 -2
  13. package/es/table-component/hook/utils.d.ts +3 -0
  14. package/es/table-component/hook/utils.js +32 -1
  15. package/es/table-component/style.scss +6 -0
  16. package/lib/ali-table/Grid.js +14 -8
  17. package/lib/ali-table/InternalTable.js +29 -0
  18. package/lib/ali-table/base-table/styles.d.ts +5 -1
  19. package/lib/ali-table/base-table/styles.js +13 -4
  20. package/lib/ali-table/base-table/table.js +1 -1
  21. package/lib/ali-table/utils/selected.js +0 -1
  22. package/lib/table-component/TableContainerEdit.js +12 -5
  23. package/lib/table-component/body/EditableCell.d.ts +3 -0
  24. package/lib/table-component/body/EditableCell.js +122 -36
  25. package/lib/table-component/body/TableBodyCellEdit.js +69 -8
  26. package/lib/table-component/hook/useColumns.js +2 -2
  27. package/lib/table-component/hook/utils.d.ts +3 -0
  28. package/lib/table-component/hook/utils.js +37 -4
  29. package/lib/table-component/style.scss +6 -0
  30. package/package.json +1 -1
@@ -239,6 +239,7 @@ const TableBodyCellEdit = props => {
239
239
  format
240
240
  } = _react.default.useContext(_useContext.TableContext);
241
241
  const expandIconColumnIndex = expandable?.expandIconColumnIndex;
242
+ const visibleColumns = table.getVisibleLeafColumns();
242
243
  const record = cell.row.original;
243
244
  const columnMeta = cell.column.columnDef.meta ?? {};
244
245
  const [isOpenTooltip, setIsOpenTooltip] = _react.default.useState(false);
@@ -316,7 +317,9 @@ const TableBodyCellEdit = props => {
316
317
  }
317
318
  }, [cell, columnMeta, isOpenTooltip, record, valueCellString]);
318
319
  const triggerDragPaste = (pasteState, ctrlKey) => {
319
- const tmpCols = table.getVisibleLeafColumns();
320
+ const tmpCols = {
321
+ ...visibleColumns
322
+ };
320
323
  const rowPasteIds = (0, _utils.getRowIdsBetween)(table, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
321
324
  const colPasteds = (0, _utils.getColIdsBetween)(table, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
322
325
  const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
@@ -390,7 +393,9 @@ const TableBodyCellEdit = props => {
390
393
  setRangePasteState?.(undefined);
391
394
  };
392
395
  const triggerPointPaste = (pasteState, cellStart, cellEnd, ctrlKey) => {
393
- const tmpCols = table.getVisibleLeafColumns();
396
+ const tmpCols = {
397
+ ...visibleColumns
398
+ };
394
399
  const rowPasteIds = (0, _utils.getRowIdsBetween)(table, cellStart?.rowId ?? '', cellEnd?.rowId ?? '');
395
400
  const colPasteds = (0, _utils.getColIdsBetween)(table, cellStart?.colId ?? '', cellEnd?.colId ?? '');
396
401
  const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
@@ -591,7 +596,9 @@ const TableBodyCellEdit = props => {
591
596
  function handleKeyDown(e, rowId, colId) {
592
597
  if (e.key === 'Tab') {
593
598
  e.preventDefault();
594
- const allCols = table.getVisibleLeafColumns();
599
+ const allCols = {
600
+ ...visibleColumns
601
+ };
595
602
  const currentColIndex = table.getColumn(colId)?.getIndex() ?? 0;
596
603
  const nextCol = allCols[currentColIndex + 1];
597
604
  if (nextCol) {
@@ -655,7 +662,7 @@ const TableBodyCellEdit = props => {
655
662
  if (e.key === 'ArrowRight') {
656
663
  e.preventDefault();
657
664
  e.stopPropagation();
658
- const allCols = table.getVisibleLeafColumns().filter(it => !_hooks.nonActionColumn.includes(it.id));
665
+ const allCols = visibleColumns.filter(it => !_hooks.nonActionColumn.includes(it.id));
659
666
  const currentColIndex = allCols.findIndex(it => it.id === cell.column.id);
660
667
  const nextCol = allCols[currentColIndex + 1];
661
668
  if (nextCol) {
@@ -686,7 +693,7 @@ const TableBodyCellEdit = props => {
686
693
  }
687
694
  if (e.key === 'ArrowLeft') {
688
695
  e.preventDefault();
689
- const allCols = table.getVisibleLeafColumns().filter(it => !_hooks.nonActionColumn.includes(it.id));
696
+ const allCols = visibleColumns.filter(it => !_hooks.nonActionColumn.includes(it.id));
690
697
 
691
698
  // const currentColIndex = table.getColumn(colId)?.getIndex() ?? 0;
692
699
  const currentColIndex = allCols.findIndex(it => it.id === cell.column.id);
@@ -834,7 +841,7 @@ const TableBodyCellEdit = props => {
834
841
  }
835
842
  const handleMouseDownIndex = rowId => {
836
843
  setIsSelecting?.(true);
837
- const allColumns = table.getVisibleLeafColumns().filter(it => !_hooks.nonActionColumn.includes(it.id));
844
+ const allColumns = visibleColumns.filter(it => !_hooks.nonActionColumn.includes(it.id));
838
845
  const firstCOlSpin = (0, _utils.findFirst)(allColumns);
839
846
  const startCol = allColumns[0].id;
840
847
  const endCol = allColumns[allColumns.length - 1].id;
@@ -868,7 +875,7 @@ const TableBodyCellEdit = props => {
868
875
  };
869
876
  const handleMouseEnterIndex = rowId => {
870
877
  if (isSelecting) {
871
- const allColumns = table.getVisibleLeafColumns().filter(it => !_hooks.nonActionColumn.includes(it.id));
878
+ const allColumns = visibleColumns.filter(it => !_hooks.nonActionColumn.includes(it.id));
872
879
 
873
880
  // const firstCOl = findFirst(allColumns)
874
881
 
@@ -1118,6 +1125,58 @@ const TableBodyCellEdit = props => {
1118
1125
  }, 100);
1119
1126
  }
1120
1127
  };
1128
+ const handleNextCell = () => {
1129
+ const allCols = visibleColumns;
1130
+
1131
+ // const colId = cell.column.id
1132
+ const rowId = cell.row.id;
1133
+
1134
+ // const currentColIndex = table.getColumn(colId)?.getIndex() ?? 0;
1135
+ // const currentColIndex = indexCol;
1136
+
1137
+ const isNextCol = allCols[colIndex + 1];
1138
+ const nextCol = (0, _utils.getNextEditableColumn)(visibleColumns, colIndex, record);
1139
+ if (isNextCol && nextCol) {
1140
+ setFocusedCell?.({
1141
+ rowId,
1142
+ colId: nextCol.id
1143
+ });
1144
+ setStartCell?.({
1145
+ rowId,
1146
+ colId: nextCol.id
1147
+ });
1148
+ setEndCell?.({
1149
+ rowId,
1150
+ colId: nextCol.id
1151
+ });
1152
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
1153
+ rowId,
1154
+ colId: nextCol.id
1155
+ }, {
1156
+ rowId,
1157
+ colId: nextCol.id
1158
+ }));
1159
+ columnVirtualizer.scrollToIndex(nextCol.getIndex(), {
1160
+ align: 'center'
1161
+ });
1162
+ const nextItem = document.querySelector(`.ui-rc-grid-row .cell-editing[data-row-key="${rowId}"].cell-editing[data-col-key="${nextCol.id}"] input`);
1163
+
1164
+ // const input = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${startSelectedCells.current.row}"].cell-editing[data-col-index="${startSelectedCells.current.col}"] input`) as HTMLInputElement
1165
+ // const textarea = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowNumber}"].cell-editing[data-col-index="${startSelectedCells.current.col}"] textarea`) as any
1166
+
1167
+ const textarea = document.querySelector(`.ui-rc-grid-row .cell-editing[data-row-key="${rowId}"].cell-editing[data-col-key="${nextCol.id}"] textarea`);
1168
+ setTimeout(() => {
1169
+ if (textarea) {
1170
+ textarea.focus();
1171
+ textarea.setSelectionRange(textarea.value.length, textarea.value.length);
1172
+ return;
1173
+ }
1174
+ if (nextItem) {
1175
+ nextItem.focus();
1176
+ }
1177
+ });
1178
+ }
1179
+ };
1121
1180
  const cellValue = cell.getValue();
1122
1181
  const rowIndex = cell.row.index;
1123
1182
  const colFormat = typeof columnMeta?.format === 'function' ? columnMeta?.format(record) : columnMeta?.format;
@@ -1253,7 +1312,9 @@ const TableBodyCellEdit = props => {
1253
1312
  editType: (0, _utils.getEditType)(cell.column.columnDef.meta, record),
1254
1313
  indexCol: cell.column.getIndex(),
1255
1314
  indexRow: cell.row.index,
1256
- record: record
1315
+ record: record,
1316
+ visibleColumns: visibleColumns,
1317
+ handleNextCell: handleNextCell
1257
1318
  // rowKey={rowKey}
1258
1319
  }) : /*#__PURE__*/_react.default.createElement("div", {
1259
1320
  className: (0, _classnames.default)('ui-rc_cell-content', {
@@ -48,9 +48,9 @@ const renderValueCell = (column, value, record, rowIndex, colIndex, format, edit
48
48
  case 'date':
49
49
  return value ? (0, _dayjs.default)(value).format(format?.dateFormat ?? 'DD/MM/YYYY') : '';
50
50
  case 'time':
51
- const timeFormat = format?.timeFormat ?? 'HH:mm';
51
+ const timeFormat = format?.timeFormat;
52
52
  const abc = (0, _utils.convertToDate)(value, timeFormat);
53
- const timeValue = value ? (0, _dayjs.default)(abc).format(timeFormat) : '';
53
+ const timeValue = value ? (0, _dayjs.default)(abc).format(timeFormat ?? 'HH:mm') : '';
54
54
  return timeValue ?? '';
55
55
  case 'year':
56
56
  const year = value ? (0, _moment.default)(value).format('yyyy') : '';
@@ -81,6 +81,7 @@ export declare function sortData(data: any[], sorter: Sorter[]): any[];
81
81
  export declare function filterDataByColumns(data: any[], queries: FilterItem[] | undefined, sorter: Sorter[] | undefined, keysFilter: string[] | undefined, ignoreAccents?: boolean): any[];
82
82
  export declare const getAllRowKey: (data: any[]) => any[];
83
83
  export declare const isEditable: <RecordType>(column: ColumnTable, rowData: RecordType) => boolean | ((rowData: any) => boolean);
84
+ export declare const getNextEditableColumn: (columns: any[], currentIndex: number, rowData: any) => any;
84
85
  export declare const checkFieldKey: (key: string | undefined) => string;
85
86
  export declare const convertArrayWithIndent: (inputArray: any[], parentIndent?: number) => any[];
86
87
  export declare const convertLabelToTitle: (data: any[]) => any[];
@@ -167,3 +168,5 @@ export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType
167
168
  export declare function sumFields(columns: ColumnTable[], data: any[], childrenKey?: string): any;
168
169
  export declare function sumNumberFields(columns: ColumnTable[], data: any[], childrenKey?: string): any;
169
170
  export declare const getTreeDepth: (rows: any[]) => number;
171
+ export type FormatToken = 'YYYY' | 'MM' | 'DD' | 'HH' | 'mm' | 'ss';
172
+ export declare const isDateChanged: (oldDate: string | Date, newDate: string | Date, format: string) => FormatToken | null;
@@ -39,12 +39,12 @@ exports.getFormat = exports.getFixedFields = exports.getEditType = exports.getDi
39
39
  exports.getHiddenParentKeys = getHiddenParentKeys;
40
40
  exports.getHiddenParentKeys1 = getHiddenParentKeys1;
41
41
  exports.getInvisibleColumns = getInvisibleColumns;
42
- exports.getNewItemsOnly = exports.getLastSelectCell = void 0;
42
+ exports.getNextEditableColumn = exports.getNewItemsOnly = exports.getLastSelectCell = void 0;
43
43
  exports.getRowIdsBetween = getRowIdsBetween;
44
44
  exports.getVisibleColumnKeys1 = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTreeDepth = exports.getTableHeight = exports.getSelectedCellMatrix = void 0;
45
45
  exports.getVisibleFields = getVisibleFields;
46
46
  exports.groupArrayByColumns = groupArrayByColumns;
47
- exports.isColor = void 0;
47
+ exports.isDateChanged = exports.isColor = void 0;
48
48
  exports.isDateString = isDateString;
49
49
  exports.isEmpty = exports.isEditable = exports.isDisable = exports.isDateValue = void 0;
50
50
  exports.isEqualSet = isEqualSet;
@@ -260,6 +260,9 @@ function getDateValueType(value) {
260
260
  }
261
261
  const datetimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/;
262
262
  const timeRegex = /^\d{2}:\d{2}(:\d{2})?$/;
263
+
264
+ // const timeRegex = /^(?:[01]\d|2[0-3])\s*:\s*[0-5]\d(?:\s*:\s*[0-5]\d)?$/;
265
+
263
266
  if (datetimeRegex.test(value)) {
264
267
  return 'datetime';
265
268
  }
@@ -274,7 +277,7 @@ const convertToDate = (value, format) => {
274
277
  }
275
278
  const valueType = getDateValueType(value);
276
279
  if (valueType === 'time') {
277
- const date = (0, _dayjs.default)(value, format, true);
280
+ const date = (0, _dayjs.default)(value, format ?? ['HH:mm:ss', 'HH:mm'], true);
278
281
  return date.isValid() ? (0, _moment.default)(date.toDate()).format() : '';
279
282
  }
280
283
  if (valueType === 'datetime') {
@@ -1336,6 +1339,15 @@ const isEditable = (column, rowData) => {
1336
1339
  return column?.editEnable;
1337
1340
  };
1338
1341
  exports.isEditable = isEditable;
1342
+ const getNextEditableColumn = (columns, currentIndex, rowData) => {
1343
+ for (let i = currentIndex + 1; i < columns.length; i++) {
1344
+ if (isEditable(columns[i].columnDef.meta, rowData)) {
1345
+ return columns[i];
1346
+ }
1347
+ }
1348
+ return undefined;
1349
+ };
1350
+ exports.getNextEditableColumn = getNextEditableColumn;
1339
1351
  const checkFieldKey = key => {
1340
1352
  if (key) {
1341
1353
  return key;
@@ -2853,4 +2865,25 @@ const getTreeDepth = rows => {
2853
2865
  if (!rows?.length) return 0;
2854
2866
  return 1 + Math.max(0, ...rows.map(r => getTreeDepth(r.children)));
2855
2867
  };
2856
- exports.getTreeDepth = getTreeDepth;
2868
+ exports.getTreeDepth = getTreeDepth;
2869
+ const TOKEN_MAP = {
2870
+ YYYY: 'year',
2871
+ MM: 'month',
2872
+ DD: 'day',
2873
+ HH: 'hour',
2874
+ mm: 'minute',
2875
+ ss: 'second'
2876
+ };
2877
+ const isDateChanged = (oldDate, newDate, format) => {
2878
+ const prev = (0, _dayjs.default)(oldDate, format, true);
2879
+ const next = (0, _dayjs.default)(newDate, format, true);
2880
+ const tokens = ['YYYY', 'MM', 'DD', 'HH', 'mm', 'ss'];
2881
+ for (const token of tokens) {
2882
+ if (!format.includes(token)) continue;
2883
+ if (!prev.isSame(next, TOKEN_MAP[token])) {
2884
+ return token;
2885
+ }
2886
+ }
2887
+ return null;
2888
+ };
2889
+ exports.isDateChanged = isDateChanged;
@@ -1195,4 +1195,10 @@ $cell-index-focus-bg-Dark: #E6EFFD !default;
1195
1195
  .ui-rc-toolbar-bottom_border-bottom {
1196
1196
  border-bottom-color: $tableBorderColorDark;
1197
1197
  }
1198
+ }
1199
+
1200
+ .ui-rc-checkbox {
1201
+ &:has(input:focus) span {
1202
+ border-color: red;
1203
+ }
1198
1204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.9.49",
3
+ "version": "1.9.51",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",