@neasg/design-system 0.4.25 → 0.4.26
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/table.js +11 -3
- package/package.json +1 -1
package/dist/table.js
CHANGED
|
@@ -279,7 +279,7 @@ function SortableTableHead({ ref, field, children, currentSortField, currentSort
|
|
|
279
279
|
: "whitespace-nowrap", align === "right" && "ml-auto justify-end", align === "center" && "mx-auto justify-center"), style: { font: "inherit", color: "inherit", fontWeight: 500 }, "aria-label": `Sort by ${resolvedSortLabel}`, children: [_jsx("span", { className: cn("min-w-0", containOverflow && !allowWrap && "truncate", containOverflow && allowWrap && "break-words [overflow-wrap:anywhere]"), children: children }), _jsx("span", { "aria-hidden": "true", className: "inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center", children: isSorted ? (currentSortDirection === "asc" ? (_jsx(ArrowUpIcon, { className: "shrink-0", size: 14 })) : (_jsx(ArrowDownIcon, { className: "shrink-0", size: 14 }))) : (_jsx(ArrowUpDown, { className: "h-3.5 w-3.5 shrink-0 opacity-50" })) })] }), resizeHandle] }));
|
|
280
280
|
}
|
|
281
281
|
const DragGripIcon = (_jsx("span", { "aria-hidden": "true", className: "pointer-events-none absolute bottom-0 left-1/2 z-20 -translate-x-1/2 translate-y-1/2 rounded border border-border bg-background px-1.5 py-0.5 text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover/drag-col:opacity-100", children: _jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { transform: "rotate(90deg)" }, children: [_jsx("circle", { cx: "9", cy: "5", r: "1" }), _jsx("circle", { cx: "15", cy: "5", r: "1" }), _jsx("circle", { cx: "9", cy: "12", r: "1" }), _jsx("circle", { cx: "15", cy: "12", r: "1" }), _jsx("circle", { cx: "9", cy: "19", r: "1" }), _jsx("circle", { cx: "15", cy: "19", r: "1" })] }) }));
|
|
282
|
-
function DraggableColumnHead({ columnKey, disabled, children, }) {
|
|
282
|
+
function DraggableColumnHead({ columnKey, disabled, hasResizeHandle, prevHasResizeHandle, isFirst, isLast, children, }) {
|
|
283
283
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging, } = useSortable({ id: columnKey, disabled });
|
|
284
284
|
return children({
|
|
285
285
|
ref: setNodeRef,
|
|
@@ -289,7 +289,14 @@ function DraggableColumnHead({ columnKey, disabled, children, }) {
|
|
|
289
289
|
zIndex: isDragging ? 30 : undefined,
|
|
290
290
|
},
|
|
291
291
|
className: cn(!disabled &&
|
|
292
|
-
"group/drag-col relative !overflow-visible cursor-grab active:cursor-grabbing
|
|
292
|
+
"group/drag-col relative !overflow-visible cursor-grab active:cursor-grabbing", !disabled &&
|
|
293
|
+
!hasResizeHandle &&
|
|
294
|
+
!isLast &&
|
|
295
|
+
"after:pointer-events-none after:absolute after:right-0 after:top-1/2 after:z-[1] after:h-6 after:-translate-y-1/2 after:w-px after:rounded-full after:bg-transparent after:transition-colors hover:after:bg-[hsl(var(--table-border))]", !disabled &&
|
|
296
|
+
!hasResizeHandle &&
|
|
297
|
+
!prevHasResizeHandle &&
|
|
298
|
+
!isFirst &&
|
|
299
|
+
"before:pointer-events-none before:absolute before:left-0 before:top-1/2 before:z-[1] before:h-6 before:-translate-y-1/2 before:w-px before:rounded-full before:bg-transparent before:transition-colors hover:before:bg-[hsl(var(--table-border))]", isDragging && "z-10 opacity-90 shadow-lg"),
|
|
293
300
|
gripIcon: disabled ? null : DragGripIcon,
|
|
294
301
|
dragHandleProps: disabled ? {} : { ...attributes, ...listeners },
|
|
295
302
|
});
|
|
@@ -641,7 +648,8 @@ function Table({ accessibleLabel, columns, rows, getRowKey, emptyState = (_jsx(E
|
|
|
641
648
|
if (!reorderableColumns) {
|
|
642
649
|
return renderColumnHead(column, columnIndex);
|
|
643
650
|
}
|
|
644
|
-
|
|
651
|
+
const prevColumn = columnIndex > 0 ? cols[columnIndex - 1] : undefined;
|
|
652
|
+
return (_jsx(DraggableColumnHead, { columnKey: column.key, disabled: Boolean(column.sticky), hasResizeHandle: Boolean(renderResizeHandle(column, columnIndex)), prevHasResizeHandle: Boolean(prevColumn && renderResizeHandle(prevColumn, columnIndex - 1)), isFirst: columnIndex === 0, isLast: columnIndex === cols.length - 1, children: (dragProps) => renderColumnHead(column, columnIndex, dragProps) }, column.key));
|
|
645
653
|
});
|
|
646
654
|
if (!reorderableColumns) {
|
|
647
655
|
return headers;
|