@neasg/design-system 0.4.26 → 0.4.28

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,8 +276,11 @@ 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
285
  function DraggableColumnHead({ columnKey, disabled, hasResizeHandle, prevHasResizeHandle, isFirst, isLast, children, }) {
283
286
  const { attributes, listeners, setNodeRef, transform, transition, isDragging, } = useSortable({ id: columnKey, disabled });
@@ -651,10 +654,7 @@ function Table({ accessibleLabel, columns, rows, getRowKey, emptyState = (_jsx(E
651
654
  const prevColumn = columnIndex > 0 ? cols[columnIndex - 1] : undefined;
652
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));
653
656
  });
654
- if (!reorderableColumns) {
655
- return headers;
656
- }
657
- return (_jsx(DndContext, { sensors: columnReorderSensors, collisionDetection: closestCenter, onDragEnd: handleColumnDragEnd, children: _jsx(SortableContext, { items: reorderableColumnIds, strategy: horizontalListSortingStrategy, children: headers }) }));
657
+ return headers;
658
658
  }
659
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);
660
660
  const container = (_jsxs(TableContainer, { ref: tableContainerRef, role: stickyScrollState.scrollable ? "region" : undefined, "aria-label": stickyScrollState.scrollable
@@ -731,9 +731,10 @@ function Table({ accessibleLabel, columns, rows, getRowKey, emptyState = (_jsx(E
731
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 +
732
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));
733
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);
734
735
  if (!pagination) {
735
- return (_jsxs("div", { className: "space-y-4", children: [toolbar, container] }));
736
+ return (_jsxs("div", { className: "space-y-4", children: [toolbar, reorderableContainer] }));
736
737
  }
737
- 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 })] }));
738
739
  }
739
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.26",
3
+ "version": "0.4.28",
4
4
  "description": "NEA shared design system primitives, theme tokens, and Storybook docs.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",