erp-pos-ecommerce-shared 0.1.6 → 0.1.7

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.
@@ -162,8 +162,14 @@ interface DataTableProps$1<TData> {
162
162
  table?: ReturnType<typeof useReactTable<TData>>;
163
163
  /** Custom Header component */
164
164
  CustomHeader?: React.ReactNode;
165
+ /** Whether to show the search input */
166
+ showSearchInput?: boolean;
167
+ /** Whether to show the bottom pagination */
168
+ showBottomPagination?: boolean;
169
+ /** Height of the table */
170
+ tableHeight?: number;
165
171
  }
166
- declare const DataTable: <TData>({ data, columns, config, filters, totalRowCount, onStateChange, loading, enableRowCheck: canCheck, onSelectionChange, headerBgColor, columnActions, listMenuActions, onRowClick, onRowHover, emptyState, table: ExternalTable, CustomHeader, }: DataTableProps$1<TData>) => react_jsx_runtime.JSX.Element;
172
+ declare const DataTable: <TData>({ showSearchInput, showBottomPagination, data, columns, config, filters, totalRowCount, onStateChange, loading, enableRowCheck: canCheck, onSelectionChange, headerBgColor, columnActions, listMenuActions, onRowClick, onRowHover, emptyState, table: ExternalTable, CustomHeader, tableHeight, }: DataTableProps$1<TData>) => react_jsx_runtime.JSX.Element;
167
173
 
168
174
  interface EmptyStateProps {
169
175
  title?: string;
@@ -262,8 +268,10 @@ interface DataTableProps<TData> {
262
268
  onRowHover?: (row: TData) => void;
263
269
  /** Empty state to display when no data is available */
264
270
  emptyState?: React$1.ReactNode;
271
+ /** Height of the table */
272
+ tableHeight?: number;
265
273
  }
266
- declare const SimpleDataTable: <TData>({ table, withBorder, borderRadius, SortIcon, SortIconAsc, SortIconDesc, canCheck, columnActions, listMenuActions, headerBgColor, loading, skeletonRowCount, onRowClick, onRowHover, emptyState, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
274
+ declare const SimpleDataTable: <TData>({ tableHeight, table, withBorder, borderRadius, SortIcon, SortIconAsc, SortIconDesc, canCheck, columnActions, listMenuActions, headerBgColor, loading, skeletonRowCount, onRowClick, onRowHover, emptyState, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
267
275
 
268
276
  interface TableSkeletonProps {
269
277
  /** Number of skeleton rows to show */
@@ -291,7 +299,7 @@ interface TablePageProps<TRow> {
291
299
  /**
292
300
  * Title of the table
293
301
  */
294
- title: string;
302
+ title?: string;
295
303
  /**
296
304
  * Columns of the table
297
305
  */
@@ -352,7 +360,19 @@ interface TablePageProps<TRow> {
352
360
  * Custom Header component
353
361
  */
354
362
  CustomHeader?: React.ReactNode;
363
+ /**
364
+ * Whether to show the search input
365
+ */
366
+ showSearchInput?: boolean;
367
+ /**
368
+ * Whether to show the bottom pagination
369
+ */
370
+ showBottomPagination?: boolean;
371
+ /**
372
+ * Height of the table
373
+ */
374
+ tableHeight?: number;
355
375
  }
356
- declare const TablePage: <TRow>({ getQueryOptions, title, columns, filters, isLoadingExternal, onRowClick, onRowHover, emptyState, table, enableRowSelection, headerBgColor, columnActions, listMenuActions, onSelectionChange, config, CustomHeader, }: TablePageProps<TRow>) => react_jsx_runtime.JSX.Element;
376
+ declare const TablePage: <TRow>({ getQueryOptions, title, columns, filters, isLoadingExternal, onRowClick, onRowHover, emptyState, table, enableRowSelection, headerBgColor, columnActions, listMenuActions, onSelectionChange, config, CustomHeader, showSearchInput, showBottomPagination, tableHeight, }: TablePageProps<TRow>) => react_jsx_runtime.JSX.Element;
357
377
 
358
378
  export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, type FilterDateProps, FilterSelect, type FilterSelectProps, FormGenerator, type FormInstance, type FormValues, ImageForm, type PaginatedResponse, SearchInput, SimpleDataTable, TablePage, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
@@ -9,7 +9,7 @@ import { modals } from '@mantine/modals';
9
9
  import { notifications } from '@mantine/notifications';
10
10
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
11
11
  import * as z from 'zod';
12
- import { flexRender, useReactTable, getPaginationRowModel, getCoreRowModel } from '@tanstack/react-table';
12
+ import { flexRender, useReactTable, getSortedRowModel, getPaginationRowModel, getCoreRowModel } from '@tanstack/react-table';
13
13
  import { ArrowDown, ArrowUp, ArrowUpDown, FileX, X, Search, ChevronUp, ChevronDown, ListFilter, Check, CalendarDays, MoreVertical } from 'lucide-react';
14
14
 
15
15
  // src/components/form/CreateEditForm.tsx
@@ -1263,10 +1263,12 @@ function useDataTable({
1263
1263
  onColumnFiltersChange: setColumnFilters,
1264
1264
  getCoreRowModel: getCoreRowModel(),
1265
1265
  getPaginationRowModel: getPaginationRowModel(),
1266
+ getSortedRowModel: getSortedRowModel(),
1266
1267
  enableRowSelection,
1267
1268
  manualPagination: true,
1268
1269
  manualFiltering: true,
1269
- manualSorting: true,
1270
+ /** Sort is applied client-side to the current page only (no server refetch) */
1271
+ manualSorting: false,
1270
1272
  pageCount: totalRowCount != null ? Math.max(1, Math.ceil(totalRowCount / pagination.pageSize)) : void 0
1271
1273
  });
1272
1274
  const selectedRows = useMemo(
@@ -1462,7 +1464,7 @@ var TableBody = ({
1462
1464
  },
1463
1465
  cell.id
1464
1466
  )),
1465
- /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
1467
+ (columnActions || listMenuActions) && /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
1466
1468
  columnActions?.(row.original),
1467
1469
  listMenuActions && /* @__PURE__ */ jsxs(Menu, { variant: "subtle", children: [
1468
1470
  /* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", color: "gray", size: "sm", children: /* @__PURE__ */ jsx(MenuIcon, { size: 16 }) }) }),
@@ -1583,6 +1585,7 @@ var EmptyState = ({
1583
1585
  );
1584
1586
  };
1585
1587
  var SimpleDataTable = ({
1588
+ tableHeight = 600,
1586
1589
  table,
1587
1590
  withBorder,
1588
1591
  borderRadius = "md",
@@ -1609,7 +1612,7 @@ var SimpleDataTable = ({
1609
1612
  const dataColumnsCount = table.getAllLeafColumns().length;
1610
1613
  const hasActionsColumn = !!(columnActions || listMenuActions);
1611
1614
  const headerBg = typeof headerBgColor === "string" ? headerBgColor : headerBgColor?.bgColor ?? defaultHeaderBgColor;
1612
- return /* @__PURE__ */ jsx(Paper, { withBorder, radius: borderRadius, children: /* @__PURE__ */ jsx(ScrollArea, { h: 600, type: "scroll", scrollbarSize: 8, children: /* @__PURE__ */ jsxs(
1615
+ return /* @__PURE__ */ jsx(Paper, { withBorder, radius: borderRadius, children: /* @__PURE__ */ jsx(ScrollArea, { h: tableHeight, type: "scroll", scrollbarSize: 8, children: /* @__PURE__ */ jsxs(
1613
1616
  Table,
1614
1617
  {
1615
1618
  styles: {
@@ -1905,6 +1908,8 @@ var FilterDate = ({
1905
1908
  );
1906
1909
  };
1907
1910
  var DataTable = ({
1911
+ showSearchInput = true,
1912
+ showBottomPagination = true,
1908
1913
  data,
1909
1914
  columns,
1910
1915
  config,
@@ -1921,7 +1926,8 @@ var DataTable = ({
1921
1926
  onRowHover,
1922
1927
  emptyState,
1923
1928
  table: ExternalTable,
1924
- CustomHeader
1929
+ CustomHeader,
1930
+ tableHeight = 600
1925
1931
  }) => {
1926
1932
  const {
1927
1933
  table: internalTable,
@@ -1949,7 +1955,7 @@ var DataTable = ({
1949
1955
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "md", children: [
1950
1956
  /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", children: [
1951
1957
  /* @__PURE__ */ jsxs(Group, { gap: "md", wrap: "wrap", children: [
1952
- mergedConfig.enableGlobalFilter && /* @__PURE__ */ jsx(
1958
+ showSearchInput && mergedConfig.enableGlobalFilter && /* @__PURE__ */ jsx(
1953
1959
  SearchInput,
1954
1960
  {
1955
1961
  value: globalFilter,
@@ -1985,6 +1991,7 @@ var DataTable = ({
1985
1991
  /* @__PURE__ */ jsx(
1986
1992
  SimpleDataTable,
1987
1993
  {
1994
+ tableHeight,
1988
1995
  onRowClick,
1989
1996
  onRowHover,
1990
1997
  table,
@@ -1997,7 +2004,7 @@ var DataTable = ({
1997
2004
  emptyState
1998
2005
  }
1999
2006
  ),
2000
- /* @__PURE__ */ jsx(
2007
+ showBottomPagination && /* @__PURE__ */ jsx(
2001
2008
  BottomPagination,
2002
2009
  {
2003
2010
  total: totalRowCount ?? 0,
@@ -2029,7 +2036,10 @@ var TablePage = ({
2029
2036
  listMenuActions,
2030
2037
  onSelectionChange,
2031
2038
  config,
2032
- CustomHeader
2039
+ CustomHeader,
2040
+ showSearchInput = true,
2041
+ showBottomPagination = true,
2042
+ tableHeight = 600
2033
2043
  }) => {
2034
2044
  const [tableParams, setTableParams] = useState({
2035
2045
  skip: 0,
@@ -2046,11 +2056,14 @@ var TablePage = ({
2046
2056
  }, []);
2047
2057
  const { data, isLoading } = useQuery(getQueryOptions(tableParams));
2048
2058
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "sm", children: [
2049
- /* @__PURE__ */ jsx(Title, { order: 1, children: title }),
2059
+ title && /* @__PURE__ */ jsx(Title, { order: 1, children: title }),
2050
2060
  /* @__PURE__ */ jsx(
2051
2061
  DataTable,
2052
2062
  {
2063
+ showBottomPagination,
2064
+ tableHeight,
2053
2065
  emptyState,
2066
+ showSearchInput,
2054
2067
  table,
2055
2068
  onRowClick: (row) => onRowClick?.(row),
2056
2069
  onRowHover: (row) => onRowHover?.(row),