@ai-matrx/design-system 0.18.0 → 0.18.1
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/CHANGELOG.md +11 -0
- package/dist/data-table/index.cjs +113 -78
- package/dist/data-table/index.cjs.map +1 -1
- package/dist/data-table/index.js +107 -68
- package/dist/data-table/index.js.map +1 -1
- package/package.json +1 -1
package/dist/data-table/index.js
CHANGED
|
@@ -427,7 +427,7 @@ import {
|
|
|
427
427
|
PointerSensor,
|
|
428
428
|
pointerWithin,
|
|
429
429
|
useDndMonitor as useDndMonitor2,
|
|
430
|
-
useDraggable as
|
|
430
|
+
useDraggable as useDraggable3,
|
|
431
431
|
useDroppable as useDroppable2,
|
|
432
432
|
useSensor,
|
|
433
433
|
useSensors
|
|
@@ -4022,7 +4022,12 @@ import {
|
|
|
4022
4022
|
} from "@ai-matrx/kit/url-state";
|
|
4023
4023
|
|
|
4024
4024
|
// src/data-table/ColumnHeaderCell.tsx
|
|
4025
|
-
import {
|
|
4025
|
+
import {
|
|
4026
|
+
useEffect as useEffect6,
|
|
4027
|
+
useMemo as useMemo3,
|
|
4028
|
+
useState as useState9
|
|
4029
|
+
} from "react";
|
|
4030
|
+
import { useDraggable } from "@dnd-kit/core";
|
|
4026
4031
|
|
|
4027
4032
|
// src/popover.tsx
|
|
4028
4033
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
@@ -4232,8 +4237,29 @@ function ColumnHeaderCell({
|
|
|
4232
4237
|
filterShowCancel = false,
|
|
4233
4238
|
filterFooterHint,
|
|
4234
4239
|
allowNegation = false,
|
|
4235
|
-
allowNullModes = false
|
|
4240
|
+
allowNullModes = false,
|
|
4241
|
+
reorderColumn
|
|
4236
4242
|
}) {
|
|
4243
|
+
const reorderEnabled = reorderColumn !== void 0;
|
|
4244
|
+
const { attributes: reorderAttributes, listeners: reorderListeners, setNodeRef } = useDraggable(
|
|
4245
|
+
reorderColumn ? {
|
|
4246
|
+
id: `matrx-column-header:${reorderColumn.id}`,
|
|
4247
|
+
data: { matrxDragKind: "column-header", columnId: reorderColumn.id },
|
|
4248
|
+
disabled: false
|
|
4249
|
+
} : {
|
|
4250
|
+
id: `matrx-column-header:inactive:${labelText ?? "column"}`,
|
|
4251
|
+
disabled: true
|
|
4252
|
+
}
|
|
4253
|
+
);
|
|
4254
|
+
const reorderLabel = reorderColumn?.label ?? labelText ?? "column";
|
|
4255
|
+
const reorderActivator = reorderEnabled ? {
|
|
4256
|
+
...reorderAttributes,
|
|
4257
|
+
...reorderListeners,
|
|
4258
|
+
ref: setNodeRef,
|
|
4259
|
+
title: `Drag to reorder ${reorderLabel}.`,
|
|
4260
|
+
"aria-description": "Drag this column label to reorder it."
|
|
4261
|
+
} : void 0;
|
|
4262
|
+
const reorderClass = reorderEnabled ? "touch-none cursor-grab active:cursor-grabbing" : void 0;
|
|
4237
4263
|
const filterActive = isColumnFilterActive(filterValue);
|
|
4238
4264
|
const deferredFilter = filterApplyLabel !== void 0 || filterShowCancel || filterFooterHint !== void 0;
|
|
4239
4265
|
const [filterOpen, setFilterOpen] = useState9(false);
|
|
@@ -4377,7 +4403,21 @@ function ColumnHeaderCell({
|
|
|
4377
4403
|
);
|
|
4378
4404
|
if (compact) {
|
|
4379
4405
|
if (!sortable && !filterKind) {
|
|
4380
|
-
|
|
4406
|
+
if (!reorderEnabled) {
|
|
4407
|
+
return /* @__PURE__ */ jsx25("div", { className: cn("flex items-center justify-center", className), children: label });
|
|
4408
|
+
}
|
|
4409
|
+
return /* @__PURE__ */ jsx25("div", { className: cn("flex items-center justify-center", className), children: /* @__PURE__ */ jsx25(
|
|
4410
|
+
"button",
|
|
4411
|
+
{
|
|
4412
|
+
type: "button",
|
|
4413
|
+
...reorderActivator,
|
|
4414
|
+
className: cn(
|
|
4415
|
+
"inline-flex items-center justify-center rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",
|
|
4416
|
+
reorderClass
|
|
4417
|
+
),
|
|
4418
|
+
children: label
|
|
4419
|
+
}
|
|
4420
|
+
) });
|
|
4381
4421
|
}
|
|
4382
4422
|
return /* @__PURE__ */ jsx25(
|
|
4383
4423
|
"div",
|
|
@@ -4394,9 +4434,13 @@ function ColumnHeaderCell({
|
|
|
4394
4434
|
type: "button",
|
|
4395
4435
|
"aria-label": menuLabel,
|
|
4396
4436
|
title: menuLabel,
|
|
4397
|
-
onClick: (
|
|
4437
|
+
onClick: (event) => {
|
|
4438
|
+
event.stopPropagation();
|
|
4439
|
+
},
|
|
4440
|
+
...reorderActivator,
|
|
4398
4441
|
className: cn(
|
|
4399
4442
|
"relative inline-flex items-center justify-center rounded p-0.5 transition-colors",
|
|
4443
|
+
reorderClass,
|
|
4400
4444
|
isSorted || filterActive ? "text-foreground" : "text-muted-foreground hover:text-foreground"
|
|
4401
4445
|
),
|
|
4402
4446
|
children: [
|
|
@@ -4432,8 +4476,10 @@ function ColumnHeaderCell({
|
|
|
4432
4476
|
{
|
|
4433
4477
|
type: "button",
|
|
4434
4478
|
onClick: onHeaderSortClick,
|
|
4479
|
+
...reorderActivator,
|
|
4435
4480
|
className: cn(
|
|
4436
4481
|
"inline-flex min-w-0 items-center gap-1 rounded px-0.5 py-0.5 text-left text-xs font-semibold uppercase tracking-wide transition-colors",
|
|
4482
|
+
reorderClass,
|
|
4437
4483
|
isSorted ? "text-foreground" : "text-muted-foreground hover:text-foreground"
|
|
4438
4484
|
),
|
|
4439
4485
|
children: [
|
|
@@ -4441,6 +4487,17 @@ function ColumnHeaderCell({
|
|
|
4441
4487
|
isSorted ? sortDirection === "asc" ? /* @__PURE__ */ jsx25(ArrowUp, { className: "h-3 w-3 shrink-0 text-primary" }) : /* @__PURE__ */ jsx25(ArrowDown, { className: "h-3 w-3 shrink-0 text-primary" }) : /* @__PURE__ */ jsx25(ArrowUpDown, { className: "h-3 w-3 shrink-0 opacity-40" })
|
|
4442
4488
|
]
|
|
4443
4489
|
}
|
|
4490
|
+
) : reorderEnabled ? /* @__PURE__ */ jsx25(
|
|
4491
|
+
"button",
|
|
4492
|
+
{
|
|
4493
|
+
type: "button",
|
|
4494
|
+
...reorderActivator,
|
|
4495
|
+
className: cn(
|
|
4496
|
+
"min-w-0 truncate rounded px-0.5 py-0.5 text-left text-xs font-semibold uppercase tracking-wide text-muted-foreground hover:text-foreground",
|
|
4497
|
+
reorderClass
|
|
4498
|
+
),
|
|
4499
|
+
children: label
|
|
4500
|
+
}
|
|
4444
4501
|
) : /* @__PURE__ */ jsx25("span", { className: "truncate text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: label }),
|
|
4445
4502
|
filterKind ? /* @__PURE__ */ jsxs17("div", { className: "inline-flex items-center", children: [
|
|
4446
4503
|
/* @__PURE__ */ jsxs17(Popover, { open: filterOpen, onOpenChange: setFilterOpen, children: [
|
|
@@ -4763,7 +4820,7 @@ function parseOptionalNumber(raw) {
|
|
|
4763
4820
|
|
|
4764
4821
|
// src/data-table/ColumnManager.tsx
|
|
4765
4822
|
import { useEffect as useEffect7, useMemo as useMemo4, useState as useState10 } from "react";
|
|
4766
|
-
import { useDndMonitor, useDraggable, useDroppable } from "@dnd-kit/core";
|
|
4823
|
+
import { useDndMonitor, useDraggable as useDraggable2, useDroppable } from "@dnd-kit/core";
|
|
4767
4824
|
init_filter_engine();
|
|
4768
4825
|
import { jsx as jsx26, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4769
4826
|
function ColumnManager({
|
|
@@ -4938,7 +4995,7 @@ function ColumnManagerDropTarget({
|
|
|
4938
4995
|
return /* @__PURE__ */ jsx26("div", { ref: setNodeRef, "data-matrx-column-manager-drop-target": id, className, children });
|
|
4939
4996
|
}
|
|
4940
4997
|
function ColumnManagerDragHandle({ id, label }) {
|
|
4941
|
-
const { attributes, listeners, setNodeRef } =
|
|
4998
|
+
const { attributes, listeners, setNodeRef } = useDraggable2({
|
|
4942
4999
|
id: `matrx-column-manager:${id}`,
|
|
4943
5000
|
data: { matrxDragKind: "column-manager", columnId: id }
|
|
4944
5001
|
});
|
|
@@ -6566,6 +6623,7 @@ function MatrxDataTableWithUrlState({
|
|
|
6566
6623
|
}
|
|
6567
6624
|
);
|
|
6568
6625
|
}
|
|
6626
|
+
var COLUMN_REORDER_ACTIVATION_DISTANCE = 6;
|
|
6569
6627
|
function MatrxDataTableCore({
|
|
6570
6628
|
data: suppliedData,
|
|
6571
6629
|
columns,
|
|
@@ -6638,7 +6696,9 @@ function MatrxDataTableCore({
|
|
|
6638
6696
|
const [internalSearch, setInternalSearch] = useState15("");
|
|
6639
6697
|
const [draggedRowId, setDraggedRowId] = useState15(null);
|
|
6640
6698
|
const hierarchySensors = useSensors(
|
|
6641
|
-
useSensor(PointerSensor, {
|
|
6699
|
+
useSensor(PointerSensor, {
|
|
6700
|
+
activationConstraint: { distance: COLUMN_REORDER_ACTIVATION_DISTANCE }
|
|
6701
|
+
})
|
|
6642
6702
|
);
|
|
6643
6703
|
const toolbarSearchControlled = toolbar?.searchValue !== void 0;
|
|
6644
6704
|
const searchValue = controlledQuery ? controlledQuery.state.search : toolbarSearchControlled ? toolbar?.searchValue ?? "" : internalSearch;
|
|
@@ -7696,6 +7756,7 @@ function MatrxDataTableCore({
|
|
|
7696
7756
|
size: "sm",
|
|
7697
7757
|
className: "h-7 gap-1 px-2 text-xs text-muted-foreground",
|
|
7698
7758
|
onClick: clearAllFilters,
|
|
7759
|
+
"aria-label": "Clear all filters",
|
|
7699
7760
|
title: "Clear all filters",
|
|
7700
7761
|
children: [
|
|
7701
7762
|
/* @__PURE__ */ jsx35(Eraser, { className: "h-3.5 w-3.5" }),
|
|
@@ -8054,45 +8115,43 @@ function MatrxDataTableCore({
|
|
|
8054
8115
|
col.align === "right" && "text-right"
|
|
8055
8116
|
),
|
|
8056
8117
|
style: columnWidthVar(col.width),
|
|
8057
|
-
children: /* @__PURE__ */
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
}
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
)
|
|
8095
|
-
] })
|
|
8118
|
+
children: /* @__PURE__ */ jsx35(ColumnHeaderDropZone, { id, enabled: reorderableColumns, children: /* @__PURE__ */ jsx35(
|
|
8119
|
+
ColumnHeaderCell,
|
|
8120
|
+
{
|
|
8121
|
+
label: col.header,
|
|
8122
|
+
labelText: headerLabel,
|
|
8123
|
+
sortable: col.sortable !== false,
|
|
8124
|
+
isSorted: Boolean(isSorted),
|
|
8125
|
+
sortDirection: sort?.direction ?? defaultSortDirection,
|
|
8126
|
+
onSortAsc: () => setSort({ id, direction: "asc" }),
|
|
8127
|
+
onSortDesc: () => setSort({ id, direction: "desc" }),
|
|
8128
|
+
onClearSort: () => setSort(null),
|
|
8129
|
+
onHeaderSortClick: () => {
|
|
8130
|
+
if (!isSorted) {
|
|
8131
|
+
setSort({ id, direction: defaultSortDirection });
|
|
8132
|
+
return;
|
|
8133
|
+
}
|
|
8134
|
+
if (sort?.direction === "asc") {
|
|
8135
|
+
setSort({ id, direction: "desc" });
|
|
8136
|
+
return;
|
|
8137
|
+
}
|
|
8138
|
+
setSort(null);
|
|
8139
|
+
},
|
|
8140
|
+
filterKind: meta?.kind ?? null,
|
|
8141
|
+
filterValue: columnFilters[id],
|
|
8142
|
+
onFilterChange: (next) => setColumnFilter(id, next),
|
|
8143
|
+
selectOptions: meta?.options,
|
|
8144
|
+
selectSingle: col.filterSingle,
|
|
8145
|
+
filterApplyLabel: filterUi?.applyLabel,
|
|
8146
|
+
filterShowCancel: filterUi?.showCancel,
|
|
8147
|
+
filterFooterHint: filterUi?.footerHint,
|
|
8148
|
+
allowNegation: filterUi?.allowNegation,
|
|
8149
|
+
allowNullModes: filterUi?.allowNullModes,
|
|
8150
|
+
align: col.align,
|
|
8151
|
+
compact: col.compact,
|
|
8152
|
+
reorderColumn: reorderableColumns ? { id, label: headerLabel } : void 0
|
|
8153
|
+
}
|
|
8154
|
+
) })
|
|
8096
8155
|
},
|
|
8097
8156
|
id
|
|
8098
8157
|
);
|
|
@@ -8683,7 +8742,7 @@ function HierarchyDragHandle({
|
|
|
8683
8742
|
label,
|
|
8684
8743
|
disabled
|
|
8685
8744
|
}) {
|
|
8686
|
-
const { attributes, listeners, setNodeRef } =
|
|
8745
|
+
const { attributes, listeners, setNodeRef } = useDraggable3({
|
|
8687
8746
|
id,
|
|
8688
8747
|
disabled
|
|
8689
8748
|
});
|
|
@@ -8851,26 +8910,6 @@ function ColumnHeaderDropZone({
|
|
|
8851
8910
|
});
|
|
8852
8911
|
return /* @__PURE__ */ jsx35("div", { ref: setNodeRef, className: "flex min-w-0 items-center", children });
|
|
8853
8912
|
}
|
|
8854
|
-
function ColumnReorderHandle({ id, label }) {
|
|
8855
|
-
const { attributes, listeners, setNodeRef } = useDraggable2({
|
|
8856
|
-
id: `matrx-column-header:${id}`,
|
|
8857
|
-
data: { matrxDragKind: "column-header", columnId: id }
|
|
8858
|
-
});
|
|
8859
|
-
return /* @__PURE__ */ jsx35(
|
|
8860
|
-
"button",
|
|
8861
|
-
{
|
|
8862
|
-
ref: setNodeRef,
|
|
8863
|
-
type: "button",
|
|
8864
|
-
className: "mr-1 flex h-7 w-5 shrink-0 touch-none cursor-grab items-center justify-center text-muted-foreground hover:text-foreground active:cursor-grabbing",
|
|
8865
|
-
"aria-label": `Reorder ${label}`,
|
|
8866
|
-
title: `Drag to reorder ${label}`,
|
|
8867
|
-
onClick: (event) => event.stopPropagation(),
|
|
8868
|
-
...attributes,
|
|
8869
|
-
...listeners,
|
|
8870
|
-
children: /* @__PURE__ */ jsx35(GripVertical, { className: "h-3.5 w-3.5" })
|
|
8871
|
-
}
|
|
8872
|
-
);
|
|
8873
|
-
}
|
|
8874
8913
|
function columnWidthVar(width) {
|
|
8875
8914
|
if (width === void 0) return void 0;
|
|
8876
8915
|
return {
|