erp-pos-ecommerce-shared 0.1.2 → 0.1.3
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 +20 -2
- package/dist/components.js +38 -3
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/dist/queries.d.ts +3 -2
- package/dist/{shift.queries-CYXL5F1D.d.ts → shift.queries-DF8gfQOQ.d.ts} +1 -14
- package/dist/types-CiX8AkJA.d.ts +15 -0
- package/package.json +1 -1
package/dist/components.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React$1, { ReactNode } from 'react';
|
|
2
2
|
import { e as IField, b as IButton } from './form.interface-CqnTdmc8.js';
|
|
3
3
|
import { ReactFormExtendedApi, FormValidateOrFn, FormAsyncValidateOrFn } from '@tanstack/react-form';
|
|
4
|
-
import { UseMutationResult } from '@tanstack/react-query';
|
|
4
|
+
import { UseMutationResult, UseQueryOptions } from '@tanstack/react-query';
|
|
5
5
|
import { s as TblProductsImage, o as ITableFilterConfig, g as IFilterSelectOption } from './filters.interface-Cx-AXMPz.js';
|
|
6
6
|
import * as z from 'zod';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import { ColumnDef, Row, useReactTable } from '@tanstack/react-table';
|
|
9
9
|
import { D as DataTableConfig, S as ServerTableState } from './datatable.interface-DFSQWdXd.js';
|
|
10
|
+
import { T as TableQueryParams } from './types-CiX8AkJA.js';
|
|
10
11
|
|
|
11
12
|
interface CreateEditFormProps<T> {
|
|
12
13
|
fields: IField[];
|
|
@@ -260,4 +261,21 @@ interface TableSkeletonProps {
|
|
|
260
261
|
}
|
|
261
262
|
declare const TableSkeleton: ({ rows, columns, canCheck, withBorder, borderRadius, rowHeight, }: TableSkeletonProps) => react_jsx_runtime.JSX.Element;
|
|
262
263
|
|
|
263
|
-
|
|
264
|
+
/** Shape that the query must return for TablePage to work correctly. */
|
|
265
|
+
interface PaginatedResponse<TRow> {
|
|
266
|
+
data: TRow[];
|
|
267
|
+
total: number;
|
|
268
|
+
}
|
|
269
|
+
interface TablePageProps<TRow> {
|
|
270
|
+
/**
|
|
271
|
+
* Factory that receives the current pagination/filter params and returns
|
|
272
|
+
* the query options. Called every time the table state changes.
|
|
273
|
+
*/
|
|
274
|
+
getQueryOptions: (params: TableQueryParams) => UseQueryOptions<PaginatedResponse<TRow>>;
|
|
275
|
+
title: string;
|
|
276
|
+
columns: ColumnDef<TRow>[];
|
|
277
|
+
filters?: ITableFilterConfig[];
|
|
278
|
+
}
|
|
279
|
+
declare const TablePage: <TRow>({ getQueryOptions, title, columns, filters, }: TablePageProps<TRow>) => react_jsx_runtime.JSX.Element;
|
|
280
|
+
|
|
281
|
+
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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useMutation } from '@tanstack/react-query';
|
|
1
|
+
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { Text, Group, Box, rem, Button, ScrollArea, Image, ActionIcon, TagsInput, Switch, MultiSelect, Select, NumberInput, PasswordInput, TextInput, LoadingOverlay, Stepper, Flex, Container, Title, Card, Pagination, Stack, Paper, Table, Menu, Popover, Skeleton, Checkbox, UnstyledButton } from '@mantine/core';
|
|
3
3
|
import { useForm } from '@tanstack/react-form';
|
|
4
4
|
import axios, { isAxiosError } from 'axios';
|
|
5
|
-
import { useRef, useMemo, useState, useEffect } from 'react';
|
|
5
|
+
import { useRef, useMemo, useState, useEffect, useCallback } from 'react';
|
|
6
6
|
import { DatePickerInput, DatePicker } from '@mantine/dates';
|
|
7
7
|
import { Dropzone, IMAGE_MIME_TYPE } from '@mantine/dropzone';
|
|
8
8
|
import { modals } from '@mantine/modals';
|
|
@@ -1926,7 +1926,42 @@ var TableSkeleton = ({
|
|
|
1926
1926
|
) }, colIdx)) }, rowIdx)) })
|
|
1927
1927
|
] }) });
|
|
1928
1928
|
};
|
|
1929
|
+
var TablePage = ({
|
|
1930
|
+
getQueryOptions,
|
|
1931
|
+
title,
|
|
1932
|
+
columns,
|
|
1933
|
+
filters
|
|
1934
|
+
}) => {
|
|
1935
|
+
const [tableParams, setTableParams] = useState({
|
|
1936
|
+
skip: 0,
|
|
1937
|
+
limit: 10,
|
|
1938
|
+
query: void 0
|
|
1939
|
+
});
|
|
1940
|
+
const handleStateChange = useCallback((state) => {
|
|
1941
|
+
setTableParams({
|
|
1942
|
+
skip: state.pageIndex * state.pageSize,
|
|
1943
|
+
limit: state.pageSize,
|
|
1944
|
+
query: state.globalFilter || void 0,
|
|
1945
|
+
columnFilters: state.columnFilters.length > 0 ? state.columnFilters : void 0
|
|
1946
|
+
});
|
|
1947
|
+
}, []);
|
|
1948
|
+
const { data, isLoading } = useQuery(getQueryOptions(tableParams));
|
|
1949
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1950
|
+
/* @__PURE__ */ jsx(Title, { order: 1, children: title }),
|
|
1951
|
+
/* @__PURE__ */ jsx(
|
|
1952
|
+
DataTable,
|
|
1953
|
+
{
|
|
1954
|
+
totalRowCount: data?.total,
|
|
1955
|
+
data: data?.data ?? [],
|
|
1956
|
+
loading: isLoading,
|
|
1957
|
+
columns,
|
|
1958
|
+
filters,
|
|
1959
|
+
onStateChange: handleStateChange
|
|
1960
|
+
}
|
|
1961
|
+
)
|
|
1962
|
+
] });
|
|
1963
|
+
};
|
|
1929
1964
|
|
|
1930
|
-
export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, FilterSelect, FormGenerator, ImageForm, SearchInput, SimpleDataTable, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
|
|
1965
|
+
export { BottomPagination, CreateEditForm, DataTable, EmptyState, FilterDate, FilterSelect, FormGenerator, ImageForm, SearchInput, SimpleDataTable, TablePage, TableSkeleton, configureImageFormIcons, dateGteFilterFn, fieldGenerator, generateFormSchema };
|
|
1931
1966
|
//# sourceMappingURL=components.js.map
|
|
1932
1967
|
//# sourceMappingURL=components.js.map
|