@smallwebco/tinypivot-react 1.0.10 → 1.0.11
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 +129 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +129 -23
- package/dist/index.js.map +1 -1
- package/dist/style.css +22 -0
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -111,7 +111,7 @@ interface PivotSkeletonProps {
|
|
|
111
111
|
onReorderRowFields: (fields: string[]) => void;
|
|
112
112
|
onReorderColumnFields: (fields: string[]) => void;
|
|
113
113
|
}
|
|
114
|
-
declare function PivotSkeleton({ rowFields, columnFields, valueFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
114
|
+
declare function PivotSkeleton({ rowFields, columnFields, valueFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, onReorderRowFields, onReorderColumnFields, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
115
115
|
|
|
116
116
|
interface ExcelGridOptions<T> {
|
|
117
117
|
data: T[];
|
package/dist/index.d.ts
CHANGED
|
@@ -111,7 +111,7 @@ interface PivotSkeletonProps {
|
|
|
111
111
|
onReorderRowFields: (fields: string[]) => void;
|
|
112
112
|
onReorderColumnFields: (fields: string[]) => void;
|
|
113
113
|
}
|
|
114
|
-
declare function PivotSkeleton({ rowFields, columnFields, valueFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
114
|
+
declare function PivotSkeleton({ rowFields, columnFields, valueFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, onReorderRowFields, onReorderColumnFields, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
115
115
|
|
|
116
116
|
interface ExcelGridOptions<T> {
|
|
117
117
|
data: T[];
|
package/dist/index.js
CHANGED
|
@@ -105,6 +105,7 @@ function useExcelGrid(options) {
|
|
|
105
105
|
const column = table.getColumn(columnId);
|
|
106
106
|
if (column) {
|
|
107
107
|
column.setFilterValue(values.length === 0 ? void 0 : values);
|
|
108
|
+
setColumnFilters(table.getState().columnFilters);
|
|
108
109
|
}
|
|
109
110
|
},
|
|
110
111
|
[table]
|
|
@@ -112,6 +113,7 @@ function useExcelGrid(options) {
|
|
|
112
113
|
const clearAllFilters = useCallback(() => {
|
|
113
114
|
table.resetColumnFilters();
|
|
114
115
|
setGlobalFilter("");
|
|
116
|
+
setColumnFilters([]);
|
|
115
117
|
}, [table]);
|
|
116
118
|
const getColumnFilterValues = useCallback(
|
|
117
119
|
(columnId) => {
|
|
@@ -1245,10 +1247,14 @@ function PivotSkeleton({
|
|
|
1245
1247
|
onAddColumnField,
|
|
1246
1248
|
onRemoveColumnField,
|
|
1247
1249
|
onAddValueField,
|
|
1248
|
-
onRemoveValueField
|
|
1250
|
+
onRemoveValueField,
|
|
1251
|
+
onReorderRowFields,
|
|
1252
|
+
onReorderColumnFields
|
|
1249
1253
|
}) {
|
|
1250
1254
|
const { showWatermark, canUsePivot, isDemo } = useLicense();
|
|
1251
1255
|
const [dragOverArea, setDragOverArea] = useState7(null);
|
|
1256
|
+
const [reorderDragSource, setReorderDragSource] = useState7(null);
|
|
1257
|
+
const [reorderDropTarget, setReorderDropTarget] = useState7(null);
|
|
1252
1258
|
const [sortDirection, setSortDirection] = useState7("asc");
|
|
1253
1259
|
const [sortTarget, setSortTarget] = useState7("row");
|
|
1254
1260
|
const toggleSort = useCallback7((target = "row") => {
|
|
@@ -1353,6 +1359,72 @@ function PivotSkeleton({
|
|
|
1353
1359
|
},
|
|
1354
1360
|
[rowFields, columnFields, valueFields, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField]
|
|
1355
1361
|
);
|
|
1362
|
+
const handleChipDragStart = useCallback7(
|
|
1363
|
+
(zone, index, event) => {
|
|
1364
|
+
setReorderDragSource({ zone, index });
|
|
1365
|
+
event.dataTransfer.effectAllowed = "move";
|
|
1366
|
+
event.dataTransfer.setData("text/plain", `reorder:${zone}:${index}`);
|
|
1367
|
+
requestAnimationFrame(() => {
|
|
1368
|
+
setDragOverArea(null);
|
|
1369
|
+
});
|
|
1370
|
+
},
|
|
1371
|
+
[]
|
|
1372
|
+
);
|
|
1373
|
+
const handleChipDragEnd = useCallback7(() => {
|
|
1374
|
+
setReorderDragSource(null);
|
|
1375
|
+
setReorderDropTarget(null);
|
|
1376
|
+
}, []);
|
|
1377
|
+
const handleChipDragOver = useCallback7(
|
|
1378
|
+
(zone, index, event) => {
|
|
1379
|
+
event.preventDefault();
|
|
1380
|
+
if (reorderDragSource && reorderDragSource.zone === zone) {
|
|
1381
|
+
event.dataTransfer.dropEffect = "move";
|
|
1382
|
+
setReorderDropTarget({ zone, index });
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
[reorderDragSource]
|
|
1386
|
+
);
|
|
1387
|
+
const handleChipDragLeave = useCallback7(() => {
|
|
1388
|
+
setReorderDropTarget(null);
|
|
1389
|
+
}, []);
|
|
1390
|
+
const handleChipDrop = useCallback7(
|
|
1391
|
+
(zone, targetIndex, event) => {
|
|
1392
|
+
event.preventDefault();
|
|
1393
|
+
event.stopPropagation();
|
|
1394
|
+
if (!reorderDragSource || reorderDragSource.zone !== zone) {
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
const sourceIndex = reorderDragSource.index;
|
|
1398
|
+
if (sourceIndex === targetIndex) {
|
|
1399
|
+
setReorderDragSource(null);
|
|
1400
|
+
setReorderDropTarget(null);
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
const fields = zone === "row" ? [...rowFields] : [...columnFields];
|
|
1404
|
+
const [movedField] = fields.splice(sourceIndex, 1);
|
|
1405
|
+
fields.splice(targetIndex, 0, movedField);
|
|
1406
|
+
if (zone === "row") {
|
|
1407
|
+
onReorderRowFields(fields);
|
|
1408
|
+
} else {
|
|
1409
|
+
onReorderColumnFields(fields);
|
|
1410
|
+
}
|
|
1411
|
+
setReorderDragSource(null);
|
|
1412
|
+
setReorderDropTarget(null);
|
|
1413
|
+
},
|
|
1414
|
+
[reorderDragSource, rowFields, columnFields, onReorderRowFields, onReorderColumnFields]
|
|
1415
|
+
);
|
|
1416
|
+
const isChipDragSource = useCallback7(
|
|
1417
|
+
(zone, index) => {
|
|
1418
|
+
return reorderDragSource?.zone === zone && reorderDragSource?.index === index;
|
|
1419
|
+
},
|
|
1420
|
+
[reorderDragSource]
|
|
1421
|
+
);
|
|
1422
|
+
const isChipDropTarget = useCallback7(
|
|
1423
|
+
(zone, index) => {
|
|
1424
|
+
return reorderDropTarget?.zone === zone && reorderDropTarget?.index === index;
|
|
1425
|
+
},
|
|
1426
|
+
[reorderDropTarget]
|
|
1427
|
+
);
|
|
1356
1428
|
const currentFontSize = fontSize;
|
|
1357
1429
|
return /* @__PURE__ */ jsxs3(
|
|
1358
1430
|
"div",
|
|
@@ -1451,17 +1523,34 @@ function PivotSkeleton({
|
|
|
1451
1523
|
/* @__PURE__ */ jsx3("span", { className: "vpg-zone-label", children: "Rows" })
|
|
1452
1524
|
] }),
|
|
1453
1525
|
/* @__PURE__ */ jsxs3("div", { className: "vpg-zone-chips", children: [
|
|
1454
|
-
rowFields.map((field) => /* @__PURE__ */ jsxs3(
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
"
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1526
|
+
rowFields.map((field, idx) => /* @__PURE__ */ jsxs3(
|
|
1527
|
+
"div",
|
|
1528
|
+
{
|
|
1529
|
+
className: `vpg-mini-chip vpg-row-chip ${isChipDragSource("row", idx) ? "vpg-chip-dragging" : ""} ${isChipDropTarget("row", idx) ? "vpg-chip-drop-target" : ""}`,
|
|
1530
|
+
draggable: true,
|
|
1531
|
+
onDragStart: (e) => handleChipDragStart("row", idx, e),
|
|
1532
|
+
onDragEnd: handleChipDragEnd,
|
|
1533
|
+
onDragOver: (e) => handleChipDragOver("row", idx, e),
|
|
1534
|
+
onDragLeave: handleChipDragLeave,
|
|
1535
|
+
onDrop: (e) => handleChipDrop("row", idx, e),
|
|
1536
|
+
children: [
|
|
1537
|
+
/* @__PURE__ */ jsx3("span", { className: "vpg-drag-handle", children: "\u22EE\u22EE" }),
|
|
1538
|
+
/* @__PURE__ */ jsx3("span", { className: "vpg-mini-name", children: field }),
|
|
1539
|
+
/* @__PURE__ */ jsx3(
|
|
1540
|
+
"button",
|
|
1541
|
+
{
|
|
1542
|
+
className: "vpg-mini-remove",
|
|
1543
|
+
onClick: (e) => {
|
|
1544
|
+
e.stopPropagation();
|
|
1545
|
+
onRemoveRowField(field);
|
|
1546
|
+
},
|
|
1547
|
+
children: "\xD7"
|
|
1548
|
+
}
|
|
1549
|
+
)
|
|
1550
|
+
]
|
|
1551
|
+
},
|
|
1552
|
+
field
|
|
1553
|
+
)),
|
|
1465
1554
|
rowFields.length === 0 && /* @__PURE__ */ jsx3("span", { className: "vpg-zone-hint", children: "Drop here" })
|
|
1466
1555
|
] })
|
|
1467
1556
|
]
|
|
@@ -1480,17 +1569,34 @@ function PivotSkeleton({
|
|
|
1480
1569
|
/* @__PURE__ */ jsx3("span", { className: "vpg-zone-label", children: "Columns" })
|
|
1481
1570
|
] }),
|
|
1482
1571
|
/* @__PURE__ */ jsxs3("div", { className: "vpg-zone-chips", children: [
|
|
1483
|
-
columnFields.map((field) => /* @__PURE__ */ jsxs3(
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
"
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1572
|
+
columnFields.map((field, idx) => /* @__PURE__ */ jsxs3(
|
|
1573
|
+
"div",
|
|
1574
|
+
{
|
|
1575
|
+
className: `vpg-mini-chip vpg-column-chip ${isChipDragSource("column", idx) ? "vpg-chip-dragging" : ""} ${isChipDropTarget("column", idx) ? "vpg-chip-drop-target" : ""}`,
|
|
1576
|
+
draggable: true,
|
|
1577
|
+
onDragStart: (e) => handleChipDragStart("column", idx, e),
|
|
1578
|
+
onDragEnd: handleChipDragEnd,
|
|
1579
|
+
onDragOver: (e) => handleChipDragOver("column", idx, e),
|
|
1580
|
+
onDragLeave: handleChipDragLeave,
|
|
1581
|
+
onDrop: (e) => handleChipDrop("column", idx, e),
|
|
1582
|
+
children: [
|
|
1583
|
+
/* @__PURE__ */ jsx3("span", { className: "vpg-drag-handle", children: "\u22EE\u22EE" }),
|
|
1584
|
+
/* @__PURE__ */ jsx3("span", { className: "vpg-mini-name", children: field }),
|
|
1585
|
+
/* @__PURE__ */ jsx3(
|
|
1586
|
+
"button",
|
|
1587
|
+
{
|
|
1588
|
+
className: "vpg-mini-remove",
|
|
1589
|
+
onClick: (e) => {
|
|
1590
|
+
e.stopPropagation();
|
|
1591
|
+
onRemoveColumnField(field);
|
|
1592
|
+
},
|
|
1593
|
+
children: "\xD7"
|
|
1594
|
+
}
|
|
1595
|
+
)
|
|
1596
|
+
]
|
|
1597
|
+
},
|
|
1598
|
+
field
|
|
1599
|
+
)),
|
|
1494
1600
|
columnFields.length === 0 && /* @__PURE__ */ jsx3("span", { className: "vpg-zone-hint", children: "Drop here" })
|
|
1495
1601
|
] })
|
|
1496
1602
|
]
|