@sqrzro/admin 2.1.0-r19.76 → 2.1.0-r19.78
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/DataTable/index.d.ts +4 -1
- package/dist/components/DataTable/index.js +1 -1
- package/dist/components/ListComponent/index.js +1 -5
- package/dist/components/Summary/index.d.ts +4 -1
- package/dist/components/Summary/index.js +1 -2
- package/dist/components/Table/index.d.ts +1 -1
- package/dist/components/Table/index.js +2 -2
- package/dist/components/TableComponent/index.d.ts +5 -4
- package/dist/components/TableComponent/index.js +5 -2
- package/dist/filters/index.d.ts +1 -0
- package/dist/filters/index.js +4 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
function DataTable({ data }) {
|
|
3
|
-
return (_jsx("table", { children: _jsx("tbody", { children:
|
|
3
|
+
return (_jsx("table", { children: _jsx("tbody", { children: data.map(({ title, value }, index) => (_jsxs("tr", { className: "odd:bg-slate-100", children: [_jsx("th", { className: "p-2 font-normal", children: title }), _jsx("td", { className: "p-2 text-right", children: value })] }, index))) }) }));
|
|
4
4
|
}
|
|
5
5
|
export default DataTable;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
3
|
import { MagnifyingGlassCircleIcon } from '@heroicons/react/24/outline';
|
|
4
4
|
import { Pagination } from '@sqrzro/components';
|
|
5
|
-
import { parseFilters } from '../../filters';
|
|
5
|
+
import { getPage, parseFilters } from '../../filters';
|
|
6
6
|
import checkHasFilters from '../../utility/check-has-filters';
|
|
7
7
|
import getSearchParams from '../../utility/get-search-params';
|
|
8
8
|
import { messages } from '../../utility/lang';
|
|
@@ -15,10 +15,6 @@ function defaultTransformer() {
|
|
|
15
15
|
title: '',
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function getPage(searchParams) {
|
|
19
|
-
const page = searchParams.get('page');
|
|
20
|
-
return page ? parseInt(page, 10) : null;
|
|
21
|
-
}
|
|
22
18
|
async function ListComponent({ emptyMessageProps, filterMap, fn, isMinimal, params, transformer, ...clientProps }) {
|
|
23
19
|
const searchParams = await getSearchParams();
|
|
24
20
|
const filters = parseFilters(searchParams, filterMap);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { tw } from '@sqrzro/components';
|
|
3
|
-
import { getEntries } from '@sqrzro/utility';
|
|
4
3
|
const colMap = {
|
|
5
4
|
1: 'grid-cols-1',
|
|
6
5
|
2: 'grid-cols-2',
|
|
@@ -10,6 +9,6 @@ const colMap = {
|
|
|
10
9
|
6: 'grid-cols-6',
|
|
11
10
|
};
|
|
12
11
|
function Summary({ data }) {
|
|
13
|
-
return (_jsx("dl", { className: tw('relative grid gap-6 before:absolute before:bottom-0 before:left-[calc(50%-50vw)] before:-z-10 before:-mb-16 before:h-96 before:w-screen before:bg-slate-800', colMap[Object.keys(data).length]), children:
|
|
12
|
+
return (_jsx("dl", { className: tw('relative grid gap-6 before:absolute before:bottom-0 before:left-[calc(50%-50vw)] before:-z-10 before:-mb-16 before:h-96 before:w-screen before:bg-slate-800', colMap[Object.keys(data).length]), children: data.map(({ title, value }, index) => (_jsxs("div", { className: "relative rounded border border-slate-500 p-4 font-semibold text-white", children: [_jsx("dt", { className: "text-slate-300", children: title }), _jsx("dd", { className: "flex min-h-8 items-center text-2xl", children: value })] }, index))) }));
|
|
14
13
|
}
|
|
15
14
|
export default Summary;
|
|
@@ -2,5 +2,5 @@ import type { TableComponentProps } from '../TableComponent';
|
|
|
2
2
|
export interface TableProps<Item extends object, Filters, Params> extends Omit<TableComponentProps<Item, Filters, Params>, 'actions' | 'hasFilters'> {
|
|
3
3
|
actions?: (data: Record<string, unknown>) => React.ReactNode;
|
|
4
4
|
}
|
|
5
|
-
declare function Table<Item extends object, Filters, Params>({ columns,
|
|
5
|
+
declare function Table<Item extends object, Filters, Params>({ columns, filterMap, ...props }: Readonly<TableProps<Item, Filters, Params>>): React.ReactElement;
|
|
6
6
|
export default Table;
|
|
@@ -4,7 +4,7 @@ import FilterBar from '../../filters/components/FilterBar';
|
|
|
4
4
|
import { createClientFilterMap } from '../../filters';
|
|
5
5
|
import Loader from '../Loader';
|
|
6
6
|
import TableComponent from '../TableComponent';
|
|
7
|
-
function Table({ columns,
|
|
8
|
-
return (_jsxs(Fragment, { children: [
|
|
7
|
+
function Table({ columns, filterMap, ...props }) {
|
|
8
|
+
return (_jsxs(Fragment, { children: [filterMap ? (_jsx(FilterBar, { columns: columns, map: createClientFilterMap(filterMap) })) : null, _jsx(Suspense, { fallback: _jsx("div", { className: "flex justify-center p-16", children: _jsx(Loader, {}) }), children: _jsx(TableComponent, { columns: columns, filterMap: filterMap, ...props }) })] }));
|
|
9
9
|
}
|
|
10
10
|
export default Table;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { EmptyMessageProps } from '@sqrzro/components';
|
|
2
2
|
import type { Errorable, Paginated } from '@sqrzro/interfaces';
|
|
3
3
|
import type { FilterMap } from '../../filters/interfaces';
|
|
4
|
+
import type { ListFnConfig } from '../ListComponent';
|
|
4
5
|
import type { TableClientComponentProps, TableItemObject } from '../TableClientComponent';
|
|
5
6
|
export interface TableComponentProps<Item, Filters, Params> extends Omit<TableClientComponentProps, 'data'> {
|
|
6
|
-
fn: (
|
|
7
|
+
fn: (config: ListFnConfig<Filters, Params>) => Promise<Errorable<Item[]>> | Promise<Errorable<Paginated<Item>>>;
|
|
7
8
|
emptyMessageProps?: EmptyMessageProps;
|
|
8
|
-
|
|
9
|
-
params?: Params;
|
|
9
|
+
filterMap?: FilterMap<Filters>;
|
|
10
|
+
params?: Params | null;
|
|
10
11
|
transformer?: (item: Item) => TableItemObject;
|
|
11
12
|
}
|
|
12
|
-
declare function TableComponent<Item extends object, Filters, Params>({ emptyMessageProps, fn, params, transformer, ...clientProps }: Readonly<TableComponentProps<Item, Filters, Params>>): Promise<React.ReactElement>;
|
|
13
|
+
declare function TableComponent<Item extends object, Filters, Params>({ emptyMessageProps, filterMap, fn, params, transformer, ...clientProps }: Readonly<TableComponentProps<Item, Filters, Params>>): Promise<React.ReactElement>;
|
|
13
14
|
export default TableComponent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { MagnifyingGlassCircleIcon } from '@heroicons/react/24/outline';
|
|
3
3
|
import { EmptyMessage, Pagination } from '@sqrzro/components';
|
|
4
|
+
import { getPage, parseFilters } from '../../filters';
|
|
4
5
|
import checkHasFilters from '../../utility/check-has-filters';
|
|
5
6
|
import getSearchParams from '../../utility/get-search-params';
|
|
6
7
|
import { messages } from '../../utility/lang';
|
|
@@ -13,9 +14,11 @@ function defaultTransformer(item) {
|
|
|
13
14
|
...item,
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
|
-
async function TableComponent({ emptyMessageProps, fn, params, transformer, ...clientProps }) {
|
|
17
|
+
async function TableComponent({ emptyMessageProps, filterMap, fn, params, transformer, ...clientProps }) {
|
|
17
18
|
const searchParams = await getSearchParams();
|
|
18
|
-
const
|
|
19
|
+
const filters = parseFilters(searchParams, filterMap);
|
|
20
|
+
const page = getPage(searchParams);
|
|
21
|
+
const [response, error] = await fn({ filters, params: params || null, page });
|
|
19
22
|
if (error) {
|
|
20
23
|
throw error;
|
|
21
24
|
}
|
package/dist/filters/index.d.ts
CHANGED
|
@@ -14,4 +14,5 @@ interface FilterReturn {
|
|
|
14
14
|
export declare function filter(): FilterReturn;
|
|
15
15
|
export declare function createClientFilterMap<T>(map: FilterMap<T>): ClientFilterMap<T>;
|
|
16
16
|
export declare function parseFilters<T>(searchParams: URLSearchParams, map?: FilterMap<T> | null): Partial<T> | null;
|
|
17
|
+
export declare function getPage(searchParams: URLSearchParams): number | null;
|
|
17
18
|
export {};
|
package/dist/filters/index.js
CHANGED