@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.
- package/README.md +4 -2
- package/dist/css/data-grid.css +11 -11
- package/dist/css/data-grid.css.map +1 -1
- package/dist/css/data-grid.min.css +2 -2
- package/dist/css/data-grid.min.css.map +1 -1
- package/dist/css/data-grid.standalone.css +1066 -0
- package/dist/css/data-grid.standalone.css.map +1 -0
- package/dist/css/data-grid.standalone.min.css +5 -0
- package/dist/css/data-grid.standalone.min.css.map +1 -0
- package/dist/js/clipboard.cjs +1 -1
- package/dist/js/clipboard.mjs +1 -1
- package/dist/js/csv.cjs +2 -2
- package/dist/js/csv.mjs +2 -2
- package/dist/js/data-grid.esm.js +45 -14
- package/dist/js/data-grid.esm.js.map +1 -1
- package/dist/js/data-grid.esm.min.js +2 -2
- package/dist/js/data-grid.esm.min.js.map +1 -1
- package/dist/js/data-grid.js +45 -14
- package/dist/js/data-grid.js.map +1 -1
- package/dist/js/data-grid.lite.esm.js +45 -14
- package/dist/js/data-grid.lite.esm.js.map +1 -1
- package/dist/js/data-grid.lite.esm.min.js +2 -2
- package/dist/js/data-grid.lite.esm.min.js.map +1 -1
- package/dist/js/data-grid.lite.js +45 -14
- package/dist/js/data-grid.lite.js.map +1 -1
- package/dist/js/data-grid.lite.min.js +2 -2
- package/dist/js/data-grid.lite.min.js.map +1 -1
- package/dist/js/data-grid.lite.mjs +45 -14
- package/dist/js/data-grid.lite.mjs.map +1 -1
- package/dist/js/data-grid.min.js +2 -2
- package/dist/js/data-grid.min.js.map +1 -1
- package/dist/js/data-grid.mjs +45 -14
- package/dist/js/data-grid.mjs.map +1 -1
- package/dist/js/direction.cjs +26 -0
- package/dist/js/direction.cjs.map +1 -0
- package/dist/js/direction.mjs +24 -0
- package/dist/js/direction.mjs.map +1 -0
- package/dist/js/drag.cjs +15 -7
- package/dist/js/drag.cjs.map +1 -1
- package/dist/js/drag.mjs +15 -7
- package/dist/js/drag.mjs.map +1 -1
- package/dist/js/{export-table-CNAKStzj.mjs → export-table-BdabEbJG.mjs} +2 -2
- package/dist/js/{export-table-CNAKStzj.mjs.map → export-table-BdabEbJG.mjs.map} +1 -1
- package/dist/js/{export-table-doIwvE5U.cjs → export-table-D762wrZ1.cjs} +2 -2
- package/dist/js/{export-table-doIwvE5U.cjs.map → export-table-D762wrZ1.cjs.map} +1 -1
- package/dist/js/filters.cjs +1 -1
- package/dist/js/filters.mjs +1 -1
- package/dist/js/labels.cjs +1 -1
- package/dist/js/labels.mjs +1 -1
- package/dist/js/print.cjs +1 -1
- package/dist/js/print.mjs +1 -1
- package/dist/js/validate.cjs +1 -1
- package/dist/js/validate.mjs +1 -1
- package/dist/js/xlsx.cjs +2 -2
- package/dist/js/xlsx.mjs +2 -2
- package/dist/types/engine/active-cell.d.ts +1 -0
- package/dist/types/engine/table.d.ts +1 -1
- package/dist/types/util/direction.d.mts +1 -0
- package/dist/types/util/direction.d.ts +17 -0
- package/package.json +14 -1
- package/scss/_base.scss +13 -0
- package/scss/_config.scss +14 -0
- package/scss/_functions.scss +1 -0
- package/scss/_mixins.scss +1 -0
- package/scss/base/_buttons.scss +113 -0
- package/scss/base/_forms.scss +157 -0
- package/scss/base/_helpers.scss +24 -0
- package/scss/base/_pagination.scss +100 -0
- package/scss/base/_reboot.scss +93 -0
- package/scss/base/_root.scss +85 -0
- package/scss/base/_spinner.scss +45 -0
- package/scss/base/_table.scss +78 -0
- package/scss/components/_data-grid.scss +807 -0
- package/scss/data-grid.scss +7 -743
- package/scss/data-grid.standalone.scss +16 -0
- package/scss/functions/_defaults.scss +25 -0
- package/scss/mixins/_tokens.scss +12 -0
- package/src/data-grid.ts +18 -3
- package/src/engine/active-cell.ts +10 -3
- package/src/engine/table.ts +9 -1
- package/src/util/direction.ts +37 -0
- package/src/util/drag.ts +40 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* CoreUI PRO data-grid v0.
|
|
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
|
-
|
|
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
|
|
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 = (
|
|
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 =
|
|
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,
|
|
@@ -5591,6 +5599,22 @@ const evaluateColumnFilter = (cellValue, filterValue, filterType = "text") => {
|
|
|
5591
5599
|
return filterValue.value.some((candidate) => String(candidate) === String(cellValue));
|
|
5592
5600
|
};
|
|
5593
5601
|
//#endregion
|
|
5602
|
+
//#region src/util/direction.ts
|
|
5603
|
+
/**
|
|
5604
|
+
* --------------------------------------------------------------------------
|
|
5605
|
+
* CoreUI PRO data-grid util/direction.ts
|
|
5606
|
+
* License (https://coreui.io/pro/license/)
|
|
5607
|
+
* --------------------------------------------------------------------------
|
|
5608
|
+
*/
|
|
5609
|
+
const isElementRTL = (element) => typeof getComputedStyle === "function" && element ? getComputedStyle(element).direction === "rtl" : false;
|
|
5610
|
+
const syncResizeDirection = (table, element) => {
|
|
5611
|
+
const direction = isElementRTL(element) ? "rtl" : "ltr";
|
|
5612
|
+
if (table.options.columnResizeDirection !== direction) table.setOptions((previous) => ({
|
|
5613
|
+
...previous,
|
|
5614
|
+
columnResizeDirection: direction
|
|
5615
|
+
}));
|
|
5616
|
+
};
|
|
5617
|
+
//#endregion
|
|
5594
5618
|
//#region src/ui/toolbar.ts
|
|
5595
5619
|
const CLASS_NAME_TOOLBAR = "data-grid-toolbar";
|
|
5596
5620
|
const CLASS_NAME_ACTIONS = "data-grid-toolbar-actions";
|
|
@@ -5721,7 +5745,7 @@ const toTanStackFilterFn = (column) => {
|
|
|
5721
5745
|
if (filterFn) return (row, columnId, filterValue) => filterFn(row.getValue(columnId), filterValue, row.original);
|
|
5722
5746
|
return (row, columnId, filterValue) => evaluateColumnFilter(row.getValue(columnId), filterValue, column.filterType);
|
|
5723
5747
|
};
|
|
5724
|
-
const createGridTable = (options) => {
|
|
5748
|
+
const createGridTable = (options, getElement) => {
|
|
5725
5749
|
const sortingOptions = typeof options.sorting === "object" ? options.sorting : {};
|
|
5726
5750
|
const sizingOptions = typeof options.columnSizing === "object" ? options.columnSizing : {};
|
|
5727
5751
|
const paginationOptions = typeof options.pagination === "object" ? options.pagination : {};
|
|
@@ -5784,6 +5808,7 @@ const createGridTable = (options) => {
|
|
|
5784
5808
|
};
|
|
5785
5809
|
}),
|
|
5786
5810
|
columnResizeMode: sizingOptions.mode ?? "onChange",
|
|
5811
|
+
columnResizeDirection: isElementRTL(getElement?.()) ? "rtl" : "ltr",
|
|
5787
5812
|
data: serverSide ? [] : options.items,
|
|
5788
5813
|
enableCellSelection: Boolean(options.cellSelection),
|
|
5789
5814
|
enableColumnFilters: Boolean(options.columnFilters),
|
|
@@ -8826,6 +8851,10 @@ let editorErrorCount = 0;
|
|
|
8826
8851
|
const STATE_STORAGE_PREFIX = "coreui-data-grid:";
|
|
8827
8852
|
const STATE_AUTOSAVE_DEBOUNCE_MS = 250;
|
|
8828
8853
|
const HISTORY_LIMIT = 100;
|
|
8854
|
+
const INVERTED_ARROWS = {
|
|
8855
|
+
ArrowLeft: "ArrowRight",
|
|
8856
|
+
ArrowRight: "ArrowLeft"
|
|
8857
|
+
};
|
|
8829
8858
|
const CELL_SELECTION_DIRECTIONS = {
|
|
8830
8859
|
ArrowDown: "down",
|
|
8831
8860
|
ArrowLeft: "left",
|
|
@@ -9137,7 +9166,7 @@ var DataGrid$1 = class DataGrid$1 extends BaseComponent {
|
|
|
9137
9166
|
}
|
|
9138
9167
|
_createTable() {
|
|
9139
9168
|
this._unsubscribeState?.();
|
|
9140
|
-
const table = createGridTable(this._config);
|
|
9169
|
+
const table = createGridTable(this._config, () => this._element);
|
|
9141
9170
|
this._unsubscribeState = subscribeToTableState(table, (previous, next) => {
|
|
9142
9171
|
this._notifyStateChange(previous, next);
|
|
9143
9172
|
this._scheduler.schedule();
|
|
@@ -9639,7 +9668,7 @@ var DataGrid$1 = class DataGrid$1 extends BaseComponent {
|
|
|
9639
9668
|
if (!result) return;
|
|
9640
9669
|
event.preventDefault();
|
|
9641
9670
|
if (this._config.cellSelection && found.cell.rowIndex >= 0 && result.cell.rowIndex >= 0) {
|
|
9642
|
-
const direction = CELL_SELECTION_DIRECTIONS[event.key];
|
|
9671
|
+
const direction = CELL_SELECTION_DIRECTIONS[isElementRTL(this._element) ? INVERTED_ARROWS[event.key] ?? event.key : event.key];
|
|
9643
9672
|
if (event.shiftKey && direction) {
|
|
9644
9673
|
this._table.extendCellSelection(direction);
|
|
9645
9674
|
this._scheduler.schedule();
|
|
@@ -9882,7 +9911,8 @@ var DataGrid$1 = class DataGrid$1 extends BaseComponent {
|
|
|
9882
9911
|
columnIds: this._visibleLeafColumns().map((column) => column.id),
|
|
9883
9912
|
rowCount,
|
|
9884
9913
|
pageStep: paginated ? this._table.store.state.pagination.pageSize : Math.max(1, viewportRows || rowCount),
|
|
9885
|
-
paginated
|
|
9914
|
+
paginated,
|
|
9915
|
+
rtl: isElementRTL(this._element)
|
|
9886
9916
|
};
|
|
9887
9917
|
}
|
|
9888
9918
|
_cellElementFor(cell) {
|
|
@@ -10081,6 +10111,7 @@ var DataGrid$1 = class DataGrid$1 extends BaseComponent {
|
|
|
10081
10111
|
const key = (event.delegateTarget ?? event.target).closest("th")?.dataset.coreuiColumn;
|
|
10082
10112
|
if (!key) return;
|
|
10083
10113
|
if (event.type === "mousedown") event.preventDefault();
|
|
10114
|
+
syncResizeDirection(this._table, this._element);
|
|
10084
10115
|
(this._table.getHeaderGroups()[0]?.headers.find((item) => item.column.id === key))?.getResizeHandler()(event);
|
|
10085
10116
|
}
|
|
10086
10117
|
_toggleRowSelection(event) {
|