erp-pos-ecommerce-shared 0.1.6 → 0.2.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/components.d.ts +24 -4
- package/dist/components.js +32 -16
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +4 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.js +32 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/components.d.ts
CHANGED
|
@@ -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
|
|
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 };
|
package/dist/components.js
CHANGED
|
@@ -9,7 +9,8 @@ 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 {
|
|
12
|
+
import { useMediaQuery } from '@mantine/hooks';
|
|
13
|
+
import { flexRender, useReactTable, getSortedRowModel, getPaginationRowModel, getCoreRowModel } from '@tanstack/react-table';
|
|
13
14
|
import { ArrowDown, ArrowUp, ArrowUpDown, FileX, X, Search, ChevronUp, ChevronDown, ListFilter, Check, CalendarDays, MoreVertical } from 'lucide-react';
|
|
14
15
|
|
|
15
16
|
// src/components/form/CreateEditForm.tsx
|
|
@@ -1114,6 +1115,8 @@ var BottomPagination = ({
|
|
|
1114
1115
|
onPageSizeChange,
|
|
1115
1116
|
onPageIndexChange
|
|
1116
1117
|
}) => {
|
|
1118
|
+
const isMobile = useMediaQuery("(max-width: 767px)");
|
|
1119
|
+
const isDesktop = useMediaQuery("(min-width: 992px)");
|
|
1117
1120
|
const totalPages = Math.ceil(total / pageSize);
|
|
1118
1121
|
const currentPage = pageIndex + 1;
|
|
1119
1122
|
const handlePageChange = (page) => {
|
|
@@ -1145,18 +1148,18 @@ var BottomPagination = ({
|
|
|
1145
1148
|
Pagination,
|
|
1146
1149
|
{
|
|
1147
1150
|
radius: "md",
|
|
1148
|
-
withEdges:
|
|
1151
|
+
withEdges: isDesktop,
|
|
1149
1152
|
total: totalPages,
|
|
1150
1153
|
value: currentPage,
|
|
1151
1154
|
onChange: handlePageChange,
|
|
1152
1155
|
size: "sm",
|
|
1153
|
-
siblings: 1,
|
|
1154
|
-
boundaries: 1,
|
|
1155
|
-
style: {
|
|
1156
|
+
siblings: !isMobile ? 1 : 0,
|
|
1157
|
+
boundaries: !isMobile ? 1 : 0,
|
|
1158
|
+
style: isDesktop ? {
|
|
1156
1159
|
position: "absolute",
|
|
1157
1160
|
left: "50%",
|
|
1158
1161
|
transform: "translateX(-50%)"
|
|
1159
|
-
}
|
|
1162
|
+
} : void 0
|
|
1160
1163
|
}
|
|
1161
1164
|
),
|
|
1162
1165
|
/* @__PURE__ */ jsxs(Group, { style: { marginLeft: "auto", alignItems: "center" }, children: [
|
|
@@ -1179,8 +1182,8 @@ var BottomPagination = ({
|
|
|
1179
1182
|
comboboxProps: { withinPortal: false }
|
|
1180
1183
|
}
|
|
1181
1184
|
),
|
|
1182
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "registros" }),
|
|
1183
|
-
total !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", ml: "xs", children: [
|
|
1185
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", visibleFrom: "sm", children: "registros" }),
|
|
1186
|
+
total !== void 0 && !isMobile && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", ml: "xs", children: [
|
|
1184
1187
|
"(",
|
|
1185
1188
|
total,
|
|
1186
1189
|
" en total)"
|
|
@@ -1263,10 +1266,12 @@ function useDataTable({
|
|
|
1263
1266
|
onColumnFiltersChange: setColumnFilters,
|
|
1264
1267
|
getCoreRowModel: getCoreRowModel(),
|
|
1265
1268
|
getPaginationRowModel: getPaginationRowModel(),
|
|
1269
|
+
getSortedRowModel: getSortedRowModel(),
|
|
1266
1270
|
enableRowSelection,
|
|
1267
1271
|
manualPagination: true,
|
|
1268
1272
|
manualFiltering: true,
|
|
1269
|
-
|
|
1273
|
+
/** Sort is applied client-side to the current page only (no server refetch) */
|
|
1274
|
+
manualSorting: false,
|
|
1270
1275
|
pageCount: totalRowCount != null ? Math.max(1, Math.ceil(totalRowCount / pagination.pageSize)) : void 0
|
|
1271
1276
|
});
|
|
1272
1277
|
const selectedRows = useMemo(
|
|
@@ -1462,7 +1467,7 @@ var TableBody = ({
|
|
|
1462
1467
|
},
|
|
1463
1468
|
cell.id
|
|
1464
1469
|
)),
|
|
1465
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
|
|
1470
|
+
(columnActions || listMenuActions) && /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
|
|
1466
1471
|
columnActions?.(row.original),
|
|
1467
1472
|
listMenuActions && /* @__PURE__ */ jsxs(Menu, { variant: "subtle", children: [
|
|
1468
1473
|
/* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", color: "gray", size: "sm", children: /* @__PURE__ */ jsx(MenuIcon, { size: 16 }) }) }),
|
|
@@ -1583,6 +1588,7 @@ var EmptyState = ({
|
|
|
1583
1588
|
);
|
|
1584
1589
|
};
|
|
1585
1590
|
var SimpleDataTable = ({
|
|
1591
|
+
tableHeight = 600,
|
|
1586
1592
|
table,
|
|
1587
1593
|
withBorder,
|
|
1588
1594
|
borderRadius = "md",
|
|
@@ -1609,7 +1615,7 @@ var SimpleDataTable = ({
|
|
|
1609
1615
|
const dataColumnsCount = table.getAllLeafColumns().length;
|
|
1610
1616
|
const hasActionsColumn = !!(columnActions || listMenuActions);
|
|
1611
1617
|
const headerBg = typeof headerBgColor === "string" ? headerBgColor : headerBgColor?.bgColor ?? defaultHeaderBgColor;
|
|
1612
|
-
return /* @__PURE__ */ jsx(Paper, { withBorder, radius: borderRadius, children: /* @__PURE__ */ jsx(ScrollArea, { h:
|
|
1618
|
+
return /* @__PURE__ */ jsx(Paper, { withBorder, radius: borderRadius, children: /* @__PURE__ */ jsx(ScrollArea, { h: tableHeight, type: "scroll", scrollbarSize: 8, children: /* @__PURE__ */ jsxs(
|
|
1613
1619
|
Table,
|
|
1614
1620
|
{
|
|
1615
1621
|
styles: {
|
|
@@ -1905,6 +1911,8 @@ var FilterDate = ({
|
|
|
1905
1911
|
);
|
|
1906
1912
|
};
|
|
1907
1913
|
var DataTable = ({
|
|
1914
|
+
showSearchInput = true,
|
|
1915
|
+
showBottomPagination = true,
|
|
1908
1916
|
data,
|
|
1909
1917
|
columns,
|
|
1910
1918
|
config,
|
|
@@ -1921,7 +1929,8 @@ var DataTable = ({
|
|
|
1921
1929
|
onRowHover,
|
|
1922
1930
|
emptyState,
|
|
1923
1931
|
table: ExternalTable,
|
|
1924
|
-
CustomHeader
|
|
1932
|
+
CustomHeader,
|
|
1933
|
+
tableHeight = 600
|
|
1925
1934
|
}) => {
|
|
1926
1935
|
const {
|
|
1927
1936
|
table: internalTable,
|
|
@@ -1949,7 +1958,7 @@ var DataTable = ({
|
|
|
1949
1958
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "md", children: [
|
|
1950
1959
|
/* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", children: [
|
|
1951
1960
|
/* @__PURE__ */ jsxs(Group, { gap: "md", wrap: "wrap", children: [
|
|
1952
|
-
mergedConfig.enableGlobalFilter && /* @__PURE__ */ jsx(
|
|
1961
|
+
showSearchInput && mergedConfig.enableGlobalFilter && /* @__PURE__ */ jsx(
|
|
1953
1962
|
SearchInput,
|
|
1954
1963
|
{
|
|
1955
1964
|
value: globalFilter,
|
|
@@ -1985,6 +1994,7 @@ var DataTable = ({
|
|
|
1985
1994
|
/* @__PURE__ */ jsx(
|
|
1986
1995
|
SimpleDataTable,
|
|
1987
1996
|
{
|
|
1997
|
+
tableHeight,
|
|
1988
1998
|
onRowClick,
|
|
1989
1999
|
onRowHover,
|
|
1990
2000
|
table,
|
|
@@ -1997,7 +2007,7 @@ var DataTable = ({
|
|
|
1997
2007
|
emptyState
|
|
1998
2008
|
}
|
|
1999
2009
|
),
|
|
2000
|
-
/* @__PURE__ */ jsx(
|
|
2010
|
+
showBottomPagination && /* @__PURE__ */ jsx(
|
|
2001
2011
|
BottomPagination,
|
|
2002
2012
|
{
|
|
2003
2013
|
total: totalRowCount ?? 0,
|
|
@@ -2029,7 +2039,10 @@ var TablePage = ({
|
|
|
2029
2039
|
listMenuActions,
|
|
2030
2040
|
onSelectionChange,
|
|
2031
2041
|
config,
|
|
2032
|
-
CustomHeader
|
|
2042
|
+
CustomHeader,
|
|
2043
|
+
showSearchInput = true,
|
|
2044
|
+
showBottomPagination = true,
|
|
2045
|
+
tableHeight = 600
|
|
2033
2046
|
}) => {
|
|
2034
2047
|
const [tableParams, setTableParams] = useState({
|
|
2035
2048
|
skip: 0,
|
|
@@ -2046,11 +2059,14 @@ var TablePage = ({
|
|
|
2046
2059
|
}, []);
|
|
2047
2060
|
const { data, isLoading } = useQuery(getQueryOptions(tableParams));
|
|
2048
2061
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "sm", children: [
|
|
2049
|
-
/* @__PURE__ */ jsx(Title, { order: 1, children: title }),
|
|
2062
|
+
title && /* @__PURE__ */ jsx(Title, { order: 1, children: title }),
|
|
2050
2063
|
/* @__PURE__ */ jsx(
|
|
2051
2064
|
DataTable,
|
|
2052
2065
|
{
|
|
2066
|
+
showBottomPagination,
|
|
2067
|
+
tableHeight,
|
|
2053
2068
|
emptyState,
|
|
2069
|
+
showSearchInput,
|
|
2054
2070
|
table,
|
|
2055
2071
|
onRowClick: (row) => onRowClick?.(row),
|
|
2056
2072
|
onRowHover: (row) => onRowHover?.(row),
|