@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
package/dist/js/data-grid.js
CHANGED
|
@@ -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)
|
|
@@ -920,7 +920,7 @@
|
|
|
920
920
|
};
|
|
921
921
|
};
|
|
922
922
|
const resolveNavigation = (key, ctrlKey, current, context) => {
|
|
923
|
-
const { columnIds, rowCount, pageStep, paginated } = context;
|
|
923
|
+
const { columnIds, rowCount, pageStep, paginated, rtl } = context;
|
|
924
924
|
const columnIndex = columnIds.indexOf(current.columnId);
|
|
925
925
|
if (columnIndex === -1 || columnIds.length === 0) return null;
|
|
926
926
|
const lastRow = rowCount - 1;
|
|
@@ -930,8 +930,8 @@
|
|
|
930
930
|
columnId: columnIds[index]
|
|
931
931
|
} });
|
|
932
932
|
switch (key) {
|
|
933
|
-
case "ArrowLeft": return cell(current.rowIndex, Math.max(columnIndex - 1, 0));
|
|
934
|
-
case "ArrowRight": return cell(current.rowIndex, Math.min(columnIndex + 1, lastColumn));
|
|
933
|
+
case "ArrowLeft": return rtl ? cell(current.rowIndex, Math.min(columnIndex + 1, lastColumn)) : cell(current.rowIndex, Math.max(columnIndex - 1, 0));
|
|
934
|
+
case "ArrowRight": return rtl ? cell(current.rowIndex, Math.max(columnIndex - 1, 0)) : cell(current.rowIndex, Math.min(columnIndex + 1, lastColumn));
|
|
935
935
|
case "ArrowUp": return cell(Math.max(current.rowIndex - 1, HEADER_ROW_INDEX), columnIndex);
|
|
936
936
|
case "ArrowDown": return cell(Math.min(current.rowIndex + 1, lastRow), columnIndex);
|
|
937
937
|
case "Home":
|
|
@@ -1155,6 +1155,7 @@
|
|
|
1155
1155
|
const horizontal = axis === "x";
|
|
1156
1156
|
let sourceHit = null;
|
|
1157
1157
|
let dragging = false;
|
|
1158
|
+
let axisSign = 1;
|
|
1158
1159
|
let origin = {
|
|
1159
1160
|
x: 0,
|
|
1160
1161
|
y: 0
|
|
@@ -1174,6 +1175,11 @@
|
|
|
1174
1175
|
const previewClassed = /* @__PURE__ */ new Set();
|
|
1175
1176
|
const contentStarts = /* @__PURE__ */ new Map();
|
|
1176
1177
|
const contentSizes = /* @__PURE__ */ new Map();
|
|
1178
|
+
const logicalStart = (rect) => {
|
|
1179
|
+
if (!horizontal) return rect.top;
|
|
1180
|
+
return axisSign === 1 ? rect.left : -rect.right;
|
|
1181
|
+
};
|
|
1182
|
+
const logicalPointer = () => horizontal ? pointer.x * axisSign : pointer.y;
|
|
1177
1183
|
const stopAutoScroll = () => {
|
|
1178
1184
|
if (scrollFrame) {
|
|
1179
1185
|
cancelAnimationFrame(scrollFrame);
|
|
@@ -1210,7 +1216,8 @@
|
|
|
1210
1216
|
const rootRect = root.getBoundingClientRect();
|
|
1211
1217
|
indicator.hidden = false;
|
|
1212
1218
|
if (horizontal) {
|
|
1213
|
-
|
|
1219
|
+
const trailing = after === (axisSign === 1);
|
|
1220
|
+
indicator.style.left = `${trailing ? rect.right : rect.left}px`;
|
|
1214
1221
|
indicator.style.top = `${rootRect.top}px`;
|
|
1215
1222
|
indicator.style.height = `${rootRect.height}px`;
|
|
1216
1223
|
} else {
|
|
@@ -1221,6 +1228,7 @@
|
|
|
1221
1228
|
};
|
|
1222
1229
|
const startDrag = () => {
|
|
1223
1230
|
dragging = true;
|
|
1231
|
+
axisSign = horizontal && getComputedStyle(root).direction === "rtl" ? -1 : 1;
|
|
1224
1232
|
const active = document.activeElement;
|
|
1225
1233
|
if (active instanceof HTMLElement && root.contains(active)) active.blur();
|
|
1226
1234
|
root.classList.add(CLASS_NAME_DRAG_ACTIVE);
|
|
@@ -1247,13 +1255,13 @@
|
|
|
1247
1255
|
const scrollElement = options.getScrollElement();
|
|
1248
1256
|
if (!scrollElement) return 0;
|
|
1249
1257
|
const rect = scrollElement.getBoundingClientRect();
|
|
1250
|
-
return horizontal ? rect
|
|
1258
|
+
return horizontal ? logicalStart(rect) - axisSign * scrollElement.scrollLeft : rect.top - scrollElement.scrollTop;
|
|
1251
1259
|
};
|
|
1252
1260
|
const captureItem = (id, origin) => {
|
|
1253
1261
|
const element = options.items.getElements(id)[0];
|
|
1254
1262
|
if (!element) return false;
|
|
1255
1263
|
const rect = element.getBoundingClientRect();
|
|
1256
|
-
const start = (
|
|
1264
|
+
const start = logicalStart(rect) - (previewDeltas.get(id) ?? 0);
|
|
1257
1265
|
contentStarts.set(id, start - origin);
|
|
1258
1266
|
contentSizes.set(id, horizontal ? rect.width : rect.height);
|
|
1259
1267
|
return true;
|
|
@@ -1265,7 +1273,7 @@
|
|
|
1265
1273
|
for (const id of options.items.getOrderedIds()) captureItem(id, origin);
|
|
1266
1274
|
};
|
|
1267
1275
|
const updateTarget = () => {
|
|
1268
|
-
const position =
|
|
1276
|
+
const position = logicalPointer();
|
|
1269
1277
|
const origin = contentOrigin();
|
|
1270
1278
|
const zones = [];
|
|
1271
1279
|
for (const id of options.items.getOrderedIds()) {
|
|
@@ -1368,7 +1376,7 @@
|
|
|
1368
1376
|
for (const [id, delta] of next) {
|
|
1369
1377
|
if (previewDeltas.get(id) === delta) continue;
|
|
1370
1378
|
for (const element of options.items.getElements(id)) {
|
|
1371
|
-
element.style.transform = horizontal ? `translateX(${delta}px)` : `translateY(${delta}px)`;
|
|
1379
|
+
element.style.transform = horizontal ? `translateX(${axisSign * delta}px)` : `translateY(${delta}px)`;
|
|
1372
1380
|
element.classList.add(CLASS_NAME_PREVIEW);
|
|
1373
1381
|
}
|
|
1374
1382
|
previewClassed.add(id);
|
|
@@ -1402,7 +1410,7 @@
|
|
|
1402
1410
|
};
|
|
1403
1411
|
const delta = previewDeltas.get(sourceHit.id) ?? 0;
|
|
1404
1412
|
return horizontal ? {
|
|
1405
|
-
x: rect.left - delta,
|
|
1413
|
+
x: rect.left - axisSign * delta,
|
|
1406
1414
|
y: rect.top
|
|
1407
1415
|
} : {
|
|
1408
1416
|
x: rect.left,
|
|
@@ -9449,6 +9457,22 @@
|
|
|
9449
9457
|
return filterValue.value.some((candidate) => String(candidate) === String(cellValue));
|
|
9450
9458
|
};
|
|
9451
9459
|
//#endregion
|
|
9460
|
+
//#region src/util/direction.ts
|
|
9461
|
+
/**
|
|
9462
|
+
* --------------------------------------------------------------------------
|
|
9463
|
+
* CoreUI PRO data-grid util/direction.ts
|
|
9464
|
+
* License (https://coreui.io/pro/license/)
|
|
9465
|
+
* --------------------------------------------------------------------------
|
|
9466
|
+
*/
|
|
9467
|
+
const isElementRTL = (element) => typeof getComputedStyle === "function" && element ? getComputedStyle(element).direction === "rtl" : false;
|
|
9468
|
+
const syncResizeDirection = (table, element) => {
|
|
9469
|
+
const direction = isElementRTL(element) ? "rtl" : "ltr";
|
|
9470
|
+
if (table.options.columnResizeDirection !== direction) table.setOptions((previous) => ({
|
|
9471
|
+
...previous,
|
|
9472
|
+
columnResizeDirection: direction
|
|
9473
|
+
}));
|
|
9474
|
+
};
|
|
9475
|
+
//#endregion
|
|
9452
9476
|
//#region src/ui/toolbar.ts
|
|
9453
9477
|
const CLASS_NAME_TOOLBAR = "data-grid-toolbar";
|
|
9454
9478
|
const CLASS_NAME_ACTIONS = "data-grid-toolbar-actions";
|
|
@@ -9579,7 +9603,7 @@
|
|
|
9579
9603
|
if (filterFn) return (row, columnId, filterValue) => filterFn(row.getValue(columnId), filterValue, row.original);
|
|
9580
9604
|
return (row, columnId, filterValue) => evaluateColumnFilter(row.getValue(columnId), filterValue, column.filterType);
|
|
9581
9605
|
};
|
|
9582
|
-
const createGridTable = (options) => {
|
|
9606
|
+
const createGridTable = (options, getElement) => {
|
|
9583
9607
|
const sortingOptions = typeof options.sorting === "object" ? options.sorting : {};
|
|
9584
9608
|
const sizingOptions = typeof options.columnSizing === "object" ? options.columnSizing : {};
|
|
9585
9609
|
const paginationOptions = typeof options.pagination === "object" ? options.pagination : {};
|
|
@@ -9642,6 +9666,7 @@
|
|
|
9642
9666
|
};
|
|
9643
9667
|
}),
|
|
9644
9668
|
columnResizeMode: sizingOptions.mode ?? "onChange",
|
|
9669
|
+
columnResizeDirection: isElementRTL(getElement?.()) ? "rtl" : "ltr",
|
|
9645
9670
|
data: serverSide ? [] : options.items,
|
|
9646
9671
|
enableCellSelection: Boolean(options.cellSelection),
|
|
9647
9672
|
enableColumnFilters: Boolean(options.columnFilters),
|
|
@@ -12684,6 +12709,10 @@
|
|
|
12684
12709
|
const STATE_STORAGE_PREFIX = "coreui-data-grid:";
|
|
12685
12710
|
const STATE_AUTOSAVE_DEBOUNCE_MS = 250;
|
|
12686
12711
|
const HISTORY_LIMIT = 100;
|
|
12712
|
+
const INVERTED_ARROWS = {
|
|
12713
|
+
ArrowLeft: "ArrowRight",
|
|
12714
|
+
ArrowRight: "ArrowLeft"
|
|
12715
|
+
};
|
|
12687
12716
|
const CELL_SELECTION_DIRECTIONS = {
|
|
12688
12717
|
ArrowDown: "down",
|
|
12689
12718
|
ArrowLeft: "left",
|
|
@@ -12995,7 +13024,7 @@
|
|
|
12995
13024
|
}
|
|
12996
13025
|
_createTable() {
|
|
12997
13026
|
this._unsubscribeState?.();
|
|
12998
|
-
const table = createGridTable(this._config);
|
|
13027
|
+
const table = createGridTable(this._config, () => this._element);
|
|
12999
13028
|
this._unsubscribeState = subscribeToTableState(table, (previous, next) => {
|
|
13000
13029
|
this._notifyStateChange(previous, next);
|
|
13001
13030
|
this._scheduler.schedule();
|
|
@@ -13497,7 +13526,7 @@
|
|
|
13497
13526
|
if (!result) return;
|
|
13498
13527
|
event.preventDefault();
|
|
13499
13528
|
if (this._config.cellSelection && found.cell.rowIndex >= 0 && result.cell.rowIndex >= 0) {
|
|
13500
|
-
const direction = CELL_SELECTION_DIRECTIONS[event.key];
|
|
13529
|
+
const direction = CELL_SELECTION_DIRECTIONS[isElementRTL(this._element) ? INVERTED_ARROWS[event.key] ?? event.key : event.key];
|
|
13501
13530
|
if (event.shiftKey && direction) {
|
|
13502
13531
|
this._table.extendCellSelection(direction);
|
|
13503
13532
|
this._scheduler.schedule();
|
|
@@ -13740,7 +13769,8 @@
|
|
|
13740
13769
|
columnIds: this._visibleLeafColumns().map((column) => column.id),
|
|
13741
13770
|
rowCount,
|
|
13742
13771
|
pageStep: paginated ? this._table.store.state.pagination.pageSize : Math.max(1, viewportRows || rowCount),
|
|
13743
|
-
paginated
|
|
13772
|
+
paginated,
|
|
13773
|
+
rtl: isElementRTL(this._element)
|
|
13744
13774
|
};
|
|
13745
13775
|
}
|
|
13746
13776
|
_cellElementFor(cell) {
|
|
@@ -13939,6 +13969,7 @@
|
|
|
13939
13969
|
const key = (event.delegateTarget ?? event.target).closest("th")?.dataset.coreuiColumn;
|
|
13940
13970
|
if (!key) return;
|
|
13941
13971
|
if (event.type === "mousedown") event.preventDefault();
|
|
13972
|
+
syncResizeDirection(this._table, this._element);
|
|
13942
13973
|
(this._table.getHeaderGroups()[0]?.headers.find((item) => item.column.id === key))?.getResizeHandler()(event);
|
|
13943
13974
|
}
|
|
13944
13975
|
_toggleRowSelection(event) {
|