@shipfox/react-ui 0.17.0 → 0.18.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.
@@ -9,6 +9,7 @@ export * from './checkbox';
9
9
  export * from './code-block';
10
10
  export * from './command';
11
11
  export * from './confetti';
12
+ export * from './count-up';
12
13
  export * from './dashboard';
13
14
  export * from './date-picker';
14
15
  export * from './date-time-range-picker';
@@ -9,6 +9,7 @@ export * from './checkbox/index.js';
9
9
  export * from './code-block/index.js';
10
10
  export * from './command/index.js';
11
11
  export * from './confetti/index.js';
12
+ export * from './count-up/index.js';
12
13
  export * from './dashboard/index.js';
13
14
  export * from './date-picker/index.js';
14
15
  export * from './date-time-range-picker/index.js';
@@ -3,6 +3,7 @@ import { Button } from '../../components/button/button.js';
3
3
  import { DatePicker } from '../../components/date-picker/index.js';
4
4
  import { Icon } from '../../components/icon/icon.js';
5
5
  import { Input } from '../../components/input/input.js';
6
+ import { Kbd } from '../../components/kbd/index.js';
6
7
  import { Label } from '../../components/label/label.js';
7
8
  import { useState } from 'react';
8
9
  import { Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemSeparator, ItemTitle } from './item.js';
@@ -139,9 +140,8 @@ export const ImportPastJobsModal = {
139
140
  /*#__PURE__*/ _jsxs("div", {
140
141
  className: "flex items-center gap-8",
141
142
  children: [
142
- /*#__PURE__*/ _jsx("kbd", {
143
- className: "flex items-center justify-center rounded-8 border border-border-neutral-base shadow-button-neutral bg-background-field-base text-xs text-foreground-neutral-subtle px-4",
144
- children: "esc"
143
+ /*#__PURE__*/ _jsx(Kbd, {
144
+ children: "Esc"
145
145
  }),
146
146
  /*#__PURE__*/ _jsx(Button, {
147
147
  variant: "transparent",
@@ -81,7 +81,14 @@ interface DataTableProps<TData, TValue> extends Omit<ComponentProps<'div'>, 'chi
81
81
  * When `true`, displays a loading skeleton instead of the table.
82
82
  */
83
83
  isLoading?: boolean;
84
+ /**
85
+ * Optional scoped container element for dropdown portals.
86
+ *
87
+ * When provided, dropdowns (like pagination select) will be rendered inside this container
88
+ * instead of the document body. This is useful for scoped CSS styling.
89
+ */
90
+ scopedContainer?: HTMLElement | null;
84
91
  }
85
- export declare function DataTable<TData, TValue>({ columns, data, pagination, pageSize, pageSizeOptions, showSelectedCount, onRowClick, emptyState, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, isLoading, className, ...props }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
92
+ export declare function DataTable<TData, TValue>({ columns, data, pagination, pageSize, pageSizeOptions, showSelectedCount, onRowClick, emptyState, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, isLoading, scopedContainer, className, ...props }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
86
93
  export {};
87
94
  //# sourceMappingURL=data-table.d.ts.map
@@ -8,7 +8,7 @@ import { useEffect, useMemo, useState } from 'react';
8
8
  import { cn } from '../../utils/cn.js';
9
9
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from './table.js';
10
10
  import { TablePagination } from './table-pagination.js';
11
- export function DataTable({ columns, data, pagination = true, pageSize = 10, pageSizeOptions, showSelectedCount = false, onRowClick, emptyState, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, isLoading, className, ...props }) {
11
+ export function DataTable({ columns, data, pagination = true, pageSize = 10, pageSizeOptions, showSelectedCount = false, onRowClick, emptyState, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, isLoading, scopedContainer, className, ...props }) {
12
12
  const [sorting, setSorting] = useState([]);
13
13
  const [columnFilters, setColumnFilters] = useState([]);
14
14
  const [internalColumnVisibility, setInternalColumnVisibility] = useState({});
@@ -91,7 +91,7 @@ export function DataTable({ columns, data, pagination = true, pageSize = 10, pag
91
91
  className: cn('p-0 gap-0', className),
92
92
  ...props,
93
93
  children: /*#__PURE__*/ _jsx(CardContent, {
94
- className: "rounded-8 overflow-hidden p-0",
94
+ className: "overflow-hidden p-0",
95
95
  children: /*#__PURE__*/ _jsxs(Table, {
96
96
  children: [
97
97
  /*#__PURE__*/ _jsx(TableHeader, {
@@ -125,7 +125,7 @@ export function DataTable({ columns, data, pagination = true, pageSize = 10, pag
125
125
  className: cn('p-0 gap-0', className),
126
126
  ...props,
127
127
  children: /*#__PURE__*/ _jsx(CardContent, {
128
- className: "rounded-b-8 overflow-hidden p-0",
128
+ className: "overflow-hidden p-0",
129
129
  children: /*#__PURE__*/ _jsxs(Table, {
130
130
  children: [
131
131
  table.getRowModel().rows.length > 0 ? /*#__PURE__*/ _jsx(TableHeader, {
@@ -165,7 +165,8 @@ export function DataTable({ columns, data, pagination = true, pageSize = 10, pag
165
165
  pagination && table.getRowModel().rows?.length > 0 && /*#__PURE__*/ _jsx(TablePagination, {
166
166
  table: table,
167
167
  pageSizeOptions: pageSizeOptions,
168
- showSelectedCount: showSelectedCount
168
+ showSelectedCount: showSelectedCount,
169
+ scopedContainer: scopedContainer
169
170
  })
170
171
  ]
171
172
  })
@@ -39,6 +39,19 @@ export interface TableColumnHeaderProps<TData, TValue> extends HTMLAttributes<HT
39
39
  * ```
40
40
  */
41
41
  title: string;
42
+ /**
43
+ * Optional scoped container element for dropdown portal.
44
+ *
45
+ * When provided, the dropdown menu will be rendered inside this container
46
+ * instead of the document body. This is useful for scoped CSS styling.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * const {scopedContainer} = useScopedContainer();
51
+ * <TableColumnHeader column={column} title="Name" scopedContainer={scopedContainer} />
52
+ * ```
53
+ */
54
+ scopedContainer?: HTMLElement | null;
42
55
  }
43
56
  /**
44
57
  * Renders a table column header with optional sorting functionality.
@@ -75,5 +88,5 @@ export interface TableColumnHeaderProps<TData, TValue> extends HTMLAttributes<HT
75
88
  * ];
76
89
  * ```
77
90
  */
78
- export declare function TableColumnHeader<TData, TValue>({ column, title, className, }: TableColumnHeaderProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
91
+ export declare function TableColumnHeader<TData, TValue>({ column, title, className, scopedContainer, }: TableColumnHeaderProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
79
92
  //# sourceMappingURL=table-column-header.d.ts.map
@@ -1,8 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Icon } from '../../components/icon/index.js';
3
+ import { useRef } from 'react';
3
4
  import { cn } from '../../utils/cn.js';
4
5
  import { Button } from '../button/index.js';
5
6
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '../dropdown-menu/index.js';
7
+ import { Text } from '../typography/index.js';
6
8
  /**
7
9
  * Renders a table column header with optional sorting functionality.
8
10
  *
@@ -37,15 +39,18 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
37
39
  * },
38
40
  * ];
39
41
  * ```
40
- */ export function TableColumnHeader({ column, title, className }) {
42
+ */ export function TableColumnHeader({ column, title, className, scopedContainer }) {
43
+ const headerRef = useRef(null);
41
44
  if (!column.getCanSort()) {
42
- return /*#__PURE__*/ _jsx("div", {
43
- className: cn('text-xs font-medium', className),
45
+ return /*#__PURE__*/ _jsx(Text, {
46
+ size: "xs",
47
+ className: cn('font-medium', className),
44
48
  children: title
45
49
  });
46
50
  }
47
51
  const isSorted = column.getIsSorted();
48
52
  return /*#__PURE__*/ _jsx("div", {
53
+ ref: headerRef,
49
54
  className: cn('flex items-center space-x-2', className),
50
55
  children: /*#__PURE__*/ _jsxs(DropdownMenu, {
51
56
  children: [
@@ -56,8 +61,9 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
56
61
  size: "xs",
57
62
  className: "-ml-12 h-32 px-8 data-[state=open]:bg-background-components-hover gap-0",
58
63
  children: [
59
- /*#__PURE__*/ _jsx("span", {
60
- className: "text-xs font-medium text-foreground-neutral-subtle",
64
+ /*#__PURE__*/ _jsx(Text, {
65
+ size: "xs",
66
+ className: "font-medium text-foreground-neutral-subtle",
61
67
  children: title
62
68
  }),
63
69
  isSorted === 'desc' ? /*#__PURE__*/ _jsx(Icon, {
@@ -76,6 +82,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
76
82
  /*#__PURE__*/ _jsxs(DropdownMenuContent, {
77
83
  align: "start",
78
84
  size: "sm",
85
+ container: scopedContainer ?? undefined,
79
86
  children: [
80
87
  /*#__PURE__*/ _jsx(DropdownMenuItem, {
81
88
  icon: "arrowUpLongLine",
@@ -47,7 +47,20 @@ interface TablePaginationProps<TData> extends ComponentProps<'tfoot'> {
47
47
  * ```
48
48
  */
49
49
  showSelectedCount?: boolean;
50
+ /**
51
+ * Optional scoped container element for select dropdown portal.
52
+ *
53
+ * When provided, the select dropdown will be rendered inside this container
54
+ * instead of the document body. This is useful for scoped CSS styling.
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * const {scopedContainer} = useScopedContainer();
59
+ * <TablePagination table={table} scopedContainer={scopedContainer} />
60
+ * ```
61
+ */
62
+ scopedContainer?: HTMLElement | null;
50
63
  }
51
- export declare function TablePagination<TData>({ table, className, pageSizeOptions, showSelectedCount, ...props }: TablePaginationProps<TData>): import("react/jsx-runtime").JSX.Element;
64
+ export declare function TablePagination<TData>({ table, className, pageSizeOptions, showSelectedCount, scopedContainer, ...props }: TablePaginationProps<TData>): import("react/jsx-runtime").JSX.Element;
52
65
  export {};
53
66
  //# sourceMappingURL=table-pagination.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Text } from '../../components/typography/index.js';
3
+ import { useRef } from 'react';
3
4
  import { Button } from '../button/index.js';
4
5
  import { Icon } from '../icon/index.js';
5
6
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../select/select.js';
@@ -9,17 +10,19 @@ export function TablePagination({ table, className, pageSizeOptions = [
9
10
  20,
10
11
  50,
11
12
  100
12
- ], showSelectedCount = false, ...props }) {
13
+ ], showSelectedCount = false, scopedContainer, ...props }) {
14
+ const paginationRef = useRef(null);
13
15
  const currentPage = table.getState().pagination.pageIndex + 1;
14
16
  const pageSize = table.getState().pagination.pageSize;
15
17
  const totalRows = table.getFilteredRowModel().rows.length;
16
18
  const startRow = totalRows === 0 ? 0 : currentPage === 1 ? 1 : (currentPage - 1) * pageSize + 1;
17
19
  const endRow = Math.min(currentPage * pageSize, totalRows);
18
20
  return /*#__PURE__*/ _jsx(TableFooter, {
21
+ ref: paginationRef,
19
22
  className: className,
20
23
  ...props,
21
24
  children: /*#__PURE__*/ _jsx(TableRow, {
22
- className: "hover:bg-transparent",
25
+ className: "hover:bg-transparent border-b-0",
23
26
  children: /*#__PURE__*/ _jsx(TableCell, {
24
27
  colSpan: table.getAllColumns().length,
25
28
  className: "group-hover/row:bg-transparent",
@@ -71,6 +74,7 @@ export function TablePagination({ table, className, pageSizeOptions = [
71
74
  children: /*#__PURE__*/ _jsx(SelectValue, {})
72
75
  }),
73
76
  /*#__PURE__*/ _jsx(SelectContent, {
77
+ container: scopedContainer ?? undefined,
74
78
  children: pageSizeOptions.map((size)=>/*#__PURE__*/ _jsx(SelectItem, {
75
79
  value: String(size),
76
80
  children: size
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn } from '../../utils/cn.js';
3
3
  function Table({ className, ...props }) {
4
4
  return /*#__PURE__*/ _jsx("div", {
5
- className: "relative w-full overflow-auto scrollbar",
5
+ className: "relative w-full overflow-auto scrollbar rounded-x-8 rounded-b-8",
6
6
  children: /*#__PURE__*/ _jsx("table", {
7
7
  "data-slot": "table",
8
8
  className: cn('w-full caption-bottom text-sm', className),
@@ -34,14 +34,14 @@ function TableFooter({ className, ...props }) {
34
34
  function TableRow({ className, ...props }) {
35
35
  return /*#__PURE__*/ _jsx("tr", {
36
36
  "data-slot": "table-row",
37
- className: cn('group/row border-b border-border-neutral-base transition-colors', 'last:border-b-0 last:rounded-b-8', 'hover:bg-background-neutral-hover', 'data-[selected=true]:bg-background-neutral-pressed data-[selected=true]:hover:bg-background-neutral-pressed', className),
37
+ className: cn('group/row border-b border-border-neutral-base transition-colors', 'last:rounded-b-8 last:border-b-0', 'hover:bg-background-neutral-hover', 'data-[selected=true]:bg-background-neutral-pressed data-[selected=true]:hover:bg-background-neutral-pressed', className),
38
38
  ...props
39
39
  });
40
40
  }
41
41
  function TableHead({ className, ...props }) {
42
42
  return /*#__PURE__*/ _jsx("th", {
43
43
  "data-slot": "table-head",
44
- className: cn('h-40 px-16 text-left align-middle text-xs font-medium leading-20 text-foreground-neutral-subtle', 'bg-background-subtle-base', '[&:has([role=checkbox])]:pr-0 [&:has([role=checkbox])]:px-12 [&:has([role=checkbox])]:w-0 [&:has([role=checkbox])]:pt-6', className),
44
+ className: cn('h-40 px-16 text-left align-middle text-xs font-medium leading-20 text-foreground-neutral-subtle', 'bg-background-subtle-base border-b border-border-neutral-base', '[&:has([role=checkbox])]:pr-0 [&:has([role=checkbox])]:px-12 [&:has([role=checkbox])]:w-0 [&:has([role=checkbox])]:pt-6', className),
45
45
  ...props
46
46
  });
47
47
  }