@shipfox/react-ui 0.24.0 → 0.25.0

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.
@@ -38,8 +38,9 @@ type ModalBodyHeaderProps = ComponentProps<'div'> & {
38
38
  alt?: string;
39
39
  title: string;
40
40
  description?: ReactNode;
41
+ children?: ReactNode;
41
42
  };
42
- declare function ModalBodyHeader({ className, src, alt, title, description, ...props }: ModalBodyHeaderProps): import("react/jsx-runtime").JSX.Element;
43
+ declare function ModalBodyHeader({ className, src, alt, title, description, children, ...props }: ModalBodyHeaderProps): import("react/jsx-runtime").JSX.Element;
43
44
  export { Modal, ModalPortal, ModalOverlay, ModalTrigger, ModalClose, ModalContent, ModalHeader, ModalBody, ModalFooter, ModalBodyHeader, ModalTitle, ModalDescription, modalContentVariants, modalOverlayVariants, modalDefaultTransition, };
44
45
  export type { ModalContentProps, ModalHeaderProps, ModalOverlayProps, ModalTitleProps, ModalDescriptionProps, ModalBodyHeaderProps, };
45
46
  //# sourceMappingURL=modal.d.ts.map
@@ -259,7 +259,7 @@ function ModalDescription({ className, ...props }) {
259
259
  ...props
260
260
  });
261
261
  }
262
- function ModalBodyHeader({ className, src, alt = '', title, description, ...props }) {
262
+ function ModalBodyHeader({ className, src, alt = '', title, description, children, ...props }) {
263
263
  return /*#__PURE__*/ _jsxs("div", {
264
264
  className: cn('flex flex-col gap-32 items-start max-w-xl', className),
265
265
  ...props,
@@ -283,7 +283,8 @@ function ModalBodyHeader({ className, src, alt = '', title, description, ...prop
283
283
  children: description
284
284
  })
285
285
  ]
286
- })
286
+ }),
287
+ children
287
288
  ]
288
289
  });
289
290
  }
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
3
3
  import { Card, CardContent } from '../../components/card/index.js';
4
4
  import { Checkbox } from '../../components/checkbox/index.js';
@@ -85,7 +85,18 @@ export function DataTable({ columns, data, pagination = true, pageSize = 10, pag
85
85
  pagination: pagination ? paginationState : undefined
86
86
  }
87
87
  });
88
- const skeletonRowCount = pageSize > 5 ? 5 : pageSize;
88
+ const rowModel = table.getRowModel();
89
+ const rowCount = rowModel.rows.length;
90
+ const hasRows = rowCount > 0;
91
+ const currentPageSize = pagination ? paginationState.pageSize : pageSize;
92
+ const skeletonRowCount = currentPageSize > 5 ? 5 : currentPageSize;
93
+ const headerHeight = 40;
94
+ const rowHeight = 46;
95
+ const paginationHeight = 52.5;
96
+ const rowsForHeight = hasRows ? currentPageSize : 5;
97
+ const shouldShowPagination = pagination && hasRows;
98
+ const minTableHeight = pagination ? headerHeight + rowsForHeight * rowHeight + (shouldShowPagination ? paginationHeight : 0) : undefined;
99
+ const emptyRowCount = pagination && hasRows ? Math.max(0, currentPageSize - rowCount) : 0;
89
100
  if (isLoading) {
90
101
  return /*#__PURE__*/ _jsx(Card, {
91
102
  className: cn('p-0 gap-0', className),
@@ -93,6 +104,9 @@ export function DataTable({ columns, data, pagination = true, pageSize = 10, pag
93
104
  children: /*#__PURE__*/ _jsx(CardContent, {
94
105
  className: "overflow-hidden p-0",
95
106
  children: /*#__PURE__*/ _jsxs(Table, {
107
+ style: minTableHeight ? {
108
+ minHeight: `${minTableHeight}px`
109
+ } : undefined,
96
110
  children: [
97
111
  /*#__PURE__*/ _jsx(TableHeader, {
98
112
  children: /*#__PURE__*/ _jsx(TableRow, {
@@ -127,8 +141,11 @@ export function DataTable({ columns, data, pagination = true, pageSize = 10, pag
127
141
  children: /*#__PURE__*/ _jsx(CardContent, {
128
142
  className: "overflow-hidden p-0",
129
143
  children: /*#__PURE__*/ _jsxs(Table, {
144
+ style: minTableHeight ? {
145
+ minHeight: `${minTableHeight}px`
146
+ } : undefined,
130
147
  children: [
131
- table.getRowModel().rows.length > 0 ? /*#__PURE__*/ _jsx(TableHeader, {
148
+ hasRows ? /*#__PURE__*/ _jsx(TableHeader, {
132
149
  children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ _jsx(TableRow, {
133
150
  className: "hover:bg-transparent border-b",
134
151
  children: headerGroup.headers.map((header)=>/*#__PURE__*/ _jsx(TableHead, {
@@ -137,32 +154,50 @@ export function DataTable({ columns, data, pagination = true, pageSize = 10, pag
137
154
  }, headerGroup.id))
138
155
  }) : null,
139
156
  /*#__PURE__*/ _jsx(TableBody, {
140
- children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row)=>/*#__PURE__*/ _jsx(TableRow, {
141
- onClick: ()=>onRowClick?.(row.original),
142
- "data-selected": row.getIsSelected(),
143
- className: onRowClick ? 'cursor-pointer' : '',
144
- tabIndex: onRowClick ? 0 : undefined,
145
- role: onRowClick ? 'button' : undefined,
146
- onKeyDown: (event)=>{
147
- if (!onRowClick) return;
148
- if (event.key === 'Enter' || event.key === ' ') {
149
- event.preventDefault();
150
- onRowClick(row.original);
151
- }
152
- },
153
- children: row.getVisibleCells().map((cell)=>/*#__PURE__*/ _jsx(TableCell, {
154
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
155
- }, cell.id))
156
- }, row.id)) : /*#__PURE__*/ _jsx(TableRow, {
157
+ children: hasRows ? /*#__PURE__*/ _jsxs(_Fragment, {
158
+ children: [
159
+ rowModel.rows.map((row)=>/*#__PURE__*/ _jsx(TableRow, {
160
+ onClick: ()=>onRowClick?.(row.original),
161
+ "data-selected": row.getIsSelected(),
162
+ className: onRowClick ? 'cursor-pointer' : '',
163
+ tabIndex: onRowClick ? 0 : undefined,
164
+ role: onRowClick ? 'button' : undefined,
165
+ onKeyDown: (event)=>{
166
+ if (!onRowClick) return;
167
+ if (event.key === 'Enter' || event.key === ' ') {
168
+ event.preventDefault();
169
+ onRowClick(row.original);
170
+ }
171
+ },
172
+ children: row.getVisibleCells().map((cell)=>/*#__PURE__*/ _jsx(TableCell, {
173
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
174
+ }, cell.id))
175
+ }, row.id)),
176
+ emptyRowCount > 0 && Array.from({
177
+ length: emptyRowCount
178
+ }, (_, idx)=>{
179
+ const emptyRowKey = `empty-row-${rowCount}-pos-${idx + rowCount}`;
180
+ return /*#__PURE__*/ _jsx(TableRow, {
181
+ className: "hover:bg-transparent pointer-events-none",
182
+ children: table.getAllColumns().map((column)=>/*#__PURE__*/ _jsx(TableCell, {
183
+ children: /*#__PURE__*/ _jsx("span", {
184
+ className: "invisible",
185
+ children: "."
186
+ })
187
+ }, column.id))
188
+ }, emptyRowKey);
189
+ })
190
+ ]
191
+ }) : /*#__PURE__*/ _jsx(TableRow, {
157
192
  className: "hover:bg-transparent",
158
193
  children: /*#__PURE__*/ _jsx(TableCell, {
159
194
  colSpan: table.getAllColumns().length,
160
- className: "h-240 text-center rounded-t-8",
195
+ className: "h-240 text-center rounded-t-8 hover:bg-transparent",
161
196
  children: emptyState || /*#__PURE__*/ _jsx(EmptyState, {})
162
197
  })
163
198
  })
164
199
  }),
165
- pagination && table.getRowModel().rows?.length > 0 && /*#__PURE__*/ _jsx(TablePagination, {
200
+ shouldShowPagination && /*#__PURE__*/ _jsx(TablePagination, {
166
201
  table: table,
167
202
  pageSizeOptions: pageSizeOptions,
168
203
  showSelectedCount: showSelectedCount,
@@ -3,6 +3,7 @@ import { cn } from '../../utils/cn.js';
3
3
  function Table({ className, ...props }) {
4
4
  return /*#__PURE__*/ _jsx("div", {
5
5
  className: "relative w-full overflow-auto scrollbar rounded-x-8 rounded-b-8",
6
+ style: props.style,
6
7
  children: /*#__PURE__*/ _jsx("table", {
7
8
  "data-slot": "table",
8
9
  className: cn('w-full caption-bottom text-sm', className),
@@ -48,7 +49,7 @@ function TableHead({ className, ...props }) {
48
49
  function TableCell({ className, ...props }) {
49
50
  return /*#__PURE__*/ _jsx("td", {
50
51
  "data-slot": "table-cell",
51
- className: cn('px-12 py-10 align-middle text-sm leading-20 text-foreground-neutral-base', 'bg-background-neutral-base', 'group-hover/row:bg-background-neutral-hover', 'group-data-[selected=true]/row:bg-background-neutral-pressed!', '[&:has([role=checkbox])]:pr-0 [&:has([role=checkbox])]:pt-14', className),
52
+ className: cn('px-12 py-10 align-middle text-sm leading-20 text-foreground-neutral-base truncate', 'bg-background-neutral-base', 'group-hover/row:bg-background-neutral-hover', 'group-data-[selected=true]/row:bg-background-neutral-pressed!', '[&:has([role=checkbox])]:pr-0 [&:has([role=checkbox])]:pt-14', className),
52
53
  ...props
53
54
  });
54
55
  }
@@ -75,7 +75,7 @@
75
75
  };
76
76
  /**
77
77
  * Sample job data
78
- */ export const jobsData = generateJobData(100);
78
+ */ export const jobsData = generateJobData(51);
79
79
  /**
80
80
  * Sample search job data
81
81
  */ export const searchJobsData = generateSearchJobData(50);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipfox/react-ui",
3
3
  "license": "MIT",
4
- "version": "0.24.0",
4
+ "version": "0.25.0",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -86,10 +86,10 @@
86
86
  "vitest": "^4.0.8",
87
87
  "zod": "^4.1.12",
88
88
  "@shipfox/biome": "1.6.0",
89
- "@shipfox/swc": "1.2.2",
90
89
  "@shipfox/ts-config": "1.3.5",
91
- "@shipfox/typescript": "1.1.2",
92
90
  "@shipfox/vite": "1.2.2",
91
+ "@shipfox/swc": "1.2.2",
92
+ "@shipfox/typescript": "1.1.2",
93
93
  "@shipfox/vitest": "1.2.0"
94
94
  },
95
95
  "scripts": {