@neasg/design-system 0.4.25 → 0.4.27

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.d.ts CHANGED
@@ -123,13 +123,12 @@ export interface TableRowExpansionProps<Row> {
123
123
  /** Accessible label for a row's expansion toggle. */
124
124
  getToggleLabel?: (row: Row, rowIndex: number, expanded: boolean) => string;
125
125
  }
126
- interface SortableTableHeadProps<T extends string> {
127
- ref?: React.Ref<HTMLTableCellElement>;
128
- field: T;
126
+ interface SortableTableHeadProps extends Omit<React.ThHTMLAttributes<HTMLTableCellElement>, "children" | "style"> {
127
+ field: string;
129
128
  children: React.ReactNode;
130
- currentSortField: T | null;
129
+ currentSortField: string | null;
131
130
  currentSortDirection: SortDirection;
132
- onSort: (field: T) => void;
131
+ onSort: (field: string) => void;
133
132
  className?: string;
134
133
  style?: React.CSSProperties;
135
134
  allowWrap?: boolean;
@@ -142,9 +141,8 @@ interface SortableTableHeadProps<T extends string> {
142
141
  treatWidthAsMinWidth?: boolean;
143
142
  containOverflow?: boolean;
144
143
  gripIcon?: React.ReactNode;
145
- [key: string]: unknown;
146
144
  }
147
- declare function SortableTableHead<T extends string>({ ref, field, children, currentSortField, currentSortDirection, onSort, className, style, allowWrap, width, minWidth, maxWidth, align, sortLabel, resizeHandle, treatWidthAsMinWidth, containOverflow, gripIcon, ...rest }: SortableTableHeadProps<T>): import("react/jsx-runtime").JSX.Element;
145
+ declare const SortableTableHead: React.ForwardRefExoticComponent<SortableTableHeadProps & React.RefAttributes<HTMLTableCellElement>>;
148
146
  export interface TableColumnResizeHandleRenderProps<Row> {
149
147
  column: TableColumn<Row>;
150
148
  nextColumn: TableColumn<Row>;
package/dist/table.js CHANGED
@@ -265,7 +265,7 @@ export const TABLE_SKELETON_PRESETS = {
265
265
  })),
266
266
  }),
267
267
  };
268
- function SortableTableHead({ ref, field, children, currentSortField, currentSortDirection, onSort, className, style, allowWrap = false, width, minWidth, maxWidth, align, sortLabel, resizeHandle, treatWidthAsMinWidth, containOverflow, gripIcon, ...rest }) {
268
+ const SortableTableHead = React.forwardRef(function SortableTableHead({ field, children, currentSortField, currentSortDirection, onSort, className, style, allowWrap = false, width, minWidth, maxWidth, align, sortLabel, resizeHandle, treatWidthAsMinWidth, containOverflow, gripIcon, ...rest }, ref) {
269
269
  const isSorted = currentSortField === field;
270
270
  const resolvedSortLabel = sortLabel !== null && sortLabel !== void 0 ? sortLabel : (typeof children === "string" || typeof children === "number"
271
271
  ? String(children)
@@ -276,10 +276,13 @@ function SortableTableHead({ ref, field, children, currentSortField, currentSort
276
276
  : "descending"
277
277
  : undefined, className: cn(resizeHandle && "relative", alignClassName(align), className), style: style, wrap: allowWrap, width: width, minWidth: minWidth, maxWidth: maxWidth, treatWidthAsMinWidth: treatWidthAsMinWidth, containOverflow: containOverflow, ...rest, children: [gripIcon, _jsxs("button", { type: "button", onClick: () => onSort(field), className: cn("-ml-1.5 flex h-7 cursor-pointer items-center gap-1 rounded px-1.5 py-0 font-medium transition-colors hover:text-foreground", containOverflow && "max-w-full overflow-hidden", allowWrap
278
278
  ? "max-w-full whitespace-normal text-left"
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
- }
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 &&
280
+ allowWrap &&
281
+ "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] }));
282
+ });
283
+ SortableTableHead.displayName = "SortableTableHead";
281
284
  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, }) {
285
+ function DraggableColumnHead({ columnKey, disabled, hasResizeHandle, prevHasResizeHandle, isFirst, isLast, children, }) {
283
286
  const { attributes, listeners, setNodeRef, transform, transition, isDragging, } = useSortable({ id: columnKey, disabled });
284
287
  return children({
285
288
  ref: setNodeRef,
@@ -289,7 +292,14 @@ function DraggableColumnHead({ columnKey, disabled, children, }) {
289
292
  zIndex: isDragging ? 30 : undefined,
290
293
  },
291
294
  className: cn(!disabled &&
292
- "group/drag-col relative !overflow-visible cursor-grab active:cursor-grabbing 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))] 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))]", isDragging && "z-10 opacity-90 shadow-lg"),
295
+ "group/drag-col relative !overflow-visible cursor-grab active:cursor-grabbing", !disabled &&
296
+ !hasResizeHandle &&
297
+ !isLast &&
298
+ "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 &&
299
+ !hasResizeHandle &&
300
+ !prevHasResizeHandle &&
301
+ !isFirst &&
302
+ "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
303
  gripIcon: disabled ? null : DragGripIcon,
294
304
  dragHandleProps: disabled ? {} : { ...attributes, ...listeners },
295
305
  });
@@ -641,12 +651,10 @@ function Table({ accessibleLabel, columns, rows, getRowKey, emptyState = (_jsx(E
641
651
  if (!reorderableColumns) {
642
652
  return renderColumnHead(column, columnIndex);
643
653
  }
644
- return (_jsx(DraggableColumnHead, { columnKey: column.key, disabled: Boolean(column.sticky), children: (dragProps) => renderColumnHead(column, columnIndex, dragProps) }, column.key));
654
+ const prevColumn = columnIndex > 0 ? cols[columnIndex - 1] : undefined;
655
+ 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
656
  });
646
- if (!reorderableColumns) {
647
- return headers;
648
- }
649
- return (_jsx(DndContext, { sensors: columnReorderSensors, collisionDetection: closestCenter, onDragEnd: handleColumnDragEnd, children: _jsx(SortableContext, { items: reorderableColumnIds, strategy: horizontalListSortingStrategy, children: headers }) }));
657
+ return headers;
650
658
  }
651
659
  const resolvedEmptyState = centerEmptyState ? (_jsx("div", { "data-slot": "table-empty-state", className: "flex w-full min-w-0 items-center justify-center whitespace-normal text-center [&>*]:mx-auto", style: { minHeight: emptyStateMinHeight }, children: emptyState })) : (emptyState);
652
660
  const container = (_jsxs(TableContainer, { ref: tableContainerRef, role: stickyScrollState.scrollable ? "region" : undefined, "aria-label": stickyScrollState.scrollable
@@ -723,9 +731,10 @@ function Table({ accessibleLabel, columns, rows, getRowKey, emptyState = (_jsx(E
723
731
  })] }), isExpanded ? (_jsx(TableRow, { id: expandedContentId, "data-slot": "table-expanded-row", className: "bg-[hsl(var(--table-row-striped-background))] hover:bg-[hsl(var(--table-row-striped-background))]", children: _jsx(TableCell, { colSpan: Math.max(visibleColumns.length +
724
732
  (hasExpansionColumn ? 1 : 0), 1), className: "h-auto whitespace-normal p-4", children: rowExpansion === null || rowExpansion === void 0 ? void 0 : rowExpansion.renderExpandedContent(row, rowIndex) }) })) : null] }, rowKey));
725
733
  })) : (_jsx(TableRow, { className: "cursor-default hover:bg-card", children: _jsx(TableCell, { colSpan: Math.max(visibleColumns.length + (hasExpansionColumn ? 1 : 0), 1), className: "p-6", children: resolvedEmptyState }) })) })] }), _jsx("div", { role: "status", className: "sr-only", children: loading ? loadingLabel : null })] }));
734
+ const reorderableContainer = reorderableColumns ? (_jsx(DndContext, { sensors: columnReorderSensors, collisionDetection: closestCenter, onDragEnd: handleColumnDragEnd, children: _jsx(SortableContext, { items: reorderableColumnIds, strategy: horizontalListSortingStrategy, children: container }) })) : (container);
726
735
  if (!pagination) {
727
- return (_jsxs("div", { className: "space-y-4", children: [toolbar, container] }));
736
+ return (_jsxs("div", { className: "space-y-4", children: [toolbar, reorderableContainer] }));
728
737
  }
729
- return (_jsxs("div", { className: "space-y-4", children: [toolbar, container, _jsx(Pagination, { ...pagination })] }));
738
+ return (_jsxs("div", { className: "space-y-4", children: [toolbar, reorderableContainer, _jsx(Pagination, { ...pagination })] }));
730
739
  }
731
740
  export { Table, TableRoot, TableContainer, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableRowHeader, TableCaption, SortableTableHead, TableRowSkeleton, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neasg/design-system",
3
- "version": "0.4.25",
3
+ "version": "0.4.27",
4
4
  "description": "NEA shared design system primitives, theme tokens, and Storybook docs.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",