@coreui/data-grid 0.2.0-rc.0 → 0.3.0-rc.0

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 (82) hide show
  1. package/README.md +4 -2
  2. package/dist/css/data-grid.css +11 -11
  3. package/dist/css/data-grid.css.map +1 -1
  4. package/dist/css/data-grid.min.css +2 -2
  5. package/dist/css/data-grid.min.css.map +1 -1
  6. package/dist/css/data-grid.standalone.css +1066 -0
  7. package/dist/css/data-grid.standalone.css.map +1 -0
  8. package/dist/css/data-grid.standalone.min.css +5 -0
  9. package/dist/css/data-grid.standalone.min.css.map +1 -0
  10. package/dist/js/clipboard.cjs +1 -1
  11. package/dist/js/clipboard.mjs +1 -1
  12. package/dist/js/csv.cjs +2 -2
  13. package/dist/js/csv.mjs +2 -2
  14. package/dist/js/data-grid.esm.js +45 -14
  15. package/dist/js/data-grid.esm.js.map +1 -1
  16. package/dist/js/data-grid.esm.min.js +2 -2
  17. package/dist/js/data-grid.esm.min.js.map +1 -1
  18. package/dist/js/data-grid.js +45 -14
  19. package/dist/js/data-grid.js.map +1 -1
  20. package/dist/js/data-grid.lite.esm.js +45 -14
  21. package/dist/js/data-grid.lite.esm.js.map +1 -1
  22. package/dist/js/data-grid.lite.esm.min.js +2 -2
  23. package/dist/js/data-grid.lite.esm.min.js.map +1 -1
  24. package/dist/js/data-grid.lite.js +45 -14
  25. package/dist/js/data-grid.lite.js.map +1 -1
  26. package/dist/js/data-grid.lite.min.js +2 -2
  27. package/dist/js/data-grid.lite.min.js.map +1 -1
  28. package/dist/js/data-grid.lite.mjs +45 -14
  29. package/dist/js/data-grid.lite.mjs.map +1 -1
  30. package/dist/js/data-grid.min.js +2 -2
  31. package/dist/js/data-grid.min.js.map +1 -1
  32. package/dist/js/data-grid.mjs +45 -14
  33. package/dist/js/data-grid.mjs.map +1 -1
  34. package/dist/js/direction.cjs +26 -0
  35. package/dist/js/direction.cjs.map +1 -0
  36. package/dist/js/direction.mjs +24 -0
  37. package/dist/js/direction.mjs.map +1 -0
  38. package/dist/js/drag.cjs +15 -7
  39. package/dist/js/drag.cjs.map +1 -1
  40. package/dist/js/drag.mjs +15 -7
  41. package/dist/js/drag.mjs.map +1 -1
  42. package/dist/js/{export-table-CNAKStzj.mjs → export-table-BdabEbJG.mjs} +2 -2
  43. package/dist/js/{export-table-CNAKStzj.mjs.map → export-table-BdabEbJG.mjs.map} +1 -1
  44. package/dist/js/{export-table-doIwvE5U.cjs → export-table-D762wrZ1.cjs} +2 -2
  45. package/dist/js/{export-table-doIwvE5U.cjs.map → export-table-D762wrZ1.cjs.map} +1 -1
  46. package/dist/js/filters.cjs +1 -1
  47. package/dist/js/filters.mjs +1 -1
  48. package/dist/js/labels.cjs +1 -1
  49. package/dist/js/labels.mjs +1 -1
  50. package/dist/js/print.cjs +1 -1
  51. package/dist/js/print.mjs +1 -1
  52. package/dist/js/validate.cjs +1 -1
  53. package/dist/js/validate.mjs +1 -1
  54. package/dist/js/xlsx.cjs +2 -2
  55. package/dist/js/xlsx.mjs +2 -2
  56. package/dist/types/engine/active-cell.d.ts +1 -0
  57. package/dist/types/engine/table.d.ts +1 -1
  58. package/dist/types/util/direction.d.mts +1 -0
  59. package/dist/types/util/direction.d.ts +17 -0
  60. package/package.json +14 -1
  61. package/scss/_base.scss +13 -0
  62. package/scss/_config.scss +14 -0
  63. package/scss/_functions.scss +1 -0
  64. package/scss/_mixins.scss +1 -0
  65. package/scss/base/_buttons.scss +113 -0
  66. package/scss/base/_forms.scss +157 -0
  67. package/scss/base/_helpers.scss +24 -0
  68. package/scss/base/_pagination.scss +100 -0
  69. package/scss/base/_reboot.scss +93 -0
  70. package/scss/base/_root.scss +85 -0
  71. package/scss/base/_spinner.scss +45 -0
  72. package/scss/base/_table.scss +78 -0
  73. package/scss/components/_data-grid.scss +807 -0
  74. package/scss/data-grid.scss +7 -743
  75. package/scss/data-grid.standalone.scss +16 -0
  76. package/scss/functions/_defaults.scss +25 -0
  77. package/scss/mixins/_tokens.scss +12 -0
  78. package/src/data-grid.ts +18 -3
  79. package/src/engine/active-cell.ts +10 -3
  80. package/src/engine/table.ts +9 -1
  81. package/src/util/direction.ts +37 -0
  82. package/src/util/drag.ts +40 -6
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * CoreUI PRO data-grid v0.2.0-rc.0 (https://coreui.io)
2
+ * CoreUI PRO data-grid v0.3.0-rc.0 (https://coreui.io)
3
3
  * Copyright 2026 The CoreUI Team (https://github.com/orgs/coreui/people)
4
4
  * License (https://coreui.io/pro/license/)
5
5
  * Bundles @tanstack/table-core and @tanstack/virtual-core, MIT (https://github.com/TanStack/table/blob/main/LICENSE)
@@ -916,7 +916,7 @@ const clampActiveCell = (cell, context) => {
916
916
  };
917
917
  };
918
918
  const resolveNavigation = (key, ctrlKey, current, context) => {
919
- const { columnIds, rowCount, pageStep, paginated } = context;
919
+ const { columnIds, rowCount, pageStep, paginated, rtl } = context;
920
920
  const columnIndex = columnIds.indexOf(current.columnId);
921
921
  if (columnIndex === -1 || columnIds.length === 0) return null;
922
922
  const lastRow = rowCount - 1;
@@ -926,8 +926,8 @@ const resolveNavigation = (key, ctrlKey, current, context) => {
926
926
  columnId: columnIds[index]
927
927
  } });
928
928
  switch (key) {
929
- case "ArrowLeft": return cell(current.rowIndex, Math.max(columnIndex - 1, 0));
930
- case "ArrowRight": return cell(current.rowIndex, Math.min(columnIndex + 1, lastColumn));
929
+ case "ArrowLeft": return rtl ? cell(current.rowIndex, Math.min(columnIndex + 1, lastColumn)) : cell(current.rowIndex, Math.max(columnIndex - 1, 0));
930
+ case "ArrowRight": return rtl ? cell(current.rowIndex, Math.max(columnIndex - 1, 0)) : cell(current.rowIndex, Math.min(columnIndex + 1, lastColumn));
931
931
  case "ArrowUp": return cell(Math.max(current.rowIndex - 1, HEADER_ROW_INDEX), columnIndex);
932
932
  case "ArrowDown": return cell(Math.min(current.rowIndex + 1, lastRow), columnIndex);
933
933
  case "Home":
@@ -1151,6 +1151,7 @@ const createDragController = (options) => {
1151
1151
  const horizontal = axis === "x";
1152
1152
  let sourceHit = null;
1153
1153
  let dragging = false;
1154
+ let axisSign = 1;
1154
1155
  let origin = {
1155
1156
  x: 0,
1156
1157
  y: 0
@@ -1170,6 +1171,11 @@ const createDragController = (options) => {
1170
1171
  const previewClassed = /* @__PURE__ */ new Set();
1171
1172
  const contentStarts = /* @__PURE__ */ new Map();
1172
1173
  const contentSizes = /* @__PURE__ */ new Map();
1174
+ const logicalStart = (rect) => {
1175
+ if (!horizontal) return rect.top;
1176
+ return axisSign === 1 ? rect.left : -rect.right;
1177
+ };
1178
+ const logicalPointer = () => horizontal ? pointer.x * axisSign : pointer.y;
1173
1179
  const stopAutoScroll = () => {
1174
1180
  if (scrollFrame) {
1175
1181
  cancelAnimationFrame(scrollFrame);
@@ -1206,7 +1212,8 @@ const createDragController = (options) => {
1206
1212
  const rootRect = root.getBoundingClientRect();
1207
1213
  indicator.hidden = false;
1208
1214
  if (horizontal) {
1209
- indicator.style.left = `${after ? rect.right : rect.left}px`;
1215
+ const trailing = after === (axisSign === 1);
1216
+ indicator.style.left = `${trailing ? rect.right : rect.left}px`;
1210
1217
  indicator.style.top = `${rootRect.top}px`;
1211
1218
  indicator.style.height = `${rootRect.height}px`;
1212
1219
  } else {
@@ -1217,6 +1224,7 @@ const createDragController = (options) => {
1217
1224
  };
1218
1225
  const startDrag = () => {
1219
1226
  dragging = true;
1227
+ axisSign = horizontal && getComputedStyle(root).direction === "rtl" ? -1 : 1;
1220
1228
  const active = document.activeElement;
1221
1229
  if (active instanceof HTMLElement && root.contains(active)) active.blur();
1222
1230
  root.classList.add(CLASS_NAME_DRAG_ACTIVE);
@@ -1243,13 +1251,13 @@ const createDragController = (options) => {
1243
1251
  const scrollElement = options.getScrollElement();
1244
1252
  if (!scrollElement) return 0;
1245
1253
  const rect = scrollElement.getBoundingClientRect();
1246
- return horizontal ? rect.left - scrollElement.scrollLeft : rect.top - scrollElement.scrollTop;
1254
+ return horizontal ? logicalStart(rect) - axisSign * scrollElement.scrollLeft : rect.top - scrollElement.scrollTop;
1247
1255
  };
1248
1256
  const captureItem = (id, origin) => {
1249
1257
  const element = options.items.getElements(id)[0];
1250
1258
  if (!element) return false;
1251
1259
  const rect = element.getBoundingClientRect();
1252
- const start = (horizontal ? rect.left : rect.top) - (previewDeltas.get(id) ?? 0);
1260
+ const start = logicalStart(rect) - (previewDeltas.get(id) ?? 0);
1253
1261
  contentStarts.set(id, start - origin);
1254
1262
  contentSizes.set(id, horizontal ? rect.width : rect.height);
1255
1263
  return true;
@@ -1261,7 +1269,7 @@ const createDragController = (options) => {
1261
1269
  for (const id of options.items.getOrderedIds()) captureItem(id, origin);
1262
1270
  };
1263
1271
  const updateTarget = () => {
1264
- const position = horizontal ? pointer.x : pointer.y;
1272
+ const position = logicalPointer();
1265
1273
  const origin = contentOrigin();
1266
1274
  const zones = [];
1267
1275
  for (const id of options.items.getOrderedIds()) {
@@ -1364,7 +1372,7 @@ const createDragController = (options) => {
1364
1372
  for (const [id, delta] of next) {
1365
1373
  if (previewDeltas.get(id) === delta) continue;
1366
1374
  for (const element of options.items.getElements(id)) {
1367
- element.style.transform = horizontal ? `translateX(${delta}px)` : `translateY(${delta}px)`;
1375
+ element.style.transform = horizontal ? `translateX(${axisSign * delta}px)` : `translateY(${delta}px)`;
1368
1376
  element.classList.add(CLASS_NAME_PREVIEW);
1369
1377
  }
1370
1378
  previewClassed.add(id);
@@ -1398,7 +1406,7 @@ const createDragController = (options) => {
1398
1406
  };
1399
1407
  const delta = previewDeltas.get(sourceHit.id) ?? 0;
1400
1408
  return horizontal ? {
1401
- x: rect.left - delta,
1409
+ x: rect.left - axisSign * delta,
1402
1410
  y: rect.top
1403
1411
  } : {
1404
1412
  x: rect.left,
@@ -9445,6 +9453,22 @@ const evaluateColumnFilter = (cellValue, filterValue, filterType = "text") => {
9445
9453
  return filterValue.value.some((candidate) => String(candidate) === String(cellValue));
9446
9454
  };
9447
9455
  //#endregion
9456
+ //#region src/util/direction.ts
9457
+ /**
9458
+ * --------------------------------------------------------------------------
9459
+ * CoreUI PRO data-grid util/direction.ts
9460
+ * License (https://coreui.io/pro/license/)
9461
+ * --------------------------------------------------------------------------
9462
+ */
9463
+ const isElementRTL = (element) => typeof getComputedStyle === "function" && element ? getComputedStyle(element).direction === "rtl" : false;
9464
+ const syncResizeDirection = (table, element) => {
9465
+ const direction = isElementRTL(element) ? "rtl" : "ltr";
9466
+ if (table.options.columnResizeDirection !== direction) table.setOptions((previous) => ({
9467
+ ...previous,
9468
+ columnResizeDirection: direction
9469
+ }));
9470
+ };
9471
+ //#endregion
9448
9472
  //#region src/ui/toolbar.ts
9449
9473
  const CLASS_NAME_TOOLBAR = "data-grid-toolbar";
9450
9474
  const CLASS_NAME_ACTIONS = "data-grid-toolbar-actions";
@@ -9575,7 +9599,7 @@ const toTanStackFilterFn = (column) => {
9575
9599
  if (filterFn) return (row, columnId, filterValue) => filterFn(row.getValue(columnId), filterValue, row.original);
9576
9600
  return (row, columnId, filterValue) => evaluateColumnFilter(row.getValue(columnId), filterValue, column.filterType);
9577
9601
  };
9578
- const createGridTable = (options) => {
9602
+ const createGridTable = (options, getElement) => {
9579
9603
  const sortingOptions = typeof options.sorting === "object" ? options.sorting : {};
9580
9604
  const sizingOptions = typeof options.columnSizing === "object" ? options.columnSizing : {};
9581
9605
  const paginationOptions = typeof options.pagination === "object" ? options.pagination : {};
@@ -9638,6 +9662,7 @@ const createGridTable = (options) => {
9638
9662
  };
9639
9663
  }),
9640
9664
  columnResizeMode: sizingOptions.mode ?? "onChange",
9665
+ columnResizeDirection: isElementRTL(getElement?.()) ? "rtl" : "ltr",
9641
9666
  data: serverSide ? [] : options.items,
9642
9667
  enableCellSelection: Boolean(options.cellSelection),
9643
9668
  enableColumnFilters: Boolean(options.columnFilters),
@@ -12680,6 +12705,10 @@ let editorErrorCount = 0;
12680
12705
  const STATE_STORAGE_PREFIX = "coreui-data-grid:";
12681
12706
  const STATE_AUTOSAVE_DEBOUNCE_MS = 250;
12682
12707
  const HISTORY_LIMIT = 100;
12708
+ const INVERTED_ARROWS = {
12709
+ ArrowLeft: "ArrowRight",
12710
+ ArrowRight: "ArrowLeft"
12711
+ };
12683
12712
  const CELL_SELECTION_DIRECTIONS = {
12684
12713
  ArrowDown: "down",
12685
12714
  ArrowLeft: "left",
@@ -12991,7 +13020,7 @@ var DataGrid$1 = class DataGrid$1 extends BaseComponent {
12991
13020
  }
12992
13021
  _createTable() {
12993
13022
  this._unsubscribeState?.();
12994
- const table = createGridTable(this._config);
13023
+ const table = createGridTable(this._config, () => this._element);
12995
13024
  this._unsubscribeState = subscribeToTableState(table, (previous, next) => {
12996
13025
  this._notifyStateChange(previous, next);
12997
13026
  this._scheduler.schedule();
@@ -13493,7 +13522,7 @@ var DataGrid$1 = class DataGrid$1 extends BaseComponent {
13493
13522
  if (!result) return;
13494
13523
  event.preventDefault();
13495
13524
  if (this._config.cellSelection && found.cell.rowIndex >= 0 && result.cell.rowIndex >= 0) {
13496
- const direction = CELL_SELECTION_DIRECTIONS[event.key];
13525
+ const direction = CELL_SELECTION_DIRECTIONS[isElementRTL(this._element) ? INVERTED_ARROWS[event.key] ?? event.key : event.key];
13497
13526
  if (event.shiftKey && direction) {
13498
13527
  this._table.extendCellSelection(direction);
13499
13528
  this._scheduler.schedule();
@@ -13736,7 +13765,8 @@ var DataGrid$1 = class DataGrid$1 extends BaseComponent {
13736
13765
  columnIds: this._visibleLeafColumns().map((column) => column.id),
13737
13766
  rowCount,
13738
13767
  pageStep: paginated ? this._table.store.state.pagination.pageSize : Math.max(1, viewportRows || rowCount),
13739
- paginated
13768
+ paginated,
13769
+ rtl: isElementRTL(this._element)
13740
13770
  };
13741
13771
  }
13742
13772
  _cellElementFor(cell) {
@@ -13935,6 +13965,7 @@ var DataGrid$1 = class DataGrid$1 extends BaseComponent {
13935
13965
  const key = (event.delegateTarget ?? event.target).closest("th")?.dataset.coreuiColumn;
13936
13966
  if (!key) return;
13937
13967
  if (event.type === "mousedown") event.preventDefault();
13968
+ syncResizeDirection(this._table, this._element);
13938
13969
  (this._table.getHeaderGroups()[0]?.headers.find((item) => item.column.id === key))?.getResizeHandler()(event);
13939
13970
  }
13940
13971
  _toggleRowSelection(event) {