schummar-table 0.46.5 → 0.46.7
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.js
CHANGED
|
@@ -3512,7 +3512,7 @@ import { jsx as jsx26, jsxs as jsxs14 } from "@emotion/react/jsx-runtime";
|
|
|
3512
3512
|
var ColumnHeaderContext = new StoreScope({
|
|
3513
3513
|
items: /* @__PURE__ */ new Map()
|
|
3514
3514
|
});
|
|
3515
|
-
function ColumnHeader() {
|
|
3515
|
+
function ColumnHeader({ index }) {
|
|
3516
3516
|
const ref = useRef4(null);
|
|
3517
3517
|
const columnId = useColumnContext();
|
|
3518
3518
|
const table = useTableContext();
|
|
@@ -3599,35 +3599,35 @@ function ColumnHeader() {
|
|
|
3599
3599
|
div.style.color = "rgba(0, 0, 0, 0.2)";
|
|
3600
3600
|
}
|
|
3601
3601
|
clone.current.style.left = `${draggingStart.current.bounds.left + event.clientX - draggingStart.current.mouseX}px`;
|
|
3602
|
-
const
|
|
3602
|
+
const index2 = state.columnOrder.indexOf(columnId);
|
|
3603
3603
|
const targetIndex = calcTargetIndex(
|
|
3604
3604
|
div.offsetLeft + event.clientX - draggingStart.current.mouseX
|
|
3605
3605
|
);
|
|
3606
|
-
const columns = table.getState().columnOrder.map((id,
|
|
3606
|
+
const columns = table.getState().columnOrder.map((id, index3) => {
|
|
3607
3607
|
var _a, _b;
|
|
3608
3608
|
return {
|
|
3609
3609
|
id,
|
|
3610
|
-
index:
|
|
3610
|
+
index: index3,
|
|
3611
3611
|
width: (_b = (_a = store.getState().items.get(id)) == null ? void 0 : _a.offsetWidth) != null ? _b : 0
|
|
3612
3612
|
};
|
|
3613
3613
|
});
|
|
3614
3614
|
state.columnOrder.forEach((id, i) => {
|
|
3615
3615
|
let offset = 0;
|
|
3616
|
-
if (i ===
|
|
3617
|
-
if (targetIndex >
|
|
3618
|
-
offset = columns.slice(
|
|
3619
|
-
} else if (targetIndex <
|
|
3620
|
-
offset = -columns.slice(targetIndex,
|
|
3616
|
+
if (i === index2) {
|
|
3617
|
+
if (targetIndex > index2) {
|
|
3618
|
+
offset = columns.slice(index2 + 1, targetIndex + 1).reduce((sum, col) => sum + col.width, 0);
|
|
3619
|
+
} else if (targetIndex < index2) {
|
|
3620
|
+
offset = -columns.slice(targetIndex, index2).reduce((sum, col) => sum + col.width, 0);
|
|
3621
3621
|
}
|
|
3622
|
-
} else if (i >= targetIndex && i <
|
|
3622
|
+
} else if (i >= targetIndex && i < index2) {
|
|
3623
3623
|
offset = div.offsetWidth;
|
|
3624
|
-
} else if (i >
|
|
3624
|
+
} else if (i > index2 && i <= targetIndex) {
|
|
3625
3625
|
offset = -div.offsetWidth;
|
|
3626
3626
|
}
|
|
3627
3627
|
state.columnStyleOverride.set(id, {
|
|
3628
3628
|
transition: "transform 500ms",
|
|
3629
3629
|
transform: `translate3d(${offset}px, 0, 0)`,
|
|
3630
|
-
zIndex: i ===
|
|
3630
|
+
zIndex: i === index2 ? 1 : void 0
|
|
3631
3631
|
});
|
|
3632
3632
|
});
|
|
3633
3633
|
});
|
|
@@ -3637,11 +3637,11 @@ function ColumnHeader() {
|
|
|
3637
3637
|
var _a;
|
|
3638
3638
|
const div = ref.current;
|
|
3639
3639
|
if (!div || draggingStart.current === void 0) return;
|
|
3640
|
-
const
|
|
3640
|
+
const index2 = state.columnOrder.indexOf(columnId);
|
|
3641
3641
|
const targetIndex = calcTargetIndex(
|
|
3642
3642
|
div.offsetLeft + event.clientX - draggingStart.current.mouseX
|
|
3643
3643
|
);
|
|
3644
|
-
state.columnOrder.splice(
|
|
3644
|
+
state.columnOrder.splice(index2, 1);
|
|
3645
3645
|
state.columnOrder.splice(targetIndex, 0, columnId);
|
|
3646
3646
|
(_a = clone.current) == null ? void 0 : _a.remove();
|
|
3647
3647
|
div.style.color = "";
|
|
@@ -3658,6 +3658,8 @@ function ColumnHeader() {
|
|
|
3658
3658
|
css: [
|
|
3659
3659
|
defaultClasses.headerCell,
|
|
3660
3660
|
{
|
|
3661
|
+
gridRow: 1,
|
|
3662
|
+
gridColumn: index + 3,
|
|
3661
3663
|
position: "relative",
|
|
3662
3664
|
userSelect: "none"
|
|
3663
3665
|
},
|
|
@@ -4390,7 +4392,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
|
|
|
4390
4392
|
{
|
|
4391
4393
|
className: classes == null ? void 0 : classes.headerCell,
|
|
4392
4394
|
css: [
|
|
4393
|
-
{ gridColumn: 1 },
|
|
4395
|
+
{ gridRow: 1, gridColumn: 1 },
|
|
4394
4396
|
defaultClasses.headerFill,
|
|
4395
4397
|
stickyHeader && defaultClasses.sticky,
|
|
4396
4398
|
stickyHeader instanceof Object && stickyHeader,
|
|
@@ -4403,7 +4405,7 @@ var TableInner = memo3(function TableInner2({ hidden }) {
|
|
|
4403
4405
|
{
|
|
4404
4406
|
className: classes == null ? void 0 : classes.headerCell,
|
|
4405
4407
|
css: [
|
|
4406
|
-
{ gridColumn: 2 },
|
|
4408
|
+
{ gridRow: 1, gridColumn: 2 },
|
|
4407
4409
|
defaultClasses.headerCell,
|
|
4408
4410
|
stickyHeader && defaultClasses.sticky,
|
|
4409
4411
|
stickyHeader instanceof Object && stickyHeader,
|
|
@@ -4420,12 +4422,13 @@ var TableInner = memo3(function TableInner2({ hidden }) {
|
|
|
4420
4422
|
]
|
|
4421
4423
|
}
|
|
4422
4424
|
),
|
|
4423
|
-
/* @__PURE__ */ jsx35(ColumnHeaderContext.Provider, { children: visibleColumns.map((column) => /* @__PURE__ */ jsx35(ColumnContext.Provider, { value: column.id, children: /* @__PURE__ */ jsx35(ColumnHeader, {}) }, column.id)) }),
|
|
4425
|
+
/* @__PURE__ */ jsx35(ColumnHeaderContext.Provider, { children: visibleColumns.map((column, index) => /* @__PURE__ */ jsx35(ColumnContext.Provider, { value: column.id, children: /* @__PURE__ */ jsx35(ColumnHeader, { index }) }, column.id)) }),
|
|
4424
4426
|
/* @__PURE__ */ jsx35(
|
|
4425
4427
|
"div",
|
|
4426
4428
|
{
|
|
4427
4429
|
className: classes == null ? void 0 : classes.headerCell,
|
|
4428
4430
|
css: [
|
|
4431
|
+
{ gridRow: 1, gridColumn: visibleColumns.length + 3 },
|
|
4429
4432
|
defaultClasses.headerFill,
|
|
4430
4433
|
stickyHeader && defaultClasses.sticky,
|
|
4431
4434
|
stickyHeader instanceof Object && stickyHeader,
|