@andreagiugni/tailwind-dashboard-ui 0.2.0 → 0.3.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.
package/dist/index.d.cts CHANGED
@@ -137,30 +137,8 @@ interface DropzoneProps {
137
137
  /** Drag-and-drop file upload area — dependency-free (native HTML5 drag/drop). */
138
138
  declare const Dropzone: React.FC<DropzoneProps>;
139
139
 
140
- interface TableProps extends React.TableHTMLAttributes<HTMLTableElement> {
141
- }
142
- declare const Table: React.FC<TableProps>;
143
- interface TableSectionProps extends React.HTMLAttributes<HTMLTableSectionElement> {
144
- }
145
- declare const TableHeader: React.FC<TableSectionProps>;
146
- declare const TableBody: React.FC<TableSectionProps>;
147
- interface TableRowProps extends React.HTMLAttributes<HTMLTableRowElement> {
148
- }
149
- declare const TableRow: React.FC<TableRowProps>;
150
- interface TableCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
151
- isHeader?: boolean;
152
- }
153
- declare const TableCell: React.FC<TableCellProps>;
154
-
155
- interface PaginationProps {
156
- currentPage: number;
157
- totalPages: number;
158
- onPageChange: (page: number) => void;
159
- }
160
- declare const Pagination: React.FC<PaginationProps>;
161
-
162
140
  type SortDirection = "asc" | "desc";
163
- interface DataTableColumn<T> {
141
+ interface TableColumn<T> {
164
142
  /** Key into the row object — also the value used for sorting/searching. */
165
143
  key: Extract<keyof T, string>;
166
144
  /** Column header label. */
@@ -174,12 +152,17 @@ interface DataTableColumn<T> {
174
152
  /** Extra classes applied to this column's header and body cells. */
175
153
  className?: string;
176
154
  }
177
- interface DataTableProps<T> {
155
+ interface TableProps<T = Record<string, unknown>> extends Omit<React.TableHTMLAttributes<HTMLTableElement>, "children"> {
156
+ /**
157
+ * Composable content (Table / TableHeader / TableBody / TableRow / TableCell).
158
+ * Used when `columns` is **not** provided.
159
+ */
160
+ children?: React.ReactNode;
178
161
  /** The array of row objects to display. */
179
- data: T[];
180
- /** Column definitions (label, sortable, custom render, …). */
181
- columns: DataTableColumn<T>[];
182
- /** Rows shown per page. Default: 10. */
162
+ data?: T[];
163
+ /** Column definitions. Providing this switches Table into data-driven mode. */
164
+ columns?: TableColumn<T>[];
165
+ /** Maximum number of rows shown per page. Default: 10. */
183
166
  rowsPerPage?: number;
184
167
  /** Options for the "Show N entries" selector. Default: [5, 10, 25, 50]. Pass [] to hide it. */
185
168
  rowsPerPageOptions?: number[];
@@ -187,12 +170,13 @@ interface DataTableProps<T> {
187
170
  pagination?: boolean;
188
171
  /** Render the "Show N entries" selector (only when pagination is on). Default: true. */
189
172
  showSizeSelector?: boolean;
190
- /** Render the search field. Default: true. */
191
- searchable?: boolean;
173
+ /**
174
+ * Fields matched when searching. The search input is shown **only** when this
175
+ * is a non-empty array — omit it (or pass `[]`) to hide the search box.
176
+ */
177
+ searchKeys?: Extract<keyof T, string>[];
192
178
  /** Placeholder for the search field. Default: "Search...". */
193
179
  searchPlaceholder?: string;
194
- /** Keys matched when searching. Defaults to every column key. */
195
- searchKeys?: Extract<keyof T, string>[];
196
180
  /** Column sorted on first render. */
197
181
  defaultSortKey?: Extract<keyof T, string>;
198
182
  /** Initial sort direction. Default: "asc". */
@@ -203,10 +187,26 @@ interface DataTableProps<T> {
203
187
  onRowClick?: (row: T, index: number) => void;
204
188
  /** Shown when no rows match. Default: "No matching records". */
205
189
  emptyContent?: React.ReactNode;
206
- /** Extra classes for the outer wrapper. */
207
- className?: string;
208
190
  }
209
- declare function DataTable<T extends Record<string, unknown>>({ data, columns, rowsPerPage, rowsPerPageOptions, pagination, showSizeSelector, searchable, searchPlaceholder, searchKeys, defaultSortKey, defaultSortDirection, getRowId, onRowClick, emptyContent, className, }: DataTableProps<T>): React.JSX.Element;
191
+ interface TableSectionProps extends React.HTMLAttributes<HTMLTableSectionElement> {
192
+ }
193
+ declare const TableHeader: React.FC<TableSectionProps>;
194
+ declare const TableBody: React.FC<TableSectionProps>;
195
+ interface TableRowProps extends React.HTMLAttributes<HTMLTableRowElement> {
196
+ }
197
+ declare const TableRow: React.FC<TableRowProps>;
198
+ interface TableCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
199
+ isHeader?: boolean;
200
+ }
201
+ declare const TableCell: React.FC<TableCellProps>;
202
+ declare function Table<T extends Record<string, unknown> = Record<string, unknown>>({ children, data, columns, rowsPerPage, rowsPerPageOptions, pagination, showSizeSelector, searchKeys, searchPlaceholder, defaultSortKey, defaultSortDirection, getRowId, onRowClick, emptyContent, className, ...rest }: TableProps<T>): React.JSX.Element;
203
+
204
+ interface PaginationProps {
205
+ currentPage: number;
206
+ totalPages: number;
207
+ onPageChange: (page: number) => void;
208
+ }
209
+ declare const Pagination: React.FC<PaginationProps>;
210
210
 
211
211
  interface BreadcrumbItem {
212
212
  label: string;
@@ -609,4 +609,4 @@ interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>,
609
609
  }
610
610
  declare const Slider: React.FC<SliderProps>;
611
611
 
612
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, Alert, type AlertProps, type AlertVariant, Avatar, type AvatarProps, type AvatarSize, type AvatarStatus, AvatarText, type AvatarTextProps, Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipColor, type ChipProps, type ChipSize, type ChipVariant, Code, type CodeColor, type CodeProps, type CodeSize, ColorOverrideProps, DataTable, type DataTableColumn, type DataTableProps, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Drawer, type DrawerPlacement, type DrawerProps, Dropdown, DropdownItem, type DropdownItemProps, type DropdownItemVariant, type DropdownProps, Dropzone, type DropzoneProps, FileInput, type FileInputProps, Form, type FormProps, Input, type InputProps, Label, type LabelProps, Modal, type ModalProps, type ModalVariant, MultiSelect, type MultiSelectProps, Pagination, type PaginationProps, PasswordInput, type PasswordInputProps, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressSize, Radio, type RadioProps, RadioSm, type RadioSmProps, Ribbon, type RibbonColor, type RibbonPosition, type RibbonProps, type RibbonVariant, Select, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderColor, type SliderProps, Snippet, type SnippetProps, type SnippetSize, type SortDirection, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCell, type TableCellProps, TableHeader, type TableProps, TableRow, type TableRowProps, type TableSectionProps, Tabs, type TabsProps, type TabsVariant, TextArea, type TextAreaProps, ThemeToggleButton, type ThemeToggleButtonProps, Toast, type ToastProps, type ToastVariant, Tooltip, type TooltipPlacement, type TooltipProps, cn };
612
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, Alert, type AlertProps, type AlertVariant, Avatar, type AvatarProps, type AvatarSize, type AvatarStatus, AvatarText, type AvatarTextProps, Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipColor, type ChipProps, type ChipSize, type ChipVariant, Code, type CodeColor, type CodeProps, type CodeSize, ColorOverrideProps, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Drawer, type DrawerPlacement, type DrawerProps, Dropdown, DropdownItem, type DropdownItemProps, type DropdownItemVariant, type DropdownProps, Dropzone, type DropzoneProps, FileInput, type FileInputProps, Form, type FormProps, Input, type InputProps, Label, type LabelProps, Modal, type ModalProps, type ModalVariant, MultiSelect, type MultiSelectProps, Pagination, type PaginationProps, PasswordInput, type PasswordInputProps, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressSize, Radio, type RadioProps, RadioSm, type RadioSmProps, Ribbon, type RibbonColor, type RibbonPosition, type RibbonProps, type RibbonVariant, Select, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderColor, type SliderProps, Snippet, type SnippetProps, type SnippetSize, type SortDirection, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCell, type TableCellProps, type TableColumn, TableHeader, type TableProps, TableRow, type TableRowProps, type TableSectionProps, Tabs, type TabsProps, type TabsVariant, TextArea, type TextAreaProps, ThemeToggleButton, type ThemeToggleButtonProps, Toast, type ToastProps, type ToastVariant, Tooltip, type TooltipPlacement, type TooltipProps, cn };
package/dist/index.d.ts CHANGED
@@ -137,30 +137,8 @@ interface DropzoneProps {
137
137
  /** Drag-and-drop file upload area — dependency-free (native HTML5 drag/drop). */
138
138
  declare const Dropzone: React.FC<DropzoneProps>;
139
139
 
140
- interface TableProps extends React.TableHTMLAttributes<HTMLTableElement> {
141
- }
142
- declare const Table: React.FC<TableProps>;
143
- interface TableSectionProps extends React.HTMLAttributes<HTMLTableSectionElement> {
144
- }
145
- declare const TableHeader: React.FC<TableSectionProps>;
146
- declare const TableBody: React.FC<TableSectionProps>;
147
- interface TableRowProps extends React.HTMLAttributes<HTMLTableRowElement> {
148
- }
149
- declare const TableRow: React.FC<TableRowProps>;
150
- interface TableCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
151
- isHeader?: boolean;
152
- }
153
- declare const TableCell: React.FC<TableCellProps>;
154
-
155
- interface PaginationProps {
156
- currentPage: number;
157
- totalPages: number;
158
- onPageChange: (page: number) => void;
159
- }
160
- declare const Pagination: React.FC<PaginationProps>;
161
-
162
140
  type SortDirection = "asc" | "desc";
163
- interface DataTableColumn<T> {
141
+ interface TableColumn<T> {
164
142
  /** Key into the row object — also the value used for sorting/searching. */
165
143
  key: Extract<keyof T, string>;
166
144
  /** Column header label. */
@@ -174,12 +152,17 @@ interface DataTableColumn<T> {
174
152
  /** Extra classes applied to this column's header and body cells. */
175
153
  className?: string;
176
154
  }
177
- interface DataTableProps<T> {
155
+ interface TableProps<T = Record<string, unknown>> extends Omit<React.TableHTMLAttributes<HTMLTableElement>, "children"> {
156
+ /**
157
+ * Composable content (Table / TableHeader / TableBody / TableRow / TableCell).
158
+ * Used when `columns` is **not** provided.
159
+ */
160
+ children?: React.ReactNode;
178
161
  /** The array of row objects to display. */
179
- data: T[];
180
- /** Column definitions (label, sortable, custom render, …). */
181
- columns: DataTableColumn<T>[];
182
- /** Rows shown per page. Default: 10. */
162
+ data?: T[];
163
+ /** Column definitions. Providing this switches Table into data-driven mode. */
164
+ columns?: TableColumn<T>[];
165
+ /** Maximum number of rows shown per page. Default: 10. */
183
166
  rowsPerPage?: number;
184
167
  /** Options for the "Show N entries" selector. Default: [5, 10, 25, 50]. Pass [] to hide it. */
185
168
  rowsPerPageOptions?: number[];
@@ -187,12 +170,13 @@ interface DataTableProps<T> {
187
170
  pagination?: boolean;
188
171
  /** Render the "Show N entries" selector (only when pagination is on). Default: true. */
189
172
  showSizeSelector?: boolean;
190
- /** Render the search field. Default: true. */
191
- searchable?: boolean;
173
+ /**
174
+ * Fields matched when searching. The search input is shown **only** when this
175
+ * is a non-empty array — omit it (or pass `[]`) to hide the search box.
176
+ */
177
+ searchKeys?: Extract<keyof T, string>[];
192
178
  /** Placeholder for the search field. Default: "Search...". */
193
179
  searchPlaceholder?: string;
194
- /** Keys matched when searching. Defaults to every column key. */
195
- searchKeys?: Extract<keyof T, string>[];
196
180
  /** Column sorted on first render. */
197
181
  defaultSortKey?: Extract<keyof T, string>;
198
182
  /** Initial sort direction. Default: "asc". */
@@ -203,10 +187,26 @@ interface DataTableProps<T> {
203
187
  onRowClick?: (row: T, index: number) => void;
204
188
  /** Shown when no rows match. Default: "No matching records". */
205
189
  emptyContent?: React.ReactNode;
206
- /** Extra classes for the outer wrapper. */
207
- className?: string;
208
190
  }
209
- declare function DataTable<T extends Record<string, unknown>>({ data, columns, rowsPerPage, rowsPerPageOptions, pagination, showSizeSelector, searchable, searchPlaceholder, searchKeys, defaultSortKey, defaultSortDirection, getRowId, onRowClick, emptyContent, className, }: DataTableProps<T>): React.JSX.Element;
191
+ interface TableSectionProps extends React.HTMLAttributes<HTMLTableSectionElement> {
192
+ }
193
+ declare const TableHeader: React.FC<TableSectionProps>;
194
+ declare const TableBody: React.FC<TableSectionProps>;
195
+ interface TableRowProps extends React.HTMLAttributes<HTMLTableRowElement> {
196
+ }
197
+ declare const TableRow: React.FC<TableRowProps>;
198
+ interface TableCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
199
+ isHeader?: boolean;
200
+ }
201
+ declare const TableCell: React.FC<TableCellProps>;
202
+ declare function Table<T extends Record<string, unknown> = Record<string, unknown>>({ children, data, columns, rowsPerPage, rowsPerPageOptions, pagination, showSizeSelector, searchKeys, searchPlaceholder, defaultSortKey, defaultSortDirection, getRowId, onRowClick, emptyContent, className, ...rest }: TableProps<T>): React.JSX.Element;
203
+
204
+ interface PaginationProps {
205
+ currentPage: number;
206
+ totalPages: number;
207
+ onPageChange: (page: number) => void;
208
+ }
209
+ declare const Pagination: React.FC<PaginationProps>;
210
210
 
211
211
  interface BreadcrumbItem {
212
212
  label: string;
@@ -609,4 +609,4 @@ interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>,
609
609
  }
610
610
  declare const Slider: React.FC<SliderProps>;
611
611
 
612
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, Alert, type AlertProps, type AlertVariant, Avatar, type AvatarProps, type AvatarSize, type AvatarStatus, AvatarText, type AvatarTextProps, Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipColor, type ChipProps, type ChipSize, type ChipVariant, Code, type CodeColor, type CodeProps, type CodeSize, ColorOverrideProps, DataTable, type DataTableColumn, type DataTableProps, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Drawer, type DrawerPlacement, type DrawerProps, Dropdown, DropdownItem, type DropdownItemProps, type DropdownItemVariant, type DropdownProps, Dropzone, type DropzoneProps, FileInput, type FileInputProps, Form, type FormProps, Input, type InputProps, Label, type LabelProps, Modal, type ModalProps, type ModalVariant, MultiSelect, type MultiSelectProps, Pagination, type PaginationProps, PasswordInput, type PasswordInputProps, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressSize, Radio, type RadioProps, RadioSm, type RadioSmProps, Ribbon, type RibbonColor, type RibbonPosition, type RibbonProps, type RibbonVariant, Select, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderColor, type SliderProps, Snippet, type SnippetProps, type SnippetSize, type SortDirection, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCell, type TableCellProps, TableHeader, type TableProps, TableRow, type TableRowProps, type TableSectionProps, Tabs, type TabsProps, type TabsVariant, TextArea, type TextAreaProps, ThemeToggleButton, type ThemeToggleButtonProps, Toast, type ToastProps, type ToastVariant, Tooltip, type TooltipPlacement, type TooltipProps, cn };
612
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, Alert, type AlertProps, type AlertVariant, Avatar, type AvatarProps, type AvatarSize, type AvatarStatus, AvatarText, type AvatarTextProps, Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipColor, type ChipProps, type ChipSize, type ChipVariant, Code, type CodeColor, type CodeProps, type CodeSize, ColorOverrideProps, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Drawer, type DrawerPlacement, type DrawerProps, Dropdown, DropdownItem, type DropdownItemProps, type DropdownItemVariant, type DropdownProps, Dropzone, type DropzoneProps, FileInput, type FileInputProps, Form, type FormProps, Input, type InputProps, Label, type LabelProps, Modal, type ModalProps, type ModalVariant, MultiSelect, type MultiSelectProps, Pagination, type PaginationProps, PasswordInput, type PasswordInputProps, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressSize, Radio, type RadioProps, RadioSm, type RadioSmProps, Ribbon, type RibbonColor, type RibbonPosition, type RibbonProps, type RibbonVariant, Select, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderColor, type SliderProps, Snippet, type SnippetProps, type SnippetSize, type SortDirection, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCell, type TableCellProps, type TableColumn, TableHeader, type TableProps, TableRow, type TableRowProps, type TableSectionProps, Tabs, type TabsProps, type TabsVariant, TextArea, type TextAreaProps, ThemeToggleButton, type ThemeToggleButtonProps, Toast, type ToastProps, type ToastVariant, Tooltip, type TooltipPlacement, type TooltipProps, cn };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export { Editor } from './chunk-4OETC46A.js';
7
7
  import { cn } from './chunk-ZLIYUUA4.js';
8
8
  export { cn } from './chunk-ZLIYUUA4.js';
9
9
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
10
- import React5, { useRef, useEffect, useState, useMemo, useCallback, useId } from 'react';
10
+ import React5, { useRef, useEffect, useState, useCallback, useId, useMemo } from 'react';
11
11
  import flatpickr from 'flatpickr';
12
12
  import 'flatpickr/dist/flatpickr.css';
13
13
 
@@ -546,19 +546,6 @@ var Dropzone = ({
546
546
  }
547
547
  );
548
548
  };
549
- var Table = ({ children, className, ...rest }) => /* @__PURE__ */ jsx("table", { className: cn("min-w-full", className), ...rest, children });
550
- var TableHeader = ({ children, className, ...rest }) => /* @__PURE__ */ jsx("thead", { className, ...rest, children });
551
- var TableBody = ({ children, className, ...rest }) => /* @__PURE__ */ jsx("tbody", { className, ...rest, children });
552
- var TableRow = ({ children, className, ...rest }) => /* @__PURE__ */ jsx("tr", { className, ...rest, children });
553
- var TableCell = ({
554
- children,
555
- isHeader = false,
556
- className,
557
- ...rest
558
- }) => {
559
- const Tag = isHeader ? "th" : "td";
560
- return /* @__PURE__ */ jsx(Tag, { className, ...rest, children });
561
- };
562
549
  var Pagination = ({
563
550
  currentPage,
564
551
  totalPages,
@@ -648,6 +635,18 @@ var Input = ({
648
635
  hint && /* @__PURE__ */ jsx("p", { className: cn("mt-1.5 text-xs", error ? "text-error-500" : success ? "text-success-500" : "text-gray-500"), children: hint })
649
636
  ] });
650
637
  };
638
+ var TableHeader = ({ children, className, ...rest }) => /* @__PURE__ */ jsx("thead", { className, ...rest, children });
639
+ var TableBody = ({ children, className, ...rest }) => /* @__PURE__ */ jsx("tbody", { className, ...rest, children });
640
+ var TableRow = ({ children, className, ...rest }) => /* @__PURE__ */ jsx("tr", { className, ...rest, children });
641
+ var TableCell = ({
642
+ children,
643
+ isHeader = false,
644
+ className,
645
+ ...rest
646
+ }) => {
647
+ const Tag = isHeader ? "th" : "td";
648
+ return /* @__PURE__ */ jsx(Tag, { className, ...rest, children });
649
+ };
651
650
  var alignClass = {
652
651
  left: "text-left",
653
652
  center: "text-center",
@@ -664,16 +663,15 @@ function SortIcon({
664
663
  /* @__PURE__ */ jsx("svg", { width: "10", height: "6", viewBox: "0 0 10 6", fill: "currentColor", "aria-hidden": "true", className: active && direction === "desc" ? on : off, children: /* @__PURE__ */ jsx("path", { d: "M5 6 1 1h8z" }) })
665
664
  ] });
666
665
  }
667
- function DataTable({
666
+ function DataDrivenTable({
668
667
  data,
669
668
  columns,
670
669
  rowsPerPage = 10,
671
670
  rowsPerPageOptions = [5, 10, 25, 50],
672
671
  pagination = true,
673
672
  showSizeSelector = true,
674
- searchable = true,
675
- searchPlaceholder = "Search...",
676
673
  searchKeys,
674
+ searchPlaceholder = "Search...",
677
675
  defaultSortKey,
678
676
  defaultSortDirection = "asc",
679
677
  getRowId,
@@ -686,13 +684,13 @@ function DataTable({
686
684
  const [sortKey, setSortKey] = useState(defaultSortKey);
687
685
  const [sortDir, setSortDir] = useState(defaultSortDirection);
688
686
  const [page, setPage] = useState(1);
687
+ const showSearch = !!(searchKeys && searchKeys.length > 0);
689
688
  const filtered = useMemo(() => {
690
- const keys = searchKeys ?? columns.map((c) => c.key);
691
689
  const q = search.trim().toLowerCase();
692
690
  let rows = data;
693
- if (searchable && q) {
691
+ if (showSearch && q) {
694
692
  rows = rows.filter(
695
- (row) => keys.some((k) => String(row[k] ?? "").toLowerCase().includes(q))
693
+ (row) => searchKeys.some((k) => String(row[k] ?? "").toLowerCase().includes(q))
696
694
  );
697
695
  }
698
696
  if (sortKey) {
@@ -704,7 +702,7 @@ function DataTable({
704
702
  });
705
703
  }
706
704
  return rows;
707
- }, [data, columns, search, searchable, searchKeys, sortKey, sortDir]);
705
+ }, [data, search, showSearch, searchKeys, sortKey, sortDir]);
708
706
  const total = filtered.length;
709
707
  const totalPages = pagination ? Math.max(1, Math.ceil(total / pageSize)) : 1;
710
708
  const current = Math.min(page, totalPages);
@@ -721,7 +719,7 @@ function DataTable({
721
719
  };
722
720
  const sizeOptions = rowsPerPageOptions.length ? rowsPerPageOptions : [];
723
721
  const showSelector = pagination && showSizeSelector && sizeOptions.length > 1;
724
- const showControls = searchable || showSelector;
722
+ const showControls = showSearch || showSelector;
725
723
  return /* @__PURE__ */ jsxs(
726
724
  "div",
727
725
  {
@@ -748,7 +746,7 @@ function DataTable({
748
746
  ),
749
747
  "entries"
750
748
  ] }) : /* @__PURE__ */ jsx("span", {}),
751
- searchable && /* @__PURE__ */ jsx(
749
+ showSearch && /* @__PURE__ */ jsx(
752
750
  Input,
753
751
  {
754
752
  type: "search",
@@ -763,7 +761,7 @@ function DataTable({
763
761
  }
764
762
  )
765
763
  ] }),
766
- /* @__PURE__ */ jsx("div", { className: "overflow-x-auto border-y border-gray-100 dark:border-white/[0.05]", children: /* @__PURE__ */ jsxs(Table, { children: [
764
+ /* @__PURE__ */ jsx("div", { className: "overflow-x-auto border-y border-gray-100 dark:border-white/[0.05]", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full", children: [
767
765
  /* @__PURE__ */ jsx(TableHeader, { className: "border-b border-gray-100 bg-gray-50 dark:border-white/[0.05] dark:bg-white/[0.06]", children: /* @__PURE__ */ jsx(TableRow, { children: columns.map((col) => {
768
766
  const isActive = sortKey === col.key;
769
767
  return /* @__PURE__ */ jsx(
@@ -828,6 +826,47 @@ function DataTable({
828
826
  }
829
827
  );
830
828
  }
829
+ function Table({
830
+ children,
831
+ data,
832
+ columns,
833
+ rowsPerPage,
834
+ rowsPerPageOptions,
835
+ pagination,
836
+ showSizeSelector,
837
+ searchKeys,
838
+ searchPlaceholder,
839
+ defaultSortKey,
840
+ defaultSortDirection,
841
+ getRowId,
842
+ onRowClick,
843
+ emptyContent,
844
+ className,
845
+ ...rest
846
+ }) {
847
+ if (columns && data) {
848
+ return /* @__PURE__ */ jsx(
849
+ DataDrivenTable,
850
+ {
851
+ data,
852
+ columns,
853
+ rowsPerPage,
854
+ rowsPerPageOptions,
855
+ pagination,
856
+ showSizeSelector,
857
+ searchKeys,
858
+ searchPlaceholder,
859
+ defaultSortKey,
860
+ defaultSortDirection,
861
+ getRowId,
862
+ onRowClick,
863
+ emptyContent,
864
+ className
865
+ }
866
+ );
867
+ }
868
+ return /* @__PURE__ */ jsx("table", { className: cn("min-w-full", className), ...rest, children });
869
+ }
831
870
  var ChevronIcon = () => /* @__PURE__ */ jsx(
832
871
  "svg",
833
872
  {
@@ -3035,6 +3074,6 @@ var Slider = ({
3035
3074
  ] });
3036
3075
  };
3037
3076
 
3038
- export { Accordion, AccordionItem, Alert, Avatar, AvatarText, Badge, Breadcrumb, Button, Card, Checkbox, Chip, Code, DataTable, DatePicker, DateTimePicker, Drawer, Dropdown, DropdownItem, Dropzone, FileInput, Form, Input, Label, MultiSelect, Pagination, PasswordInput, Popover, Progress, Radio, RadioSm, Ribbon, Select, Skeleton, Slider, Snippet, Spinner, Switch, Tab, Table, TableBody, TableCell, TableHeader, TableRow, Tabs, TextArea, ThemeToggleButton, Toast, Tooltip, styleOverride };
3077
+ export { Accordion, AccordionItem, Alert, Avatar, AvatarText, Badge, Breadcrumb, Button, Card, Checkbox, Chip, Code, DatePicker, DateTimePicker, Drawer, Dropdown, DropdownItem, Dropzone, FileInput, Form, Input, Label, MultiSelect, Pagination, PasswordInput, Popover, Progress, Radio, RadioSm, Ribbon, Select, Skeleton, Slider, Snippet, Spinner, Switch, Tab, Table, TableBody, TableCell, TableHeader, TableRow, Tabs, TextArea, ThemeToggleButton, Toast, Tooltip, styleOverride };
3039
3078
  //# sourceMappingURL=index.js.map
3040
3079
  //# sourceMappingURL=index.js.map