schummar-table 0.46.5 → 0.46.6
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/dist/index.cjs +20 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4406,7 +4406,7 @@ var import_jsx_runtime28 = require("@emotion/react/jsx-runtime");
|
|
|
4406
4406
|
var ColumnHeaderContext = new StoreScope({
|
|
4407
4407
|
items: /* @__PURE__ */ new Map()
|
|
4408
4408
|
});
|
|
4409
|
-
function ColumnHeader() {
|
|
4409
|
+
function ColumnHeader({ index }) {
|
|
4410
4410
|
const ref = (0, import_react34.useRef)(null);
|
|
4411
4411
|
const columnId = useColumnContext();
|
|
4412
4412
|
const table = useTableContext();
|
|
@@ -4493,35 +4493,35 @@ function ColumnHeader() {
|
|
|
4493
4493
|
div.style.color = "rgba(0, 0, 0, 0.2)";
|
|
4494
4494
|
}
|
|
4495
4495
|
clone.current.style.left = `${draggingStart.current.bounds.left + event.clientX - draggingStart.current.mouseX}px`;
|
|
4496
|
-
const
|
|
4496
|
+
const index2 = state.columnOrder.indexOf(columnId);
|
|
4497
4497
|
const targetIndex = calcTargetIndex(
|
|
4498
4498
|
div.offsetLeft + event.clientX - draggingStart.current.mouseX
|
|
4499
4499
|
);
|
|
4500
|
-
const columns = table.getState().columnOrder.map((id,
|
|
4500
|
+
const columns = table.getState().columnOrder.map((id, index3) => {
|
|
4501
4501
|
var _a, _b;
|
|
4502
4502
|
return {
|
|
4503
4503
|
id,
|
|
4504
|
-
index:
|
|
4504
|
+
index: index3,
|
|
4505
4505
|
width: (_b = (_a = store.getState().items.get(id)) == null ? void 0 : _a.offsetWidth) != null ? _b : 0
|
|
4506
4506
|
};
|
|
4507
4507
|
});
|
|
4508
4508
|
state.columnOrder.forEach((id, i) => {
|
|
4509
4509
|
let offset = 0;
|
|
4510
|
-
if (i ===
|
|
4511
|
-
if (targetIndex >
|
|
4512
|
-
offset = columns.slice(
|
|
4513
|
-
} else if (targetIndex <
|
|
4514
|
-
offset = -columns.slice(targetIndex,
|
|
4510
|
+
if (i === index2) {
|
|
4511
|
+
if (targetIndex > index2) {
|
|
4512
|
+
offset = columns.slice(index2 + 1, targetIndex + 1).reduce((sum, col) => sum + col.width, 0);
|
|
4513
|
+
} else if (targetIndex < index2) {
|
|
4514
|
+
offset = -columns.slice(targetIndex, index2).reduce((sum, col) => sum + col.width, 0);
|
|
4515
4515
|
}
|
|
4516
|
-
} else if (i >= targetIndex && i <
|
|
4516
|
+
} else if (i >= targetIndex && i < index2) {
|
|
4517
4517
|
offset = div.offsetWidth;
|
|
4518
|
-
} else if (i >
|
|
4518
|
+
} else if (i > index2 && i <= targetIndex) {
|
|
4519
4519
|
offset = -div.offsetWidth;
|
|
4520
4520
|
}
|
|
4521
4521
|
state.columnStyleOverride.set(id, {
|
|
4522
4522
|
transition: "transform 500ms",
|
|
4523
4523
|
transform: `translate3d(${offset}px, 0, 0)`,
|
|
4524
|
-
zIndex: i ===
|
|
4524
|
+
zIndex: i === index2 ? 1 : void 0
|
|
4525
4525
|
});
|
|
4526
4526
|
});
|
|
4527
4527
|
});
|
|
@@ -4531,11 +4531,11 @@ function ColumnHeader() {
|
|
|
4531
4531
|
var _a;
|
|
4532
4532
|
const div = ref.current;
|
|
4533
4533
|
if (!div || draggingStart.current === void 0) return;
|
|
4534
|
-
const
|
|
4534
|
+
const index2 = state.columnOrder.indexOf(columnId);
|
|
4535
4535
|
const targetIndex = calcTargetIndex(
|
|
4536
4536
|
div.offsetLeft + event.clientX - draggingStart.current.mouseX
|
|
4537
4537
|
);
|
|
4538
|
-
state.columnOrder.splice(
|
|
4538
|
+
state.columnOrder.splice(index2, 1);
|
|
4539
4539
|
state.columnOrder.splice(targetIndex, 0, columnId);
|
|
4540
4540
|
(_a = clone.current) == null ? void 0 : _a.remove();
|
|
4541
4541
|
div.style.color = "";
|
|
@@ -4552,6 +4552,8 @@ function ColumnHeader() {
|
|
|
4552
4552
|
css: [
|
|
4553
4553
|
defaultClasses.headerCell,
|
|
4554
4554
|
{
|
|
4555
|
+
gridRow: 1,
|
|
4556
|
+
gridColumn: index + 2,
|
|
4555
4557
|
position: "relative",
|
|
4556
4558
|
userSelect: "none"
|
|
4557
4559
|
},
|
|
@@ -5284,7 +5286,7 @@ var TableInner = (0, import_react43.memo)(function TableInner2({ hidden }) {
|
|
|
5284
5286
|
{
|
|
5285
5287
|
className: classes == null ? void 0 : classes.headerCell,
|
|
5286
5288
|
css: [
|
|
5287
|
-
{ gridColumn: 1 },
|
|
5289
|
+
{ gridRow: 1, gridColumn: 1 },
|
|
5288
5290
|
defaultClasses.headerFill,
|
|
5289
5291
|
stickyHeader && defaultClasses.sticky,
|
|
5290
5292
|
stickyHeader instanceof Object && stickyHeader,
|
|
@@ -5297,7 +5299,7 @@ var TableInner = (0, import_react43.memo)(function TableInner2({ hidden }) {
|
|
|
5297
5299
|
{
|
|
5298
5300
|
className: classes == null ? void 0 : classes.headerCell,
|
|
5299
5301
|
css: [
|
|
5300
|
-
{ gridColumn: 2 },
|
|
5302
|
+
{ gridRow: 1, gridColumn: 2 },
|
|
5301
5303
|
defaultClasses.headerCell,
|
|
5302
5304
|
stickyHeader && defaultClasses.sticky,
|
|
5303
5305
|
stickyHeader instanceof Object && stickyHeader,
|
|
@@ -5314,12 +5316,13 @@ var TableInner = (0, import_react43.memo)(function TableInner2({ hidden }) {
|
|
|
5314
5316
|
]
|
|
5315
5317
|
}
|
|
5316
5318
|
),
|
|
5317
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ColumnHeaderContext.Provider, { children: visibleColumns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ColumnContext.Provider, { value: column.id, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ColumnHeader, {}) }, column.id)) }),
|
|
5319
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ColumnHeaderContext.Provider, { children: visibleColumns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ColumnContext.Provider, { value: column.id, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ColumnHeader, { index }) }, column.id)) }),
|
|
5318
5320
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
5319
5321
|
"div",
|
|
5320
5322
|
{
|
|
5321
5323
|
className: classes == null ? void 0 : classes.headerCell,
|
|
5322
5324
|
css: [
|
|
5325
|
+
{ gridRow: 1, gridColumn: visibleColumns.length + 3 },
|
|
5323
5326
|
defaultClasses.headerFill,
|
|
5324
5327
|
stickyHeader && defaultClasses.sticky,
|
|
5325
5328
|
stickyHeader instanceof Object && stickyHeader,
|