@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)
|
|
@@ -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,
|
|
@@ -5595,6 +5603,22 @@
|
|
|
5595
5603
|
return filterValue.value.some((candidate) => String(candidate) === String(cellValue));
|
|
5596
5604
|
};
|
|
5597
5605
|
//#endregion
|
|
5606
|
+
//#region src/util/direction.ts
|
|
5607
|
+
/**
|
|
5608
|
+
* --------------------------------------------------------------------------
|
|
5609
|
+
* CoreUI PRO data-grid util/direction.ts
|
|
5610
|
+
* License (https://coreui.io/pro/license/)
|
|
5611
|
+
* --------------------------------------------------------------------------
|
|
5612
|
+
*/
|
|
5613
|
+
const isElementRTL = (element) => typeof getComputedStyle === "function" && element ? getComputedStyle(element).direction === "rtl" : false;
|
|
5614
|
+
const syncResizeDirection = (table, element) => {
|
|
5615
|
+
const direction = isElementRTL(element) ? "rtl" : "ltr";
|
|
5616
|
+
if (table.options.columnResizeDirection !== direction) table.setOptions((previous) => ({
|
|
5617
|
+
...previous,
|
|
5618
|
+
columnResizeDirection: direction
|
|
5619
|
+
}));
|
|
5620
|
+
};
|
|
5621
|
+
//#endregion
|
|
5598
5622
|
//#region src/ui/toolbar.ts
|
|
5599
5623
|
const CLASS_NAME_TOOLBAR = "data-grid-toolbar";
|
|
5600
5624
|
const CLASS_NAME_ACTIONS = "data-grid-toolbar-actions";
|
|
@@ -5725,7 +5749,7 @@
|
|
|
5725
5749
|
if (filterFn) return (row, columnId, filterValue) => filterFn(row.getValue(columnId), filterValue, row.original);
|
|
5726
5750
|
return (row, columnId, filterValue) => evaluateColumnFilter(row.getValue(columnId), filterValue, column.filterType);
|
|
5727
5751
|
};
|
|
5728
|
-
const createGridTable = (options) => {
|
|
5752
|
+
const createGridTable = (options, getElement) => {
|
|
5729
5753
|
const sortingOptions = typeof options.sorting === "object" ? options.sorting : {};
|
|
5730
5754
|
const sizingOptions = typeof options.columnSizing === "object" ? options.columnSizing : {};
|
|
5731
5755
|
const paginationOptions = typeof options.pagination === "object" ? options.pagination : {};
|
|
@@ -5788,6 +5812,7 @@
|
|
|
5788
5812
|
};
|
|
5789
5813
|
}),
|
|
5790
5814
|
columnResizeMode: sizingOptions.mode ?? "onChange",
|
|
5815
|
+
columnResizeDirection: isElementRTL(getElement?.()) ? "rtl" : "ltr",
|
|
5791
5816
|
data: serverSide ? [] : options.items,
|
|
5792
5817
|
enableCellSelection: Boolean(options.cellSelection),
|
|
5793
5818
|
enableColumnFilters: Boolean(options.columnFilters),
|
|
@@ -8830,6 +8855,10 @@
|
|
|
8830
8855
|
const STATE_STORAGE_PREFIX = "coreui-data-grid:";
|
|
8831
8856
|
const STATE_AUTOSAVE_DEBOUNCE_MS = 250;
|
|
8832
8857
|
const HISTORY_LIMIT = 100;
|
|
8858
|
+
const INVERTED_ARROWS = {
|
|
8859
|
+
ArrowLeft: "ArrowRight",
|
|
8860
|
+
ArrowRight: "ArrowLeft"
|
|
8861
|
+
};
|
|
8833
8862
|
const CELL_SELECTION_DIRECTIONS = {
|
|
8834
8863
|
ArrowDown: "down",
|
|
8835
8864
|
ArrowLeft: "left",
|
|
@@ -9141,7 +9170,7 @@
|
|
|
9141
9170
|
}
|
|
9142
9171
|
_createTable() {
|
|
9143
9172
|
this._unsubscribeState?.();
|
|
9144
|
-
const table = createGridTable(this._config);
|
|
9173
|
+
const table = createGridTable(this._config, () => this._element);
|
|
9145
9174
|
this._unsubscribeState = subscribeToTableState(table, (previous, next) => {
|
|
9146
9175
|
this._notifyStateChange(previous, next);
|
|
9147
9176
|
this._scheduler.schedule();
|
|
@@ -9643,7 +9672,7 @@
|
|
|
9643
9672
|
if (!result) return;
|
|
9644
9673
|
event.preventDefault();
|
|
9645
9674
|
if (this._config.cellSelection && found.cell.rowIndex >= 0 && result.cell.rowIndex >= 0) {
|
|
9646
|
-
const direction = CELL_SELECTION_DIRECTIONS[event.key];
|
|
9675
|
+
const direction = CELL_SELECTION_DIRECTIONS[isElementRTL(this._element) ? INVERTED_ARROWS[event.key] ?? event.key : event.key];
|
|
9647
9676
|
if (event.shiftKey && direction) {
|
|
9648
9677
|
this._table.extendCellSelection(direction);
|
|
9649
9678
|
this._scheduler.schedule();
|
|
@@ -9886,7 +9915,8 @@
|
|
|
9886
9915
|
columnIds: this._visibleLeafColumns().map((column) => column.id),
|
|
9887
9916
|
rowCount,
|
|
9888
9917
|
pageStep: paginated ? this._table.store.state.pagination.pageSize : Math.max(1, viewportRows || rowCount),
|
|
9889
|
-
paginated
|
|
9918
|
+
paginated,
|
|
9919
|
+
rtl: isElementRTL(this._element)
|
|
9890
9920
|
};
|
|
9891
9921
|
}
|
|
9892
9922
|
_cellElementFor(cell) {
|
|
@@ -10085,6 +10115,7 @@
|
|
|
10085
10115
|
const key = (event.delegateTarget ?? event.target).closest("th")?.dataset.coreuiColumn;
|
|
10086
10116
|
if (!key) return;
|
|
10087
10117
|
if (event.type === "mousedown") event.preventDefault();
|
|
10118
|
+
syncResizeDirection(this._table, this._element);
|
|
10088
10119
|
(this._table.getHeaderGroups()[0]?.headers.find((item) => item.column.id === key))?.getResizeHandler()(event);
|
|
10089
10120
|
}
|
|
10090
10121
|
_toggleRowSelection(event) {
|